Search in sources :

Example 1 with ServiceException

use of com.google.protobuf.ServiceException in project hadoop by apache.

the class TraceAdminProtocolServerSideTranslatorPB method addSpanReceiver.

@Override
public AddSpanReceiverResponseProto addSpanReceiver(RpcController controller, AddSpanReceiverRequestProto req) throws ServiceException {
    try {
        SpanReceiverInfoBuilder factory = new SpanReceiverInfoBuilder(req.getClassName());
        for (ConfigPair config : req.getConfigList()) {
            factory.addConfigurationPair(config.getKey(), config.getValue());
        }
        long id = server.addSpanReceiver(factory.build());
        return AddSpanReceiverResponseProto.newBuilder().setId(id).build();
    } catch (IOException e) {
        throw new ServiceException(e);
    }
}
Also used : ConfigPair(org.apache.hadoop.tracing.TraceAdminPB.ConfigPair) ServiceException(com.google.protobuf.ServiceException) IOException(java.io.IOException)

Example 2 with ServiceException

use of com.google.protobuf.ServiceException in project hadoop by apache.

the class TraceAdminProtocolTranslatorPB method listSpanReceivers.

@Override
public SpanReceiverInfo[] listSpanReceivers() throws IOException {
    ArrayList<SpanReceiverInfo> infos = new ArrayList<SpanReceiverInfo>(1);
    try {
        ListSpanReceiversRequestProto req = ListSpanReceiversRequestProto.newBuilder().build();
        ListSpanReceiversResponseProto resp = rpcProxy.listSpanReceivers(null, req);
        for (SpanReceiverListInfo info : resp.getDescriptionsList()) {
            infos.add(new SpanReceiverInfo(info.getId(), info.getClassName()));
        }
    } catch (ServiceException e) {
        throw ProtobufHelper.getRemoteException(e);
    }
    return infos.toArray(new SpanReceiverInfo[infos.size()]);
}
Also used : ServiceException(com.google.protobuf.ServiceException) ArrayList(java.util.ArrayList) SpanReceiverListInfo(org.apache.hadoop.tracing.TraceAdminPB.SpanReceiverListInfo) ListSpanReceiversRequestProto(org.apache.hadoop.tracing.TraceAdminPB.ListSpanReceiversRequestProto) ListSpanReceiversResponseProto(org.apache.hadoop.tracing.TraceAdminPB.ListSpanReceiversResponseProto)

Example 3 with ServiceException

use of com.google.protobuf.ServiceException in project hadoop by apache.

the class TraceAdminProtocolTranslatorPB method addSpanReceiver.

@Override
public long addSpanReceiver(SpanReceiverInfo info) throws IOException {
    try {
        AddSpanReceiverRequestProto.Builder bld = AddSpanReceiverRequestProto.newBuilder();
        bld.setClassName(info.getClassName());
        for (ConfigurationPair configPair : info.configPairs) {
            ConfigPair tuple = ConfigPair.newBuilder().setKey(configPair.getKey()).setValue(configPair.getValue()).build();
            bld.addConfig(tuple);
        }
        AddSpanReceiverResponseProto resp = rpcProxy.addSpanReceiver(null, bld.build());
        return resp.getId();
    } catch (ServiceException e) {
        throw ProtobufHelper.getRemoteException(e);
    }
}
Also used : ConfigPair(org.apache.hadoop.tracing.TraceAdminPB.ConfigPair) AddSpanReceiverResponseProto(org.apache.hadoop.tracing.TraceAdminPB.AddSpanReceiverResponseProto) ServiceException(com.google.protobuf.ServiceException) AddSpanReceiverRequestProto(org.apache.hadoop.tracing.TraceAdminPB.AddSpanReceiverRequestProto) ConfigurationPair(org.apache.hadoop.tracing.SpanReceiverInfo.ConfigurationPair)

Example 4 with ServiceException

use of com.google.protobuf.ServiceException in project hadoop by apache.

the class TraceAdminProtocolTranslatorPB method removeSpanReceiver.

@Override
public void removeSpanReceiver(long spanReceiverId) throws IOException {
    try {
        RemoveSpanReceiverRequestProto req = RemoveSpanReceiverRequestProto.newBuilder().setId(spanReceiverId).build();
        rpcProxy.removeSpanReceiver(null, req);
    } catch (ServiceException e) {
        throw ProtobufHelper.getRemoteException(e);
    }
}
Also used : RemoveSpanReceiverRequestProto(org.apache.hadoop.tracing.TraceAdminPB.RemoveSpanReceiverRequestProto) ServiceException(com.google.protobuf.ServiceException)

Example 5 with ServiceException

use of com.google.protobuf.ServiceException in project hadoop by apache.

the class GetUserMappingsProtocolClientSideTranslatorPB method getGroupsForUser.

@Override
public String[] getGroupsForUser(String user) throws IOException {
    GetGroupsForUserRequestProto request = GetGroupsForUserRequestProto.newBuilder().setUser(user).build();
    GetGroupsForUserResponseProto resp;
    try {
        resp = rpcProxy.getGroupsForUser(NULL_CONTROLLER, request);
    } catch (ServiceException se) {
        throw ProtobufHelper.getRemoteException(se);
    }
    return resp.getGroupsList().toArray(new String[resp.getGroupsCount()]);
}
Also used : ServiceException(com.google.protobuf.ServiceException) GetGroupsForUserResponseProto(org.apache.hadoop.tools.proto.GetUserMappingsProtocolProtos.GetGroupsForUserResponseProto) GetGroupsForUserRequestProto(org.apache.hadoop.tools.proto.GetUserMappingsProtocolProtos.GetGroupsForUserRequestProto)

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