Java 类com.google.protobuf.ServiceException 实例源码

项目:angel    文件:MasterClient.java   
/**
 * 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;
}
项目:hadoop    文件:ClientNamenodeProtocolTranslatorPB.java   
@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);
  }
}
项目:hadoop    文件:TraceAdminProtocolTranslatorPB.java   
@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()]);
}
项目:hadoop    文件:DatanodeProtocolClientSideTranslatorPB.java   
@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);
  }
}
项目:angel    文件:AngelClient.java   
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);
  }
}
项目:ditb    文件:TestMetaTableLocator.java   
/**
 * 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));
}
项目:ditb    文件:HBaseAdmin.java   
/**
 * 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);
}
项目:hadoop-oss    文件:TestRPC.java   
@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");
    }
  }
}
项目:hadoop-oss    文件:TraceAdminProtocolServerSideTranslatorPB.java   
@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);
  }
}
项目:ditb    文件:ServerManager.java   
/**
 * 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);
  }
}
项目:hadoop    文件:ClientNamenodeProtocolServerSideTranslatorPB.java   
@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);
  }
}
项目:hadoop    文件:QJournalProtocolTranslatorPB.java   
@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);
  }
}
项目:ditb    文件:HTable.java   
/**
 * {@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);
}
项目:hadoop    文件:ClientNamenodeProtocolTranslatorPB.java   
@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);
  }
}
项目:ditb    文件:RpcRetryingCallerWithReadReplicas.java   
@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);
  }
}
项目:angel    文件:MasterService.java   
/**
 * 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();
}
项目:angel    文件:MasterService.java   
/**
 * 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();
}
项目:ditb    文件:RSRpcServices.java   
@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);
  }
}
项目:angel    文件:IndexGetFuncTest.java   
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());

}
项目:hadoop-oss    文件:TestProtoBufRpc.java   
@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);
}
项目:ditb    文件:TestSnapshotFromMaster.java   
@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);
}
项目:hadoop    文件:QJournalProtocolServerSideTranslatorPB.java   
@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);
  }
}
项目:hadoop    文件:ApplicationMasterProtocolPBClientImpl.java   
@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;
  }
}
项目:hadoop    文件:ClientNamenodeProtocolTranslatorPB.java   
@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);
  }
}
项目:ditb    文件:TestClientNoCluster.java   
@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();
  }
}
项目:ditb    文件:MasterRpcServices.java   
@Override
public ShutdownResponse shutdown(RpcController controller,
    ShutdownRequest request) throws ServiceException {
  LOG.info(master.getClientIdAuditPrefix() + " shutdown");
  master.shutdown();
  return ShutdownResponse.newBuilder().build();
}
项目:ditb    文件:MasterRpcServices.java   
@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);
  }
}
项目:hadoop    文件:ClientNamenodeProtocolServerSideTranslatorPB.java   
@Override
public GetFsStatsResponseProto getFsStats(RpcController controller,
    GetFsStatusRequestProto req) throws ServiceException {
  try {
    return PBHelper.convert(server.getStats());
  } catch (IOException e) {
    throw new ServiceException(e);
  }
}
项目:hadoop    文件:NamenodeProtocolTranslatorPB.java   
@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);
  }
}
项目:ditb    文件:ProtobufUtil.java   
/**
 * 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);
  }
}
项目:ditb    文件:ProtobufUtil.java   
/**
 * A helper to split a region using admin protocol.
 *
 * @param admin
 * @param hri
 * @param splitPoint
 * @throws IOException
 */
public static void split(final RpcController controller,
    final AdminService.BlockingInterface admin, final HRegionInfo hri, byte[] splitPoint)
        throws IOException {
  SplitRegionRequest request =
    RequestConverter.buildSplitRegionRequest(hri.getRegionName(), splitPoint);
  try {
    admin.splitRegion(controller, request);
  } catch (ServiceException se) {
    throw ProtobufUtil.getRemoteException(se);
  }
}
项目:ditb    文件:RSRpcServices.java   
@Override
@QosPriority(priority=HConstants.ADMIN_QOS)
public GetStoreFileResponse getStoreFile(final RpcController controller,
    final GetStoreFileRequest request) throws ServiceException {
  try {
    checkOpen();
    Region region = getRegion(request.getRegion());
    requestCount.increment();
    Set<byte[]> columnFamilies;
    if (request.getFamilyCount() == 0) {
      columnFamilies = region.getTableDesc().getFamiliesKeys();
    } else {
      columnFamilies = new TreeSet<byte[]>(Bytes.BYTES_RAWCOMPARATOR);
      for (ByteString cf: request.getFamilyList()) {
        columnFamilies.add(cf.toByteArray());
      }
    }
    int nCF = columnFamilies.size();
    List<String>  fileList = region.getStoreFileList(
      columnFamilies.toArray(new byte[nCF][]));
    GetStoreFileResponse.Builder builder = GetStoreFileResponse.newBuilder();
    builder.addAllStoreFile(fileList);
    return builder.build();
  } catch (IOException ie) {
    throw new ServiceException(ie);
  }
}
项目:hadoop    文件:ClientNamenodeProtocolServerSideTranslatorPB.java   
@Override
public RenewDelegationTokenResponseProto renewDelegationToken(
    RpcController controller, RenewDelegationTokenRequestProto req)
    throws ServiceException {
  try {
    long result = server.renewDelegationToken(PBHelper
        .convertDelegationToken(req.getToken()));
    return RenewDelegationTokenResponseProto.newBuilder()
        .setNewExpiryTime(result).build();
  } catch (IOException e) {
    throw new ServiceException(e);
  }
}
项目:hadoop-oss    文件:ZKFCProtocolClientSideTranslatorPB.java   
@Override
public void gracefulFailover() throws IOException, AccessControlException {
  try {
    rpcProxy.gracefulFailover(NULL_CONTROLLER,
        GracefulFailoverRequestProto.getDefaultInstance());
  } catch (ServiceException e) {
    throw ProtobufHelper.getRemoteException(e);
  }
}
项目:ditb    文件:MasterRpcServices.java   
@Override
public BalanceResponse balance(RpcController controller,
    BalanceRequest request) throws ServiceException {
  try {
    return BalanceResponse.newBuilder().setBalancerRan(master.balance()).build();
  } catch (IOException ex) {
    throw new ServiceException(ex);
  }
}
项目:hadoop    文件:ClientNamenodeProtocolServerSideTranslatorPB.java   
@Override
public GetDatanodeReportResponseProto getDatanodeReport(
    RpcController controller, GetDatanodeReportRequestProto req)
    throws ServiceException {
  try {
    List<? extends DatanodeInfoProto> result = PBHelper.convert(server
        .getDatanodeReport(PBHelper.convert(req.getType())));
    return GetDatanodeReportResponseProto.newBuilder()
        .addAllDi(result).build();
  } catch (IOException e) {
    throw new ServiceException(e);
  }
}
项目:ditb    文件:HBaseAdmin.java   
private void flush(final ServerName sn, final HRegionInfo hri)
throws IOException {
  PayloadCarryingRpcController controller = rpcControllerFactory.newController();
  AdminService.BlockingInterface admin = this.connection.getAdmin(sn);
  FlushRegionRequest request =
    RequestConverter.buildFlushRegionRequest(hri.getRegionName());
  try {
    admin.flushRegion(controller, request);
  } catch (ServiceException se) {
    throw ProtobufUtil.getRemoteException(se);
  }
}
项目:hadoop    文件:ClientNamenodeProtocolTranslatorPB.java   
@Override
public void removeAcl(String src) throws IOException {
  RemoveAclRequestProto req = RemoveAclRequestProto.newBuilder()
      .setSrc(src).build();
  try {
    rpcProxy.removeAcl(null, req);
  } catch (ServiceException e) {
    throw ProtobufHelper.getRemoteException(e);
  }
}
项目:ditb    文件:TestWALFiltering.java   
private void flushAllRegions(int rsId)
throws ServiceException, IOException {
  HRegionServer hrs = getRegionServer(rsId);
  for (byte[] regionName : getRegionsByServer(rsId)) {
    FlushRegionRequest request =
      RequestConverter.buildFlushRegionRequest(regionName);
    hrs.getRSRpcServices().flushRegion(null, request);
  }
}
项目:hadoop-oss    文件:TestRPC.java   
@Override
public void run() {
  Integer[] indata = new Integer[datasize];
  Arrays.fill(indata, 123);
  TestProtos.ExchangeRequestProto exchangeRequest =
      TestProtos.ExchangeRequestProto.newBuilder().addAllValues(
          Arrays.asList(indata)).build();
  Integer[] outdata = null;
  TestProtos.ExchangeResponseProto exchangeResponse;

  TestProtos.AddRequestProto addRequest =
      TestProtos.AddRequestProto.newBuilder().setParam1(1)
          .setParam2(2).build();
  TestProtos.AddResponseProto addResponse;

  int val = 0;
  try {
    exchangeResponse = proxy.exchange(null, exchangeRequest);
    outdata = new Integer[exchangeResponse.getValuesCount()];
    outdata = exchangeResponse.getValuesList().toArray(outdata);
    addResponse = proxy.add(null, addRequest);
    val = addResponse.getResult();
  } catch (ServiceException e) {
    assertTrue("Exception from RPC exchange() "  + e, false);
  }
  assertEquals(indata.length, outdata.length);
  assertEquals(3, val);
  for (int i = 0; i < outdata.length; i++) {
    assertEquals(outdata[i].intValue(), i);
  }
}