Package org.jgroups.protocols
Class FD_SOCK2
java.lang.Object
org.jgroups.stack.Protocol
org.jgroups.protocols.FD_SOCK2
- All Implemented Interfaces:
ConnectionListener,Receiver,Lifecycle,ProcessingQueue.Handler<FD_SOCK2.Request>
public class FD_SOCK2
extends Protocol
implements Receiver, ConnectionListener, ProcessingQueue.Handler<FD_SOCK2.Request>
Failure detection protocol based on TCP connections, successor to
FD_SOCK. The design
is at ./docs/design/FD_SOCK2.txt-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classTask which periodically broadcasts a list of suspected members.static classprotected static classprotected static classprotected static enum -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final FD_SOCK2.BroadcastTaskprotected InetAddressprotected intprotected Stringprotected intprotected InetAddressprotected intprotected intprotected intprotected final Membershipprotected intprotected intprotected intprotected final FD_SOCK2.PingDestprotected final Membershipprotected intprotected final ProcessingQueue<FD_SOCK2.Request> protected booleanprotected NioServerprotected final BoundedList<String> protected longprotected final Membershipprotected TimeSchedulerFields inherited from class org.jgroups.stack.Protocol
after_creation_hook, down_prot, ergonomics, id, local_addr, log, policies, stack, stats, up_prot -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidbroadcastSuspectMessage(List<Address> suspected_members) Sends a SUSPECT message to all group members.protected voidprotected voidprotected int[]computeBindPorts(int actual_port) voidconnectionClosed(Connection conn) voidprotected booleanconnectTo(Address new_ping_dest, Membership mbrs) protected booleanprotected voidconnectToNextPingDest(Address already_suspect) protected NioServercreateServer(int[] bind_ports) An event is to be sent down the stack.intintintintintintReturns the physical addresses for in range [a+offset..a+offset+port_rangeintlongprotected Objecthandle(FD_SOCK2.FdHeader hdr, Address sender) voidhandle(FD_SOCK2.Request req) protected voidhandleView(View v) static ByteArraymessageToBuffer(Message msg) voidDelivers a message from a given sender to the applicationvoidReceive data from the given sendervoidsetClientBindPort(int c) setExternalPort(int e) setLinger(int l) setOffset(int o) setPortRange(int p) setSuspectMsgInterval(long s) voidstart()This method is called on aJChannel.connect(String); starts work.voidstop()Called on aJChannel.disconnect(); stops work (e.g.protected voidsuspect(Collection<Address> suspects) protected voidA single message was received.voidup(MessageBatch batch) Sends up a multiple messages in aMessageBatch.Methods inherited from class org.jgroups.stack.Protocol
accept, addPolicy, addr, addr, afterCreationHook, destroy, down, down, enableStats, getAddress, getComponents, getDownProtocol, getDownServices, getId, getIdsAbove, getLevel, getLog, getName, getPolicies, getProtocolStack, getSocketFactory, getThreadFactory, getTransport, getUpProtocol, getUpServices, getValue, init, isErgonomics, level, parse, policies, providedDownServices, providedUpServices, removePolicy, requiredDownServices, requiredUpServices, resetStatistics, setAddress, setDownProtocol, setErgonomics, setId, setLevel, setPolicies, setProtocolStack, setSocketFactory, setUpProtocol, setValue, statsEnabled, toString, up
-
Field Details
-
bind_addr
-
offset
protected int offset -
port_range
protected int port_range -
client_bind_port
protected int client_bind_port -
external_addr
-
external_port
protected int external_port -
suspect_msg_interval
protected long suspect_msg_interval -
connect_timeout
protected int connect_timeout -
min_port
protected int min_port -
max_port
protected int max_port -
linger
protected int linger -
num_suspect_events
protected int num_suspect_events -
shutting_down
protected volatile boolean shutting_down -
pingable_mbrs
-
members
-
suspected_mbrs
-
cluster
-
srv
-
ping_dest
-
timer
-
bcast_task
-
req_handler
-
suspect_history
-
-
Constructor Details
-
FD_SOCK2
public FD_SOCK2()
-
-
Method Details
-
getNumSuspectedMembers
public int getNumSuspectedMembers() -
getPingDest
-
getClientState
-
getBindAddress
-
setBindAddress
-
getExternalAddress
-
setExternalAddress
-
getExternalPort
public int getExternalPort() -
setExternalPort
-
getSuspectMsgInterval
public long getSuspectMsgInterval() -
setSuspectMsgInterval
-
getClientBindPort
public int getClientBindPort() -
setClientBindPort
-
getPortRange
public int getPortRange() -
setPortRange
-
getOffset
public int getOffset() -
setOffset
-
getLinger
public int getLinger() -
setLinger
-
getActualBindPort
public int getActualBindPort() -
printSuspectHistory
-
printConnections
-
start
Description copied from class:ProtocolThis method is called on aJChannel.connect(String); starts work. Protocols are connected ready to receive events. Will be called from bottom to top. -
stop
public void stop()Description copied from class:ProtocolCalled on aJChannel.disconnect(); stops work (e.g. by closing multicast socket). Will be called from top to bottom. -
resetStats
public void resetStats()- Overrides:
resetStatsin classProtocol
-
up
Description copied from class:ProtocolA single message was received. Protocols may examine the message and do something (e.g. add a header) with it before passing it up. -
up
Description copied from class:ProtocolSends up a multiple messages in aMessageBatch. The sender of the batch is always the same, and so is the destination (null == multicast messages). Messages in a batch can be OOB messages, regular messages, or mixed messages, although the transport itself will create initial MessageBatches that contain only either OOB or regular messages.The default processing below sends messages up the stack individually, based on a matching criteria (calling
Protocol.accept(Message)), and - if true - callsProtocol.up(org.jgroups.Event)for that message and removes the message. If the batch is not empty, it is passed up, or else it is dropped.Subclasses should check if there are any messages destined for them (e.g. using
MessageBatch.iterator(Predicate)), then possibly remove and process them and finally pass the batch up to the next protocol. Protocols can also modify messages in place, e.g. ENCRYPT could decrypt all encrypted messages in the batch, not remove them, and pass the batch up when done. -
down
Description copied from class:ProtocolAn event is to be sent down the stack. A protocol may want to examine its type and perform some action on it, depending on the event's type. If the event is a message MSG, then the protocol may need to add a header to it (or do nothing at all) before sending it down the stack usingdown_prot.down(). -
receive
Description copied from interface:ReceiverDelivers a message from a given sender to the application- Specified by:
receivein interfaceReceiver- Parameters:
sender- The sender of the messagebuf- The buffer. An application typically de-serializes data from the buffer into objects used by the application. Note that when receive() returns, it is not safe to use the buffer any longer; if an application needs to use a buffer after this callback returns, it must make a copy.offset- The offset at which the received data startslength- The length of the received data
-
receive
Description copied from interface:ReceiverReceive data from the given sender -
connectionEstablished
- Specified by:
connectionEstablishedin interfaceConnectionListener
-
connectionClosed
- Specified by:
connectionClosedin interfaceConnectionListener
-
handle
-
createServer
-
closeConnectionToPingDest
protected void closeConnectionToPingDest() -
handle
- Specified by:
handlein interfaceProcessingQueue.Handler<FD_SOCK2.Request>- Throws:
Exception
-
handleView
-
connectToNextPingDest
-
connectTo
-
connectTo
-
getPhysicalAddresses
Returns the physical addresses for in range [a+offset..a+offset+port_range -
messageToBuffer
- Throws:
Exception
-
computeBindPorts
protected int[] computeBindPorts(int actual_port) -
suspect
-
unsuspect
-
broadcastSuspectMessage
Sends a SUSPECT message to all group members. Only the coordinator (or the next member in line if the coord itself is suspected) will react to this message by installing a new view. To overcome the unreliability of the SUSPECT message (it may be lost because we are not above any retransmission layer), the following scheme is used: after sending the SUSPECT message, it is also added to the broadcast task, which will periodically re-send the SUSPECT until a view is received in which the suspected process is not a member anymore. The reason is that - at one point - either the coordinator or another participant taking over for a crashed coordinator, will react to the SUSPECT message and issue a new view, at which point the broadcast task stops. -
broadcastUnuspectMessage
-