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
Protocol.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 | Field and 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 Address |
local_addr
The address (host and port) of this member
|
protected java.util.Vector |
members
The members of this group (updated when a member joins or leaves)
|
protected TimeScheduler |
timer |
protected View |
view |
down_handler, down_prot, down_queue, down_thread, down_thread_prio, log, observer, props, stack, stats, up_handler, up_prot, up_queue, up_thread, up_thread_prio
Modifier | Constructor and Description |
---|---|
protected |
TP()
Creates the TP protocol, and initializes the
state variables, does however not start any sockets or threads.
|
Modifier and Type | Method and Description |
---|---|
void |
down(Event evt)
Caller by the layer above this layer.
|
java.util.Map |
dumpStats() |
java.lang.String |
getBindAddress() |
boolean |
getBindToAllInterfaces()
Deprecated.
Use
isReceiveOnAllInterfaces() instead |
java.lang.String |
getChannelName() |
int |
getIncomingQueueSize() |
abstract java.lang.String |
getInfo() |
Address |
getLocalAddress() |
int |
getMaxBundleSize() |
long |
getMaxBundleTimeout() |
long |
getNumBytesReceived() |
long |
getNumBytesSent() |
long |
getNumMessagesReceived() |
long |
getNumMessagesSent() |
int |
getOutgoingQueueMaxSize() |
int |
getOutgoingQueueSize() |
java.util.List |
getReceiveInterfaces() |
java.util.List |
getSendInterfaces() |
protected void |
handleConfigEvent(java.util.HashMap map) |
protected void |
handleDownEvent(Event evt) |
void |
init()
Called after instance has been created (null constructor) and before protocol is started.
|
boolean |
isDiscardIncompatiblePackets() |
boolean |
isEnableBundling() |
boolean |
isLoopback() |
boolean |
isReceiveOnAllInterfaces() |
boolean |
isSendOnAllInterfaces() |
boolean |
isUseIncomingPacketHandler() |
boolean |
isUseOutgoingPacketHandler() |
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 |
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 |
setBindAddress(java.lang.String bind_addr) |
void |
setBindToAllInterfaces(boolean flag) |
void |
setDiscardIncompatiblePackets(boolean flag) |
void |
setEnableBundling(boolean flag) |
void |
setLoopback(boolean b) |
void |
setMaxBundleSize(int size) |
void |
setMaxBundleTimeout(long timeout) |
void |
setOutgoingQueueMaxSize(int new_size) |
boolean |
setProperties(java.util.Properties props)
Setup the Protocol instance according to the configuration string
|
protected void |
setThreadNames() |
void |
start()
Creates the unicast and multicast sockets and starts the unicast and multicast receiver threads
|
void |
startUpHandler()
This prevents the up-handler thread to be created, which essentially is superfluous:
messages are received from the network rather than from a layer below.
|
void |
stop()
This method is called on a
Channel.disconnect() . |
java.lang.String |
toString()
debug only
|
protected void |
unsetThreadNames() |
void |
up(Event evt)
handle the UP event.
|
destroy, downThreadEnabled, enableStats, getDownProtocol, getDownQueue, getName, getProperties, getUpProtocol, getUpQueue, handleSpecialDownEvent, passDown, passUp, printStats, providedDownServices, providedUpServices, receiveDownEvent, receiveUpEvent, requiredDownServices, requiredUpServices, setDownProtocol, setObserver, setPropertiesInternal, setProtocolStack, setUpProtocol, startDownHandler, statsEnabled, stopInternal, upThreadEnabled
protected Address local_addr
protected java.lang.String channel_name
protected java.net.InetAddress bind_addr
protected final java.util.Vector members
protected View view
protected TimeScheduler timer
protected TP()
public java.lang.String toString()
toString
in class java.lang.Object
public void resetStats()
resetStats
in class Protocol
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 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 int getMaxBundleSize()
public void setMaxBundleSize(int size)
public long getMaxBundleTimeout()
public void setMaxBundleTimeout(long timeout)
public int getOutgoingQueueSize()
public int getIncomingQueueSize()
public Address getLocalAddress()
public java.lang.String getChannelName()
public boolean isLoopback()
public void setLoopback(boolean b)
public boolean isUseIncomingPacketHandler()
public boolean isUseOutgoingPacketHandler()
public int getOutgoingQueueMaxSize()
public void setOutgoingQueueMaxSize(int new_size)
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 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 flushedpublic boolean setProperties(java.util.Properties props)
setProperties
in class Protocol
public void startUpHandler()
startUpHandler
in class Protocol
public void up(Event evt)
public void down(Event evt)
protected final void receive(Address dest, Address sender, byte[] data, int offset, int length)
dest
- sender
- data
- offset
- length
- protected void handleDownEvent(Event evt)
protected void setThreadNames()
protected void unsetThreadNames()
protected void handleConfigEvent(java.util.HashMap map)
Copyright ? 1998-2006 Bela Ban. All Rights Reserved.