edu.isi.pegasus.planner.catalog.site.classes
Class SiteStore

java.lang.Object
  extended by edu.isi.pegasus.planner.catalog.site.classes.SiteData
      extended by edu.isi.pegasus.planner.catalog.site.classes.AbstractSiteData
          extended by edu.isi.pegasus.planner.catalog.site.classes.SiteStore
All Implemented Interfaces:
Cloneable

public class SiteStore
extends AbstractSiteData

The site store contains the collection of sites backed by a HashMap.

Version:
$Revision: 4915 $
Author:
Karan Vahi, Mats Rynge

Field Summary
protected  boolean mDeepStorageStructure
          A boolean indicating whether to have a deep directory structure for the storage directory or not.
private  PlannerOptions mPlannerOptions
           
protected  String mStorageDir
          This contains the storage directory relative to the se mount point of the pool.
private  Map<String,SiteCatalogEntry> mStore
          The internal map that maps a site catalog entry to the site handle.
private  String mWorkDir
          The work dir path from the properties.
static String SCHEMA_LOCATION
          The "not-so-official" location URL of the DAX schema definition.
static String SCHEMA_NAMESPACE
          The "official" namespace URI of the site catalog schema.
static String SCHEMA_VERSION
          The version to report.
 
Constructor Summary
SiteStore()
          The default constructor.
 
Method Summary
 SiteCatalogEntry addEntry(SiteCatalogEntry entry)
          Adds a site catalog entry to the store.
 Object clone()
          Returns the clone of the object.
 boolean contains(String handle)
          Returns boolean indicating whether the store has a SiteCatalogEntry matching a handle.
 Iterator<SiteCatalogEntry> entryIterator()
          Returns an iterator to SiteCatalogEntry objects in the store.
 String getEnvironmentVariable(String handle, String variable)
          Returns an environment variable associated with the site.
 String getExternalStorageDirectory(String site)
          Return the storage mount point for a particular pool.
 String getExternalWorkDirectory(FileServer fs, String siteHandle)
          Return the work directory as seen externally (including external mount point)
 String getExternalWorkDirectoryURL(String siteHandle)
          Returns a URL to the work directory as seen externally ( including external mount point ).
 String getInternalWorkDirectory(Job job)
          This determines the working directory on remote execution pool for a particular job.
 String getInternalWorkDirectory(Job job, boolean onStagingSite)
          This determines the working directory on remote execution pool or a staging site for a particular job.
 String getInternalWorkDirectory(String handle)
          This determines the working directory on remote execution pool on the basis of whether an absolute path is specified in the pegasus.dir.exec directory or a relative path.
 String getInternalWorkDirectory(String handle, String path)
          This determines the working directory on remote execution pool on the basis of whether an absolute path is specified in the pegasus.dir.exec directory or a relative path.
 String getInternalWorkDirectory(String handle, String path, int jobClass)
          This determines the working directory on remote execution pool on the basis of whether an absolute path is specified in the pegasus.dir.exec directory or a relative path.
 String getPegasusHome(String handle)
          Deprecated. 
 SysInfo getSysInfo(String handle)
          Returns the SysInfo for the site
 Map<String,SysInfo> getSysInfos(List<String> sites)
           
 String getVDSHome(String handle)
          Deprecated. 
 VDSSysInfo getVDSSysInfo(String handle)
          Returns the VDSSysInfo for the site
 void initialize()
          The intialize method.
 Set<String> list()
          Returns the list of sites, in the store.
 SiteCatalogEntry lookup(String handle)
          Returns SiteCatalogEntry matching a site handle.
 boolean removeFileServer(String handle, String url)
          This is a soft state remove, that removes a file server from a particular pool entry.
 boolean removeGridGateway(String handle, String contact)
          This is a soft state remove, that removes a GridGateway from a particular site.
 void setForPlannerUse(PegasusProperties properties, PlannerOptions options)
          A setter method that is to be set to use getWorkDirectory functions, correctly.
 void toXML(Writer writer, String indent)
          Writes out the contents of the replica store as XML document
 void writeXMLHeader(Writer stream, String indent)
          Writes the header of the XML output.
 
Methods inherited from class edu.isi.pegasus.planner.catalog.site.classes.AbstractSiteData
toString, toXML, writeAttribute
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SCHEMA_NAMESPACE

public static final String SCHEMA_NAMESPACE
The "official" namespace URI of the site catalog schema.

See Also:
Constant Field Values

SCHEMA_LOCATION

public static final String SCHEMA_LOCATION
The "not-so-official" location URL of the DAX schema definition.

See Also:
Constant Field Values

SCHEMA_VERSION

public static final String SCHEMA_VERSION
The version to report.

See Also:
Constant Field Values

mStore

private Map<String,SiteCatalogEntry> mStore
The internal map that maps a site catalog entry to the site handle.


mWorkDir

private String mWorkDir
The work dir path from the properties.


mPlannerOptions

private PlannerOptions mPlannerOptions

mStorageDir

protected String mStorageDir
This contains the storage directory relative to the se mount point of the pool. It is populated from the pegasus.dir.storage property from the properties file. If not specified then the storage directory is the se mount point from the pool.config file.


mDeepStorageStructure

protected boolean mDeepStorageStructure
A boolean indicating whether to have a deep directory structure for the storage directory or not.

Constructor Detail

SiteStore

public SiteStore()
The default constructor.

Method Detail

initialize

public void initialize()
The intialize method.


setForPlannerUse

public void setForPlannerUse(PegasusProperties properties,
                             PlannerOptions options)
A setter method that is to be set to use getWorkDirectory functions, correctly.

Parameters:
properties - the PegasusProperties
options - the PlannerOptions

addEntry

public SiteCatalogEntry addEntry(SiteCatalogEntry entry)
Adds a site catalog entry to the store.

Parameters:
entry - the site catalog entry.
Returns:
previous value associated with specified key, or null if there was no mapping for key

entryIterator

public Iterator<SiteCatalogEntry> entryIterator()
Returns an iterator to SiteCatalogEntry objects in the store.

Returns:
Iterator

list

public Set<String> list()
Returns the list of sites, in the store.

Returns:
list of sites

lookup

public SiteCatalogEntry lookup(String handle)
Returns SiteCatalogEntry matching a site handle.

Parameters:
handle - the handle of the site to be looked up.
Returns:
SiteCatalogEntry if exists else null.

contains

public boolean contains(String handle)
Returns boolean indicating whether the store has a SiteCatalogEntry matching a handle.

Parameters:
handle - the site handle / identifier.
Returns:
boolean

getSysInfos

public Map<String,SysInfo> getSysInfos(List<String> sites)
Parameters:
sites - the list of site identifiers for which sysinfo is required.
Returns:
the sysinfo map

getVDSSysInfo

public VDSSysInfo getVDSSysInfo(String handle)
Returns the VDSSysInfo for the site

Parameters:
handle - the site handle / identifier.
Returns:
the VDSSysInfo else null

getSysInfo

public SysInfo getSysInfo(String handle)
Returns the SysInfo for the site

Parameters:
handle - the site handle / identifier.
Returns:
the SysInfo else null

getVDSHome

@Deprecated
public String getVDSHome(String handle)
Deprecated. 

Returns the value of VDS_HOME for a site.

Parameters:
handle - the site handle / identifier.
Returns:
value if set else null.

getPegasusHome

@Deprecated
public String getPegasusHome(String handle)
Deprecated. 

Returns the value of PEGASUS_HOME for a site.

Parameters:
handle - the site handle / identifier.
Returns:
value if set else null.

getEnvironmentVariable

public String getEnvironmentVariable(String handle,
                                     String variable)
Returns an environment variable associated with the site. If a env value is not specified in the site catalog, then only for local site it falls back on the value retrieved from the environment.

Parameters:
handle - the site handle / identifier.
variable - the name of the environment variable.
Returns:
value of the environment variable if found, else null

removeGridGateway

public boolean removeGridGateway(String handle,
                                 String contact)
This is a soft state remove, that removes a GridGateway from a particular site. The cause of this removal could be the inability to authenticate against it at runtime. The successful removal lead Pegasus not to schedule job on that particular grid gateway.

Parameters:
handle - the site handle with which it is associated.
contact - the contact string for the grid gateway.
Returns:
true if was able to remove the jobmanager from the cache false if unable to remove, or the matching entry is not found or if the implementing class does not maintain a soft state.

removeFileServer

public boolean removeFileServer(String handle,
                                String url)
This is a soft state remove, that removes a file server from a particular pool entry. The cause of this removal could be the inability to authenticate against it at runtime. The successful removal lead Pegasus not to schedule any transfers on that particular gridftp server.

Parameters:
handle - the site handle with which it is associated.
url - the contact string for the file server.
Returns:
true if was able to remove the gridftp from the cache false if unable to remove, or the matching entry is not found or if the implementing class does not maintain a soft state. or the information about site is not in the site catalog.

getExternalWorkDirectoryURL

public String getExternalWorkDirectoryURL(String siteHandle)
Returns a URL to the work directory as seen externally ( including external mount point ).

Parameters:
siteHandle - the site handle.
Returns:
the url

getExternalWorkDirectory

public String getExternalWorkDirectory(FileServer fs,
                                       String siteHandle)
Return the work directory as seen externally (including external mount point)

Parameters:
fs - the FileServer with the file system
siteHanlde - the site for which you want the directory
Returns:
String corresponding to the mount point

getExternalStorageDirectory

public String getExternalStorageDirectory(String site)
Return the storage mount point for a particular pool.

Parameters:
site - the site for which you want the storage-mount-point.
Returns:
String corresponding to the mount point if the pool is found. null if pool entry is not found.

getInternalWorkDirectory

public String getInternalWorkDirectory(String handle)
This determines the working directory on remote execution pool on the basis of whether an absolute path is specified in the pegasus.dir.exec directory or a relative path.

Parameters:
handle - the site handle of the site where a job has to be executed.
Returns:
the path to the pool work dir.
Throws:
RuntimeException - in case of site not found in the site catalog.

getInternalWorkDirectory

public String getInternalWorkDirectory(Job job)
This determines the working directory on remote execution pool for a particular job. The job should have it's execution pool set.

Parameters:
job - Job object for the job.
Returns:
the path to the pool work dir.
Throws:
RuntimeException - in case of site not found in the site catalog.

getInternalWorkDirectory

public String getInternalWorkDirectory(Job job,
                                       boolean onStagingSite)
This determines the working directory on remote execution pool or a staging site for a particular job. The job should have it's execution pool set.

Parameters:
job - Job object for the job.
onStagingSite - boolean indicating whether the work directory required is the one on staging site.
Returns:
the path to the pool work dir.
Throws:
RuntimeException - in case of site not found in the site catalog.

getInternalWorkDirectory

public String getInternalWorkDirectory(String handle,
                                       String path)
This determines the working directory on remote execution pool on the basis of whether an absolute path is specified in the pegasus.dir.exec directory or a relative path.

Parameters:
handle - the site handle of the site where a job has to be executed.
path - the relative path that needs to be appended to the workdir from the execution pool.
Returns:
the path to the pool work dir.
Throws:
RuntimeException - in case of site not found in the site catalog.

getInternalWorkDirectory

public String getInternalWorkDirectory(String handle,
                                       String path,
                                       int jobClass)
This determines the working directory on remote execution pool on the basis of whether an absolute path is specified in the pegasus.dir.exec directory or a relative path. If the job class happens to be a create directory job it does not append the name of the random directory since the job is trying to create that random directory.

Parameters:
handle - the site handle of the site where a job has to be executed.
path - the relative path that needs to be appended to the workdir from the execution pool.
jobClass - the class of the job.
Returns:
the path to the pool work dir.
Throws:
RuntimeException - in case of site not found in the site catalog.

toXML

public void toXML(Writer writer,
                  String indent)
           throws IOException
Writes out the contents of the replica store as XML document

Specified by:
toXML in class AbstractSiteData
Parameters:
writer -
indent -
Throws:
IOException

writeXMLHeader

public void writeXMLHeader(Writer stream,
                           String indent)
                    throws IOException
Writes the header of the XML output. The output contains the special strings to start an XML document, some comments, and the root element. The latter points to the XML schema via XML Instances.

Parameters:
stream - is a stream opened and ready for writing. This can also be a string stream for efficient output.
indent - is a String of spaces used for pretty printing. The initial amount of spaces should be an empty string. The parameter is used internally for the recursive traversal.
Throws:
IOException - if something fishy happens to the stream.

clone

public Object clone()
Returns the clone of the object.

Overrides:
clone in class AbstractSiteData
Returns:
the clone


Copyright © 2011 The University of Southern California. All Rights Reserved.