edu.isi.pegasus.planner.catalog.replica.impl
public class LRC extends Object implements ReplicaCatalog
| Modifier and Type | Class and Description |
|---|---|
private class |
LRC.MyRLSString2Bulk
The class that extends RLSString2Bulk and adds on the equals method,
that allows me to do the set operations
|
private class |
LRC.RLSAttributeComparator
The comparator that is used to group the RLSAttributeObject objects by the
value in the key field.
|
private class |
LRC.RLSString2BulkComparator
The comparator that is used to group the RLSString2Bulk objects by the
value in the s1 field.
|
private class |
LRC.RLSString2Comparator
The comparator that is used to group the
RLSString2 objects by the
value in the s1 field. |
| Modifier and Type | Field and Description |
|---|---|
static String |
DEFAULT_LRC_TIMEOUT
The default timeout in seconds to be used while querying the LRC.
|
static String |
LRC_NOT_CONNECTED_MSG
The error message for not connected to LRC.
|
static String |
LRC_SITE_TO_LRC_URL_KEY
The properties key that allow us to associate a site with a LRC URL,
and hence providing a value for the SITE_ATTRIBUTE.
|
static String |
LRC_TIMEOUT_KEY
The key that is used to get hold of the timeout value from the properties
object.
|
private int |
mBatchSize
The batch size while querying the LRC in the bulk mode.
|
private String |
mDefaultSiteAttribute
The default site attribute to be associated with the results.
|
private LogManager |
mLogger
The handle to the logging object.
|
private String |
mLogMsg
The string holding the message that is logged in the logger.
|
private org.globus.replica.rls.RLSClient.LRC |
mLRC
The handle to the client that allows access to the LRC running at the
url specified while connecting.
|
private String |
mLRCURL
The URL pointing to the LRC to which this instance of class talks to.
|
private org.globus.replica.rls.RLSClient |
mRLS
The handle to the client that allows access to the RLS running at the
url specified while connecting.
|
private int |
mTimeout
The timeout in seconds while querying to the LRC.
|
static String |
PROXY_KEY
The key that if set, specifies the proxy to be picked up while connecting
to the RLS.
|
static int |
RLS_BULK_QUERY_SIZE
The number of entries searched in each bulk query to RLS.
|
static String |
RLS_TIMEOUT_KEY
The key that is used to get hold of the timeout value from the properties
object.
|
static String |
SITE_ATTRIBUTE
The attribute in RLS that maps to a site handle.
|
static String |
UNDEFINED_SITE
The undefined pool attribute value.
|
static String |
URL_KEY
The key that is used to get hold of the url from the properties object.
|
BATCH_KEY, c_prefix, DB_PREFIXDB_ALL_PREFIX| Constructor and Description |
|---|
LRC()
The default constructor, that creates an object which is not linked with
any RLS.
|
| Modifier and Type | Method and Description |
|---|---|
private int |
bulkDelete(List lfnPfns)
Calls the bulk delete on the mappings.
|
private int |
bulkInsert(List lfnPfns,
Map attrMap)
Calls the bulk insert on the mappings.
|
private Map |
bulkLookup(Set lfns,
String attrKey)
Retrieves multiple entries for a given logical filename, up to the
complete LRC.
|
private Map |
bulkLookup(Set lfns,
String attrKey,
Object attrVal)
Retrieves multiple entries for a given logical filename, up to the
complete LRC.
|
private Map |
bulkLookupNoAttributes(Set lfns)
Retrieves multiple entries for a given logical filename, up to the
complete LRC.
|
int |
clear()
Removes everything.
|
void |
close()
Explicitely free resources before the garbage collection hits.
|
boolean |
connect(Properties props)
Establishes a connection to the LRC.
|
boolean |
connect(String url)
Establishes a connection to the LRC, picking up the proxy from the default
location usually /tmp/ directory.
|
boolean |
connect(String url,
String proxy)
Establishes a connection to the LRC.
|
private org.globus.replica.rls.RLSString2Bulk |
convert(org.globus.replica.rls.RLSString2 obj)
A helper method that converts RLSString2 to MyRLSString2Bulk object.
|
private String |
defaultResourceHandle()
Returns the default value that is to be assigned to site handle
for a replica catalog entry.
|
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 ReplicaCatalogException |
exception(org.globus.replica.rls.RLSString2Bulk rs)
Constructs an exception from the
RLSString2Bulk object. |
private ReplicaCatalogException |
exception(String prefix,
org.globus.replica.rls.RLSException e)
Constructs replica catalog exception out the RLSException that is
thrown by the API underneath.
|
private String |
getAttribute(org.globus.replica.rls.RLSClient.LRC lrc,
String pfn,
String name)
Retrieves from the lrc, the attribute value associated with the
pfn
for a given attribute name. |
private String |
getAttribute(String pfn,
String name)
Retrieves from the lrc associated with this instance all, the attribute
value associated with the
pfn for a given attribute name. |
private Map |
getAttributes(List lfnPfns,
String attrKey,
Object attrVal)
Retrieves from the lrc associated with this instance, all the
attributes associated with the lfn-pfns in a map indexed by the lfn.
|
private Map |
getAttributes(org.globus.replica.rls.RLSClient.LRC lrc,
String pfn)
Retrieves from the lrc, all the attributes associated with the
pfn
in a map. |
private Map |
getAttributes(String pfn)
Retrieves from the lrc, associated with this instance all the
attributes associated with the
pfn in a map. |
private Object |
getAttributeValue(org.globus.replica.rls.RLSAttribute attr)
Retrieves the attribute value as an object from the
RLSAttribute
object. |
private int |
getBatchSize()
Returns the number of lfns in each batch while querying the lrc in the
bulk mode.
|
org.globus.replica.rls.RLSClient.LRC |
getLRC()
Gets a handle to the LRC that is associated with the RLS running at
url.
|
private String |
getSiteHandle(org.globus.replica.rls.RLSClient.LRC lrc,
String pfn)
Returns the site handle associated with a pfn at the lrc associated
with the
RLSClient passed. |
private String |
getSiteHandle(String pfn)
Returns the site handle associated with the pfn at the lrc to which
the instance of this application binds.
|
protected int |
getTimeout(Properties properties)
It returns the timeout value in seconds after which to timeout in case of
no activity from the LRC.
|
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()
Returns whether the connection to the RLS with which this instance is
associated is closed or not.
|
Set |
list()
Lists all logical filenames in the catalog.
|
Set |
list(String constraint)
Lists a subset of all logical filenames in the catalog.
|
List |
listLFNPFN(String constraint,
boolean lfnConstraint)
Lists a subset of all LFN,PFN pairs in the catalog matching to
a pfn or a lfn constraint.
|
private void |
log(String message,
Exception e,
int level)
Logs to the logger object.
|
private void |
log(String message,
int level)
Logs to the logger object.
|
Map |
lookup(Map constraints)
Retrieves multiple entries for a given logical filename, up to the
complete catalog.
|
Map |
lookup(Set lfns)
Retrieves multiple entries for a given logical filename, up to the
complete LRC.
|
Map |
lookup(Set lfns,
String handle)
Retrieves multiple entries for a given logical filename, up to the
complete LRC.
|
Map |
lookup(Set lfns,
String name,
Object value)
Retrieves multiple entries for a given logical filename, up to the
complete LRC.
|
Collection |
lookup(String lfn)
Retrieves all entries for a given LFN from the LRC.
|
String |
lookup(String lfn,
String handle)
Retrieves the entry for a given filename and resource handle from
the LRC.
|
List |
lookupLFNPFN(Map constraints)
Retrieves multiple entries for a given logical filename, up to the
complete catalog.
|
Map |
lookupNoAttributes(Set lfns)
Retrieves multiple entries for a given logical filename, up to the
complete catalog.
|
Map |
lookupNoAttributes(Set lfns,
String handle)
Retrieves multiple entries for a given logical filename, up to the
complete catalog.
|
Map |
lookupNoAttributes(Set lfns,
String name,
Object value)
Retrieves multiple entries for a given logical filename, 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)
Testing function.
|
int |
remove(Set lfns)
Removes all mappings for a set of LFNs.
|
int |
remove(String lfn)
Removes all mappings for a set of LFNs.
|
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 |
setBatchSize(Properties properties)
Sets the number of lfns in each batch while querying the lrc in the
bulk mode.
|
private void |
setResourceHandle(Map<String,String> m)
Sets the resource handle in an attribute map.
|
private void |
setResourceHandle(ReplicaCatalogEntry rce)
Sets the resource handle in an attribute map.
|
private Set |
subset(Collection collection,
String name,
Object value)
Returns a subset of a collection of
ReplicaCatalogEntry
objects that have attributes matchin to the attribute identified by
the parameters passed. |
private Set |
subset(Collection collection,
String name,
Object value,
boolean onlyPFN)
Returns a subset of a collection of
ReplicaCatalogEntry
objects that have attributes matchin to the attribute identified by
the parameters passed. |
public static final int RLS_BULK_QUERY_SIZE
public static final String DEFAULT_LRC_TIMEOUT
public static final String RLS_TIMEOUT_KEY
public static final String LRC_TIMEOUT_KEY
public static final String LRC_SITE_TO_LRC_URL_KEY
public static final String SITE_ATTRIBUTE
public static final String UNDEFINED_SITE
public static final String URL_KEY
public static final String PROXY_KEY
public static final String LRC_NOT_CONNECTED_MSG
private LogManager mLogger
private String mLogMsg
private String mLRCURL
private org.globus.replica.rls.RLSClient mRLS
private org.globus.replica.rls.RLSClient.LRC mLRC
private int mBatchSize
private int mTimeout
private String mDefaultSiteAttribute
public LRC()
connect(Properties).public boolean connect(Properties props)
public boolean connect(String url)
url - the url to lrc to connect to.public boolean connect(String url, String proxy)
url - the url to lrc to connect to.proxy - the path to the proxy file to be picked up. null denotes
default location.ReplicaCatalogException - in case ofpublic org.globus.replica.rls.RLSClient.LRC getLRC()
RLSClient.LRC that points to the RLI that is
running , or null in case connect method not being called.mLRCURLpublic String lookup(String lfn, String handle)
lookup in interface ReplicaCataloglfn - is the logical filename to obtain information for.handle - is the resource handle to obtain entries for.null if no match was found.ReplicaCatalogException - in case of any error that is throw by LRC
that can't be handled.public Collection lookup(String lfn) throws ReplicaCatalogException
lookup in interface ReplicaCataloglfn - is the logical filename to obtain information for.ReplicaCatalogException - in case of any error that is throw by LRC
that can't be handled.ReplicaCatalogEntrypublic Set lookupNoAttributes(String lfn)
lookupNoAttributes in interface ReplicaCataloglfn - is the logical filename to obtain information for.public Map lookup(Set lfns) throws ReplicaCatalogException
lookup in interface ReplicaCataloglfns - is a set of logical filename strings to look up.ReplicaCatalogExceptionReplicaCatalogEntry,
getBatchSize()public Map lookup(Set lfns, String handle)
noAttributes flag is missing on purpose, because
due to the resource handle, attribute lookups are already required.lookup in interface ReplicaCataloglfns - is a set of logical filename strings to look up.handle - is the resource handle, restricting the LFNs.ReplicaCatalogEntrypublic Map lookup(Set lfns, String name, Object value)
lfns - is a set of logical filename strings to look up.name - is the name of the attribute.value - is the value of the attribute.ReplicaCatalogEntrypublic Map lookupNoAttributes(Set lfns)
lookupNoAttributes in interface ReplicaCataloglfns - is a set of logical filename strings to look up.public Map lookupNoAttributes(Set lfns, String handle)
lookupNoAttributes in interface ReplicaCataloglfns - is a set of logical filename strings to look up.handle - is the resource handle, restricting the LFNs.public Map lookupNoAttributes(Set lfns, String name, Object value)
lfns - is a set of logical filename strings to look up.name - is the PFN attribute name to look for.value - is an exact match of the attribute value to match.public Map lookup(Map constraints) throws ReplicaCatalogException
At present it DOES NOT SUPPORT ATTRIBUTE MATCHING.
lookup in interface ReplicaCatalogconstraints - is mapping of keys 'lfn', 'pfn', 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.ReplicaCatalogExceptionReplicaCatalogEntrypublic List lookupLFNPFN(Map constraints)
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.MyRLSString2Bulk objects containing
the lfn in s1 field, and pfn in s2 field. The list is
grouped by lfns. The set may be empty.public Set list()
list in interface ReplicaCatalogpublic Set list(String constraint)
list in interface ReplicaCatalogconstraint - 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.public List listLFNPFN(String constraint, boolean lfnConstraint) throws ReplicaCatalogException
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.MyRLSString2Bulk objects containing
the lfn in s1 field, and pfn in s2 field. The list is
grouped by lfns. The set may be empty.ReplicaCatalogExceptiongetAttributes(List,String,Object)public int insert(Map x)
insert in interface ReplicaCatalogx - is a map from logical filename string to list of replica
catalog entries.ReplicaCatalogEntryprivate int bulkDelete(List lfnPfns) throws ReplicaCatalogException
lfnPfns - list of RLSString2 objects containing the
lfn pfn mappings to be deleted.ReplicaCatalogException - in case of errorprivate int bulkInsert(List lfnPfns, Map attrMap)
lfnPfns - list of RLSString2 objects containing the
lfn pfn mappings to be inserted.attrMap - a map indexed by pfn and values as RLSAttributeObject objects.ReplicaCatalogException - in case of errorpublic int insert(String lfn, ReplicaCatalogEntry tuple)
insert in interface ReplicaCataloglfn - is the logical filename under which to book the entry.tuple - is the physical filename 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 filename under which to book the entry.pfn - is the physical filename associated with it.handle - is a resource handle where the PFN resides.insert( String, ReplicaCatalogEntry ),
ReplicaCatalogEntrypublic int delete(Map x, boolean matchAttributes)
delete in interface ReplicaCatalogx - is a map from logical filename string to list of
replica catalog entries.matchAttributes - whether mapping should be deleted only if all
attributes match.ReplicaCatalogEntrypublic int delete(String lfn, String pfn)
delete in interface ReplicaCataloglfn - is the logical filename in the tuple.pfn - is the physical filename in the tuple.public int delete(String lfn, ReplicaCatalogEntry tuple)
delete in interface ReplicaCataloglfn - is the logical filename in the tuple.tuple - is a description of the PFN and its attributes.public int delete(String lfn, String name, Object value)
delete in interface ReplicaCataloglfn - 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.public int deleteByResource(String lfn, String handle)
delete( lfn, SITE_ATTRIBUTE, handle )
deleteByResource in interface ReplicaCataloglfn - is the logical filename to look for.handle - is the resource handleSITE_ATTRIBUTEpublic int remove(String lfn)
remove in interface ReplicaCataloglfn - is a set of logical filename to remove all mappings for.public int remove(Set lfns)
remove in interface ReplicaCataloglfns - is a set of logical filename to remove all mappings for.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 removeByAttribute(String name, Object value)
removeByAttribute in interface ReplicaCatalogname - is the PFN attribute name to look for.value - is an exact match of the attribute value to match.public int clear()
clear in interface ReplicaCatalogpublic void close()
public boolean isClosed()
protected int getTimeout(Properties properties)
DEFAULT_LRC_TIMEOUTprivate String getSiteHandle(String pfn)
UNDEFINED_SITE
even when the pfn is not in the lrc.pfn - The pfn with which the attribute is associated.private String getSiteHandle(org.globus.replica.rls.RLSClient.LRC lrc, String pfn)
RLSClient passed. It returns UNDEFINED_SITE
even when the pfn is not in the lrc.lrc - the handle to the lrc , where the attributes are stored.pfn - the pfn with which the attribute is associated.private String defaultResourceHandle()
private void setResourceHandle(Map<String,String> m)
m - the attribute map.defaultResourceHandle()private void setResourceHandle(ReplicaCatalogEntry rce)
rce - the ReplicaCatalogEntrydefaultResourceHandle()private Map getAttributes(String pfn)
pfn in a map. All the
attribute values are stored as String.pfn - the pfn with which the attribute is associated.Mapcontaining the attribute keys and values,
else an empty Map.private Map getAttributes(List lfnPfns, String attrKey, Object attrVal)
ReplicaCatalogEntry objects.
All the attribute values are stored as String.
If the attribute value passed is not null, then explicit matching occurs
on attribute values in addition.lfnPfns - a list of RLSString2Bulk objects containing
the lfn in s1 field, and pfn in s2 field. The list is
assumed to be grouped by lfns.attrKey - the name of attribute that needs to be queried for each
pfn. a value of null denotes all attributes.attrVal - the value of the attribute that should be matching.private Map getAttributes(org.globus.replica.rls.RLSClient.LRC lrc, String pfn)
pfn
in a map. All the attribute values are stored as String.lrc - the handle to the lrc , where the attributes are stored.pfn - the pfn with which the attribute is associated.Mapcontaining the attribute keys and values,
else an empty Map.private String getAttribute(String pfn, String name)
pfn for a given attribute name.pfn - the pfn with which the attribute is associated.name - the name of the attribute for which we want to search.private String getAttribute(org.globus.replica.rls.RLSClient.LRC lrc, String pfn, String name)
pfn
for a given attribute name.lrc - the handle to the lrc , where the attributes are stored.pfn - the pfn with which the attribute is associated.name - the name of the attribute for which we want to search.private Object getAttributeValue(org.globus.replica.rls.RLSAttribute attr)
RLSAttribute
object. Does automatic boxing (i.e converts int to Integer) etc.
The value is returned of the type as determined from the internal value
type.attr - the RLSAttribute from which to extract the value.ReplicaCatalogException - if illegal value associated.private void setBatchSize(Properties properties)
properties - the properties passed while connecting.private int getBatchSize()
private Map bulkLookup(Set lfns, String attrKey)
ReplicaCatalogEntry objects
that have the attribute identified by attribute key passed.lfns - set of logical filename strings to look up.attrKey - the name of attribute that needs to be queried for each
pfn. a value of null denotes all attributes.ReplicaCatalogEntry,
lookup(Set)private Map bulkLookup(Set lfns, String attrKey, Object attrVal)
ReplicaCatalogEntry objects that have
the attribute identified by attribute key passed.lfns - set of logical filename strings to look up.attrKey - the name of attribute that needs to be queried for each
pfn. a value of null denotes all attributes.attrVal - the value of the attribute that should be matching.ReplicaCatalogEntry,
lookup(Set)private Map bulkLookupNoAttributes(Set lfns)
lfns - is a set of logical filename strings to look up.lookupNoAttributes(Set)private ReplicaCatalogException exception(String prefix, org.globus.replica.rls.RLSException e)
prefix - the prefix that is to be applied to the message
passed while creating the exception.e - the RLSException that is caught underneath.private ReplicaCatalogException exception(org.globus.replica.rls.RLSString2Bulk rs)
RLSString2Bulk object.private Set subset(Collection collection, String name, Object value)
ReplicaCatalogEntry
objects that have attributes matchin to the attribute identified by
the parameters passed.collection - the collection of ReplicaCatalogEntry
objects.name - the attribute name to match.value - the attribute value.ReplicaCatalogEntry objects.private Set subset(Collection collection, String name, Object value, boolean onlyPFN)
ReplicaCatalogEntry
objects that have attributes matchin to the attribute identified by
the parameters passed.collection - the collection of ReplicaCatalogEntry
objects.name - the attribute name to match.value - the attribute value.onlyPFN - boolean to denote if we only want the PFN'sReplicaCatalogEntry objects if onlyPfn
parameter is set to false, else a Set of pfns.private org.globus.replica.rls.RLSString2Bulk convert(org.globus.replica.rls.RLSString2 obj)
obj - the RLSString2 to convert.MyRLSString2 object.private void log(String message, int level)
message - the message to be logged.level - the logger level at which the message is to be logged.private void log(String message, Exception e, int level)
message - the message to be logged.e - the exception that occured.level - the logger level at which the message is to be logged.public static void main(String[] args)