edu.isi.pegasus.planner.visualize.spaceusage
Class SpaceUsageCallback

java.lang.Object
  extended by edu.isi.pegasus.planner.visualize.spaceusage.SpaceUsageCallback
All Implemented Interfaces:
Callback
Direct Known Subclasses:
TailStatd

public class SpaceUsageCallback
extends Object
implements Callback

Implements callback interface to calculate space usage.

Version:
1.0
Author:
not attributable

Field Summary
static String MAINJOB_MARKER
          The marker for the MAINJOB.
protected  long mJobInSize
          Stores in bytes the size of all the input files for a job.
protected  long mJobOutSize
          Stores in bytes the size of all the output files for a job.
protected  JobSpace mJobSpace
          Stores all the space readings for the current invocation record.
protected  LogManager mLogger
          The handle to the logger.
protected  String mMainJob
          The main job whose record is being parsed.
protected  String mSite
          The logical site where the job was run.
protected  SpaceUsage mSpaceStore
          The SpaceUsage object created during the callback construction.
protected  boolean mUseStatInfo
          Boolean indicating whether to use stat data or not for computing directory sizes.
static String POSTJOB_MARKER
          The marker for the POSTJOB.
static String PREJOB_MARKER
          The marker for the PREJOB.
 
Fields inherited from interface edu.isi.pegasus.planner.visualize.Callback
VERSION
 
Constructor Summary
SpaceUsageCallback()
          The default constructor.
 
Method Summary
 void cbInputFile(String filename, StatInfo info)
          Callback function for when stat information for an input file is encountered.
 void cbInvocationEnd()
          Callback signalling that an invocation record has been parsed.
 void cbInvocationStart(String job, String resource)
          Callback for the starting of an invocation record.
 void cbMachine(Machine machine)
          Callback to pass the machine information on which the job is executed.
 void cbMetadata(Map metadata)
          Callback for the metadata retrieved from the kickstart record.
 void cbOutputFile(String filename, StatInfo info)
          Callback function for when stat information for an output file is encountered.
 void cbStdERR(List jobs, String data)
          Callback function for the data section of stderr.
 void cbStdIN(List jobs, String data)
          Callback function for the data section of stdin.
 void cbStdOut(List jobs, String data)
          Callback function for the data section of stdout.
 boolean cleanupJob(String name)
          Returns boolean indicating whether the job is a cleanup job or not.
 void done()
          Callback signalling that we are done with the parsing of the files.
 Object getConstructedObject()
          Returns the SpaceUsage store built.
protected  int getEventTypeForHeader(String marker)
          Returns the event type matching a header.
 void initialize(String directory, boolean useStatInfo)
          Initializes the callback.
protected  Space parseContent(String header, String content)
          Parses the content and stores it in a Space object.
private  void parseData(String data)
          Parses the data in the data section.
protected  boolean validHeader(String token)
          Returns a boolean indicating whether the token passed matches a header or not.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PREJOB_MARKER

public static final String PREJOB_MARKER
The marker for the PREJOB. The stdout corresponding to the PREJOB is enclosed within this marker.

See Also:
Constant Field Values

MAINJOB_MARKER

public static final String MAINJOB_MARKER
The marker for the MAINJOB. The stdout corresponding to the MAINJOB is enclosed within this marker.

See Also:
Constant Field Values

POSTJOB_MARKER

public static final String POSTJOB_MARKER
The marker for the POSTJOB. The stdout corresponding to the POSTJOB is enclosed within this marker.

See Also:
Constant Field Values

mSite

protected String mSite
The logical site where the job was run.


mSpaceStore

protected SpaceUsage mSpaceStore
The SpaceUsage object created during the callback construction.


mMainJob

protected String mMainJob
The main job whose record is being parsed.


mLogger

protected LogManager mLogger
The handle to the logger.


mUseStatInfo

protected boolean mUseStatInfo
Boolean indicating whether to use stat data or not for computing directory sizes.


mJobOutSize

protected long mJobOutSize
Stores in bytes the size of all the output files for a job.


mJobInSize

protected long mJobInSize
Stores in bytes the size of all the input files for a job.


mJobSpace

protected JobSpace mJobSpace
Stores all the space readings for the current invocation record.

Constructor Detail

SpaceUsageCallback

public SpaceUsageCallback()
The default constructor.

Method Detail

initialize

public void initialize(String directory,
                       boolean useStatInfo)
Initializes the callback.

Specified by:
initialize in interface Callback
Parameters:
directory - the directory where all the files reside.
useStatInfo - boolean indicating whether to use stat info or not.

cbInvocationStart

public void cbInvocationStart(String job,
                              String resource)
Callback for the starting of an invocation record.

Specified by:
cbInvocationStart in interface Callback
Parameters:
job - the job/file being parsed.
resource - the site id where the job was executed.

cbStdIN

public void cbStdIN(List jobs,
                    String data)
Description copied from interface: Callback
Callback function for the data section of stdin. Since the jobs ( setup, prejob, main, postjob, cleanup) do not have separate stdout etc, all are passed.

Specified by:
cbStdIN in interface Callback
Parameters:
jobs - all the jobs specified in the kickstart record.
data - the data contents as String.

cbStdOut

public void cbStdOut(List jobs,
                     String data)
Description copied from interface: Callback
Callback function for the data section of stdout. Since the jobs ( setup, prejob, main, postjob, cleanup) do not have separate stdout etc, all are passed.

Specified by:
cbStdOut in interface Callback
Parameters:
jobs - all the jobs specified in the kickstart record.
data - the data contents as String.

cbStdERR

public void cbStdERR(List jobs,
                     String data)
Description copied from interface: Callback
Callback function for the data section of stderr. Since the jobs ( setup, prejob, main, postjob, cleanup) do not have separate stdout etc, all are passed.

Specified by:
cbStdERR in interface Callback
Parameters:
jobs - all the jobs specified in the kickstart record.
data - the data contents as String.

cbInputFile

public void cbInputFile(String filename,
                        StatInfo info)
Callback function for when stat information for an input file is encountered. Empty for time being.

Specified by:
cbInputFile in interface Callback
Parameters:
filename - the name of the file.
info - the StatInfo about the file.

cbOutputFile

public void cbOutputFile(String filename,
                         StatInfo info)
Callback function for when stat information for an output file is encountered. The size of the file is computed and stored.

Specified by:
cbOutputFile in interface Callback
Parameters:
filename - the name of the file.
info - the StatInfo about the file.

cbInvocationEnd

public void cbInvocationEnd()
Callback signalling that an invocation record has been parsed. Stores the total compute size, somewhere in the space structure for the jobs.

Specified by:
cbInvocationEnd in interface Callback

getConstructedObject

public Object getConstructedObject()
Returns the SpaceUsage store built.

Specified by:
getConstructedObject in interface Callback
Returns:
SpaceUsage

parseData

private void parseData(String data)
Parses the data in the data section.

Parameters:
data - String

done

public void done()
Callback signalling that we are done with the parsing of the files.

Specified by:
done in interface Callback

validHeader

protected boolean validHeader(String token)
Returns a boolean indicating whether the token passed matches a header or not. In the specific case of using statinfo, for calculating directory sizes, we only mainjob and postjob markers are valid.

Parameters:
token - the token to be matched.
Returns:
boolean

cleanupJob

public boolean cleanupJob(String name)
Returns boolean indicating whether the job is a cleanup job or not. Does it on the basis of the name of the job.

Parameters:
name - the name of the job.
Returns:
boolean

parseContent

protected Space parseContent(String header,
                             String content)
Parses the content and stores it in a Space object.

Parameters:
header - the header from which the content was collected.
content - the Content.
Returns:
Space

getEventTypeForHeader

protected int getEventTypeForHeader(String marker)
Returns the event type matching a header.

Parameters:
marker - the marker
Returns:
the corresponding event type

cbMetadata

public void cbMetadata(Map metadata)
Callback for the metadata retrieved from the kickstart record.

Specified by:
cbMetadata in interface Callback
Parameters:
metadata -

cbMachine

public void cbMachine(Machine machine)
Callback to pass the machine information on which the job is executed.

Specified by:
cbMachine in interface Callback
Parameters:
machine -


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