|
|||||||||
| Home >> All >> com >> ubermq >> chord >> [ jms overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
com.ubermq.chord.jms
Class RemoteChordNode

java.lang.Objectcom.ubermq.chord.jms.RemoteChordNode
- All Implemented Interfaces:
- com.ubermq.chord.ChordNode, java.io.Serializable
- public class RemoteChordNode
- extends java.lang.Object
- implements com.ubermq.chord.ChordNode, java.io.Serializable
- extends java.lang.Object
A proxy for a remote chord node. This implementation uses JMS and the ChordMessage object hierarchy for connectivity.
This object may be serialized across the network as a way to describe chord nodes to other chord participants.
| Field Summary | |
private static java.util.Map |
cachedNodes
|
private java.lang.String |
commandTopic
|
private boolean |
connected
|
static long |
DEFAULT_QUERY_TIMEOUT
The default query timeout to wait for a response from the remote node. |
private com.ubermq.chord.ChordIdentifier |
identifier
|
private Mutex |
queryMutex
|
private javax.jms.TopicSubscriber |
replySub
|
private javax.jms.Topic |
replyTopic
|
static long |
serialVersionUID
|
private javax.jms.TopicConnection |
tc
|
private javax.jms.TopicPublisher |
tpub
|
private javax.jms.TopicSession |
ts
|
private java.net.URI |
uri
|
| Constructor Summary | |
private |
RemoteChordNode(com.ubermq.chord.ChordIdentifierFactory f,
java.net.URI remoteURI)
|
| Method Summary | |
private static void |
cache(java.net.URI uri,
RemoteChordNode n)
|
void |
close()
Closes the node's resources. |
com.ubermq.chord.ChordNode |
closestPrecedingFinger(com.ubermq.chord.ChordIdentifier id)
Returns the element of the finger table that most closely precedes the given identifier. |
void |
connect()
Connects to the service provider for the remote node. |
static RemoteChordNode |
createRemoteInstance(com.ubermq.chord.ChordIdentifierFactory f,
java.net.URI uri)
Constructs a remote chord node from a JMS topic connection factory. |
private void |
ensureConnected()
|
boolean |
equals(java.lang.Object o)
Determine whether this Object is semantically equal to another Object. |
static java.util.List |
findNodeAtURI(java.net.URI uri)
Given a non-specific URI of a message server, this method probes the server for connected nodes and returns the URI of one that is uniquely addressable. |
com.ubermq.chord.ChordNode[] |
fingers()
Returns the finger table for this node. |
static RemoteChordNode |
getRemoteRepresentation(com.ubermq.chord.ChordNodeProvider p)
Creates a remote chord node representation for a local chord node provider. |
int |
hashCode()
Get a value that represents this Object, as uniquely as possible within the confines of an int. |
com.ubermq.chord.ChordIdentifier |
identifier()
Returns the identifier for this node. |
boolean |
isConnected()
Returns true if the connect method has been invoked
successfully. |
void |
join(com.ubermq.chord.ChordInfrastructure i)
Joins the node to the specified infrastructure. |
void |
leave(com.ubermq.chord.ChordInfrastructure i)
Leaves the infrastructure, by notifying the immediate predecessor that we are going away. |
private static RemoteChordNode |
lookup(java.net.URI uri)
Looks for a remote node with the given URI in the big cache. |
void |
notify(com.ubermq.chord.ChordNode n)
Instructs the node that the specified node may be its predecessor. |
void |
notifyGoingAway(com.ubermq.chord.ChordNode n)
Instructs the node that the specified node is leaving the infrastructure. |
com.ubermq.chord.ChordNode |
predecessor()
Returns the predecessor of this node, defined as the node n such that n.successor() == this. |
java.lang.Object |
query(java.lang.Object key)
Queries the node for the object indexed at the specified key. |
private java.lang.Object |
readResolve()
Read resolution provides us a way to go through our cached local connections, rather than creating new ones every time. |
void |
store(java.lang.Object key,
java.lang.Object value)
Stores the specified object at the given key, on this node. |
com.ubermq.chord.ChordNode |
successor()
Returns the successor of this node. |
java.lang.String |
toHtml()
Returns an in-depth HTML description of this chord node. |
java.lang.String |
toString()
Convert this Object to a human-readable String. |
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
identifier
private final com.ubermq.chord.ChordIdentifier identifier
uri
private final java.net.URI uri
commandTopic
private final java.lang.String commandTopic
serialVersionUID
public static final long serialVersionUID
- See Also:
- Constant Field Values
connected
private transient boolean connected
queryMutex
private transient Mutex queryMutex
tc
private transient javax.jms.TopicConnection tc
ts
private transient javax.jms.TopicSession ts
tpub
private transient javax.jms.TopicPublisher tpub
replyTopic
private transient javax.jms.Topic replyTopic
replySub
private transient javax.jms.TopicSubscriber replySub
cachedNodes
private static final java.util.Map cachedNodes
DEFAULT_QUERY_TIMEOUT
public static final long DEFAULT_QUERY_TIMEOUT
- The default query timeout to wait for a response from the
remote node.
- See Also:
- Constant Field Values
| Constructor Detail |
RemoteChordNode
private RemoteChordNode(com.ubermq.chord.ChordIdentifierFactory f, java.net.URI remoteURI)
| Method Detail |
lookup
private static RemoteChordNode lookup(java.net.URI uri)
- Looks for a remote node with the given URI in the big cache.
cache
private static void cache(java.net.URI uri, RemoteChordNode n)
createRemoteInstance
public static RemoteChordNode createRemoteInstance(com.ubermq.chord.ChordIdentifierFactory f, java.net.URI uri)
- Constructs a remote chord node from a JMS topic connection
factory. The node must be connected with the
connectmethod before being used.
getRemoteRepresentation
public static RemoteChordNode getRemoteRepresentation(com.ubermq.chord.ChordNodeProvider p)
- Creates a remote chord node representation
for a local chord node provider.
findNodeAtURI
public static java.util.List findNodeAtURI(java.net.URI uri) throws javax.jms.JMSException
- Given a non-specific URI of a message server, this method
probes the server for connected nodes and returns the URI
of one that is uniquely addressable.
readResolve
private java.lang.Object readResolve() throws java.io.ObjectStreamException
- Read resolution provides us a way to go through
our cached local connections, rather than creating new ones
every time.
connect
public void connect()
throws javax.jms.JMSException
- Connects to the service provider for the remote node.
close
public void close()
- Description copied from interface:
com.ubermq.chord.ChordNode - Closes the node's resources.
- Specified by:
closein interfacecom.ubermq.chord.ChordNode
isConnected
public boolean isConnected()
- Returns true if the
connectmethod has been invoked successfully.
toString
public java.lang.String toString()
- Description copied from class:
java.lang.Object - Convert this Object to a human-readable String.
There are no limits placed on how long this String
should be or what it should contain. We suggest you
make it as intuitive as possible to be able to place
it into System.out.println() 55
and such.
It is typical, but not required, to ensure that this method never completes abruptly with a java.lang.RuntimeException.
This method will be called when performing string concatenation with this object. If the result is
null, string concatenation will instead use"null".The default implementation returns
getClass().getName() + "@" + Integer.toHexString(hashCode()).
toHtml
public java.lang.String toHtml()
- Description copied from interface:
com.ubermq.chord.ChordNode - Returns an in-depth HTML description of this chord node.
The information returned could include the set of keys
stored here, etc.
It is anticipated that this method may be costly to invoke. Please do not use it for debugging purposes.
- Specified by:
toHtmlin interfacecom.ubermq.chord.ChordNode
identifier
public com.ubermq.chord.ChordIdentifier identifier()
- Returns the identifier for this node.
- Specified by:
identifierin interfacecom.ubermq.chord.ChordNode
successor
public com.ubermq.chord.ChordNode successor()
- Returns the successor of this node.
- Specified by:
successorin interfacecom.ubermq.chord.ChordNode
predecessor
public com.ubermq.chord.ChordNode predecessor()
- Description copied from interface:
com.ubermq.chord.ChordNode - Returns the predecessor of this node, defined as the node
n such that
n.successor() == this.- Specified by:
predecessorin interfacecom.ubermq.chord.ChordNode
notify
public void notify(com.ubermq.chord.ChordNode n)
- Instructs the node that the specified node may be its predecessor.
- Specified by:
notifyin interfacecom.ubermq.chord.ChordNode
notifyGoingAway
public void notifyGoingAway(com.ubermq.chord.ChordNode n)
- Description copied from interface:
com.ubermq.chord.ChordNode - Instructs the node that the specified node is leaving the infrastructure.
This may be received by an existing predecessor or successor
node.
- Specified by:
notifyGoingAwayin interfacecom.ubermq.chord.ChordNode
closestPrecedingFinger
public com.ubermq.chord.ChordNode closestPrecedingFinger(com.ubermq.chord.ChordIdentifier id)
- Returns the element of the finger table
that most closely precedes the given identifier.
- Specified by:
closestPrecedingFingerin interfacecom.ubermq.chord.ChordNode
join
public void join(com.ubermq.chord.ChordInfrastructure i)
- Joins the node to the specified infrastructure. This causes the node
to perform any logic that is required to inform itself or
other nodes in the infrastructure about its presence.
- Specified by:
joinin interfacecom.ubermq.chord.ChordNode
leave
public void leave(com.ubermq.chord.ChordInfrastructure i)
- Description copied from interface:
com.ubermq.chord.ChordNode - Leaves the infrastructure, by notifying the immediate predecessor that
we are going away.
- Specified by:
leavein interfacecom.ubermq.chord.ChordNode
fingers
public com.ubermq.chord.ChordNode[] fingers()
- Returns the finger table for this node. The finger table is
a set of nodes, such that the i
th entry contains the identity of the first node that succeeds this node by at least 2i-1 on the identifier circle.- Specified by:
fingersin interfacecom.ubermq.chord.ChordNode
store
public void store(java.lang.Object key, java.lang.Object value)
- Stores the specified object at the given key, on this node.
The node may refuse the key if the hash value is not consistent.
- Specified by:
storein interfacecom.ubermq.chord.ChordNode
query
public java.lang.Object query(java.lang.Object key)
- Queries the node for the object indexed at the specified key.
- Specified by:
queryin interfacecom.ubermq.chord.ChordNode
ensureConnected
private void ensureConnected()
hashCode
public int hashCode()
- Description copied from class:
java.lang.Object - Get a value that represents this Object, as uniquely as
possible within the confines of an int.
There are some requirements on this method which subclasses must follow:
- Semantic equality implies identical hashcodes. In other
words, if
a.equals(b)is true, thena.hashCode() == b.hashCode()must be as well. However, the reverse is not necessarily true, and two objects may have the same hashcode without being equal. - It must be consistent. Whichever value o.hashCode() returns on the first invocation must be the value returned on all later invocations as long as the object exists. Notice, however, that the result of hashCode may change between separate executions of a Virtual Machine, because it is not invoked on the same object.
Notice that since
hashCodeis used in java.util.Hashtable and other hashing classes, a poor implementation will degrade the performance of hashing (so don't blindly implement it as returning a constant!). Also, if calculating the hash is time-consuming, a class may consider caching the results.The default implementation returns
System.identityHashCode(this) - Semantic equality implies identical hashcodes. In other
words, if
equals
public boolean equals(java.lang.Object o)
- Description copied from class:
java.lang.Object - Determine whether this Object is semantically equal
to another Object.
There are some fairly strict requirements on this method which subclasses must follow:
- It must be transitive. If
a.equals(b)andb.equals(c), thena.equals(c)must be true as well. - It must be symmetric.
a.equals(b)andb.equals(a)must have the same value. - It must be reflexive.
a.equals(a)must always be true. - It must be consistent. Whichever value a.equals(b) returns on the first invocation must be the value returned on all later invocations.
a.equals(null)must be false.- It must be consistent with hashCode(). That is,
a.equals(b)must implya.hashCode() == b.hashCode(). The reverse is not true; two objects that are not equal may have the same hashcode, but that has the potential to harm hashing performance.
This is typically overridden to throw a java.lang.ClassCastException if the argument is not comparable to the class performing the comparison, but that is not a requirement. It is legal for
a.equals(b)to be true even thougha.getClass() != b.getClass(). Also, it is typical to never cause a java.lang.NullPointerException.In general, the Collections API (
java.util) use theequalsmethod rather than the==operator to compare objects. However, java.util.IdentityHashMap is an exception to this rule, for its own good reasons.The default implementation returns
this == o. - It must be transitive. If
|
|||||||||
| Home >> All >> com >> ubermq >> chord >> [ jms overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
com.ubermq.chord.jms.RemoteChordNode