edu.isi.pegasus.planner.client
Class RCClient

java.lang.Object
  extended by org.griphyn.vdl.toolkit.Toolkit
      extended by 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: 3619 $
Author:
Jens-S. Vöckler, Yong Zhao
See Also:
edu.isi.pegasus.planner.catalog.replica.ReplicaCatalog, ReplicaCatalogEntry, JDBCRC

Field Summary
private static int DEFAULT_CHUNK_FACTOR
          The default chunk factor that is used for biting off chunks of large files.
private static 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  String m_conf_property_file
          Reference to the property file passed using the --conf option
private  org.apache.log4j.Logger m_log
          Our own logger.
protected  PegasusProperties m_pegasus_props
          The object holding all the properties pertaining to Pegasus.
private  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.
 
Fields inherited from class org.griphyn.vdl.toolkit.Toolkit
m_application, m_home, m_logger, m_props, m_verbosity
 
Constructor Summary
RCClient(String appName)
          ctor: Constructs a new instance of the commandline interface to replica catalogs.
 
Method Summary
(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)
           
 Object enter(String key, String value)
          Adds a preference to the instance preferences settings.
private  String escape(String s)
          Escapes quotes and backslashes by backslashing them.
protected  gnu.getopt.LongOpt[] generateValidOptions()
          Creates a set of GNU long options.
private  void initialize(String[] opts, char confChar)
          Initialize the RCClient object
private  void lfnDoesNotExist(String lfn)
          Writes out a message about LFN not existing.
static void log(org.apache.log4j.Level level, String msg)
          Logs messages from main() method.
private  String lookupConfProperty(String[] opts, char confChar)
          Looks up for the conf property in the command line arguments passed to the RCClient
static void main(String[] args)
          Manipulate entries in a given replica catalog implementation.
private  String noquote(String s)
          Removes a pair of outer quotes, which are optional.
 void parse(String filename)
          Consumes commands that control the replica management.
 void parse(String filename, String command)
          Consumes commands that control the replica management.
 void setLevel(int level)
          Sets a logging level.
private  void show(String lfn, ReplicaCatalogEntry rce)
          Preliminary implementation of output method.
 void showHelp()
          Prints internal command help.
 void showUsage()
          Prints the usage string on stdout.
private  String unescape(String s)
          Unescapes previously backslashed characters.
 int work(List words)
          Works on the command contained within one line.
 int work(List lines, String command)
          Works on the command contained within chunk of lines.
 
Methods inherited from class org.griphyn.vdl.toolkit.Toolkit
getVerbosity, increaseVerbosity, readFile, setVerbosity
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LFN_DOES_NOT_EXIST_MSG

private static final 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 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 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.

Constructor Detail

RCClient

public RCClient(String appName)
ctor: Constructs a new instance of the commandline interface to replica catalogs.

Parameters:
appName - is the name of to print in usage records.
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,
                       String msg)
Logs messages from main() method.

Parameters:
level - is the log4j level to generate the log message for
msg - is the message itself.
See Also:
Category.log(Priority, Object )

doSet

private void doSet(org.apache.log4j.Level level)

enter

public Object enter(String key,
                    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(String[] opts,
                        char confChar)
Initialize the RCClient object

Parameters:
opts - the command line argument passed by the user
confChar - the short option corresponding the conf property.

showUsage

public void showUsage()
Prints the usage string on stdout.

Specified by:
showUsage in class org.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 ClassNotFoundException,
              IOException,
              NoSuchMethodException,
              InstantiationException,
              IllegalAccessException,
              InvocationTargetException,
              MissingResourceException
Connects the interface with the replica catalog implementation. The choice of backend is configured through properties.

Throws:
ClassNotFoundException - if the schema for the database cannot be loaded. You might want to check your CLASSPATH, too.
NoSuchMethodException - if the schema's constructor interface does not comply with the database driver API.
InstantiationException - if the schema class is an abstract class instead of a concrete implementation.
IllegalAccessException - if the constructor for the schema class it not publicly accessible to this package.
InvocationTargetException - if the constructor of the schema throws an exception while being dynamically loaded.
IOException
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 String escape(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 String unescape(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 String noquote(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(String lfn)
Writes out a message about LFN not existing.

Parameters:
lfn - the lfn.

show

private void show(String lfn,
                  ReplicaCatalogEntry rce)
Preliminary implementation of output method.

Parameters:
lfn - is the logical filename to show
rce - 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(List lines,
                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 appropriately
command - the command to be invoked.
Returns:
number of entries affected, or -1 to stop processing.

work

public int work(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(String filename)
           throws IOException
Consumes commands that control the replica management.

Parameters:
filename - is the file to read from. If null, use stdin.
Throws:
IOException

parse

public void parse(String filename,
                  String command)
           throws 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:
IOException

lookupConfProperty

private String lookupConfProperty(String[] opts,
                                  char confChar)
Looks up for the conf property in the command line arguments passed to the RCClient

Parameters:
opts - command line arguments
confChar - short char corresponding to the conf property
Returns:
path to the property file

main

public static void main(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.



Copyright © 2011 The University of Southern California. All Rights Reserved.