com.hazelcast.core.Cluster.addMembershipListener()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(7.7k)|赞(0)|评价(0)|浏览(203)

本文整理了Java中com.hazelcast.core.Cluster.addMembershipListener()方法的一些代码示例,展示了Cluster.addMembershipListener()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Cluster.addMembershipListener()方法的具体详情如下:
包路径:com.hazelcast.core.Cluster
类名称:Cluster
方法名:addMembershipListener

Cluster.addMembershipListener介绍

[英]Adds MembershipListener to listen for membership updates.

The addMembershipListener method returns a register ID. This ID is needed to remove the MembershipListener using the #removeMembershipListener(String) method.

If the MembershipListener implements the InitialMembershipListener interface, it will also receive the InitialMembershipEvent.

There is no check for duplicate registrations, so if you register the listener twice, it will get events twice.
[中]

代码示例

代码示例来源:origin: apache/usergrid

public void init() {
  logger.info( "HazelcastLifecycleMonitor initializing..." );
  Hazelcast.addInstanceListener( this );
  Hazelcast.getCluster().addMembershipListener( this );
  logger.info( "HazelcastLifecycleMonitor initialized" );
}

代码示例来源:origin: SonarSource/sonarqube

public ClusterAppStateImpl(AppSettings settings, HazelcastMember hzMember, EsConnector esConnector) {
 this.hzMember = hzMember;
 // Get or create the replicated map
 operationalProcesses = (ReplicatedMap) hzMember.getReplicatedMap(OPERATIONAL_PROCESSES);
 operationalProcessListenerUUID = operationalProcesses.addEntryListener(new OperationalProcessListener());
 nodeDisconnectedListenerUUID = hzMember.getCluster().addMembershipListener(new NodeDisconnectedListener());
 if (ClusterSettings.isLocalElasticsearchEnabled(settings)) {
  this.healthStateSharing = new HealthStateSharingImpl(hzMember, new SearchNodeHealthProvider(settings.getProps(), this, NetworkUtilsImpl.INSTANCE));
  this.healthStateSharing.start();
 }
 this.esConnector = esConnector;
}

代码示例来源:origin: com.hazelcast/hazelcast-all

@Override
public final void init(Cluster cluster, ClientConfig config) {
  this.clusterRef = cluster;
  cluster.addMembershipListener(this);
}

代码示例来源:origin: hazelcast/hazelcast-jet

@Override
public final void init(Cluster cluster, ClientConfig config) {
  this.clusterRef = cluster;
  cluster.addMembershipListener(this);
}

代码示例来源:origin: com.atlassian.cache/atlassian-cache-hazelcast

AsyncInvalidationListener(Cluster cluster, Cache<K, ?> localCache, ITopic<K> topic)
{
  this.cluster = cluster;
  this.localCacheRef = new WeakReference<>(localCache);
  this.topic = topic;
  this.topicListenerId = topic.addMessageListener(this);
  this.membershipListenerId = cluster.addMembershipListener(this);
}

代码示例来源:origin: com.atlassian.cache/atlassian-cache-hazelcast

AsyncInvalidationListener(Cluster cluster, CachedReference<?> localReference, ITopic<ReferenceKey> topic)
{
  this.cluster = cluster;
  this.localReferenceRef = new WeakReference<>(localReference);
  this.topic = topic;
  this.topicListenerId = topic.addMessageListener(this);
  this.membershipListenerId = cluster.addMembershipListener(this);
}

代码示例来源:origin: dsukhoroslov/bagri

public TopologyManagement(HazelcastInstance hzInstance) {
  //super(hzInstance);
  this.hzInstance = hzInstance;
  hzInstance.getCluster().addMembershipListener(this);
}

代码示例来源:origin: org.apache.karaf.cellar/org.apache.karaf.cellar.hazelcast

public CellarMembershipListener(HazelcastInstance instance) {
  this.instance = instance;
  instance.getCluster().addMembershipListener(this);
}

代码示例来源:origin: dsukhoroslov/bagri

public SchemaManagement(HazelcastInstance hzInstance) {
  super(hzInstance);
  hzInstance.getCluster().addMembershipListener(this);
}

代码示例来源:origin: apache/karaf-cellar

public CellarMembershipListener(HazelcastInstance instance) {
  this.instance = instance;
  instance.getCluster().addMembershipListener(this);
}

代码示例来源:origin: dsukhoroslov/bagri

public void setHazelcastInstance(HazelcastInstance hzInstance) {
  logger.trace("setHazelcastInstance.enter");
  this.hzInstance = hzInstance;
  hzInstance.getCluster().addMembershipListener(this);
  setupCaches();
}

代码示例来源:origin: org.apache.camel/camel-hazelcast

public HazelcastInstanceConsumer(HazelcastInstance hazelcastInstance, DefaultEndpoint endpoint, Processor processor) {
  super(endpoint, processor);
  hazelcastInstance.getCluster().addMembershipListener(new HazelcastMembershipListener());
}

代码示例来源:origin: org.wso2.carbon.analytics/org.wso2.carbon.analytics.dataservice

public AnalyticsClusterManagerImpl() {
  this.hz = AnalyticsServiceHolder.getHazelcastInstance();
  if (this.isClusteringEnabled()) {
    this.hz.getCluster().addMembershipListener(this);
  }
}

代码示例来源:origin: org.wso2.carbon.analytics/org.wso2.carbon.analytics.dataservice.core

public AnalyticsClusterManagerImpl() {
  this.hz = AnalyticsServiceHolder.getHazelcastInstance();
  if (this.isClusteringEnabled()) {
    this.hz.getCluster().addMembershipListener(this);
  }
}

代码示例来源:origin: net.kuujo/xync

public HazelcastClusterManager(HazelcastInstance hazelcast) {
 this.hazelcast = hazelcast;
 this.nodeId = hazelcast.getCluster().getLocalMember().getUuid();
 hazelcast.getCluster().addMembershipListener(this);
}

代码示例来源:origin: datasalt/splout-db

public DistributedRegistry(String registryName, Object nodeInfo, HazelcastInstance hzInstance,
              int minutesToCheckRegister, int oldestMembersLeading) {
 this.registryName = registryName;
 this.nodeInfo = nodeInfo;
 this.hzInstance = hzInstance;
 hzInstance.getCluster().addMembershipListener(new MyListener());
 hzInstance.getLifecycleService().addLifecycleListener(new RestartListener());
 this.minutesToCheckRegister = minutesToCheckRegister;
 this.oldestMembersLeading = oldestMembersLeading;
}

代码示例来源:origin: hazelcast/hazelcast-code-samples

protected static CountDownLatch simulateSplitBrain(HazelcastInstance h1, HazelcastInstance h2) {
  SampleMemberShipListener memberShipListener = new SampleMemberShipListener(1);
  h2.getCluster().addMembershipListener(memberShipListener);
  SampleLifeCycleListener lifeCycleListener = new SampleLifeCycleListener(1);
  h2.getLifecycleService().addLifecycleListener(lifeCycleListener);
  closeConnectionBetween(h1, h2);
  assertOpenEventually(memberShipListener.latch);
  assertClusterSizeEventually(1, h1);
  assertClusterSizeEventually(1, h2);
  return lifeCycleListener.latch;
}

代码示例来源:origin: org.sonarsource.sonarqube/sonar-main

public ClusterAppStateImpl(AppSettings settings, HazelcastMember hzMember) {
 this.hzMember = hzMember;
 // Get or create the replicated map
 operationalProcesses = (ReplicatedMap) hzMember.getReplicatedMap(OPERATIONAL_PROCESSES);
 operationalProcessListenerUUID = operationalProcesses.addEntryListener(new OperationalProcessListener());
 nodeDisconnectedListenerUUID = hzMember.getCluster().addMembershipListener(new NodeDisconnectedListener());
 if (ClusterSettings.isLocalElasticsearchEnabled(settings)) {
  this.healthStateSharing = new HealthStateSharingImpl(hzMember, new SearchNodeHealthProvider(settings.getProps(), this, NetworkUtilsImpl.INSTANCE));
  this.healthStateSharing.start();
 }
}

代码示例来源:origin: hazelcast/hazelcast-jet

@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());
  }
}

代码示例来源:origin: com.hazelcast/hazelcast-all

@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());
  }
}

相关文章