edu.isi.pegasus.planner.ranking
Class GetDAX

java.lang.Object
  extended by edu.isi.pegasus.planner.ranking.GetDAX

public class GetDAX
extends Object

This class is responsible for the fetching the DAX'es on the basis of the request ID's from the Windward Provenance Tracking Catalog. If there are more than one way's to get the DAX's then it should be an interface.

Version:
$Revision: 2585 $
Author:
Karan Vahi

Field Summary
static String c_prefix
          Prefix for the property subset to use with this catalog.
static String DB_PREFIX
          The DB Driver properties prefix.
private  Connection mConnection
          Maintains the connection to the database over the lifetime of this instance.
private static String[] mCStatements
          The statement to prepare to slurp attributes.
private  LogManager mLogger
          The instance to the Logging manager.
private  Properties mProps
          The properties passed to the client.
private  PreparedStatement[] mStatements
          Maintains an essential set of prepared statement, ready to use.
 
Constructor Summary
GetDAX()
          The default constructor.
 
Method Summary
 void close()
          Explicitely free resources before the garbage collection hits.
 boolean connect(PegasusProperties properties)
          A convenience method to connect on the basis of PegasusProperties.
 boolean connect(Properties props)
          Establishes a connection to the database from the properties.
 Collection<String> get(String id, String dir)
          Given a request ID it fetches the DAX's from the DB and writes out to the directory passed.
protected  String getJDBCURL(String driver, Properties properties)
          Constructs the jdbc url on the basis fo the driver and db properties.
protected  PreparedStatement getStatement(int i)
          Singleton manager for prepared statements.
 boolean isClosed()
          Predicate to check, if the connection with the catalog's implementation is still active.
static void main(String[] args)
          For Testing purposes only.
protected static void sanityCheck(File dir)
          Checks the destination location for existence, if it can be created, if it is writable etc.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

c_prefix

public static final String c_prefix
Prefix for the property subset to use with this catalog.

See Also:
Constant Field Values

DB_PREFIX

public static final String DB_PREFIX
The DB Driver properties prefix.

See Also:
Constant Field Values

mCStatements

private static final String[] mCStatements
The statement to prepare to slurp attributes.


mConnection

private Connection mConnection
Maintains the connection to the database over the lifetime of this instance.


mStatements

private PreparedStatement[] mStatements
Maintains an essential set of prepared statement, ready to use.


mProps

private Properties mProps
The properties passed to the client.


mLogger

private LogManager mLogger
The instance to the Logging manager.

Constructor Detail

GetDAX

public GetDAX()
The default constructor.

Method Detail

connect

public boolean connect(PegasusProperties properties)
A convenience method to connect on the basis of PegasusProperties. Eventually this logic should go in the invoking code or factory.

Parameters:
properties - PegasusProperties
Returns:
boolean

connect

public boolean connect(Properties props)
Establishes a connection to the database from the properties. You can specify a driver property to contain the class name of the JDBC driver for your database. This property will be removed before attempting to connect. You must speficy a url property to describe the connection. It will be removed before attempting to connect.

Parameters:
props - is the property table with sufficient settings to establish a link with the database. The minimum key required key is "url", and possibly "driver". Any other keys depend on the database driver.
Returns:
true if connected, false if failed to connect.
See Also:
DriverManager.getConnection( String, Properties )

getJDBCURL

protected String getJDBCURL(String driver,
                            Properties properties)
Constructs the jdbc url on the basis fo the driver and db properties.

Parameters:
driver - the driver being used.
properties - the db properites
Returns:
the jdbc url, else null if unable to construct

get

public Collection<String> get(String id,
                              String dir)
Given a request ID it fetches the DAX's from the DB and writes out to the directory passed.

Parameters:
id - the request id.
dir - the directory where the DAX'es need to be placed.
Returns:
a Collection of basenames fo the DAX'es placed in the directory.

isClosed

public boolean isClosed()
Predicate to check, if the connection with the catalog's implementation is still active. This helps determining, if it makes sense to call close().

Returns:
true, if the implementation is disassociated, false otherwise.
See Also:
close()

close

public void close()
Explicitely free resources before the garbage collection hits.


getStatement

protected PreparedStatement getStatement(int i)
                                  throws SQLException
Singleton manager for prepared statements. This instruction checks that a prepared statement is ready to use, and will create an instance of the prepared statement, if it was unused previously.

Parameters:
i - is the index which prepared statement to check.
Returns:
a handle to the prepared statement.
Throws:
SQLException - in case of unable to delete entry.

sanityCheck

protected static void sanityCheck(File dir)
                           throws IOException
Checks the destination location for existence, if it can be created, if it is writable etc.

Parameters:
dir - is the new base directory to optionally create.
Throws:
IOException - in case of error while writing out files.

main

public static void main(String[] args)
For Testing purposes only.

Parameters:
args - the arguments passed.


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