edu.udo.cs.miningmart.compiler
Class CompilerAccessLogic

java.lang.Object
  extended byedu.udo.cs.miningmart.compiler.CompilerAccessLogic
All Implemented Interfaces:
CompilerAccess, M4InterfaceContext

public class CompilerAccessLogic
extends java.lang.Object
implements M4InterfaceContext, CompilerAccess

Objects of this class realize a single thread executing a command to the compiler. This is used by the RMI interface class to create different instances for concurrent compiler instances, but also by the class miningmart.compiler.CreateCompiler to run a single local (non-RMI) instance for a single compiliation task (e.g. command line based).

Version:
$Id: CompilerAccessLogic.java,v 1.11 2006/04/11 14:10:09 euler Exp $
Author:
Martin Scholz
See Also:
edu.udo.cs.miningmart.compiler.CompilerAccessImpl, miningmart.compiler.CreateCompiler

Constructor Summary
CompilerAccessLogic(DB db, Print printObject)
          This constructor takes all information needed from an existing database connection and shares the cache with the DB object!
CompilerAccessLogic(java.lang.String myDbConfigFile)
          Sets up a new instance of CompilerAccessLogic, using the default verbosity and the specified configuration file.
CompilerAccessLogic(java.lang.String myDbConfigFile, java.util.logging.Level verbosity)
          Sets up a new instance of CompilerAccessLogic, using the specified verbosity and configuration file.
 
Method Summary
 void changeCompilerOutputVerbosity(long caseId, java.util.logging.Level newVerbosity)
          Change the verbosity level of the compiler log messages for the given case.
 void compileAll(long caseId, boolean lazyMode)
          This method is given the ID of a Case to be compiled.
 void compileAll(long caseId, boolean lazy, int verbosity)
           
 void compileRestOfCase(long caseId, boolean lazyMode)
          A call to this method compiles only those steps of a case which have not already been compiled.
 void compileStep(long stepId, boolean lazyMode)
          This method is given the ID of the step to be compiled.
 void compileStep(long stepId, boolean lazy, int verbosity)
           
 void compileStep(java.lang.String stepName, boolean lazyMode)
          This method is given the name of the step to be compiled, as specified in table STEP_T, attribute ST_NAME.
 void compileStepFrom(long stepId, boolean lazyMode)
          This method is given the ID of the first Step of a subtree to be compiled.
 void compileStepFrom(long stepId, boolean lazy, int verbosity)
           
 void compileStepTo(long stepId, boolean lazyMode, boolean ignoreCompiledStatus)
          This method compiles all Steps that need to be compiled before the given Step can be compiled; then it compiles the given Step.
 void deleteTrashForCase(long caseId)
          Runs the garbage collection for all Steps of a specified Case.
 void deleteTrashForStep(long stepId)
          Runs the garbage collection for the specified Step and all subsequent dependent Steps with respect to the entries in the table STEPSEQUENCE_T.
 Case getCase()
           
 Print getCurrentPrintObject()
          Gets the instance of the Case-dependent Print object, if available.
 CompilerDatabaseService getDb()
          Gets the instance of class DB representing the database access to both the M4 and business schema.
static ExecutableOperator getExecutableOperator(Operator operator)
          This method bridges the gap between the M4 operator objects and the executable operators.
 DB getM4db()
          Same as getDb(), but with less specific return type for the implemented interface.
 Print getPrintObject()
           
 java.lang.String getStatusFromLine(long caseId, int lineNumber)
          Reads the status message of a running compiler server thread.
 java.lang.String getStatusMessage(long caseId, int numberOfLines)
          Reads the status message of a running compiler server thread.
 boolean getStopRequest()
          Checked to decide, if an exception should be thrown to stop execution.
 boolean isReadyForCompilation(long stepId)
          This method checks for a given Step, if it can currently be compiled.
 boolean killCompilerThread(long caseId)
          This method kills a running compiler thread.
 void updateColumnsetStatistics(long columnsetID)
          Uses the stored procedures of the database to update the statistics of the specified column set and of all the columns contained in the column set.
 void updateColumnStatistics(long columnID)
          Uses the stored procedures of the database to update the statistics of the specified column.
 void updateStatisticsForConcept(long conceptID)
          Uses the stored procedures of the database to update all the statistics which are related to the specified concept.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CompilerAccessLogic

public CompilerAccessLogic(DB db,
                           Print printObject)
This constructor takes all information needed from an existing database connection and shares the cache with the DB object!

Parameters:
db - an existing database connection object of type DB
printObject - the Print object to be used for log messages

CompilerAccessLogic

public CompilerAccessLogic(java.lang.String myDbConfigFile)
                    throws java.io.IOException,
                           java.sql.SQLException
Sets up a new instance of CompilerAccessLogic, using the default verbosity and the specified configuration file.

Parameters:
myDbConfigFile - the path to the configuration file describing the settings of the database
See Also:
miningmart.compiler.utils.Print

CompilerAccessLogic

public CompilerAccessLogic(java.lang.String myDbConfigFile,
                           java.util.logging.Level verbosity)
                    throws java.io.IOException,
                           java.sql.SQLException
Sets up a new instance of CompilerAccessLogic, using the specified verbosity and configuration file.

Parameters:
myDbConfigFile - the path to the configuration file describing the settings of the database
verbosity - the verbosity of the Print object associated with this object.
See Also:
miningmart.compiler.utils.Print
Method Detail

compileStep

public void compileStep(long stepId,
                        boolean lazyMode)
                 throws M4CompilerInterfaceError,
                        M4CompilerWarning,
                        UserError
Description copied from interface: CompilerAccess
This method is given the ID of the step to be compiled. If the lazy mode flag is set, then a less time consuming execution is performed.

An exception is thrown if the step is not present in the according M4 table, if parameters are missing, if references are invalid, if the database connection fails or if the execution of an operator fails.

Specified by:
compileStep in interface CompilerAccess
Parameters:
stepId - the ID of the step in STEP_T
lazyMode - a flag indicating if the compiler should run in lazy mode or not
Throws:
M4CompilerInterfaceError
M4CompilerWarning
UserError
See Also:
edu.udo.cs.miningmart.compiler.CompilerAccessImpl#compileStep(long, boolean)

compileStep

public void compileStep(java.lang.String stepName,
                        boolean lazyMode)
                 throws M4CompilerInterfaceError,
                        M4CompilerWarning,
                        UserError
Description copied from interface: CompilerAccess
This method is given the name of the step to be compiled, as specified in table STEP_T, attribute ST_NAME. If the lazy mode flag is set, then a less time consuming execution is performed.

An exception is thrown if the step is not present in the according M4 table, if parameters are missing, if references are invalid, if the database connection fails or if the execution of an operator fails.

Specified by:
compileStep in interface CompilerAccess
Parameters:
stepName - the name of the step in STEP_T
lazyMode - a flag indicating if the compiler should run in lazy mode or not
Throws:
M4CompilerInterfaceError
M4CompilerWarning
UserError
See Also:
edu.udo.cs.miningmart.compiler.CompilerAccessImpl#compileStep(String, boolean)

getExecutableOperator

public static ExecutableOperator getExecutableOperator(Operator operator)
                                                throws M4CompilerError
This method bridges the gap between the M4 operator objects and the executable operators. It reads an operator class name, as delivered e.g. by Step.getOperatorClass() and returns an executable operator.

Returns:
an instantiated ExecutableOperator
Throws:
M4CompilerError

compileAll

public void compileAll(long caseId,
                       boolean lazyMode)
                throws M4CompilerInterfaceError,
                       M4CompilerWarning,
                       UserError
Description copied from interface: CompilerAccess
This method is given the ID of a Case to be compiled. The compiler calculates a valid sequential order of the embedded steps with respect to the constraints introduced by the STEPSEQUENCE_T table. If the lazy mode flag is set, then a less time consuming execution is performed.

An exception is thrown if there is no valid sequence (e.g. cyclic dependencies), if there are no steps connected to the given case, if parameters are missing, if references are invalid, if the database connection fails or if the execution of an operator fails.

Specified by:
compileAll in interface CompilerAccess
Parameters:
caseId - the ID of the case to be compiled
lazyMode - a flag indicating if the compiler should run in lazy mode or not
Throws:
M4CompilerInterfaceError
M4CompilerWarning
UserError
See Also:
edu.udo.cs.miningmart.compiler.CompilerAccessImpl#compileAll(long, boolean)

compileStepFrom

public void compileStepFrom(long stepId,
                            boolean lazyMode)
                     throws M4CompilerInterfaceError,
                            M4CompilerWarning,
                            UserError
Description copied from interface: CompilerAccess
This method is given the ID of the first Step of a subtree to be compiled. The compiler calculates a valid sequential order of the subtree defined by and with respect to the constraints introduced by the STEPSEQUENCE_T table. If the lazy mode flag is set, then a less time consuming execution is performed.

An exception is thrown if there is no valid sequence (e.g. cyclic dependencies), if there are no steps connected to the given case, if parameters are missing, if references are invalid, if the database connection fails or if the execution of an operator fails.

Specified by:
compileStepFrom in interface CompilerAccess
Parameters:
stepId - the ID of the first step to be compiled
lazyMode - a flag indicating if the compiler should run in lazy mode or not
Throws:
M4CompilerInterfaceError
M4CompilerWarning
UserError
See Also:
edu.udo.cs.miningmart.compiler.CompilerAccessImpl#compileStepFrom(long, boolean)

compileStepTo

public void compileStepTo(long stepId,
                          boolean lazyMode,
                          boolean ignoreCompiledStatus)
                   throws M4CompilerInterfaceError,
                          M4CompilerWarning,
                          UserError
Description copied from interface: CompilerAccess
This method compiles all Steps that need to be compiled before the given Step can be compiled; then it compiles the given Step.

Specified by:
compileStepTo in interface CompilerAccess
Parameters:
stepId - the ID of the last step to be compiled
lazyMode - a flag indicating if the compiler should run in lazy mode or not
ignoreCompiledStatus - if TRUE, only the graph structure determines which Steps are compiled. If FALSE, only those Steps among the predecessors of the given Step are compiled that have not been compiled yet. In the latter case, only Steps on the shortest paths from a compiled step to the given Step are compiled, and no Steps that precede an already compiled Step are compiled.
Throws:
M4CompilerInterfaceError
M4CompilerWarning
UserError
See Also:
edu.udo.cs.miningmart.compiler.CompilerAccessImpl#compileStepTo(long, boolean)

updateColumnStatistics

public void updateColumnStatistics(long columnID)
                            throws M4CompilerInterfaceError
Description copied from interface: CompilerAccess
Uses the stored procedures of the database to update the statistics of the specified column.

Specified by:
updateColumnStatistics in interface CompilerAccess
Parameters:
columnID - the ID of column set in table COLUMN_T for which the statistics shall be updated
Throws:
M4CompilerInterfaceError
See Also:
edu.udo.cs.miningmart.compiler.CompilerAccessImpl#updateColumnStatistics(long)

updateColumnsetStatistics

public void updateColumnsetStatistics(long columnsetID)
                               throws M4CompilerInterfaceError
Description copied from interface: CompilerAccess
Uses the stored procedures of the database to update the statistics of the specified column set and of all the columns contained in the column set.

Specified by:
updateColumnsetStatistics in interface CompilerAccess
Parameters:
columnsetID - the ID of column set in table COLUMNSET_T for which the statistics shall be updated
Throws:
M4CompilerInterfaceError
See Also:
edu.udo.cs.miningmart.compiler.CompilerAccessImpl#updateColumnsetStatistics(long)

updateStatisticsForConcept

public void updateStatisticsForConcept(long conceptID)
                                throws M4CompilerInterfaceError
Description copied from interface: CompilerAccess
Uses the stored procedures of the database to update all the statistics which are related to the specified concept. These are the statistics of the related column sets and of all the columns contained.

Specified by:
updateStatisticsForConcept in interface CompilerAccess
Parameters:
conceptID - the ID of the concept in table CONCEPT_T for which the statistics shall be updated
Throws:
M4CompilerInterfaceError
See Also:
edu.udo.cs.miningmart.compiler.CompilerAccessImpl#updateStatisticsForConcept(long)

deleteTrashForStep

public void deleteTrashForStep(long stepId)
                        throws M4CompilerInterfaceError
Description copied from interface: CompilerAccess
Runs the garbage collection for the specified Step and all subsequent dependent Steps with respect to the entries in the table STEPSEQUENCE_T.

Specified by:
deleteTrashForStep in interface CompilerAccess
Parameters:
stepId - the ID of the (first) Step to run the garbage collection for.
Throws:
M4CompilerInterfaceError
See Also:
edu.udo.cs.miningmart.compiler.CompilerAccessImpl#deleteTrashForStep(long)

deleteTrashForCase

public void deleteTrashForCase(long caseId)
                        throws M4CompilerInterfaceError
Description copied from interface: CompilerAccess
Runs the garbage collection for all Steps of a specified Case.

Specified by:
deleteTrashForCase in interface CompilerAccess
Parameters:
caseId - of the Case to run the garbage collection for.
Throws:
M4CompilerInterfaceError
See Also:
edu.udo.cs.miningmart.compiler.CompilerAccessImpl#deleteTrashForCase(long)

getStatusMessage

public java.lang.String getStatusMessage(long caseId,
                                         int numberOfLines)
                                  throws M4CompilerInterfaceError
Description copied from interface: CompilerAccess
Reads the status message of a running compiler server thread.

Specified by:
getStatusMessage in interface CompilerAccess
Parameters:
caseId - the id of the case to receive log information for. Because of the case locking mechanism each case is never compiled more than once at the same time, so this is a unique Thread identifier. A caseId of 0 or lower is interpreted as the default Print class, used before having found the right case or in case of severe errors.
numberOfLines - the numberOfLines to be returned
Returns:
the last number of lines from the status logfile of the thread The first line holds the line number after the last line, so that using this number as the line number in the next call will return the log messages collected in between.
Throws:
M4CompilerInterfaceError
See Also:
edu.udo.cs.miningmart.compiler.CompilerAccessImpl#getStatusMessage(long, int)

getStatusFromLine

public java.lang.String getStatusFromLine(long caseId,
                                          int lineNumber)
                                   throws M4CompilerInterfaceError
Description copied from interface: CompilerAccess
Reads the status message of a running compiler server thread. A start line number is specified. The log messages starting from this line number up to the end are returned.

Specified by:
getStatusFromLine in interface CompilerAccess
Parameters:
caseId - the id of the case to receive log information for. Because of the case locking mechanism each case is never compiled more than once at the same time, so this is a unique Thread identifier. A caseId of 0 or lower is interpreted as the default Print class, used before having found the right case or in case of severe errors.
lineNumber - the first line of the logfile to be returned
Returns:
the last lines from the status logfile of the thread, starting with the lineNumber specified as a parameter.
Throws:
M4CompilerInterfaceError
See Also:
edu.udo.cs.miningmart.compiler.CompilerAccessImpl#getStatusFromLine(long, int)

changeCompilerOutputVerbosity

public void changeCompilerOutputVerbosity(long caseId,
                                          java.util.logging.Level newVerbosity)
                                   throws M4CompilerInterfaceError
Description copied from interface: CompilerAccess
Change the verbosity level of the compiler log messages for the given case.

Specified by:
changeCompilerOutputVerbosity in interface CompilerAccess
Parameters:
caseId - the id of the case to receive log information for. Because of the case locking mechanism each case is never compiled more than once at the same time, so this is a unique Thread identifier. A caseId of 0 or lower is interpreted as the default Print class, used before having found the right case or in case of severe errors.
newVerbosity - The new verbosity. Use one of the public constants of the class edu.udo.cs.miningmart.m4.utils.Print, if possible.
Throws:
M4CompilerInterfaceError
See Also:
edu.udo.cs.miningmart.compiler.CompilerAccessImpl#changeCompilerOutputVerbosity(long, int)

isReadyForCompilation

public boolean isReadyForCompilation(long stepId)
                              throws M4CompilerInterfaceError
Description copied from interface: CompilerAccess
This method checks for a given Step, if it can currently be compiled. Validity aspects are not checked, but for all Steps the given Step depends on (regarding to STEPSEQUENCE_T) it is made sure that they have recently (after the last garbage collection) been compiled, so the outputs of these Steps are available in the database.

Specified by:
isReadyForCompilation in interface CompilerAccess
Parameters:
stepId - the ID of the Step
Returns:
if all Steps this Step depends on have been compiled
Throws:
M4CompilerInterfaceError
See Also:
edu.udo.cs.miningmart.compiler.CompilerAccessImpl#isReadyForCompilation(long)

compileRestOfCase

public void compileRestOfCase(long caseId,
                              boolean lazyMode)
                       throws M4CompilerInterfaceError,
                              M4CompilerWarning
A call to this method compiles only those steps of a case which have not already been compiled. Please note that for eager mode it is not checked, whether all steps compiled earlier were also compiled in eager mode!

Parameters:
caseId - the ID of the case to be compiled
lazyMode - indicates if the steps should be compiled in lazy mode
Throws:
M4CompilerInterfaceError
M4CompilerWarning

getDb

public CompilerDatabaseService getDb()
Gets the instance of class DB representing the database access to both the M4 and business schema.

Returns:
the DB object for the current thread

getM4db

public DB getM4db()
Same as getDb(), but with less specific return type for the implemented interface.

Specified by:
getM4db in interface M4InterfaceContext

getCurrentPrintObject

public Print getCurrentPrintObject()
Gets the instance of the Case-dependent Print object, if available. If no such object could be set up, yet, then the default Print object is returned instead.

Returns:
a Print object to be used in the current compiler run

getStopRequest

public boolean getStopRequest()
Checked to decide, if an exception should be thrown to stop execution.

Specified by:
getStopRequest in interface M4InterfaceContext
Returns:
true iff the Thread should not continue.

getCase

public Case getCase()
Specified by:
getCase in interface M4InterfaceContext
Returns:
the Case associated with this CompilerAccessLogic object.

getPrintObject

public Print getPrintObject()
Specified by:
getPrintObject in interface M4InterfaceContext
See Also:
miningmart.compiler.utils.CompilerAccessLogic.getPrintObject()

compileAll

public void compileAll(long caseId,
                       boolean lazy,
                       int verbosity)
                throws M4CompilerInterfaceError,
                       M4CompilerWarning,
                       UserError
Throws:
M4CompilerInterfaceError
M4CompilerWarning
UserError

compileStep

public void compileStep(long stepId,
                        boolean lazy,
                        int verbosity)
                 throws M4CompilerInterfaceError,
                        M4CompilerWarning,
                        UserError
Throws:
M4CompilerInterfaceError
M4CompilerWarning
UserError

compileStepFrom

public void compileStepFrom(long stepId,
                            boolean lazy,
                            int verbosity)
                     throws M4CompilerInterfaceError,
                            M4CompilerWarning,
                            UserError
Throws:
M4CompilerInterfaceError
M4CompilerWarning
UserError

killCompilerThread

public boolean killCompilerThread(long caseId)
Description copied from interface: CompilerAccess
This method kills a running compiler thread. Threads are identified by the Case they are compiling. Nevertheless, for a few seconds after launching a compileStep command this method may not succeed in identifying the right Thread. For this reason, there is a return value. It is a good idea to send kill request until true is returned. A Thread is killed by a special exception, which is finally translated to an M4CompilerInterfaceError.

Specified by:
killCompilerThread in interface CompilerAccess
Parameters:
caseId - The ID of the case for which the compiler thread should be killed.
Returns:
true iff a thread for the given case has been found and the the kill flag has been set.


Copyright © 2001-2005