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.ToolkitThis 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 intDEFAULT_CHUNK_FACTORThe default chunk factor that is used for biting off chunks of large files.private static java.lang.StringLFN_DOES_NOT_EXIST_MSGThe message for LFN's not found.private booleanm_batchIndication of batch mode.private intm_chunk_factorThe number of lines that are to be parsed for chunking up large input files.private java.lang.Stringm_conf_property_fileReference to the property file passed using the --conf optionprivate org.apache.log4j.Loggerm_logOur own logger.protected PegasusPropertiesm_pegasus_propsThe object holding all the properties pertaining to Pegasus.private java.util.Mapm_prefsMaintains instance-local settings on user preferences.private ReplicaCatalogm_rcMaintains the interface to the replica catalog implementation.private LogManagerm_rls_loggerLogger for RLS implementation for the time being.private static org.apache.log4j.Loggerm_rootKeeps track of log4j's root logger as singleton.private intm_total_lines_succ_workedThe total number of lines on which the client has successfully worked on till yet.private intm_total_lines_workedThe 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) voidclose()Frees resources taken by the instance of the replica catalog.(package private) voidconnect(PegasusProperties properties)Connects the interface with the replica catalog implementation.private voiddetermineChunkFactor()Sets the chunk factor for chunking up large input files.private voiddoSet(org.apache.log4j.Level level)java.lang.Objectenter(java.lang.String key, java.lang.String value)Adds a preference to the instance preferences settings.private java.lang.Stringescape(java.lang.String s)Escapes quotes and backslashes by backslashing them.protected gnu.getopt.LongOpt[]generateValidOptions()Creates a set of GNU long options.private voidinitialize(java.lang.String[] opts, char confChar)Initialize the RCClient objectprivate voidlfnDoesNotExist(java.lang.String lfn)Writes out a message about LFN not existing.static voidlog(org.apache.log4j.Level level, java.lang.String msg)Logs messages from main() method.private java.lang.StringlookupConfProperty(java.lang.String[] opts, char confChar)Looks up for the conf property in the command line arguments passed to the RCClientstatic voidmain(java.lang.String[] args)Manipulate entries in a given replica catalog implementation.private java.lang.Stringnoquote(java.lang.String s)Removes a pair of outer quotes, which are optional.voidparse(java.lang.String filename)Consumes commands that control the replica management.voidparse(java.lang.String filename, java.lang.String command)Consumes commands that control the replica management.voidsetLevel(int level)Sets a logging level.private voidshow(java.lang.String lfn, ReplicaCatalogEntry rce)Preliminary implementation of output method.voidshowHelp()Prints internal command help.voidshowUsage()Prints the usage string on stdout.private java.lang.Stringunescape(java.lang.String s)Unescapes previously backslashed characters.intwork(java.util.List words)Works on the command contained within one line.intwork(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:
showUsagein 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.IOExceptionjava.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.IOExceptionConsumes 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.IOExceptionConsumes 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.
-
-