Java Doc for FD_SOCK.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.FD_SOCK

FD_SOCK
public class FD_SOCK extends Protocol implements Runnable(Code)
Failure detection protocol based on sockets. Failure detection is ring-based. Each member creates a server socket and announces its address together with the server socket's address in a multicast. A pinger thread will be started when the membership goes above 1 and will be stopped when it drops below 2. The pinger thread connects to its neighbor on the right and waits until the socket is closed. When the socket is closed by the monitored peer in an abnormal fashion (IOException), the neighbor will be suspected.

The main feature of this protocol is that no ping messages need to be exchanged between any 2 peers, and failure detection relies entirely on TCP sockets. The advantage is that no activity will take place between 2 peers as long as they are alive (i.e. have their server sockets open). The disadvantage is that hung servers or crashed routers will not cause sockets to be closed, therefore they won't be detected. The FD_SOCK protocol will work for groups where members are on different hosts

The costs involved are 2 additional threads: one that monitors the client side of the socket connection (to monitor a peer) and another one that manages the server socket. However, those threads will be idle as long as both peers are running.
author:
   Bela Ban May 29 2001


Inner Class :public static class FdHeader extends Header implements Streamable

Field Summary
 InetAddressbind_addr
    
final  Hashtablecache
    
final  Promiseget_cache_promise
    
final static  longget_cache_retry_timeout
    
 longget_cache_timeout
    
 booleangot_cache_from_coord
    
 Stringgroup_name
    
 Addresslocal_addr
    
final  Vectormembers
    
 intnum_suspect_events
    
 intnum_tries
    
final  Promiseping_addr_promise
    
 Addressping_dest
    
 InputStreamping_input
    
 Socketping_sock
    
final  Vectorpingable_mbrs
    
final  Objectpinger_mutex
    
 Threadpinger_thread
    
 booleanregular_sock_close
    
final  Objectsock_mutex
    
 ServerSocketsrv_sock
    
 IpAddresssrv_sock_addr
    
 InetAddresssrv_sock_bind_addr
    
 booleansrv_sock_sent
    
 intstart_port
     Start port for server socket (uses first available port starting at start_port).
 BoundedListsuspect_history
    
 longsuspect_msg_interval
    
 TimeSchedulertimer
    


Method Summary
 voidbroadcastSuspectMessage(Address suspected_mbr)
     Sends a SUSPECT message to all group members.
 voidbroadcastWhoHasSockMessage(Address mbr)
    
 AddressdetermineCoordinator()
    
 AddressdeterminePingDest()
    
public  voiddown(Event evt)
    
 voidgetCacheFromCoordinator()
     Determines coordinator C.
public  StringgetLocalAddress()
    
public  StringgetMembers()
    
public  StringgetName()
    
public  intgetNumSuspectEventsGenerated()
    
public  StringgetPingDest()
    
public  StringgetPingableMembers()
    
 voidhandleSocketClose(Exception ex)
    
public  voidinit()
    
 voidinterruptPingerThread()
     Interrupts the pinger thread.
public  StringprintSuspectHistory()
    
public  voidresetStats()
    
public  voidrun()
     Runs as long as there are 2 members and more.
 voidsendIHaveSockMessage(Address dst, Address mbr, IpAddress addr)
     Sends or broadcasts a I_HAVE_SOCK response.
 voidsendPingInterrupt()
    
synchronized  voidsendPingSignal(int signal)
    
synchronized  voidsendPingTermination()
    
public  booleansetProperties(Properties props)
    
 booleansetupPingSocket(IpAddress dest)
     Creates a socket to dest, and assigns it to ping_sock.
static  StringsignalToString(int signal)
    
public  voidstart()
    
 voidstartPingerThread()
    
 voidstartServerSocket()
    
public  voidstop()
    
 voidstopPingerThread()
    
 voidstopServerSocket()
    
 voidteardownPingSocket()
    
public  voidup(Event evt)
    

Field Detail
bind_addr
InetAddress bind_addr(Code)



cache
final Hashtable cache(Code)



get_cache_promise
final Promise get_cache_promise(Code)



get_cache_retry_timeout
final static long get_cache_retry_timeout(Code)



get_cache_timeout
long get_cache_timeout(Code)



got_cache_from_coord
boolean got_cache_from_coord(Code)



group_name
String group_name(Code)



local_addr
Address local_addr(Code)



members
final Vector members(Code)



num_suspect_events
int num_suspect_events(Code)



num_tries
int num_tries(Code)



ping_addr_promise
final Promise ping_addr_promise(Code)



ping_dest
Address ping_dest(Code)



ping_input
InputStream ping_input(Code)



ping_sock
Socket ping_sock(Code)



pingable_mbrs
final Vector pingable_mbrs(Code)



pinger_mutex
final Object pinger_mutex(Code)



pinger_thread
Thread pinger_thread(Code)



regular_sock_close
boolean regular_sock_close(Code)



sock_mutex
final Object sock_mutex(Code)



srv_sock
ServerSocket srv_sock(Code)



srv_sock_addr
IpAddress srv_sock_addr(Code)



srv_sock_bind_addr
InetAddress srv_sock_bind_addr(Code)
bind_addr



srv_sock_sent
boolean srv_sock_sent(Code)



start_port
int start_port(Code)
Start port for server socket (uses first available port starting at start_port). A value of 0 (default) picks a random port



suspect_history
BoundedList suspect_history(Code)



suspect_msg_interval
long suspect_msg_interval(Code)



timer
TimeScheduler timer(Code)





Method Detail
broadcastSuspectMessage
void broadcastSuspectMessage(Address suspected_mbr)(Code)
Sends a SUSPECT message to all group members. Only the coordinator (or the next member in line if the coord itself is suspected) will react to this message by installing a new view. To overcome the unreliability of the SUSPECT message (it may be lost because we are not above any retransmission layer), the following scheme is used: after sending the SUSPECT message, it is also added to the broadcast task, which will periodically re-send the SUSPECT until a view is received in which the suspected process is not a member anymore. The reason is that - at one point - either the coordinator or another participant taking over for a crashed coordinator, will react to the SUSPECT message and issue a new view, at which point the broadcast task stops.



broadcastWhoHasSockMessage
void broadcastWhoHasSockMessage(Address mbr)(Code)



determineCoordinator
Address determineCoordinator()(Code)



determinePingDest
Address determinePingDest()(Code)



down
public void down(Event evt)(Code)



getCacheFromCoordinator
void getCacheFromCoordinator()(Code)
Determines coordinator C. If C is null and we are the first member, return. Else loop: send GET_CACHE message to coordinator and wait for GET_CACHE_RSP response. Loop until valid response has been received.



getLocalAddress
public String getLocalAddress()(Code)



getMembers
public String getMembers()(Code)



getName
public String getName()(Code)



getNumSuspectEventsGenerated
public int getNumSuspectEventsGenerated()(Code)



getPingDest
public String getPingDest()(Code)



getPingableMembers
public String getPingableMembers()(Code)



handleSocketClose
void handleSocketClose(Exception ex)(Code)



init
public void init() throws Exception(Code)



interruptPingerThread
void interruptPingerThread()(Code)
Interrupts the pinger thread. The Thread.interrupt() method doesn't seem to work under Linux with JDK 1.3.1 (JDK 1.2.2 had no problems here), therefore we close the socket (setSoLinger has to be set !) if we are running under Linux. This should be tested under Windows. (Solaris 8 and JDK 1.3.1 definitely works).

Oct 29 2001 (bela): completely removed Thread.interrupt(), but used socket close on all OSs. This makes this code portable and we don't have to check for OSs.

Does *not* need to be synchronized on pinger_mutex because the caller (down()) already has the mutex acquired
See Also:   org.jgroups.tests.InterruptTest
See Also:    to determine whether Thread.interrupt() works for InputStream.read().




printSuspectHistory
public String printSuspectHistory()(Code)



resetStats
public void resetStats()(Code)



run
public void run()(Code)
Runs as long as there are 2 members and more. Determines the member to be monitored and fetches its server socket address (if n/a, sends a message to obtain it). The creates a client socket and listens on it until the connection breaks. If it breaks, emits a SUSPECT message. It the connection is closed regularly, nothing happens. In both cases, a new member to be monitored will be chosen and monitoring continues (unless there are fewer than 2 members).



sendIHaveSockMessage
void sendIHaveSockMessage(Address dst, Address mbr, IpAddress addr)(Code)
Sends or broadcasts a I_HAVE_SOCK response. If 'dst' is null, the reponse will be broadcast, otherwise it will be unicast back to the requester



sendPingInterrupt
void sendPingInterrupt()(Code)



sendPingSignal
synchronized void sendPingSignal(int signal)(Code)



sendPingTermination
synchronized void sendPingTermination()(Code)



setProperties
public boolean setProperties(Properties props)(Code)



setupPingSocket
boolean setupPingSocket(IpAddress dest)(Code)
Creates a socket to dest, and assigns it to ping_sock. Also assigns ping_input



signalToString
static String signalToString(int signal)(Code)



start
public void start() throws Exception(Code)



startPingerThread
void startPingerThread()(Code)
Does *not* need to be synchronized on pinger_mutex because the caller (down()) already has the mutex acquired



startServerSocket
void startServerSocket()(Code)



stop
public void stop()(Code)



stopPingerThread
void stopPingerThread()(Code)



stopServerSocket
void stopServerSocket()(Code)



teardownPingSocket
void teardownPingSocket()(Code)



up
public void up(Event evt)(Code)



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.