edu.isi.pegasus.planner.partitioner

## Class DAXWriter

- java.lang.Object
- - edu.isi.pegasus.planner.partitioner.DAXWriter

Direct Known Subclasses:
  MultipleLook, SingleLook

    public abstract class DAXWriter
    extends java.lang.Object

The 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
`protected java.lang.String` `mDaxFile` The dax file that is being partitioned.
`protected LogManager` `mLogger` The handle to the logging object.
`protected java.lang.String` `mPartitionName` The name of the partition dax that are generated.
`protected java.lang.String` `mPDAXDirectory` The directory in which the daxes corresponding to the partition are generated.
`protected java.io.PrintWriter` `mWriteHandle` The write handle to the xml file being written.
`static java.lang.String` `PACKAGE_NAME` The name of the package in which the writers are implemented.
`static java.lang.String` `PARTITION_PREFIX` The prefix added to the name of the dax to identify it is a partitioned dax.

### Constructor Summary

Constructors
`protected` `DAXWriter()` The default constructor
`protected` `DAXWriter(java.lang.String daxFile, java.lang.String directory)` The overloaded constructor.

### Method Summary

All Methods Static Methods Instance Methods Abstract Methods Concrete Methods
`void` `close()` Close the write handle to the file that is written.
`private static java.lang.String` `constructPartitionName(java.lang.String daxName, boolean addPrefix)` It constructs the partition name given the daxName.
`java.lang.String` `getPartitionName()` It returns the name of the partitioned dax, that the object is currently writing or initialized to write.
`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.
`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.
`void` `initializeWriteHandle(int index)` This initializes the write handle a file in directory specified when creating the instance of this class.
`void` `initializeWriteHandle(java.lang.String fileName)` This initializes the write handle to the file in directory specified when creating the instance of this class.
`static DAXWriter` `loadInstance(PegasusProperties properties, java.lang.String daxFile, java.lang.String directory)` The ends up loading the PDAXWriter.
`static DAXWriter` `loadInstance(java.lang.String className, PegasusProperties properties, java.lang.String daxFile, java.lang.String directory)` Loads the implementing PDAXWriter.
`void` `setPartitionName(java.lang.String daxName)` It sets the name of the partition in the dax that is generated.
`void` `writeln(java.lang.String st)` Writes out to the file.
`boolean` `writePartitionDax(Partition partition)` It writes out a dax consisting of the jobs as specified in the partition.
`abstract boolean` `writePartitionDax(Partition partition, int index)` It writes out a dax consisting of the jobs as specified in the partition.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### 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.