edu.isi.pegasus.planner.catalog.transformation.impl
Class Text

java.lang.Object
  extended by edu.isi.pegasus.planner.catalog.transformation.impl.Abstract
      extended by edu.isi.pegasus.planner.catalog.transformation.impl.Text
All Implemented Interfaces:
Catalog, TransformationCatalog

public class Text
extends Abstract
implements TransformationCatalog

A File based Transformation Catalog where each entry spans multiple lines. The implementation refers to the following same format for specifying a transformation catalog entry.

 tr example::keg:1.0 {

  #specify profiles that apply for all the sites for the transformation
  #in each site entry the profile can be overriden
  profile env "APP_HOME" "/tmp/karan"
  profile env "JAVA_HOME" "/bin/java.1.5"
 
  site isi {
   profile env "me" "with"
   profile condor "more" "test"
   profile env "JAVA_HOME" "/bin/java.1.6"
   pfn "/path/to/keg"
   arch  "x86"
   os    "linux"
   osrelease "fc"
   osversion "4"
   type "installed"
  }

  site wind {
   profile env "me" "with"
   profile condor "more" "test"
   pfn "/path/to/keg"
   arch  "x86"
   os    "linux"
   osrelease "fc"
   osversion "4"
   type "STAGEABLE"
  }
 }

 

Version:
$Revision: 2183 $
Author:
Karan Vahi

Field Summary
static String DESCRIPTION
          Describes the transformation catalog mode.
private  boolean mFlushOnClose
          Boolean indicating whether to flush the contents back to the file on close.
protected  LogManager mLogger
          The LogManager object which is used to log all the messages.
private  boolean modifyFileURL
          Boolean indicating whether to modify the file URL or not
private  PegasusProperties mProps
          The handle to the properties object.
private  String mTCFile
          The path to the file based TC.
private  TransformationStore mTCStore
          The transformation store containing the transformations after parsing the file.
private  TransformationCatalogTextParser mTextParser
          Instance to the TextParser.
 
Fields inherited from interface edu.isi.pegasus.planner.catalog.TransformationCatalog
FILE_URL_SCHEME, MODIFY_FOR_FILE_URLS_KEY, VERSION
 
Fields inherited from interface edu.isi.pegasus.planner.catalog.Catalog
DB_ALL_PREFIX
 
Constructor Summary
Text()
          Default constructor.
 
Method Summary
 int addLFNProfile(String namespace, String name, String version, List profiles)
          Add additional profile to a logical transformation .
 int addPFNProfile(String pfn, TCType type, String resourcename, List profiles)
          Add additional profile to a physical transformation.
protected  boolean addTCEntry(String namespace, String name, String version, String physicalname, TCType type, String resourceid, List pfnprofiles, List lfnprofiles, SysInfo system, Notifications invokes, boolean write)
          Add an single entry into the transformation catalog.
 int clear()
          Deletes the entire transformation catalog.
 void close()
          Closes the connection to the back end.
private static void columnLength(String[] s, int[] count)
          Computes the maximum column lenght for pretty printing.
 boolean connect(Properties props)
          Empty for the time being.
 int deleteLFNProfiles(String namespace, String name, String version, List profiles)
          Delete a list of profiles or all the profiles associated with a logical transformation.
 int deletePFNProfiles(String physicalname, TCType type, String resourceid, List profiles)
          Delete a list of profiles or all the profiles associated with a pfn on a resource and of a type.
 List<TransformationCatalogEntry> getContents()
          List all the contents of the TC
 String getDescription()
          Returns a textual description of the transformation mode.
 List<String[]> getTCLogicalNames(String resourceid, TCType type)
          Get the list of LogicalNames available on a particular resource.
 void initialize(PegasusBag bag)
          Initialize the implementation, and return an instance of the implementation.
 int insert(List<TransformationCatalogEntry> entries)
          Add multiple TCEntries to the Catalog.
 int insert(String namespace, String name, String version, String physicalname, TCType type, String resourceid, List pfnprofiles, List lfnprofiles, SysInfo system)
          Add an single entry into the transformation catalog.
 int insert(TransformationCatalogEntry entry)
          Add single TCEntry to the Catalog.
 int insert(TransformationCatalogEntry entry, boolean write)
          Add single TCEntry object temporarily to the in memory Catalog.
 boolean isClosed()
          Returns whether the connection is closed or not.
protected  void logMessage(String msg)
          Logs the message to a logging stream.
 List<TransformationCatalogEntry> lookup(String namespace, String name, String version, List resourceids, TCType type)
          Returns TC entries for a particular logical transformation and/or on a number of resources and/or of a particular type.
 List<TransformationCatalogEntry> lookup(String namespace, String name, String version, String resourceid, TCType type)
          Returns TC entries for a particular logical transformation and/or on a particular resource and/or of a particular type.
 List<Profile> lookupLFNProfiles(String namespace, String name, String version)
          Get the list of Profiles associated with a particular logical transformation.
 List<TransformationCatalogEntry> lookupNoProfiles(String namespace, String name, String version, String resourceid, TCType type)
          Get the list of PhysicalNames for a particular transformation on a site/sites for a particular type/types;
 List<Profile> lookupPFNProfiles(String pfn, String resourceid, TCType type)
          Get the list of Profiles associated with a particular physical transformation.
 List<String> lookupSites(String namespace, String name, String version, TCType type)
          Get the list of Resource ID's where a particular transformation may reside.
 int removeByLFN(String namespace, String name, String version, String resourceid, TCType type)
          Delete all entries in the transformation catalog for a give logical transformation and/or on a resource and/or of a particular type
 int removeByPFN(String physicalname, String namespace, String name, String version, String resourceid, TCType type)
          Delete all entries in the transformation catalog for pair of logical and physical transformation.
 int removeBySiteID(String resourceid)
          Delete all entries on a particular resource from the transformation catalog.
 int removeBySysInfo(SysInfo sysinfo)
          Deletes entries from the catalog which have a particular system information.
 int removeByType(TCType type, String resourceid)
          Delete a particular type of transformation, and/or on a particular resource
 
Methods inherited from class edu.isi.pegasus.planner.catalog.transformation.impl.Abstract
modifyForFileURLS, modifyForFileURLS
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DESCRIPTION

public static final String DESCRIPTION
Describes the transformation catalog mode.

See Also:
Constant Field Values

mLogger

protected LogManager mLogger
The LogManager object which is used to log all the messages. It's values are set in the CPlanner (the main toolkit) class.


mTCFile

private String mTCFile
The path to the file based TC.


mProps

private PegasusProperties mProps
The handle to the properties object.


mTextParser

private TransformationCatalogTextParser mTextParser
Instance to the TextParser.


mTCStore

private TransformationStore mTCStore
The transformation store containing the transformations after parsing the file.


mFlushOnClose

private boolean mFlushOnClose
Boolean indicating whether to flush the contents back to the file on close.


modifyFileURL

private boolean modifyFileURL
Boolean indicating whether to modify the file URL or not

Constructor Detail

Text

public Text()
Default constructor.

Method Detail

initialize

public void initialize(PegasusBag bag)
Initialize the implementation, and return an instance of the implementation. It should be in the connect method, to be consistent with the other catalogs.

Specified by:
initialize in interface TransformationCatalog
Parameters:
bag - the bag of Pegasus initialization objects.

connect

public boolean connect(Properties props)
Empty for the time being. The factory still calls out to the initialize method.

Specified by:
connect in interface Catalog
Parameters:
props - the connection properties.
Returns:

isClosed

public boolean isClosed()
Returns whether the connection is closed or not.

Specified by:
isClosed in interface Catalog
Returns:
See Also:
Catalog.close()

close

public void close()
Closes the connection to the back end.

Specified by:
close in interface Catalog

getDescription

public String getDescription()
Returns a textual description of the transformation mode.

Specified by:
getDescription in interface TransformationCatalog
Returns:
String containing the description.

lookup

public List<TransformationCatalogEntry> lookup(String namespace,
                                               String name,
                                               String version,
                                               List resourceids,
                                               TCType type)
                                        throws Exception
Returns TC entries for a particular logical transformation and/or on a number of resources and/or of a particular type.

Specified by:
lookup in interface TransformationCatalog
Parameters:
namespace - String The namespace of the logical transformation.
name - String the name of the logical transformation.
version - String The version of the logical transformation.
resourceids - List The List resourceid where the transformation is located. If NULL it returns all resources.
type - TCType The type of the transformation to search for. If NULL it returns all types.
Returns:
List Returns a list of TransformationCatalogEntry objects containing the corresponding entries from the TC. Returns null if no entry found.
Throws:
Exception
See Also:
TCType, edu.isi.pegasus.planner.catalog.TransformationCatalogEntry

lookup

public List<TransformationCatalogEntry> lookup(String namespace,
                                               String name,
                                               String version,
                                               String resourceid,
                                               TCType type)
                                        throws Exception
Returns TC entries for a particular logical transformation and/or on a particular resource and/or of a particular type.

Specified by:
lookup in interface TransformationCatalog
Parameters:
namespace - String The namespace of the logical transformation.
name - String the name of the logical transformation.
version - String The version of the logical transformation.
resourceid - String The resourceid where the transformation is located. If NULL it returns all resources.
type - TCType The type of the transformation to search for. If NULL it returns all types.
Returns:
List Returns a list of TransformationCatalogEntry objects containing the corresponding entries from the TC. Returns null if no entry found.
Throws:
Exception
See Also:
TCType, edu.isi.pegasus.planner.catalog.TransformationCatalogEntry

lookupSites

public List<String> lookupSites(String namespace,
                                String name,
                                String version,
                                TCType type)
                         throws Exception
Get the list of Resource ID's where a particular transformation may reside.

Specified by:
lookupSites in interface TransformationCatalog
Parameters:
namespace - String The namespace of the transformation to search for.
name - String The name of the transformation to search for.
version - String The version of the transformation to search for.
type - TCType The type of the transformation to search for.
(Enumerated type includes SOURCE, STATIC-BINARY, DYNAMIC-BINARY, PACMAN, INSTALLED, SCRIPT)
If NULL it returns all types.
Returns:
List Returns a list of Resource Id's as strings. Returns NULL if no results found.
Throws:
Exception - NotImplementedException if not implemented
See Also:
TCType

lookupNoProfiles

public List<TransformationCatalogEntry> lookupNoProfiles(String namespace,
                                                         String name,
                                                         String version,
                                                         String resourceid,
                                                         TCType type)
                                                  throws Exception
Get the list of PhysicalNames for a particular transformation on a site/sites for a particular type/types;

Specified by:
lookupNoProfiles in interface TransformationCatalog
Parameters:
namespace - String The namespace of the transformation to search for.
name - String The name of the transformation to search for.
version - String The version of the transformation to search for.
resourceid - String The id of the resource on which you want to search.
If NULL then returns entries on all resources
type - TCType The type of the transformation to search for.
(Enumerated type includes source, binary, dynamic-binary, pacman, installed)
If NULL then returns entries of all types.
Returns:
List Returns a List of objects with the profiles not populated.
Throws:
Exception - NotImplementedException if not implemented.
See Also:
TCType

getTCLogicalNames

public List<String[]> getTCLogicalNames(String resourceid,
                                        TCType type)
                                 throws Exception
Get the list of LogicalNames available on a particular resource.

Specified by:
getTCLogicalNames in interface TransformationCatalog
Parameters:
resourceid - String The id of the resource on which you want to search
type - TCType The type of the transformation to search for.
(Enumerated type includes source, binary, dynamic-binary, pacman, installed)
If NULL then return logical name for all types.
Returns:
List Returns a list of String Arrays. Each array contains the resourceid, logical transformation in the format namespace::name:version and type. Returns NULL if no results found.
Throws:
Exception - NotImplementedException if not implemented.

lookupLFNProfiles

public List<Profile> lookupLFNProfiles(String namespace,
                                       String name,
                                       String version)
                                throws Exception
Get the list of Profiles associated with a particular logical transformation.

Specified by:
lookupLFNProfiles in interface TransformationCatalog
Parameters:
namespace - String The namespace of the transformation to search for.
name - String The name of the transformation to search for.
version - String The version of the transformation to search for.
Returns:
List Returns a list of Profile Objects containing profiles assocaited with the transformation. Returns NULL if no profiles found.
Throws:
Exception - NotImplementedException if not implemented.
See Also:
org.griphyn.cPlanner.classes.Profile

lookupPFNProfiles

public List<Profile> lookupPFNProfiles(String pfn,
                                       String resourceid,
                                       TCType type)
                                throws Exception
Get the list of Profiles associated with a particular physical transformation.

Specified by:
lookupPFNProfiles in interface TransformationCatalog
Parameters:
pfn - The physical file name to search the transformation by.
resourceid - String The id of the resource on which you want to search.
type - TCType The type of the transformation to search for.
(Enumerated type includes source, binary, dynamic-binary, pacman, installed)
Returns:
List Returns a list of Profile Objects containing profiles assocaited with the transformation. Returns NULL if no profiless found.
Throws:
Exception - NotImplementedException if not implemented.
See Also:
org.griphyn.cPlanner.classes.Profile

getContents

public List<TransformationCatalogEntry> getContents()
                                             throws Exception
List all the contents of the TC

Specified by:
getContents in interface TransformationCatalog
Returns:
List Returns a List of TransformationCatalogEntry objects.
Throws:
Exception

insert

public int insert(List<TransformationCatalogEntry> entries)
           throws Exception
Add multiple TCEntries to the Catalog.

Specified by:
insert in interface TransformationCatalog
Parameters:
tcentry - List Takes a list of TransformationCatalogEntry objects as input
Returns:
number of insertions On failure,throw an exception, don't use zero.
Throws:
Exception
See Also:
edu.isi.pegasus.planner.catalog.TransformationCatalogEntry

insert

public int insert(TransformationCatalogEntry entry)
           throws Exception
Add single TCEntry to the Catalog.

Specified by:
insert in interface TransformationCatalog
Parameters:
tcentry - Takes a single TransformationCatalogEntry object as input
Returns:
number of insertions, should always be 1. On failure, throw an exception, don't use zero.
Throws:
Exception
See Also:
edu.isi.pegasus.planner.catalog.TransformationCatalogEntry

insert

public int insert(TransformationCatalogEntry entry,
                  boolean write)
           throws Exception
Add single TCEntry object temporarily to the in memory Catalog. This is a hack to get around for adding soft state entries to the TC

Specified by:
insert in interface TransformationCatalog
Parameters:
tcentry - Takes a single TransformationCatalogEntry object as input
write - boolean enable write commits to backed catalog or not.
Returns:
number of insertions, should always be 1. On failure, throw an exception, don't use zero.
Throws:
Exception
See Also:
edu.isi.pegasus.planner.catalog.TransformationCatalogEntry

insert

public int insert(String namespace,
                  String name,
                  String version,
                  String physicalname,
                  TCType type,
                  String resourceid,
                  List pfnprofiles,
                  List lfnprofiles,
                  SysInfo system)
           throws Exception
Add an single entry into the transformation catalog.

Specified by:
insert in interface TransformationCatalog
Parameters:
namespace - String The namespace of the transformation to be added (Can be null)
name - String The name of the transformation to be added.
version - String The version of the transformation to be added. (Can be null)
physicalname - String The physical name/location of the transformation to be added.
type - TCType The type of the physical transformation.
resourceid - String The resource location id where the transformation is located.
lfnprofiles - List The List of Profile objects associated with a Logical Transformation. (can be null)
pfnprofiles - List The List of Profile objects associated with a Physical Transformation. (can be null)
sysinfo - SysInfo The System information associated with a physical transformation.
Returns:
number of insertions, should always be 1. On failure, throw an exception, don't use zero.
Throws:
Exception
See Also:
edu.isi.pegasus.planner.catalog.TransformationCatalogEntry, SysInfo, org.griphyn.cPlanner.classes.Profile

addTCEntry

protected boolean addTCEntry(String namespace,
                             String name,
                             String version,
                             String physicalname,
                             TCType type,
                             String resourceid,
                             List pfnprofiles,
                             List lfnprofiles,
                             SysInfo system,
                             Notifications invokes,
                             boolean write)
                      throws Exception
Add an single entry into the transformation catalog.

Parameters:
namespace - the namespace of the transformation to be added (Can be null)
name - the name of the transformation to be added.
version - the version of the transformation to be added. (Can be null)
physicalname - the physical name/location of the transformation to be added.
type - the type of the physical transformation.
resourceid - the resource location id where the transformation is located.
lfnprofiles - the List of Profile objects associated with a Logical Transformation. (can be null)
pfnprofiles - the list of Profile objects associated with a Physical Transformation. (can be null)
system - the System information associated with a physical transformation.
invokes - the Notifications associated with the transformation.
write - boolean to commit changes to backend catalog
Returns:
boolean true if succesfully added, returns false if error and throws exception.
Throws:
Exception
See Also:
edu.isi.pegasus.planner.catalog.TransformationCatalogEntry, SysInfo, org.griphyn.cPlanner.classes.Profile

addLFNProfile

public int addLFNProfile(String namespace,
                         String name,
                         String version,
                         List profiles)
                  throws Exception
Add additional profile to a logical transformation .

Specified by:
addLFNProfile in interface TransformationCatalog
Parameters:
namespace - String The namespace of the transformation to be added. (can be null)
name - String The name of the transformation to be added.
version - String The version of the transformation to be added. (can be null)
profiles - List The List of Profile objects that are to be added to the transformation.
Returns:
number of insertions. On failure, throw an exception, don't use zero.
Throws:
Exception
See Also:
org.griphyn.cPlanner.classes.Profile

addPFNProfile

public int addPFNProfile(String pfn,
                         TCType type,
                         String resourcename,
                         List profiles)
                  throws Exception
Add additional profile to a physical transformation.

Specified by:
addPFNProfile in interface TransformationCatalog
Parameters:
pfn - String The physical name of the transformation
type - TCType The type of transformation that the profile is associated with.
resourcename - String The resource on which the physical transformation exists
profiles - The List of Profile objects that are to be added to the transformation.
Returns:
number of insertions. On failure, throw an exception, don't use zero.
Throws:
Exception
See Also:
org.griphyn.cPlanner.classes.Profile

removeByLFN

public int removeByLFN(String namespace,
                       String name,
                       String version,
                       String resourceid,
                       TCType type)
                throws Exception
Delete all entries in the transformation catalog for a give logical transformation and/or on a resource and/or of a particular type

Specified by:
removeByLFN in interface TransformationCatalog
Parameters:
namespace - String The namespace of the transformation to be deleted. (can be null)
name - String The name of the transformation to be deleted.
version - String The version of the transformation to be deleted. ( can be null)
resourceid - String The resource id for which the transformation is to be deleted. If NULL then transformation on all resource are deleted
type - TCType The type of the transformation. If NULL then all types are deleted for the transformation.
Returns:
the number of removed entries.
Throws:
Exception
See Also:
TCType

removeByPFN

public int removeByPFN(String physicalname,
                       String namespace,
                       String name,
                       String version,
                       String resourceid,
                       TCType type)
                throws Exception
Delete all entries in the transformation catalog for pair of logical and physical transformation.

Specified by:
removeByPFN in interface TransformationCatalog
Parameters:
physicalname - String The physical name of the transformation
namespace - String The namespace associated in the logical name of the transformation.
name - String The name of the logical transformation.
version - String The version number of the logical transformation.
resourceid - String The resource on which the transformation is to be deleted. If NULL then it searches all the resource id.
type - TCType The type of transformation. If NULL then it search and deletes entries for all types.
Returns:
the number of removed entries.
Throws:
Exception
See Also:
TCType

removeByType

public int removeByType(TCType type,
                        String resourceid)
                 throws Exception
Delete a particular type of transformation, and/or on a particular resource

Specified by:
removeByType in interface TransformationCatalog
Parameters:
type - TCType The type of the transformation
resourceid - String The resource on which the transformation exists. If NULL then that type of transformation is deleted from all the resources.
Returns:
the number of removed entries.
Throws:
Exception
See Also:
TCType

removeBySysInfo

public int removeBySysInfo(SysInfo sysinfo)
                    throws Exception
Deletes entries from the catalog which have a particular system information.

Specified by:
removeBySysInfo in interface TransformationCatalog
Parameters:
sysinfo - SysInfo The System Information by which you want to delete
Returns:
the number of removed entries.
Throws:
Exception
See Also:
SysInfo

removeBySiteID

public int removeBySiteID(String resourceid)
                   throws Exception
Delete all entries on a particular resource from the transformation catalog.

Specified by:
removeBySiteID in interface TransformationCatalog
Parameters:
resourceid - String The resource which you want to remove.
Returns:
the number of removed entries.
Throws:
Exception

clear

public int clear()
          throws Exception
Deletes the entire transformation catalog. CLEAN............. USE WITH CAUTION.

Specified by:
clear in interface TransformationCatalog
Returns:
the number of removed entries.
Throws:
Exception

deletePFNProfiles

public int deletePFNProfiles(String physicalname,
                             TCType type,
                             String resourceid,
                             List profiles)
                      throws Exception
Delete a list of profiles or all the profiles associated with a pfn on a resource and of a type.

Specified by:
deletePFNProfiles in interface TransformationCatalog
Parameters:
physicalname - String The physical name of the transformation.
type - TCType The type of the transformation.
resourceid - String The resource of the transformation.
profiles - List The list of profiles to be deleted. If NULL then all profiles for that pfn+resource+type are deleted.
Returns:
the number of removed entries.
Throws:
Exception
See Also:
org.griphyn.cPlanner.classes.Profile

deleteLFNProfiles

public int deleteLFNProfiles(String namespace,
                             String name,
                             String version,
                             List profiles)
                      throws Exception
Delete a list of profiles or all the profiles associated with a logical transformation.

Specified by:
deleteLFNProfiles in interface TransformationCatalog
Parameters:
namespace - String The namespace of the logical transformation.
name - String The name of the logical transformation.
version - String The version of the logical transformation.
profiles - List The List of profiles to be deleted. If NULL then all profiles for the logical transformation are deleted.
Returns:
the number of removed entries.
Throws:
Exception
See Also:
org.griphyn.cPlanner.classes.Profile

columnLength

private static void columnLength(String[] s,
                                 int[] count)
Computes the maximum column lenght for pretty printing.

Parameters:
s - String[]
count - int[]

logMessage

protected void logMessage(String msg)
Logs the message to a logging stream. Currently does not log to any stream.

Parameters:
msg - the message to be logged.


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