if (queryId.equals(QueryIdFactory.NULL_QUERY_ID)) {
builder.setResultCode(ClientProtos.ResultCode.OK);
builder.setState(TajoProtos.QueryState.QUERY_SUCCEEDED);
} else {
QueryMasterTask queryMasterTask = workerContext.getQueryMaster().getQueryMasterTask(queryId);
builder.setResultCode(ClientProtos.ResultCode.OK);
builder.setQueryMasterHost(bindAddr.getHostName());
builder.setQueryMasterPort(bindAddr.getPort());
if (queryMasterTask == null) {
queryMasterTask = workerContext.getQueryMaster().getQueryMasterTask(queryId, true);
}
if (queryMasterTask == null) {
builder.setState(TajoProtos.QueryState.QUERY_NOT_ASSIGNED);
return builder.build();
}
builder.setHasResult(
!(queryMasterTask.getQueryTaskContext().getQueryContext().isCreateTable() ||
queryMasterTask.getQueryTaskContext().getQueryContext().isInsert())
);
queryMasterTask.touchSessionTime();
Query query = queryMasterTask.getQuery();
if (query != null) {
builder.setState(query.getState());
builder.setProgress(query.getProgress());
builder.setSubmitTime(query.getAppSubmitTime());
if (query.getState() == TajoProtos.QueryState.QUERY_SUCCEEDED) {
builder.setFinishTime(query.getFinishTime());
} else {
builder.setFinishTime(System.currentTimeMillis());
}
} else {
builder.setState(queryMasterTask.getState());
builder.setErrorMessage(queryMasterTask.getErrorMessage());
}
}
return builder.build();
}