public static void main(String[] args) { HazelcastInstance instance1 = Hazelcast.newHazelcastInstance(null); HazelcastInstance instance2 = Hazelcast.newHazelcastInstance(null); // initialize partitions instance1.getMap("map1").put(0, 0); instance1.getPartitionService().addPartitionLostListener(new PartitionLostListener() { @Override public void partitionLost(PartitionLostEvent event) { System.out.println("Instance2 has lost a partition for data with 0 backup! " + event); } }); instance2.getLifecycleService().terminate(); } }
private void initialize(HazelcastInstance hzInstance) { this.hzInstance = hzInstance; ITopic<Counter> cTopic = hzInstance.getTopic(TPN_XDM_COUNTERS); cTopic.addMessageListener(this); ITopic<Long> pTopic = hzInstance.getTopic(TPN_XDM_POPULATION); pTopic.addMessageListener(new PopulationStateListener()); hTopic = hzInstance.getTopic(TPN_XDM_HEALTH); xddCache = hzInstance.getMap(CN_XDM_DOCUMENT); hzInstance.getPartitionService().addPartitionLostListener(this); }
@SuppressWarnings("checkstyle:magicnumber") @SuppressFBWarnings({"EI_EXPOSE_REP2"}) public ExpirationManager(ClearExpiredRecordsTask task, NodeEngine nodeEngine) { this.task = task; this.nodeEngine = nodeEngine; this.globalTaskScheduler = nodeEngine.getExecutionService().getGlobalTaskScheduler(); this.taskPeriodSeconds = checkPositive(task.getTaskPeriodSeconds(), "taskPeriodSeconds should be a positive number"); this.lifecycleService = getHazelcastInstance().getLifecycleService(); this.lifecycleListenerId = lifecycleService.addLifecycleListener(this); this.partitionService = getHazelcastInstance().getPartitionService(); this.partitionLostListenerId = partitionService.addPartitionLostListener(this); }
@SuppressWarnings("checkstyle:magicnumber") @SuppressFBWarnings({"EI_EXPOSE_REP2"}) public ExpirationManager(ClearExpiredRecordsTask task, NodeEngine nodeEngine) { this.task = task; this.nodeEngine = nodeEngine; this.globalTaskScheduler = nodeEngine.getExecutionService().getGlobalTaskScheduler(); this.taskPeriodSeconds = checkPositive(task.getTaskPeriodSeconds(), "taskPeriodSeconds should be a positive number"); this.lifecycleService = getHazelcastInstance().getLifecycleService(); this.lifecycleListenerId = lifecycleService.addLifecycleListener(this); this.partitionService = getHazelcastInstance().getPartitionService(); this.partitionLostListenerId = partitionService.addPartitionLostListener(this); }