how to get all Map Names from Hazelcast client

4,861 views
Skip to first unread message

Mohan

unread,
Mar 7, 2011, 7:08:04 AM3/7/11
to Hazelcast
Hi All,

I'm writing a Java client program to remotely connect to a Hazelcast
cluster and clear the entries.

Have a doubt, how to get the list of Maps available. (Just Map names
would be fine), is there any API available in

Hazelcast client Jar to do that ?

Thanks,
Mohan

Fuad Malikov

unread,
Mar 7, 2011, 2:50:39 PM3/7/11
to haze...@googlegroups.com, Mohan
How about this:

Collection<Instance> instances =  hazelcastInstance.getInstances();
for(Instance instance: instances){
if(instance.getInstanceType().isMap()){
//do anything. hazelcastInstance can be hazelcast node or hazelcast client. Both will work.
}
}

Fuad


--
You received this message because you are subscribed to the Google Groups "Hazelcast" group.
To post to this group, send email to haze...@googlegroups.com.
To unsubscribe from this group, send email to hazelcast+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/hazelcast?hl=en.




--

@fuadm

epim...@gmail.com

unread,
Sep 28, 2014, 5:19:09 PM9/28/14
to haze...@googlegroups.com, amoh...@gmail.com

         Collection<DistributedObject> instances =  client.getDistributedObjects();
        for(DistributedObject instance: instances){
        if ( instance.getServiceName().equals("hz:impl:mapService")){
        instance.destroy();
        }
        }

Pratik Patel

unread,
Oct 14, 2014, 11:04:13 AM10/14/14
to haze...@googlegroups.com, amoh...@gmail.com

Hi,

From Hazelcast server, you can execute following code to clearthe entries.

private void removeMaps(){
Map<String,MapConfig> mapList = instance.getConfig().getMapConfigs();
logger.info("Removing Maps. Current size: "+mapList.size());
for (String name : mapList.keySet()) {
instance.getMap(name).clear();
logger.info("Size of map: "+instance.getMap(name).size());
}
logger.info("Removed Maps. Current size: "+mapList.size());
Reply all
Reply to author
Forward
0 new messages