com.google.protobuf.RpcController Java Examples
The following examples show how to use
com.google.protobuf.RpcController.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ClientNamenodeProtocolServerSideTranslatorPB.java From big-c with Apache License 2.0 | 6 votes |
@Override public ListCachePoolsResponseProto listCachePools(RpcController controller, ListCachePoolsRequestProto request) throws ServiceException { try { BatchedEntries<CachePoolEntry> entries = server.listCachePools(request.getPrevPoolName()); ListCachePoolsResponseProto.Builder responseBuilder = ListCachePoolsResponseProto.newBuilder(); responseBuilder.setHasMore(entries.hasMore()); for (int i=0, n=entries.size(); i<n; i++) { responseBuilder.addEntries(PBHelper.convert(entries.get(i))); } return responseBuilder.build(); } catch (IOException e) { throw new ServiceException(e); } }
Example #2
Source File: RpcForwarder.java From protobuf-socket-rpc with MIT License | 6 votes |
private void forwardToService(SocketRpcProtos.Request rpcRequest, RpcCallback<Message> callback, Service service, RpcController socketController) throws RpcException { // Get matching method MethodDescriptor method = getMethod(rpcRequest, service.getDescriptorForType()); // Create request for method Message request = getRequestProto(rpcRequest, service.getRequestPrototype(method)); // Call method try { service.callMethod(method, socketController, request, callback); } catch (RuntimeException e) { throw new RpcException(ErrorReason.RPC_ERROR, "Error running method " + method.getFullName(), e); } }
Example #3
Source File: ClientNamenodeProtocolServerSideTranslatorPB.java From big-c with Apache License 2.0 | 6 votes |
@Override public GetDelegationTokenResponseProto getDelegationToken( RpcController controller, GetDelegationTokenRequestProto req) throws ServiceException { try { Token<DelegationTokenIdentifier> token = server .getDelegationToken(new Text(req.getRenewer())); GetDelegationTokenResponseProto.Builder rspBuilder = GetDelegationTokenResponseProto.newBuilder(); if (token != null) { rspBuilder.setToken(PBHelper.convert(token)); } return rspBuilder.build(); } catch (IOException e) { throw new ServiceException(e); } }
Example #4
Source File: TxnLifecycleEndpoint.java From spliceengine with GNU Affero General Public License v3.0 | 6 votes |
@Override public void getActiveTransactionIds(RpcController controller,TxnMessage.ActiveTxnRequest request,RpcCallback<TxnMessage.ActiveTxnIdResponse> done){ long endTxnId=request.getEndTxnId(); long startTxnId=request.getStartTxnId(); try (RpcUtils.RootEnv env = RpcUtils.getRootEnv()) { byte[] destTables=null; if(request.hasDestinationTables()) destTables=request.getDestinationTables().toByteArray(); long[] activeTxnIds=lifecycleStore.getActiveTransactionIds(destTables,startTxnId,endTxnId); TxnMessage.ActiveTxnIdResponse.Builder response=TxnMessage.ActiveTxnIdResponse.newBuilder(); //noinspection ForLoopReplaceableByForEach for(int i=0;i<activeTxnIds.length;i++){ response.addActiveTxnIds(activeTxnIds[i]); } done.run(response.build()); }catch(IOException e){ setControllerException(controller,e); } }
Example #5
Source File: ClientNamenodeProtocolServerSideTranslatorPB.java From hadoop with Apache License 2.0 | 6 votes |
@Override public GetEZForPathResponseProto getEZForPath( RpcController controller, GetEZForPathRequestProto req) throws ServiceException { try { GetEZForPathResponseProto.Builder builder = GetEZForPathResponseProto.newBuilder(); final EncryptionZone ret = server.getEZForPath(req.getSrc()); if (ret != null) { builder.setZone(PBHelper.convert(ret)); } return builder.build(); } catch (IOException e) { throw new ServiceException(e); } }
Example #6
Source File: TajoMasterClientService.java From tajo with Apache License 2.0 | 6 votes |
@Override public KeyValueSetResponse getAllSessionVariables(RpcController controller, TajoIdProtos.SessionIdProto request) throws ServiceException { try { String sessionId = request.getId(); KeyValueSet keyValueSet = new KeyValueSet(); keyValueSet.putAll(context.getSessionManager().getAllVariables(sessionId)); return KeyValueSetResponse.newBuilder() .setState(OK) .setValue(keyValueSet.getProto()) .build(); } catch (Throwable t) { printStackTraceIfError(LOG, t); return KeyValueSetResponse.newBuilder() .setState(returnError(t)) .build(); } }
Example #7
Source File: CatalogServer.java From tajo with Apache License 2.0 | 6 votes |
@Override public GetTablesResponse getAllTables(RpcController controller, NullProto request) throws ServiceException { rlock.lock(); try { return GetTablesResponse.newBuilder() .setState(OK) .addAllTable(store.getAllTables()) .build(); } catch (Throwable t) { printStackTraceIfError(LOG, t); return GetTablesResponse.newBuilder() .setState(returnError(t)) .build(); } finally { rlock.unlock(); } }
Example #8
Source File: ClientNamenodeProtocolServerSideTranslatorPB.java From big-c with Apache License 2.0 | 6 votes |
@Override public GetEZForPathResponseProto getEZForPath( RpcController controller, GetEZForPathRequestProto req) throws ServiceException { try { GetEZForPathResponseProto.Builder builder = GetEZForPathResponseProto.newBuilder(); final EncryptionZone ret = server.getEZForPath(req.getSrc()); if (ret != null) { builder.setZone(PBHelper.convert(ret)); } return builder.build(); } catch (IOException e) { throw new ServiceException(e); } }
Example #9
Source File: CatalogServer.java From tajo with Apache License 2.0 | 6 votes |
@Override public IndexListResponse getAllIndexes(RpcController controller, NullProto request) throws ServiceException { rlock.lock(); try { return IndexListResponse.newBuilder().setState(OK).addAllIndexDesc(store.getAllIndexes()).build(); } catch (Throwable t) { printStackTraceIfError(LOG, t); return IndexListResponse.newBuilder() .setState(returnError(t)) .build(); } finally { rlock.unlock(); } }
Example #10
Source File: GetUserMappingsProtocolServerSideTranslatorPB.java From hadoop with Apache License 2.0 | 6 votes |
@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(); }
Example #11
Source File: ClientNamenodeProtocolServerSideTranslatorPB.java From hadoop with Apache License 2.0 | 6 votes |
@Override public AddBlockResponseProto addBlock(RpcController controller, AddBlockRequestProto req) throws ServiceException { try { List<DatanodeInfoProto> excl = req.getExcludeNodesList(); List<String> favor = req.getFavoredNodesList(); LocatedBlock result = server.addBlock( req.getSrc(), req.getClientName(), req.hasPrevious() ? PBHelper.convert(req.getPrevious()) : null, (excl == null || excl.size() == 0) ? null : PBHelper.convert(excl .toArray(new DatanodeInfoProto[excl.size()])), req.getFileId(), (favor == null || favor.size() == 0) ? null : favor .toArray(new String[favor.size()])); return AddBlockResponseProto.newBuilder() .setBlock(PBHelper.convert(result)).build(); } catch (IOException e) { throw new ServiceException(e); } }
Example #12
Source File: HSAdminRefreshProtocolServerSideTranslatorPB.java From hadoop with Apache License 2.0 | 5 votes |
@Override public RefreshLogRetentionSettingsResponseProto refreshLogRetentionSettings( RpcController controller, RefreshLogRetentionSettingsRequestProto request) throws ServiceException { try { impl.refreshLogRetentionSettings(); } catch (IOException e) { throw new ServiceException(e); } return VOID_REFRESH_LOG_RETENTION_SETTINGS_RESPONSE; }
Example #13
Source File: ClientNamenodeProtocolServerSideTranslatorPB.java From big-c with Apache License 2.0 | 5 votes |
@Override public SetXAttrResponseProto setXAttr(RpcController controller, SetXAttrRequestProto req) throws ServiceException { try { server.setXAttr(req.getSrc(), PBHelper.convertXAttr(req.getXAttr()), PBHelper.convert(req.getFlag())); } catch (IOException e) { throw new ServiceException(e); } return VOID_SETXATTR_RESPONSE; }
Example #14
Source File: ClientNamenodeProtocolServerSideTranslatorPB.java From hadoop with Apache License 2.0 | 5 votes |
@Override public ReportBadBlocksResponseProto reportBadBlocks(RpcController controller, ReportBadBlocksRequestProto req) throws ServiceException { try { List<LocatedBlockProto> bl = req.getBlocksList(); server.reportBadBlocks(PBHelper.convertLocatedBlock( bl.toArray(new LocatedBlockProto[bl.size()]))); } catch (IOException e) { throw new ServiceException(e); } return VOID_REP_BAD_BLOCK_RESPONSE; }
Example #15
Source File: ClientNamenodeProtocolServerSideTranslatorPB.java From hadoop with Apache License 2.0 | 5 votes |
@Override public AbandonBlockResponseProto abandonBlock(RpcController controller, AbandonBlockRequestProto req) throws ServiceException { try { server.abandonBlock(PBHelper.convert(req.getB()), req.getFileId(), req.getSrc(), req.getHolder()); } catch (IOException e) { throw new ServiceException(e); } return VOID_ADD_BLOCK_RESPONSE; }
Example #16
Source File: JournalProtocolServerSideTranslatorPB.java From hadoop with Apache License 2.0 | 5 votes |
@Override public FenceResponseProto fence(RpcController controller, FenceRequestProto req) throws ServiceException { try { FenceResponse resp = impl.fence(PBHelper.convert(req.getJournalInfo()), req.getEpoch(), req.getFencerInfo()); return FenceResponseProto.newBuilder().setInSync(resp.isInSync()) .setLastTransactionId(resp.getLastTransactionId()) .setPreviousEpoch(resp.getPreviousEpoch()).build(); } catch (IOException e) { throw new ServiceException(e); } }
Example #17
Source File: ClientNamenodeProtocolServerSideTranslatorPB.java From hadoop with Apache License 2.0 | 5 votes |
@Override public SetOwnerResponseProto setOwner(RpcController controller, SetOwnerRequestProto req) throws ServiceException { try { server.setOwner(req.getSrc(), req.hasUsername() ? req.getUsername() : null, req.hasGroupname() ? req.getGroupname() : null); } catch (IOException e) { throw new ServiceException(e); } return VOID_SET_OWNER_RESPONSE; }
Example #18
Source File: HSAdminRefreshProtocolServerSideTranslatorPB.java From big-c with Apache License 2.0 | 5 votes |
@Override public RefreshAdminAclsResponseProto refreshAdminAcls( RpcController controller, RefreshAdminAclsRequestProto request) throws ServiceException { try { impl.refreshAdminAcls(); } catch (IOException e) { throw new ServiceException(e); } return VOID_REFRESH_ADMIN_ACLS_RESPONSE; }
Example #19
Source File: HSAdminRefreshProtocolServerSideTranslatorPB.java From big-c with Apache License 2.0 | 5 votes |
@Override public RefreshJobRetentionSettingsResponseProto refreshJobRetentionSettings( RpcController controller, RefreshJobRetentionSettingsRequestProto request) throws ServiceException { try { impl.refreshJobRetentionSettings(); } catch (IOException e) { throw new ServiceException(e); } return VOID_REFRESH_JOB_RETENTION_SETTINGS_RESPONSE; }
Example #20
Source File: ClientNamenodeProtocolServerSideTranslatorPB.java From hadoop with Apache License 2.0 | 5 votes |
@Override public RemoveCacheDirectiveResponseProto removeCacheDirective(RpcController controller, RemoveCacheDirectiveRequestProto request) throws ServiceException { try { server.removeCacheDirective(request.getId()); return RemoveCacheDirectiveResponseProto. newBuilder().build(); } catch (IOException e) { throw new ServiceException(e); } }
Example #21
Source File: MRClientProtocolPBServiceImpl.java From big-c with Apache License 2.0 | 5 votes |
@Override public GetDelegationTokenResponseProto getDelegationToken( RpcController controller, GetDelegationTokenRequestProto proto) throws ServiceException { GetDelegationTokenRequest request = new GetDelegationTokenRequestPBImpl(proto); try { GetDelegationTokenResponse response = real.getDelegationToken(request); return ((GetDelegationTokenResponsePBImpl)response).getProto(); } catch (IOException e) { throw new ServiceException(e); } }
Example #22
Source File: NamenodeProtocolServerSideTranslatorPB.java From hadoop with Apache License 2.0 | 5 votes |
@Override public GetTransactionIdResponseProto getTransactionId(RpcController unused, GetTransactionIdRequestProto request) throws ServiceException { long txid; try { txid = impl.getTransactionID(); } catch (IOException e) { throw new ServiceException(e); } return GetTransactionIdResponseProto.newBuilder().setTxId(txid).build(); }
Example #23
Source File: ClientDatanodeProtocolServerSideTranslatorPB.java From hadoop with Apache License 2.0 | 5 votes |
@Override public RefreshNamenodesResponseProto refreshNamenodes( RpcController unused, RefreshNamenodesRequestProto request) throws ServiceException { try { impl.refreshNamenodes(); } catch (IOException e) { throw new ServiceException(e); } return REFRESH_NAMENODE_RESP; }
Example #24
Source File: NamenodeProtocolServerSideTranslatorPB.java From hadoop with Apache License 2.0 | 5 votes |
@Override public GetBlocksResponseProto getBlocks(RpcController unused, GetBlocksRequestProto request) throws ServiceException { DatanodeInfo dnInfo = new DatanodeInfo(PBHelper.convert(request .getDatanode())); BlocksWithLocations blocks; try { blocks = impl.getBlocks(dnInfo, request.getSize()); } catch (IOException e) { throw new ServiceException(e); } return GetBlocksResponseProto.newBuilder() .setBlocks(PBHelper.convert(blocks)).build(); }
Example #25
Source File: DatanodeProtocolServerSideTranslatorPB.java From hadoop with Apache License 2.0 | 5 votes |
@Override public RegisterDatanodeResponseProto registerDatanode( RpcController controller, RegisterDatanodeRequestProto request) throws ServiceException { DatanodeRegistration registration = PBHelper.convert(request .getRegistration()); DatanodeRegistration registrationResp; try { registrationResp = impl.registerDatanode(registration); } catch (IOException e) { throw new ServiceException(e); } return RegisterDatanodeResponseProto.newBuilder() .setRegistration(PBHelper.convert(registrationResp)).build(); }
Example #26
Source File: FakeServiceImpl.java From protobuf-socket-rpc with MIT License | 5 votes |
@Override public Response testMethod(RpcController controller, Request request) throws ServiceException { Assert.assertEquals(expectedRequest, request); if (error != null) { controller.setFailed(error); throw new ServiceException(error); } if (rex != null) { throw rex; } return response; }
Example #27
Source File: DatanodeProtocolServerSideTranslatorPB.java From hadoop with Apache License 2.0 | 5 votes |
@Override public ReportBadBlocksResponseProto reportBadBlocks(RpcController controller, ReportBadBlocksRequestProto request) throws ServiceException { List<LocatedBlockProto> lbps = request.getBlocksList(); LocatedBlock [] blocks = new LocatedBlock [lbps.size()]; for(int i=0; i<lbps.size(); i++) { blocks[i] = PBHelper.convert(lbps.get(i)); } try { impl.reportBadBlocks(blocks); } catch (IOException e) { throw new ServiceException(e); } return VOID_REPORT_BAD_BLOCK_RESPONSE; }
Example #28
Source File: DatanodeProtocolServerSideTranslatorPB.java From hadoop with Apache License 2.0 | 5 votes |
@Override public VersionResponseProto versionRequest(RpcController controller, VersionRequestProto request) throws ServiceException { NamespaceInfo info; try { info = impl.versionRequest(); } catch (IOException e) { throw new ServiceException(e); } return VersionResponseProto.newBuilder() .setInfo(PBHelper.convert(info)).build(); }
Example #29
Source File: QJournalProtocolServerSideTranslatorPB.java From big-c with Apache License 2.0 | 5 votes |
@Override public PurgeLogsResponseProto purgeLogs(RpcController controller, PurgeLogsRequestProto req) throws ServiceException { try { impl.purgeLogsOlderThan(convert(req.getReqInfo()), req.getMinTxIdToKeep()); } catch (IOException e) { throw new ServiceException(e); } return PurgeLogsResponseProto.getDefaultInstance(); }
Example #30
Source File: CatalogServer.java From tajo with Apache License 2.0 | 5 votes |
@Override public GetTablespaceResponse getTablespace(RpcController controller, StringProto request) { rlock.lock(); try { // if there exists the tablespace in linked meta data Optional<Pair<String, URI>> optional = linkedMetadataManager.getTablespace(request.getValue()); if (optional.isPresent()) { Pair<String, URI> spaceInfo = optional.get(); return GetTablespaceResponse.newBuilder() .setState(OK) .setTablespace(TablespaceProto.newBuilder() .setSpaceName(spaceInfo.getFirst()) .setUri(spaceInfo.getSecond().toString()) ).build(); } return GetTablespaceResponse.newBuilder() .setState(OK) .setTablespace(store.getTablespace(request.getValue())) .build(); } catch (Throwable t) { printStackTraceIfError(LOG, t); return GetTablespaceResponse.newBuilder() .setState(returnError(t)) .build(); } finally { rlock.unlock(); } }