public abstract class Discovery extends Protocol
PING
) or, if gossiping is enabled,
by contacting the GossipRouter (TCPGOSSIP
).
The responses should allow us to determine the coordinator which we have to contact, e.g. in case we want to join
the group, or to see if we have diverging views in case of MERGE2.
When we are a server (after having received the BECOME_SERVER event), we'll respond to discovery requests with
a discovery response.Modifier and Type | Class and Description |
---|---|
protected static class |
Discovery.Responses |
Modifier and Type | Field and Description |
---|---|
protected boolean |
break_on_coord_rsp |
protected Address |
current_coord |
protected boolean |
force_sending_discovery_rsps |
protected String |
group_addr |
protected boolean |
is_coord |
protected boolean |
is_leaving |
protected boolean |
is_server |
protected Address |
local_addr |
protected List<Address> |
members |
protected int |
num_discovery_requests |
protected int |
num_initial_members |
protected int |
num_initial_srv_members
Deprecated.
|
protected Set<Discovery.Responses> |
ping_responses |
protected boolean |
return_entire_cache |
protected long |
stagger_timeout |
protected long |
timeout |
protected TimeScheduler |
timer |
protected View |
view |
Constructor and Description |
---|
Discovery() |
Modifier and Type | Method and Description |
---|---|
protected PingData |
deserialize(byte[] data) |
void |
discoveryRequestReceived(Address sender,
String logical_name,
Collection<PhysicalAddress> physical_addrs) |
Object |
down(Event evt)
An event is to be sent down the stack.
|
abstract Collection<PhysicalAddress> |
fetchClusterMembers(String cluster_name)
Grab all current cluster members
|
List<PingData> |
findAllViews(Promise<JoinRsp> promise) |
String |
findAllViewsAsString() |
List<PingData> |
findInitialMembers(Promise<JoinRsp> promise)
Finds initial members
|
String |
findInitialMembersAsString() |
protected List<PingData> |
findMembers(Promise<JoinRsp> promise,
int num_expected_rsps,
boolean break_on_coord,
ViewId view_id) |
String |
getCurrentCoord() |
int |
getNumberOfDiscoveryRequestsSent() |
int |
getNumInitialMembers() |
long |
getTimeout() |
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 boolean |
isMergeRunning() |
List<Integer> |
providedUpServices()
List of events that are provided to layers above (they will be handled when sent down from
above).
|
void |
resetStats() |
void |
sendDiscoveryRequest(String cluster_name,
Promise promise,
ViewId view_id) |
abstract boolean |
sendDiscoveryRequestsInParallel()
Whether or not to send each discovery request on a separate (timer) thread.
|
protected void |
sendDiscoveryResponse(Address logical_addr,
List<PhysicalAddress> physical_addrs,
boolean is_server,
boolean return_view_only,
String logical_name,
Address sender) |
protected void |
sendMcastDiscoveryRequest(Message discovery_request) |
protected byte[] |
serializeWithoutView(PingData data)
Creates a byte[] representation of the PingData, but DISCARDING the view it contains.
|
void |
setForceSendingDiscoveryRsps(boolean flag) |
void |
setNumInitialMembers(int num_initial_members) |
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() . |
Object |
up(Event evt)
An event was received from the layer below.
|
destroy, dumpStats, enableStats, getConfigurableObjects, getDownProtocol, getId, getLevel, getName, getProtocolStack, getSocketFactory, getThreadFactory, getTransport, getUpProtocol, getValue, isErgonomics, printStats, providedDownServices, requiredDownServices, requiredUpServices, resetStatistics, setDownProtocol, setErgonomics, setId, setLevel, setProtocolStack, setSocketFactory, setUpProtocol, setValue, setValues, statsEnabled
protected long timeout
protected int num_initial_members
@Deprecated protected int num_initial_srv_members
protected boolean break_on_coord_rsp
protected boolean return_entire_cache
protected long stagger_timeout
protected boolean force_sending_discovery_rsps
protected int num_discovery_requests
protected volatile boolean is_server
protected volatile boolean is_leaving
protected TimeScheduler timer
protected View view
protected boolean is_coord
protected Address local_addr
protected Address current_coord
protected String group_addr
protected final Set<Discovery.Responses> ping_responses
public void setForceSendingDiscoveryRsps(boolean flag)
public void init() throws Exception
Protocol
public abstract Collection<PhysicalAddress> fetchClusterMembers(String cluster_name)
cluster_name
- public abstract boolean sendDiscoveryRequestsInParallel()
fetchClusterMembers(String)
sequentiallypublic abstract boolean isDynamic()
public void handleDisconnect()
public void handleConnect()
public void discoveryRequestReceived(Address sender, String logical_name, Collection<PhysicalAddress> physical_addrs)
public long getTimeout()
public void setTimeout(long timeout)
public int getNumInitialMembers()
public void setNumInitialMembers(int num_initial_members)
public int getNumberOfDiscoveryRequestsSent()
public String getView()
public ViewId getViewId()
public String getCurrentCoord()
protected boolean isMergeRunning()
public List<Integer> providedUpServices()
Protocol
providedUpServices
in class Protocol
public void resetStats()
resetStats
in class Protocol
public void start() throws 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
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 List<PingData> findInitialMembers(Promise<JoinRsp> promise)
promise
- protected List<PingData> findMembers(Promise<JoinRsp> promise, int num_expected_rsps, boolean break_on_coord, ViewId view_id)
public void sendDiscoveryRequest(String cluster_name, Promise promise, ViewId view_id) throws Exception
Exception
protected void sendMcastDiscoveryRequest(Message discovery_request)
public String findInitialMembersAsString()
public String findAllViewsAsString()
public 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 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 byte[] serializeWithoutView(PingData data)
data
- the PingData instance to serialize.protected PingData deserialize(byte[] data)
protected void sendDiscoveryResponse(Address logical_addr, List<PhysicalAddress> physical_addrs, boolean is_server, boolean return_view_only, String logical_name, Address sender)
Copyright © 2012 JBoss by Red Hat. All Rights Reserved.