本文整理汇总了Java中com.hazelcast.core.MembershipEvent类的典型用法代码示例。如果您正苦于以下问题:Java MembershipEvent类的具体用法?Java MembershipEvent怎么用?Java MembershipEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MembershipEvent类属于com.hazelcast.core包,在下文中一共展示了MembershipEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: update
import com.hazelcast.core.MembershipEvent; //导入依赖的package包/类
@Override
public final void update(Observable arg0, Object arg1) {
if(arg1 instanceof MembershipEvent)
{
MembershipEvent me = (MembershipEvent) arg1;
switch(me.getEventType())
{
case MembershipEvent.MEMBER_ADDED:
handleMemberAdded(me.getMember());
break;
case MembershipEvent.MEMBER_REMOVED:
handleMemberRemoved(me.getMember());
break;
case MembershipEvent.MEMBER_ATTRIBUTE_CHANGED:
MemberAttributeEvent ma = (MemberAttributeEvent) arg1;
handleMemberModified(ma.getMember(), ma.getOperationType());
break;
default: break;
}
}
}
示例2: sendExchange
import com.hazelcast.core.MembershipEvent; //导入依赖的package包/类
private void sendExchange(MembershipEvent event, String action) {
Exchange exchange = getEndpoint().createExchange();
HazelcastComponentHelper.setListenerHeaders(exchange, HazelcastConstants.INSTANCE_LISTENER, action);
// instance listener header values
InetSocketAddress adr = event.getMember().getSocketAddress();
if (adr != null) {
exchange.getIn().setHeader(HazelcastConstants.INSTANCE_HOST, adr.getHostName());
exchange.getIn().setHeader(HazelcastConstants.INSTANCE_PORT, adr.getPort());
}
try {
getProcessor().process(exchange);
} catch (Exception e) {
exchange.setException(e);
}
if (exchange.getException() != null) {
getExceptionHandler().handleException("Error processing exchange for Hazelcast consumer on your Hazelcast cluster.", exchange, exchange.getException());
}
}
示例3: testAddInstance
import com.hazelcast.core.MembershipEvent; //导入依赖的package包/类
@Test
public void testAddInstance() throws InterruptedException {
MockEndpoint added = getMockEndpoint("mock:added");
added.setExpectedMessageCount(1);
when(member.getSocketAddress()).thenReturn(new InetSocketAddress("foo.bar", 12345));
MembershipEvent event = new MembershipEvent(cluster, member, MembershipEvent.MEMBER_ADDED, null);
argument.getValue().memberAdded(event);
assertMockEndpointsSatisfied(5000, TimeUnit.MILLISECONDS);
// check headers
Exchange ex = added.getExchanges().get(0);
Map<String, Object> headers = ex.getIn().getHeaders();
this.checkHeaders(headers, HazelcastConstants.ADDED);
}
示例4: memberAdded
import com.hazelcast.core.MembershipEvent; //导入依赖的package包/类
@Override
public synchronized void memberAdded(MembershipEvent membershipEvent) {
if (!active) {
return;
}
try {
multimaps.forEach(HazelcastAsyncMultiMap::clearCache);
if (nodeListener != null) {
Member member = membershipEvent.getMember();
members.add(member);
nodeListener.nodeAdded(member.getUuid());
}
} catch (Throwable t) {
log.error("Failed to handle memberAdded", t);
}
}
示例5: memberRemoved
import com.hazelcast.core.MembershipEvent; //导入依赖的package包/类
@Override
public synchronized void memberRemoved(MembershipEvent membershipEvent) {
if (!active) {
return;
}
try {
multimaps.forEach(HazelcastAsyncMultiMap::clearCache);
if (nodeListener != null) {
Member member = membershipEvent.getMember();
members.remove(member);
nodeListener.nodeLeft(member.getUuid());
}
} catch (Throwable t) {
log.error("Failed to handle memberRemoved", t);
}
}
示例6: memberRemoved
import com.hazelcast.core.MembershipEvent; //导入依赖的package包/类
@Override
public void memberRemoved(MembershipEvent membershipEvent) {
String uuid = membershipEvent.getMember().getUuid();
logger.info("关闭连接: {}", uuid);
messageServerManager.unload(uuid);
// userClientInfoManager.unloadServer(uuid);
}
示例7: memberAdded
import com.hazelcast.core.MembershipEvent; //导入依赖的package包/类
@Override
public void memberAdded(MembershipEvent membershipEvent) {
Member member = membershipEvent.getMember();
// Send all cluster messages
carbonCluster.memberAdded(member);
log.info(String.format("Member joined: [UUID] %s, [Address] %s", member.getUuid(), member.getSocketAddress().toString()));
// Wait for sometime for the member to completely join before
// replaying messages
try {
Thread.sleep(5000);
} catch (InterruptedException ignored) {
}
HazelcastUtil.sendMessagesToMember(messageBuffer, member, carbonCluster);
}
示例8: memberRemoved
import com.hazelcast.core.MembershipEvent; //导入依赖的package包/类
@Override
public void memberRemoved(MembershipEvent membershipEvent) {
log.info("Member {} removed", membershipEvent.getMember());
NodeId nodeId = new NodeId(memberAddress(membershipEvent.getMember()).toString());
updateState(nodeId, State.INACTIVE);
notifyDelegate(new ClusterEvent(INSTANCE_DEACTIVATED, getNode(nodeId)));
}
示例9: memberRemoved
import com.hazelcast.core.MembershipEvent; //导入依赖的package包/类
@Override
public void memberRemoved(MembershipEvent event) {
long begin =System.currentTimeMillis();
cluster.controllerRemoved(event);
long end=System.currentTimeMillis();
System.out.println("translation time:"+(end-begin));
}
示例10: controllerRemoved
import com.hazelcast.core.MembershipEvent; //导入依赖的package包/类
@Override
public void controllerRemoved(MembershipEvent event) {
Member m = event.getMember();
log.info("{} disconnected", m.getUuid());
controllerLoad.remove(m.getUuid());// 移除故障控制器负载
List<String> load = ImmutableList.copyOf(getSortedControllerLoad());// 取得控制器负载排序
String uuid = floodlightProvider.getControllerModel().getControllerId();// 得到本机uuid
ControllerModel c = controllers.get(m.getUuid());// 得到故障控制器模型
Collection<SwitchConnectModel> switchs = controllerMappingSwitch.get(c);// 得到故障控制器控制的交换机
if (!load.isEmpty()&&uuid.equals(load.get(0))) {
for (SwitchConnectModel s : switchs) {// 遍历交换机a
if(!s.getRole().equals(OFControllerRole.ROLE_MASTER.toString())) continue;
DatapathId dpid = DatapathId.of(s.getDpid());
// removeMasterMap(dpid.toString());
for (int i = 0; i < load.size(); i++) {
if (isConnected(s.getDpid(), load.get(i))) {
IOFSwitch sw = switchService.getSwitch(dpid);
log.info("change master {}<-->{}", uuid, dpid);
sw.writeRequest(sw.getOFFactory().buildRoleRequest()
.setGenerationId(U64.ZERO)
.setRole(OFControllerRole.ROLE_MASTER).build());
break;
}
}
}
controllerMappingSwitch.remove(c);
controllers.remove(c.getControllerId());
}
}
示例11: memberRemoved
import com.hazelcast.core.MembershipEvent; //导入依赖的package包/类
@Override
public void memberRemoved(MembershipEvent membershipEvent) {
try {
ObjectName topName = TopologyManager.getMemberName(membershipEvent.getMember());
mbeanExporter.unregisterManagedResource(topName);
} catch (MalformedObjectNameException ex) {
logger.error("memberRemoved.error; ", ex);
}
}
示例12: memberAdded
import com.hazelcast.core.MembershipEvent; //导入依赖的package包/类
@Override
public void memberAdded(MembershipEvent membershipEvent) {
logger.info("memberAdded; event: {}", membershipEvent);
// this does not work, unfortunately
//if (membershipEvent.getMember().localMember()) {
// IMap<XDMDocumentKey, XDMDocument> xddCache = nodeEngine.getHazelcastInstance().getMap(CN_XDM_DOCUMENT);
// xddCache.addEntryListener(this, true);
//}
//checkPopulation(membershipEvent.getMembers().size());
}
示例13: memberAdded
import com.hazelcast.core.MembershipEvent; //导入依赖的package包/类
public void memberAdded(MembershipEvent event) {
// local member only
if (event.getMember().localMember()) { // We left and re-joined the cluster
joinCluster();
} else {
nodePresences.put(NodeID.getInstance(StringUtils.getBytes(event.getMember().getUuid())),
new ConcurrentHashMap<String, Collection<String>>());
// Trigger event that a new node has joined the cluster
ClusterManager.fireJoinedCluster(StringUtils.getBytes(event.getMember().getUuid()), true);
}
clusterNodesInfo.put(event.getMember().getUuid(),
new HazelcastClusterNodeInfo(event.getMember(), cluster.getClusterTime()));
}
示例14: memberRemoved
import com.hazelcast.core.MembershipEvent; //导入依赖的package包/类
public void memberRemoved(MembershipEvent event) {
byte[] nodeID = StringUtils.getBytes(event.getMember().getUuid());
if (event.getMember().localMember()) {
logger.info("Leaving cluster: " + nodeID);
// This node may have realized that it got kicked out of the cluster
leaveCluster();
} else {
// Trigger event that a node left the cluster
ClusterManager.fireLeftCluster(nodeID);
// Clean up directed presences sent from entities hosted in the leaving node to local entities
// Clean up directed presences sent to entities hosted in the leaving node from local entities
cleanupDirectedPresences(NodeID.getInstance(nodeID));
if (!seniorClusterMember && CacheFactory.isSeniorClusterMember()) {
seniorClusterMember = true;
ClusterManager.fireMarkedAsSeniorClusterMember();
}
cleanupNode(NodeID.getInstance(nodeID));
// Remove traces of directed presences sent from local entities to handlers that no longer exist.
// At this point c2s sessions are gone from the routing table so we can identify expired sessions
XMPPServer.getInstance().getPresenceUpdateHandler().removedExpiredPresences();
}
// Delete nodeID instance (release from memory)
NodeID.deleteInstance(nodeID);
clusterNodesInfo.remove(event.getMember().getUuid());
}
示例15: memberRemoved
import com.hazelcast.core.MembershipEvent; //导入依赖的package包/类
@Override
public void memberRemoved(MembershipEvent membershipEvent) {
HazelcastInstance hazelcastInstance = BPELServiceComponent.getHazelcastInstance();
Member leader = hazelcastInstance.getCluster().getMembers().iterator().next();
// Allow Leader to update distributed map.
if (leader.localMember()) {
String leftMemberID = getHazelCastNodeID(membershipEvent.getMember());
hazelcastInstance.getMap(BPELConstants.BPS_CLUSTER_NODE_MAP).remove(leftMemberID);
}
}