public abstract class Discovery extends Protocol
The FIND_INITIAL_MBRS event will eventually be answered with a FIND_INITIAL_MBRS_OK event up the stack. The following properties are available
Constructor and Description |
---|
Discovery() |
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
down(Event evt)
An event is to be sent down the stack.
|
java.util.List<PingRsp> |
findInitialMembers(Promise<JoinRsp> promise)
Finds the initial membership: sends a GET_MBRS_REQ to all members, waits 'timeout' ms or
until 'num_initial_members' have been retrieved
|
java.lang.String |
findInitialMembersAsString() |
int |
getNumberOfDiscoveryRequestsSent() |
int |
getNumInitialMembers() |
int |
getNumPingRequests() |
long |
getTimeout() |
void |
handleConnect() |
void |
handleDisconnect() |
void |
init()
Called after instance has been created (null constructor) and before protocol is started.
|
void |
localAddressSet(Address addr)
Called after local_addr was set
|
protected View |
makeView(java.util.Vector 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() |
abstract void |
sendGetMembersRequest() |
void |
setNumInitialMembers(int num_initial_members) |
void |
setNumPingRequests(int num_ping_requests) |
boolean |
setProperties(java.util.Properties props)
sets the properties of the PING protocol.
|
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.
|
destroy, downThreadEnabled, dumpStats, enableStats, getDownProtocol, getName, getProperties, getProtocolStack, getThreadFactory, getTransport, getUpProtocol, printStats, providedDownServices, requiredDownServices, requiredUpServices, setDownProtocol, setPropertiesInternal, setProtocolStack, setUpProtocol, statsEnabled, upThreadEnabled
public void init() throws java.lang.Exception
Protocol
public void localAddressSet(Address addr)
public abstract void sendGetMembersRequest()
public void handleDisconnect()
public void handleConnect()
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.util.Vector<java.lang.Integer> providedUpServices()
Protocol
providedUpServices
in class Protocol
public boolean setProperties(java.util.Properties props)
setProperties
in class Protocol
props
- - a property setpublic void resetStats()
resetStats
in class Protocol
public void start() throws java.lang.Exception
Protocol
Channel.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 Protocol
java.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()
Protocol
Channel.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 flushedpublic java.util.List<PingRsp> findInitialMembers(Promise<JoinRsp> promise)
public java.lang.String findInitialMembersAsString()
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 abovepublic 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.protected final View makeView(java.util.Vector mbrs)
Copyright ? 1998-2008 Bela Ban. All Rights Reserved.