de.fhg.igd.atlas.core
Class LSProxy

java.lang.Object
  extended byde.fhg.igd.semoa.service.AbstractService
      extended byde.fhg.igd.semoa.net.AbstractServer
          extended byde.fhg.igd.atlas.core.LSProxy
All Implemented Interfaces:
Runnable, Server, Service

public class LSProxy
extends AbstractServer

Provides a proxy server that will be used as gateway to Location Service Servers (LSServer) by Location Service Clients (LSClient) in the local LAN if existent. This Location Service Proxy (LSProxy) can be installed as potential proxy to improve the lookup speed and the fault tolerance in case of network breakdowns. The active proxy will be elected automatically among all existent potential proxys in the common LAN.

Following request are accepted as LSP messages from the local LAN:

Version:
"$Id: LSProxy.java 1913 2007-08-08 02:41:53Z jpeters $"
Author:
Jan Peters
See Also:
LSProxyService, ProxyInfo

Nested Class Summary
 
Nested classes inherited from class de.fhg.igd.semoa.net.AbstractServer
AbstractServer.Job
 
Field Summary
private static String[] DEPEND_
          The dependencies to other objects in the global Environment.
private static Logger log_
          The Logger instance for this class
static int MAX_CAPACITY
          The maximum capacity of this server.
static String OPT_DESCR
          The ArgsParser option descriptor for the case that this class is initiated from command line.
static String PROTOCOL
          The string identifier of the protocol spoken by this server.
protected  ProxyInfo proxyInfo_
          The reference to an instance of , which is used to publish this component as electable LSProxy,
protected  LSProxyServiceImpl proxyService_
          The reference to the LSProxyService interface.
static long STORAGE_DB_TIMEOUT
          Timeout for entries of the internal storage database in milli seconds.
 
Fields inherited from class de.fhg.igd.semoa.net.AbstractServer
bad_, DEFAULT_CAPACITY, good_, thread_
 
Fields inherited from class de.fhg.igd.semoa.service.AbstractService
REV_POSTFIX, REV_PREFIX
 
Fields inherited from interface de.fhg.igd.semoa.net.Server
BOUND_TO_PORT, ERROR, RUNNING, SHUTDOWN, UNDEFINED
 
Constructor Summary
protected LSProxy(StorageDB storageDB, boolean verifyContactAddress)
          Creates an instance of this class and initializes the LSProxyService with the given parameters.
 
Method Summary
 String author()
          Returns the String with the author's name.
protected  boolean checkHostLocality()
          Checks if another LSProxy already runs on the same host with the initialized port.
protected  boolean checkLANLocality(Socket connection)
          Checks the LAN locality of the source of the given connection.
 String[] dependencies()
          Returns the dependencies of this service as described in Service.
protected  void handleConnection(Socket connection)
          Handles the given connection according to a simple request/response scheme.
protected  LSPReply handleRequest(LSPRequest request)
          Handles the given request and returns a corresponding reply.
 String info()
          Returns the String with the service's short description.
protected  boolean initLSInfrastructure(String configFile)
          Initialize the location service infrastructure of distributed LS-Servers by parsing the given configuration file.
protected  boolean initLSInfrastructure(URL configLdapServer)
          Initialize the location service infrastructure of distributed LS-Servers by requesting the configuration from a LDAP server with the given URL.
static void main(String[] argv)
          Initializes the LSProxy from command line.
 String protocol()
           
 String revision()
          Returns the revision number of this class as a string.
protected  void serverStateChanged(int state)
          Implementation of the server state hook, which is called by the servers run method.
 
Methods inherited from class de.fhg.igd.semoa.net.AbstractServer
bad, createJob, createServerSocket, exceptionInfo, getCapacity, getMaximumSize, getPort, getServerState, good, isEnabled, localURL, rebind, run, setCapacity, setEnabled, setMaximumSize, setPort, shutdown, signal, toString
 
Methods inherited from class de.fhg.igd.semoa.service.AbstractService
checkDependencies, docs, doPrivileged, doPrivileged, getACC, getEnvironment, majorVersion, minorVersion
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

log_

private static Logger log_
The Logger instance for this class


DEPEND_

private static final String[] DEPEND_
The dependencies to other objects in the global Environment.


PROTOCOL

public static final String PROTOCOL
The string identifier of the protocol spoken by this server.

See Also:
Constant Field Values

MAX_CAPACITY

public static final int MAX_CAPACITY
The maximum capacity of this server.

See Also:
Constant Field Values

STORAGE_DB_TIMEOUT

public static long STORAGE_DB_TIMEOUT
Timeout for entries of the internal storage database in milli seconds.


OPT_DESCR

public static final String OPT_DESCR
The ArgsParser option descriptor for the case that this class is initiated from command line.

See Also:
Constant Field Values

proxyService_

protected LSProxyServiceImpl proxyService_
The reference to the LSProxyService interface.


proxyInfo_

protected ProxyInfo proxyInfo_
The reference to an instance of , which is used to publish this component as electable LSProxy,

Constructor Detail

LSProxy

protected LSProxy(StorageDB storageDB,
                  boolean verifyContactAddress)
Creates an instance of this class and initializes the LSProxyService with the given parameters. If storageDB is null, the MemoryDB is used as default database for the server. If filename is null, no server will be initialized.

Parameters:
storageDB - The storage database to use as part of the LSServer.
verifyContactAddress - If this flag is set, contact addresses to register are verified first (see LSProxyServiceImpl).
Method Detail

initLSInfrastructure

protected boolean initLSInfrastructure(String configFile)
Initialize the location service infrastructure of distributed LS-Servers by parsing the given configuration file. If configFile is null, no server will be initialized.

Parameters:
configFile - The name the configuration file containing the configuration of the location service infrastructure.
Returns:
true, if the given configuration file has been parsed successfully, false otherwise.

initLSInfrastructure

protected boolean initLSInfrastructure(URL configLdapServer)
Initialize the location service infrastructure of distributed LS-Servers by requesting the configuration from a LDAP server with the given URL. If configLdapServer is null, no server will be initialized.

Parameters:
configLdapServer - The URL of the ldap server maintaining the configuration of the location service infrastructure.
Returns:
true, if the configuration has been received successfully from the given LDAP server, false otherwise.

info

public String info()
Returns the String with the service's short description.

Specified by:
info in interface Service
Specified by:
info in class AbstractService
Returns:
The String with the service's short description.

author

public String author()
Returns the String with the author's name.

Specified by:
author in interface Service
Overrides:
author in class AbstractServer
Returns:
The String with the author's name.

revision

public String revision()
Returns the revision number of this class as a string.

Specified by:
revision in class AbstractService
Returns:
The revision number of this class as a string.

dependencies

public String[] dependencies()
Returns the dependencies of this service as described in Service.

Specified by:
dependencies in interface Service
Overrides:
dependencies in class AbstractService
Returns:
The array of dependencies.

protocol

public String protocol()
Specified by:
protocol in interface Server
Specified by:
protocol in class AbstractServer
Returns:
The string identifier of the protocol spoken by this server.

serverStateChanged

protected void serverStateChanged(int state)
Implementation of the server state hook, which is called by the servers run method. According to the current server state, the status of the local proxy is updated for the Vicinity election.

Overrides:
serverStateChanged in class AbstractServer

handleConnection

protected void handleConnection(Socket connection)
Handles the given connection according to a simple request/response scheme. This method is called if the server has accepted a new connection. In addition to the regular replies of corresponding requests, replies with the following states can be returned to sender in case of an error, which has been occured during request decoding:

Overrides:
handleConnection in class AbstractServer
Parameters:
connection - The socket connection that must be handled by this method.

checkHostLocality

protected boolean checkHostLocality()
Checks if another LSProxy already runs on the same host with the initialized port.

Returns:
true iff another LSProxy server is running locally, false otherwise.

checkLANLocality

protected boolean checkLANLocality(Socket connection)
Checks the LAN locality of the source of the given connection.

Returns:
true if the source of the connection lies in the current subnet; false otherwise.

handleRequest

protected LSPReply handleRequest(LSPRequest request)
Handles the given request and returns a corresponding reply. Following requests are allowed:

Parameters:
request - The request to be handled.
Returns:
The reply to the given request.

main

public static void main(String[] argv)
                 throws ArgsParserException,
                        ObjectExistsException
Initializes the LSProxy from command line.

Parameters:
argv - The command line parameters.
Throws:
ArgsParserException
ObjectExistsException


Copyright © Fraunhofer Gesellschaft. All Rights Reserved.