/** * {@inheritDoc} */ public String toString() { return "HealthMessage.Entry: Id = " + id.toString() + "; State = " + state + "; LastTimeStamp = " + timestamp + "; Sequence ID = " + seqID; }
@Override public int compareTo(Object o) { int result; if (o instanceof ProcessedMasterViewId) { ProcessedMasterViewId e = (ProcessedMasterViewId)o; result = master.compareTo(e.master); if (result == 0) { result = (int)(masterViewIdSeq - e.masterViewIdSeq); } return result; } else { throw new IllegalArgumentException(); } }
@Override @SuppressWarnings( "unchecked" ) public void addRemotePeer( PeerID peerID ) { if( peerID == null ) return; if( peerID.equals( localPeerID ) ) return; // lookback String instanceName = peerID.getInstanceName(); if( instanceName != null && peerID.getUniqueID() instanceof GrizzlyPeerID ) { // PeerID<GrizzlyPeerID> previous = peerIDMap.get(instanceName); // if (previous != null) { // if (previous.getUniqueID().getTcpPort() != ((GrizzlyPeerID) peerID.getUniqueID()).tcpPort) { // LOG.log(Level.WARNING, "addRemotePeer: assertion failure: no mapping should have existed for member:" // + instanceName + " existingID=" + previous + " adding peerid=" + peerID, new Exception("stack trace")); // } // } PeerID<GrizzlyPeerID> previous = peerIDMap.put( instanceName, peerID ); if (previous == null) { if (nomcastLogger.isLoggable(Level.FINE)) { nomcastLogger.log(Level.FINE, "addRemotePeer: " + instanceName + " peerId:" + peerID, new Exception("stack trace")); } } } addToVMS(peerID); }
public boolean equals( Object other ) { if (this == other) { // check if this and other are both same Peerid. Works if both are NULL_PEER_ID. return true; } else if( other instanceof PeerID ) { boolean equal = true; PeerID otherPeerID = (PeerID)other; if( uniqueID != null && uniqueID.equals( otherPeerID.getUniqueID() ) ) { if( groupName != null ) equal = groupName.equals( otherPeerID.getGroupName() ); if( !equal ) return false; if( instanceName != null ) equal = instanceName.equals( otherPeerID.getInstanceName() ); if( !equal ) return false; } else { return false; } return true; } else { return false; } }
String dumpView() { StringBuffer sb = new StringBuffer(); viewLock.lock(); try { sb.append("clusterviewmanager snapshot: group:" + manager.getGroupName() + " current view id=" + this.viewId + " \n"); int counter = 0; for (Map.Entry<PeerID,SystemAdvertisement> current : view.entrySet()) { PeerID peerid = current.getKey(); SystemAdvertisement sa = current.getValue(); sb.append(++counter).append(". "); sb.append(peerid.getInstanceName()); sb.append(" "); sb.append(peerid.getUniqueID().toString()); sb.append('\n'); } } finally { viewLock.unlock(); } return sb.toString(); } }
public String getMemberStateViaLWR(final PeerID peerID, long timeout) { if (peerID.equals(localPeerID)){ LOG.finer("getMemberStateViaLWR send query to " + peerID.toString()); } catch (IOException e) { ioe = true; LOG.log(Level.FINE, "Could not send the LWR Multicast message to get the member state of " + peerID.toString() + " IOException : " + e.getMessage());
/** * Since MasterNode reports on other peers that they are DEAD or INDOUBT, be sure not to compare sequence ids between * a peer and a MasterNode health message report on that peer. * * @param other the entry of other peer * @return true if this HM.entry and other are from same member. */ public boolean isFromSameMember(HealthMessage.Entry other) { return (other != null && id.equals(other.id)); }
LOG.log(Level.FINER, "Unicasting Message to :" + peerid.toString()); msgSendStat = getMsgSendStats(peerid.getInstanceName()); sent = manager.getNetworkManager().send( peerid, msg ); msgSendStat.sendSucceeded();
public String toString() { return "ProcessedMasterViewId master:" + master.getInstanceName() + " masterViewSequenceID=" + masterViewIdSeq + " receivedTime=" + new Date(receivedTime); }
public boolean resend(PeerID to, Long seqId) throws IOException { boolean result = false; ReliableBroadcast rb = sendHistory.get(seqId); if (rb != null) { Message msg = rb.msg; msg.addMessageElement("RESEND", Boolean.TRUE); result = manager.getNetworkManager().send(to, rb.msg); rb.resends++; if (logger.isLoggable(Level.FINE)) { logger.log(Level.FINE, "mgmt.reliable.mcast.resend", new Object[]{seqId, to.getInstanceName(),to.getGroupName(), rb.resends, clusterViewEventMsgToString(msg)}); } } else if (logger.isLoggable(Level.FINE)) { logger.log(Level.FINE, "mgmt.reliable.mcast.resend.failed", new Object[]{seqId, to.getInstanceName(),to.getGroupName()}); } return result; }
tcpStartPort, null, -1); return new PeerID<GrizzlyPeerID>(gpID, localPeerID.getGroupName(), port = tcpStartPort; return new PeerID<GrizzlyPeerID>( new GrizzlyPeerID( discoveryUri.getHost(), port, multicastAddress, multicastPort ), localPeerID.getGroupName(),
if (isMasterAssigned() && masterId != null && masterId.equals(master)) { boolean entered = false; if (lastCheckedMaster == null || lastCheckedMasterViewID != latestMasterViewID) { entered = true; if (mcastLogger.isLoggable(DEBUG_TRACE)) { mcastLogger.log(DEBUG_TRACE, "enter checkForMissedMasterChangeEvents master:" + master.getInstanceName() + " latestMasterViewSeqID=" + latestMasterViewID); new Object[]{ master.getInstanceName(), latestMasterViewID , missed, lastCheckedMasterViewID}); if (mcastLogger.isLoggable(DEBUG_TRACE)){ mcastLogger.log(DEBUG_TRACE, "exit checkForMissedMasterChangeEvents master:" + master.getInstanceName() + " latestMasterViewSeqID=" + latestMasterViewID+ " lastCheckedMasterViewID:" + lastCheckedMasterViewID );
/** * {@inheritDoc} */ public int hashCode() { return id.hashCode() * 45191; }
protected boolean doSend( final PeerID peerID, final Message message ) throws IOException { if( peerID == null ) throw new IOException( "peer ID can not be null" ); Serializable uniqueID = peerID.getUniqueID(); SocketAddress remoteSocketAddress; if( uniqueID instanceof GrizzlyPeerID ) { GrizzlyPeerID grizzlyPeerID = (GrizzlyPeerID)uniqueID; remoteSocketAddress = new InetSocketAddress( grizzlyPeerID.getHost(), grizzlyPeerID.getTcpPort() ); } else { throw new IOException( "peer ID must be GrizzlyPeerID type" ); } return send(remoteSocketAddress, null, message, peerID); }
throw new IOException("can not find an unique host"); localPeerID = new PeerID<GrizzlyPeerID>(new GrizzlyPeerID(uniqueHost, tcpPort, multicastAddress, multicastPort), groupName, instanceName); peerIDMap.put(instanceName, localPeerID);
targetPeerID = (PeerID)element; if( sourcePeerID != null && !localPeerID.getGroupName().equals( sourcePeerID.getGroupName() ) ) return; // drop the different group's packet
public boolean equals( Object other ) { if (this == other) { // check if this and other are both same Peerid. Works if both are NULL_PEER_ID. return true; } else if( other instanceof PeerID ) { boolean equal = true; PeerID otherPeerID = (PeerID)other; if( uniqueID != null && uniqueID.equals( otherPeerID.getUniqueID() ) ) { if( groupName != null ) equal = groupName.equals( otherPeerID.getGroupName() ); if( !equal ) return false; if( instanceName != null ) equal = instanceName.equals( otherPeerID.getInstanceName() ); if( !equal ) return false; } else { return false; } return true; } else { return false; } }
public String getMemberStateViaLWR(final PeerID peerID, long timeout) { if (peerID.equals(localPeerID)){ LOG.finer("getMemberStateViaLWR send query to " + peerID.toString()); } catch (IOException e) { ioe = true; LOG.log(Level.FINE, "Could not send the LWR Multicast message to get the member state of " + peerID.toString() + " IOException : " + e.getMessage());
/** * Since MasterNode reports on other peers that they are DEAD or INDOUBT, be sure not to compare sequence ids between * a peer and a MasterNode health message report on that peer. * * @param other the entry of other peer * @return true if this HM.entry and other are from same member. */ public boolean isFromSameMember(HealthMessage.Entry other) { return (other != null && id.equals(other.id)); }
LOG.log(Level.FINER, "Unicasting Message to :" + peerid.toString()); msgSendStat = getMsgSendStats(peerid.getInstanceName()); sent = manager.getNetworkManager().send( peerid, msg ); msgSendStat.sendSucceeded();