public HazelcastPartitionManager(PartitionService partitionService) { this.partitionService = partitionService; partitionService.addMigrationListener(new MigrationListener() { @Override public void migrationStarted(MigrationEvent migrationEvent) {} @Override public void migrationFailed(MigrationEvent migrationEvent) { migrationCompleted(migrationEvent); } @Override public void migrationCompleted(MigrationEvent migrationEvent) { if(migrationEvent.getOldOwner() == null) { for(PartitionLostListener listener : listeners) { try { listener.partitionLost(migrationEvent); } catch (Exception e) { //swallow log.error("An exception was thrown by our partitionLost event listener. I will ignore it. ", e); } } } } }); }
@Override protected void doStart() { final HazelcastClusterMonitorListener clusterMonitorListener = new HazelcastClusterMonitorListener(); if (this.monitorTypes.contains(ClusterMonitorType.MEMBERSHIP.name())) { final String registrationId = this.hazelcastInstance.getCluster() .addMembershipListener(clusterMonitorListener); this.hazelcastRegisteredListenerIdMap.put(ClusterMonitorType.MEMBERSHIP, registrationId); } if (this.monitorTypes.contains(ClusterMonitorType.DISTRIBUTED_OBJECT.name())) { final String registrationId = this.hazelcastInstance .addDistributedObjectListener(clusterMonitorListener); this.hazelcastRegisteredListenerIdMap.put(ClusterMonitorType.DISTRIBUTED_OBJECT, registrationId); } if (this.monitorTypes.contains(ClusterMonitorType.MIGRATION.name())) { final String registrationId = this.hazelcastInstance.getPartitionService() .addMigrationListener(clusterMonitorListener); this.hazelcastRegisteredListenerIdMap.put(ClusterMonitorType.MIGRATION, registrationId); } if (this.monitorTypes.contains(ClusterMonitorType.LIFECYCLE.name())) { final String registrationId = this.hazelcastInstance.getLifecycleService() .addLifecycleListener(clusterMonitorListener); this.hazelcastRegisteredListenerIdMap.put(ClusterMonitorType.LIFECYCLE, registrationId); } if (this.monitorTypes.contains(ClusterMonitorType.CLIENT.name())) { final String registrationId = this.hazelcastInstance.getClientService() .addClientListener(clusterMonitorListener); this.hazelcastRegisteredListenerIdMap.put(ClusterMonitorType.CLIENT, registrationId); } }
@Override public void onStart() { logger.info("Plugin:active: logPartitions:" + logPartitions); connectionObservable.addConnectionListener(new ConnectionListenerImpl()); hazelcastInstance.getCluster().addMembershipListener(new MembershipListenerImpl()); if (logPartitions) { hazelcastInstance.getPartitionService().addMigrationListener(new MigrationListenerImpl()); } hazelcastInstance.getLifecycleService().addLifecycleListener(new LifecycleListenerImpl()); if (nodeExtension != null) { nodeExtension.registerListener(new ClusterVersionListenerImpl()); } }
@Override public void onStart() { logger.info("Plugin:active: logPartitions:" + logPartitions); connectionObservable.addConnectionListener(new ConnectionListenerImpl()); hazelcastInstance.getCluster().addMembershipListener(new MembershipListenerImpl()); if (logPartitions) { hazelcastInstance.getPartitionService().addMigrationListener(new MigrationListenerImpl()); } hazelcastInstance.getLifecycleService().addLifecycleListener(new LifecycleListenerImpl()); if (nodeExtension != null) { nodeExtension.registerListener(new ClusterVersionListenerImpl()); } }