Skip to content

Commit

Permalink
Add error code in UI
Browse files Browse the repository at this point in the history
  • Loading branch information
angoenka authored and electrum committed Jan 9, 2015
1 parent c32f7f7 commit a5752c6
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 6 deletions.
Expand Up @@ -16,6 +16,7 @@
import com.facebook.presto.Session;
import com.facebook.presto.client.FailureInfo;
import com.facebook.presto.spi.ErrorCode;
import com.facebook.presto.spi.StandardErrorCode.ErrorType;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.base.Preconditions;
Expand All @@ -31,6 +32,7 @@
import java.util.Map;
import java.util.Set;

import static com.facebook.presto.spi.StandardErrorCode.toErrorType;
import static com.google.common.base.MoreObjects.toStringHelper;

@Immutable
Expand All @@ -48,6 +50,7 @@ public class QueryInfo
private final Set<String> resetSessionProperties;
private final StageInfo outputStage;
private final FailureInfo failureInfo;
private final ErrorType errorType;
private final ErrorCode errorCode;
private final Set<Input> inputs;

Expand Down Expand Up @@ -91,16 +94,11 @@ public QueryInfo(
this.resetSessionProperties = ImmutableSet.copyOf(resetSessionProperties);
this.outputStage = outputStage;
this.failureInfo = failureInfo;
this.errorType = errorCode == null ? null : toErrorType(errorCode.getCode());
this.errorCode = errorCode;
this.inputs = ImmutableSet.copyOf(inputs);
}

@JsonProperty
public ErrorCode getErrorCode()
{
return errorCode;
}

@JsonProperty
public QueryId getQueryId()
{
Expand Down Expand Up @@ -174,6 +172,20 @@ public FailureInfo getFailureInfo()
return failureInfo;
}

@Nullable
@JsonProperty
public ErrorType getErrorType()
{
return errorType;
}

@Nullable
@JsonProperty
public ErrorCode getErrorCode()
{
return errorCode;
}

@JsonProperty
public Set<Input> getInputs()
{
Expand Down
Expand Up @@ -17,11 +17,14 @@
import com.facebook.presto.execution.QueryId;
import com.facebook.presto.execution.QueryInfo;
import com.facebook.presto.execution.QueryState;
import com.facebook.presto.spi.ErrorCode;
import com.facebook.presto.spi.StandardErrorCode.ErrorType;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.airlift.units.Duration;
import org.joda.time.DateTime;

import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;

import java.net.URI;
Expand All @@ -36,6 +39,8 @@ public class BasicQueryInfo
private final QueryId queryId;
private final Session session;
private final QueryState state;
private final ErrorType errorType;
private final ErrorCode errorCode;
private final boolean scheduled;
private final URI self;
private final String query;
Expand All @@ -52,6 +57,8 @@ public BasicQueryInfo(
@JsonProperty("queryId") QueryId queryId,
@JsonProperty("session") Session session,
@JsonProperty("state") QueryState state,
@JsonProperty("errorType") ErrorType errorType,
@JsonProperty("errorCode") ErrorCode errorCode,
@JsonProperty("scheduled") boolean scheduled,
@JsonProperty("self") URI self,
@JsonProperty("query") String query,
Expand All @@ -67,6 +74,8 @@ public BasicQueryInfo(
this.queryId = checkNotNull(queryId, "queryId is null");
this.session = checkNotNull(session, "session is null");
this.state = checkNotNull(state, "state is null");
this.errorType = errorType;
this.errorCode = errorCode;
this.scheduled = scheduled;
this.self = checkNotNull(self, "self is null");
this.query = checkNotNull(query, "query is null");
Expand All @@ -89,6 +98,8 @@ public BasicQueryInfo(QueryInfo queryInfo)
this(queryInfo.getQueryId(),
queryInfo.getSession(),
queryInfo.getState(),
queryInfo.getErrorType(),
queryInfo.getErrorCode(),
queryInfo.isScheduled(),
queryInfo.getSelf(),
queryInfo.getQuery(),
Expand Down Expand Up @@ -119,6 +130,20 @@ public QueryState getState()
return state;
}

@Nullable
@JsonProperty
public ErrorType getErrorType()
{
return errorType;
}

@Nullable
@JsonProperty
public ErrorCode getErrorCode()
{
return errorCode;
}

@JsonProperty
public boolean isScheduled()
{
Expand Down
14 changes: 14 additions & 0 deletions presto-main/src/main/resources/webapp/index.html
Expand Up @@ -49,6 +49,7 @@ <h1>Presto</h1>
<th>Source</th>
<th>User</th>
<th>State</th>
<th>Error</th>
<th>Done</th>
<th>Total</th>
<th>Completion</th>
Expand Down Expand Up @@ -128,6 +129,7 @@ <h1>Presto</h1>
queryInfo.session.source,
queryInfo.session.user,
queryInfo.state,
shortErrorType(queryInfo.errorType),
completedSplits,
splits,
d3.format("%")(splits == 0 ? 0 : completedSplits / splits)
Expand Down Expand Up @@ -216,6 +218,18 @@ <h1>Presto</h1>
return [stage].concat(flatten(substages));
}

function shortErrorType(errorType)
{
switch (errorType) {
case "USER_ERROR":
return "USER";
case "INTERNAL_ERROR":
return "INTERNAL";
case "INSUFFICIENT_RESOURCES":
return "RESOURCES";
}
return errorType;
}

function flatten(array)
{
Expand Down
20 changes: 20 additions & 0 deletions presto-main/src/main/resources/webapp/query.html
Expand Up @@ -98,6 +98,12 @@ <h2>Summary</h2>
<dt>Kill</dt>
<dd id="killQuery"></dd>

<dt>Error Type</dt>
<dd id="errorType"></dd>

<dt>Error Code</dt>
<dd id="errorCode"></dd>

<dt>Message</dt>
<dd id="failureMessage"></dd>

Expand Down Expand Up @@ -170,6 +176,20 @@ <h2>Tasks</h2>
d3.select('#failureMessage').html("&nbsp;");
}

if (query.errorType) {
d3.select('#errorType').text(query.errorType);
}
else {
d3.select('#errorType').html("&nbsp;");
}

if (query.errorCode) {
d3.select('#errorCode').text(query.errorCode.name + " (" + query.errorCode.code + ")");
}
else {
d3.select('#errorCode').html("&nbsp;");
}

var sessionPropertiesList = d3.select('#sessionProperties').append("ul");

for (property in query.session.systemProperties) {
Expand Down

0 comments on commit a5752c6

Please sign in to comment.