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.限定符和类型 | 字段和说明 |
---|---|
protected boolean |
always_send_physical_addr_with_discovery_request
已过时。
|
protected boolean |
async_discovery |
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
已过时。
|
protected int |
num_initial_srv_members
已过时。
|
protected java.util.Map<java.lang.Long,Responses> |
ping_responses |
protected boolean |
return_entire_cache |
protected long |
stagger_timeout |
protected long |
timeout
已过时。
|
protected TimeScheduler |
timer |
protected boolean |
transport_supports_multicasting |
protected boolean |
use_disk_cache |
protected View |
view |
protected static byte[] |
WHITESPACE |
构造器和说明 |
---|
Discovery() |
限定符和类型 | 方法和说明 |
---|---|
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) |
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. physical address, logical name) for the given member addresses.
|
boolean |
forceDiscoveryResponses() |
Discovery |
forceDiscoveryResponses(boolean f) |
java.lang.String |
getCurrentCoord() |
int |
getNumberOfDiscoveryRequestsSent() |
int |
getNumInitialMembers()
已过时。
|
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()
已过时。
|
Discovery |
numInitialMembers(int num)
已过时。
|
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) |
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)
已过时。
|
void |
setTimeout(long timeout) |
long |
staggerTimeout() |
Discovery |
staggerTimeout(long timeout) |
void |
start()
This method is called on a
Channel.connect(String) . |
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) |
protected void |
write(java.util.List<PingData> list,
java.io.OutputStream out) |
accept, destroy, dumpStats, enableStats, getConfigurableObjects, getDownProtocol, getDownServices, getId, getIdsAbove, getLevel, 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 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 java.lang.String getView()
public ViewId getViewId()
public java.lang.String getCurrentCoord()
protected boolean isMergeRunning()
public java.util.List<java.lang.Integer> providedUpServices()
Protocol
providedUpServices
在类中 Protocol
public void resetStats()
resetStats
在类中 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
在类中 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)
protected boolean addDiscoveryResponseToCaches(Address mbr, java.lang.String logical_name, PhysicalAddress physical_addr)
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)