private void initializeListeners(Config config) { for (final ListenerConfig listenerCfg : config.getListenerConfigs()) { Object listener = listenerCfg.getImplementation(); if (listener == null) { try { listener = Serializer.newInstance(Serializer.loadClass(listenerCfg.getClassName())); } catch (Exception e) { logger.log(Level.SEVERE, e.getMessage(), e); } } if (listener instanceof InstanceListener) { factory.addInstanceListener((InstanceListener) listener); } else if (listener instanceof MembershipListener) { clusterImpl.addMembershipListener((MembershipListener) listener); } else if (listener instanceof MigrationListener) { concurrentMapManager.partitionServiceImpl.addMigrationListener((MigrationListener) listener); } else if (listener != null) { final String error = "Unknown listener type: " + listener.getClass(); Throwable t = new IllegalArgumentException(error); logger.log(Level.WARNING, error, t); } } }
private void initializeListeners(Config config) { for (final ListenerConfig listenerCfg : config.getListenerConfigs()) { Object listener = listenerCfg.getImplementation(); if (listener == null) { try { listener = Serializer.newInstance(Serializer.loadClass(listenerCfg.getClassName())); } catch (Exception e) { logger.log(Level.SEVERE, e.getMessage(), e); } } if (listener instanceof InstanceListener) { factory.addInstanceListener((InstanceListener) listener); } else if (listener instanceof MembershipListener) { clusterImpl.addMembershipListener((MembershipListener) listener); } else if (listener instanceof MigrationListener) { concurrentMapManager.partitionServiceImpl.addMigrationListener((MigrationListener) listener); } else if (listener instanceof LifecycleListener) { factory.lifecycleService.addLifecycleListener((LifecycleListener) listener); } else if (listener != null) { final String error = "Unknown listener type: " + listener.getClass(); Throwable t = new IllegalArgumentException(error); logger.log(Level.WARNING, error, t); } } }
public MembershipListenerManager(HazelcastClient client) { this.client = client; final ClientConfig clientConfig = client.getClientConfig(); if (clientConfig != null) { for (Object listener : clientConfig.getListeners()) { if (listener instanceof MembershipListener) { registerListener((MembershipListener) listener); } } } }
@Override protected void trainHazelcastInstance(HazelcastInstance hazelcastInstance) { when(hazelcastInstance.getCluster()).thenReturn(cluster); argument = ArgumentCaptor.forClass(MembershipListener.class); when(cluster.addMembershipListener(argument.capture())).thenReturn("foo"); }
@Override protected void verifyHazelcastInstance(HazelcastInstance hazelcastInstance) { verify(hazelcastInstance).getCluster(); verify(cluster).addMembershipListener(any(MembershipListener.class)); }
public static void addMemberListener(MembershipListener membershipListener){//添加成员事件监听 instance.getCluster().addMembershipListener(membershipListener); }
@Override public void addMemberListener(MembershipListener mebershipListener) { HazelcastListenerManager.addMemberListener(mebershipListener); }
public void addMembershipListener(MembershipListener listener) { listeners.add(listener); }
public void removeMembershipListener(MembershipListener listener) { listeners.remove(listener); }
public void registerListener(MembershipListener listener) { this.memberShipListeners.add(listener); }
public void removeListener(MembershipListener listener) { this.memberShipListeners.remove(listener); }
/** * Initialize with a member event listener, and broadcast message listener * @param clusterListener * @param msgListener */ public void init(final MembershipListener clusterListener){ hazelcast.getCluster().addMembershipListener(clusterListener); }
public void addMemberListener(MembershipListener mebershipListener);