Package org.elasticsearch.tasks
Class TaskResult
- java.lang.Object
-
- org.elasticsearch.tasks.TaskResult
-
- All Implemented Interfaces:
Writeable
,ToXContent
,ToXContentObject
public final class TaskResult extends java.lang.Object implements Writeable, ToXContentObject
Information about a running task or a task that stored its result. Running tasks just have agetTask()
while tasks with stored result will have either agetError()
orgetResponse()
.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.elasticsearch.common.xcontent.ToXContent
ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.Params
-
Nested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V>
-
-
Field Summary
Fields Modifier and Type Field Description static ConstructingObjectParser<TaskResult,java.lang.Void>
PARSER
-
Fields inherited from interface org.elasticsearch.common.xcontent.ToXContent
EMPTY_PARAMS
-
-
Constructor Summary
Constructors Constructor Description TaskResult(boolean completed, TaskInfo task)
Construct a TaskResult for a task for which we don't have a result or error.TaskResult(StreamInput in)
Read from a stream.TaskResult(TaskInfo task, java.lang.Exception error)
Construct a TaskResult for a task that completed with an error.TaskResult(TaskInfo task, ToXContent response)
Construct a TaskResult for a task that completed successfully.
-
Method Summary
Modifier and Type Method Description boolean
equals(java.lang.Object obj)
BytesReference
getError()
Get the error that finished this task.java.util.Map<java.lang.String,java.lang.Object>
getErrorAsMap()
ConvertgetError()
from XContent to a Map for easy processing.BytesReference
getResponse()
Get the response that this task finished with.java.util.Map<java.lang.String,java.lang.Object>
getResponseAsMap()
ConvertgetResponse()
from XContent to a Map for easy processing.TaskInfo
getTask()
Get the task that this wraps.int
hashCode()
XContentBuilder
innerToXContent(XContentBuilder builder, ToXContent.Params params)
boolean
isCompleted()
java.lang.String
toString()
XContentBuilder
toXContent(XContentBuilder builder, ToXContent.Params params)
void
writeTo(StreamOutput out)
Write this into the StreamOutput.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.elasticsearch.common.xcontent.ToXContentObject
isFragment
-
-
-
-
Field Detail
-
PARSER
public static final ConstructingObjectParser<TaskResult,java.lang.Void> PARSER
-
-
Constructor Detail
-
TaskResult
public TaskResult(boolean completed, TaskInfo task)
Construct a TaskResult for a task for which we don't have a result or error. That usually means that the task is incomplete, but it could also mean that we waited for the task to complete but it didn't save any error information.
-
TaskResult
public TaskResult(TaskInfo task, java.lang.Exception error) throws java.io.IOException
Construct a TaskResult for a task that completed with an error.- Throws:
java.io.IOException
-
TaskResult
public TaskResult(TaskInfo task, ToXContent response) throws java.io.IOException
Construct a TaskResult for a task that completed successfully.- Throws:
java.io.IOException
-
TaskResult
public TaskResult(StreamInput in) throws java.io.IOException
Read from a stream.- Throws:
java.io.IOException
-
-
Method Detail
-
writeTo
public void writeTo(StreamOutput out) throws java.io.IOException
Description copied from interface:Writeable
Write this into the StreamOutput.
-
getTask
public TaskInfo getTask()
Get the task that this wraps.
-
getError
public BytesReference getError()
Get the error that finished this task. Will return null if the task didn't finish with an error, it hasn't yet finished, or didn't store its result.
-
getErrorAsMap
public java.util.Map<java.lang.String,java.lang.Object> getErrorAsMap()
ConvertgetError()
from XContent to a Map for easy processing. Will return an empty map if the task didn't finish with an error, hasn't yet finished, or didn't store its result.
-
getResponse
public BytesReference getResponse()
Get the response that this task finished with. Will return null if the task was finished by an error, it hasn't yet finished, or didn't store its result.
-
getResponseAsMap
public java.util.Map<java.lang.String,java.lang.Object> getResponseAsMap()
ConvertgetResponse()
from XContent to a Map for easy processing. Will return an empty map if the task was finished with an error, hasn't yet finished, or didn't store its result.
-
isCompleted
public boolean isCompleted()
-
toXContent
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws java.io.IOException
- Specified by:
toXContent
in interfaceToXContent
- Throws:
java.io.IOException
-
innerToXContent
public XContentBuilder innerToXContent(XContentBuilder builder, ToXContent.Params params) throws java.io.IOException
- Throws:
java.io.IOException
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
-