Package edu.isi.pegasus.planner.client
Class RCClient
- java.lang.Object
-
- org.griphyn.vdl.toolkit.Toolkit
-
- edu.isi.pegasus.planner.client.RCClient
-
public class RCClient extends org.griphyn.vdl.toolkit.Toolkit
This class interfaces the with the replica catalog API to delve into the underlying true catalog without knowing (once instantiated) which one it is.- Version:
- $Revision$
- Author:
- Jens-S. Vöckler, Yong Zhao
- See Also:
edu.isi.pegasus.planner.catalog.replica.ReplicaCatalog
,ReplicaCatalogEntry
,JDBCRC
-
-
Field Summary
Fields Modifier and Type Field Description private static int
DEFAULT_CHUNK_FACTOR
The default chunk factor that is used for biting off chunks of large files.private static java.lang.String
LFN_DOES_NOT_EXIST_MSG
The message for LFN's not found.private boolean
m_batch
Indication of batch mode.private int
m_chunk_factor
The number of lines that are to be parsed for chunking up large input files.private java.lang.String
m_conf_property_file
Reference to the property file passed using the --conf optionprivate org.apache.log4j.Logger
m_log
Our own logger.protected PegasusProperties
m_pegasus_props
The object holding all the properties pertaining to Pegasus.private java.util.Map
m_prefs
Maintains instance-local settings on user preferences.private ReplicaCatalog
m_rc
Maintains the interface to the replica catalog implementation.private LogManager
m_rls_logger
Logger for RLS implementation for the time being.private static org.apache.log4j.Logger
m_root
Keeps track of log4j's root logger as singleton.private int
m_total_lines_succ_worked
The total number of lines on which the client has successfully worked on till yet.private int
m_total_lines_worked
The total number of lines on which the client has worked on till yet.
-
Constructor Summary
Constructors Constructor Description RCClient(java.lang.String appName)
ctor: Constructs a new instance of the commandline interface to replica catalogs.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) void
close()
Frees resources taken by the instance of the replica catalog.(package private) void
connect(PegasusProperties properties)
Connects the interface with the replica catalog implementation.private void
determineChunkFactor()
Sets the chunk factor for chunking up large input files.private void
doSet(org.apache.log4j.Level level)
java.lang.Object
enter(java.lang.String key, java.lang.String value)
Adds a preference to the instance preferences settings.private java.lang.String
escape(java.lang.String s)
Escapes quotes and backslashes by backslashing them.protected gnu.getopt.LongOpt[]
generateValidOptions()
Creates a set of GNU long options.private void
initialize(java.lang.String[] opts, char confChar)
Initialize the RCClient objectprivate void
lfnDoesNotExist(java.lang.String lfn)
Writes out a message about LFN not existing.static void
log(org.apache.log4j.Level level, java.lang.String msg)
Logs messages from main() method.private java.lang.String
lookupConfProperty(java.lang.String[] opts, char confChar)
Looks up for the conf property in the command line arguments passed to the RCClientstatic void
main(java.lang.String[] args)
Manipulate entries in a given replica catalog implementation.private java.lang.String
noquote(java.lang.String s)
Removes a pair of outer quotes, which are optional.void
parse(java.lang.String filename)
Consumes commands that control the replica management.void
parse(java.lang.String filename, java.lang.String command)
Consumes commands that control the replica management.void
setLevel(int level)
Sets a logging level.private void
show(java.lang.String lfn, ReplicaCatalogEntry rce)
Preliminary implementation of output method.void
showHelp()
Prints internal command help.void
showUsage()
Prints the usage string on stdout.private java.lang.String
unescape(java.lang.String s)
Unescapes previously backslashed characters.int
work(java.util.List words)
Works on the command contained within one line.int
work(java.util.List lines, java.lang.String command)
Works on the command contained within chunk of lines.
-
-
-
Field Detail
-
LFN_DOES_NOT_EXIST_MSG
private static final java.lang.String LFN_DOES_NOT_EXIST_MSG
The message for LFN's not found.- See Also:
- Constant Field Values
-
DEFAULT_CHUNK_FACTOR
private static final int DEFAULT_CHUNK_FACTOR
The default chunk factor that is used for biting off chunks of large files.- See Also:
- Constant Field Values
-
m_rc
private ReplicaCatalog m_rc
Maintains the interface to the replica catalog implementation.
-
m_prefs
private java.util.Map m_prefs
Maintains instance-local settings on user preferences.
-
m_root
private static org.apache.log4j.Logger m_root
Keeps track of log4j's root logger as singleton.
-
m_rls_logger
private LogManager m_rls_logger
Logger for RLS implementation for the time being.
-
m_chunk_factor
private int m_chunk_factor
The number of lines that are to be parsed for chunking up large input files.
-
m_total_lines_worked
private int m_total_lines_worked
The total number of lines on which the client has worked on till yet.
-
m_total_lines_succ_worked
private int m_total_lines_succ_worked
The total number of lines on which the client has successfully worked on till yet.
-
m_batch
private boolean m_batch
Indication of batch mode.
-
m_pegasus_props
protected PegasusProperties m_pegasus_props
The object holding all the properties pertaining to Pegasus.
-
m_conf_property_file
private java.lang.String m_conf_property_file
Reference to the property file passed using the --conf option
-
m_log
private org.apache.log4j.Logger m_log
Our own logger.
-
-
Method Detail
-
setLevel
public void setLevel(int level)
Sets a logging level.- Parameters:
level
- is the new level to achieve.
-
log
public static void log(org.apache.log4j.Level level, java.lang.String msg)
Logs messages from main() method.- Parameters:
level
- is the log4j level to generate the log message formsg
- is the message itself.- See Also:
Category.log(Priority, Object )
-
doSet
private void doSet(org.apache.log4j.Level level)
-
enter
public java.lang.Object enter(java.lang.String key, java.lang.String value)
Adds a preference to the instance preferences settings.- Parameters:
key
- is a key into the preference map.value
- is the new value to add.- Returns:
- the previous value, or null if no such value exists.
-
initialize
private void initialize(java.lang.String[] opts, char confChar)
Initialize the RCClient object- Parameters:
opts
- the command line argument passed by the userconfChar
- the short option corresponding the conf property.
-
showUsage
public void showUsage()
Prints the usage string on stdout.- Specified by:
showUsage
in classorg.griphyn.vdl.toolkit.Toolkit
-
generateValidOptions
protected gnu.getopt.LongOpt[] generateValidOptions()
Creates a set of GNU long options.- Returns:
- an initialized array with the options
-
connect
void connect(PegasusProperties properties) throws java.lang.ClassNotFoundException, java.io.IOException, java.lang.NoSuchMethodException, java.lang.InstantiationException, java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException, java.util.MissingResourceException
Connects the interface with the replica catalog implementation. The choice of backend is configured through properties.- Throws:
java.lang.ClassNotFoundException
- if the schema for the database cannot be loaded. You might want to check your CLASSPATH, too.java.lang.NoSuchMethodException
- if the schema's constructor interface does not comply with the database driver API.java.lang.InstantiationException
- if the schema class is an abstract class instead of a concrete implementation.java.lang.IllegalAccessException
- if the constructor for the schema class it not publicly accessible to this package.java.lang.reflect.InvocationTargetException
- if the constructor of the schema throws an exception while being dynamically loaded.java.io.IOException
java.util.MissingResourceException
- See Also:
ChimeraProperties
-
close
void close()
Frees resources taken by the instance of the replica catalog. This method is safe to be called on failed or already closed catalogs.
-
escape
private java.lang.String escape(java.lang.String s)
Escapes quotes and backslashes by backslashing them. Identity s == unescape(escape(s)) is preserved.- Parameters:
s
- is the string to escape- Returns:
- a string with escaped special characters.
- See Also:
unescape(String )
-
unescape
private java.lang.String unescape(java.lang.String s)
Unescapes previously backslashed characters. Identity s == unescape(escape(s)) is preserved.- Parameters:
s
- is the string to escape- Returns:
- a string with unescaped special characters.
- See Also:
escape(String )
-
noquote
private java.lang.String noquote(java.lang.String s)
Removes a pair of outer quotes, which are optional.- Parameters:
s
- is a string which may start and end in quotes- Returns:
- a string without the optional quotes, or the string itself.
-
lfnDoesNotExist
private void lfnDoesNotExist(java.lang.String lfn)
Writes out a message about LFN not existing.- Parameters:
lfn
- the lfn.
-
show
private void show(java.lang.String lfn, ReplicaCatalogEntry rce)
Preliminary implementation of output method.- Parameters:
lfn
- is the logical filename to showrce
- is the replica catalog entry to show. It contains at minimum the physical filename, and may contain any number of key-value pairs.
-
showHelp
public void showHelp()
Prints internal command help.
-
work
public int work(java.util.List lines, java.lang.String command)
Works on the command contained within chunk of lines.- Parameters:
lines
- is a list of lines with each line being a list of words that is split appropriatelycommand
- the command to be invoked.- Returns:
- number of entries affected, or -1 to stop processing.
-
work
public int work(java.util.List words)
Works on the command contained within one line.- Parameters:
words
- is a list of the arguments, split appropriately- Returns:
- number of entries affected, or -1 to stop processing.
-
parse
public void parse(java.lang.String filename) throws java.io.IOException
Consumes commands that control the replica management.- Parameters:
filename
- is the file to read from. If null, use stdin.- Throws:
java.io.IOException
-
parse
public void parse(java.lang.String filename, java.lang.String command) throws java.io.IOException
Consumes commands that control the replica management.- Parameters:
filename
- is the file to read from.command
- is the command that needs to be applied to the file contents- Throws:
java.io.IOException
-
lookupConfProperty
private java.lang.String lookupConfProperty(java.lang.String[] opts, char confChar)
Looks up for the conf property in the command line arguments passed to the RCClient- Parameters:
opts
- command line argumentsconfChar
- short char corresponding to the conf property- Returns:
- path to the property file
-
main
public static void main(java.lang.String[] args)
Manipulate entries in a given replica catalog implementation.- Parameters:
args
- are the commandline arguments.
-
determineChunkFactor
private void determineChunkFactor()
Sets the chunk factor for chunking up large input files.
-
-