public class Regex extends java.lang.Object implements ReplicaCatalog
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 java.lang.String[] |
c_final
Provides the final states and associated messages.
|
private static short[][] |
c_state
Contains the state transition tables.
|
protected java.lang.String |
m_filename
Records the name of the on-disk representation.
|
protected java.util.Map<java.lang.String,java.util.Collection<ReplicaCatalogEntry>> |
m_lfn
Maintains a memory slurp of the file representation.
|
protected java.util.Map<java.lang.String,java.util.regex.Pattern> |
m_lfn_pattern |
protected java.util.Map<java.lang.String,java.util.Collection<ReplicaCatalogEntry>> |
m_lfn_regex |
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 java.lang.String |
READ_ONLY_KEY
The name of the key that disables writing back to the cache file.
|
static java.lang.String |
REGEX_KEY |
BATCH_KEY, c_prefix, DB_PREFIX, PROXY_KEYDB_ALL_PREFIX| Constructor and Description |
|---|
Regex()
Default empty constructor creates an object that is not yet connected to
any database.
|
| Modifier and Type | Method and Description |
|---|---|
int |
clear()
Removes everything.
|
private ReplicaCatalogEntry |
cloneRCE(ReplicaCatalogEntry e) |
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 filename)
Reads the on-disk map file into 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.
|
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.
|
private boolean |
isRegex(ReplicaCatalogEntry tuple)
Checks if the 'regex' attribute is set to true for the given tuple
|
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 filename, up to the
complete catalog.
|
java.util.Map |
lookup(java.util.Set lfns)
Retrieves multiple entries for a given logical filename, up to the
complete catalog.
|
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.
|
java.util.Collection<ReplicaCatalogEntry> |
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 filename and site handle from the replica
catalog.
|
java.util.Map |
lookupNoAttributes(java.util.Set lfns)
Retrieves multiple entries for a given logical filename, up to the
complete catalog.
|
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.
|
java.util.Set<java.lang.String> |
lookupNoAttributes(java.lang.String lfn)
Retrieves all entries for a given LFN from the replica catalog.
|
java.util.Collection<ReplicaCatalogEntry> |
lookupWithHandle(java.lang.String lfn,
java.lang.String handle) |
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(java.lang.String line,
int lineno)
Parses a line from the file replica catalog
|
java.lang.String |
quote(Escape e,
java.lang.String s)
Quotes a string only if necessary.
|
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 |
write(java.io.Writer out,
java.util.Map<java.lang.String,java.util.Collection<ReplicaCatalogEntry>> m) |
public static final java.lang.String READ_ONLY_KEY
public static final java.lang.String REGEX_KEY
protected boolean m_quote
protected java.lang.String m_filename
protected java.util.Map<java.lang.String,java.util.Collection<ReplicaCatalogEntry>> m_lfn
protected java.util.Map<java.lang.String,java.util.Collection<ReplicaCatalogEntry>> m_lfn_regex
protected java.util.Map<java.lang.String,java.util.regex.Pattern> m_lfn_pattern
boolean m_readonly
private static final java.lang.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 Regex()
connect(Properties)public boolean parse(java.lang.String line,
int lineno)
line - is the line to parselineno - is the line number of this linepublic boolean connect(java.lang.String filename)
filename - is the name of the file to read.public boolean connect(java.util.Properties props)
public java.lang.String quote(Escape e, java.lang.String s)
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()
private void write(java.io.Writer out,
java.util.Map<java.lang.String,java.util.Collection<ReplicaCatalogEntry>> m)
throws java.io.IOException
java.io.IOExceptionpublic boolean isClosed()
close().public java.lang.String lookup(java.lang.String lfn,
java.lang.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.public java.util.Collection<ReplicaCatalogEntry> lookupWithHandle(java.lang.String lfn, java.lang.String handle)
public java.util.Collection<ReplicaCatalogEntry> lookup(java.lang.String lfn)
lookup in interface ReplicaCataloglfn - is the logical filename to obtain information for.ReplicaCatalogEntryprivate ReplicaCatalogEntry cloneRCE(ReplicaCatalogEntry e)
public java.util.Set<java.lang.String> lookupNoAttributes(java.lang.String lfn)
lookupNoAttributes in interface ReplicaCataloglfn - is the logical filename to obtain information for.public java.util.Map lookup(java.util.Set lfns)
lookup in interface ReplicaCataloglfns - is a set of logical filename strings to look up.ReplicaCatalogEntrypublic java.util.Map lookupNoAttributes(java.util.Set lfns)
lookupNoAttributes in interface ReplicaCataloglfns - is a set of logical filename 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 filename 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 filename 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 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.private boolean isRegex(ReplicaCatalogEntry tuple)
tuple - public int insert(java.lang.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(java.lang.String lfn,
java.lang.String pfn,
java.lang.String handle)
ReplicaCatalogEntry element will be constructed, 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 insert(java.util.Map x)
insert in interface ReplicaCatalogx - is a map from logical filename 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 filename in the tuple.pfn - is the physical filename in the tuple.public int delete(java.util.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.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 filename in the tuple.tuple - is a description of the PFN and its attributes.public int delete(java.lang.String lfn,
java.lang.String name,
java.lang.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(java.lang.String lfn,
java.lang.String handle)
delete( lfn, RESOURCE_HANDLE, handle )
deleteByResource in interface ReplicaCataloglfn - is the logical filename to look for.handle - is the resource handlepublic int remove(java.lang.String lfn)
remove in interface ReplicaCataloglfn - is the logical filename to remove all mappings for.public int remove(java.util.Set lfns)
remove in interface ReplicaCataloglfns - is a set of logical filename 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 ReplicaCatalog