Search in sources :

Example 11 with BasicThrowable

use of co.cask.cdap.proto.BasicThrowable in project cdap by caskdata.

the class RemoteRuntimeStoreHandler method setStop.

@POST
@Path("/setStop")
public void setStop(HttpRequest request, HttpResponder responder) throws Exception {
    Iterator<MethodArgument> arguments = parseArguments(request);
    ProgramId program = deserializeNext(arguments);
    String pid = deserializeNext(arguments);
    long endTime = deserializeNext(arguments);
    ProgramRunStatus runStatus = deserializeNext(arguments);
    BasicThrowable failureCause = deserializeNext(arguments);
    store.setStop(program, pid, endTime, runStatus, failureCause);
    responder.sendStatus(HttpResponseStatus.OK);
}
Also used : ProgramRunStatus(co.cask.cdap.proto.ProgramRunStatus) MethodArgument(co.cask.cdap.common.internal.remote.MethodArgument) ProgramId(co.cask.cdap.proto.id.ProgramId) BasicThrowable(co.cask.cdap.proto.BasicThrowable) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST)

Example 12 with BasicThrowable

use of co.cask.cdap.proto.BasicThrowable in project cdap by caskdata.

the class BasicThrowableCodec method deserialize.

@Override
public BasicThrowable deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
    JsonObject jsonObj = json.getAsJsonObject();
    String className = jsonObj.get("className").getAsString();
    String message = jsonObj.get("message") == null ? null : jsonObj.get("message").getAsString();
    JsonArray stackTraces = jsonObj.get("stackTraces").getAsJsonArray();
    StackTraceElement[] stackTraceElements = context.deserialize(stackTraces, StackTraceElement[].class);
    JsonElement cause = jsonObj.get("cause");
    BasicThrowable basicThrowable = null;
    if (cause != null) {
        basicThrowable = context.deserialize(cause, BasicThrowable.class);
    }
    return new BasicThrowable(className, message, stackTraceElements, basicThrowable);
}
Also used : JsonArray(com.google.gson.JsonArray) JsonElement(com.google.gson.JsonElement) JsonObject(com.google.gson.JsonObject) BasicThrowable(co.cask.cdap.proto.BasicThrowable)

Example 13 with BasicThrowable

use of co.cask.cdap.proto.BasicThrowable in project cdap by caskdata.

the class BasicThrowableCodec method serialize.

@Override
public JsonElement serialize(BasicThrowable src, Type typeOfSrc, JsonSerializationContext context) {
    JsonObject json = new JsonObject();
    json.addProperty("className", src.getClassName());
    json.addProperty("message", src.getMessage());
    json.add("stackTraces", context.serialize(src.getStackTraces(), StackTraceElement[].class));
    json.add("cause", context.serialize(src.getCause(), BasicThrowable.class));
    return json;
}
Also used : JsonObject(com.google.gson.JsonObject) BasicThrowable(co.cask.cdap.proto.BasicThrowable)

Aggregations

BasicThrowable (co.cask.cdap.proto.BasicThrowable)13 ProgramId (co.cask.cdap.proto.id.ProgramId)4 ProgramController (co.cask.cdap.app.runtime.ProgramController)3 AbstractListener (co.cask.cdap.internal.app.runtime.AbstractListener)3 ProgramRunStatus (co.cask.cdap.proto.ProgramRunStatus)3 WorkflowNodeStateDetail (co.cask.cdap.proto.WorkflowNodeStateDetail)3 BasicArguments (co.cask.cdap.internal.app.runtime.BasicArguments)2 SimpleProgramOptions (co.cask.cdap.internal.app.runtime.SimpleProgramOptions)2 ApplicationId (co.cask.cdap.proto.id.ApplicationId)2 ProgramRunId (co.cask.cdap.proto.id.ProgramRunId)2 Supplier (com.google.common.base.Supplier)2 JsonObject (com.google.gson.JsonObject)2 Nullable (javax.annotation.Nullable)2 RunId (org.apache.twill.api.RunId)2 ServiceListenerAdapter (org.apache.twill.internal.ServiceListenerAdapter)2 Test (org.junit.Test)2 ApplicationSpecification (co.cask.cdap.api.app.ApplicationSpecification)1 ArtifactSummary (co.cask.cdap.api.artifact.ArtifactSummary)1 DatasetContext (co.cask.cdap.api.data.DatasetContext)1 DatasetManagementException (co.cask.cdap.api.dataset.DatasetManagementException)1