Java Doc for Link.java in  » Net » JGroups-2.4.1-sp3 » org » jgroups » blocks » 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.blocks 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.jgroups.blocks.Link

All known Subclasses:   org.jgroups.blocks.LogicalLink,
Link
public class Link implements Runnable(Code)
Implements a physical link between 2 parties (point-to-point connection). For incoming traffic, a server socket is created (bound to a given local address and port). The receiver thread does the following: it accepts a new connection from the server socket and (on the same thread) reads messages until the connection breaks. Then it goes back to accept(). This is done in 2 nested while-loops. The outgoing connection is established when started. If this fails, the link is marked as not established. This means that there is not outgoing socket.
A heartbeat will be exchanged between the 2 peers periodically as long as the connection is established (outgoing socket is okay). When the connection breaks, the heartbeat will stop and a connection establisher thread will be started. It periodically tries to re-establish connection to the peer. When this happens it will stop and the heartbeat thread will resume.
For details see Link.txt
author:
   Bela Ban, June 2000

Inner Class :public interface Receiver
Inner Class :class Heartbeat implements Runnable

Field Summary
final static  intHB_PACKET
    
 booleanestablished
    
 Heartbeathb
    
 longhb_interval
    
 Socketincoming
    
 DataInputStreaminstream
    
 Stringlocal_addrremote_addr
    
 intlocal_portremote_port
    
 InetAddresslocalremote
    
 Loglog
    
 Socketoutgoing
    
final  Objectoutgoing_mutex
    
 DataOutputStreamoutstream
    
 Receiverreceiver
    
 Threadreceiver_thread
    
final  longreceiver_thread_join_timeout
    
 ServerSocketsrv_sock
    
 booleanstop
    
 longtimeout
    
 booleantrace
    
 TimedWriterwriter
    

Constructor Summary
public  Link(String local_addr, int local_port, String remote_addr, int remote_port)
    
public  Link(String local_addr, int local_port, String remote_addr, int remote_port, Receiver r)
    
public  Link(String local_addr, int local_port, String remote_addr, int remote_port, long timeout, long hb_interval, Receiver r)
    

Method Summary
synchronized  voidcloseConnections()
     Close outgoing and incoming sockets.
synchronized  voidcloseIncomingConnection()
     When the heartbeat thread detects that the peer 'hangs' (not detected by incoming.read()), then it closes the outgoing *and* incoming socket.
 voidcloseOutgoingConnection()
    
 booleancreateOutgoingConnection()
     Tries to create an outgoing connection.
 booleancreateOutgoingConnection(long timeout)
     Tries to create an outgoing connection.
public  booleanequals(Object other)
    
public  booleanestablished()
    
public  InetAddressgetLocalAddress()
    
public  intgetLocalPort()
    
public  InetAddressgetRemoteAddress()
    
public  intgetRemotePort()
    
public  inthashCode()
    
public static  voidmain(String[] args)
    
 StringprintSocket(Socket s)
    
 booleanretry(byte[] buf)
    
public  voidrun()
     Receiver thread main loop.
public  booleansend(byte[] buf)
     Tries to send buffer across out socket.
public  voidsetReceiver(Receiver r)
    
public  voidsetTrace(boolean t)
    
public  voidstart()
    
 voidstartReceiverThread()
    
public  voidstop()
    
 voidstopReceiverThread()
    
public  StringtoString()
    

Field Detail
HB_PACKET
final static int HB_PACKET(Code)



established
boolean established(Code)



hb
Heartbeat hb(Code)



hb_interval
long hb_interval(Code)



incoming
Socket incoming(Code)



instream
DataInputStream instream(Code)



local_addrremote_addr
String local_addrremote_addr(Code)



local_portremote_port
int local_portremote_port(Code)



localremote
InetAddress localremote(Code)



log
Log log(Code)



outgoing
Socket outgoing(Code)



outgoing_mutex
final Object outgoing_mutex(Code)



outstream
DataOutputStream outstream(Code)



receiver
Receiver receiver(Code)



receiver_thread
Thread receiver_thread(Code)



receiver_thread_join_timeout
final long receiver_thread_join_timeout(Code)



srv_sock
ServerSocket srv_sock(Code)



stop
boolean stop(Code)



timeout
long timeout(Code)



trace
boolean trace(Code)



writer
TimedWriter writer(Code)




Constructor Detail
Link
public Link(String local_addr, int local_port, String remote_addr, int remote_port)(Code)



Link
public Link(String local_addr, int local_port, String remote_addr, int remote_port, Receiver r)(Code)



Link
public Link(String local_addr, int local_port, String remote_addr, int remote_port, long timeout, long hb_interval, Receiver r)(Code)




Method Detail
closeConnections
synchronized void closeConnections()(Code)
Close outgoing and incoming sockets.



closeIncomingConnection
synchronized void closeIncomingConnection()(Code)
When the heartbeat thread detects that the peer 'hangs' (not detected by incoming.read()), then it closes the outgoing *and* incoming socket. The latter needs to be done, so that we can return to accept() and await a new client connection request.



closeOutgoingConnection
void closeOutgoingConnection()(Code)
Closes the outgoing connection



createOutgoingConnection
boolean createOutgoingConnection()(Code)
Tries to create an outgoing connection. If successful, the heartbeat is started. Does not stop the connection establisher ! The reason is that this method is going to be called by the connection establisher as well, therefore it would kill itself !



createOutgoingConnection
boolean createOutgoingConnection(long timeout)(Code)
Tries to create an outgoing connection. If successful, the heartbeat is started. Does not stop the connection establisher ! The reason is that this method is going to be called by the connection establisher as well, therefore it would kill itself !



equals
public boolean equals(Object other)(Code)



established
public boolean established()(Code)



getLocalAddress
public InetAddress getLocalAddress()(Code)



getLocalPort
public int getLocalPort()(Code)



getRemoteAddress
public InetAddress getRemoteAddress()(Code)



getRemotePort
public int getRemotePort()(Code)



hashCode
public int hashCode()(Code)



main
public static void main(String[] args)(Code)



printSocket
String printSocket(Socket s)(Code)



retry
boolean retry(byte[] buf)(Code)



run
public void run()(Code)
Receiver thread main loop. Accept a connection and then read on it until the connection breaks. Only then is the next connection handled. The reason is that there is only supposed to be 1 connection to this server socket at the same time.



send
public boolean send(byte[] buf)(Code)
Tries to send buffer across out socket. Tries to establish connection if not yet connected.



setReceiver
public void setReceiver(Receiver r)(Code)



setTrace
public void setTrace(boolean t)(Code)



start
public void start() throws Exception(Code)



startReceiverThread
void startReceiverThread()(Code)



stop
public void stop()(Code)



stopReceiverThread
void stopReceiverThread()(Code)



toString
public String toString()(Code)



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.