@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; } } }
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()); } }
@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); }
@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); } }
@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); } }
@Override public void memberRemoved(MembershipEvent membershipEvent) { String uuid = membershipEvent.getMember().getUuid(); logger.info("关闭连接: {}", uuid); messageServerManager.unload(uuid); // userClientInfoManager.unloadServer(uuid); }
@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); }
@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))); }
@Override public void memberRemoved(MembershipEvent event) { long begin =System.currentTimeMillis(); cluster.controllerRemoved(event); long end=System.currentTimeMillis(); System.out.println("translation time:"+(end-begin)); }
@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()); } }
@Override public void memberRemoved(MembershipEvent membershipEvent) { try { ObjectName topName = TopologyManager.getMemberName(membershipEvent.getMember()); mbeanExporter.unregisterManagedResource(topName); } catch (MalformedObjectNameException ex) { logger.error("memberRemoved.error; ", ex); } }
@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()); }
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())); }
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()); }
@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); } }
/** * {@inheritDoc} */ @Override public void memberRemoved(final MembershipEvent membershipEvent) { final String removedMemberId = membershipEvent.getMember().getUuid(); logger.info("Found there is one node removed from this cluster: {}", removedMemberId); final Optional<NodeRecord> masterNode = this.hazelcastHelper.getMasterNodeRecord(); if (!masterNode.isPresent() || StringUtils.equals(removedMemberId, masterNode.get().getMemberId())) { logger.info("The removed node is a master node. Trying to become the master node."); this.hazelcastHelper.setMaster(this); } else { logger.info("The current master node: {}", masterNode.get()); } }
/** * {@inheritDoc} */ @Override public void memberAdded(MembershipEvent membershipEvent) { Member member = membershipEvent.getMember(); log.info("Handling cluster gossip: New member joined to the cluster. Member Socket Address:" + member.getSocketAddress() + " UUID:" + member.getUuid()); checkAndNotifyCoordinatorChange(); int maximumNumOfTries = 3; String nodeId; int numberOfAttemptsTried = 0; /* * Try a few times until nodeId is read from distributed Hazelcast Map * and give up */ nodeId = configurableClusterAgent.getIdOfNode(member); if (null == nodeId) { while (numberOfAttemptsTried < maximumNumOfTries) { try { // Exponentially increase waiting time long sleepTime = Math.round(Math.pow(2, (numberOfAttemptsTried))); TimeUnit.SECONDS.sleep(sleepTime); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } nodeId = configurableClusterAgent.getIdOfNode(member); numberOfAttemptsTried = numberOfAttemptsTried + 1; if (!(StringUtils.isEmpty(nodeId))) { break; } } } if (StringUtils.isEmpty(nodeId)) { log.warn("Node ID is not set for member " + member + " when newly joined"); } configurableClusterAgent.memberAdded(nodeId); }
/** * {@inheritDoc} */ @Override public void memberRemoved(MembershipEvent membershipEvent) { Member member = membershipEvent.getMember(); log.info("Handling cluster gossip: A member left the cluster. Member Socket Address:" + member.getSocketAddress() + " UUID:" + member.getUuid()); try { checkAndNotifyCoordinatorChange(); configurableClusterAgent.memberRemoved(configurableClusterAgent.getIdOfNode(member)); } catch (AndesException e) { log.error("Error while handling node removal, " + member.getSocketAddress(), e); } }
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(); } if (CacheFactory.isSeniorClusterMember()) { 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()); }
@Override public void memberAdded(final MembershipEvent event) { // This method will be called from the Hazelcast context so we have // to make sure we call Vert.x handlers on the proper context. for (final Handler<String> handler : joinHandlers) { context.run(new Runnable() { @Override public void run() { handler.handle(event.getMember().getUuid()); } }); } }
@Override public void memberRemoved(final MembershipEvent event) { // This method will be called from the Hazelcast context so we have // to make sure we call Vert.x handlers on the proper context. for (final Handler<String> handler : leaveHandlers) { context.run(new Runnable() { @Override public void run() { handler.handle(event.getMember().getUuid()); } }); } }
public void memberAdded(MembershipEvent membershipEvent) { InetSocketAddress address = membershipEvent.getMember().getInetSocketAddress(); Collection<InetSocketAddress> addresses = AddressHelper.getPossibleSocketAddresses(address.getAddress(), address.getPort()); clusterMembers.addAll(addresses); initialClusterMembers.addAll(addresses); }
@Override public void memberAdded(MembershipEvent membershipEvent) { String uuid = membershipEvent.getMember().getUuid(); logger.info("建立连接: {}", uuid); }
@Override synchronized public void memberAdded(MembershipEvent membershipEvent) { currentMembers = membershipEvent.getMembers(); updatePlaces(); }
@Override synchronized public void memberRemoved(MembershipEvent membershipEvent) { runtime.failureTime = System.nanoTime(); currentMembers = membershipEvent.getMembers(); updatePlaces(); }
@Override public void memberRemoved(MembershipEvent membershipEvent) { Member member = membershipEvent.getMember(); carbonCluster.memberRemoved(member); log.info(String.format("Member left: [UUID] %s, [Address] %s", member.getUuid(), member.getSocketAddress().toString())); }
@Override public void memberAdded(final MembershipEvent event) { setChanged(); notifyObservers(event); }
@Override public void memberAdded(MembershipEvent arg0) { checkConnected(); }
@Override public void memberRemoved(MembershipEvent arg0) { checkConnected(); }
public void memberAdded(MembershipEvent event) { this.sendExchange(event, HazelcastConstants.ADDED); }
public void memberRemoved(MembershipEvent event) { this.sendExchange(event, HazelcastConstants.REMOVED); }
@Test public void testRemoveInstance() throws InterruptedException { MockEndpoint removed = getMockEndpoint("mock:removed"); removed.setExpectedMessageCount(1); when(member.getSocketAddress()).thenReturn(new InetSocketAddress("foo.bar", 12345)); MembershipEvent event = new MembershipEvent(cluster, member, MembershipEvent.MEMBER_REMOVED, null); argument.getValue().memberRemoved(event); assertMockEndpointsSatisfied(5000, TimeUnit.MILLISECONDS); // check headers Exchange ex = removed.getExchanges().get(0); Map<String, Object> headers = ex.getIn().getHeaders(); this.checkHeaders(headers, HazelcastConstants.REMOVED); }
@Override public void memberAdded(final MembershipEvent event) { m_logger.debug("Member added: {} {}", event.getMember().getSocketAddress(), event.getMember().getUuid()); }
@Override public void memberRemoved(final MembershipEvent event) { m_logger.debug("Member removed: {} {}", event.getMember().getSocketAddress(), event.getMember().getUuid()); }
@Override public void memberAdded(MembershipEvent membershipEvent) { log.info("Member {} added", membershipEvent.getMember()); ControllerNode node = addNode(node(membershipEvent.getMember())); notifyDelegate(new ClusterEvent(INSTANCE_ACTIVATED, node)); }
@Override public void memberAdded(MembershipEvent membershipEvent) { logger.trace("memberAdded.enter; event: {}", membershipEvent); //int cnt = initMember(membershipEvent.getMember()); //logger.trace("memberAdded.exit; {} clients initialized", cnt); }
@Override public void memberRemoved(MembershipEvent membershipEvent) { logger.trace("memberRemoved.enter; event: {}", membershipEvent); int cnt = denitMember(membershipEvent.getMembers(), membershipEvent.getMember()); logger.trace("memberRemoved.exit; {} schemas de-initialized", cnt); }