org.jlab.coda.afecs.platform
Class APlatformRegistrar

java.lang.Object
  extended by org.jlab.coda.afecs.platform.APlatformRegistrar

public class APlatformRegistrar
extends java.lang.Object

JSA: Thomas Jefferson National Accelerator Facility
This software was developed under a United States Government license,
described in the NOTICE file included as part of this distribution.
Copyright (c), Aug 13, 2009

This is the class, resposible for creating and maintaining physical client registration information AClientInfo database, as well as maintaining sessions ASessionInfo database including runnumbers for each session. Information will be stored and retrieved from the xml files. (database option is not supported for this version).


Constructor Summary
APlatformRegistrar()
          Constructor
 
Method Summary
 void addAgent(AComponent a)
          Adds an agent to the agents hashmap
 void addClient(AClientInfo a)
          Adds new agent to the hashmap
 int addConfigId(java.lang.String confName)
           
 void addSession(ASessionInfo a)
          Adds the new session to the sessions registration hashmap
 boolean dumpAgentsDatabase()
          Dumps the content of the agents hash map to the disk in the form of xml file.
 boolean dumpClientDatabase()
          Dumps the content of the hashmap of the registered agents to the disk as an xml file.
 boolean dumpRunTypeDatabase()
           
 boolean dumpSessionsDatabase()
          Dumps the content of the sessions hash map to the disk in the form of xml file.
 AComponent getAgent(java.lang.String n)
          gets the specific agent information form the hashmap
 java.util.concurrent.ConcurrentHashMap<java.lang.String,AComponent> getAgentDir()
          gets the hshmap of registered agents
 AClientInfo getClient(java.lang.String n)
          Gets the specified client from the clients hashmap
 java.util.concurrent.ConcurrentHashMap<java.lang.String,AClientInfo> getClientDir()
          Gets the hashmap of all regiostered physical clients
 int getConfigId(java.lang.String confName)
           
 java.util.SortedSet<java.lang.String> getContainerAdmins()
          Goes over the agents database and extracts the agent host names (where agents are physically running).
 int[] getRunNumbers(java.lang.String session)
           
 ASessionInfo getSession(java.lang.String n)
          Gets the specified session from the sessions hashmap
 java.util.concurrent.ConcurrentHashMap<java.lang.String,ASessionInfo> getSessionDir()
          gets the stored hashmap of all registered sessions of the control
 java.util.ArrayList<java.lang.String> getSessionNames()
           
 int getSessionRunNumber(java.lang.String s)
          Returns the run number of the specified session
 int incrementDbRunnumber(java.lang.String session)
           
 int incrementSessionRunNumber(java.lang.String s)
          Retrives the run number for the specified session from the registered sessions hashmap, increments it and puts it back.
 boolean readClientDatabase()
          Reads the AFECS_HOME/db/clientRegistration.xml file and fills the internal hashmap of the registered physical clients.
 boolean readRunTypeDatabase()
           
 boolean readSessionDatabase()
          Parses AFECS_HOME/db/conmtrolSessions.xml file and creats sessions registrastion internal hashmap.
 void removeAgent(java.lang.String n)
          Removes agent from the agents hashmap
 void removeClient(java.lang.String a)
          Removes agent from the hashmap
 void removeSession(java.lang.String a)
          Removes the session from the registered sessions hashmap
 void setAgentDir(java.util.concurrent.ConcurrentHashMap<java.lang.String,AComponent> agentDir)
          Sets entire agent registration map
 int setDBRunNumber(int rn, java.lang.String session)
           
 int setSessionRunNumber(java.lang.String s, int r)
          Set the run number for the specified session
 void updateSessionRunType(java.lang.String session, java.lang.String runtype)
          Update the config name for the session
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

APlatformRegistrar

public APlatformRegistrar()
Constructor

Method Detail

getClientDir

public java.util.concurrent.ConcurrentHashMap<java.lang.String,AClientInfo> getClientDir()
Gets the hashmap of all regiostered physical clients

Returns:
hashmap (key = client name, value = AClientInfo object)

getClient

public AClientInfo getClient(java.lang.String n)
Gets the specified client from the clients hashmap

Parameters:
n - the name of the client
Returns:
AClientInfo object

addClient

public void addClient(AClientInfo a)
Adds new agent to the hashmap

Parameters:
a - AClientInfo object

removeClient

public void removeClient(java.lang.String a)
Removes agent from the hashmap

Parameters:
a - the name of the agent

dumpClientDatabase

public boolean dumpClientDatabase()
Dumps the content of the hashmap of the registered agents to the disk as an xml file. The file will be stored in AFECS_HOME/db/clientRegistration.xml file

Returns:
status of the operation

readClientDatabase

public boolean readClientDatabase()
Reads the AFECS_HOME/db/clientRegistration.xml file and fills the internal hashmap of the registered physical clients.

Returns:
status of the operation

getSessionDir

public java.util.concurrent.ConcurrentHashMap<java.lang.String,ASessionInfo> getSessionDir()
gets the stored hashmap of all registered sessions of the control

Returns:
hashmap (key = session name, value = ASessionInfo object)

getSession

public ASessionInfo getSession(java.lang.String n)
Gets the specified session from the sessions hashmap

Parameters:
n - the name of the session
Returns:
AssesionInfo object

addSession

public void addSession(ASessionInfo a)
Adds the new session to the sessions registration hashmap

Parameters:
a - ASessionInfo object

removeSession

public void removeSession(java.lang.String a)
Removes the session from the registered sessions hashmap

Parameters:
a - the name of the session

setSessionRunNumber

public int setSessionRunNumber(java.lang.String s,
                               int r)
Set the run number for the specified session

Parameters:
s - the name of the session
r - run number
Returns:
-1 if unsuccessful and 0 if successful

incrementSessionRunNumber

public int incrementSessionRunNumber(java.lang.String s)
Retrives the run number for the specified session from the registered sessions hashmap, increments it and puts it back.

Parameters:
s - the name of the session
Returns:
rn run number or -1 if failed

updateSessionRunType

public void updateSessionRunType(java.lang.String session,
                                 java.lang.String runtype)
Update the config name for the session

Parameters:
session - the name of the session
runtype - the name of the new config

getSessionRunNumber

public int getSessionRunNumber(java.lang.String s)
Returns the run number of the specified session

Parameters:
s - the name of the session
Returns:
run number

dumpSessionsDatabase

public boolean dumpSessionsDatabase()
Dumps the content of the sessions hash map to the disk in the form of xml file. The content will be stored in the AFECS_HOME/db/controlSessions.xml file

Returns:
status of the operation

readSessionDatabase

public boolean readSessionDatabase()
Parses AFECS_HOME/db/conmtrolSessions.xml file and creats sessions registrastion internal hashmap.

Returns:
status of the operation

dumpRunTypeDatabase

public boolean dumpRunTypeDatabase()

readRunTypeDatabase

public boolean readRunTypeDatabase()

getConfigId

public int getConfigId(java.lang.String confName)

addConfigId

public int addConfigId(java.lang.String confName)

getSessionNames

public java.util.ArrayList<java.lang.String> getSessionNames()
Returns:
the names of all registered sessions

getAgentDir

public java.util.concurrent.ConcurrentHashMap<java.lang.String,AComponent> getAgentDir()
gets the hshmap of registered agents

Returns:
hashmap of AComponent objects

setAgentDir

public void setAgentDir(java.util.concurrent.ConcurrentHashMap<java.lang.String,AComponent> agentDir)
Sets entire agent registration map

Parameters:
agentDir - hashmap (key = name of the agent, value = AComponent objects)

getAgent

public AComponent getAgent(java.lang.String n)
gets the specific agent information form the hashmap

Parameters:
n - the name of the agent
Returns:
AComponent object

addAgent

public void addAgent(AComponent a)
Adds an agent to the agents hashmap

Parameters:
a - AComponent object

removeAgent

public void removeAgent(java.lang.String n)
Removes agent from the agents hashmap

Parameters:
n - the name of the agent

dumpAgentsDatabase

public boolean dumpAgentsDatabase()
Dumps the content of the agents hash map to the disk in the form of xml file. The content will be stored in the AFECS_HOME/db/controlAgents.xml file. N.B. This class will not recreate Agents hashmap parsing back created xml file. Agent data base will be created/updated only by the registration request of the agents.

Returns:
status of the operation

getContainerAdmins

public java.util.SortedSet<java.lang.String> getContainerAdmins()
Goes over the agents database and extracts the agent host names (where agents are physically running).

Returns:
Filles and retunrs set of the host_admin ( the name of the container administrator agent).

setDBRunNumber

public int setDBRunNumber(int rn,
                          java.lang.String session)

incrementDbRunnumber

public int incrementDbRunnumber(java.lang.String session)

getRunNumbers

public int[] getRunNumbers(java.lang.String session)