All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
aerospike_info.h
Go to the documentation of this file.
1 /*
2  * Copyright 2008-2014 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 an Aerospike cluster for
24  * information.
25  *
26  * The following API are provided:
27  * - aerospike_info_host() - Query a single host in the cluster.
28  * - aerospike_info_foreach() - Query every host in the cluster.
29  *
30  */
31 
32 #include <aerospike/aerospike.h>
34 #include <aerospike/as_error.h>
35 #include <aerospike/as_node.h>
36 #include <aerospike/as_policy.h>
37 #include <aerospike/as_status.h>
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 res The response to the info request.
49  * @param udata The udata provided to the aerospike_info_foreach()
50  *
51  * @return TRUE to continue to the next info response. FALSE to stop processing.
52  *
53  * @ingroup info_operations
54  */
55 typedef bool (* aerospike_info_foreach_callback)(const as_error * err, const as_node * node, const char * req, char * res, void * udata);
56 
57 /******************************************************************************
58  * FUNCTIONS
59  *****************************************************************************/
60 
61 /**
62  * Send an info request to a specific host. The response must be freed by the caller on success.
63  *
64  * ~~~~~~~~~~{.c}
65  * char * res = NULL;
66  * if ( aerospike_info_host(&as, &err, NULL, "127.0.0.1", 3000, "info", &res) != AEROSPIKE_OK ) {
67  * // handle error
68  * }
69  * else {
70  * // handle response
71  * free(res);
72  * res = NULL;
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 addr The IP address or hostname to send the request to.
80  * @param port The port to send the request to.
81  * @param req The info request to send.
82  * @param res The response from the node. The response will be a NULL terminated string, 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  */
89  aerospike * as, as_error * err, const as_policy_info * policy,
90  const char * addr, uint16_t port, const char * req,
91  char ** res
92  );
93 
94 /**
95  * Send an info request to the entire cluster.
96  *
97  * ~~~~~~~~~~{.c}
98  * if ( aerospike_info_foreach(&as, &err, NULL, "info", callback, NULL) != AEROSPIKE_OK ) {
99  * // handle error
100  * }
101  * ~~~~~~~~~~
102  *
103  * The callback takes a response string. The caller should not free this string.
104  *
105  * ~~~~~~~~~~{.c}
106  * bool callback(const as_error * err, const char * node, char * res, void * udata) {
107  * // handle response
108  * }
109  * ~~~~~~~~~~
110  *
111  *
112  * @param as The aerospike instance to use for this operation.
113  * @param err The as_error to be populated if an error occurs.
114  * @param policy The policy to use for this operation. If NULL, then the default policy will be used.
115  * @param req The info request to send.
116  * @param callback The function to call when a response is received.
117  * @param udata User-data to send to the callback.
118  *
119  * @return AEROSPIKE_OK on success. Otherwise an error.
120  *
121  * @ingroup info_operations
122  */
124  aerospike * as, as_error * err, const as_policy_info * policy,
125  const char * req,
126  aerospike_info_foreach_callback callback, void * udata
127  );
as_status
Definition: as_status.h:26
bool(* aerospike_info_foreach_callback)(const as_error *err, const as_node *node, const char *req, char *res, void *udata)
as_status aerospike_info_host(aerospike *as, as_error *err, const as_policy_info *policy, const char *addr, uint16_t port, const char *req, char **res)
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)