public class ExecutionLog extends Object
CustomTasks.| Modifier and Type | Class and Description |
|---|---|
static class |
ExecutionLog.TaskState
Represents the current state of a task.
|
| Modifier | Constructor and Description |
|---|---|
protected |
ExecutionLog(com.google.gson.JsonObject json)
Creates a new Execution Log from the provided JSON representation.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object obj) |
Optional<String> |
getCode()
If this log refers to a
CustomTask, the code that was run is returned. |
Optional<org.joda.time.DateTime> |
getEnd()
If this task is in the
ExecutionLog.TaskState.RUNNING state, returns an empty Optional. |
Set<String> |
getFiles()
Returns an immutable set of all the filenames output by the task during its execution.
|
String |
getHostname()
Returns the canonical hostname of the machine that ran this task.
|
String |
getId()
Returns the unique identifier of this execution.
|
Optional<String> |
getStackTrace()
If the task is in the
ExecutionLog.TaskState.RUNNING state, returns the stack trace of the execution thrown by the task, if one
is present. |
org.joda.time.DateTime |
getStart()
Returns the date in which this execution has started.
|
ExecutionLog.TaskState |
getState()
Returns the
ExecutionLog.TaskState for this execution. |
String |
getTaskName()
Returns the name of the task that this execution refers to.
|
Optional<String> |
getUser()
If this log refers to a
CustomTask, the username of the user that ran the task is returned. |
int |
hashCode() |
com.google.gson.JsonObject |
json()
Returns a JSON representation of this log.
|
static ExecutionLog |
newCustomExecution(String taskName,
String code,
String user)
Creates a new execution log for the given custom task, taking note of the code that was run, and the user who ran it.
|
static ExecutionLog |
newExecutionFor(String taskName)
Creates a new execution log for the given task, automatically assigning it a randomly-generated unique identifier.
|
ExecutionLog |
withError(Throwable t)
Creates a new
ExecutionLog based on this one, marking it as failed, with the stack trace provided by the given
throwable. |
ExecutionLog |
withFile(String filename)
Creates a new
ExecutionLog based on this one, with the given filename added to the list of files generated by the
task. |
ExecutionLog |
withSuccess()
Creates a new
ExecutionLog based on this one, marking it as successful, ending in the moment of the method call. |
protected ExecutionLog(com.google.gson.JsonObject json)
json() method, otherwise the results of invoking
this constructor are undefined.json - The JSON object containing the description of an execution logpublic static ExecutionLog newExecutionFor(String taskName)
ExecutionLog.TaskState.RUNNING state, with the current time as the start time.taskName - The name of the task that was runNullPointerException - If the task name is nullpublic static ExecutionLog newCustomExecution(String taskName, String code, String user)
newExecutionFor(String) method, the returned log is assigned a randomly-generated unique identifier,
an is in the ExecutionLog.TaskState.RUNNING state, with the current time as the start time.taskName - The name of the task that was runcode - The code that was runuser - The user who ran the taskNullPointerException - If either the task name, code or user is nullpublic String getId()
public org.joda.time.DateTime getStart()
public Optional<org.joda.time.DateTime> getEnd()
ExecutionLog.TaskState.RUNNING state, returns an empty Optional. Otherwise returns the date in
which this execution has ended.public ExecutionLog.TaskState getState()
ExecutionLog.TaskState for this execution.public String getTaskName()
public Optional<String> getStackTrace()
ExecutionLog.TaskState.RUNNING state, returns the stack trace of the execution thrown by the task, if one
is present.
Otherwise, returns an empty Optional.public Set<String> getFiles()
public String getHostname()
public Optional<String> getCode()
CustomTask, the code that was run is returned. Otherwise, returns an empty Optional
.public Optional<String> getUser()
CustomTask, the username of the user that ran the task is returned. Otherwise, returns an
empty Optional.public ExecutionLog withSuccess()
ExecutionLog based on this one, marking it as successful, ending in the moment of the method call.
This is typically invoked upon successful task completion, so that it may be recorded in the log repository.public ExecutionLog withError(Throwable t)
ExecutionLog based on this one, marking it as failed, with the stack trace provided by the given
throwable. The returned log has its end date as the current date.
This is typically invoked upon failed task completion, so that it may be recorded in the log repository.t - The exception that caused this task to failpublic ExecutionLog withFile(String filename)
ExecutionLog based on this one, with the given filename added to the list of files generated by the
task.filename - The name of the file to be addedNullPointerException - If the given filename was nullpublic com.google.gson.JsonObject json()
Note: The JSON returned by this method can be used by log repositories to re-create instances of
ExecutionLog from their JSON representation, via the package-protected ExecutionLog(JsonObject)
constructor.
Copyright © 2018 FenixEdu. All rights reserved.