当前位置: 首页>>代码示例>>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;未经允许,请勿转载。