edu.isi.pegasus.planner.catalog.replica.impl
public class SimpleFile extends Object implements ReplicaCatalog
The site attribute should be specified whenever possible. The attribute key for the site attribute is "pool". For the shell planner, its value will always be "local".
The class is permissive in what inputs it accepts. The LFN may or may not be quoted. If it contains linear whitespace, quotes, backslash or an equality sign, it must be quoted and escaped. Ditto for the PFN. The attribute key-value pairs are separated by an equality sign without any whitespaces. The value may be in quoted. The LFN sentiments about quoting apply.
LFN PFN LFN PFN a=b [..] LFN PFN a="b" [..] "LFN w/LWS" "PFN w/LWS" [..]The class is strict when producing (storing) results. The LFN and PFN are only quoted and escaped, if necessary. The attribute values are always quoted and escaped.
Modifier and Type | Field and Description |
---|---|
private static short[][] |
c_action
Contains the actions to perform upon each state transition including
transition into self state.
|
private static String[] |
c_final
Provides the final states and associated messages.
|
private static short[][] |
c_state
Contains the state transition tables.
|
protected String |
m_filename
Records the name of the on-disk representation.
|
protected Map |
m_lfn
Maintains a memory slurp of the file representation.
|
protected boolean |
m_quote
Records the quoting mode for LFNs and PFNs.
|
(package private) boolean |
m_readonly
A boolean indicating whether the catalog is read only or not.
|
static String |
READ_ONLY_KEY
The name of the key that disables writing back to the cache file.
|
BATCH_KEY, c_prefix, DB_PREFIX, PROXY_KEY
DB_ALL_PREFIX
Constructor and Description |
---|
SimpleFile()
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 filename)
Reads the on-disk map file into 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 filename, up to the
complete catalog.
|
Map |
lookup(Set lfns)
Retrieves multiple entries for a given logical filename, up to the
complete catalog.
|
Map |
lookup(Set lfns,
String handle)
Retrieves multiple entries for a given logical filename, 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 filename and site handle from the
replica 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.
|
Set |
lookupNoAttributes(String lfn)
Retrieves all entries for a given LFN from the replica catalog.
|
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.
|
boolean |
parse(String line,
int lineno)
Parses a line from the file replica catalog
|
String |
quote(Escape e,
String s)
Quotes a string only if necessary.
|
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.
|
public static final String READ_ONLY_KEY
protected boolean m_quote
protected String m_filename
protected Map m_lfn
boolean m_readonly
private static final String[] c_final
---+----+-------------------- F1 | 17 | final state, no record F2 | 16 | final state, valid record E1 | 18 | premature end E2 | 19 | illegal character E3 | 20 | incomplete record E4 | 21 | unterminated string
private static final short[][] c_state
| EOS | lws | = | "" | \\ | else| -----+-----+-----+-----+-----+-----+-----+-------------- 0 | F1,-| 0,-| E2 | 3,-| E2 | 1,Sl| skip initial ws a 1 | E3 | 2,Fl| E2 | E2 | E2 | 1,Sl| LFN w/o quotes 2 | E3 | 2,-| E2 | 6,-| E2 | 5,Sp| skip ws between LFN and PFN b 3 | E4 | 3,Sl| 3,Sl| 2,Fl| 4,-| 3,Sl| LFN in quotes c 4 | E4 | 3,Sl| 3,Sl| 3,Sl| 3,Sl| 3,Sl| LFN backslash escape -----+-----+-----+-----+-----+-----+-----+-------------- a 5 |F2,Fp| 8,Fp| E2 | E2 | E2 | 5,Sp| PFN w/o quotes b 6 | E4 | 6,Sp| 6,Sp| 8,Fp| 7,-| 6,Sp| PFN in quotes c 7 | E4 | 6,Sp| 6,Sp| 6,Sp| 6,Sp| 6,Sp| PFN backslash escape 8 | F2,-| 8,-| E2 | E2 | E2 | 9,Sk| skip ws before attributes 9 | E1 | E2 |10,Fk| E2 | E2 | 9,Sk| attribute key 10 | E1 | E2 | E2 | 12,-| E2 |11,Sv| equals sign -----+-----+-----+-----+-----+-----+-----+-------------- a 11 |F2,Fv| 8,Fv| E2 | E2 | E2 |11,Sv| value w/o quotes b 12 | E4 |12,Sv|12,Sv| 8,Fv| 13,-|12,Sv| value in quotes c 13 | E4 |12,Sv|12,Sv|12,Sv|12,Sv|12,Sv| value backslash escape
private static final short[][] c_action
| | ---+---+------------------------------------------- - | 0 | no op S*| 1 | append to sb Fl| 2 | lfn := sb Fp| 3 | pfn := sb Fk| 4 | key := sb Fv| 5 | value := sb
public SimpleFile()
connect( Properties )
public boolean parse(String line, int lineno)
line
- is the line to parselineno
- is the line number of this linepublic boolean connect(String filename)
filename
- is the name of the file to read.public boolean connect(Properties props)
public String quote(Escape e, String s)
However, if the property "quote" had a true
value
when connecting to the database, output will always be quoted.
e
- is the Escape instance used to escape strings.s
- is the string that may require quotingpublic void close()
public boolean isClosed()
close()
.public String lookup(String lfn, String handle)
lookup
in interface ReplicaCatalog
lfn
- is the logical filename 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 ReplicaCatalog
lfn
- is the logical filename to obtain information for.ReplicaCatalogEntry
public Set lookupNoAttributes(String lfn)
lookupNoAttributes
in interface ReplicaCatalog
lfn
- is the logical filename to obtain information for.public Map lookup(Set lfns)
lookup
in interface ReplicaCatalog
lfns
- is a set of logical filename strings to look up.org.griphyn.common.catalog.ReplicaCatalogEntry
public Map lookupNoAttributes(Set lfns)
lookupNoAttributes
in interface ReplicaCatalog
lfns
- is a set of logical filename strings to look up.public Map lookup(Set lfns, String handle)
lookup
in interface ReplicaCatalog
lfns
- is a set of logical filename strings to look up.handle
- is the resource handle, restricting the LFNs.ReplicaCatalogEntry
public Map lookupNoAttributes(Set lfns, String handle)
lookupNoAttributes
in interface ReplicaCatalog
lfns
- is a set of logical filename strings to look up.handle
- is the resource handle, restricting the LFNs.public Map lookup(Map constraints)
lookup
in interface ReplicaCatalog
constraints
- 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.ReplicaCatalogEntry
public Set list()
list
in interface ReplicaCatalog
public Set list(String constraint)
list
in interface ReplicaCatalog
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.public int insert(String lfn, ReplicaCatalogEntry tuple)
insert
in interface ReplicaCatalog
lfn
- 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 ReplicaCatalog
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.insert( String, ReplicaCatalogEntry )
,
ReplicaCatalogEntry
public int insert(Map x)
insert
in interface ReplicaCatalog
x
- is a map from logical filename string to list of replica
catalog entries.org.griphyn.common.catalog.ReplicaCatalogEntry
public int delete(String lfn, String pfn)
delete
in interface ReplicaCatalog
lfn
- is the logical filename in the tuple.pfn
- is the physical filename in the tuple.public int delete(Map x, boolean matchAttributes)
delete
in interface ReplicaCatalog
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.ReplicaCatalogEntry
private 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 ReplicaCatalog
lfn
- is the logical filename 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 ReplicaCatalog
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.public int deleteByResource(String lfn, String handle)
delete( lfn, RESOURCE_HANDLE, handle )
deleteByResource
in interface ReplicaCatalog
lfn
- is the logical filename to look for.handle
- is the resource handlepublic int remove(String lfn)
remove
in interface ReplicaCatalog
lfn
- is the logical filename to remove all mappings for.public int remove(Set lfns)
remove
in interface ReplicaCatalog
lfns
- is a set of logical filename to remove all mappings for.remove( String )
public int removeByAttribute(String name, Object value)
removeByAttribute
in interface ReplicaCatalog
name
- 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 ReplicaCatalog
handle
- is the site handle to remove all entries for.removeByAttribute( String, Object )
public int clear()
clear
in interface ReplicaCatalog