Class TP
java.lang.Object
org.jgroups.stack.Protocol
org.jgroups.protocols.TPConfig
org.jgroups.protocols.TP
- All Implemented Interfaces:
Lifecycle, DiagnosticsHandler.ProbeHandler
- Direct Known Subclasses:
BasicTCP, MockTransport, SHARED_LOOPBACK, TUNNEL, UDP
Generic transport - specific implementations should extend this class.
Features which are provided to the subclasses include
The
- version checking
- marshalling and unmarshalling
- message bundling (handling single messages, and message lists)
- incoming packet handler
sendUnicast(PhysicalAddress, ByteBuffer)init()start(): subclasses must call super.start() after they initialize themselves (e.g., created their sockets).stop(): subclasses must call super.stop() after they deinitialized themselvesdestroy()
The
receive(Address, byte[], int, int) method must
be called by subclasses when a unicast or multicast message has been received.- Author:
- Bela Ban
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final byteprotected static final longstatic final intstatic final byteFields inherited from class TPConfig
async_executor, bind_addr, bind_port, bundler, bundler_type, cluster_name, connectLock, diag_handler, external_addr, external_port, header, is_trace, last_discovery_request, local_physical_addr, local_transport, local_transport_class, log_discard_msgs, log_discard_msgs_version, logical_addr_cache, logical_addr_cache_expiration, logical_addr_cache_max_size, logical_addr_cache_reaper, logical_addr_cache_reaper_interval, members, message_processing_policy, msg_processing_policy, msg_stats, port_range, print_function, receive_interfaces, receive_on_all_interfaces, rtt, socket_factory, suppress_log_different_cluster, suppress_log_different_version, suppress_time_different_cluster_warnings, suppress_time_different_version_warnings, thread_factory, thread_naming_pattern, thread_pool, time_service, time_service_interval, timer, timer_handle_non_blocking_tasks, use_direct_memory, use_vthreads, view, who_has_cache, who_has_cache_timeoutFields inherited from class Protocol
after_creation_hook, down_prot, ergonomics, id, local_addr, log, policies, preview_warning, stack, stats, up_prot -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddPhysicalAddressToCache(Address logical_addr, PhysicalAddress physical_addr) protected booleanaddPhysicalAddressToCache(Address logical_addr, PhysicalAddress physical_addr, boolean overwrite) voidClears the cache.voiddestroy()This method is called on aJChannel.close().voidvoiddoSend(ByteBuffer buf, Address dest) An event is to be sent down the stack.A message needs to be sent to a single member or all members<T extends TP>
TvoidvoidevictLogicalAddressCache(boolean force) protected voidGrabs the local address (or addresses in the shared transport case) and registers them with the physical address in the transport's cacheprotected voidfetchPhysicalAddrs(List<Address> missing) protected ResponsesfetchResponsesFromDiscoveryProtocol(List<Address> missing) protected Collection<PhysicalAddress> protected abstract PhysicalAddressReturns the physical address of this transportgetPhysicalAddressFromCache(Address logical_addr) protected voidprotected voidprotected voidhandleMessageBatch(DataInput in, boolean multicast) handleProbe(String... keys) Handles a probe.protected voidhandleSingleMessage(DataInput in, boolean multicast) voidinit()Called after a protocol has been created and before the protocol is started.voidpassBatchUp(MessageBatch batch, boolean perform_cluster_name_matching, boolean discard_own_mcast) voidpassMessageUp(Message msg, boolean perform_cluster_name_matching, boolean multicast, boolean discard_own_mcast) protected voidprocessBatch(MessageBatch batch, boolean oob) voidSubclasses must call this method when a unicast or multicast message has been receivedvoidprotected voidregisterLocalAddress(Address addr) Associates the address with the physical address fetched from the cacheprotected voidremoveLogicalAddressFromCache(Address logical_addr) protected voidsendTo(Address dest, ByteBuffer buf) protected voidsendToAll(ByteBuffer buf) Fetches the physical addrs for all mbrs and sends the msg to each physical address.abstract voidsendUnicast(PhysicalAddress dest, ByteBuffer buf) Send a unicast message to a member.protected voidsendUnicasts(List<PhysicalAddress> dests, ByteBuffer data) <T extends Protocol>
TsetAddress(Address addr) protected voidsetInAllThreadFactories(String cluster_name, Address local_address, String pattern) protected voidsetSourceAddress(Message msg) If the sender is null, set our own address.protected voidvoidstart()Creates the unicast and multicast sockets and starts the unicast and multicast receiver threadsprotected voidvoidstop()Called on aJChannel.disconnect(); stops work (e.g.protected voidString[]Returns a list of supported keysabstract booleanWhether hardware multicasting is supportedtoString()booleanunicastDestMismatch(Address dest) protected voidprotected booleanversionMatch(short version, Address sender) Methods inherited from class TPConfig
bundler, clearDifferentClusterCache, clearDifferentVersionCache, clusterName, createBundler, createDiagnosticsHandler, defaultHeaders, dumpTimerTasks, enableAllStats, enableBlockingTimerTasks, enableStats, getAsyncExecutor, getBindAddr, getBindAddress, getBindPort, getBundler, getBundlerClass, getBundlerType, getClusterName, getClusterNameAscii, getDiagnosticsHandler, getDifferentClusterMessages, getDifferentVersionMessages, getExternalAddr, getExternalPort, getLocalPhysicalAddress, getLocalTransport, getLogDiscardMessages, getLogDiscardMessagesVersion, getLogicalAddrCacheExpiration, getLogicalAddrCacheMaxSize, getLogicalAddrCacheReaperInterval, getLogicalAddressCache, getMessageProcessingPolicy, getMessageStats, getNumberOfThreadDumps, getNumMcastMsgsReceived, getNumMcastMsgsSent, getNumRejectedMsgs, getNumThreads, getNumTimerTasks, getNumUcastMsgsReceived, getNumUcastMsgsSent, getPortRange, getReceiveInterfaces, getRTT, getSocketFactory, getSuppressTimeDifferentClusterWarnings, getSuppressTimeDifferentVersionWarnings, getThreadFactory, getThreadNamingPattern, getThreadPool, getTimer, getTimerClass, getTimerThreads, getTimeService, getTimeServiceInterval, getWhoHasCacheTimeout, isLogicalAddressCacheReaperRunning, isReceiveOnAllInterfaces, isTrace, isTrace, localPhysicalAddress, logDiscardMsgs, logDiscardMsgs, logDiscardMsgsVersion, logDiscardMsgsVersion, loggerType, msgProcessingPolicy, msgProcessingPolicy, printLogicalAddressCache, printWhoHasCache, receiveOnAllInterfaces, receiveOnAllInterfaces, registerProbeHandler, removeCancelledTimerTasks, resetStats, sameCluster, setAsyncExecutor, setBindAddr, setBindAddress, setBindPort, setBindToAllInterfaces, setBundler, setBundlerType, setDiagnosticsHandler, setExternalAddr, setExternalPort, setLevel, setLocalTransport, setLocalTransport, setLogDiscardMessages, setLogDiscardMessagesVersion, setLogicalAddrCacheExpiration, setLogicalAddrCacheMaxSize, setLogicalAddrCacheReaperInterval, setMessageProcessingPolicy, setMessageStats, setPortRange, setSocketFactory, setSuppressTimeDifferentClusterWarnings, setSuppressTimeDifferentVersionWarnings, setThreadFactory, setThreadPool, setTimer, setTimeService, setTimeServiceInterval, setWhoHasCacheTimeout, threadNamingPattern, timestamp, unregisterProbeHandler, unregisterProbeHandler, useDirectMemory, useDirectMemory, useVirtualThreads, useVirtualThreads, viewMethods inherited from class Protocol
accept, addPolicy, addr, addr, afterCreationHook, down, getAddress, getComponents, getDownProtocol, getDownServices, getId, getIdsAbove, getLevel, getLog, getName, getPolicies, getProtocolStack, getTransport, getUpProtocol, getUpServices, getValue, isErgonomics, level, parse, policies, previewWarning, previewWarning, providedDownServices, providedUpServices, removePolicy, requiredDownServices, requiredUpServices, resetStatistics, setDownProtocol, setErgonomics, setId, setPolicies, setProtocolStack, setUpProtocol, setValue, statsEnabled, up, up, up
-
Field Details
-
LIST
public static final byte LIST- See Also:
-
MULTICAST
public static final byte MULTICAST- See Also:
-
MSG_OVERHEAD
public static final int MSG_OVERHEAD- See Also:
-
MIN_WAIT_BETWEEN_DISCOVERIES
protected static final long MIN_WAIT_BETWEEN_DISCOVERIES
-
-
Constructor Details
-
TP
protected TP()
-
-
Method Details
-
supportsMulticasting
public abstract boolean supportsMulticasting()Whether hardware multicasting is supported -
getPhysicalAddress
Returns the physical address of this transport -
sendUnicast
Send a unicast message to a member. Note that the destination address is a *physical*, not a logical address -
toString
-
setAddress
- Overrides:
setAddressin classProtocol
-
init
Description copied from class:ProtocolCalled after a protocol has been created and before the protocol is started. Attributes are already set. Other protocols are not yet connected and events cannot yet be sent. -
start
Creates the unicast and multicast sockets and starts the unicast and multicast receiver threads -
stop
-
destroy
-
enableDiagnostics
-
disableDiagnostics
public void disableDiagnostics() -
handleProbe
Description copied from interface:DiagnosticsHandler.ProbeHandlerHandles a probe. For each key that is handled, the key and its result should be in the returned map.- Specified by:
handleProbein interfaceDiagnosticsHandler.ProbeHandler- Returns:
- A map of sring keys and values. A null return value is permissible.
-
supportedKeys
Description copied from interface:DiagnosticsHandler.ProbeHandlerReturns a list of supported keys- Specified by:
supportedKeysin interfaceDiagnosticsHandler.ProbeHandler
-
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(). -
down
-
passMessageUp
public void passMessageUp(Message msg, boolean perform_cluster_name_matching, boolean multicast, boolean discard_own_mcast) -
passBatchUp
public void passBatchUp(MessageBatch batch, boolean perform_cluster_name_matching, boolean discard_own_mcast) -
receive
Subclasses must call this method when a unicast or multicast message has been received -
receive
-
doSend
- Throws:
Exception
-
unicastDestMismatch
-
addPhysicalAddressToCache
-
getPhysicalAddressFromCache
-
handleMessageBatch
-
handleSingleMessage
-
processBatch
-
versionMatch
-
sendTo
- Throws:
Exception
-
sendToAll
Fetches the physical addrs for all mbrs and sends the msg to each physical address. Asks discovery for missing members' physical addresses if needed- Throws:
Exception
-
sendUnicasts
- Throws:
Exception
-
fetchPhysicalAddrs
-
fetchResponsesFromDiscoveryProtocol
-
setSourceAddress
If the sender is null, set our own address. We cannot just go ahead and set the address anyway, as we might send a message on behalf of someone else, e.g. in case of retransmission, when the original sender has crashed. -
handleConnect
-
handleDisconnect
protected void handleDisconnect() -
evictLogicalAddressCache
public void evictLogicalAddressCache() -
evictLogicalAddressCache
public void evictLogicalAddressCache(boolean force) -
registerLocalAddress
Associates the address with the physical address fetched from the cache -
fetchLocalAddresses
protected void fetchLocalAddresses()Grabs the local address (or addresses in the shared transport case) and registers them with the physical address in the transport's cache -
startDiagnostics
-
stopDiagnostics
protected void stopDiagnostics() -
setThreadNames
protected void setThreadNames() -
unsetThreadNames
protected void unsetThreadNames() -
setInAllThreadFactories
-
addPhysicalAddressToCache
protected boolean addPhysicalAddressToCache(Address logical_addr, PhysicalAddress physical_addr, boolean overwrite) -
getAllPhysicalAddressesFromCache
-
removeLogicalAddressFromCache
-
clearLogicalAddressCache
public void clearLogicalAddressCache()Clears the cache. Do not use, this is only for unit testing !
-