use of com.google.protobuf.ServiceException in project SSM by Intel-bigdata.
the class ClientSmartProtocolServerSideTranslatorPB method listRulesInfo.
@Override
public ListRulesInfoResponseProto listRulesInfo(RpcController controller, ListRulesInfoRequestProto req) throws ServiceException {
try {
List<RuleInfo> infos = server.listRulesInfo();
List<RuleInfoProto> infoProtos = new ArrayList<>();
for (RuleInfo info : infos) {
infoProtos.add(PBHelper.convert(info));
}
return ListRulesInfoResponseProto.newBuilder().addAllRulesInfo(infoProtos).build();
} catch (IOException e) {
throw new ServiceException(e);
}
}
use of com.google.protobuf.ServiceException in project SSM by Intel-bigdata.
the class ClientSmartProtocolServerSideTranslatorPB method listActionInfoOfLastActions.
@Override
public ListActionInfoOfLastActionsResponseProto listActionInfoOfLastActions(RpcController controller, ListActionInfoOfLastActionsRequestProto request) throws ServiceException {
try {
List<ActionInfo> list = server.listActionInfoOfLastActions(request.getMaxNumActions());
if (list == null) {
return ListActionInfoOfLastActionsResponseProto.newBuilder().build();
}
List<ActionInfoProto> protoList = new ArrayList<>();
for (ActionInfo a : list) {
protoList.add(PBHelper.convert(a));
}
return ListActionInfoOfLastActionsResponseProto.newBuilder().addAllActionInfoList(protoList).build();
} catch (IOException e) {
throw new ServiceException(e);
}
}
use of com.google.protobuf.ServiceException in project SSM by Intel-bigdata.
the class ClientSmartProtocolServerSideTranslatorPB method listCommandInfo.
@Override
public ListCommandInfoResponseProto listCommandInfo(RpcController controller, ListCommandInfoRequestProto req) throws ServiceException {
try {
List<CommandInfo> list = server.listCommandInfo(req.getRuleID(), CommandState.fromValue(req.getCommandState()));
if (list == null)
return ListCommandInfoResponseProto.newBuilder().build();
List<CommandInfoProto> protoList = new ArrayList<>();
for (CommandInfo info : list) {
protoList.add(PBHelper.convert(info));
}
return ListCommandInfoResponseProto.newBuilder().addAllCommandInfos(protoList).build();
} catch (IOException e) {
throw new ServiceException(e);
}
}
use of com.google.protobuf.ServiceException in project SSM by Intel-bigdata.
the class SmartAdminProtocolAdminSideTranslatorPB method listCommandInfo.
@Override
public List<CommandInfo> listCommandInfo(long rid, CommandState commandState) throws IOException {
ListCommandInfoRequestProto req = ListCommandInfoRequestProto.newBuilder().setRuleID(rid).setCommandState(commandState.getValue()).build();
try {
List<CommandInfoProto> protoslist = rpcProxy.listCommandInfo(null, req).getCommandInfosList();
if (protoslist == null)
return new ArrayList<>();
List<CommandInfo> list = new ArrayList<>();
for (CommandInfoProto infoProto : protoslist) {
list.add(PBHelper.convert(infoProto));
}
return list;
} catch (ServiceException e) {
throw PBHelper.getRemoteException(e);
}
}
use of com.google.protobuf.ServiceException in project hive by apache.
the class LlapTaskCommunicator method registerRunningTaskAttempt.
@Override
public void registerRunningTaskAttempt(final ContainerId containerId, final TaskSpec taskSpec, Map<String, LocalResource> additionalResources, Credentials credentials, boolean credentialsChanged, int priority) {
super.registerRunningTaskAttempt(containerId, taskSpec, additionalResources, credentials, credentialsChanged, priority);
int dagId = taskSpec.getTaskAttemptID().getTaskID().getVertexID().getDAGId().getId();
if (currentQueryIdentifierProto == null || (dagId != currentQueryIdentifierProto.getDagIndex())) {
// TODO HiveQueryId extraction by parsing the Processor payload is ugly. This can be improved
// once TEZ-2672 is fixed.
String hiveQueryId;
try {
hiveQueryId = extractQueryId(taskSpec);
} catch (IOException e) {
throw new RuntimeException("Failed to extract query id from task spec: " + taskSpec, e);
}
Preconditions.checkNotNull(hiveQueryId, "Unexpected null query id");
resetCurrentDag(dagId, hiveQueryId);
}
ContainerInfo containerInfo = getContainerInfo(containerId);
String host;
int port;
if (containerInfo != null) {
synchronized (containerInfo) {
host = containerInfo.host;
port = containerInfo.port;
}
} else {
// TODO Handle this properly
throw new RuntimeException("ContainerInfo not found for container: " + containerId + ", while trying to launch task: " + taskSpec.getTaskAttemptID());
}
LlapNodeId nodeId = LlapNodeId.getInstance(host, port);
registerKnownNode(nodeId);
entityTracker.registerTaskAttempt(containerId, taskSpec.getTaskAttemptID(), host, port);
nodesForQuery.add(nodeId);
sourceStateTracker.registerTaskForStateUpdates(host, port, taskSpec.getInputs());
FragmentRuntimeInfo fragmentRuntimeInfo;
try {
fragmentRuntimeInfo = sourceStateTracker.getFragmentRuntimeInfo(taskSpec.getVertexName(), taskSpec.getTaskAttemptID().getTaskID().getId(), priority);
} catch (Exception e) {
LOG.error("Error while trying to get runtimeFragmentInfo for fragmentId={}, containerId={}, currentQI={}, currentQueryId={}", taskSpec.getTaskAttemptID(), containerId, currentQueryIdentifierProto, currentHiveQueryId, e);
if (e instanceof RuntimeException) {
throw (RuntimeException) e;
} else {
throw new RuntimeException(e);
}
}
SubmitWorkRequestProto requestProto;
try {
requestProto = constructSubmitWorkRequest(containerId, taskSpec, fragmentRuntimeInfo, currentHiveQueryId);
} catch (IOException e) {
throw new RuntimeException("Failed to construct request", e);
}
// Have to register this up front right now. Otherwise, it's possible for the task to start
// sending out status/DONE/KILLED/FAILED messages before TAImpl knows how to handle them.
getContext().taskStartedRemotely(taskSpec.getTaskAttemptID(), containerId);
communicator.sendSubmitWork(requestProto, host, port, new LlapProtocolClientProxy.ExecuteRequestCallback<SubmitWorkResponseProto>() {
@Override
public void setResponse(SubmitWorkResponseProto response) {
if (response.hasSubmissionState()) {
LlapDaemonProtocolProtos.SubmissionStateProto ss = response.getSubmissionState();
if (ss.equals(LlapDaemonProtocolProtos.SubmissionStateProto.REJECTED)) {
LOG.info("Unable to run task: " + taskSpec.getTaskAttemptID() + " on containerId: " + containerId + ", Service Busy");
getContext().taskKilled(taskSpec.getTaskAttemptID(), TaskAttemptEndReason.EXECUTOR_BUSY, "Service Busy");
return;
}
} else {
// This should never happen as server always returns a valid status on success
throw new RuntimeException("SubmissionState in response is expected!");
}
if (response.hasUniqueNodeId()) {
entityTracker.registerTaskSubmittedToNode(taskSpec.getTaskAttemptID(), response.getUniqueNodeId());
}
LOG.info("Successfully launched task: " + taskSpec.getTaskAttemptID());
scheduler.notifyStarted(taskSpec.getTaskAttemptID());
}
@Override
public void indicateError(Throwable t) {
Throwable originalError = t;
if (t instanceof ServiceException) {
ServiceException se = (ServiceException) t;
t = se.getCause();
}
if (t instanceof RemoteException) {
// All others from the remote service cause the task to FAIL.
LOG.info("Failed to run task: " + taskSpec.getTaskAttemptID() + " on containerId: " + containerId, t);
processSendError(originalError);
getContext().taskFailed(taskSpec.getTaskAttemptID(), TaskFailureType.NON_FATAL, TaskAttemptEndReason.OTHER, t.toString());
} else {
// Exception from the RPC layer - communication failure, consider as KILLED / service down.
if (t instanceof IOException) {
LOG.info("Unable to run task: " + taskSpec.getTaskAttemptID() + " on containerId: " + containerId + ", Communication Error");
processSendError(originalError);
getContext().taskKilled(taskSpec.getTaskAttemptID(), TaskAttemptEndReason.COMMUNICATION_ERROR, "Communication Error");
} else {
// Anything else is a FAIL.
LOG.info("Failed to run task: " + taskSpec.getTaskAttemptID() + " on containerId: " + containerId, t);
processSendError(originalError);
getContext().taskFailed(taskSpec.getTaskAttemptID(), TaskFailureType.NON_FATAL, TaskAttemptEndReason.OTHER, t.getMessage());
}
}
}
});
}
Aggregations