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(); } }
@Override @SuppressWarnings("unchecked") public int compareTo( PeerID other ) { if( this == other ) return 0; if( other == null ) return 1; if (this == NULL_PEER_ID) { return -1; } int result = groupName.compareTo(other.getGroupName()); if (result != 0) { return result; } result = instanceName.compareTo(other.getInstanceName()); if (result != 0) { return result; } final Class<T> uniqueIDClass = (Class<T>) uniqueID.getClass(); if (Comparable.class.isAssignableFrom(uniqueIDClass) && uniqueIDClass.isAssignableFrom(other.getUniqueID().getClass())) { return ((Comparable<T>) uniqueID).compareTo((T) other.getUniqueID()); } else { return uniqueID.toString().compareTo(other.getUniqueID().toString()); } } }
@Override @SuppressWarnings("unchecked") public int compareTo( PeerID other ) { if( this == other ) return 0; if( other == null ) return 1; if (this == NULL_PEER_ID) { return -1; } int result = groupName.compareTo(other.getGroupName()); if (result != 0) { return result; } result = instanceName.compareTo(other.getInstanceName()); if (result != 0) { return result; } final Class<T> uniqueIDClass = (Class<T>) uniqueID.getClass(); if (Comparable.class.isAssignableFrom(uniqueIDClass) && uniqueIDClass.isAssignableFrom(other.getUniqueID().getClass())) { return ((Comparable<T>) uniqueID).compareTo((T) other.getUniqueID()); } else { return uniqueID.toString().compareTo(other.getUniqueID().toString()); } } }
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(); } }
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); }
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 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; } }
@Override 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(null, remoteSocketAddress, message, peerID); }
@Override 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(null, remoteSocketAddress, message, peerID); }
@SuppressWarnings( "unchecked" ) public void addRemotePeer( PeerID peerID, SelectionKey selectionKey ) { 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(selectionKey): 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 (LOG.isLoggable(Level.FINE)) { LOG.fine("addRemotePeer: " + instanceName + " peerId:" + peerID); } } if( selectionKey != null ) selectionKeyMap.put( selectionKey, instanceName ); } addToVMS(peerID); }
@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); }
@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); }
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.getMulticastPort() ); } else { throw new IOException( "peer ID must be GrizzlyPeerID type" ); } try { return send( remoteSocketAddress, null, message ); } catch( IOException ie ) { // once retry return send( remoteSocketAddress, null, message ); } }
@SuppressWarnings( "unchecked" ) public void addRemotePeer(final PeerID peerID, final Connection connection) { if (peerID == null) { return; } if (peerID.equals(localPeerID)) { return; // lookback } final String peerInstanceName = peerID.getInstanceName(); if (peerInstanceName != null && peerID.getUniqueID() instanceof GrizzlyPeerID) { final PeerID<GrizzlyPeerID> previous = peerIDMap.put(peerInstanceName, peerID); if (previous == null) { if (LOG.isLoggable(Level.FINE)) { LOG.log(Level.FINE, "addRemotePeer: {0} peerId:{1}", new Object[]{peerInstanceName, peerID}); } } if (connection != null) { obtainInstance(peerInstanceName).register(connection); } } addToVMS(peerID); }
@SuppressWarnings( "unchecked" ) public void addRemotePeer(final PeerID peerID, final Connection connection) { if (peerID == null) { return; } if (peerID.equals(localPeerID)) { return; // lookback } final String peerInstanceName = peerID.getInstanceName(); if (peerInstanceName != null && peerID.getUniqueID() instanceof GrizzlyPeerID) { final PeerID<GrizzlyPeerID> previous = peerIDMap.put(peerInstanceName, peerID); if (previous == null) { if (LOG.isLoggable(Level.FINE)) { LOG.log(Level.FINE, "addRemotePeer: {0} peerId:{1}", new Object[]{peerInstanceName, peerID}); } } if (connection != null) { obtainInstance(peerInstanceName).register(connection); } } addToVMS(peerID); }