当前位置: 首页>>代码示例>>Java>>正文


Java MembershipEvent类代码示例

本文整理汇总了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;
    }
  }
  
}
 
开发者ID:javanotes,项目名称:reactive-data,代码行数:25,代码来源:AbstractMembershipEventObserver.java

示例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());
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:23,代码来源:HazelcastInstanceConsumer.java

示例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);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:18,代码来源:HazelcastInstanceConsumerTest.java

示例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);
  }
}
 
开发者ID:vert-x3,项目名称:vertx-hazelcast,代码行数:17,代码来源:HazelcastClusterManager.java

示例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);
  }
}
 
开发者ID:vert-x3,项目名称:vertx-hazelcast,代码行数:17,代码来源:HazelcastClusterManager.java

示例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);
}
 
开发者ID:ccfish86,项目名称:sctalk,代码行数:8,代码来源:MyClusterMembershipListener.java

示例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);
}
 
开发者ID:wso2,项目名称:mesos-artifacts,代码行数:16,代码来源:MesosMembershipScheme.java

示例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)));
}
 
开发者ID:ravikumaran2015,项目名称:ravikumaran201504,代码行数:8,代码来源:HazelcastClusterStore.java

示例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));

}
 
开发者ID:DaiDongLiang,项目名称:DSC,代码行数:10,代码来源:ControllerMembershipListener.java

示例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());
		}
	}
 
开发者ID:DaiDongLiang,项目名称:DSC,代码行数:30,代码来源:ClusterManager.java

示例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);
	}
}
 
开发者ID:dsukhoroslov,项目名称:bagri,代码行数:10,代码来源:TopologyManagement.java

示例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());
}
 
开发者ID:dsukhoroslov,项目名称:bagri,代码行数:11,代码来源:PopulationManagementImpl.java

示例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()));
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:14,代码来源:ClusterListener.java

示例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()); 
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:30,代码来源:ClusterListener.java

示例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);
    }
}
 
开发者ID:wso2,项目名称:carbon-business-process,代码行数:11,代码来源:BPELServerImpl.java


注:本文中的com.hazelcast.core.MembershipEvent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。