Search in sources :

Example 6 with ServiceException

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

the class GetUserMappingsProtocolServerSideTranslatorPB method getGroupsForUser.

@Override
public GetGroupsForUserResponseProto getGroupsForUser(RpcController controller, GetGroupsForUserRequestProto request) throws ServiceException {
    String[] groups;
    try {
        groups = impl.getGroupsForUser(request.getUser());
    } catch (IOException e) {
        throw new ServiceException(e);
    }
    GetGroupsForUserResponseProto.Builder builder = GetGroupsForUserResponseProto.newBuilder();
    for (String g : groups) {
        builder.addGroups(g);
    }
    return builder.build();
}
Also used : ServiceException(com.google.protobuf.ServiceException) GetGroupsForUserResponseProto(org.apache.hadoop.tools.proto.GetUserMappingsProtocolProtos.GetGroupsForUserResponseProto) IOException(java.io.IOException)

Example 7 with ServiceException

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

the class ProtocolMetaInfoServerSideTranslatorPB method getProtocolSignature.

@Override
public GetProtocolSignatureResponseProto getProtocolSignature(RpcController controller, GetProtocolSignatureRequestProto request) throws ServiceException {
    GetProtocolSignatureResponseProto.Builder builder = GetProtocolSignatureResponseProto.newBuilder();
    String protocol = request.getProtocol();
    String rpcKind = request.getRpcKind();
    long[] versions;
    try {
        versions = getProtocolVersionForRpcKind(RPC.RpcKind.valueOf(rpcKind), protocol);
    } catch (ClassNotFoundException e1) {
        throw new ServiceException(e1);
    }
    if (versions == null) {
        return builder.build();
    }
    for (long v : versions) {
        ProtocolSignatureProto.Builder sigBuilder = ProtocolSignatureProto.newBuilder();
        sigBuilder.setVersion(v);
        try {
            ProtocolSignature signature = ProtocolSignature.getProtocolSignature(protocol, v);
            for (int m : signature.getMethods()) {
                sigBuilder.addMethods(m);
            }
        } catch (ClassNotFoundException e) {
            throw new ServiceException(e);
        }
        builder.addProtocolSignature(sigBuilder.build());
    }
    return builder.build();
}
Also used : ProtocolSignatureProto(org.apache.hadoop.ipc.protobuf.ProtocolInfoProtos.ProtocolSignatureProto) ServiceException(com.google.protobuf.ServiceException) GetProtocolSignatureResponseProto(org.apache.hadoop.ipc.protobuf.ProtocolInfoProtos.GetProtocolSignatureResponseProto)

Example 8 with ServiceException

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

the class ProtocolMetaInfoServerSideTranslatorPB method getProtocolVersions.

@Override
public GetProtocolVersionsResponseProto getProtocolVersions(RpcController controller, GetProtocolVersionsRequestProto request) throws ServiceException {
    String protocol = request.getProtocol();
    GetProtocolVersionsResponseProto.Builder builder = GetProtocolVersionsResponseProto.newBuilder();
    for (RPC.RpcKind r : RPC.RpcKind.values()) {
        long[] versions;
        try {
            versions = getProtocolVersionForRpcKind(r, protocol);
        } catch (ClassNotFoundException e) {
            throw new ServiceException(e);
        }
        ProtocolVersionProto.Builder b = ProtocolVersionProto.newBuilder();
        if (versions != null) {
            b.setRpcKind(r.toString());
            for (long v : versions) {
                b.addVersions(v);
            }
        }
        builder.addProtocolVersions(b.build());
    }
    return builder.build();
}
Also used : ServiceException(com.google.protobuf.ServiceException) ProtocolVersionProto(org.apache.hadoop.ipc.protobuf.ProtocolInfoProtos.ProtocolVersionProto) GetProtocolVersionsResponseProto(org.apache.hadoop.ipc.protobuf.ProtocolInfoProtos.GetProtocolVersionsResponseProto)

Example 9 with ServiceException

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

the class GenericRefreshProtocolServerSideTranslatorPB method refresh.

@Override
public GenericRefreshResponseCollectionProto refresh(RpcController controller, GenericRefreshRequestProto request) throws ServiceException {
    try {
        List<String> argList = request.getArgsList();
        String[] args = argList.toArray(new String[argList.size()]);
        if (!request.hasIdentifier()) {
            throw new ServiceException("Request must contain identifier");
        }
        Collection<RefreshResponse> results = impl.refresh(request.getIdentifier(), args);
        return pack(results);
    } catch (IOException e) {
        throw new ServiceException(e);
    }
}
Also used : RefreshResponse(org.apache.hadoop.ipc.RefreshResponse) ServiceException(com.google.protobuf.ServiceException) IOException(java.io.IOException)

Example 10 with ServiceException

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

the class HAServiceProtocolClientSideTranslatorPB method transitionToStandby.

@Override
public void transitionToStandby(StateChangeRequestInfo reqInfo) throws IOException {
    try {
        TransitionToStandbyRequestProto req = TransitionToStandbyRequestProto.newBuilder().setReqInfo(convert(reqInfo)).build();
        rpcProxy.transitionToStandby(NULL_CONTROLLER, req);
    } catch (ServiceException e) {
        throw ProtobufHelper.getRemoteException(e);
    }
}
Also used : TransitionToStandbyRequestProto(org.apache.hadoop.ha.proto.HAServiceProtocolProtos.TransitionToStandbyRequestProto) ServiceException(com.google.protobuf.ServiceException)

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