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

## Class SiteStore

- java.lang.Object
- - edu.isi.pegasus.planner.catalog.site.classes.SiteData
  - - edu.isi.pegasus.planner.catalog.site.classes.AbstractSiteData
    - - edu.isi.pegasus.planner.catalog.site.classes.SiteStore

All Implemented Interfaces:
  java.lang.Cloneable

    public class SiteStore
    extends AbstractSiteData

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

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

### Field Summary

Fields
`protected boolean` `mDeepStorageStructure` A boolean indicating whether to have a deep directory structure for the storage directory or not.
`private PlannerOptions` `mPlannerOptions`
`private java.util.Map<java.lang.String,SiteCatalogEntry>` `mStore` The internal map that maps a site catalog entry to the site handle.
`private java.lang.String` `mWorkDir` The work dir path from the properties.

### Constructor Summary

Constructors
Constructor and Description
`SiteStore()` The default constructor.

### Method Summary

All Methods Instance Methods Concrete Methods Deprecated Methods
`void` `accept(SiteDataVisitor visitor)` Accept method for the SiteStore object
`SiteCatalogEntry` `addEntry(SiteCatalogEntry entry)` Adds a site catalog entry to the store.
`java.lang.Object` `clone()` Returns the clone of the object.
`boolean` `contains(java.lang.String handle)` Returns boolean indicating whether the store has a SiteCatalogEntry matching a handle.
`java.util.Iterator<SiteCatalogEntry>` `entryIterator()` Returns an iterator to SiteCatalogEntry objects in the store.
`java.lang.String` `getEnvironmentVariable(java.lang.String handle, java.lang.String variable)` Returns an environment variable associated with the site.
`java.lang.String` `getExternalWorkDirectory(FileServer fs, java.lang.String siteHandle)` Return the work directory as seen externally (including external mount point)
`java.lang.String` `getExternalWorkDirectoryURL(FileServer server, java.lang.String siteHandle)` Returns a URL to the work directory as seen externally ( including external mount point ).
`java.lang.String` `getExternalWorkDirectoryURL(java.lang.String siteHandle, FileServerType.OPERATION operation)` Returns a URL to the work directory as seen externally ( including external mount point ).
`java.lang.String` `getInternalWorkDirectory(Job job)` This determines the working directory on remote execution pool for a particular job.
`java.lang.String` `getInternalWorkDirectory(Job job, boolean onStagingSite)` This determines the working directory on remote execution pool or a staging site for a particular job.
`java.lang.String` `getInternalWorkDirectory(java.lang.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.
`java.lang.String` `getInternalWorkDirectory(java.lang.String handle, java.lang.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.
`java.lang.String` `getInternalWorkDirectory(java.lang.String handle, java.lang.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.
`java.lang.String` `getPegasusHome(java.lang.String handle)` Deprecated.
`java.lang.String` `getRelativeStorageDirectoryAddon()` Return the relative directory that needs to be appended to the storage directory for the workflow.
`SysInfo` `getSysInfo(java.lang.String handle)` Returns the `SysInfo` for the site
`java.util.Map<java.lang.String,SysInfo>` `getSysInfos(java.util.List<java.lang.String> sites)`
`java.lang.String` `getVDSHome(java.lang.String handle)` Deprecated.
`VDSSysInfo` `getVDSSysInfo(java.lang.String handle)` Returns the `VDSSysInfo` for the site
`private boolean` `hashedOutputMapperUsed(PegasusProperties properties)` Returns a boolean indicating whether the Hashed Output Mapper was used or not
`void` `initialize()` The intialize method.
`java.util.Set<java.lang.String>` `list()` Returns the list of sites, in the store.
`SiteCatalogEntry` `lookup(java.lang.String handle)` Returns SiteCatalogEntry matching a site handle.
`boolean` `removeFileServer(java.lang.String handle, java.lang.String url)` This is a soft state remove, that removes a file server from a particular pool entry.
`boolean` `removeGridGateway(java.lang.String handle, java.lang.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(java.io.Writer writer, java.lang.String indent)` Writes out the contents of the replica store as XML document

### 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

#### mStore

    private java.util.Map<java.lang.String,SiteCatalogEntry> mStore

The internal map that maps a site catalog entry to the site handle.

#### mWorkDir

    private java.lang.String mWorkDir

The work dir path from the properties.

#### mPlannerOptions

    private PlannerOptions mPlannerOptions

#### 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 java.util.Iterator<SiteCatalogEntry> entryIterator()

Returns an iterator to SiteCatalogEntry objects in the store.

Returns:
  Iterator<SiteCatalogEntry>

#### list

    public java.util.Set<java.lang.String> list()

Returns the list of sites, in the store.

Returns:
  list of sites

#### lookup

    public SiteCatalogEntry lookup(java.lang.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(java.lang.String handle)

Returns boolean indicating whether the store has a SiteCatalogEntry matching a handle.

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

#### getSysInfos

    public java.util.Map<java.lang.String,SysInfo> getSysInfos(java.util.List<java.lang.String> sites)

Parameters:
  `sites` - the list of site identifiers for which sysinfo is required.
Returns:
  the sysinfo map

#### getVDSSysInfo

    public VDSSysInfo getVDSSysInfo(java.lang.String handle)

Returns the `VDSSysInfo` for the site

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

#### getSysInfo

    public SysInfo getSysInfo(java.lang.String handle)

Returns the `SysInfo` for the site

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

#### getVDSHome

    @Deprecated
    public java.lang.String getVDSHome(java.lang.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 java.lang.String getPegasusHome(java.lang.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 java.lang.String getEnvironmentVariable(java.lang.String handle,
                                                   java.lang.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(java.lang.String handle,
                                     java.lang.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(java.lang.String handle,
                                    java.lang.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 java.lang.String getExternalWorkDirectoryURL(java.lang.String siteHandle,
                                                        FileServerType.OPERATION operation)

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

Parameters:
  `siteHandle` - the site handle.
  `operation` - the operation for which we need the server.
Returns:
  the url

#### getExternalWorkDirectoryURL

    public java.lang.String getExternalWorkDirectoryURL(FileServer server,
                                                        java.lang.String siteHandle)

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

Parameters:
  `server` - the FileServer to use
  `siteHandle` - the site handle.
Returns:
  the url else null

#### getExternalWorkDirectory

    public java.lang.String getExternalWorkDirectory(FileServer fs,
                                                     java.lang.String siteHandle)

Return the work directory as seen externally (including external mount point)

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

#### getRelativeStorageDirectoryAddon

    public java.lang.String getRelativeStorageDirectoryAddon()

Return the relative directory that needs to be appended to the storage directory for the workflow.

Returns:
  String corresponding to the mount point if the pool is found. null if pool entry is not found.

#### getInternalWorkDirectory

    public java.lang.String getInternalWorkDirectory(java.lang.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:
  `java.lang.RuntimeException` - in case of site not found in the site catalog.

#### getInternalWorkDirectory

    public java.lang.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:
  `java.lang.RuntimeException` - in case of site not found in the site catalog.

#### getInternalWorkDirectory

    public java.lang.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:
  `java.lang.RuntimeException` - in case of site not found in the site catalog.

#### getInternalWorkDirectory

    public java.lang.String getInternalWorkDirectory(java.lang.String handle,
                                                     java.lang.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:
  `java.lang.RuntimeException` - in case of site not found in the site catalog.

#### getInternalWorkDirectory

    public java.lang.String getInternalWorkDirectory(java.lang.String handle,
                                                     java.lang.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:
  `java.lang.RuntimeException` - in case of site not found in the site catalog.

#### toXML

    public void toXML(java.io.Writer writer,
                      java.lang.String indent)
               throws java.io.IOException

Writes out the contents of the replica store as XML document

Specified by:
  `toXML` in class `AbstractSiteData`
Parameters:
  `writer` -
  `indent` -
Throws:
  `java.io.IOException`

#### clone

    public java.lang.Object clone()

Returns the clone of the object.

Overrides:
  `clone` in class `AbstractSiteData`
Returns:
  the clone

#### accept

    public void accept(SiteDataVisitor visitor)
                throws java.io.IOException

Accept method for the SiteStore object

Specified by:
  `accept` in class `AbstractSiteData`
Parameters:
  `visitor` - that goes through it
Throws:
  `java.io.IOException` - if something fishy happens to the stream.

#### hashedOutputMapperUsed

    private boolean hashedOutputMapperUsed(PegasusProperties properties)

Returns a boolean indicating whether the Hashed Output Mapper was used or not

Parameters:
  `properties` -
Returns:
  boolean