Loading...
Searching...
No Matches
aerospike_info.h
Go to the documentation of this file.
1/*
2 * Copyright 2008-2022 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/**
20 * @defgroup info_operations Info Operations
21 * @ingroup client_operations
22 *
23 * The Info API provides the ability to query server node(s) for statistics and set dynamically
24 * configurable variables.
25 */
26
27#include <aerospike/aerospike.h>
29#include <aerospike/as_error.h>
30#include <aerospike/as_info.h>
31#include <aerospike/as_node.h>
32#include <aerospike/as_policy.h>
33#include <aerospike/as_status.h>
34
35#ifdef __cplusplus
36extern "C" {
37#endif
38
39/******************************************************************************
40 * TYPES
41 *****************************************************************************/
42
43/**
44 * Callback for aerospike_info_foreach()
45 *
46 * @param err The status and possible error information for the info request.
47 * @param node The node which provided the response.
48 * @param req The initial request.
49 * @param res The response to the info request.
50 * @param udata The udata provided to the aerospike_info_foreach()
51 *
52 * @return TRUE to continue to the next info response. FALSE to stop processing.
53 *
54 * @ingroup info_operations
55 */
56typedef bool (*aerospike_info_foreach_callback)(const as_error* err, const as_node* node, const char* req, char* res, void* udata);
57
58/******************************************************************************
59 * FUNCTIONS
60 *****************************************************************************/
61
62/**
63 * Send an info request to a specific server node. The response must be freed by the caller on success.
64 *
65 * ~~~~~~~~~~{.c}
66 * char* res = NULL;
67 * if (aerospike_info_node(&as, &err, NULL, node, "info", &res) != AEROSPIKE_OK) {
68 * // handle error
69 * }
70 * else {
71 * // handle response
72 * free(res);
73 * }
74 * ~~~~~~~~~~
75 *
76 * @param as The aerospike instance to use for this operation.
77 * @param err The as_error to be populated if an error occurs.
78 * @param policy The policy to use for this operation. If NULL, then the default policy will be used.
79 * @param node The server node to send the request to.
80 * @param req The info request to send.
81 * @param res The response from the node. The response will be a NULL terminated string,
82 * allocated by the function, and must be freed by the caller.
83 *
84 * @return AEROSPIKE_OK on success. Otherwise an error.
85 *
86 * @ingroup info_operations
87 */
90 aerospike* as, as_error* err, const as_policy_info* policy, as_node* node,
91 const char* req, char** res
92 );
93
94/**
95 * Asynchronously send an info request to a specific server node.
96 *
97 * ~~~~~~~~~~{.c}
98 * void my_listener(as_error* err, char* response, void* udata, as_event_loop* event_loop)
99 * {
100 * if (err) {
101 * printf("Command failed: %d %s\n", err->code, err->message);
102 * return;
103 * }
104 * // Process response
105 * // Do not free response because the calling function will do that for you.
106 * }
107 *
108 * aerospike_info_node_async(&as, &err, NULL, node, "info", my_listener, NULL, NULL);
109 * ~~~~~~~~~~
110 *
111 * @param as The aerospike instance to use for this operation.
112 * @param err The as_error to be populated if an error occurs.
113 * @param policy The info policy. If NULL, the default info policy will be used.
114 * @param node The server node to send the request to.
115 * @param req The info request to send.
116 * @param listener User function to be called with command results.
117 * @param udata User data to be forwarded to user callback.
118 * @param event_loop Event loop assigned to run this command. If NULL, an event loop will be
119 * chosen by round-robin.
120 *
121 * @return AEROSPIKE_OK on success. Otherwise an error.
122 *
123 * @ingroup info_operations
124 */
125static inline as_status
127 aerospike* as, as_error* err, as_policy_info* policy, as_node* node, const char* req,
128 as_async_info_listener listener, void* udata, as_event_loop* event_loop
129 )
130{
131 return as_info_command_node_async(as, err, policy, node, req, listener, udata, event_loop);
132}
133
134/**
135 * Send an info request to a specific host. The response must be freed by the caller on success.
136 *
137 * ~~~~~~~~~~{.c}
138 * char* res = NULL;
139 * if (aerospike_info_host(&as, &err, NULL, "127.0.0.1", 3000, "info", &res) != AEROSPIKE_OK) {
140 * // handle error
141 * }
142 * else {
143 * // handle response
144 * free(res);
145 * res = NULL;
146 * }
147 * ~~~~~~~~~~
148 *
149 * This function does not support TLS nor the new user authentication protocol.
150 *
151 * @deprecated Use aerospike_info_node() or aerospike_info_any() instead.
152 *
153 * @param as The aerospike instance to use for this operation.
154 * @param err The as_error to be populated if an error occurs.
155 * @param policy The policy to use for this operation. If NULL, then the default policy will be used.
156 * @param hostname The IP address or hostname to send the request to.
157 * @param port The port to send the request to.
158 * @param req The info request to send.
159 * @param res The response from the node. The response will be a NULL terminated string,
160 * allocated by the function, and must be freed by the caller.
161 *
162 * @return AEROSPIKE_OK on success. Otherwise an error.
163 *
164 * @ingroup info_operations
165 */
168 aerospike* as, as_error* err, const as_policy_info* policy, const char* hostname, uint16_t port,
169 const char* req, char** res
170 );
171
172/**
173 * Send an info request to a specific socket address. The response must be freed by the caller on success.
174 *
175 * ~~~~~~~~~~{.c}
176 * char* res = NULL;
177 * if (aerospike_info_socket_address(&as, &err, NULL, &sa_in, "info", &res) != AEROSPIKE_OK) {
178 * // handle error
179 * }
180 * else {
181 * // handle response
182 * free(res);
183 * res = NULL;
184 * }
185 * ~~~~~~~~~~
186 *
187 * This function does not support TLS, IPv6 nor the new user authentication protocol.
188 *
189 * @deprecated Use aerospike_info_node() or aerospike_info_any() instead.
190 *
191 * @param as The aerospike instance to use for this operation.
192 * @param err The as_error to be populated if an error occurs.
193 * @param policy The policy to use for this operation. If NULL, then the default policy will be used.
194 * @param sa_in The IP address and port to send the request to.
195 * @param req The info request to send.
196 * @param res The response from the node. The response will be a NULL terminated string,
197 * allocated by the function, and must be freed by the caller.
198 *
199 * @return AEROSPIKE_OK on success. Otherwise an error.
200 *
201 * @ingroup info_operations
202 */
205 aerospike* as, as_error* err, const as_policy_info* policy, struct sockaddr_in* sa_in,
206 const char* req, char** res
207 );
208
209/**
210 * Send an info request to a node in the cluster. If node request fails, send request to the next
211 * node in the cluster. Repeat until the node request succeeds. The response must be freed by
212 * the caller on success.
213 *
214 * ~~~~~~~~~~{.c}
215 * char* res = NULL;
216 * if (aerospike_info_any(&as, &err, NULL, "info", &res) != AEROSPIKE_OK) {
217 * // handle error
218 * }
219 * else {
220 * // handle response
221 * free(res);
222 * res = NULL;
223 * }
224 * ~~~~~~~~~~
225 *
226 * @param as The aerospike instance to use for this operation.
227 * @param err The as_error to be populated if an error occurs.
228 * @param policy The policy to use for this operation. If NULL, then the default policy will be used.
229 * @param req The info request to send.
230 * @param res The response from the node. The response will be a NULL terminated string,
231 * allocated by the function, and must be freed by the caller.
232 *
233 * @return AEROSPIKE_OK on success. Otherwise an error.
234 *
235 * @ingroup info_operations
236 */
239 aerospike* as, as_error* err, const as_policy_info* policy, const char* req, char** res
240 );
241
242/**
243 * Send an info request to the entire cluster.
244 *
245 * ~~~~~~~~~~{.c}
246 * if (aerospike_info_foreach(&as, &err, NULL, "info", callback, NULL) != AEROSPIKE_OK) {
247 * // handle error
248 * }
249 * ~~~~~~~~~~
250 *
251 * The callback takes a response string. The caller should not free this string.
252 *
253 * ~~~~~~~~~~{.c}
254 * bool callback(const as_error* err, const as_node * node, const char* req, char* res, void* udata) {
255 * // handle response
256 * }
257 * ~~~~~~~~~~
258 *
259 * @param as The aerospike instance to use for this operation.
260 * @param err The as_error to be populated if an error occurs.
261 * @param policy The policy to use for this operation. If NULL, then the default policy will be used.
262 * @param req The info request to send.
263 * @param callback The function to call when a response is received.
264 * @param udata User-data to send to the callback.
265 *
266 * @return AEROSPIKE_OK on success. Otherwise an error.
267 *
268 * @ingroup info_operations
269 */
272 aerospike* as, as_error* err, const as_policy_info* policy, const char* req,
273 aerospike_info_foreach_callback callback, void* udata
274 );
275
276#ifdef __cplusplus
277} // end extern "C"
278#endif
AS_EXTERN as_status as_info_command_node_async(aerospike *as, as_error *err, as_policy_info *policy, as_node *node, const char *command, as_async_info_listener listener, void *udata, as_event_loop *event_loop)
void(* as_async_info_listener)(as_error *err, char *response, void *udata, as_event_loop *event_loop)
Definition as_listener.h:85
as_status
Definition as_status.h:30
#define AS_EXTERN
Definition as_std.h:25
AS_EXTERN as_status aerospike_info_foreach(aerospike *as, as_error *err, const as_policy_info *policy, const char *req, aerospike_info_foreach_callback callback, void *udata)
bool(* aerospike_info_foreach_callback)(const as_error *err, const as_node *node, const char *req, char *res, void *udata)
AS_EXTERN as_status aerospike_info_any(aerospike *as, as_error *err, const as_policy_info *policy, const char *req, char **res)
static as_status aerospike_info_node_async(aerospike *as, as_error *err, as_policy_info *policy, as_node *node, const char *req, as_async_info_listener listener, void *udata, as_event_loop *event_loop)
AS_EXTERN as_status aerospike_info_socket_address(aerospike *as, as_error *err, const as_policy_info *policy, struct sockaddr_in *sa_in, const char *req, char **res)
AS_EXTERN as_status aerospike_info_node(aerospike *as, as_error *err, const as_policy_info *policy, as_node *node, const char *req, char **res)
AS_EXTERN as_status aerospike_info_host(aerospike *as, as_error *err, const as_policy_info *policy, const char *hostname, uint16_t port, const char *req, char **res)