shakedzy
shakedzy

Reputation: 2893

Aerospike: count all objects in a namespace?

So I've been going through Aerospike's documentations, and I still fail to understand how to get the number of master (not-replicated) records in a names-space via the Java API (not AQL).. any help?

Upvotes: 2

Views: 1682

Answers (2)

pgupta
pgupta

Reputation: 5435

I repeated with a three node cluster. 10,000 master objects, replication factor of 2. Created cluster by running 3 aerospike processes on same VM but separated ports as 3000, 4000 & 5000.

Java code (not parsing the string):

console.printf("\nNode at Port 3000\n");
console.printf(Info.request("127.0.0.1", 3000, "namespace/test"));  

console.printf("\nNode at Port 4000\n");
console.printf(Info.request("127.0.0.1", 4000, "namespace/test"));

console.printf("\nNode at Port 5000\n");
console.printf(Info.request("127.0.0.1", 5000, "namespace/test"));

Relevant Output:

Node at Port 3000
objects=6537;sub_objects=0;master_objects=3286;master_sub_objects=0;prole_objects=3251;prole_sub_objects=0;...
Node at Port 4000
objects=6674;sub_objects=0;master_objects=3294;master_sub_objects=0;prole_objects=3380;prole_sub_objects=0;...
Node at Port 5000
objects=6789;sub_objects=0;master_objects=3420;master_sub_objects=0;prole_objects=3369;prole_sub_objects=0;...

Cross check with asadm

asadm>info

3-node cluster, relevant output: enter image description here

Upvotes: 2

pgupta
pgupta

Reputation: 5435

I tried this with a server running on localhost, port 3000. You can explore the Info class further and use better constructs. I have 10,000 objects in a namespace called 'test'.

String output = Info.request("127.0.0.1", 3000, "namespace/test");
String[] mp = output.split(";") ; 
console.printf(mp[0]);

I got the following output on my console:

objects=10000

Upvotes: 3

Related Questions