Java Doc for TP.java in  » Net » JGroups-2.4.1-sp3 » org » jgroups » protocols » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Net » JGroups 2.4.1 sp3 » org.jgroups.protocols 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   java.lang.Thread
      org.jgroups.stack.UpHandler
         org.jgroups.protocols.TP

All known Subclasses:   org.jgroups.protocols.BasicTCP,  org.jgroups.protocols.UDP,
TP
abstract public class TP extends Protocol (Code)
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
  • loopback
A subclass has to override The create() or start() method has to create a local address.
The TP.receive(Address,Address,byte[],int,int) method must be called by subclasses when a unicast or multicast message has been received.
author:
   Bela Ban
version:
   $Id: TP.java,v 1.77.2.3 2007/04/27 08:03:51 belaban Exp $

Inner Class :static class IncomingQueueEntry
Inner Class :class IncomingPacketHandler implements Runnable
Inner Class :class IncomingMessageHandler implements Runnable
Inner Class :class OutgoingPacketHandler implements Runnable

Field Summary
final static  byteLIST
    
final static  byteMULTICAST
    
 byte[]additional_data
     If set it will be added to local_addr.
 HashMapaddr_translation_table
     HashMap.
protected  InetAddressbind_addr
    
 intbind_port
     The port to which the transport binds.
 booleanbind_to_all_interfaces
    
final  ExposedBufferedInputStreambuf_in_stream
    
final  ExposedBufferedOutputStreambuf_out_stream
    
protected  Stringchannel_name
    
 Stringdiagnostics_addr
    
 intdiagnostics_port
    
final  DataInputStreamdis
    
 booleandiscard_incompatible_packets
     Discard packets with a different version.
final  ExposedDataOutputStreamdos
    
 booleanenable_bundling
    
 booleanenable_diagnostics
    
static  NumberFormatf
    
 TpHeaderheader
    
final  ExposedByteArrayInputStreamin_stream
    
 IncomingMessageHandlerincoming_msg_handler
    
 Queueincoming_msg_queue
    
 IncomingPacketHandlerincoming_packet_handler
    
 Queueincoming_packet_queue
    
protected  Addresslocal_addr
    
 booleanloopback
     If true, messages sent to self are treated specially: unicast messages are looped back immediately, multicast messages get a local copy first and - when the real copy arrives - it will be discarded.
 intmax_bundle_size
     Maximum number of bytes for messages to be queued until they are sent.
 longmax_bundle_timeout
     Max number of milliseconds until queued messages are sent.
final protected  Vectormembers
    
final  Stringname
    
 longnum_msgs_sentnum_msgs_receivednum_bytes_sentnum_bytes_received
    
final  ExposedByteArrayOutputStreamout_stream
     Pre-allocated byte stream.
 OutgoingPacketHandleroutgoing_packet_handler
    
 BoundedLinkedQueueoutgoing_queue
    
 intoutgoing_queue_max_size
    
 intport_range
    
 java.util.Listreceive_interfaces
     List of interfaces to receive multicasts on.
 booleanreceive_on_all_interfaces
    
 java.util.Listsend_interfaces
     List of interfaces to send multicasts on.
 booleansend_on_all_interfaces
     If true, the transport should use all available interfaces to send multicast messages.
protected  TimeSchedulertimer
    
 booleanuse_addr_translation
    
 booleanuse_incoming_packet_handler
     Sometimes receivers are overloaded (they have to handle de-serialization etc). Packet handler is a separate thread taking care of de-serialization, receiver thread(s) simply put packet in queue and return immediately.
 booleanuse_local_host
    
 booleanuse_outgoing_packet_handler
     Packets to be sent are stored in outgoing_queue and sent by a separate thread.
protected  Viewview
    

Constructor Summary
protected  TP()
     Creates the TP protocol, and initializes the state variables, does however not start any sockets or threads.

Method Summary
public  voiddown(Event evt)
     Caller by the layer above this layer.
public  MapdumpStats()
    
public  StringgetBindAddress()
    
public  booleangetBindToAllInterfaces()
    
public  StringgetChannelName()
    
public  intgetIncomingQueueSize()
    
abstract public  StringgetInfo()
    
public  AddressgetLocalAddress()
    
public  intgetMaxBundleSize()
    
public  longgetMaxBundleTimeout()
    
public  longgetNumBytesReceived()
    
public  longgetNumBytesSent()
    
public  longgetNumMessagesReceived()
    
public  longgetNumMessagesSent()
    
public  intgetOutgoingQueueMaxSize()
    
public  intgetOutgoingQueueSize()
    
public  java.util.ListgetReceiveInterfaces()
    
public  java.util.ListgetSendInterfaces()
    
protected  voidhandleConfigEvent(HashMap map)
    
protected  voidhandleDownEvent(Event evt)
    
public  voidinit()
    
public  booleanisDiscardIncompatiblePackets()
    
public  booleanisEnableBundling()
    
public  booleanisLoopback()
    
public  booleanisReceiveOnAllInterfaces()
    
public  booleanisSendOnAllInterfaces()
    
public  booleanisUseIncomingPacketHandler()
    
public  booleanisUseOutgoingPacketHandler()
    
abstract public  voidpostUnmarshalling(Message msg, Address dest, Address src, boolean multicast)
    
abstract public  voidpostUnmarshallingList(Message msg, Address dest, boolean multicast)
    
final protected  voidreceive(Address dest, Address sender, byte[] data, int offset, int length)
     Subclasses must call this method when a unicast or multicast message has been received.
public  voidresetStats()
    
abstract public  voidsendToAllMembers(byte[] data, int offset, int length)
     Send to all members in the group.
abstract public  voidsendToSingleMember(Address dest, byte[] data, int offset, int length)
     Send to all members in the group.
public  voidsetBindAddress(String bind_addr)
    
public  voidsetBindToAllInterfaces(boolean flag)
    
public  voidsetDiscardIncompatiblePackets(boolean flag)
    
public  voidsetEnableBundling(boolean flag)
    
public  voidsetLoopback(boolean b)
    
public  voidsetMaxBundleSize(int size)
    
public  voidsetMaxBundleTimeout(long timeout)
    
public  voidsetOutgoingQueueMaxSize(int new_size)
    
public  booleansetProperties(Properties props)
    
protected  voidsetThreadNames()
    
public  voidstart()
    
public  voidstartUpHandler()
     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.
public  voidstop()
    
public  StringtoString()
    
protected  voidunsetThreadNames()
    
public  voidup(Event evt)
     handle the UP event.

Field Detail
LIST
final static byte LIST(Code)



MULTICAST
final static byte MULTICAST(Code)



additional_data
byte[] additional_data(Code)
If set it will be added to local_addr. Used to implement for example transport independent addresses



addr_translation_table
HashMap addr_translation_table(Code)
HashMap. Keys=senders, values=destinations. For each incoming message M with sender S, adds an entry with key=S and value= sender's IP address and port.



bind_addr
protected InetAddress bind_addr(Code)
The interface (NIC) which should be used by this transport



bind_port
int bind_port(Code)
The port to which the transport binds. 0 means to bind to any (ephemeral) port



bind_to_all_interfaces
boolean bind_to_all_interfaces(Code)
If true, the transport should use all available interfaces to receive multicast messages receive_on_all_interfaces



buf_in_stream
final ExposedBufferedInputStream buf_in_stream(Code)



buf_out_stream
final ExposedBufferedOutputStream buf_out_stream(Code)



channel_name
protected String channel_name(Code)
The name of the group to which this member is connected



diagnostics_addr
String diagnostics_addr(Code)



diagnostics_port
int diagnostics_port(Code)



dis
final DataInputStream dis(Code)



discard_incompatible_packets
boolean discard_incompatible_packets(Code)
Discard packets with a different version. Usually minor version differences are okay. Setting this property to true means that we expect the exact same version on all incoming packets



dos
final ExposedDataOutputStream dos(Code)



enable_bundling
boolean enable_bundling(Code)
Enabled bundling of smaller messages into bigger ones



enable_diagnostics
boolean enable_diagnostics(Code)



f
static NumberFormat f(Code)



header
TpHeader header(Code)



in_stream
final ExposedByteArrayInputStream in_stream(Code)



incoming_msg_handler
IncomingMessageHandler incoming_msg_handler(Code)



incoming_msg_queue
Queue incoming_msg_queue(Code)
Used by packet handler to store incoming Messages



incoming_packet_handler
IncomingPacketHandler incoming_packet_handler(Code)
Dequeues DatagramPackets from packet_queue, unmarshalls them and calls handleIncomingUdpPacket()



incoming_packet_queue
Queue incoming_packet_queue(Code)
Used by packet handler to store incoming DatagramPackets



local_addr
protected Address local_addr(Code)
The address (host and port) of this member



loopback
boolean loopback(Code)
If true, messages sent to self are treated specially: unicast messages are looped back immediately, multicast messages get a local copy first and - when the real copy arrives - it will be discarded. Useful for Window media (non)sense



max_bundle_size
int max_bundle_size(Code)
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



max_bundle_timeout
long max_bundle_timeout(Code)
Max number of milliseconds until queued messages are sent. Messages are sent when max_bundle_size or max_bundle_timeout has been exceeded (whichever occurs faster)



members
final protected Vector members(Code)
The members of this group (updated when a member joins or leaves)



name
final String name(Code)



num_msgs_sentnum_msgs_receivednum_bytes_sentnum_bytes_received
long num_msgs_sentnum_msgs_receivednum_bytes_sentnum_bytes_received(Code)



out_stream
final ExposedByteArrayOutputStream out_stream(Code)
Pre-allocated byte stream. Used for marshalling messages. Will grow as needed



outgoing_packet_handler
OutgoingPacketHandler outgoing_packet_handler(Code)



outgoing_queue
BoundedLinkedQueue outgoing_queue(Code)
Used by packet handler to store outgoing DatagramPackets



outgoing_queue_max_size
int outgoing_queue_max_size(Code)
max number of elements in the bounded outgoing_queue



port_range
int port_range(Code)



receive_interfaces
java.util.List receive_interfaces(Code)
List of 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 override receive_on_all_interfaces.



receive_on_all_interfaces
boolean receive_on_all_interfaces(Code)
If true, the transport should use all available interfaces to receive multicast messages



send_interfaces
java.util.List send_interfaces(Code)
List of interfaces to send multicasts on. The multicast send socket will send the same multicast message 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. If this property is set, it override send_on_all_interfaces.



send_on_all_interfaces
boolean send_on_all_interfaces(Code)
If true, the transport should use all available interfaces to send multicast messages. This means the same multicast message is sent N times, so use with care



timer
protected TimeScheduler timer(Code)



use_addr_translation
boolean use_addr_translation(Code)



use_incoming_packet_handler
boolean use_incoming_packet_handler(Code)
Sometimes receivers are overloaded (they have to handle de-serialization etc). Packet handler is a separate thread taking care of de-serialization, receiver thread(s) simply put packet in queue and return immediately. Setting this to true adds one more thread



use_local_host
boolean use_local_host(Code)
Overrides bind_addr, -Djgroups.bind_addr and -Dbind.address: let's the OS return the local host address



use_outgoing_packet_handler
boolean use_outgoing_packet_handler(Code)
Packets to be sent are stored in outgoing_queue and sent by a separate thread. Enabling this value uses an additional thread



view
protected View view(Code)




Constructor Detail
TP
protected TP()(Code)
Creates the TP protocol, and initializes the state variables, does however not start any sockets or threads.




Method Detail
down
public void down(Event evt)(Code)
Caller by the layer above this layer. Usually we just put this Message into the send queue and let one or more worker threads handle it. A worker thread then removes the Message from the send queue, performs a conversion and adds the modified Message to the send queue of the layer below it, by calling down()).



dumpStats
public Map dumpStats()(Code)



getBindAddress
public String getBindAddress()(Code)



getBindToAllInterfaces
public boolean getBindToAllInterfaces()(Code)
TP.isReceiveOnAllInterfaces()



getChannelName
public String getChannelName()(Code)



getIncomingQueueSize
public int getIncomingQueueSize()(Code)



getInfo
abstract public String getInfo()(Code)



getLocalAddress
public Address getLocalAddress()(Code)



getMaxBundleSize
public int getMaxBundleSize()(Code)



getMaxBundleTimeout
public long getMaxBundleTimeout()(Code)



getNumBytesReceived
public long getNumBytesReceived()(Code)



getNumBytesSent
public long getNumBytesSent()(Code)



getNumMessagesReceived
public long getNumMessagesReceived()(Code)



getNumMessagesSent
public long getNumMessagesSent()(Code)



getOutgoingQueueMaxSize
public int getOutgoingQueueMaxSize()(Code)



getOutgoingQueueSize
public int getOutgoingQueueSize()(Code)



getReceiveInterfaces
public java.util.List getReceiveInterfaces()(Code)



getSendInterfaces
public java.util.List getSendInterfaces()(Code)



handleConfigEvent
protected void handleConfigEvent(HashMap map)(Code)



handleDownEvent
protected void handleDownEvent(Event evt)(Code)



init
public void init() throws Exception(Code)



isDiscardIncompatiblePackets
public boolean isDiscardIncompatiblePackets()(Code)



isEnableBundling
public boolean isEnableBundling()(Code)



isLoopback
public boolean isLoopback()(Code)



isReceiveOnAllInterfaces
public boolean isReceiveOnAllInterfaces()(Code)



isSendOnAllInterfaces
public boolean isSendOnAllInterfaces()(Code)



isUseIncomingPacketHandler
public boolean isUseIncomingPacketHandler()(Code)



isUseOutgoingPacketHandler
public boolean isUseOutgoingPacketHandler()(Code)



postUnmarshalling
abstract public void postUnmarshalling(Message msg, Address dest, Address src, boolean multicast)(Code)



postUnmarshallingList
abstract public void postUnmarshallingList(Message msg, Address dest, boolean multicast)(Code)



receive
final protected void receive(Address dest, Address sender, byte[] data, int offset, int length)(Code)
Subclasses must call this method when a unicast or multicast message has been received. Declared final so subclasses cannot override this method.
Parameters:
  dest -
Parameters:
  sender -
Parameters:
  data -
Parameters:
  offset -
Parameters:
  length -



resetStats
public void resetStats()(Code)



sendToAllMembers
abstract public void sendToAllMembers(byte[] data, int offset, int length) throws Exception(Code)
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 it
Parameters:
  offset -
Parameters:
  length -
throws:
  Exception -



sendToSingleMember
abstract public void sendToSingleMember(Address dest, byte[] data, int offset, int length) throws Exception(Code)
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:
  dest - Must be a non-null unicast address
Parameters:
  data - The data to be sent. This is not a copy, so don't modify it
Parameters:
  offset -
Parameters:
  length -
throws:
  Exception -



setBindAddress
public void setBindAddress(String bind_addr) throws UnknownHostException(Code)



setBindToAllInterfaces
public void setBindToAllInterfaces(boolean flag)(Code)



setDiscardIncompatiblePackets
public void setDiscardIncompatiblePackets(boolean flag)(Code)



setEnableBundling
public void setEnableBundling(boolean flag)(Code)



setLoopback
public void setLoopback(boolean b)(Code)



setMaxBundleSize
public void setMaxBundleSize(int size)(Code)



setMaxBundleTimeout
public void setMaxBundleTimeout(long timeout)(Code)



setOutgoingQueueMaxSize
public void setOutgoingQueueMaxSize(int new_size)(Code)



setProperties
public boolean setProperties(Properties props)(Code)
Setup the Protocol instance according to the configuration string true if no other properties are left.false if the properties still have data in them, ie ,properties are left over and not handled by the protocol stack



setThreadNames
protected void setThreadNames()(Code)



start
public void start() throws Exception(Code)
Creates the unicast and multicast sockets and starts the unicast and multicast receiver threads



startUpHandler
public void startUpHandler()(Code)
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. DON'T REMOVE !



stop
public void stop()(Code)



toString
public String toString()(Code)
debug only



unsetThreadNames
protected void unsetThreadNames()(Code)



up
public void up(Event evt)(Code)
handle the UP event.
Parameters:
  evt - - the event being send from the stack



Fields inherited from org.jgroups.stack.UpHandler
final protected Log log(Code)(Java Doc)

Methods inherited from org.jgroups.stack.UpHandler
public void run()(Code)(Java Doc)
public void setObserver(ProtocolObserver observer)(Code)(Java Doc)

Fields inherited from java.lang.Thread
final public static int MAX_PRIORITY(Code)(Java Doc)
final public static int MIN_PRIORITY(Code)(Java Doc)
final public static int NORM_PRIORITY(Code)(Java Doc)

Methods inherited from java.lang.Thread
public static int activeCount()(Code)(Java Doc)
final public void checkAccess()(Code)(Java Doc)
native public int countStackFrames()(Code)(Java Doc)
native public static Thread currentThread()(Code)(Java Doc)
public void destroy()(Code)(Java Doc)
public static void dumpStack()(Code)(Java Doc)
public static int enumerate(Thread tarray)(Code)(Java Doc)
public static Map<Thread, StackTraceElement[]> getAllStackTraces()(Code)(Java Doc)
public ClassLoader getContextClassLoader()(Code)(Java Doc)
public static UncaughtExceptionHandler getDefaultUncaughtExceptionHandler()(Code)(Java Doc)
public long getId()(Code)(Java Doc)
final public String getName()(Code)(Java Doc)
final public int getPriority()(Code)(Java Doc)
public StackTraceElement[] getStackTrace()(Code)(Java Doc)
public State getState()(Code)(Java Doc)
final public ThreadGroup getThreadGroup()(Code)(Java Doc)
public UncaughtExceptionHandler getUncaughtExceptionHandler()(Code)(Java Doc)
native public static boolean holdsLock(Object obj)(Code)(Java Doc)
public void interrupt()(Code)(Java Doc)
public static boolean interrupted()(Code)(Java Doc)
final native public boolean isAlive()(Code)(Java Doc)
final public boolean isDaemon()(Code)(Java Doc)
public boolean isInterrupted()(Code)(Java Doc)
final public synchronized void join(long millis) throws InterruptedException(Code)(Java Doc)
final public synchronized void join(long millis, int nanos) throws InterruptedException(Code)(Java Doc)
final public void join() throws InterruptedException(Code)(Java Doc)
final public void resume()(Code)(Java Doc)
public void run()(Code)(Java Doc)
public void setContextClassLoader(ClassLoader cl)(Code)(Java Doc)
final public void setDaemon(boolean on)(Code)(Java Doc)
public static void setDefaultUncaughtExceptionHandler(UncaughtExceptionHandler eh)(Code)(Java Doc)
final public void setName(String name)(Code)(Java Doc)
final public void setPriority(int newPriority)(Code)(Java Doc)
public void setUncaughtExceptionHandler(UncaughtExceptionHandler eh)(Code)(Java Doc)
native public static void sleep(long millis) throws InterruptedException(Code)(Java Doc)
public static void sleep(long millis, int nanos) throws InterruptedException(Code)(Java Doc)
public synchronized void start()(Code)(Java Doc)
final public void stop()(Code)(Java Doc)
final public synchronized void stop(Throwable obj)(Code)(Java Doc)
final public void suspend()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
native public static void yield()(Code)(Java Doc)

Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.