public class Directory extends java.lang.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 java.lang.String |
DEFAULT_SITE_HANDLE
The default site handle to use.
|
static java.lang.String |
DEFAULT_URL_PREFIX
The default URL Prefix to use.
|
static java.lang.String |
DIRECTORY_PROPERTY_KEY
The name of the key that specifies the path to directory.
|
static java.lang.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 java.lang.String |
mDirectory
Records the name of the on-disk representation.
|
protected java.util.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 java.lang.String |
mSiteHandle
The site handle to use.
|
protected java.lang.String |
mURLPrefix
The URL prefix to use
|
static java.lang.String |
SITE_PROPERTY_KEY
The name of the key that specifies the site attribute to be associated
|
static java.lang.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(java.util.Properties props)
Establishes a connection to the database from the properties.
|
boolean |
connect(java.lang.String directory)
Does the file listing on the directory to create the mappings in memory.
|
int |
delete(java.util.Map x,
boolean matchAttributes)
Deletes multiple mappings into the replica catalog.
|
int |
delete(java.lang.String lfn,
ReplicaCatalogEntry tuple)
Deletes a very specific mapping from the replica catalog.
|
int |
delete(java.lang.String lfn,
java.lang.String pfn)
Deletes a specific mapping from the replica catalog.
|
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.
|
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.
|
private boolean |
hasMatchingAttr(ReplicaCatalogEntry rce,
java.lang.String name,
java.lang.Object value)
Looks for a match of an attribute value in a replica catalog
entry.
|
int |
insert(java.util.Map x)
Inserts multiple mappings into the replica catalog.
|
int |
insert(java.lang.String lfn,
ReplicaCatalogEntry tuple)
Inserts a new mapping into the replica catalog.
|
int |
insert(java.lang.String lfn,
java.lang.String pfn,
java.lang.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.
|
java.util.Set |
list()
Lists all logical filenames in the catalog.
|
java.util.Set |
list(java.lang.String constraint)
Lists a subset of all logical filenames in the catalog.
|
java.util.Map |
lookup(java.util.Map constraints)
Retrieves multiple entries for a given logical directory, up to the
complete catalog.
|
java.util.Map |
lookup(java.util.Set lfns)
Retrieves multiple entries for a given logical directory, up to the
complete catalog.
|
java.util.Map |
lookup(java.util.Set lfns,
java.lang.String handle)
Retrieves multiple entries for a given logical directory, up to the
complete catalog.
|
java.util.Collection |
lookup(java.lang.String lfn)
Retrieves all entries for a given LFN from the replica catalog.
|
java.lang.String |
lookup(java.lang.String lfn,
java.lang.String handle)
Retrieves the entry for a given directory and site handle from the
replica catalog.
|
java.util.Map |
lookupNoAttributes(java.util.Set lfns)
Retrieves multiple entries for a given logical directory, up to the
complete catalog.
|
java.util.Map |
lookupNoAttributes(java.util.Set lfns,
java.lang.String handle)
Retrieves multiple entries for a given logical directory, up to the
complete catalog.
|
java.util.Set |
lookupNoAttributes(java.lang.String lfn)
Retrieves all entries for a given LFN from the replica catalog.
|
static void |
main(java.lang.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(java.util.Set lfns)
Removes all mappings for a set of LFNs.
|
int |
remove(java.lang.String lfn)
Removes all mappings for an LFN from the replica catalog.
|
int |
removeByAttribute(java.lang.String handle)
Removes all entries associated with a particular resource handle.
|
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.
|
private void |
traverse(java.io.File directory,
java.lang.String prefix)
Traverses a directory and populates the mappings in memory
|
public static final java.lang.String DEFAULT_SITE_HANDLE
public static final java.lang.String DEFAULT_URL_PREFIX
public static final java.lang.String DIRECTORY_PROPERTY_KEY
public static final java.lang.String SITE_PROPERTY_KEY
public static final java.lang.String URL_PRFIX_PROPERTY_KEY
public static final java.lang.String FLAT_LFN_PROPERTY_KEY
protected java.lang.String mDirectory
protected java.util.Map mLFNMap
boolean mReadOnly
boolean mConstructFlatLFN
protected java.lang.String mSiteHandle
protected java.lang.String mURLPrefix
public Directory()
connect( Properties )public boolean connect(java.util.Properties props)
public boolean connect(java.lang.String directory)
directory - is the name of the file to read.private void traverse(java.io.File directory,
java.lang.String prefix)
directory - the directory to traverse.prefix - the LFN prefix to be appliedpublic void close()
public boolean isClosed()
close().public java.lang.String lookup(java.lang.String lfn,
java.lang.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 java.util.Collection lookup(java.lang.String lfn)
lookup in interface ReplicaCataloglfn - is the logical directory to obtain information for.ReplicaCatalogEntrypublic java.util.Set lookupNoAttributes(java.lang.String lfn)
lookupNoAttributes in interface ReplicaCataloglfn - is the logical directory to obtain information for.public java.util.Map lookup(java.util.Set lfns)
lookup in interface ReplicaCataloglfns - is a set of logical directory strings to look up.ReplicaCatalogEntrypublic java.util.Map lookupNoAttributes(java.util.Set lfns)
lookupNoAttributes in interface ReplicaCataloglfns - is a set of logical directory strings to look up.public java.util.Map lookup(java.util.Set lfns,
java.lang.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 java.util.Map lookupNoAttributes(java.util.Set lfns,
java.lang.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 java.util.Map lookup(java.util.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 java.util.Set list()
list in interface ReplicaCatalogpublic java.util.Set list(java.lang.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(java.lang.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(java.lang.String lfn,
java.lang.String pfn,
java.lang.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(java.util.Map x)
insert in interface ReplicaCatalogx - is a map from logical directory string to list of replica
catalog entries.ReplicaCatalogEntrypublic int delete(java.lang.String lfn,
java.lang.String pfn)
delete in interface ReplicaCataloglfn - is the logical directory in the tuple.pfn - is the physical directory in the tuple.public int delete(java.util.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(java.lang.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, java.lang.String name, java.lang.Object value)
rce - is the replica catalog entryname - is the attribute key to matchvalue - is the value to match againstpublic int delete(java.lang.String lfn,
java.lang.String name,
java.lang.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(java.lang.String lfn,
java.lang.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(java.lang.String lfn)
remove in interface ReplicaCataloglfn - is the logical directory to remove all mappings for.public int remove(java.util.Set lfns)
remove in interface ReplicaCataloglfns - is a set of logical directory to remove all mappings for.remove( String )public int removeByAttribute(java.lang.String name,
java.lang.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(java.lang.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(java.lang.String[] args)
args - the arguments