java类com.google.protobuf.ServiceException的实例源码

MasterClient.java 文件源码 项目:angel 阅读 32 收藏 0 点赞 0 评论 0
/**
 * Get task clocks for all matrices from Master
 * @return task clocks for all matrices from Master
 * @throws ServiceException
 */
public Int2ObjectOpenHashMap<Int2IntOpenHashMap> getTaskMatrixClocks() throws ServiceException {
  GetTaskMatrixClockResponse response = masterProxy.getTaskMatrixClocks(null,
    GetTaskMatrixClockRequest.newBuilder().build());
  Int2ObjectOpenHashMap<Int2IntOpenHashMap> taskIdToMatrixClocksMap = new Int2ObjectOpenHashMap<>(response.getTaskMatrixClocksCount());

  List<TaskMatrixClock> taskMatrixClocks = response.getTaskMatrixClocksList();
  int size = taskMatrixClocks.size();
  int matrixNum;
  for(int i = 0; i < size; i++) {
    Int2IntOpenHashMap matrixIdToClockMap = new Int2IntOpenHashMap(taskMatrixClocks.get(i).getMatrixClocksCount());
    taskIdToMatrixClocksMap.put(taskMatrixClocks.get(i).getTaskId().getTaskIndex(), matrixIdToClockMap);
    List<MatrixClock> matrixClocks = taskMatrixClocks.get(i).getMatrixClocksList();
    matrixNum = matrixClocks.size();
    for(int j = 0; j < matrixNum; j++) {
      matrixIdToClockMap.put(matrixClocks.get(j).getMatrixId(), matrixClocks.get(j).getClock());
    }
  }

  return taskIdToMatrixClocksMap;
}
ClientNamenodeProtocolTranslatorPB.java 文件源码 项目:hadoop 阅读 27 收藏 0 点赞 0 评论 0
@Override
public LocatedBlock getAdditionalDatanode(String src, long fileId,
    ExtendedBlock blk, DatanodeInfo[] existings, String[] existingStorageIDs,
    DatanodeInfo[] excludes,
    int numAdditionalNodes, String clientName) throws AccessControlException,
    FileNotFoundException, SafeModeException, UnresolvedLinkException,
    IOException {
  GetAdditionalDatanodeRequestProto req = GetAdditionalDatanodeRequestProto
      .newBuilder()
      .setSrc(src)
      .setFileId(fileId)
      .setBlk(PBHelper.convert(blk))
      .addAllExistings(PBHelper.convert(existings))
      .addAllExistingStorageUuids(Arrays.asList(existingStorageIDs))
      .addAllExcludes(PBHelper.convert(excludes))
      .setNumAdditionalNodes(numAdditionalNodes)
      .setClientName(clientName)
      .build();
  try {
    return PBHelper.convert(rpcProxy.getAdditionalDatanode(null, req)
        .getBlock());
  } catch (ServiceException e) {
    throw ProtobufHelper.getRemoteException(e);
  }
}
TraceAdminProtocolTranslatorPB.java 文件源码 项目:hadoop 阅读 23 收藏 0 点赞 0 评论 0
@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()]);
}
DatanodeProtocolClientSideTranslatorPB.java 文件源码 项目:hadoop 阅读 26 收藏 0 点赞 0 评论 0
@Override
public void blockReceivedAndDeleted(DatanodeRegistration registration,
    String poolId, StorageReceivedDeletedBlocks[] receivedAndDeletedBlocks)
    throws IOException {
  BlockReceivedAndDeletedRequestProto.Builder builder = 
      BlockReceivedAndDeletedRequestProto.newBuilder()
      .setRegistration(PBHelper.convert(registration))
      .setBlockPoolId(poolId);
  for (StorageReceivedDeletedBlocks storageBlock : receivedAndDeletedBlocks) {
    StorageReceivedDeletedBlocksProto.Builder repBuilder = 
        StorageReceivedDeletedBlocksProto.newBuilder();
    repBuilder.setStorageUuid(storageBlock.getStorage().getStorageID());  // Set for wire compatibility.
    repBuilder.setStorage(PBHelper.convert(storageBlock.getStorage()));
    for (ReceivedDeletedBlockInfo rdBlock : storageBlock.getBlocks()) {
      repBuilder.addBlocks(PBHelper.convert(rdBlock));
    }
    builder.addBlocks(repBuilder.build());
  }
  try {
    rpcProxy.blockReceivedAndDeleted(NULL_CONTROLLER, builder.build());
  } catch (ServiceException se) {
    throw ProtobufHelper.getRemoteException(se);
  }
}
AngelClient.java 文件源码 项目:angel 阅读 27 收藏 0 点赞 0 评论 0
protected void waitForAllPS(int psNumber) throws ServiceException, InterruptedException {
  boolean isAllPSReady = true;
  while(true) {
    GetAllPSLocationResponse response = master.getAllPSLocation(null, GetAllPSLocationRequest.newBuilder().build());
    List<PSLocationProto> psLocs = response.getPsLocationsList();
    int size = psLocs.size();
    if(size == psNumber) {
      isAllPSReady = true;
      for(int i = 0; i < size; i++) {
        if(psLocs.get(i).getPsStatus() == PSStatus.PS_NOTREADY) {
          isAllPSReady = false;
          break;
        }
      }

      if(isAllPSReady) {
        return;
      }
    }       
    Thread.sleep(100);
  }
}
TestMetaTableLocator.java 文件源码 项目:ditb 阅读 34 收藏 0 点赞 0 评论 0
/**
 * Test get of meta region fails properly if nothing to connect to.
 * @throws IOException
 * @throws InterruptedException
 * @throws KeeperException
 * @throws ServiceException
 */
@Test
public void testVerifyMetaRegionLocationFails()
throws IOException, InterruptedException, KeeperException, ServiceException {
  ClusterConnection connection = Mockito.mock(ClusterConnection.class);
  ServiceException connectException =
    new ServiceException(new ConnectException("Connection refused"));
  final AdminProtos.AdminService.BlockingInterface implementation =
    Mockito.mock(AdminProtos.AdminService.BlockingInterface.class);
  Mockito.when(implementation.getRegionInfo((RpcController)Mockito.any(),
    (GetRegionInfoRequest)Mockito.any())).thenThrow(connectException);
  Mockito.when(connection.getAdmin(Mockito.any(ServerName.class))).
    thenReturn(implementation);
      RpcControllerFactory controllerFactory = Mockito.mock(RpcControllerFactory.class);
      Mockito.when(controllerFactory.newController()).thenReturn(
        Mockito.mock(PayloadCarryingRpcController.class));
      Mockito.when(connection.getRpcControllerFactory()).thenReturn(controllerFactory);

  ServerName sn = ServerName.valueOf("example.com", 1234, System.currentTimeMillis());
  MetaTableLocator.setMetaLocation(this.watcher,
          sn,
          RegionState.State.OPENING);
  assertFalse(new MetaTableLocator().verifyMetaRegionLocation(connection, watcher, 100));
  MetaTableLocator.setMetaLocation(this.watcher, sn, RegionState.State.OPEN);
  assertFalse(new MetaTableLocator().verifyMetaRegionLocation(connection, watcher, 100));
}
HBaseAdmin.java 文件源码 项目:ditb 阅读 29 收藏 0 点赞 0 评论 0
/**
 * Enable the table but does not block and wait for it be completely enabled.
 * You can use Future.get(long, TimeUnit) to wait on the operation to complete.
 * It may throw ExecutionException if there was an error while executing the operation
 * or TimeoutException in case the wait timeout was not long enough to allow the
 * operation to complete.
 *
 * @param tableName name of table to delete
 * @throws IOException if a remote or network exception occurs
 * @return the result of the async enable. You can use Future.get(long, TimeUnit)
 *    to wait on the operation to complete.
 */
// TODO: This should be called Async but it will break binary compatibility
private Future<Void> enableTableAsyncV2(final TableName tableName) throws IOException {
  TableName.isLegalFullyQualifiedTableName(tableName.getName());
  EnableTableResponse response = executeCallable(
    new MasterCallable<EnableTableResponse>(getConnection()) {
      @Override
      public EnableTableResponse call(int callTimeout) throws ServiceException {
        PayloadCarryingRpcController controller = rpcControllerFactory.newController();
        controller.setCallTimeout(callTimeout);
        controller.setPriority(tableName);

        LOG.info("Started enable of " + tableName);
        EnableTableRequest req =
            RequestConverter.buildEnableTableRequest(tableName, ng.getNonceGroup(),ng.newNonce());
        return master.enableTable(controller,req);
      }
    });
  return new EnableTableFuture(this, tableName, response);
}
TestRPC.java 文件源码 项目:hadoop-oss 阅读 27 收藏 0 点赞 0 评论 0
@Test
public void testClientWithoutServer() throws Exception {
  TestRpcService proxy;

  short invalidPort = 20;
  InetSocketAddress invalidAddress = new InetSocketAddress(ADDRESS,
      invalidPort);
  long invalidClientVersion = 1L;
  try {
    proxy = RPC.getProxy(TestRpcService.class,
        invalidClientVersion, invalidAddress, conf);
    // Test echo method
    proxy.echo(null, newEchoRequest("hello"));
    fail("We should not have reached here");
  } catch (ServiceException ioe) {
    //this is what we expected
    if (!(ioe.getCause() instanceof ConnectException)) {
      fail("We should not have reached here");
    }
  }
}
TraceAdminProtocolServerSideTranslatorPB.java 文件源码 项目:hadoop-oss 阅读 22 收藏 0 点赞 0 评论 0
@Override
public ListSpanReceiversResponseProto listSpanReceivers(
    RpcController controller, ListSpanReceiversRequestProto req)
        throws ServiceException {
  try {
    SpanReceiverInfo[] descs = server.listSpanReceivers();
    ListSpanReceiversResponseProto.Builder bld =
        ListSpanReceiversResponseProto.newBuilder();
    for (int i = 0; i < descs.length; ++i) {
      bld.addDescriptions(TraceAdminPB.SpanReceiverListInfo.newBuilder().
            setId(descs[i].getId()).
            setClassName(descs[i].getClassName()).build());
    }
    return bld.build();
  } catch (IOException e) {
    throw new ServiceException(e);
  }
}
ServerManager.java 文件源码 项目:ditb 阅读 26 收藏 0 点赞 0 评论 0
/**
 * Sends an OPEN RPC to the specified server to open the specified region.
 * <p>
 * Open should not fail but can if server just crashed.
 * <p>
 * @param server server to open a region
 * @param regionOpenInfos info of a list of regions to open
 * @return a list of region opening states
 */
public List<RegionOpeningState> sendRegionOpen(ServerName server,
    List<Triple<HRegionInfo, Integer, List<ServerName>>> regionOpenInfos)
throws IOException {
  AdminService.BlockingInterface admin = getRsAdmin(server);
  if (admin == null) {
    LOG.warn("Attempting to send OPEN RPC to server " + server.toString() +
      " failed because no RPC connection found to this server");
    return null;
  }

  OpenRegionRequest request = RequestConverter.buildOpenRegionRequest(server, regionOpenInfos,
    (RecoveryMode.LOG_REPLAY == this.services.getMasterFileSystem().getLogRecoveryMode()));
  try {
    OpenRegionResponse response = admin.openRegion(null, request);
    return ResponseConverter.getRegionOpeningStateList(response);
  } catch (ServiceException se) {
    throw ProtobufUtil.getRemoteException(se);
  }
}
ClientNamenodeProtocolServerSideTranslatorPB.java 文件源码 项目:hadoop 阅读 25 收藏 0 点赞 0 评论 0
@Override
public GetListingResponseProto getListing(RpcController controller,
    GetListingRequestProto req) throws ServiceException {
  try {
    DirectoryListing result = server.getListing(
        req.getSrc(), req.getStartAfter().toByteArray(),
        req.getNeedLocation());
    if (result !=null) {
      return GetListingResponseProto.newBuilder().setDirList(
        PBHelper.convert(result)).build();
    } else {
      return VOID_GETLISTING_RESPONSE;
    }
  } catch (IOException e) {
    throw new ServiceException(e);
  }
}
QJournalProtocolTranslatorPB.java 文件源码 项目:hadoop 阅读 34 收藏 0 点赞 0 评论 0
@Override
public Boolean canRollBack(String journalId, StorageInfo storage,
    StorageInfo prevStorage, int targetLayoutVersion) throws IOException {
  try {
    CanRollBackResponseProto response = rpcProxy.canRollBack(
        NULL_CONTROLLER,
        CanRollBackRequestProto.newBuilder()
          .setJid(convertJournalId(journalId))
          .setStorage(PBHelper.convert(storage))
          .setPrevStorage(PBHelper.convert(prevStorage))
          .setTargetLayoutVersion(targetLayoutVersion)
          .build());
    return response.getCanRollBack();
  } catch (ServiceException e) {
    throw ProtobufHelper.getRemoteException(e);
  }
}
HTable.java 文件源码 项目:ditb 阅读 31 收藏 0 点赞 0 评论 0
/**
 * {@inheritDoc}
 */
@Override
public boolean checkAndDelete(final byte [] row,
    final byte [] family, final byte [] qualifier, final byte [] value,
    final Delete delete)
throws IOException {
  RegionServerCallable<Boolean> callable =
    new RegionServerCallable<Boolean>(connection, getName(), row) {
      @Override
      public Boolean call(int callTimeout) throws IOException {
        PayloadCarryingRpcController controller = rpcControllerFactory.newController();
        controller.setPriority(tableName);
        controller.setCallTimeout(callTimeout);
        try {
          MutateRequest request = RequestConverter.buildMutateRequest(
            getLocation().getRegionInfo().getRegionName(), row, family, qualifier,
              new BinaryComparator(value), CompareType.EQUAL, delete);
          MutateResponse response = getStub().mutate(controller, request);
          return Boolean.valueOf(response.getProcessed());
        } catch (ServiceException se) {
          throw ProtobufUtil.getRemoteException(se);
        }
      }
    };
  return rpcCallerFactory.<Boolean> newCaller().callWithRetries(callable, this.operationTimeout);
}
ClientNamenodeProtocolTranslatorPB.java 文件源码 项目:hadoop 阅读 27 收藏 0 点赞 0 评论 0
@Override
public void updatePipeline(String clientName, ExtendedBlock oldBlock,
    ExtendedBlock newBlock, DatanodeID[] newNodes, String[] storageIDs) throws IOException {
  UpdatePipelineRequestProto req = UpdatePipelineRequestProto.newBuilder()
      .setClientName(clientName)
      .setOldBlock(PBHelper.convert(oldBlock))
      .setNewBlock(PBHelper.convert(newBlock))
      .addAllNewNodes(Arrays.asList(PBHelper.convert(newNodes)))
      .addAllStorageIDs(storageIDs == null ? null : Arrays.asList(storageIDs))
      .build();
  try {
    rpcProxy.updatePipeline(null, req);
  } catch (ServiceException e) {
    throw ProtobufHelper.getRemoteException(e);
  }
}
RpcRetryingCallerWithReadReplicas.java 文件源码 项目:ditb 阅读 25 收藏 0 点赞 0 评论 0
@Override
public Result call(int callTimeout) throws Exception {
  if (controller.isCanceled()) return null;

  if (Thread.interrupted()) {
    throw new InterruptedIOException();
  }

  byte[] reg = location.getRegionInfo().getRegionName();

  ClientProtos.GetRequest request =
      RequestConverter.buildGetRequest(reg, get);
  controller.setCallTimeout(callTimeout);

  try {
    ClientProtos.GetResponse response = getStub().get(controller, request);
    if (response == null) {
      return null;
    }
    return ProtobufUtil.toResult(response.getResult());
  } catch (ServiceException se) {
    throw ProtobufUtil.getRemoteException(se);
  }
}
MasterService.java 文件源码 项目:angel 阅读 25 收藏 0 点赞 0 评论 0
/**
 * worker run over successfully
 *
 * @param controller rpc controller of protobuf
 * @param request contains worker attempt id
 * @throws ServiceException
 */
@SuppressWarnings("unchecked")
@Override
public WorkerDoneResponse workerDone(RpcController controller, WorkerDoneRequest request)
    throws ServiceException {
  WorkerAttemptId workerAttemptId = ProtobufUtil.convertToId(request.getWorkerAttemptId());
  LOG.info("worker attempt " + workerAttemptId + " is done");
  WorkerDoneResponse.Builder resBuilder = WorkerDoneResponse.newBuilder();

  //if worker attempt id is not in monitor set, we should shutdown it
  if (!workerLastHeartbeatTS.containsKey(workerAttemptId)) {
    resBuilder.setCommand(WorkerCommandProto.W_SHUTDOWN);
  } else {
    workerLastHeartbeatTS.remove(workerAttemptId);
    resBuilder.setCommand(WorkerCommandProto.W_SUCCESS);
    context.getEventHandler().handle(new WorkerAttemptEvent(WorkerAttemptEventType.DONE, workerAttemptId));
  }

  return resBuilder.build();
}
MasterService.java 文件源码 项目:angel 阅读 31 收藏 0 点赞 0 评论 0
/**
 * worker run failed
 *
 * @param controller rpc controller of protobuf
 * @param request contains worker attempt id, error message
 * @throws ServiceException
 */
@SuppressWarnings("unchecked")
@Override
public WorkerErrorResponse workerError(RpcController controller, WorkerErrorRequest request)
    throws ServiceException {
  WorkerAttemptId workerAttemptId = ProtobufUtil.convertToId(request.getWorkerAttemptId());
  LOG.info("worker attempt " + workerAttemptId + " failed, details=" + request.getMsg());

  WorkerErrorResponse.Builder resBuilder = WorkerErrorResponse.newBuilder();

  //if worker attempt id is not in monitor set, we should shutdown it
  if (!workerLastHeartbeatTS.containsKey(workerAttemptId)) {
    resBuilder.setCommand(WorkerCommandProto.W_SHUTDOWN);
  } else {
    workerLastHeartbeatTS.remove(workerAttemptId);
    context.getEventHandler()
        .handle(new WorkerAttemptDiagnosticsUpdateEvent(workerAttemptId, request.getMsg()));
    context.getEventHandler().handle(new WorkerAttemptEvent(WorkerAttemptEventType.ERROR, workerAttemptId));
    resBuilder.setCommand(WorkerCommandProto.W_SUCCESS);
  }

  return resBuilder.build();
}
RSRpcServices.java 文件源码 项目:ditb 阅读 28 收藏 0 点赞 0 评论 0
@Override
@QosPriority(priority=HConstants.ADMIN_QOS)
public GetRegionInfoResponse getRegionInfo(final RpcController controller,
    final GetRegionInfoRequest request) throws ServiceException {
  try {
    checkOpen();
    requestCount.increment();
    Region region = getRegion(request.getRegion());
    HRegionInfo info = region.getRegionInfo();
    GetRegionInfoResponse.Builder builder = GetRegionInfoResponse.newBuilder();
    builder.setRegionInfo(HRegionInfo.convert(info));
    if (request.hasCompactionState() && request.getCompactionState()) {
      builder.setCompactionState(region.getCompactionState());
    }
    builder.setIsRecovering(region.isRecovering());
    return builder.build();
  } catch (IOException ie) {
    throw new ServiceException(ie);
  }
}
IndexGetFuncTest.java 文件源码 项目:angel 阅读 21 收藏 0 点赞 0 评论 0
public void testDenseDoubleUDF() throws ServiceException, IOException, InvalidParameterException,
    AngelException, InterruptedException, ExecutionException {
  Worker worker = LocalClusterContext.get().getWorker(workerAttempt0Id).getWorker();
  MatrixClient client1 = worker.getPSAgent().getMatrixClient(DENSE_DOUBLE_MAT, 0);
  int matrixW1Id = client1.getMatrixId();

  int[] index = genIndexs(feaNum, nnz);

  DenseDoubleVector deltaVec = new DenseDoubleVector(feaNum);
  for (int i = 0; i < feaNum; i++)
    deltaVec.set(i, i);
  deltaVec.setRowId(0);

  client1.increment(deltaVec);
  client1.clock().get();

  IndexGetFunc func = new IndexGetFunc(new IndexGetParam(matrixW1Id, 0, index));
  SparseDoubleVector row = (SparseDoubleVector) ((GetRowResult) client1.get(func)).getRow();
  for (int id: index) {
    Assert.assertTrue(row.get(id) == deltaVec.get(id));
  }
  Assert.assertTrue(index.length == row.size());

}
TestProtoBufRpc.java 文件源码 项目:hadoop-oss 阅读 30 收藏 0 点赞 0 评论 0
@Test(timeout = 12000)
public void testEnsureNoLogIfDisabled() throws IOException, ServiceException {
  // disable slow RPC  logging
  server.setLogSlowRPC(false);
  TestRpcService2 client = getClient2();

  // make 10 K fast calls
  for (int x = 0; x < 10000; x++) {
    client.ping2(null, newEmptyRequest());
  }

  // Ensure RPC metrics are updated
  RpcMetrics rpcMetrics = server.getRpcMetrics();
  assertTrue(rpcMetrics.getProcessingSampleCount() > 999L);
  long before = rpcMetrics.getRpcSlowCalls();

  // make a really slow call. Sleep sleeps for 1000ms
  client.sleep(null, newSleepRequest(SLEEP_DURATION));

  long after = rpcMetrics.getRpcSlowCalls();

  // make sure we never called into Log slow RPC routine.
  assertEquals(before, after);
}
TestSnapshotFromMaster.java 文件源码 项目:ditb 阅读 25 收藏 0 点赞 0 评论 0
@Test(timeout = 300000)
public void testDeleteSnapshot() throws Exception {

  String snapshotName = "completed";
  SnapshotDescription snapshot = SnapshotDescription.newBuilder().setName(snapshotName).build();

  DeleteSnapshotRequest request = DeleteSnapshotRequest.newBuilder().setSnapshot(snapshot)
      .build();
  try {
    master.getMasterRpcServices().deleteSnapshot(null, request);
    fail("Master didn't throw exception when attempting to delete snapshot that doesn't exist");
  } catch (ServiceException e) {
    LOG.debug("Correctly failed delete of non-existant snapshot:" + e.getMessage());
  }

  // write one snapshot to the fs
  Path snapshotDir = SnapshotDescriptionUtils.getCompletedSnapshotDir(snapshotName, rootDir);
  SnapshotDescriptionUtils.writeSnapshotInfo(snapshot, snapshotDir, fs);

  // then delete the existing snapshot,which shouldn't cause an exception to be thrown
  master.getMasterRpcServices().deleteSnapshot(null, request);
}
QJournalProtocolServerSideTranslatorPB.java 文件源码 项目:hadoop 阅读 28 收藏 0 点赞 0 评论 0
@Override
public DoFinalizeResponseProto doFinalize(RpcController controller,
    DoFinalizeRequestProto request) throws ServiceException {
  try {
    impl.doFinalize(convert(request.getJid()));
    return DoFinalizeResponseProto.getDefaultInstance();
  } catch (IOException e) {
    throw new ServiceException(e);
  }
}
ApplicationMasterProtocolPBClientImpl.java 文件源码 项目:hadoop 阅读 34 收藏 0 点赞 0 评论 0
@Override
public AllocateResponse allocate(AllocateRequest request)
    throws YarnException, IOException {
  AllocateRequestProto requestProto =
      ((AllocateRequestPBImpl) request).getProto();
  try {
    return new AllocateResponsePBImpl(proxy.allocate(null, requestProto));
  } catch (ServiceException e) {
    RPCUtil.unwrapAndThrowException(e);
    return null;
  }
}
ClientNamenodeProtocolTranslatorPB.java 文件源码 项目:hadoop 阅读 27 收藏 0 点赞 0 评论 0
@Override
public void setStoragePolicy(String src, String policyName)
    throws IOException {
  SetStoragePolicyRequestProto req = SetStoragePolicyRequestProto
      .newBuilder().setSrc(src).setPolicyName(policyName).build();
  try {
    rpcProxy.setStoragePolicy(null, req);
  } catch (ServiceException e) {
    throw ProtobufHelper.getRemoteException(e);
  }
}
TestClientNoCluster.java 文件源码 项目:ditb 阅读 29 收藏 0 点赞 0 评论 0
@Override
public MultiResponse multi(RpcController controller, MultiRequest request)
throws ServiceException {
  int concurrentInvocations = this.multiInvocationsCount.incrementAndGet();
  try {
    if (concurrentInvocations >= tooManyMultiRequests) {
      throw new ServiceException(new RegionTooBusyException("concurrentInvocations=" +
       concurrentInvocations));
    }
    Threads.sleep(multiPause);
    return doMultiResponse(meta, sequenceids, request);
  } finally {
    this.multiInvocationsCount.decrementAndGet();
  }
}
MasterRpcServices.java 文件源码 项目:ditb 阅读 25 收藏 0 点赞 0 评论 0
@Override
public ShutdownResponse shutdown(RpcController controller,
    ShutdownRequest request) throws ServiceException {
  LOG.info(master.getClientIdAuditPrefix() + " shutdown");
  master.shutdown();
  return ShutdownResponse.newBuilder().build();
}
MasterRpcServices.java 文件源码 项目:ditb 阅读 22 收藏 0 点赞 0 评论 0
@Override
public ReportRegionStateTransitionResponse reportRegionStateTransition(RpcController c,
    ReportRegionStateTransitionRequest req) throws ServiceException {
  try {
    master.checkServiceStarted();
    RegionStateTransition rt = req.getTransition(0);
    TableName tableName = ProtobufUtil.toTableName(
      rt.getRegionInfo(0).getTableName());
    RegionStates regionStates = master.assignmentManager.getRegionStates();
    if (!(TableName.META_TABLE_NAME.equals(tableName)
        && regionStates.getRegionState(HRegionInfo.FIRST_META_REGIONINFO) != null)
          && !master.assignmentManager.isFailoverCleanupDone()) {
      // Meta region is assigned before master finishes the
      // failover cleanup. So no need this check for it
      throw new PleaseHoldException("Master is rebuilding user regions");
    }
    ServerName sn = ProtobufUtil.toServerName(req.getServer());
    String error = master.assignmentManager.onRegionTransition(sn, rt);
    ReportRegionStateTransitionResponse.Builder rrtr =
      ReportRegionStateTransitionResponse.newBuilder();
    if (error != null) {
      rrtr.setErrorMessage(error);
    }
    return rrtr.build();
  } catch (IOException ioe) {
    throw new ServiceException(ioe);
  }
}
ClientNamenodeProtocolServerSideTranslatorPB.java 文件源码 项目:hadoop 阅读 30 收藏 0 点赞 0 评论 0
@Override
public GetFsStatsResponseProto getFsStats(RpcController controller,
    GetFsStatusRequestProto req) throws ServiceException {
  try {
    return PBHelper.convert(server.getStats());
  } catch (IOException e) {
    throw new ServiceException(e);
  }
}
NamenodeProtocolTranslatorPB.java 文件源码 项目:hadoop 阅读 35 收藏 0 点赞 0 评论 0
@Override
public NamenodeRegistration registerSubordinateNamenode(
    NamenodeRegistration registration) throws IOException {
  RegisterRequestProto req = RegisterRequestProto.newBuilder()
      .setRegistration(PBHelper.convert(registration)).build();
  try {
    return PBHelper.convert(
        rpcProxy.registerSubordinateNamenode(NULL_CONTROLLER, req)
        .getRegistration());
  } catch (ServiceException e) {
    throw ProtobufHelper.getRemoteException(e);
  }
}
ProtobufUtil.java 文件源码 项目:ditb 阅读 24 收藏 0 点赞 0 评论 0
/**
 * A helper to retrieve region info given a region name
 * using admin protocol.
 *
 * @param admin
 * @param regionName
 * @return the retrieved region info
 * @throws IOException
 */
public static HRegionInfo getRegionInfo(final RpcController controller,
    final AdminService.BlockingInterface admin, final byte[] regionName) throws IOException {
  try {
    GetRegionInfoRequest request =
      RequestConverter.buildGetRegionInfoRequest(regionName);
    GetRegionInfoResponse response =
      admin.getRegionInfo(controller, request);
    return HRegionInfo.convert(response.getRegionInfo());
  } catch (ServiceException se) {
    throw getRemoteException(se);
  }
}


问题


面经


文章

微信
公众号

扫码关注公众号