All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
as_peers.h
Go to the documentation of this file.
1 /*
2  * Copyright 2008-2021 Aerospike, Inc.
3  *
4  * Portions may be licensed to Aerospike, Inc. under one or more contributor
5  * license agreements.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
8  * use this file except in compliance with the License. You may obtain a copy of
9  * the License at http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14  * License for the specific language governing permissions and limitations under
15  * the License.
16  */
17 #pragma once
18 
19 #include <aerospike/as_std.h>
20 #include <aerospike/as_status.h>
21 #include <aerospike/as_error.h>
22 #include <aerospike/as_host.h>
23 #include <aerospike/as_vector.h>
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 /******************************************************************************
30  * TYPES
31  *****************************************************************************/
32 
33 typedef struct as_peers_s {
34  as_vector /* as_node* */ nodes;
35  as_vector /* as_host */ invalid_hosts;
36  uint32_t refresh_count;
38 } as_peers;
39 
40 struct as_cluster_s;
41 struct as_node_s;
42 
43 /******************************************************************************
44  * FUNCTIONS
45  *****************************************************************************/
46 
47 struct as_node_s*
48 as_peers_find_local_node(as_vector* nodes, const char* name);
49 
52  as_peers* peers, as_error* err, struct as_cluster_s* cluster, struct as_node_s* node, char* buf
53  );
54 
55 bool
57 
58 static inline void
60 {
61  as_host* trg = as_vector_reserve(&peers->invalid_hosts);
62  as_host_copy(host, trg);
63 }
64 
65 static inline uint32_t
67 {
68  return peers->invalid_hosts.size;
69 }
70 
71 #ifdef __cplusplus
72 } // end extern "C"
73 #endif
static void * as_vector_reserve(as_vector *vector)
Definition: as_vector.h:171
struct as_node_s * as_peers_find_local_node(as_vector *nodes, const char *name)
static void as_peers_add_invalid_host(as_peers *peers, as_host *host)
Definition: as_peers.h:59
as_status
Definition: as_status.h:30
static void as_host_copy(const as_host *src, as_host *trg)
Definition: as_host.h:66
as_status as_peers_parse_peers(as_peers *peers, as_error *err, struct as_cluster_s *cluster, struct as_node_s *node, char *buf)
as_vector nodes
Definition: as_peers.h:34
uint32_t refresh_count
Definition: as_peers.h:36
as_vector invalid_hosts
Definition: as_peers.h:35
static uint32_t as_peers_invalid_count(as_peers *peers)
Definition: as_peers.h:66
bool gen_changed
Definition: as_peers.h:37
uint32_t size
Definition: as_vector.h:48
bool as_peers_find_invalid_host(as_peers *peers, as_host *host)