Class DAXWriter
- java.lang.Object
-
- edu.isi.pegasus.planner.partitioner.DAXWriter
-
- Direct Known Subclasses:
MultipleLook,SingleLook
public abstract class DAXWriter extends java.lang.ObjectThe abstract class that identifies the interface for writing out a dax corresponding to a partition. The interface stipulates that the jobs making up the partition and relations between those jobs in the partition are identified when invoking it. However all the job details are to be gotten by the implementing classes by parsing the original dax.- Version:
- $Revision$
- Author:
- Karan Vahi
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.StringmDaxFileThe dax file that is being partitioned.protected LogManagermLoggerThe handle to the logging object.protected java.lang.StringmPartitionNameThe name of the partition dax that are generated.protected java.lang.StringmPDAXDirectoryThe directory in which the daxes corresponding to the partition are generated.protected java.io.PrintWritermWriteHandleThe write handle to the xml file being written.static java.lang.StringPACKAGE_NAMEThe name of the package in which the writers are implemented.static java.lang.StringPARTITION_PREFIXThe prefix added to the name of the dax to identify it is a partitioned dax.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidclose()Close the write handle to the file that is written.private static java.lang.StringconstructPartitionName(java.lang.String daxName, boolean addPrefix)It constructs the partition name given the daxName.java.lang.StringgetPartitionName()It returns the name of the partitioned dax, that the object is currently writing or initialized to write.static java.lang.StringgetPDAXFilename(java.lang.String daxName, int index)It constructs the name of the partitioned dax file that has to be written corresponding to a partition of the dax.static java.lang.StringgetPDAXFilename(java.lang.String daxName, int index, boolean addPrefix)It constructs the name of the partitioned dax file that has to be written corresponding to a partition of the dax.voidinitializeWriteHandle(int index)This initializes the write handle a file in directory specified when creating the instance of this class.voidinitializeWriteHandle(java.lang.String fileName)This initializes the write handle to the file in directory specified when creating the instance of this class.static DAXWriterloadInstance(PegasusProperties properties, java.lang.String daxFile, java.lang.String directory)The ends up loading the PDAXWriter.static DAXWriterloadInstance(java.lang.String className, PegasusProperties properties, java.lang.String daxFile, java.lang.String directory)Loads the implementing PDAXWriter.voidsetPartitionName(java.lang.String daxName)It sets the name of the partition in the dax that is generated.voidwriteln(java.lang.String st)Writes out to the file.booleanwritePartitionDax(Partition partition)It writes out a dax consisting of the jobs as specified in the partition.abstract booleanwritePartitionDax(Partition partition, int index)It writes out a dax consisting of the jobs as specified in the partition.
-
-
-
Field Detail
-
PARTITION_PREFIX
public static final java.lang.String PARTITION_PREFIX
The prefix added to the name of the dax to identify it is a partitioned dax.- See Also:
- Constant Field Values
-
PACKAGE_NAME
public static final java.lang.String PACKAGE_NAME
The name of the package in which the writers are implemented.- See Also:
- Constant Field Values
-
mDaxFile
protected java.lang.String mDaxFile
The dax file that is being partitioned. The dax file is the repository for all the jobs in the partitioned daxes.
-
mPDAXDirectory
protected java.lang.String mPDAXDirectory
The directory in which the daxes corresponding to the partition are generated.
-
mPartitionName
protected java.lang.String mPartitionName
The name of the partition dax that are generated.
-
mLogger
protected LogManager mLogger
The handle to the logging object.
-
mWriteHandle
protected java.io.PrintWriter mWriteHandle
The write handle to the xml file being written.
-
-
Constructor Detail
-
DAXWriter
protected DAXWriter()
The default constructor
-
DAXWriter
protected DAXWriter(java.lang.String daxFile, java.lang.String directory)The overloaded constructor.- Parameters:
daxFile- the path to the dax file that is being partitioned.directory- the directory in which the partitioned daxes are to be generated.
-
-
Method Detail
-
writePartitionDax
public boolean writePartitionDax(Partition partition)
It writes out a dax consisting of the jobs as specified in the partition.- Parameters:
partition- the partition object containing the relations and id's of the jobs making up the partition.- Returns:
- boolean true if dax successfully generated and written. false in case of error.
-
writePartitionDax
public abstract boolean writePartitionDax(Partition partition, int index)
It writes out a dax consisting of the jobs as specified in the partition.- Parameters:
partition- the partition object containing the relations and id's of the jobs making up the partition.index- the index of the partition.- Returns:
- boolean true if dax successfully generated and written. false in case of error.
-
loadInstance
public static DAXWriter loadInstance(PegasusProperties properties, java.lang.String daxFile, java.lang.String directory)
The ends up loading the PDAXWriter. It selects the writer as specified by the vds.partition.parse.mode property.- Parameters:
properties- the handle to the properties visible to Pegasus.daxFile- the path to the dax file that is being partitioned.directory- the directory in which the partitioned daxes are to be generated.
-
loadInstance
public static DAXWriter loadInstance(java.lang.String className, PegasusProperties properties, java.lang.String daxFile, java.lang.String directory) throws FactoryException
Loads the implementing PDAXWriter. The name of the class that is to be loaded is passed and can be complete(with package name) or just the name of the class, in which case the class is loaded from the default package.- Parameters:
properties- the handle to the properties visible to Pegasus.className- the name of the class with or without the package name.daxFile- the path to the dax file that is being partitioned.directory- the directory in which the partitioned daxes are to be generated.- Throws:
FactoryException- that nests any error that might occur during the instantiation of the implementation.
-
getPDAXFilename
public static java.lang.String getPDAXFilename(java.lang.String daxName, int index)It constructs the name of the partitioned dax file that has to be written corresponding to a partition of the dax. The dax name returned has no prefix added to it.- Parameters:
daxName- the name attribute in the adag element of the dax.index- the partition number of the partition.
-
getPDAXFilename
public static java.lang.String getPDAXFilename(java.lang.String daxName, int index, boolean addPrefix)It constructs the name of the partitioned dax file that has to be written corresponding to a partition of the dax.- Parameters:
daxName- the name attribute in the adag element of the dax.index- the partition number of the partition.addPrefix- whether you want to addPrefix or not.
-
constructPartitionName
private static java.lang.String constructPartitionName(java.lang.String daxName, boolean addPrefix)It constructs the partition name given the daxName. It only ends up adding the prefix if the addPrefix parameter is set.- Parameters:
daxName- the name attribute in the adag element of the dax.addPrefix- whether to add prefix or not.
-
setPartitionName
public void setPartitionName(java.lang.String daxName)
It sets the name of the partition in the dax that is generated. It suffixes PARTITION_PREFIX to the name of the dax.- Parameters:
daxName- the name attribute in the adag element of the dax.
-
getPartitionName
public java.lang.String getPartitionName()
It returns the name of the partitioned dax, that the object is currently writing or initialized to write. By the name, one means the value that is set to the name attribute in the adag element.
-
initializeWriteHandle
public void initializeWriteHandle(int index)
This initializes the write handle a file in directory specified when creating the instance of this class. The name of the file is constructed by default, by looking at the partition name that is assigned to the name attribute for the adag element.- Parameters:
index- the partition number of the partition.
-
initializeWriteHandle
public void initializeWriteHandle(java.lang.String fileName)
This initializes the write handle to the file in directory specified when creating the instance of this class.- Parameters:
fileName- the name of the file that is to be written in the directory.
-
writeln
public void writeln(java.lang.String st)
Writes out to the file.
-
close
public void close()
Close the write handle to the file that is written.
-
-