當前位置: 首頁>>代碼示例>>Java>>正文


Java ServiceException類代碼示例

本文整理匯總了Java中com.google.protobuf.ServiceException的典型用法代碼示例。如果您正苦於以下問題:Java ServiceException類的具體用法?Java ServiceException怎麽用?Java ServiceException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ServiceException類屬於com.google.protobuf包,在下文中一共展示了ServiceException類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getTaskMatrixClocks

import com.google.protobuf.ServiceException; //導入依賴的package包/類
/**
 * 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;
}
 
開發者ID:Tencent,項目名稱:angel,代碼行數:26,代碼來源:MasterClient.java

示例2: getStoreFile

import com.google.protobuf.ServiceException; //導入依賴的package包/類
@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);
  }
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:28,代碼來源:RSRpcServices.java

示例3: getAdditionalDatanode

import com.google.protobuf.ServiceException; //導入依賴的package包/類
@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);
  }
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:26,代碼來源:ClientNamenodeProtocolTranslatorPB.java

示例4: listSpanReceivers

import com.google.protobuf.ServiceException; //導入依賴的package包/類
@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()]);
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:17,代碼來源:TraceAdminProtocolTranslatorPB.java

示例5: blockReceivedAndDeleted

import com.google.protobuf.ServiceException; //導入依賴的package包/類
@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);
  }
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:25,代碼來源:DatanodeProtocolClientSideTranslatorPB.java

示例6: waitForAllPS

import com.google.protobuf.ServiceException; //導入依賴的package包/類
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);
  }
}
 
開發者ID:Tencent,項目名稱:angel,代碼行數:23,代碼來源:AngelClient.java

示例7: scan

import com.google.protobuf.ServiceException; //導入依賴的package包/類
@Override
public ScanResponse scan(final RpcController controller, final ScanRequest request)
    throws ServiceException {
  if (request.hasScannerId()) {
    ScanResponse scanResponse = super.scan(controller, request);
    if (this.tableScannerId == request.getScannerId() && 
        (sleepAlways || (!slept && seqNoToSleepOn == request.getNextCallSeq()))) {
      try {
        LOG.info("SLEEPING " + (rpcTimeout + 500));
        Thread.sleep(rpcTimeout + 500);
      } catch (InterruptedException e) {
      }
      slept = true;
      tryNumber++;
      if (tryNumber > 2 * CLIENT_RETRIES_NUMBER) {
        sleepAlways = false;
      }
    }
    return scanResponse;
  } else {
    ScanResponse scanRes = super.scan(controller, request);
    String regionName = Bytes.toString(request.getRegion().getValue().toByteArray());
    if (!regionName.contains(TableName.META_TABLE_NAME.getNameAsString())) {
      tableScannerId = scanRes.getScannerId();
    }
    return scanRes;
  }
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:29,代碼來源:TestClientScannerRPCTimeout.java

示例8: testVerifyMetaRegionLocationFails

import com.google.protobuf.ServiceException; //導入依賴的package包/類
/**
 * 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));
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:33,代碼來源:TestMetaTableLocator.java

示例9: enableTableAsyncV2

import com.google.protobuf.ServiceException; //導入依賴的package包/類
/**
 * 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);
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:32,代碼來源:HBaseAdmin.java

示例10: testClientWithoutServer

import com.google.protobuf.ServiceException; //導入依賴的package包/類
@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");
    }
  }
}
 
開發者ID:nucypher,項目名稱:hadoop-oss,代碼行數:22,代碼來源:TestRPC.java

示例11: listSpanReceivers

import com.google.protobuf.ServiceException; //導入依賴的package包/類
@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);
  }
}
 
開發者ID:nucypher,項目名稱:hadoop-oss,代碼行數:19,代碼來源:TraceAdminProtocolServerSideTranslatorPB.java

示例12: sendRegionOpen

import com.google.protobuf.ServiceException; //導入依賴的package包/類
/**
 * 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);
  }
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:29,代碼來源:ServerManager.java

示例13: getListing

import com.google.protobuf.ServiceException; //導入依賴的package包/類
@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);
  }
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:18,代碼來源:ClientNamenodeProtocolServerSideTranslatorPB.java

示例14: canRollBack

import com.google.protobuf.ServiceException; //導入依賴的package包/類
@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);
  }
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:18,代碼來源:QJournalProtocolTranslatorPB.java

示例15: checkAndDelete

import com.google.protobuf.ServiceException; //導入依賴的package包/類
/**
 * {@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);
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:29,代碼來源:HTable.java


注:本文中的com.google.protobuf.ServiceException類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。