Class MRC
- java.lang.Object
-
- edu.isi.pegasus.planner.catalog.replica.impl.MRC
-
- All Implemented Interfaces:
Catalog,ReplicaCatalog
public class MRC extends java.lang.Object implements ReplicaCatalog
A multiple replica catalog implementation that allows users to query different multiple catalogs at the same time.To use it set
pegasus.catalog.replica MRC
Each associated replica catalog can be configured via properties as follows.The user associates a variable name referred to as [value] for each of the catalogs, where [value] is any legal identifier (concretely [A-Za-z][_A-Za-z0-9]*) For each associated replica catalogs the user specifies the following properties.
pegasus.catalog.replica.mrc.[value] to specify the type of replica catalog. pegasus.catalog.replica.mrc.[value].key to specify a property name key for a particular catalogFor example, if a user wants to query two lrc's at the same time he/she can specify as follows
pegasus.catalog.replica.mrc.lrc1 LRC pegasus.catalog.replica.mrc.lrc2.url rls://sukhna pegasus.catalog.replica.mrc.lrc2 LRC pegasus.catalog.replica.mrc.lrc2.url rls://smartyIn the above example, lrc1, lrc2 are any valid identifier names and url is the property key that needed to be specified.
- Version:
- $Revision$
- Author:
- Karan Vahi
-
-
Field Summary
Fields Modifier and Type Field Description protected LogManagermLoggerThe handle to the logging manager.protected java.util.ListmRCListThe list of replica catalogs that need to be queried for.static java.lang.StringPROPERTY_PREFIXThe prefix for the property subset for connecting to the individual catalogs.static java.lang.StringTYPE_KEYThe property key that designates the type of replica catalog to connect to.-
Fields inherited from interface edu.isi.pegasus.planner.catalog.Catalog
DB_ALL_PREFIX
-
Fields inherited from interface edu.isi.pegasus.planner.catalog.ReplicaCatalog
BATCH_KEY, c_prefix, DB_PREFIX, PROXY_KEY
-
-
Constructor Summary
Constructors Constructor Description MRC()The default constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intclear()Removes everything from the catalogs.voidclose()Explicitely free resources before the garbage collection hits.protected booleanconnect(java.lang.String name, java.util.Properties properties)Connects to an individual replica catalog.booleanconnect(java.util.Properties props)Establishes a link between the implementation and the thing the implementation is build upon.intdelete(java.lang.String lfn, ReplicaCatalogEntry tuple)Deletes a very specific mapping from the replica catalog.intdelete(java.lang.String lfn, java.lang.String pfn)Deletes a specific mapping from the replica catalog.intdelete(java.lang.String lfn, java.lang.String name, java.lang.Object value)Deletes all PFN entries for a given LFN from the replica catalog where the PFN attribute is found, and matches exactly the object value.intdelete(java.util.Map x, boolean matchAttributes)Deletes multiple mappings into the replica catalog.intdeleteByResource(java.lang.String lfn, java.lang.String handle)Deletes all PFN entries for a given LFN from the replica catalog where the resource handle is found.protected java.lang.StringgetKey(java.lang.String key, java.lang.String prefix)Returns the key with the prefix stripped off.protected java.lang.StringgetName(java.lang.String key)Returns the name from the key.intinsert(java.lang.String lfn, ReplicaCatalogEntry tuple)Inserts a new mapping into the replica catalog.intinsert(java.lang.String lfn, java.lang.String pfn, java.lang.String handle)Inserts a new mapping into the replica catalog.intinsert(java.util.Map x)Inserts multiple mappings into the replica catalog.booleanisClosed()Predicate to check, if the connection with the catalog's implementation is still active.java.util.Setlist()Lists all logical filenames in the catalog.java.util.Setlist(java.lang.String constraint)Lists a subset of all logical filenames in the catalog.java.util.Collectionlookup(java.lang.String lfn)Retrieves all entries for a given LFN from the replica catalog.java.lang.Stringlookup(java.lang.String lfn, java.lang.String handle)Retrieves the entry for a given filename and resource handle from the replica catalog.java.util.Maplookup(java.util.Map constraints)Retrieves multiple entries for a given logical filename, up to the complete catalog.java.util.Maplookup(java.util.Set lfns)Retrieves multiple entries for a given logical filename, up to the complete catalog.java.util.Maplookup(java.util.Set lfns, java.lang.String handle)Retrieves multiple entries for a given logical filename, up to the complete catalog.java.util.SetlookupNoAttributes(java.lang.String lfn)Retrieves all entries for a given LFN from the replica catalog.java.util.MaplookupNoAttributes(java.util.Set lfns)Retrieves multiple entries for a given logical filename, up to the complete catalog.java.util.MaplookupNoAttributes(java.util.Set lfns, java.lang.String handle)Retrieves multiple entries for a given logical filename, up to the complete catalog.protected java.util.IteratorrcIterator()Returns an iterator to iterate through the list of ReplicaCatalogs that MRC is associated with.intremove(java.lang.String lfn)Removes all mappings for an LFN from the replica catalog.intremove(java.util.Set lfns)Removes all mappings for a set of LFNs.intremoveByAttribute(java.lang.String handle)Removes all entries associated with a particular resource handle.intremoveByAttribute(java.lang.String name, java.lang.Object value)Removes all entries from the replica catalog where the PFN attribute is found, and matches exactly the object value.
-
-
-
Field Detail
-
PROPERTY_PREFIX
public static final java.lang.String PROPERTY_PREFIX
The prefix for the property subset for connecting to the individual catalogs.- See Also:
- Constant Field Values
-
TYPE_KEY
public static final java.lang.String TYPE_KEY
The property key that designates the type of replica catalog to connect to.- See Also:
- Constant Field Values
-
mRCList
protected java.util.List mRCList
The list of replica catalogs that need to be queried for.
-
mLogger
protected LogManager mLogger
The handle to the logging manager.
-
-
Method Detail
-
clear
public int clear()
Removes everything from the catalogs. Use with care!!!- Specified by:
clearin interfaceReplicaCatalog- Returns:
- the number of removed entries.
-
close
public void close()
Explicitely free resources before the garbage collection hits.
-
connect
public boolean connect(java.util.Properties props)
Establishes a link between the implementation and the thing the implementation is build upon.
-
connect
protected boolean connect(java.lang.String name, java.util.Properties properties)Connects to an individual replica catalog. Also adds the handle to the connected replica catalog in the internal list.- Parameters:
name- the name given by the user in the properties file.properties- the properties to use for connecting.- Returns:
- boolean
-
rcIterator
protected java.util.Iterator rcIterator()
Returns an iterator to iterate through the list of ReplicaCatalogs that MRC is associated with.- Returns:
- Iterator
-
getName
protected java.lang.String getName(java.lang.String key)
Returns the name from the key. The name is first component of the key before the first dot (.).- Parameters:
key- String- Returns:
- String
-
getKey
protected java.lang.String getKey(java.lang.String key, java.lang.String prefix)Returns the key with the prefix stripped off. In the case, where the key is the prefix, STYLE_KEY is returned. If the key does not start with the prefix, then null is returned.- Parameters:
key- the keyprefix- String- Returns:
- key stripped off of the prefix
- See Also:
TYPE_KEY
-
delete
public int delete(java.lang.String lfn, java.lang.String name, java.lang.Object value)Deletes all PFN entries for a given LFN from the replica catalog where the PFN attribute is found, and matches exactly the object value.- Specified by:
deletein interfaceReplicaCatalog- Parameters:
lfn- is the logical filename to look for.name- is the PFN attribute name to look for.value- is an exact match of the attribute value to match.- Returns:
- the number of removed entries.
-
delete
public int delete(java.lang.String lfn, ReplicaCatalogEntry tuple)Deletes a very specific mapping from the replica catalog.- Specified by:
deletein interfaceReplicaCatalog- Parameters:
lfn- is the logical filename in the tuple.tuple- is a description of the PFN and its attributes.- Returns:
- the number of removed entries, either 0 or 1.
-
delete
public int delete(java.util.Map x, boolean matchAttributes)Deletes multiple mappings into the replica catalog.- Specified by:
deletein interfaceReplicaCatalog- Parameters:
x- is a map from logical filename string to list of replica catalog entries.matchAttributes- whether mapping should be deleted only if all attributes match.- Returns:
- the number of deletions.
- See Also:
ReplicaCatalogEntry
-
delete
public int delete(java.lang.String lfn, java.lang.String pfn)Deletes a specific mapping from the replica catalog.- Specified by:
deletein interfaceReplicaCatalog- Parameters:
lfn- is the logical filename in the tuple.pfn- is the physical filename in the tuple.- Returns:
- the number of removed entries.
-
deleteByResource
public int deleteByResource(java.lang.String lfn, java.lang.String handle)Deletes all PFN entries for a given LFN from the replica catalog where the resource handle is found.- Specified by:
deleteByResourcein interfaceReplicaCatalog- Parameters:
lfn- is the logical filename to look for.handle- is the resource handle- Returns:
- the number of entries removed.
-
insert
public int insert(java.lang.String lfn, java.lang.String pfn, java.lang.String handle)Inserts a new mapping into the replica catalog.- Specified by:
insertin interfaceReplicaCatalog- Parameters:
lfn- is the logical filename under which to book the entry.pfn- is the physical filename associated with it.handle- is a resource handle where the PFN resides.- Returns:
- number of insertions, should always be 1. On failure, throw an exception, don't use zero.
- Throws:
java.lang.UnsupportedOperationException- See Also:
ReplicaCatalog.insert( String, ReplicaCatalogEntry ),ReplicaCatalogEntry
-
insert
public int insert(java.lang.String lfn, ReplicaCatalogEntry tuple)Inserts a new mapping into the replica catalog.- Specified by:
insertin interfaceReplicaCatalog- Parameters:
lfn- is the logical filename under which to book the entry.tuple- is the physical filename and associated PFN attributes.- Returns:
- number of insertions, should always be 1. On failure, throw exception
- Throws:
java.lang.UnsupportedOperationException
-
insert
public int insert(java.util.Map x)
Inserts multiple mappings into the replica catalog.- Specified by:
insertin interfaceReplicaCatalog- Parameters:
x- is a map from logical filename string to list of replica catalog entries.- Returns:
- the number of insertions.
- Throws:
java.lang.UnsupportedOperationException- See Also:
ReplicaCatalogEntry
-
isClosed
public boolean isClosed()
Predicate to check, if the connection with the catalog's implementation is still active. Returns true only if the connections to all the associated replica catalogs is closed.- Specified by:
isClosedin interfaceCatalog- Returns:
- true, if the implementation is disassociated, false otherwise.
- See Also:
Catalog.close()
-
list
public java.util.Set list(java.lang.String constraint)
Lists a subset of all logical filenames in the catalog.- Specified by:
listin interfaceReplicaCatalog- Parameters:
constraint- is a constraint for the logical filename only. It is a string that has some meaning to the implementing system. This can be a SQL wildcard for queries, or a regular expression for Java-based memory collections.- Returns:
- A set of logical filenames that match. The set may be empty
-
list
public java.util.Set list()
Lists all logical filenames in the catalog.- Specified by:
listin interfaceReplicaCatalog- Returns:
- A set of all logical filenames known to the catalog.
-
lookup
public java.lang.String lookup(java.lang.String lfn, java.lang.String handle)Retrieves the entry for a given filename and resource handle from the replica catalog.- Specified by:
lookupin interfaceReplicaCatalog- Parameters:
lfn- is the logical filename to obtain information for.handle- is the resource handle to obtain entries for.- Returns:
- the (first) matching physical filename, or
nullif no match was found.
-
lookup
public java.util.Collection lookup(java.lang.String lfn)
Retrieves all entries for a given LFN from the replica catalog.- Specified by:
lookupin interfaceReplicaCatalog- Parameters:
lfn- is the logical filename to obtain information for.- Returns:
- a collection of replica catalog entries
- See Also:
ReplicaCatalogEntry
-
lookup
public java.util.Map lookup(java.util.Set lfns, java.lang.String handle)Retrieves multiple entries for a given logical filename, up to the complete catalog.- Specified by:
lookupin interfaceReplicaCatalog- Parameters:
lfns- is a set of logical filename strings to look up.handle- is the resource handle, restricting the LFNs.- Returns:
- a map indexed by the LFN. Each value is a collection of replica catalog entries (all attributes).
- See Also:
ReplicaCatalogEntry
-
lookup
public java.util.Map lookup(java.util.Map constraints)
Retrieves multiple entries for a given logical filename, up to the complete catalog.- Specified by:
lookupin interfaceReplicaCatalog- Parameters:
constraints- is mapping of keys 'lfn', 'pfn', or any attribute name, e.g. the resource handle 'site', to a string that has some meaning to the implementing system. This can be a SQL wildcard for queries, or a regular expression for Java-based memory collections. Unknown keys are ignored. Using an empty map requests the complete catalog.- Returns:
- a map indexed by the LFN. Each value is a collection of replica catalog entries.
- See Also:
ReplicaCatalogEntry
-
lookup
public java.util.Map lookup(java.util.Set lfns)
Retrieves multiple entries for a given logical filename, up to the complete catalog.- Specified by:
lookupin interfaceReplicaCatalog- Parameters:
lfns- is a set of logical filename strings to look up.- Returns:
- a map indexed by the LFN. Each value is a collection of replica catalog entries for the LFN.
- See Also:
ReplicaCatalogEntry
-
lookupNoAttributes
public java.util.Set lookupNoAttributes(java.lang.String lfn)
Retrieves all entries for a given LFN from the replica catalog.- Specified by:
lookupNoAttributesin interfaceReplicaCatalog- Parameters:
lfn- is the logical filename to obtain information for.- Returns:
- a set of PFN strings
-
lookupNoAttributes
public java.util.Map lookupNoAttributes(java.util.Set lfns)
Retrieves multiple entries for a given logical filename, up to the complete catalog.- Specified by:
lookupNoAttributesin interfaceReplicaCatalog- Parameters:
lfns- is a set of logical filename strings to look up.- Returns:
- a map indexed by the LFN. Each value is a set of PFN strings.
-
lookupNoAttributes
public java.util.Map lookupNoAttributes(java.util.Set lfns, java.lang.String handle)Retrieves multiple entries for a given logical filename, up to the complete catalog.- Specified by:
lookupNoAttributesin interfaceReplicaCatalog- Parameters:
lfns- is a set of logical filename strings to look up.handle- is the resource handle, restricting the LFNs.- Returns:
- a map indexed by the LFN. Each value is a set of physical filenames.
-
remove
public int remove(java.lang.String lfn)
Removes all mappings for an LFN from the replica catalog.- Specified by:
removein interfaceReplicaCatalog- Parameters:
lfn- is the logical filename to remove all mappings for.- Returns:
- the number of removed entries.
-
remove
public int remove(java.util.Set lfns)
Removes all mappings for a set of LFNs.- Specified by:
removein interfaceReplicaCatalog- Parameters:
lfns- is a set of logical filename to remove all mappings for.- Returns:
- the number of removed entries.
-
removeByAttribute
public int removeByAttribute(java.lang.String name, java.lang.Object value)Removes all entries from the replica catalog where the PFN attribute is found, and matches exactly the object value.- Specified by:
removeByAttributein interfaceReplicaCatalog- Parameters:
name- is the PFN attribute name to look for.value- is an exact match of the attribute value to match.- Returns:
- the number of removed entries.
-
removeByAttribute
public int removeByAttribute(java.lang.String handle)
Removes all entries associated with a particular resource handle.- Specified by:
removeByAttributein interfaceReplicaCatalog- Parameters:
handle- is the site handle to remove all entries for.- Returns:
- the number of removed entries.
- See Also:
ReplicaCatalog.removeByAttribute( String, Object )
-
-