mondrian.server
Class Execution

java.lang.Object
  extended by mondrian.server.Execution
Direct Known Subclasses:
MondrianOlap4jCellSet

public class Execution
extends Object

Execution context.

Loosely corresponds to a CellSet. A given statement may be executed several times over its lifetime, but at most one execution can be going on at a time.

Author:
jhyde

Nested Class Summary
static class Execution.State
          Enumeration of the states of an Execution instance.
 
Field Summary
static Execution NONE
           
(package private)  StatementImpl statement
           
 
Constructor Summary
Execution(Statement statement, long timeoutIntervalMillis)
           
 
Method Summary
 void cancel()
          Cancels the execution instance.
 void cancelSqlStatements()
          Called by the RolapResultShepherd when the execution needs to clean all of its resources for whatever reasons, typically when an exception has occurred or the execution has ended.
 void checkCancelOrTimeout()
          Checks the state of this Execution and throws an exception if something is wrong.
 void copyMDC()
          Copy the current MDC so it can be used later
 void end()
          Called when query execution has completed.
 long getElapsedMillis()
           
 long getId()
           
 Statement getMondrianStatement()
           
 QueryTiming getQueryTiming()
           
 long getStartTime()
           
 boolean isCancelOrTimeout()
          Returns whether this execution is currently in a failed state and will throw an exception as soon as the next check is performed using checkCancelOrTimeout().
 void registerStatement(Locus locus, Statement statement)
          This method is typically called by SqlStatement at construction time.
 void setContextMap()
          Set the copied mdc into the current MDC.
 void setOutOfMemory(String msg)
          This method will change the state of this execution to Execution.State.ERROR and will set the message to display.
 void start()
          Marks the start of an Execution instance.
 void tracePhase(int hitCount, int missCount, int pendingCount)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

statement

final StatementImpl statement

NONE

public static final Execution NONE
Constructor Detail

Execution

public Execution(Statement statement,
                 long timeoutIntervalMillis)
Method Detail

copyMDC

public void copyMDC()
Copy the current MDC so it can be used later


setContextMap

public void setContextMap()
Set the copied mdc into the current MDC. This should be called any time there will be logging in a thread handled by the RolapResultShepherd where original MDC needs to be retrieved


start

public void start()
Marks the start of an Execution instance. It is called by Statement.start(Execution) automatically. Users don't need to call this method.


tracePhase

public void tracePhase(int hitCount,
                       int missCount,
                       int pendingCount)

cancel

public void cancel()
Cancels the execution instance. Cleanup of the resources used by this execution instance will be performed in the background later on.


setOutOfMemory

public final void setOutOfMemory(String msg)
This method will change the state of this execution to Execution.State.ERROR and will set the message to display. Cleanup of the resources used by this execution instance will be performed in the background later on.

Parameters:
msg - The message to display to the user, describing the problem encountered with the memory space.

checkCancelOrTimeout

public void checkCancelOrTimeout()
                          throws MondrianException
Checks the state of this Execution and throws an exception if something is wrong. This method should be called by the user thread.

It won't throw anything if the query has successfully completed.

Throws:
MondrianException - The exception encountered.

isCancelOrTimeout

public boolean isCancelOrTimeout()
Returns whether this execution is currently in a failed state and will throw an exception as soon as the next check is performed using checkCancelOrTimeout().

Returns:
True or false, depending on the timeout state.

cancelSqlStatements

public void cancelSqlStatements()
Called by the RolapResultShepherd when the execution needs to clean all of its resources for whatever reasons, typically when an exception has occurred or the execution has ended. Any currently running SQL statements will be canceled. It should only be called if isCancelOrTimeout() returns true.

This method doesn't need to be called by a user. It will be called internally by Mondrian when the system is ready to clean the remaining resources.

To check if this execution is failed, use isCancelOrTimeout() instead.


end

public void end()
Called when query execution has completed. Once query execution has ended, it is not possible to cancel or timeout the query until it starts executing again.


getStartTime

public final long getStartTime()

getMondrianStatement

public final Statement getMondrianStatement()

getQueryTiming

public final QueryTiming getQueryTiming()

getId

public final long getId()

getElapsedMillis

public final long getElapsedMillis()

registerStatement

public void registerStatement(Locus locus,
                              Statement statement)
This method is typically called by SqlStatement at construction time. It ties all Statement objects to a particular Execution instance so that we can audit, monitor and gracefully cancel an execution.

Parameters:
statement - The statement used by this execution.

Get Mondrian at SourceForge.net. Fast, secure and free Open Source software downloads