dist1.acb.CBL
Class ControlSocket

java.lang.Object
  extended byjava.lang.Thread
      extended bydist1.acb.common.transport.AbstractConnectionServer
          extended bydist1.acb.CBL.ControlSocket
All Implemented Interfaces:
java.lang.Runnable

public class ControlSocket
extends AbstractConnectionServer

ControlSocket - responsible for exchange control information such a Environment condition between CBLs.

Version:
$Revision: 1.28 $
Author:
Alexander Stasiv

Nested Class Summary
 class ControlSocket.ClientManager
          Client manager
 
Field Summary
 
Fields inherited from class dist1.acb.common.transport.AbstractConnectionServer
log, socketPort
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Method Summary
static boolean checkLinkTo(java.lang.String host, int port)
          Checks link to a CBL server.
static boolean checkLinkToImmortalPoint()
          Checks link to the 'immortal point'
protected  AbstractPersonalManager createPersonalManager(java.net.Socket s, java.lang.ThreadGroup group)
          Concrete creating a PersonalManager
static ResponseEnvironment getEnvironment(java.util.LinkedList srvList)
          Returns current condition of the enviroment from an alive CBL
static ControlSocket getInstance()
          Returns only one instance of the class
static java.net.InetSocketAddress getPrimary()
          Getter for property primary.
protected  void handleUnrecoverableError(java.lang.Throwable e)
           
static boolean isItI(java.net.InetSocketAddress addr)
          Checks if the provided address is our address
static boolean isItI(java.lang.String extendedHostName, int port)
          Checks if the provided address is our address
static boolean requestForHotJoin(CBL cbl)
          Tries to connect to the CBL and to send RequestForHostJoin
static void setPrimary(java.net.InetSocketAddress aprimary)
          Setter for property primary.
 void start()
           Initiate some objects and if succeed, causes this thread to begin execution; the Java Virtual Machine calls the run method of this thread.
 
Methods inherited from class dist1.acb.common.transport.AbstractConnectionServer
run
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getEnvironment

public static ResponseEnvironment getEnvironment(java.util.LinkedList srvList)
                                          throws java.lang.RuntimeException
Returns current condition of the enviroment from an alive CBL

Parameters:
srvList - Possible alive CBLs
Returns:
The environment
Throws:
java.lang.RuntimeException - if something wrong

getInstance

public static ControlSocket getInstance()
Returns only one instance of the class

Returns:
The only one instance

isItI

public static boolean isItI(java.lang.String extendedHostName,
                            int port)
                     throws java.net.UnknownHostException
Checks if the provided address is our address

Parameters:
extendedHostName - A host
port - A port
Returns:
true, if the address is our
Throws:
java.net.UnknownHostException - if our address was not resolved

isItI

public static boolean isItI(java.net.InetSocketAddress addr)
                     throws java.net.UnknownHostException
Checks if the provided address is our address

Parameters:
addr - An address
Returns:
true, if the address is our
Throws:
java.net.UnknownHostException - if our address was not resolved

setPrimary

public static void setPrimary(java.net.InetSocketAddress aprimary)
Setter for property primary.

Parameters:
aprimary - New value of property primary.

getPrimary

public static java.net.InetSocketAddress getPrimary()
Getter for property primary.

Returns:
Value of property primary.

checkLinkTo

public static boolean checkLinkTo(java.lang.String host,
                                  int port)
Checks link to a CBL server. If (host, port) is our address returns false.

Parameters:
host - Destination host
port - Destination port
Returns:
true if the link is ok, false otherwise

checkLinkToImmortalPoint

public static boolean checkLinkToImmortalPoint()
Checks link to the 'immortal point'

Returns:
true if the link is ok, false otherwise

requestForHotJoin

public static boolean requestForHotJoin(CBL cbl)
                                 throws java.lang.RuntimeException,
                                        java.lang.ClassNotFoundException,
                                        java.lang.InterruptedException
Tries to connect to the CBL and to send RequestForHostJoin

Parameters:
cbl - The CBL
Returns:
true if the CBL is Primary with runed Hot Join Protocol and we can join it
Throws:
java.lang.RuntimeException - if we must stop attemps for the Hot Join
java.lang.ClassNotFoundException - if the current class was not found
java.lang.InterruptedException - Current thread was interrupted

start

public void start()
 Initiate some objects and if succeed, causes this thread to begin execution; the Java Virtual Machine calls the run method of this thread.


createPersonalManager

protected AbstractPersonalManager createPersonalManager(java.net.Socket s,
                                                        java.lang.ThreadGroup group)
Concrete creating a PersonalManager

Specified by:
createPersonalManager in class AbstractConnectionServer
Parameters:
s - A socket with connected client
group - Thread group to which current thread will be related
Returns:
New object ClientManager

handleUnrecoverableError

protected void handleUnrecoverableError(java.lang.Throwable e)
Specified by:
handleUnrecoverableError in class AbstractConnectionServer


Copyright © 2004 Phoenix Team (CMU/AIT). All Rights Reserved.