org.rhq.core.domain.operation
Class OperationHistory

java.lang.Object
  extended by org.rhq.core.domain.operation.OperationHistory
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
GroupOperationHistory, ResourceOperationHistory

public abstract class OperationHistory
extends Object
implements Serializable

The entity that represents an operation invocation that is either in progress or has completed. This is the superclass to both the the individual resource history object (that encapsulates the results) and the group history object (for group invocations across multiple resources).

See Also:
Serialized Form

Field Summary
static String QUERY_DELETE_BY_DEFINITION
           
static String QUERY_DELETE_BY_HISTORY_IDS
           
static String QUERY_FIND_BY_JOB_ID
           
static String QUERY_GET_PARAMETER_CONFIGURATION_IDS
           
static String QUERY_GET_RECENTLY_COMPLETED_GROUP
           
static String QUERY_GET_RECENTLY_COMPLETED_GROUP_ADMIN
           
static String QUERY_GET_RECENTLY_COMPLETED_RESOURCE
           
static String QUERY_GET_RECENTLY_COMPLETED_RESOURCE_ADMIN
           
static String QUERY_GET_RESULT_CONFIGURATION_IDS
           
 
Constructor Summary
protected OperationHistory()
           
protected OperationHistory(String jobName, String jobGroup, String subjectName, OperationDefinition operationDefinition, Configuration parameters)
           
 
Method Summary
 boolean equals(Object obj)
           
 long getCreatedTime()
          The time this entity was originally created.
 long getDuration()
          The duration of the operation invocation which simply is the difference between the getCreatedTime() and the getModifiedTime().
 String getErrorMessage()
          If not null, this is an error message (possibly a full stack trace) to indicate the overall error that occurred when the operation failed.
 int getId()
           
 String getJobGroup()
           
 HistoryJobId getJobId()
          The single job ID which identifies this specific history item.
 String getJobName()
           
 long getModifiedTime()
          The time this entity was last modified.
 OperationDefinition getOperationDefinition()
           
 Configuration getParameters()
           
 long getStartedTime()
          The time when corresponding operation was started.
 OperationRequestStatus getStatus()
          The status of the operation which indicates that the invocation is either still in progress, or it has completed and either succeeded or failed.
 String getSubjectName()
          For auditing purposes, this method tells you the username of the person that invoked the operation.
 int hashCode()
           
 void setErrorMessage(String errorMessage)
          Calling this method with a non-null error message implies that the request's status is OperationRequestStatus.FAILURE.
 void setId(int id)
           
 void setJobGroup(String jobGroup)
           
 void setJobName(String jobName)
           
 void setOperationDefinition(OperationDefinition operationDefinition)
           
 void setParameters(Configuration parameters)
           
 void setStartedTime()
          This method MUST be called when the corresponding operation is triggered, but before the request is sent down to the agent.
 void setStatus(OperationRequestStatus status)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

QUERY_FIND_BY_JOB_ID

public static final String QUERY_FIND_BY_JOB_ID
See Also:
Constant Field Values

QUERY_GET_RECENTLY_COMPLETED_RESOURCE

public static final String QUERY_GET_RECENTLY_COMPLETED_RESOURCE
See Also:
Constant Field Values

QUERY_GET_RECENTLY_COMPLETED_RESOURCE_ADMIN

public static final String QUERY_GET_RECENTLY_COMPLETED_RESOURCE_ADMIN
See Also:
Constant Field Values

QUERY_GET_RECENTLY_COMPLETED_GROUP

public static final String QUERY_GET_RECENTLY_COMPLETED_GROUP
See Also:
Constant Field Values

QUERY_GET_RECENTLY_COMPLETED_GROUP_ADMIN

public static final String QUERY_GET_RECENTLY_COMPLETED_GROUP_ADMIN
See Also:
Constant Field Values

QUERY_GET_PARAMETER_CONFIGURATION_IDS

public static final String QUERY_GET_PARAMETER_CONFIGURATION_IDS
See Also:
Constant Field Values

QUERY_GET_RESULT_CONFIGURATION_IDS

public static final String QUERY_GET_RESULT_CONFIGURATION_IDS
See Also:
Constant Field Values

QUERY_DELETE_BY_HISTORY_IDS

public static final String QUERY_DELETE_BY_HISTORY_IDS
See Also:
Constant Field Values

QUERY_DELETE_BY_DEFINITION

public static final String QUERY_DELETE_BY_DEFINITION
See Also:
Constant Field Values
Constructor Detail

OperationHistory

protected OperationHistory()

OperationHistory

protected OperationHistory(String jobName,
                           String jobGroup,
                           String subjectName,
                           OperationDefinition operationDefinition,
                           Configuration parameters)
Method Detail

getJobId

public HistoryJobId getJobId()
The single job ID which identifies this specific history item. It can later be parsed via HistoryJobId.HistoryJobId(String).

Returns:
job ID

getId

public int getId()

setId

public void setId(int id)

getJobName

public String getJobName()

setJobName

public void setJobName(String jobName)

getJobGroup

public String getJobGroup()

setJobGroup

public void setJobGroup(String jobGroup)

getOperationDefinition

public OperationDefinition getOperationDefinition()

setOperationDefinition

public void setOperationDefinition(OperationDefinition operationDefinition)

getParameters

public Configuration getParameters()

setParameters

public void setParameters(Configuration parameters)

getStatus

public OperationRequestStatus getStatus()
The status of the operation which indicates that the invocation is either still in progress, or it has completed and either succeeded or failed. This may return null if the job hasn't even been triggered yet.

Returns:
the request status

setStatus

public void setStatus(OperationRequestStatus status)

getErrorMessage

public String getErrorMessage()
If not null, this is an error message (possibly a full stack trace) to indicate the overall error that occurred when the operation failed. This will normally be null unless the status indicates a OperationRequestStatus.FAILURE.

Returns:
overall error that occurred

setErrorMessage

public void setErrorMessage(String errorMessage)
Calling this method with a non-null error message implies that the request's status is OperationRequestStatus.FAILURE. The inverse is not true - that is, if you set the error message to null, the status is left as-is; it will not assume that a null error message means the status is successful.

Parameters:
errorMessage -

getSubjectName

public String getSubjectName()
For auditing purposes, this method tells you the username of the person that invoked the operation. This is not a relationship to an actual Subject because we want to maintain the audit trail, even if a Subject has been deleted from the database.

Returns:
the actual name string of the submitter of the operation invocation

getCreatedTime

public long getCreatedTime()
The time this entity was originally created. This may, but will not necessarily, be similar or nearly identical to the getStartedTime() value. If this is an operation on a single resource, then these two figures will be very similar because resource operations are started immediately after the history element is created for them. If this is an operation on a resource group, especially a large group, then these two figures might diverge considerably because all history elements are created up front, and then the process begins executing each in turn.

Returns:
creation time, in epoch milliseconds
See Also:
getStartedTime()

getModifiedTime

public long getModifiedTime()
The time this entity was last modified. This is the last time the status was updated. If the status has never been updated, this will be the created time.

Returns:
last modified time, in epoch milliseconds

setStartedTime

public void setStartedTime()
This method MUST be called when the corresponding operation is triggered, but before the request is sent down to the agent. The started time is used in the calculation of getDuration(), which is in turn used by the business layer to reason whether an operation has timed out. If this method is never called, and if there are any issues executing the corresponding operation, this history element will never time out and will forever stay in the OperationRequestStatus.INPROGRESS state.

Throws:
IllegalArgumentException - if an attempt is made to start this object more than once
See Also:
getCreatedTime()

getStartedTime

public long getStartedTime()
The time when corresponding operation was started. If the corresponding operation has not yet been started, this method will return 0.

Returns:
started time, in epoch millis

getDuration

public long getDuration()
The duration of the operation invocation which simply is the difference between the getCreatedTime() and the getModifiedTime(). If the operation hasn't completed yet, this will be the difference between the current time and the created time.

Returns:
the duration of time that the operation took or is taking to complete

toString

public String toString()
Overrides:
toString in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object


Copyright © 2008-2011 Red Hat, Inc.. All Rights Reserved.