Search in sources :

Example 61 with ServiceException

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);
    }
}
Also used : ServiceException(com.google.protobuf.ServiceException) ArrayList(java.util.ArrayList) RuleInfoProto(org.smartdata.common.protocol.AdminServerProto.RuleInfoProto) IOException(java.io.IOException) RuleInfo(org.smartdata.common.rule.RuleInfo)

Example 62 with ServiceException

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);
    }
}
Also used : ActionInfoProto(org.smartdata.common.protocol.AdminServerProto.ActionInfoProto) ServiceException(com.google.protobuf.ServiceException) ArrayList(java.util.ArrayList) ActionInfo(org.smartdata.common.actions.ActionInfo) IOException(java.io.IOException)

Example 63 with ServiceException

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);
    }
}
Also used : CommandInfo(org.smartdata.common.command.CommandInfo) ServiceException(com.google.protobuf.ServiceException) ArrayList(java.util.ArrayList) CommandInfoProto(org.smartdata.common.protocol.AdminServerProto.CommandInfoProto) IOException(java.io.IOException)

Example 64 with ServiceException

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);
    }
}
Also used : CommandInfo(org.smartdata.common.command.CommandInfo) ListCommandInfoRequestProto(org.smartdata.common.protocol.AdminServerProto.ListCommandInfoRequestProto) ServiceException(com.google.protobuf.ServiceException) ArrayList(java.util.ArrayList) CommandInfoProto(org.smartdata.common.protocol.AdminServerProto.CommandInfoProto)

Example 65 with ServiceException

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());
                }
            }
        }
    });
}
Also used : FragmentRuntimeInfo(org.apache.hadoop.hive.llap.daemon.rpc.LlapDaemonProtocolProtos.FragmentRuntimeInfo) ByteString(com.google.protobuf.ByteString) IOException(java.io.IOException) ServiceException(com.google.protobuf.ServiceException) RetriableException(org.apache.hadoop.ipc.RetriableException) TezUncheckedException(org.apache.tez.dag.api.TezUncheckedException) IOException(java.io.IOException) RemoteException(org.apache.hadoop.ipc.RemoteException) TezException(org.apache.tez.dag.api.TezException) LlapNodeId(org.apache.hadoop.hive.llap.LlapNodeId) ServiceException(com.google.protobuf.ServiceException) SubmitWorkRequestProto(org.apache.hadoop.hive.llap.daemon.rpc.LlapDaemonProtocolProtos.SubmitWorkRequestProto) SubmitWorkResponseProto(org.apache.hadoop.hive.llap.daemon.rpc.LlapDaemonProtocolProtos.SubmitWorkResponseProto) LlapProtocolClientProxy(org.apache.hadoop.hive.llap.tez.LlapProtocolClientProxy) RemoteException(org.apache.hadoop.ipc.RemoteException)

Aggregations

ServiceException (com.google.protobuf.ServiceException)139 IOException (java.io.IOException)66 Test (org.junit.Test)22 ArrayList (java.util.ArrayList)12 Configuration (org.apache.hadoop.conf.Configuration)11 FsPermission (org.apache.hadoop.fs.permission.FsPermission)5 Table (org.apache.hadoop.hbase.client.Table)5 CoprocessorRpcChannel (org.apache.hadoop.hbase.ipc.CoprocessorRpcChannel)5 InetSocketAddress (java.net.InetSocketAddress)4 DatanodeCommand (org.apache.hadoop.hdfs.server.protocol.DatanodeCommand)4 ByteString (com.google.protobuf.ByteString)3 InterruptedIOException (java.io.InterruptedIOException)3 ConnectException (java.net.ConnectException)3 SocketTimeoutException (java.net.SocketTimeoutException)3 Callable (java.util.concurrent.Callable)3 ExecutionException (java.util.concurrent.ExecutionException)3 ExecutorService (java.util.concurrent.ExecutorService)3 EncryptionZone (org.apache.hadoop.hdfs.protocol.EncryptionZone)3 LocatedBlock (org.apache.hadoop.hdfs.protocol.LocatedBlock)3 Server (org.apache.hadoop.ipc.Server)3