BasicTCP
, LOOPBACK
, SHARED_LOOPBACK
, TUNNEL
, UDP
public abstract class TP extends Protocol
sendToAllMembers(byte[], int, int)
sendToSingleMember(org.jgroups.Address, 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 themselves
destroy()
receive(Address, Address, byte[], int, int)
method must
be called by subclasses when a unicast or multicast message has been received.Modifier and Type | Class | Description |
---|---|---|
static interface |
TP.ProbeHandler |
|
static class |
TP.ProtocolAdapter |
Modifier and Type | Field | Description |
---|---|---|
protected java.net.InetAddress |
bind_addr |
The interface (NIC) which should be used by this transport
|
protected java.lang.String |
channel_name |
The name of the group to which this member is connected
|
protected boolean |
discard_incompatible_packets |
Discard packets with a different version.
|
protected ThreadFactory |
global_thread_factory |
Used by all threads created by JGroups outside of the thread pools
|
protected Address |
local_addr |
The address (host and port) of this member
|
protected java.util.HashSet<Address> |
members |
The members of this group (updated when a member joins or leaves)
|
protected boolean |
persistent_ports |
|
protected java.lang.String |
persistent_ports_file |
|
protected PortsManager |
pm |
|
protected long |
pm_expiry_time |
|
protected java.lang.String |
thread_naming_pattern |
Names the current thread.
|
protected TimeScheduler |
timer |
================================== Timer thread pool =================================
|
protected ThreadFactory |
timer_thread_factory |
|
protected View |
view |
Modifier | Constructor | Description |
---|---|---|
protected |
TP() |
Creates the TP protocol, and initializes the
state variables, does however not start any sockets or threads.
|
Modifier and Type | Method | Description |
---|---|---|
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) |
|
void |
destroy() |
This method is called on a
Channel.close() . |
java.lang.Object |
down(Event evt) |
Caller by the layer above this layer.
|
java.util.Map<java.lang.String,java.lang.Object> |
dumpStats() |
|
java.lang.String |
getBindAddress() |
|
int |
getBindPort() |
|
boolean |
getBindToAllInterfaces() |
Deprecated.
Use
isReceiveOnAllInterfaces() instead |
java.lang.String |
getChannelName() |
|
java.util.concurrent.Executor |
getDefaultThreadPool() |
|
ThreadFactory |
getDefaultThreadPoolThreadFactory() |
|
long |
getIncomingKeepAliveTime() |
|
int |
getIncomingMaxPoolSize() |
|
int |
getIncomingMaxQueueSize() |
|
long |
getIncomingMessages() |
|
int |
getIncomingMinPoolSize() |
|
int |
getIncomingPoolSize() |
|
int |
getIncomingQueueSize() |
|
abstract java.lang.String |
getInfo() |
|
Address |
getLocalAddress() |
|
int |
getMaxBundleSize() |
|
long |
getMaxBundleTimeout() |
|
long |
getNumBytesReceived() |
|
long |
getNumBytesSent() |
|
long |
getNumMessagesReceived() |
|
long |
getNumMessagesSent() |
|
long |
getOOBKeepAliveTime() |
|
int |
getOOBMaxPoolSize() |
|
int |
getOOBMaxQueueSize() |
|
long |
getOOBMessages() |
|
int |
getOOBMinPoolSize() |
|
int |
getOOBPoolSize() |
|
int |
getOOBQueueSize() |
|
java.util.concurrent.Executor |
getOOBThreadPool() |
|
ThreadFactory |
getOOBThreadPoolThreadFactory() |
|
java.util.List |
getReceiveInterfaces() |
|
java.util.List |
getSendInterfaces() |
|
java.lang.String |
getSingletonName() |
|
ThreadFactory |
getThreadFactory() |
Supposed to be overwritten by subclasses.
|
java.lang.String |
getThreadNamingPattern() |
|
TimeScheduler |
getTimer() |
|
ThreadFactory |
getTimerThreadFactory() |
|
java.util.concurrent.ConcurrentMap<java.lang.String,Protocol> |
getUpProtocols() |
|
protected void |
handleConfigEvent(java.util.Map<java.lang.String,java.lang.Object> map) |
|
protected void |
handleConnect() |
|
protected void |
handleDisconnect() |
|
protected java.lang.Object |
handleDownEvent(Event evt) |
|
void |
init() |
Called after instance has been created (null constructor) and before protocol is started.
|
boolean |
isDefaulThreadPoolEnabled() |
|
boolean |
isDiscardIncompatiblePackets() |
|
boolean |
isEnable_unicast_bundling() |
|
boolean |
isEnableBundling() |
|
boolean |
isLoopback() |
|
boolean |
isOOBThreadPoolEnabled() |
|
boolean |
isReceiveOnAllInterfaces() |
|
boolean |
isSendOnAllInterfaces() |
|
boolean |
isUseIncomingPacketHandler() |
|
protected void |
passToAllUpProtocols(Event evt) |
|
abstract void |
postUnmarshalling(Message msg,
Address dest,
Address src,
boolean multicast) |
|
abstract void |
postUnmarshallingList(Message msg,
Address dest,
boolean multicast) |
|
protected void |
receive(Address dest,
Address sender,
byte[] data,
int offset,
int length) |
Subclasses must call this method when a unicast or multicast message has been received.
|
void |
registerProbeHandler(TP.ProbeHandler handler) |
|
void |
resetStats() |
|
abstract void |
sendToAllMembers(byte[] data,
int offset,
int length) |
Send to all members in the group.
|
abstract void |
sendToSingleMember(Address dest,
byte[] data,
int offset,
int length) |
Send to all members in the group.
|
void |
sendUpLocalAddressEvent() |
|
void |
setBindAddress(java.lang.String bind_addr) |
|
void |
setBindPort(int port) |
|
void |
setBindToAllInterfaces(boolean flag) |
|
void |
setDefaultThreadPool(java.util.concurrent.Executor thread_pool) |
|
void |
setDefaultThreadPoolThreadFactory(ThreadFactory factory) |
|
void |
setDiscardIncompatiblePackets(boolean flag) |
|
void |
setEnable_unicast_bundling(boolean enable_unicast_bundling) |
|
void |
setEnableBundling(boolean flag) |
|
void |
setIncomingKeepAliveTime(long time) |
|
void |
setIncomingMaxPoolSize(int size) |
|
void |
setIncomingMinPoolSize(int size) |
|
void |
setLoopback(boolean b) |
|
void |
setMaxBundleSize(int size) |
|
void |
setMaxBundleTimeout(long timeout) |
|
void |
setOOBKeepAliveTime(long time) |
|
void |
setOOBMaxPoolSize(int size) |
|
void |
setOOBMinPoolSize(int size) |
|
void |
setOOBThreadPool(java.util.concurrent.Executor oob_thread_pool) |
|
void |
setOOBThreadPoolThreadFactory(ThreadFactory factory) |
|
boolean |
setProperties(java.util.Properties props) |
Setup the Protocol instance according to the configuration string
|
void |
setThreadFactory(ThreadFactory factory) |
|
protected void |
setThreadNames() |
|
void |
setTimerThreadFactory(ThreadFactory factory) |
|
void |
start() |
Creates the unicast and multicast sockets and starts the unicast and multicast receiver threads
|
void |
stop() |
This method is called on a
Channel.disconnect() . |
java.lang.String |
toString() |
debug only
|
void |
unregisterProbeHandler(TP.ProbeHandler handler) |
|
protected void |
unsetThreadNames() |
|
java.lang.Object |
up(Event evt) |
handle the UP event.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
downThreadEnabled, enableStats, getDownProtocol, getName, getProperties, getProtocolStack, getTransport, getUpProtocol, printStats, providedDownServices, providedUpServices, requiredDownServices, requiredUpServices, setDownProtocol, setPropertiesInternal, setProtocolStack, setUpProtocol, statsEnabled, upThreadEnabled
protected Address local_addr
protected java.lang.String channel_name
protected java.net.InetAddress bind_addr
protected final java.util.HashSet<Address> members
protected View view
protected boolean discard_incompatible_packets
protected java.lang.String thread_naming_pattern
protected TimeScheduler timer
protected ThreadFactory timer_thread_factory
protected ThreadFactory global_thread_factory
protected PortsManager pm
protected java.lang.String persistent_ports_file
protected long pm_expiry_time
protected boolean persistent_ports
protected TP()
public java.lang.String getThreadNamingPattern()
public java.util.concurrent.Executor getOOBThreadPool()
public void setOOBThreadPool(java.util.concurrent.Executor oob_thread_pool)
public ThreadFactory getOOBThreadPoolThreadFactory()
public void setOOBThreadPoolThreadFactory(ThreadFactory factory)
public java.util.concurrent.Executor getDefaultThreadPool()
public void setDefaultThreadPool(java.util.concurrent.Executor thread_pool)
public ThreadFactory getDefaultThreadPoolThreadFactory()
public void setDefaultThreadPoolThreadFactory(ThreadFactory factory)
public ThreadFactory getTimerThreadFactory()
public void setTimerThreadFactory(ThreadFactory factory)
public TimeScheduler getTimer()
public ThreadFactory getThreadFactory()
Protocol
getThreadFactory
in class Protocol
public void setThreadFactory(ThreadFactory factory)
public java.lang.String toString()
toString
in class java.lang.Object
public void resetStats()
resetStats
in class Protocol
public void registerProbeHandler(TP.ProbeHandler handler)
public void unregisterProbeHandler(TP.ProbeHandler handler)
public long getNumMessagesSent()
public long getNumMessagesReceived()
public long getNumBytesSent()
public long getNumBytesReceived()
public java.lang.String getBindAddress()
public void setBindAddress(java.lang.String bind_addr) throws java.net.UnknownHostException
java.net.UnknownHostException
public int getBindPort()
public void setBindPort(int port)
public boolean getBindToAllInterfaces()
isReceiveOnAllInterfaces()
insteadpublic void setBindToAllInterfaces(boolean flag)
public boolean isReceiveOnAllInterfaces()
public java.util.List getReceiveInterfaces()
public boolean isSendOnAllInterfaces()
public java.util.List getSendInterfaces()
public boolean isDiscardIncompatiblePackets()
public void setDiscardIncompatiblePackets(boolean flag)
public boolean isEnableBundling()
public void setEnableBundling(boolean flag)
public boolean isEnable_unicast_bundling()
public void setEnable_unicast_bundling(boolean enable_unicast_bundling)
public int getMaxBundleSize()
public void setMaxBundleSize(int size)
public long getMaxBundleTimeout()
public void setMaxBundleTimeout(long timeout)
public Address getLocalAddress()
public java.lang.String getChannelName()
public boolean isLoopback()
public void setLoopback(boolean b)
public boolean isUseIncomingPacketHandler()
public boolean isDefaulThreadPoolEnabled()
public boolean isOOBThreadPoolEnabled()
public java.util.concurrent.ConcurrentMap<java.lang.String,Protocol> getUpProtocols()
public int getOOBMinPoolSize()
public void setOOBMinPoolSize(int size)
public int getOOBMaxPoolSize()
public void setOOBMaxPoolSize(int size)
public int getOOBPoolSize()
public long getOOBKeepAliveTime()
public void setOOBKeepAliveTime(long time)
public long getOOBMessages()
public int getOOBQueueSize()
public int getOOBMaxQueueSize()
public int getIncomingMinPoolSize()
public void setIncomingMinPoolSize(int size)
public int getIncomingMaxPoolSize()
public void setIncomingMaxPoolSize(int size)
public int getIncomingPoolSize()
public long getIncomingKeepAliveTime()
public void setIncomingKeepAliveTime(long time)
public long getIncomingMessages()
public int getIncomingQueueSize()
public int getIncomingMaxQueueSize()
public java.util.Map<java.lang.String,java.lang.Object> dumpStats()
public abstract void sendToAllMembers(byte[] data, int offset, int length) throws java.lang.Exception
data
- The data to be sent. This is not a copy, so don't modify itoffset
- length
- java.lang.Exception
public abstract void sendToSingleMember(Address dest, byte[] data, int offset, int length) throws java.lang.Exception
dest
- Must be a non-null unicast addressdata
- The data to be sent. This is not a copy, so don't modify itoffset
- length
- java.lang.Exception
public abstract java.lang.String getInfo()
public abstract void postUnmarshalling(Message msg, Address dest, Address src, boolean multicast)
public abstract void postUnmarshallingList(Message msg, Address dest, boolean multicast)
public void init() throws java.lang.Exception
Protocol
public void destroy()
Protocol
Channel.close()
.
Does some cleanup; after the call the VM will terminatepublic void start() throws java.lang.Exception
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 void handleConnect() throws java.lang.Exception
java.lang.Exception
protected void handleDisconnect()
public java.lang.String getSingletonName()
public boolean setProperties(java.util.Properties props)
setProperties
in class Protocol
public java.lang.Object up(Event evt)
public java.lang.Object down(Event evt)
protected final void receive(Address dest, Address sender, byte[] data, int offset, int length)
dest
- sender
- data
- offset
- length
- protected java.lang.Object handleDownEvent(Event evt)
protected void setThreadNames()
protected void unsetThreadNames()
protected void handleConfigEvent(java.util.Map<java.lang.String,java.lang.Object> map)
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)
protected void passToAllUpProtocols(Event evt)
public void sendUpLocalAddressEvent()
Copyright ? 1998-2008 Bela Ban. All Rights Reserved.