de.fhg.igd.atlas.core
Class LSClient

java.lang.Object
  extended byde.fhg.igd.semoa.service.AbstractService
      extended byde.fhg.igd.atlas.core.LSClient
All Implemented Interfaces:
AgentFilter, Listener, Runnable, Service

public class LSClient
extends AbstractService
implements Runnable, Listener, AgentFilter

Provides an interface between the SeMoA server and the location service. All important agent events are caught by this Location Service Client (LSClient) to initialize, update or delete the location entries of an existing Location Service Proxy (LSProxy) respectively the corresponding Location Service Server (LSServer). A refresh daemon is installed to refresh these entries periodically after certain time intervals while they are running on the local SeMoA server. Moreover the LSClientService is installed, which is used by this component and can be used by local agents to lookup the current location of other agents.

Version:
"$Id: LSClient.java 1913 2007-08-08 02:41:53Z jpeters $"
Author:
Jan Peters
See Also:
LSClientService

Nested Class Summary
 
Nested classes inherited from class de.fhg.igd.semoa.server.AgentFilter
AgentFilter.In, AgentFilter.Out
 
Field Summary
protected  LSClientServiceImpl clientService_
          The reference to the LSClientService interface.
private static String[] DEPEND_
          The dependencies to other objects in the global Environment.
private static Logger log_
          The Logger instance for this class
static String OPT_DESCR
          The ArgsParser option descriptor for the case that this class is initiated from command line.
protected  long proxyRefreshTime_
          The time interval in milli seconds after that a proxy refresh of all local agent entries is initiated.
protected  Thread refreshThread_
          Thread that provides a periodic refresh of all local agent entries.
protected  long serverRefreshTime_
          The time interval in milli seconds after that a global refresh of all local agent entries is initiated.
 
Fields inherited from class de.fhg.igd.semoa.service.AbstractService
REV_POSTFIX, REV_PREFIX
 
Constructor Summary
protected LSClient()
          Creates an instance of this class and initializes the LSClientService with the given parameters.
 
Method Summary
 String author()
          Returns the String with the author's name.
protected  boolean checkLANLocality(Ticket ticket)
          Checks the LAN locality of the destination URLs of the given ticket.
 String[] dependencies()
          Returns the dependencies of this service as described in Service.
 ErrorCode filter(AgentContext agentContext)
          Called from the information filter, which has to be installed within the incoming agent filter pipeline, whenever a new incomming agent has been detected.
protected  void globalRefreshAllAgents()
          Refreshes the location entries on the LSServer of all agents, which can be found on the local system through localLookupAll.
 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 LSClient from command line.
 void notifiedOf(Object obj)
          This method is called with the event that caused the notification.
protected  void proxyInvalidate(AgentContext ctx)
          Invalidates the proxy location entry for the agent with the given agent context.
protected  void proxyRefreshAllAgents()
          Refreshes the location entries on the LSProxy of all agents which can be found on the local system through localLokupAll.
protected  void register(AgentContext ctx, boolean init)
          Registers this system as new location for the agent with the given agent context.
protected  void registerDelete(AgentContext ctx)
          Deletes the location entry for the agent with the given agent context.
 String revision()
          Returns the revision number of this class as a string.
 void run()
          This method represents the functionality of the refresh daemon.
 
Methods inherited from class de.fhg.igd.semoa.service.AbstractService
checkDependencies, docs, doPrivileged, doPrivileged, getACC, getEnvironment, majorVersion, minorVersion, toString
 
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.


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

clientService_

protected LSClientServiceImpl clientService_
The reference to the LSClientService interface.


proxyRefreshTime_

protected long proxyRefreshTime_
The time interval in milli seconds after that a proxy refresh of all local agent entries is initiated.


serverRefreshTime_

protected long serverRefreshTime_
The time interval in milli seconds after that a global refresh of all local agent entries is initiated.


refreshThread_

protected Thread refreshThread_
Thread that provides a periodic refresh of all local agent entries.

Constructor Detail

LSClient

protected LSClient()
Creates an instance of this class and initializes the LSClientService with the given parameters. Moreover the refresh daemon is started.

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
Specified by:
author in class AbstractService
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.

run

public void run()
This method represents the functionality of the refresh daemon.

Specified by:
run in interface Runnable

notifiedOf

public void notifiedOf(Object obj)
Description copied from interface: Listener
This method is called with the event that caused the notification.

Specified by:
notifiedOf in interface Listener
Parameters:
obj - The object describing the event.

filter

public ErrorCode filter(AgentContext agentContext)
Called from the information filter, which has to be installed within the incoming agent filter pipeline, whenever a new incomming agent has been detected.

Specified by:
filter in interface AgentFilter
Parameters:
agentContext - The agent context of the agent that is to be filtered.
Returns:
OK.

checkLANLocality

protected boolean checkLANLocality(Ticket ticket)
                            throws UnknownHostException
Checks the LAN locality of the destination URLs of the given ticket.

Parameters:
ticket - The ticket.
Returns:
true if every destination URL of the ticket lies in the current subnet; false otherwise.
Throws:
UnknownHostException - if the IP address of one of the ticket's URLs or the local Host could not be resolved.

proxyRefreshAllAgents

protected void proxyRefreshAllAgents()
Refreshes the location entries on the LSProxy of all agents which can be found on the local system through localLokupAll.


globalRefreshAllAgents

protected void globalRefreshAllAgents()
Refreshes the location entries on the LSServer of all agents, which can be found on the local system through localLookupAll.


register

protected void register(AgentContext ctx,
                        boolean init)
Registers this system as new location for the agent with the given agent context. This method considers the different error cases and handles them internally as good as possible. (It's assumed, that there already exists an older location entry for this entry and the agent contains the valid current cookie.)

Parameters:
ctx - The agent context.
init - true if a new entry should be initialized; true for an update request.

registerDelete

protected void registerDelete(AgentContext ctx)
Deletes the location entry for the agent with the given agent context. This method considers the different error cases and handles them internally as good as possible. (It's assumed that there exists a location entry for this agent.)

Parameters:
ctx - The agent context.

proxyInvalidate

protected void proxyInvalidate(AgentContext ctx)
Invalidates the proxy location entry for the agent with the given agent context. This method is called, if an agent migrates to another host outside the local LAN.

Parameters:
ctx - The agent context.

main

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

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


Copyright © Fraunhofer Gesellschaft. All Rights Reserved.