Skip to content

Commit 658bb07

Browse files
committed
[CLIENT-2219] Remove deprecated client.info()
1 parent 9172fc4 commit 658bb07

File tree

9 files changed

+4
-494
lines changed

9 files changed

+4
-494
lines changed

aerospike-stubs/aerospike.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,6 @@ class Client:
348348
def index_map_values_create(self, ns: str, set: str, bin: str, index_datatype, name: str, policy: dict = ...) -> None: ...
349349
def index_remove(self, ns, name: str, policy: dict = ...) -> None: ...
350350
def index_string_create(self, ns: str, set: str, bin: str, name: str, policy: dict = ...) -> None: ...
351-
def info(self, command, hosts = ..., policy: dict = ...) -> dict: ...
352351
def info_all(self, command: str, policy: dict = ...) -> dict: ...
353352
def info_random_node(self, command: str, policy: dict = ...) -> str: ...
354353
def info_single_node(self, command: str, host: str, policy: dict = ...) -> str: ...

doc/client.rst

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -778,43 +778,6 @@ Info Operations
778778

779779
.. versionchanged:: 6.0.0
780780

781-
.. method:: info(command[, hosts[, policy: dict]]) -> {}
782-
783-
.. deprecated:: 3.0.0
784-
Use :meth:`info_all` to send a request to the entire cluster.
785-
786-
Send an info command to all nodes in the cluster, and optionally filter responses to only include certain nodes.
787-
788-
:param str command: the info command. See `Info Command Reference <http://www.aerospike.com/docs/reference/info/>`_
789-
:param list hosts: a :class:`list` containing ``(address, port)`` tuples. If specified, only send the command to these hosts. Example: ``[('127.0.0.1', 3000)]``
790-
:param dict policy: optional :ref:`aerospike_info_policies`.
791-
:rtype: :class:`dict`
792-
:raises: a subclass of :exc:`~aerospike.exception.AerospikeError`.
793-
794-
.. code-block:: python
795-
796-
response = client.info(command)
797-
client.close()
798-
# {'BB9581F41290C00': (None, '127.0.0.1:3000\n'), 'BC3581F41290C00': (None, '127.0.0.1:3010\n')}
799-
800-
.. note::
801-
Sending requests to specific nodes can be better handled with a simple Python function such as:
802-
803-
.. code-block:: python
804-
805-
def info_to_host_list(client, request, hosts, policy=None):
806-
output = {}
807-
for host in hosts:
808-
try:
809-
response = client.info_single_node(request, host, policy)
810-
output[host] = response
811-
except Exception as e:
812-
# Handle the error gracefully here
813-
output[host] = e
814-
return output
815-
816-
.. versionchanged:: 3.0.0
817-
818781
.. method:: set_xdr_filter(data_center, namespace, expression_filter[, policy: dict]) -> str
819782

820783
Set the cluster's xdr filter using an Aerospike expression.

examples/client/ttl.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ def test_params_for_stanza(p, contx, is_namespace):
183183
info_code = "set-config:context=" + \
184184
contx + ";" + t[0] + "=" + str(t[1])
185185
try:
186-
v = list(client.info(info_code).items())
186+
v = list(client.info_all(info_code).items())
187187
res = v[0][1][1]
188188
if res != "ok\n":
189189
print(
@@ -319,7 +319,7 @@ def write_records():
319319
print("service parameters passed")
320320

321321
print("getting initial ttl values")
322-
info = client.info("namespace/" + options.namespace)
322+
info = client.info_all("namespace/" + options.namespace)
323323
default_ttl = 0
324324
max_ttl = 0
325325
for key, value in list(info.items()):

src/include/client.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -556,15 +556,6 @@ PyObject *AerospikeClient_GetExpressionBase64(AerospikeClient *self,
556556
PyObject *AerospikeClient_InfoAll(AerospikeClient *self, PyObject *args,
557557
PyObject *kwds);
558558

559-
/**
560-
* Perform info operation on the database.
561-
*
562-
* client.info((x,y,z))
563-
*
564-
*/
565-
PyObject *AerospikeClient_Info(AerospikeClient *self, PyObject *args,
566-
PyObject *kwds);
567-
568559
/**
569560
* Perform get nodes operation on the database.
570561
*

src/main/client/info.c

Lines changed: 0 additions & 280 deletions
Original file line numberDiff line numberDiff line change
@@ -44,182 +44,6 @@ static PyObject *AerospikeClient_InfoAll_Invoke(AerospikeClient *self,
4444
PyObject *py_policy);
4545

4646
static PyObject *get_formatted_info_response(const char *response);
47-
/**
48-
********************************************************************************************************
49-
* Macros for Info API.
50-
********************************************************************************************************
51-
*/
52-
#define INET_ADDRSTRLEN 16
53-
#define INET6_ADDRSTRLEN 46
54-
#define INET_PORT 5
55-
#define IP_PORT_SEPARATOR_LEN 1
56-
// Add 2 to the length to facilitate [] around the edges
57-
#define IP_PORT_MAX_LEN INET6_ADDRSTRLEN + INET_PORT + IP_PORT_SEPARATOR_LEN + 2
58-
59-
/**
60-
*******************************************************************************************************
61-
* Callback for as_info_foreach().
62-
*
63-
* @param err The as_error to be populated by the function
64-
* with the encountered error if any.
65-
* @param node The current as_node object for which the
66-
* callback is fired by c client.
67-
* @param req The info request string.
68-
* @param res The info response string for current node.
69-
* @pram udata The callback udata containing the host_lookup
70-
* array and the return zval to be populated with
71-
* an entry for current node's info response with
72-
* the node's ID as the key.
73-
*
74-
* Returns true if callback is successful, Otherwise false.
75-
*******************************************************************************************************
76-
*/
77-
static bool AerospikeClient_Info_each(as_error *err, const as_node *node,
78-
const char *req, char *res, void *udata)
79-
{
80-
PyObject *py_err = NULL;
81-
PyObject *py_ustr = NULL;
82-
PyObject *py_out = NULL;
83-
foreach_callback_info_udata *udata_ptr =
84-
(foreach_callback_info_udata *)udata;
85-
as_address *addr = NULL;
86-
87-
// Need to make sure we have the GIL since we're back in python land now
88-
PyGILState_STATE gil_state = PyGILState_Ensure();
89-
90-
if (err && err->code != AEROSPIKE_OK) {
91-
as_error_update(err, err->code, NULL);
92-
goto CLEANUP;
93-
}
94-
else if (res) {
95-
char *out = strchr(res, '\t');
96-
if (out) {
97-
out++;
98-
py_out = PyUnicode_FromString(out);
99-
}
100-
else {
101-
py_out = PyUnicode_FromString(res);
102-
}
103-
}
104-
105-
if (!py_err) {
106-
Py_INCREF(Py_None);
107-
py_err = Py_None;
108-
}
109-
110-
if (!py_out) {
111-
Py_INCREF(Py_None);
112-
py_out = Py_None;
113-
}
114-
115-
PyObject *py_res = PyTuple_New(2);
116-
PyTuple_SetItem(py_res, 0, py_err);
117-
PyTuple_SetItem(py_res, 1, py_out);
118-
119-
if (udata_ptr->host_lookup_p) {
120-
PyObject *py_hosts = (PyObject *)udata_ptr->host_lookup_p;
121-
if (py_hosts && PyList_Check(py_hosts)) {
122-
addr = as_node_get_address((as_node *)node);
123-
int size = (int)PyList_Size(py_hosts);
124-
for (int i = 0; i < size; i++) {
125-
char *host_addr = NULL;
126-
int port = -1;
127-
PyObject *py_host = PyList_GetItem(py_hosts, i);
128-
if (PyTuple_Check(py_host) && PyTuple_Size(py_host) == 2) {
129-
PyObject *py_addr = PyTuple_GetItem(py_host, 0);
130-
PyObject *py_port = PyTuple_GetItem(py_host, 1);
131-
if (PyUnicode_Check(py_addr)) {
132-
py_ustr = PyUnicode_AsUTF8String(py_addr);
133-
host_addr = PyBytes_AsString(py_ustr);
134-
}
135-
else {
136-
as_error_update(&udata_ptr->error, AEROSPIKE_ERR_PARAM,
137-
"Host address is of type incorrect");
138-
if (py_res) {
139-
Py_DECREF(py_res);
140-
}
141-
PyGILState_Release(gil_state);
142-
return false;
143-
}
144-
if (PyLong_Check(py_port)) {
145-
port = (uint16_t)PyLong_AsLong(py_port);
146-
}
147-
else {
148-
break;
149-
}
150-
char ip_port[IP_PORT_MAX_LEN];
151-
// If the address is longer than the max length of an ipv6 address, raise an error and exit
152-
if (strnlen(host_addr, INET6_ADDRSTRLEN) >=
153-
INET6_ADDRSTRLEN) {
154-
as_error_update(&udata_ptr->error, AEROSPIKE_ERR_PARAM,
155-
"Host address is too long");
156-
if (py_res) {
157-
Py_DECREF(py_res);
158-
}
159-
goto CLEANUP;
160-
}
161-
sprintf(ip_port, "%s:%d", host_addr, port);
162-
if (!strcmp(ip_port, addr->name)) {
163-
PyObject *py_nodes = (PyObject *)udata_ptr->udata_p;
164-
PyDict_SetItemString(py_nodes, node->name, py_res);
165-
}
166-
else {
167-
sprintf(ip_port, "[%s]:%d", host_addr, port);
168-
if (!strcmp(ip_port, addr->name)) {
169-
PyObject *py_nodes = (PyObject *)udata_ptr->udata_p;
170-
PyDict_SetItemString(py_nodes, node->name, py_res);
171-
}
172-
}
173-
}
174-
175-
if (py_ustr) {
176-
Py_DECREF(py_ustr);
177-
py_ustr = NULL;
178-
}
179-
}
180-
}
181-
else if (!PyList_Check(py_hosts)) {
182-
as_error_update(&udata_ptr->error, AEROSPIKE_ERR_PARAM,
183-
"Hosts should be specified in a list.");
184-
if (py_res) {
185-
Py_DECREF(py_res);
186-
}
187-
goto CLEANUP;
188-
}
189-
}
190-
else {
191-
PyObject *py_nodes = (PyObject *)udata_ptr->udata_p;
192-
PyDict_SetItemString(py_nodes, node->name, py_res);
193-
}
194-
195-
Py_DECREF(py_res);
196-
197-
CLEANUP:
198-
if (py_ustr) {
199-
Py_DECREF(py_ustr);
200-
}
201-
if (udata_ptr->error.code != AEROSPIKE_OK) {
202-
PyObject *py_err = NULL;
203-
error_to_pyobject(&udata_ptr->error, &py_err);
204-
PyObject *exception_type = raise_exception_old(&udata_ptr->error);
205-
PyErr_SetObject(exception_type, py_err);
206-
Py_DECREF(py_err);
207-
PyGILState_Release(gil_state);
208-
return NULL;
209-
}
210-
if (err->code != AEROSPIKE_OK) {
211-
PyObject *py_err = NULL;
212-
error_to_pyobject(err, &py_err);
213-
PyObject *exception_type = raise_exception_old(err);
214-
PyErr_SetObject(exception_type, py_err);
215-
Py_DECREF(py_err);
216-
PyGILState_Release(gil_state);
217-
return NULL;
218-
}
219-
220-
PyGILState_Release(gil_state);
221-
return true;
222-
}
22347

22448
/**
22549
*******************************************************************************************************
@@ -297,110 +121,6 @@ static bool AerospikeClient_InfoAll_each(as_error *err, const as_node *node,
297121
return true;
298122
}
299123

300-
/**
301-
*******************************************************************************************************
302-
* Sends an info request to all the nodes in a cluster.
303-
*
304-
* @param self AerospikeClient object
305-
* @param args The args is a tuple object containing an argument
306-
* list passed from Python to a C function
307-
* @param kwds Dictionary of keywords
308-
*
309-
* Returns a server response for the particular request string.
310-
* In case of error,appropriate exceptions will be raised.
311-
*******************************************************************************************************
312-
*/
313-
PyObject *AerospikeClient_Info(AerospikeClient *self, PyObject *args,
314-
PyObject *kwds)
315-
{
316-
PyObject *py_req = NULL;
317-
PyObject *py_policy = NULL;
318-
PyObject *py_hosts = NULL;
319-
PyObject *py_nodes = NULL;
320-
PyObject *py_ustr = NULL;
321-
foreach_callback_info_udata info_callback_udata;
322-
323-
static char *kwlist[] = {"command", "hosts", "policy", NULL};
324-
325-
if (PyArg_ParseTupleAndKeywords(args, kwds, "O|OO:info", kwlist, &py_req,
326-
&py_hosts, &py_policy) == false) {
327-
return NULL;
328-
}
329-
330-
as_error err;
331-
as_error_init(&err);
332-
333-
as_policy_info info_policy;
334-
as_policy_info *info_policy_p = NULL;
335-
py_nodes = PyDict_New();
336-
info_callback_udata.udata_p = py_nodes;
337-
info_callback_udata.host_lookup_p = py_hosts;
338-
as_error_init(&info_callback_udata.error);
339-
340-
if (!self || !self->as) {
341-
as_error_update(&err, AEROSPIKE_ERR_PARAM, "Invalid aerospike object");
342-
goto CLEANUP;
343-
}
344-
if (!self->is_conn_16) {
345-
as_error_update(&err, AEROSPIKE_ERR_CLUSTER,
346-
"No connection to aerospike cluster");
347-
goto CLEANUP;
348-
}
349-
350-
// Convert python policy object to as_policy_info
351-
pyobject_to_policy_info(&err, py_policy, &info_policy, &info_policy_p,
352-
&self->as->config.policies.info);
353-
if (err.code != AEROSPIKE_OK) {
354-
goto CLEANUP;
355-
}
356-
char *req = NULL;
357-
if (PyUnicode_Check(py_req)) {
358-
py_ustr = PyUnicode_AsUTF8String(py_req);
359-
req = PyBytes_AsString(py_ustr);
360-
}
361-
else {
362-
as_error_update(&err, AEROSPIKE_ERR_PARAM, "Request must be a string");
363-
goto CLEANUP;
364-
}
365-
366-
Py_BEGIN_ALLOW_THREADS
367-
aerospike_info_foreach(
368-
self->as, &err, info_policy_p, req,
369-
(aerospike_info_foreach_callback)AerospikeClient_Info_each,
370-
&info_callback_udata);
371-
Py_END_ALLOW_THREADS
372-
373-
if (info_callback_udata.error.code != AEROSPIKE_OK) {
374-
as_error_update(&err, err.code, NULL);
375-
goto CLEANUP;
376-
}
377-
CLEANUP:
378-
if (py_ustr) {
379-
Py_DECREF(py_ustr);
380-
}
381-
if (info_callback_udata.error.code != AEROSPIKE_OK) {
382-
PyObject *py_err = NULL;
383-
error_to_pyobject(&info_callback_udata.error, &py_err);
384-
PyObject *exception_type =
385-
raise_exception_old(&info_callback_udata.error);
386-
PyErr_SetObject(exception_type, py_err);
387-
Py_DECREF(py_err);
388-
if (py_nodes) {
389-
Py_DECREF(py_nodes);
390-
}
391-
return NULL;
392-
}
393-
if (err.code != AEROSPIKE_OK) {
394-
raise_exception(&err);
395-
if (py_nodes) {
396-
Py_DECREF(py_nodes);
397-
}
398-
return NULL;
399-
}
400-
401-
return info_callback_udata.udata_p;
402-
}
403-
404124
/**
405125
*******************************************************************************************************
406126
* Sends an info request to all the nodes in a cluster.

src/main/client/type.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,6 @@ PyDoc_STRVAR(
163163
\n\
164164
Initiate a background scan and apply a record UDF to each record matched by the scan.");
165165

166-
PyDoc_STRVAR(info_doc, "info(command[, hosts[, policy]]) -> {}\n\
167-
\n\
168-
Send an info command to multiple nodes specified in a hosts list.");
169-
170166
PyDoc_STRVAR(
171167
set_xdr_filter_doc,
172168
"set_xdr_filter(data_center, namespace, expression_filter[, policy]) -> {}\n\
@@ -458,8 +454,6 @@ static PyMethodDef AerospikeClient_Type_Methods[] = {
458454

459455
// INFO OPERATIONS
460456

461-
{"info", (PyCFunction)AerospikeClient_Info, METH_VARARGS | METH_KEYWORDS,
462-
info_doc},
463457
{"set_xdr_filter", (PyCFunction)AerospikeClient_SetXDRFilter,
464458
METH_VARARGS | METH_KEYWORDS, set_xdr_filter_doc},
465459
{"get_expression_base64", (PyCFunction)AerospikeClient_GetExpressionBase64,

0 commit comments

Comments
 (0)