|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jgroups.stack.Protocol
org.jgroups.protocols.Discovery
public abstract class Discovery
The Discovery protocol layer retrieves the initial membership (used by the GMS when started by sending event FIND_INITIAL_MBRS down the stack). We do this by specific subclasses, e.g. by mcasting PING requests to an IP MCAST address or, if gossiping is enabled, by contacting the GossipRouter. The responses should allow us to determine the coordinator whom we have to contact, e.g. in case we want to join the group. When we are a server (after having received the BECOME_SERVER event), we'll respond to PING requests with a PING response.
The FIND_INITIAL_MBRS event will eventually be answered with a FIND_INITIAL_MBRS_OK event up the stack. The following properties are available
| Nested Class Summary | |
|---|---|
protected class |
Discovery.PingSenderTask
|
protected static class |
Discovery.Responses
|
| Field Summary | |
|---|---|
protected boolean |
break_on_coord_rsp
|
protected java.lang.String |
group_addr
|
protected boolean |
is_server
|
protected Address |
local_addr
|
protected int |
max_found_members
The largest cluster size found so far (gets reset on stop()) |
protected int |
max_rank
|
protected java.util.Vector<Address> |
members
|
protected int |
num_discovery_requests
|
protected int |
num_initial_members
|
protected int |
num_initial_srv_members
|
protected int |
num_ping_requests
|
protected java.util.Set<Discovery.Responses> |
ping_responses
|
protected int |
rank
|
protected boolean |
return_entire_cache
|
protected Discovery.PingSenderTask |
sender
|
protected long |
stagger_timeout
|
protected long |
timeout
|
protected TimeScheduler |
timer
|
protected View |
view
|
| Fields inherited from class org.jgroups.stack.Protocol |
|---|
down_prot, ergonomics, id, log, name, stack, stats, up_prot |
| Constructor Summary | |
|---|---|
Discovery()
|
|
| Method Summary | |
|---|---|
protected PingData |
deserialize(byte[] data)
|
void |
discoveryRequestReceived(Address sender,
java.lang.String logical_name,
java.util.Collection<PhysicalAddress> physical_addrs)
|
java.lang.Object |
down(Event evt)
An event is to be sent down the stack. |
java.util.List<PingData> |
findAllViews(Promise<JoinRsp> promise)
|
java.lang.String |
findAllViewsAsString()
|
java.util.List<PingData> |
findInitialMembers(Promise<JoinRsp> promise)
Finds initial members |
java.lang.String |
findInitialMembersAsString()
|
protected java.util.List<PingData> |
findMembers(Promise<JoinRsp> promise,
int num_expected_rsps,
boolean break_on_coord,
ViewId view_id)
|
int |
getNumberOfDiscoveryRequestsSent()
|
int |
getNumInitialMembers()
|
int |
getNumPingRequests()
|
long |
getTimeout()
|
java.lang.String |
getView()
|
ViewId |
getViewId()
|
void |
handleConnect()
|
void |
handleDisconnect()
|
void |
init()
Called after instance has been created (null constructor) and before protocol is started. |
abstract boolean |
isDynamic()
|
protected View |
makeView(java.util.Vector<Address> mbrs)
|
java.util.Vector<java.lang.Integer> |
providedUpServices()
List of events that are provided to layers above (they will be handled when sent down from above). |
void |
resetStats()
|
protected void |
sendDiscoveryResponse(Address logical_addr,
java.util.List<PhysicalAddress> physical_addrs,
boolean is_server,
boolean return_view_only,
java.lang.String logical_name,
Address sender)
|
abstract void |
sendGetMembersRequest(java.lang.String cluster_name,
Promise promise,
ViewId view_id)
|
protected byte[] |
serializeWithoutView(PingData data)
Creates a byte[] representation of the PingData, but DISCARDING the view it contains. |
void |
setNumInitialMembers(int num_initial_members)
|
void |
setNumPingRequests(int num_ping_requests)
|
void |
setTimeout(long timeout)
|
void |
start()
This method is called on a Channel.connect(String). |
void |
stop()
This method is called on a Channel.disconnect(). |
java.lang.Object |
up(Event evt)
An event was received from the layer below. |
| Methods inherited from class org.jgroups.stack.Protocol |
|---|
destroy, downThreadEnabled, dumpStats, enableStats, getConfigurableObjects, getDownProtocol, getId, getLevel, getName, getProperties, getProtocolStack, getSocketFactory, getThreadFactory, getTransport, getUpProtocol, getValue, isErgonomics, printStats, providedDownServices, requiredDownServices, requiredUpServices, setDownProtocol, setErgonomics, setId, setLevel, setProperties, setPropertiesInternal, setProperty, setProtocolStack, setSocketFactory, setUpProtocol, setValue, setValues, statsEnabled, upThreadEnabled |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected long timeout
protected int num_initial_members
protected int num_initial_srv_members
protected boolean break_on_coord_rsp
protected int num_ping_requests
protected boolean return_entire_cache
protected int max_rank
protected long stagger_timeout
protected int num_discovery_requests
protected volatile int max_found_members
protected int rank
protected volatile boolean is_server
protected TimeScheduler timer
protected View view
protected final java.util.Vector<Address> members
protected Address local_addr
protected java.lang.String group_addr
protected final java.util.Set<Discovery.Responses> ping_responses
protected final Discovery.PingSenderTask sender
| Constructor Detail |
|---|
public Discovery()
| Method Detail |
|---|
public void init()
throws java.lang.Exception
Protocol
init in class Protocoljava.lang.Exception - Thrown if protocol cannot be initialized successfully. This will cause the
ProtocolStack to fail, so the channel constructor will throw an exception
public abstract void sendGetMembersRequest(java.lang.String cluster_name,
Promise promise,
ViewId view_id)
throws java.lang.Exception
java.lang.Exceptionpublic abstract boolean isDynamic()
public void handleDisconnect()
public void handleConnect()
public void discoveryRequestReceived(Address sender,
java.lang.String logical_name,
java.util.Collection<PhysicalAddress> physical_addrs)
public long getTimeout()
public void setTimeout(long timeout)
public int getNumInitialMembers()
public void setNumInitialMembers(int num_initial_members)
public int getNumPingRequests()
public void setNumPingRequests(int num_ping_requests)
public int getNumberOfDiscoveryRequestsSent()
public java.lang.String getView()
public ViewId getViewId()
public java.util.Vector<java.lang.Integer> providedUpServices()
Protocol
providedUpServices in class Protocolpublic void resetStats()
resetStats in class Protocol
public void start()
throws java.lang.Exception
ProtocolChannel.connect(String). Starts work.
Protocols are connected and queues are ready to receive events.
Will be called from bottom to top. This call will replace
the START and START_OK events.
start in class Protocoljava.lang.Exception - Thrown if protocol cannot be started successfully. This will cause the ProtocolStack
to fail, so Channel.connect(String) will throw an exceptionpublic void stop()
ProtocolChannel.disconnect(). Stops work (e.g. by closing multicast socket).
Will be called from top to bottom. This means that at the time of the method invocation the
neighbor protocol below is still working. This method will replace the
STOP, STOP_OK, CLEANUP and CLEANUP_OK events. The ProtocolStack guarantees that
when this method is called all messages in the down queue will have been flushed
stop in class Protocolpublic java.util.List<PingData> findInitialMembers(Promise<JoinRsp> promise)
promise -
public java.util.List<PingData> findAllViews(Promise<JoinRsp> promise)
protected java.util.List<PingData> findMembers(Promise<JoinRsp> promise,
int num_expected_rsps,
boolean break_on_coord,
ViewId view_id)
public java.lang.String findInitialMembersAsString()
public java.lang.String findAllViewsAsString()
public java.lang.Object up(Event evt)
PassDown or c) the event (or another event) is sent up
the stack using PassUp.
For the PING protocol, the Up operation does the following things.
1. If the event is a Event.MSG then PING will inspect the message header.
If the header is null, PING simply passes up the event
If the header is PingHeader.GET_MBRS_REQ then the PING protocol
will PassDown a PingRequest message
If the header is PingHeader.GET_MBRS_RSP we will add the message to the initial members
vector and wake up any waiting threads.
2. If the event is Event.SET_LOCAL_ADDR we will simple set the local address of this protocol
3. For all other messages we simple pass it up to the protocol above
up in class Protocolevt - - the event that has been sent from the layer belowpublic java.lang.Object down(Event evt)
PassDown. In case of a GET_ADDRESS event (which tries to
retrieve the stack's address from one of the bottom layers), the layer may need to send
a new response event back up the stack using up_prot.up().
The PING protocol is interested in several different down events,
Event.FIND_INITIAL_MBRS - sent by the GMS layer and expecting a GET_MBRS_OK
Event.TMP_VIEW and Event.VIEW_CHANGE - a view change event
Event.BECOME_SERVER - called after client has joined and is fully working group member
Event.CONNECT, Event.DISCONNECT.
down in class Protocolprotected final View makeView(java.util.Vector<Address> mbrs)
protected byte[] serializeWithoutView(PingData data)
data - the PingData instance to serialize.
protected PingData deserialize(byte[] data)
protected void sendDiscoveryResponse(Address logical_addr,
java.util.List<PhysicalAddress> physical_addrs,
boolean is_server,
boolean return_view_only,
java.lang.String logical_name,
Address sender)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||