edu.isi.pegasus.planner.catalog.replica.impl
public class Directory extends Object implements ReplicaCatalog
pegasus.catalog.replica.directory.site
The URL prefix for the PFN's defaults to file:// unless specified in Pegasus
Properties by specifying the property
pegasus.catalog.replica.directory.url.prefix
By default, deep LFN's are constructed while traversing through the directory,
unless the following property is set to true
pegasus.catalog.replica.directory.flat.lfn
| Modifier and Type | Field and Description |
|---|---|
static String |
DEFAULT_SITE_HANDLE
The default site handle to use.
|
static String |
DEFAULT_URL_PREFIX
The default URL Prefix to use.
|
static String |
DIRECTORY_PROPERTY_KEY
The name of the key that specifies the path to directory.
|
static String |
FLAT_LFN_PROPERTY_KEY
the name of the key that specifies whether we want flat lfns or not.
|
(package private) boolean |
mConstructFlatLFN
A boolean indicating whether the catalog is to construct flat lfns or not
|
protected String |
mDirectory
Records the name of the on-disk representation.
|
protected Map |
mLFNMap
Maintains a memory slurp of the file representation.
|
(package private) boolean |
mReadOnly
A boolean indicating whether the catalog is read only or not.
|
protected String |
mSiteHandle
The site handle to use.
|
protected String |
mURLPrefix
The URL prefix to use
|
static String |
SITE_PROPERTY_KEY
The name of the key that specifies the site attribute to be associated
|
static String |
URL_PRFIX_PROPERTY_KEY
The name of the key that specifies the url prefix to be associated with the PFN's
|
BATCH_KEY, c_prefix, DB_PREFIX, PROXY_KEYDB_ALL_PREFIX| Constructor and Description |
|---|
Directory()
Default empty constructor creates an object that is not yet connected
to any database.
|
| Modifier and Type | Method and Description |
|---|---|
int |
clear()
Removes everything.
|
void |
close()
This operation will dump the in-memory representation back onto
disk.
|
boolean |
connect(Properties props)
Establishes a connection to the database from the properties.
|
boolean |
connect(String directory)
Does the file listing on the directory to create the mappings in memory.
|
int |
delete(Map x,
boolean matchAttributes)
Deletes multiple mappings into the replica catalog.
|
int |
delete(String lfn,
ReplicaCatalogEntry tuple)
Deletes a very specific mapping from the replica catalog.
|
int |
delete(String lfn,
String pfn)
Deletes a specific mapping from the replica catalog.
|
int |
delete(String lfn,
String name,
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.
|
int |
deleteByResource(String lfn,
String handle)
Deletes all PFN entries for a given LFN from the replica catalog
where the resource handle is found.
|
private boolean |
hasMatchingAttr(ReplicaCatalogEntry rce,
String name,
Object value)
Looks for a match of an attribute value in a replica catalog
entry.
|
int |
insert(Map x)
Inserts multiple mappings into the replica catalog.
|
int |
insert(String lfn,
ReplicaCatalogEntry tuple)
Inserts a new mapping into the replica catalog.
|
int |
insert(String lfn,
String pfn,
String handle)
Inserts a new mapping into the replica catalog.
|
boolean |
isClosed()
Predicate to check, if the connection with the catalog's
implementation is still active.
|
Set |
list()
Lists all logical filenames in the catalog.
|
Set |
list(String constraint)
Lists a subset of all logical filenames in the catalog.
|
Map |
lookup(Map constraints)
Retrieves multiple entries for a given logical directory, up to the
complete catalog.
|
Map |
lookup(Set lfns)
Retrieves multiple entries for a given logical directory, up to the
complete catalog.
|
Map |
lookup(Set lfns,
String handle)
Retrieves multiple entries for a given logical directory, up to the
complete catalog.
|
Collection |
lookup(String lfn)
Retrieves all entries for a given LFN from the replica catalog.
|
String |
lookup(String lfn,
String handle)
Retrieves the entry for a given directory and site handle from the
replica catalog.
|
Map |
lookupNoAttributes(Set lfns)
Retrieves multiple entries for a given logical directory, up to the
complete catalog.
|
Map |
lookupNoAttributes(Set lfns,
String handle)
Retrieves multiple entries for a given logical directory, up to the
complete catalog.
|
Set |
lookupNoAttributes(String lfn)
Retrieves all entries for a given LFN from the replica catalog.
|
static void |
main(String[] args)
The main program
|
private boolean |
matchMe(ReplicaCatalogEntry full,
ReplicaCatalogEntry part)
Attempts to see, if all keys in the partial replica catalog entry are
contained in the full replica catalog entry.
|
int |
remove(Set lfns)
Removes all mappings for a set of LFNs.
|
int |
remove(String lfn)
Removes all mappings for an LFN from the replica catalog.
|
int |
removeByAttribute(String handle)
Removes all entries associated with a particular resource handle.
|
int |
removeByAttribute(String name,
Object value)
Removes all entries from the replica catalog where the PFN attribute
is found, and matches exactly the object value.
|
private void |
traverse(File directory,
String prefix)
Traverses a directory and populates the mappings in memory
|
public static final String DEFAULT_SITE_HANDLE
public static final String DEFAULT_URL_PREFIX
public static final String DIRECTORY_PROPERTY_KEY
public static final String SITE_PROPERTY_KEY
public static final String URL_PRFIX_PROPERTY_KEY
public static final String FLAT_LFN_PROPERTY_KEY
protected String mDirectory
protected Map mLFNMap
boolean mReadOnly
boolean mConstructFlatLFN
protected String mSiteHandle
protected String mURLPrefix
public Directory()
connect( Properties )public boolean connect(Properties props)
public boolean connect(String directory)
directory - is the name of the file to read.private void traverse(File directory, String prefix)
directory - the directory to traverse.prefix - the LFN prefix to be appliedpublic void close()
public boolean isClosed()
close().public String lookup(String lfn, String handle)
lookup in interface ReplicaCataloglfn - is the logical directory to obtain information for.handle - is the resource handle to obtain entries for.null if no match was found.public Collection lookup(String lfn)
lookup in interface ReplicaCataloglfn - is the logical directory to obtain information for.ReplicaCatalogEntrypublic Set lookupNoAttributes(String lfn)
lookupNoAttributes in interface ReplicaCataloglfn - is the logical directory to obtain information for.public Map lookup(Set lfns)
lookup in interface ReplicaCataloglfns - is a set of logical directory strings to look up.ReplicaCatalogEntrypublic Map lookupNoAttributes(Set lfns)
lookupNoAttributes in interface ReplicaCataloglfns - is a set of logical directory strings to look up.public Map lookup(Set lfns, String handle)
lookup in interface ReplicaCataloglfns - is a set of logical directory strings to look up.handle - is the resource handle, restricting the LFNs.ReplicaCatalogEntrypublic Map lookupNoAttributes(Set lfns, String handle)
lookupNoAttributes in interface ReplicaCataloglfns - is a set of logical directory strings to look up.handle - is the resource handle, restricting the LFNs.public Map lookup(Map constraints)
lookup in interface ReplicaCatalogconstraints - is mapping of keys 'lfn', 'pfn', or any
attribute name, e.g. the resource handle 'pool', 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.ReplicaCatalogEntrypublic Set list()
list in interface ReplicaCatalogpublic Set list(String constraint)
list in interface ReplicaCatalogconstraint - is a constraint for the logical directory 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.public int insert(String lfn, ReplicaCatalogEntry tuple)
insert in interface ReplicaCataloglfn - is the logical directory under which to book the entry.tuple - is the physical directory and associated PFN attributes.public int insert(String lfn, String pfn, String handle)
ReplicaCatalogEntry element will be contructed, and
passed to the appropriate insert function.insert in interface ReplicaCataloglfn - is the logical directory under which to book the entry.pfn - is the physical directory associated with it.handle - is a resource handle where the PFN resides.insert( String, ReplicaCatalogEntry ),
ReplicaCatalogEntrypublic int insert(Map x)
insert in interface ReplicaCatalogx - is a map from logical directory string to list of replica
catalog entries.ReplicaCatalogEntrypublic int delete(String lfn, String pfn)
delete in interface ReplicaCataloglfn - is the logical directory in the tuple.pfn - is the physical directory in the tuple.public int delete(Map x, boolean matchAttributes)
delete in interface ReplicaCatalogx - is a map from logical directory string to list of
replica catalog entries.matchAttributes - whether mapping should be deleted only if all
attributes match.ReplicaCatalogEntryprivate boolean matchMe(ReplicaCatalogEntry full, ReplicaCatalogEntry part)
full - is the full entry to check against.part - is the partial entry to check with.public int delete(String lfn, ReplicaCatalogEntry tuple)
delete in interface ReplicaCataloglfn - is the logical directory in the tuple.tuple - is a description of the PFN and its attributes.private boolean hasMatchingAttr(ReplicaCatalogEntry rce, String name, Object value)
rce - is the replica catalog entryname - is the attribute key to matchvalue - is the value to match againstpublic int delete(String lfn, String name, Object value)
delete in interface ReplicaCataloglfn - is the logical directory to look for.name - is the PFN attribute name to look for.value - is an exact match of the attribute value to match.public int deleteByResource(String lfn, String handle)
delete( lfn, RESOURCE_HANDLE, handle )
deleteByResource in interface ReplicaCataloglfn - is the logical directory to look for.handle - is the resource handlepublic int remove(String lfn)
remove in interface ReplicaCataloglfn - is the logical directory to remove all mappings for.public int remove(Set lfns)
remove in interface ReplicaCataloglfns - is a set of logical directory to remove all mappings for.remove( String )public int removeByAttribute(String name, Object value)
removeByAttribute in interface ReplicaCatalogname - is the PFN attribute key to look for.value - is an exact match of the attribute value to match.public int removeByAttribute(String handle)
removeByAttribute method.removeByAttribute in interface ReplicaCataloghandle - is the site handle to remove all entries for.removeByAttribute( String, Object )public int clear()
clear in interface ReplicaCatalogpublic static void main(String[] args)
args - the arguments