Package org.jgroups.protocols
Class TP
- java.lang.Object
-
- org.jgroups.stack.Protocol
-
- org.jgroups.protocols.TP
-
- All Implemented Interfaces:
AdditionalJmxObjects
,DiagnosticsHandler.ProbeHandler
- Direct Known Subclasses:
BasicTCP
,SHARED_LOOPBACK
,SimpleTCP
,TUNNEL
,UDP
public abstract class TP extends Protocol implements DiagnosticsHandler.ProbeHandler, AdditionalJmxObjects
Generic transport - specific implementations should extend this abstract class. Features which are provided to the subclasses include- version checking
- marshalling and unmarshalling
- message bundling (handling single messages, and message lists)
- incoming packet handler
sendMulticast(byte[], int, int)
sendUnicast(org.jgroups.PhysicalAddress, byte[], int, int)
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()
Thereceive(Address, byte[], int, int)
method must be called by subclasses when a unicast or multicast message has been received.- Author:
- Bela Ban
-
-
Field Summary
Fields Modifier and Type Field Description protected AverageMinMax
avg_batch_size
protected java.net.InetAddress
bind_addr
protected int
bind_port
The port to which the transport binds.protected Bundler
bundler
protected int
bundler_capacity
protected int
bundler_num_spins
protected java.lang.String
bundler_type
protected java.lang.String
bundler_wait_strategy
protected AsciiString
cluster_name
The name of the group to which this member is connected.protected java.util.concurrent.locks.ReentrantLock
connectLock
protected boolean
diag_enable_tcp
protected boolean
diag_enable_udp
protected DiagnosticsHandler
diag_handler
protected java.net.InetAddress
diagnostics_addr
protected java.net.InetAddress
diagnostics_bind_addr
protected java.util.List<java.net.NetworkInterface>
diagnostics_bind_interfaces
protected java.lang.String
diagnostics_passcode
protected int
diagnostics_port
protected int
diagnostics_port_range
protected int
diagnostics_ttl
protected boolean
drop_when_full
protected boolean
enable_diagnostics
protected java.net.InetAddress
external_addr
protected int
external_port
protected TpHeader
header
The header including the cluster name, sent with each message.protected java.util.concurrent.Executor
internal_pool
protected ThreadFactory
internal_thread_factory
protected boolean
is_trace
protected long
last_discovery_request
static byte
LIST
protected Address
local_addr
The address (host and port) of this memberprotected PhysicalAddress
local_physical_addr
protected boolean
log_discard_msgs
Whether or not warnings about messages from different groups are logged - private flag, not for common useprotected boolean
log_discard_msgs_version
protected LazyRemovalCache<Address,PhysicalAddress>
logical_addr_cache
Cache which maintains mappings between logical and physical addresses.protected long
logical_addr_cache_expiration
protected int
logical_addr_cache_max_size
protected java.util.concurrent.Future<?>
logical_addr_cache_reaper
protected long
logical_addr_cache_reaper_interval
protected boolean
loopback_copy
protected boolean
loopback_separate_thread
protected int
max_bundle_size
Maximum number of bytes for messages to be queued until they are sent.protected java.util.Set<Address>
members
The members of this group (updated when a member joins or leaves).protected java.lang.String
message_processing_policy
protected static long
MIN_WAIT_BETWEEN_DISCOVERIES
static int
MSG_OVERHEAD
protected int
msg_processing_max_buffer_size
protected MessageProcessingPolicy
msg_processing_policy
protected MsgStats
msg_stats
static byte
MULTICAST
protected int
port_range
protected java.util.List<DiagnosticsHandler.ProbeHandler>
preregistered_probe_handlers
protected static LazyRemovalCache.Printable<Address,LazyRemovalCache.Entry<PhysicalAddress>>
print_function
protected java.util.List<java.net.NetworkInterface>
receive_interfaces
Listof interfaces to receive multicasts on. protected boolean
receive_on_all_interfaces
protected SocketFactory
socket_factory
protected boolean
spawn_thread_on_full_pool
protected SuppressLog<Address>
suppress_log_different_cluster
Log to suppress identical warnings for messages from members in different clustersprotected SuppressLog<Address>
suppress_log_different_version
Log to suppress identical warnings for messages from members with different (incompatible) versionsprotected long
suppress_time_different_cluster_warnings
protected long
suppress_time_different_version_warnings
protected java.lang.String
thread_dump_path
protected java.util.concurrent.atomic.AtomicInteger
thread_dumps
protected int
thread_dumps_threshold
protected ThreadFactory
thread_factory
Factory which is used by the thread poolprotected java.lang.String
thread_naming_pattern
protected java.util.concurrent.Executor
thread_pool
The thread pool which handles unmarshalling, version checks and dispatching of messagesprotected boolean
thread_pool_enabled
protected long
thread_pool_keep_alive_time
protected int
thread_pool_max_threads
protected int
thread_pool_min_threads
protected TimeService
time_service
protected long
time_service_interval
protected TimeScheduler
timer
protected boolean
timer_handle_non_blocking_tasks
protected boolean
use_common_fork_join_pool
protected boolean
use_fibers
protected boolean
use_fork_join_pool
protected boolean
use_ip_addrs
protected View
view
protected ExpiryCache<Address>
who_has_cache
Cache keeping track of WHO_HAS requests for physical addresses (given a logical address) and expiring them after who_has_cache_timeout msprotected long
who_has_cache_timeout
-
Fields inherited from class org.jgroups.stack.Protocol
after_creation_hook, down_prot, ergonomics, id, log, stack, stats, up_prot
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
TP()
Creates the TP protocol, and initializes the state variables, does however not start any sockets or threads.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
_send(Message msg, Address dest)
protected boolean
addPhysicalAddressToCache(Address logical_addr, PhysicalAddress physical_addr)
protected boolean
addPhysicalAddressToCache(Address logical_addr, PhysicalAddress physical_addr, boolean overwrite)
AverageMinMax
avgBatchSize()
<T extends TP>
Tbundler(java.lang.String type)
int
bundlerNumSpins()
<T extends TP>
TbundlerNumSpins(int spins)
java.lang.String
bundlerStats()
void
bundlerStatsReset()
java.lang.String
bundlerWaitStrategy()
<T extends TP>
TbundlerWaitStrategy(java.lang.String strategy)
<T extends TP>
TclearDifferentClusterCache()
<T extends TP>
TclearDifferentVersionCache()
void
clearLogicalAddressCache()
Clears the cache.protected Bundler
createBundler(java.lang.String type)
protected DiagnosticsHandler
createDiagnosticsHandler()
protected static java.util.concurrent.ExecutorService
createThreadPool(int min_threads, int max_threads, long keep_alive_time, java.lang.String rejection_policy, java.util.concurrent.BlockingQueue<java.lang.Runnable> queue, ThreadFactory factory, Log log, boolean use_fork_join_pool, boolean use_common_fork_join_pool)
void
destroy()
This method is called on aJChannel.close()
.<T extends TP>
TdiagEnableTcp(boolean f)
<T extends TP>
TdiagEnableUdp(boolean f)
boolean
diagTcpEnabled()
void
disableDiagnostics()
void
doSend(byte[] buf, int offset, int length, Address dest)
java.lang.Object
down(Event evt)
An event is to be sent down the stack.java.lang.Object
down(Message msg)
A message needs to be sent to a single member or all membersjava.lang.String
dumpTimerTasks()
<T extends TP>
TenableBlockingTimerTasks(boolean flag)
void
enableDiagnostics()
void
evictLogicalAddressCache()
void
evictLogicalAddressCache(boolean force)
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 cacheprotected void
fetchPhysicalAddrs(java.util.List<Address> missing)
protected Responses
fetchResponsesFromDiscoveryProtocol(java.util.List<Address> missing)
protected java.util.Collection<PhysicalAddress>
getAllPhysicalAddressesFromCache()
java.lang.String
getAvgBatchSize()
java.net.InetAddress
getBindAddress()
int
getBindPort()
Bundler
getBundler()
int
getBundlerBufferSize()
int
getBundlerCapacity()
java.lang.String
getBundlerClass()
java.lang.String
getClusterName()
AsciiString
getClusterNameAscii()
DiagnosticsHandler
getDiagnosticsHandler()
int
getDifferentClusterMessages()
int
getDifferentVersionMessages()
boolean
getDropWhenFull()
abstract java.lang.String
getInfo()
java.util.concurrent.Executor
getInternalThreadPool()
int
getInternalThreadPoolSize()
int
getInternalThreadPoolSizeLargest()
ThreadFactory
getInternalThreadPoolThreadFactory()
java.lang.Object[]
getJmxObjects()
java.lang.String
getLocalAddress()
java.lang.String
getLocalPhysicalAddress()
boolean
getLogDiscardMessages()
boolean
getLogDiscardMessagesVersion()
int
getMaxBundleSize()
int
getMessageProcessingMaxBufferSize()
MsgStats
getMessageStats()
int
getNumberOfThreadDumps()
long
getNumMessagesSent()
static int
getNumThreads()
int
getNumTimerTasks()
protected abstract PhysicalAddress
getPhysicalAddress()
protected PhysicalAddress
getPhysicalAddressFromCache(Address logical_addr)
int
getPortRange()
java.util.List<java.net.NetworkInterface>
getReceiveInterfaces()
SocketFactory
getSocketFactory()
Returns the SocketFactory associated with this protocol, if overridden in a subclass, or passes the call downint
getThreadDumpsThreshold()
ThreadFactory
getThreadFactory()
Supposed to be overwritten by subclasses.java.lang.String
getThreadNamingPattern()
Names the current thread.java.util.concurrent.Executor
getThreadPool()
long
getThreadPoolKeepAliveTime()
int
getThreadPoolMaxThreads()
int
getThreadPoolMinThreads()
int
getThreadPoolSize()
int
getThreadPoolSizeActive()
int
getThreadPoolSizeLargest()
ThreadFactory
getThreadPoolThreadFactory()
TimeScheduler
getTimer()
java.lang.String
getTimerClass()
int
getTimerThreads()
TimeService
getTimeService()
boolean
getUseIpAddresses()
protected void
handleConnect()
protected void
handleDisconnect()
protected void
handleMessageBatch(java.io.DataInput in, boolean multicast)
java.util.Map<java.lang.String,java.lang.String>
handleProbe(java.lang.String... keys)
Handles a probe.protected void
handleSingleMessage(java.io.DataInput in, boolean multicast)
<T extends TP>
TincrBatchesSent(int delta)
<T extends TP>
TincrNumSingleMsgsSent(int d)
void
init()
Called after instance has been created (null constructor) and before protocol is started.boolean
isDiagnosticsEnabled()
boolean
isDiagnosticsRunning()
boolean
isDiagUdEnabled()
boolean
isLogicalAddressCacheReaperRunning()
boolean
isMulticastCapable()
boolean
isReceiveOnAllInterfaces()
Address
localAddress()
static java.lang.String
loggerType()
protected void
loopback(Message msg, boolean multicast)
void
passBatchUp(MessageBatch batch, boolean perform_cluster_name_matching, boolean discard_own_mcast)
void
passMessageUp(Message msg, byte[] cluster_name, boolean perform_cluster_name_matching, boolean multicast, boolean discard_own_mcast)
java.lang.String
printLogicalAddressCache()
java.lang.String
printWhoHasCache()
protected void
processBatch(MessageBatch batch, boolean oob, boolean internal)
void
receive(Address sender, byte[] data, int offset, int length)
Subclasses must call this method when a unicast or multicast message has been received.void
receive(Address sender, java.io.DataInput in)
protected void
registerLocalAddress(Address addr)
Associates the address with the physical address fetched from the cache<T extends TP>
TregisterProbeHandler(DiagnosticsHandler.ProbeHandler handler)
void
removeCancelledTimerTasks()
protected void
removeLogicalAddressFromCache(Address logical_addr)
void
resetStats()
void
resetThreadDumps()
protected boolean
runInNewThread(java.lang.Runnable task)
protected void
send(Message msg)
Serializes and sends a message.abstract void
sendMulticast(byte[] data, int offset, int length)
Send to all members in the group.protected void
sendToMembers(java.util.Collection<Address> mbrs, byte[] buf, int offset, int length)
Fetches the physical addrs for mbrs and sends the msg to each physical address.protected void
sendToSingleMember(Address dest, byte[] buf, int offset, int length)
abstract void
sendUnicast(PhysicalAddress dest, byte[] data, int offset, int length)
Send a unicast to 1 member.<T extends TP>
TsetBindAddress(java.net.InetAddress a)
<T extends TP>
TsetBindPort(int port)
<T extends TP>
TsetBindToAllInterfaces(boolean f)
<T extends TP>
TsetBundler(Bundler bundler)
Installs a bundler.<T extends TP>
TsetBundlerCapacity(int c)
<T extends TP>
TsetDiagnosticsEnabled(boolean f)
<T extends TP>
TsetDiagnosticsHandler(DiagnosticsHandler handler)
Sets aDiagnosticsHandler
.<T extends TP>
TsetDropWhenFull(boolean b)
protected void
setInAllThreadFactories(java.lang.String cluster_name, Address local_address, java.lang.String pattern)
<T extends TP>
TsetInternalThreadPool(java.util.concurrent.Executor thread_pool)
<T extends TP>
TsetInternalThreadPoolThreadFactory(ThreadFactory factory)
<T extends Protocol>
TsetLevel(java.lang.String level)
Sets the level of a logger.<T extends TP>
TsetLogDiscardMessages(boolean flag)
<T extends TP>
TsetLogDiscardMessagesVersion(boolean f)
<T extends TP>
TsetMaxBundleSize(int size)
void
setMessageProcessingPolicy(java.lang.String policy)
<T extends TP>
TsetPortRange(int range)
void
setSocketFactory(SocketFactory factory)
Sets a SocketFactory.protected void
setSourceAddress(Message msg)
If the sender is null, set our own address.<T extends TP>
TsetThreadDumpsThreshold(int t)
<T extends TP>
TsetThreadFactory(ThreadFactory factory)
protected void
setThreadNames()
<T extends TP>
TsetThreadPool(java.util.concurrent.Executor thread_pool)
<T extends TP>
TsetThreadPoolKeepAliveTime(long time)
<T extends TP>
TsetThreadPoolMaxThreads(int size)
<T extends TP>
TsetThreadPoolMinThreads(int size)
<T extends TP>
TsetThreadPoolThreadFactory(ThreadFactory factory)
<T extends TP>
TsetTimer(TimeScheduler timer)
Sets a new timer.<T extends TP>
TsetTimeService(TimeService ts)
protected static void
shutdownThreadPool(java.util.concurrent.Executor thread_pool)
void
start()
Creates the unicast and multicast sockets and starts the unicast and multicast receiver threadsprotected void
startDiagnostics()
void
stop()
This method is called on aJChannel.disconnect()
.protected void
stopDiagnostics()
boolean
submitToThreadPool(java.lang.Runnable task, boolean spawn_thread_on_rejection)
boolean
submitToThreadPool(java.util.concurrent.Executor pool, java.lang.Runnable task, boolean spawn_thread_on_rejection, boolean forward_to_internal_pool)
java.lang.String[]
supportedKeys()
Returns a list of supported keysabstract boolean
supportsMulticasting()
Whether or not hardware multicasting is supportedprotected long
timestamp()
java.lang.String
toString()
boolean
unicastDestMismatch(Address dest)
<T extends TP>
TunregisterProbeHandler(DiagnosticsHandler.ProbeHandler handler)
protected void
unsetThreadNames()
boolean
useFibers()
protected boolean
versionMatch(short version, Address sender)
View
view()
-
Methods inherited from class org.jgroups.stack.Protocol
accept, afterCreationHook, enableStats, getConfigurableObjects, getDownProtocol, getDownServices, getId, getIdsAbove, getLevel, getLog, getName, getProtocolStack, getTransport, getUpProtocol, getUpServices, getValue, isErgonomics, level, parse, providedDownServices, providedUpServices, requiredDownServices, requiredUpServices, resetStatistics, setDownProtocol, setErgonomics, setId, setProtocolStack, setUpProtocol, setValue, statsEnabled, up, up, up
-
-
-
-
Field Detail
-
LIST
public static final byte LIST
- See Also:
- Constant Field Values
-
MULTICAST
public static final byte MULTICAST
- See Also:
- Constant Field Values
-
MSG_OVERHEAD
public static final int MSG_OVERHEAD
- See Also:
- Constant Field Values
-
MIN_WAIT_BETWEEN_DISCOVERIES
protected static final long MIN_WAIT_BETWEEN_DISCOVERIES
-
bind_addr
protected java.net.InetAddress bind_addr
-
use_ip_addrs
protected boolean use_ip_addrs
-
external_addr
protected java.net.InetAddress external_addr
-
external_port
protected int external_port
-
is_trace
protected boolean is_trace
-
receive_on_all_interfaces
protected boolean receive_on_all_interfaces
-
receive_interfaces
protected java.util.List<java.net.NetworkInterface> receive_interfaces
Listof interfaces to receive multicasts on. The multicast receive socket will listen on all of these interfaces. This is a comma-separated list of IP addresses or interface names. E.g. "192.168.5.1,eth1,127.0.0.1". Duplicates are discarded; we only bind to an interface once. If this property is set, it overrides receive_on_all_interfaces.
-
logical_addr_cache_max_size
protected int logical_addr_cache_max_size
-
logical_addr_cache_expiration
protected long logical_addr_cache_expiration
-
logical_addr_cache_reaper_interval
protected long logical_addr_cache_reaper_interval
-
bind_port
protected int bind_port
The port to which the transport binds. 0 means to bind to any (ephemeral) port. See alsoport_range
-
port_range
protected int port_range
-
loopback_copy
protected boolean loopback_copy
-
loopback_separate_thread
protected boolean loopback_separate_thread
-
message_processing_policy
protected java.lang.String message_processing_policy
-
msg_processing_max_buffer_size
protected int msg_processing_max_buffer_size
-
thread_naming_pattern
protected java.lang.String thread_naming_pattern
-
use_fork_join_pool
protected boolean use_fork_join_pool
-
use_common_fork_join_pool
protected boolean use_common_fork_join_pool
-
use_fibers
protected boolean use_fibers
-
thread_pool_enabled
protected boolean thread_pool_enabled
-
thread_pool_min_threads
protected int thread_pool_min_threads
-
thread_pool_max_threads
protected int thread_pool_max_threads
-
thread_pool_keep_alive_time
protected long thread_pool_keep_alive_time
-
spawn_thread_on_full_pool
protected boolean spawn_thread_on_full_pool
-
time_service_interval
protected long time_service_interval
-
enable_diagnostics
protected boolean enable_diagnostics
-
diag_enable_udp
protected boolean diag_enable_udp
-
diag_enable_tcp
protected boolean diag_enable_tcp
-
diagnostics_addr
protected java.net.InetAddress diagnostics_addr
-
diagnostics_bind_addr
protected java.net.InetAddress diagnostics_bind_addr
-
diagnostics_bind_interfaces
protected java.util.List<java.net.NetworkInterface> diagnostics_bind_interfaces
-
diagnostics_port
protected int diagnostics_port
-
diagnostics_port_range
protected int diagnostics_port_range
-
diagnostics_ttl
protected int diagnostics_ttl
-
diagnostics_passcode
protected java.lang.String diagnostics_passcode
-
log_discard_msgs
protected boolean log_discard_msgs
Whether or not warnings about messages from different groups are logged - private flag, not for common use
-
log_discard_msgs_version
protected boolean log_discard_msgs_version
-
who_has_cache_timeout
protected long who_has_cache_timeout
-
suppress_time_different_version_warnings
protected long suppress_time_different_version_warnings
-
suppress_time_different_cluster_warnings
protected long suppress_time_different_cluster_warnings
-
thread_dumps_threshold
protected int thread_dumps_threshold
-
thread_dump_path
protected java.lang.String thread_dump_path
-
thread_dumps
protected final java.util.concurrent.atomic.AtomicInteger thread_dumps
-
max_bundle_size
protected int max_bundle_size
Maximum number of bytes for messages to be queued until they are sent. This value needs to be smaller than the largest datagram packet size in case of UDP
-
bundler_type
protected java.lang.String bundler_type
-
drop_when_full
protected boolean drop_when_full
-
bundler_capacity
protected int bundler_capacity
-
bundler_num_spins
protected int bundler_num_spins
-
bundler_wait_strategy
protected java.lang.String bundler_wait_strategy
-
msg_stats
protected final MsgStats msg_stats
-
cluster_name
protected AsciiString cluster_name
The name of the group to which this member is connected. With a shared transport, the channel name is in TP.ProtocolAdapter (cluster_name), and this field is not used
-
timer_handle_non_blocking_tasks
protected boolean timer_handle_non_blocking_tasks
-
local_addr
protected Address local_addr
The address (host and port) of this member
-
local_physical_addr
protected PhysicalAddress local_physical_addr
-
view
protected volatile View view
-
members
protected final java.util.Set<Address> members
The members of this group (updated when a member joins or leaves). With a shared transport, members contains *all* members from all channels sitting on the shared transport
-
connectLock
protected final java.util.concurrent.locks.ReentrantLock connectLock
-
thread_pool
protected java.util.concurrent.Executor thread_pool
The thread pool which handles unmarshalling, version checks and dispatching of messages
-
thread_factory
protected ThreadFactory thread_factory
Factory which is used by the thread pool
-
internal_thread_factory
protected ThreadFactory internal_thread_factory
-
internal_pool
protected java.util.concurrent.Executor internal_pool
-
timer
protected TimeScheduler timer
-
time_service
protected TimeService time_service
-
socket_factory
protected SocketFactory socket_factory
-
bundler
protected Bundler bundler
-
msg_processing_policy
protected MessageProcessingPolicy msg_processing_policy
-
diag_handler
protected DiagnosticsHandler diag_handler
-
preregistered_probe_handlers
protected final java.util.List<DiagnosticsHandler.ProbeHandler> preregistered_probe_handlers
-
header
protected TpHeader header
The header including the cluster name, sent with each message. Not used with a shared transport (instead TP.ProtocolAdapter attaches the header to the message
-
logical_addr_cache
protected LazyRemovalCache<Address,PhysicalAddress> logical_addr_cache
Cache which maintains mappings between logical and physical addresses. When sending a message to a logical address, we look up the physical address from logical_addr_cache and send the message to the physical address
The keys are logical addresses, the values physical addresses
-
last_discovery_request
protected long last_discovery_request
-
logical_addr_cache_reaper
protected java.util.concurrent.Future<?> logical_addr_cache_reaper
-
avg_batch_size
protected final AverageMinMax avg_batch_size
-
print_function
protected static final LazyRemovalCache.Printable<Address,LazyRemovalCache.Entry<PhysicalAddress>> print_function
-
who_has_cache
protected ExpiryCache<Address> who_has_cache
Cache keeping track of WHO_HAS requests for physical addresses (given a logical address) and expiring them after who_has_cache_timeout ms
-
suppress_log_different_version
protected SuppressLog<Address> suppress_log_different_version
Log to suppress identical warnings for messages from members with different (incompatible) versions
-
suppress_log_different_cluster
protected SuppressLog<Address> suppress_log_different_cluster
Log to suppress identical warnings for messages from members in different clusters
-
-
Method Detail
-
getBundlerClass
public java.lang.String getBundlerClass()
-
setMaxBundleSize
public <T extends TP> T setMaxBundleSize(int size)
-
getMaxBundleSize
public final int getMaxBundleSize()
-
getBundlerCapacity
public int getBundlerCapacity()
-
setBundlerCapacity
public <T extends TP> T setBundlerCapacity(int c)
-
getMessageProcessingMaxBufferSize
public int getMessageProcessingMaxBufferSize()
-
useFibers
public boolean useFibers()
-
getThreadDumpsThreshold
public int getThreadDumpsThreshold()
-
setThreadDumpsThreshold
public <T extends TP> T setThreadDumpsThreshold(int t)
-
getDropWhenFull
public boolean getDropWhenFull()
-
setDropWhenFull
public <T extends TP> T setDropWhenFull(boolean b)
-
getBundlerBufferSize
public int getBundlerBufferSize()
-
bundlerWaitStrategy
public java.lang.String bundlerWaitStrategy()
-
bundlerWaitStrategy
public <T extends TP> T bundlerWaitStrategy(java.lang.String strategy)
-
bundlerNumSpins
public int bundlerNumSpins()
-
bundlerNumSpins
public <T extends TP> T bundlerNumSpins(int spins)
-
isLogicalAddressCacheReaperRunning
public boolean isLogicalAddressCacheReaperRunning()
-
getAvgBatchSize
public java.lang.String getAvgBatchSize()
-
avgBatchSize
public AverageMinMax avgBatchSize()
-
setThreadPoolMinThreads
public <T extends TP> T setThreadPoolMinThreads(int size)
-
getThreadPoolMinThreads
public int getThreadPoolMinThreads()
-
setThreadPoolMaxThreads
public <T extends TP> T setThreadPoolMaxThreads(int size)
-
getThreadPoolMaxThreads
public int getThreadPoolMaxThreads()
-
setThreadPoolKeepAliveTime
public <T extends TP> T setThreadPoolKeepAliveTime(long time)
-
getThreadPoolKeepAliveTime
public long getThreadPoolKeepAliveTime()
-
getJmxObjects
public java.lang.Object[] getJmxObjects()
- Specified by:
getJmxObjects
in interfaceAdditionalJmxObjects
-
setLevel
public <T extends Protocol> T setLevel(java.lang.String level)
Description copied from class:Protocol
Sets the level of a logger. This method is used to dynamically change the logging level of a running system, e.g. via JMX. The appender of a level needs to exist.
-
getNumberOfThreadDumps
public int getNumberOfThreadDumps()
-
resetThreadDumps
public void resetThreadDumps()
-
setMessageProcessingPolicy
public void setMessageProcessingPolicy(java.lang.String policy)
-
getTimerClass
public java.lang.String getTimerClass()
-
getClusterName
public java.lang.String getClusterName()
-
getClusterNameAscii
public AsciiString getClusterNameAscii()
-
getDifferentClusterMessages
public int getDifferentClusterMessages()
-
getDifferentVersionMessages
public int getDifferentVersionMessages()
-
clearDifferentClusterCache
public <T extends TP> T clearDifferentClusterCache()
-
clearDifferentVersionCache
public <T extends TP> T clearDifferentVersionCache()
-
loggerType
public static java.lang.String loggerType()
-
enableBlockingTimerTasks
public <T extends TP> T enableBlockingTimerTasks(boolean flag)
-
getMessageStats
public MsgStats getMessageStats()
-
supportsMulticasting
public abstract boolean supportsMulticasting()
Whether or not hardware multicasting is supported
-
isMulticastCapable
public boolean isMulticastCapable()
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getLocalAddress
public java.lang.String getLocalAddress()
-
localAddress
public Address localAddress()
-
view
public View view()
-
getLocalPhysicalAddress
public java.lang.String getLocalPhysicalAddress()
-
resetStats
public void resetStats()
- Overrides:
resetStats
in classProtocol
-
registerProbeHandler
public <T extends TP> T registerProbeHandler(DiagnosticsHandler.ProbeHandler handler)
-
unregisterProbeHandler
public <T extends TP> T unregisterProbeHandler(DiagnosticsHandler.ProbeHandler handler)
-
getDiagnosticsHandler
public DiagnosticsHandler getDiagnosticsHandler()
-
setDiagnosticsHandler
public <T extends TP> T setDiagnosticsHandler(DiagnosticsHandler handler) throws java.lang.Exception
Sets aDiagnosticsHandler
. Should be set before the stack is started- Parameters:
handler
-- Throws:
java.lang.Exception
-
getBundler
public Bundler getBundler()
-
setBundler
public <T extends TP> T setBundler(Bundler bundler)
Installs a bundler. Needs to be done before the channel is connected
-
getThreadPool
public java.util.concurrent.Executor getThreadPool()
-
setThreadPool
public <T extends TP> T setThreadPool(java.util.concurrent.Executor thread_pool)
-
getThreadPoolThreadFactory
public ThreadFactory getThreadPoolThreadFactory()
-
setThreadPoolThreadFactory
public <T extends TP> T setThreadPoolThreadFactory(ThreadFactory factory)
-
getInternalThreadPool
public java.util.concurrent.Executor getInternalThreadPool()
-
setInternalThreadPool
public <T extends TP> T setInternalThreadPool(java.util.concurrent.Executor thread_pool)
-
getInternalThreadPoolThreadFactory
public ThreadFactory getInternalThreadPoolThreadFactory()
-
setInternalThreadPoolThreadFactory
public <T extends TP> T setInternalThreadPoolThreadFactory(ThreadFactory factory)
-
getTimer
public TimeScheduler getTimer()
-
setTimer
public <T extends TP> T setTimer(TimeScheduler timer)
Sets a new timer. This should be done before the transport is initialized; be very careful, as replacing a running timer with tasks in it can wreak havoc !- Parameters:
timer
-
-
getTimeService
public TimeService getTimeService()
-
setTimeService
public <T extends TP> T setTimeService(TimeService ts)
-
getThreadFactory
public ThreadFactory getThreadFactory()
Description copied from class:Protocol
Supposed to be overwritten by subclasses. Usually the transport returns a valid non-null thread factory, but thread factories can also be created by individual protocols- Overrides:
getThreadFactory
in classProtocol
- Returns:
-
setThreadFactory
public <T extends TP> T setThreadFactory(ThreadFactory factory)
-
getSocketFactory
public SocketFactory getSocketFactory()
Description copied from class:Protocol
Returns the SocketFactory associated with this protocol, if overridden in a subclass, or passes the call down- Overrides:
getSocketFactory
in classProtocol
- Returns:
- SocketFactory
-
setSocketFactory
public void setSocketFactory(SocketFactory factory)
Description copied from class:Protocol
Sets a SocketFactory. Socket factories are typically provided by the transport (TP
)- Overrides:
setSocketFactory
in classProtocol
-
getThreadNamingPattern
public java.lang.String getThreadNamingPattern()
Names the current thread. Valid values are "pcl": p: include the previous (original) name, e.g. "Incoming thread-1", "UDP ucast receiver" c: include the cluster name, e.g. "MyCluster" l: include the local address of the current member, e.g. "192.168.5.1:5678"
-
getNumMessagesSent
public long getNumMessagesSent()
-
incrBatchesSent
public <T extends TP> T incrBatchesSent(int delta)
-
incrNumSingleMsgsSent
public <T extends TP> T incrNumSingleMsgsSent(int d)
-
getBindAddress
public java.net.InetAddress getBindAddress()
-
setBindAddress
public <T extends TP> T setBindAddress(java.net.InetAddress a)
-
getBindPort
public int getBindPort()
-
setBindPort
public <T extends TP> T setBindPort(int port)
-
setBindToAllInterfaces
public <T extends TP> T setBindToAllInterfaces(boolean f)
-
isReceiveOnAllInterfaces
public boolean isReceiveOnAllInterfaces()
-
getReceiveInterfaces
public java.util.List<java.net.NetworkInterface> getReceiveInterfaces()
-
setPortRange
public <T extends TP> T setPortRange(int range)
-
getPortRange
public int getPortRange()
-
getThreadPoolSize
public int getThreadPoolSize()
-
getThreadPoolSizeActive
public int getThreadPoolSizeActive()
-
getThreadPoolSizeLargest
public int getThreadPoolSizeLargest()
-
getInternalThreadPoolSize
public int getInternalThreadPoolSize()
-
getInternalThreadPoolSizeLargest
public int getInternalThreadPoolSizeLargest()
-
getNumTimerTasks
public int getNumTimerTasks()
-
dumpTimerTasks
public java.lang.String dumpTimerTasks()
-
removeCancelledTimerTasks
public void removeCancelledTimerTasks()
-
getTimerThreads
public int getTimerThreads()
-
getNumThreads
public static int getNumThreads()
-
isDiagnosticsRunning
public boolean isDiagnosticsRunning()
-
setLogDiscardMessages
public <T extends TP> T setLogDiscardMessages(boolean flag)
-
getLogDiscardMessages
public boolean getLogDiscardMessages()
-
setLogDiscardMessagesVersion
public <T extends TP> T setLogDiscardMessagesVersion(boolean f)
-
getLogDiscardMessagesVersion
public boolean getLogDiscardMessagesVersion()
-
getUseIpAddresses
public boolean getUseIpAddresses()
-
isDiagnosticsEnabled
public boolean isDiagnosticsEnabled()
-
setDiagnosticsEnabled
public <T extends TP> T setDiagnosticsEnabled(boolean f)
-
isDiagUdEnabled
public boolean isDiagUdEnabled()
-
diagEnableUdp
public <T extends TP> T diagEnableUdp(boolean f)
-
diagTcpEnabled
public boolean diagTcpEnabled()
-
diagEnableTcp
public <T extends TP> T diagEnableTcp(boolean f)
-
printLogicalAddressCache
public java.lang.String printLogicalAddressCache()
-
printWhoHasCache
public java.lang.String printWhoHasCache()
-
evictLogicalAddressCache
public void evictLogicalAddressCache()
-
evictLogicalAddressCache
public void evictLogicalAddressCache(boolean force)
-
sendMulticast
public abstract void sendMulticast(byte[] data, int offset, int length) throws java.lang.Exception
Send to all members in the group. UDP would use an IP multicast message, whereas TCP would send N messages, one for each member- Parameters:
data
- The data to be sent. This is not a copy, so don't modify itoffset
-length
-- Throws:
java.lang.Exception
-
sendUnicast
public abstract void sendUnicast(PhysicalAddress dest, byte[] data, int offset, int length) throws java.lang.Exception
Send a unicast to 1 member. Note that the destination address is a *physical*, not a logical address- Parameters:
dest
- Must be a non-null unicast addressdata
- The data to be sent. This is not a copy, so don't modify itoffset
-length
-- Throws:
java.lang.Exception
-
getInfo
public abstract java.lang.String getInfo()
-
init
public void init() throws java.lang.Exception
Description copied from class:Protocol
Called after instance has been created (null constructor) and before protocol is started. Properties are already set. Other protocols are not yet connected and events cannot yet be sent.
-
start
public void start() throws java.lang.Exception
Creates the unicast and multicast sockets and starts the unicast and multicast receiver threads- Overrides:
start
in classProtocol
- Throws:
java.lang.Exception
- Thrown if protocol cannot be started successfully. This will cause the ProtocolStack to fail, soJChannel.connect(String)
will throw an exception
-
stop
public void stop()
Description copied from class:Protocol
This method is called on aJChannel.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 flushed
-
destroy
public void destroy()
Description copied from class:Protocol
This method is called on aJChannel.close()
. Does some cleanup; after the call the VM will terminate
-
bundlerStats
public java.lang.String bundlerStats()
-
bundlerStatsReset
public void bundlerStatsReset()
-
bundler
public <T extends TP> T bundler(java.lang.String type)
-
enableDiagnostics
public void enableDiagnostics()
-
disableDiagnostics
public void disableDiagnostics()
-
startDiagnostics
protected void startDiagnostics() throws java.lang.Exception
- Throws:
java.lang.Exception
-
stopDiagnostics
protected void stopDiagnostics()
-
handleProbe
public java.util.Map<java.lang.String,java.lang.String> handleProbe(java.lang.String... keys)
Description copied from interface:DiagnosticsHandler.ProbeHandler
Handles a probe. For each key that is handled, the key and its result should be in the returned map.- Specified by:
handleProbe
in interfaceDiagnosticsHandler.ProbeHandler
- Returns:
- Map
. A map of keys and values. A null return value is permissible.
-
supportedKeys
public java.lang.String[] supportedKeys()
Description copied from interface:DiagnosticsHandler.ProbeHandler
Returns a list of supported keys- Specified by:
supportedKeys
in interfaceDiagnosticsHandler.ProbeHandler
-
handleConnect
protected void handleConnect() throws java.lang.Exception
- Throws:
java.lang.Exception
-
handleDisconnect
protected void handleDisconnect()
-
down
public java.lang.Object down(Event evt)
Description copied from class:Protocol
An 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
public java.lang.Object down(Message msg)
A message needs to be sent to a single member or all members
-
createDiagnosticsHandler
protected DiagnosticsHandler createDiagnosticsHandler()
-
createBundler
protected Bundler createBundler(java.lang.String type)
-
loopback
protected void loopback(Message msg, boolean multicast)
-
setSourceAddress
protected void setSourceAddress(Message msg)
If the sender is null, set our own address. We cannot just go ahead and set the address anyway, as we might be sending a message on behalf of someone else ! E.g. in case of retransmission, when the original sender has crashed, or in a FLUSH protocol when we have to return all unstable messages with the FLUSH_OK response.
-
passMessageUp
public void passMessageUp(Message msg, byte[] cluster_name, 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
public void receive(Address sender, byte[] data, int offset, int length)
Subclasses must call this method when a unicast or multicast message has been received.
-
receive
public void receive(Address sender, java.io.DataInput in) throws java.lang.Exception
- Throws:
java.lang.Exception
-
handleMessageBatch
protected void handleMessageBatch(java.io.DataInput in, boolean multicast)
-
handleSingleMessage
protected void handleSingleMessage(java.io.DataInput in, boolean multicast)
-
processBatch
protected void processBatch(MessageBatch batch, boolean oob, boolean internal)
-
unicastDestMismatch
public boolean unicastDestMismatch(Address dest)
-
submitToThreadPool
public boolean submitToThreadPool(java.lang.Runnable task, boolean spawn_thread_on_rejection)
-
submitToThreadPool
public boolean submitToThreadPool(java.util.concurrent.Executor pool, java.lang.Runnable task, boolean spawn_thread_on_rejection, boolean forward_to_internal_pool)
-
runInNewThread
protected boolean runInNewThread(java.lang.Runnable task)
-
versionMatch
protected boolean versionMatch(short version, Address sender)
-
send
protected void send(Message msg) throws java.lang.Exception
Serializes and sends a message. This method is not reentrant- Throws:
java.lang.Exception
-
doSend
public void doSend(byte[] buf, int offset, int length, Address dest) throws java.lang.Exception
- Throws:
java.lang.Exception
-
sendToSingleMember
protected void sendToSingleMember(Address dest, byte[] buf, int offset, int length) throws java.lang.Exception
- Throws:
java.lang.Exception
-
sendToMembers
protected void sendToMembers(java.util.Collection<Address> mbrs, byte[] buf, int offset, int length) throws java.lang.Exception
Fetches the physical addrs for mbrs and sends the msg to each physical address. Asks discovery for missing members' physical addresses if needed- Throws:
java.lang.Exception
-
fetchPhysicalAddrs
protected void fetchPhysicalAddrs(java.util.List<Address> missing)
-
fetchResponsesFromDiscoveryProtocol
protected Responses fetchResponsesFromDiscoveryProtocol(java.util.List<Address> missing)
-
timestamp
protected long timestamp()
-
registerLocalAddress
protected void registerLocalAddress(Address addr)
Associates the address with the physical address fetched from the cache- Parameters:
addr
-
-
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
-
setThreadNames
protected void setThreadNames()
-
unsetThreadNames
protected void unsetThreadNames()
-
setInAllThreadFactories
protected void setInAllThreadFactories(java.lang.String cluster_name, Address local_address, java.lang.String pattern)
-
createThreadPool
protected static java.util.concurrent.ExecutorService createThreadPool(int min_threads, int max_threads, long keep_alive_time, java.lang.String rejection_policy, java.util.concurrent.BlockingQueue<java.lang.Runnable> queue, ThreadFactory factory, Log log, boolean use_fork_join_pool, boolean use_common_fork_join_pool)
-
shutdownThreadPool
protected static void shutdownThreadPool(java.util.concurrent.Executor thread_pool)
-
addPhysicalAddressToCache
protected boolean addPhysicalAddressToCache(Address logical_addr, PhysicalAddress physical_addr)
-
addPhysicalAddressToCache
protected boolean addPhysicalAddressToCache(Address logical_addr, PhysicalAddress physical_addr, boolean overwrite)
-
getPhysicalAddressFromCache
protected PhysicalAddress getPhysicalAddressFromCache(Address logical_addr)
-
getAllPhysicalAddressesFromCache
protected java.util.Collection<PhysicalAddress> getAllPhysicalAddressesFromCache()
-
removeLogicalAddressFromCache
protected void removeLogicalAddressFromCache(Address logical_addr)
-
clearLogicalAddressCache
public void clearLogicalAddressCache()
Clears the cache. Do not use, this is only for unit testing !
-
getPhysicalAddress
protected abstract PhysicalAddress getPhysicalAddress()
-
-