RIshab R Bafna
RIshab R Bafna

Reputation: 427

Hazelcast Map Configuration For Data Backup

1.Trying to create a cluster using Hazelcast. In case of data backup:

<hazelcast>
  <map name="**default**">
    <backup-count>1</backup-count>
  </map>
</hazelcast>

From the above snippet, just wanted to clarify what does "default" map name stands for? does it mean that all maps will have backup count 1, or the map name "default" will have a backup count of 1.

HazelCast Reference Link

  1. Is there a way I can iterate over all the maps across the cluster ?

Upvotes: 0

Views: 761

Answers (1)

Neil Stevenson
Neil Stevenson

Reputation: 3150

  1. The name "default" (not "**default**") means any map.

If you have doubt over this, create a cluster of two nodes, put some data into a Hazelcast map and kill one node. If backup count was 1 for that map, you won't have lost data for that map.

  1. Try

    Set<String> iMapNames = this.hazelcastInstance.getDistributedObjects().stream()
            .filter(distributedObject -> distributedObject instanceof IMap)
            .map(distributedObject -> distributedObject.getName()).collect(Collectors.toCollection(TreeSet::new));
    
    iMapNames.stream().forEach(name -> {
        IMap<?, ?> iMap = this.hazelcastInstance.getMap(name);
        System.out.printf("IMap: '%s'%n", iMap.getName());
    }
    

Upvotes: 1

Related Questions