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 class |
Discovery.DiscoveryCacheDisseminationTask |
Modifier and Type | Field and Description |
---|---|
protected boolean |
always_send_physical_addr_with_discovery_request
Deprecated.
|
protected boolean |
async_discovery |
protected boolean |
async_discovery_use_separate_thread_per_request |
protected boolean |
break_on_coord_rsp |
protected java.lang.String |
cluster_name |
protected Address |
current_coord |
protected long |
discovery_rsp_expiry_time |
protected boolean |
force_sending_discovery_rsps |
protected boolean |
is_coord |
protected boolean |
is_leaving |
protected boolean |
is_server |
protected Address |
local_addr |
protected int |
max_members_in_discovery_request |
protected java.util.List<Address> |
members |
protected int |
num_discovery_requests |
protected int |
num_initial_members
Deprecated.
|
protected int |
num_initial_srv_members
Deprecated.
|
protected java.util.Map<java.lang.Long,Responses> |
ping_responses |
protected boolean |
return_entire_cache |
protected boolean |
send_cache_on_join |
protected long |
stagger_timeout |
protected long |
timeout
Deprecated.
|
protected TimeScheduler |
timer |
protected boolean |
transport_supports_multicasting |
protected boolean |
use_disk_cache |
protected View |
view |
protected static byte[] |
WHITESPACE |
after_creation_hook, down_prot, ergonomics, id, log, name, stack, stats, up_prot
Constructor and Description |
---|
Discovery() |
Modifier and Type | Method and Description |
---|---|
protected boolean |
addDiscoveryResponseToCaches(Address mbr,
java.lang.String logical_name,
PhysicalAddress physical_addr) |
protected void |
addResponse(PingData rsp,
boolean overwrite) |
protected static java.lang.String |
addressAsString(Address address) |
void |
addToCache(java.lang.String filename) |
boolean |
breakOnCoordResponse() |
Discovery |
breakOnCoordResponse(boolean flag) |
protected static PingData |
deserialize(byte[] data) |
void |
discoveryRequestReceived(Address sender,
java.lang.String logical_name,
PhysicalAddress physical_addr) |
Discovery |
discoveryRspExpiryTime(long t) |
protected void |
disseminateDiscoveryInformation(java.util.List current_mbrs,
java.util.List<Address> left_mbrs,
java.util.List<Address> new_mbrs)
Disseminates cache information (UUID/IP adddress/port/name) to the given members
|
java.lang.Object |
down(Event evt)
An event is to be sent down the stack.
|
void |
dumpCache(java.lang.String output_filename) |
java.lang.String |
findInitialMembersAsString() |
Responses |
findMembers(java.util.List<Address> members,
boolean initial_discovery,
boolean async) |
protected abstract void |
findMembers(java.util.List<Address> members,
boolean initial_discovery,
Responses responses)
Fetches information (e.g.
|
boolean |
forceDiscoveryResponses() |
Discovery |
forceDiscoveryResponses(boolean f) |
java.lang.String |
getCurrentCoord() |
int |
getNumberOfDiscoveryRequestsSent() |
int |
getNumInitialMembers()
Deprecated.
|
long |
getTimeout() |
java.lang.String |
getView() |
ViewId |
getViewId() |
void |
handleConnect() |
void |
handleDisconnect() |
protected void |
handleDiscoveryResponse(PingData data,
Address sender) |
void |
init()
Called after instance has been created (null constructor) and before protocol is started.
|
protected boolean |
isCoord(Address member) |
abstract boolean |
isDynamic() |
protected boolean |
isMergeRunning() |
static Buffer |
marshal(PingData data) |
long |
numInitialMembers()
Deprecated.
|
Discovery |
numInitialMembers(int num)
Deprecated.
|
java.util.List<java.lang.Integer> |
providedUpServices()
List of events that are provided to layers above (they will be handled when sent down from above)
|
protected java.util.List<PingData> |
read(java.io.InputStream in) |
protected PingData |
readPingData(byte[] buffer,
int offset,
int length) |
void |
resetStats() |
boolean |
returnEntireCache() |
Discovery |
returnEntireCache(boolean flag) |
void |
sendCacheInformation() |
protected void |
sendDiscoveryResponse(Address logical_addr,
PhysicalAddress physical_addr,
java.lang.String logical_name,
Address sender,
boolean coord) |
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)
Deprecated.
|
void |
setTimeout(long timeout) |
long |
staggerTimeout() |
Discovery |
staggerTimeout(long timeout) |
void |
start()
This method is called on a
Channel.connect(String) . |
protected void |
startCacheDissemination(java.util.List<Address> curr_mbrs,
java.util.List<Address> left_mbrs,
java.util.List<Address> new_mbrs) |
void |
stop()
This method is called on a
Channel.disconnect() . |
long |
timeout() |
Discovery |
timeout(long timeout) |
java.lang.Object |
up(Event evt)
An event was received from the layer below.
|
boolean |
useDiskCache() |
Discovery |
useDiskCache(boolean flag) |
void |
weedOutCompletedDiscoveryResponses()
Removes responses which are done or whose timeout has expired (in the latter case, an expired response is marked as done)
|
protected void |
write(java.util.List<PingData> list,
java.io.OutputStream out) |
accept, afterCreationHook, destroy, dumpStats, enableStats, getConfigurableObjects, getDownProtocol, getDownServices, getId, getIdsAbove, getLevel, getLog, getName, getProtocolStack, getSocketFactory, getThreadFactory, getTransport, getUpProtocol, getUpServices, getValue, isErgonomics, level, parse, printStats, providedDownServices, requiredDownServices, requiredUpServices, resetStatistics, setDownProtocol, setErgonomics, setId, setLevel, setProtocolStack, setSocketFactory, setUpProtocol, setValue, setValues, statsEnabled, up
@Deprecated protected long timeout
@Deprecated 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 boolean use_disk_cache
@Deprecated protected boolean always_send_physical_addr_with_discovery_request
protected int max_members_in_discovery_request
protected long discovery_rsp_expiry_time
protected boolean async_discovery
protected boolean async_discovery_use_separate_thread_per_request
protected boolean send_cache_on_join
protected int num_discovery_requests
protected volatile boolean is_server
protected volatile boolean is_leaving
protected TimeScheduler timer
protected View view
protected final java.util.List<Address> members
protected boolean is_coord
protected Address local_addr
protected Address current_coord
protected java.lang.String cluster_name
protected final java.util.Map<java.lang.Long,Responses> ping_responses
protected boolean transport_supports_multicasting
protected static final byte[] WHITESPACE
public void setForceSendingDiscoveryRsps(boolean flag)
public void init() throws java.lang.Exception
Protocol
public abstract boolean isDynamic()
public void handleDisconnect()
public void handleConnect()
public void discoveryRequestReceived(Address sender, java.lang.String logical_name, PhysicalAddress physical_addr)
public long getTimeout()
public void setTimeout(long timeout)
@Deprecated public int getNumInitialMembers()
@Deprecated public void setNumInitialMembers(int num)
public int getNumberOfDiscoveryRequestsSent()
public long timeout()
public Discovery timeout(long timeout)
@Deprecated public long numInitialMembers()
@Deprecated public Discovery numInitialMembers(int num)
public boolean breakOnCoordResponse()
public Discovery breakOnCoordResponse(boolean flag)
public boolean returnEntireCache()
public Discovery returnEntireCache(boolean flag)
public long staggerTimeout()
public Discovery staggerTimeout(long timeout)
public boolean forceDiscoveryResponses()
public Discovery forceDiscoveryResponses(boolean f)
public boolean useDiskCache()
public Discovery useDiskCache(boolean flag)
public Discovery discoveryRspExpiryTime(long t)
public java.lang.String getView()
public ViewId getViewId()
public java.lang.String getCurrentCoord()
protected boolean isMergeRunning()
public void sendCacheInformation()
public java.util.List<java.lang.Integer> providedUpServices()
Protocol
providedUpServices
in class Protocol
public 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 flushedprotected abstract void findMembers(java.util.List<Address> members, boolean initial_discovery, Responses responses)
Responses
object. If async_discovery
is true, this method will be called
in a separate thread, otherwise the caller's thread will be used.members
- A list of logical addresses (typically UUID
s). If null, then information
for all members is fetchedinitial_discovery
- Set to true if this is for the initial membership discovery. Some protocols (e.g.
file based ones) may return only the information for the coordinator(s).responses
- The list to which responses should be addedpublic Responses findMembers(java.util.List<Address> members, boolean initial_discovery, boolean async)
public java.lang.String findInitialMembersAsString()
public void addToCache(java.lang.String filename) throws java.lang.Exception
java.lang.Exception
public void dumpCache(java.lang.String output_filename) throws java.lang.Exception
java.lang.Exception
public java.lang.Object up(Event evt)
Protocol
down_prot.down()
or c) the event (or another event) is sent up
the stack using up_prot.up()
.public java.lang.Object down(Event evt)
Protocol
down_prot.down()
. 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()
.protected java.util.List<PingData> read(java.io.InputStream in)
protected void write(java.util.List<PingData> list, java.io.OutputStream out) throws java.lang.Exception
java.lang.Exception
protected void addResponse(PingData rsp, boolean overwrite)
public void weedOutCompletedDiscoveryResponses()
protected boolean addDiscoveryResponseToCaches(Address mbr, java.lang.String logical_name, PhysicalAddress physical_addr)
protected void startCacheDissemination(java.util.List<Address> curr_mbrs, java.util.List<Address> left_mbrs, java.util.List<Address> new_mbrs)
protected byte[] serializeWithoutView(PingData data)
data
- the PingData instance to serialize.protected static PingData deserialize(byte[] data) throws java.lang.Exception
java.lang.Exception
protected PingData readPingData(byte[] buffer, int offset, int length)
protected void sendDiscoveryResponse(Address logical_addr, PhysicalAddress physical_addr, java.lang.String logical_name, Address sender, boolean coord)
protected static java.lang.String addressAsString(Address address)
protected boolean isCoord(Address member)
protected void disseminateDiscoveryInformation(java.util.List current_mbrs, java.util.List<Address> left_mbrs, java.util.List<Address> new_mbrs)
current_mbrs
- The current members. Guaranteed to be non-null. This is a copy and can be modified.left_mbrs
- The members which left. These are excluded from dissemination. Can be null if no members leftnew_mbrs
- The new members that we need to disseminate the information to. Will be all members if null.Copyright © 1998-2020 Red Hat. All Rights Reserved.