Main Page
Modules
Data Structures
Files
File List
Globals
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
aerospike
aerospike_info.h
Go to the documentation of this file.
1
/******************************************************************************
2
* Copyright 2008-2013 by Aerospike.
3
*
4
* Permission is hereby granted, free of charge, to any person obtaining a copy
5
* of this software and associated documentation files (the "Software"), to
6
* deal in the Software without restriction, including without limitation the
7
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8
* sell copies of the Software, and to permit persons to whom the Software is
9
* furnished to do so, subject to the following conditions:
10
*
11
* The above copyright notice and this permission notice shall be included in
12
* all copies or substantial portions of the Software.
13
*
14
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20
* IN THE SOFTWARE.
21
*****************************************************************************/
22
23
/**
24
* @defgroup info_operations Info Operations
25
* @ingroup client_operations
26
*
27
* The Info API provides the ability to query an Aerospike cluster for
28
* information.
29
*
30
* The following API are provided:
31
* - aerospike_info_host() - Query a single host in the cluster.
32
* - aerospike_info_foreach() - Query every host in the cluster.
33
*
34
*/
35
36
#pragma once
37
38
#include <
aerospike/aerospike.h
>
39
#include <
aerospike/aerospike_scan.h
>
40
#include <
aerospike/as_error.h
>
41
#include <
aerospike/as_node.h
>
42
#include <
aerospike/as_policy.h
>
43
#include <
aerospike/as_status.h
>
44
45
/******************************************************************************
46
* TYPES
47
*****************************************************************************/
48
49
/**
50
* Callback for aerospike_info_foreach()
51
*
52
* @param err The status and possible error information for the info request.
53
* @param node The node which provided the response.
54
* @param res The response to the info request. The response must be freed by the caller.
55
* @param udata The udata provided to the aerospike_info_foreach()
56
*
57
* @return TRUE to continue to the next info response. FALSE to stop processing.
58
*
59
* @ingroup info_operations
60
*/
61
typedef
bool (*
aerospike_info_foreach_callback
)(
const
as_error
* err,
const
as_node
* node,
const
char
* req,
char
* res,
void
* udata);
62
63
/******************************************************************************
64
* FUNCTIONS
65
*****************************************************************************/
66
67
/**
68
* Send an info request to a specific host. The response must be freed by the caller.
69
*
70
* ~~~~~~~~~~{.c}
71
* char * res = NULL;
72
* if ( aerospike_info_host(&as, &err, NULL, "127.0.0.1", 3000, "info", &res) != AEROSPIKE_OK ) {
73
* // handle error
74
* }
75
* else {
76
* // handle response
77
* free(res);
78
* res = NULL;
79
* }
80
* ~~~~~~~~~~
81
*
82
* @param as The aerospike instance to use for this operation.
83
* @param err The as_error to be populated if an error occurs.
84
* @param policy The policy to use for this operation. If NULL, then the default policy will be used.
85
* @param addr The IP address or hostname to send the request to.
86
* @param port The port to send the request to.
87
* @param req The info request to send.
88
* @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.
89
*
90
* @return AEROSPIKE_OK on success. Otherwise an error.
91
*
92
* @ingroup info_operations
93
*/
94
as_status
aerospike_info_host
(
95
aerospike
* as,
as_error
* err,
const
as_policy_info
* policy,
96
const
char
* addr, uint16_t port,
const
char
* req,
97
char
** res
98
);
99
100
/**
101
* Send an info request to the entire cluster.
102
*
103
* ~~~~~~~~~~{.c}
104
* if ( aerospike_info_foreach(&as, &err, NULL, "info", callback, NULL) != AEROSPIKE_OK ) {
105
* // handle error
106
* }
107
* ~~~~~~~~~~
108
*
109
* The callback takes a response string, which the caller is reponsible for freeing.
110
*
111
* ~~~~~~~~~~{.c}
112
* bool callback(const as_error * err, const char * node, char * res, void * udata) {
113
* // handle response
114
* free(res);
115
* res = NULL;
116
* }
117
* ~~~~~~~~~~
118
*
119
*
120
* @param as The aerospike instance to use for this operation.
121
* @param err The as_error to be populated if an error occurs.
122
* @param policy The policy to use for this operation. If NULL, then the default policy will be used.
123
* @param req The info request to send.
124
* @param callback The function to call when a response is received.
125
* @param udata User-data to send to the callback.
126
*
127
* @return AEROSPIKE_OK on success. Otherwise an error.
128
*
129
* @ingroup info_operations
130
*/
131
as_status
aerospike_info_foreach
(
132
aerospike
* as,
as_error
* err,
const
as_policy_info
* policy,
133
const
char
* req,
134
aerospike_info_foreach_callback
callback,
void
* udata
135
);