当前位置: 首页>>代码示例>>Java>>正文


Java Table.coprocessorService方法代码示例

本文整理汇总了Java中org.apache.hadoop.hbase.client.Table.coprocessorService方法的典型用法代码示例。如果您正苦于以下问题:Java Table.coprocessorService方法的具体用法?Java Table.coprocessorService怎么用?Java Table.coprocessorService使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.hadoop.hbase.client.Table的用法示例。


在下文中一共展示了Table.coprocessorService方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: sum

import org.apache.hadoop.hbase.client.Table; //导入方法依赖的package包/类
private static Map<byte [], Long> sum(final Table table, final byte [] family,
  final byte [] qualifier, final byte [] start, final byte [] end)
    throws ServiceException, Throwable {
return table.coprocessorService(ColumnAggregationProtos.ColumnAggregationService.class,
    start, end,
  new Batch.Call<ColumnAggregationProtos.ColumnAggregationService, Long>() {
    @Override
    public Long call(ColumnAggregationProtos.ColumnAggregationService instance)
    throws IOException {
      BlockingRpcCallback<ColumnAggregationProtos.SumResponse> rpcCallback =
          new BlockingRpcCallback<ColumnAggregationProtos.SumResponse>();
      ColumnAggregationProtos.SumRequest.Builder builder =
        ColumnAggregationProtos.SumRequest.newBuilder();
      builder.setFamily(ByteStringer.wrap(family));
      if (qualifier != null && qualifier.length > 0) {
        builder.setQualifier(ByteStringer.wrap(qualifier));
      }
      instance.sum(null, builder.build(), rpcCallback);
      return rpcCallback.get().getSum();
    }
  });
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:23,代码来源:TestCoprocessorTableEndpoint.java

示例2: sum

import org.apache.hadoop.hbase.client.Table; //导入方法依赖的package包/类
private Map<byte [], Long> sum(final Table table, final byte [] family,
    final byte [] qualifier, final byte [] start, final byte [] end)
throws ServiceException, Throwable {
  return table.coprocessorService(ColumnAggregationProtos.ColumnAggregationService.class,
      start, end,
    new Batch.Call<ColumnAggregationProtos.ColumnAggregationService, Long>() {
      @Override
      public Long call(ColumnAggregationProtos.ColumnAggregationService instance)
      throws IOException {
        BlockingRpcCallback<ColumnAggregationProtos.SumResponse> rpcCallback =
            new BlockingRpcCallback<ColumnAggregationProtos.SumResponse>();
        ColumnAggregationProtos.SumRequest.Builder builder =
          ColumnAggregationProtos.SumRequest.newBuilder();
        builder.setFamily(ByteStringer.wrap(family));
        if (qualifier != null && qualifier.length > 0) {
          builder.setQualifier(ByteStringer.wrap(qualifier));
        }
        instance.sum(null, builder.build(), rpcCallback);
        return rpcCallback.get().getSum();
      }
    });
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:23,代码来源:TestCoprocessorEndpoint.java

示例3: hello

import org.apache.hadoop.hbase.client.Table; //导入方法依赖的package包/类
private Map<byte [], String> hello(final Table table, final String send, final byte [] start,
    final byte [] end)
throws ServiceException, Throwable {
  return table.coprocessorService(PingProtos.PingService.class,
      start, end,
      new Batch.Call<PingProtos.PingService, String>() {
        @Override
        public String call(PingProtos.PingService instance) throws IOException {
          BlockingRpcCallback<PingProtos.HelloResponse> rpcCallback =
            new BlockingRpcCallback<PingProtos.HelloResponse>();
          PingProtos.HelloRequest.Builder builder = PingProtos.HelloRequest.newBuilder();
          if (send != null) builder.setName(send);
          instance.hello(null, builder.build(), rpcCallback);
          PingProtos.HelloResponse r = rpcCallback.get();
          return r != null && r.hasResponse()? r.getResponse(): null;
        }
      });
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:19,代码来源:TestServerCustomProtocol.java

示例4: compoundOfHelloAndPing

import org.apache.hadoop.hbase.client.Table; //导入方法依赖的package包/类
private Map<byte [], String> compoundOfHelloAndPing(final Table table, final byte [] start,
    final byte [] end)
throws ServiceException, Throwable {
  return table.coprocessorService(PingProtos.PingService.class,
      start, end,
      new Batch.Call<PingProtos.PingService, String>() {
        @Override
        public String call(PingProtos.PingService instance) throws IOException {
          BlockingRpcCallback<PingProtos.HelloResponse> rpcCallback =
            new BlockingRpcCallback<PingProtos.HelloResponse>();
          PingProtos.HelloRequest.Builder builder = PingProtos.HelloRequest.newBuilder();
          // Call ping on same instance.  Use result calling hello on same instance.
          builder.setName(doPing(instance));
          instance.hello(null, builder.build(), rpcCallback);
          PingProtos.HelloResponse r = rpcCallback.get();
          return r != null && r.hasResponse()? r.getResponse(): null;
        }
      });
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:20,代码来源:TestServerCustomProtocol.java

示例5: noop

import org.apache.hadoop.hbase.client.Table; //导入方法依赖的package包/类
private Map<byte [], String> noop(final Table table, final byte [] start,
    final byte [] end)
throws ServiceException, Throwable {
  return table.coprocessorService(PingProtos.PingService.class, start, end,
      new Batch.Call<PingProtos.PingService, String>() {
        @Override
        public String call(PingProtos.PingService instance) throws IOException {
          BlockingRpcCallback<PingProtos.NoopResponse> rpcCallback =
            new BlockingRpcCallback<PingProtos.NoopResponse>();
          PingProtos.NoopRequest.Builder builder = PingProtos.NoopRequest.newBuilder();
          instance.noop(null, builder.build(), rpcCallback);
          rpcCallback.get();
          // Looks like null is expected when void.  That is what the test below is looking for
          return null;
        }
      });
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:18,代码来源:TestServerCustomProtocol.java

示例6: obtainToken

import org.apache.hadoop.hbase.client.Table; //导入方法依赖的package包/类
/**
 * Obtain and return an authentication token for the current user.
 * @param conn The HBase cluster connection
 * @return the authentication token instance
 */
public static Token<AuthenticationTokenIdentifier> obtainToken(
    Connection conn) throws IOException {
  Table meta = null;
  try {
    meta = conn.getTable(TableName.META_TABLE_NAME);
    CoprocessorRpcChannel rpcChannel = meta.coprocessorService(HConstants.EMPTY_START_ROW);
    AuthenticationProtos.AuthenticationService.BlockingInterface service =
        AuthenticationProtos.AuthenticationService.newBlockingStub(rpcChannel);
    AuthenticationProtos.GetAuthenticationTokenResponse response = service.getAuthenticationToken(null,
        AuthenticationProtos.GetAuthenticationTokenRequest.getDefaultInstance());

    return ProtobufUtil.toToken(response.getToken());
  } catch (ServiceException se) {
    ProtobufUtil.toIOException(se);
  } finally {
    if (meta != null) {
      meta.close();
    }
  }
  // dummy return for ServiceException block
  return null;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:28,代码来源:TokenUtil.java

示例7: testEndpoint

import org.apache.hadoop.hbase.client.Table; //导入方法依赖的package包/类
public void testEndpoint() throws Throwable {
  Table table = new HTable(CONF, TEST_TABLE);

  // insert some test rows
  for (int i=0; i<5; i++) {
    byte[] iBytes = Bytes.toBytes(i);
    Put p = new Put(iBytes);
    p.add(TEST_FAMILY, TEST_COLUMN, iBytes);
    table.put(p);
  }

  final ExampleProtos.CountRequest request = ExampleProtos.CountRequest.getDefaultInstance();
  Map<byte[],Long> results = table.coprocessorService(ExampleProtos.RowCountService.class,
      null, null,
      new Batch.Call<ExampleProtos.RowCountService,Long>() {
        public Long call(ExampleProtos.RowCountService counter) throws IOException {
          ServerRpcController controller = new ServerRpcController();
          BlockingRpcCallback<ExampleProtos.CountResponse> rpcCallback =
              new BlockingRpcCallback<ExampleProtos.CountResponse>();
          counter.getRowCount(controller, request, rpcCallback);
          ExampleProtos.CountResponse response = rpcCallback.get();
          if (controller.failedOnException()) {
            throw controller.getFailedOn();
          }
          return (response != null && response.hasCount()) ? response.getCount() : 0;
        }
      });
  // should be one region with results
  assertEquals(1, results.size());
  Iterator<Long> iter = results.values().iterator();
  Long val = iter.next();
  assertNotNull(val);
  assertEquals(5l, val.longValue());
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:35,代码来源:TestRowCountEndpoint.java

示例8: incrementCounter

import org.apache.hadoop.hbase.client.Table; //导入方法依赖的package包/类
private int incrementCounter(Table table) throws Throwable {
  CoprocessorRpcChannel channel = table.coprocessorService(ROW);
  RowProcessorEndpoint.IncrementCounterProcessor processor =
      new RowProcessorEndpoint.IncrementCounterProcessor(ROW);
  RowProcessorService.BlockingInterface service =
      RowProcessorService.newBlockingStub(channel);
  ProcessRequest request = RowProcessorClient.getRowProcessorPB(processor);
  ProcessResponse protoResult = service.process(null, request);
  IncCounterProcessorResponse response = IncCounterProcessorResponse
      .parseFrom(protoResult.getRowProcessorResult());
  Integer result = response.getResponse();
  return result;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:14,代码来源:TestRowProcessorEndpoint.java

示例9: swapRows

import org.apache.hadoop.hbase.client.Table; //导入方法依赖的package包/类
private void swapRows(Table table) throws Throwable {
  CoprocessorRpcChannel channel = table.coprocessorService(ROW);
  RowProcessorEndpoint.RowSwapProcessor processor =
      new RowProcessorEndpoint.RowSwapProcessor(ROW, ROW2);
  RowProcessorService.BlockingInterface service =
      RowProcessorService.newBlockingStub(channel);
  ProcessRequest request = RowProcessorClient.getRowProcessorPB(processor);
  service.process(null, request);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:10,代码来源:TestRowProcessorEndpoint.java

示例10: invokeBulkDeleteProtocol

import org.apache.hadoop.hbase.client.Table; //导入方法依赖的package包/类
private long invokeBulkDeleteProtocol(TableName tableName, final Scan scan, final int rowBatchSize,
    final DeleteType deleteType, final Long timeStamp) throws Throwable {
  Table ht = new HTable(TEST_UTIL.getConfiguration(), tableName);
  long noOfDeletedRows = 0L;
  Batch.Call<BulkDeleteService, BulkDeleteResponse> callable =
    new Batch.Call<BulkDeleteService, BulkDeleteResponse>() {
    ServerRpcController controller = new ServerRpcController();
    BlockingRpcCallback<BulkDeleteResponse> rpcCallback =
      new BlockingRpcCallback<BulkDeleteResponse>();

    public BulkDeleteResponse call(BulkDeleteService service) throws IOException {
      Builder builder = BulkDeleteRequest.newBuilder();
      builder.setScan(ProtobufUtil.toScan(scan));
      builder.setDeleteType(deleteType);
      builder.setRowBatchSize(rowBatchSize);
      if (timeStamp != null) {
        builder.setTimestamp(timeStamp);
      }
      service.delete(controller, builder.build(), rpcCallback);
      return rpcCallback.get();
    }
  };
  Map<byte[], BulkDeleteResponse> result = ht.coprocessorService(BulkDeleteService.class, scan
      .getStartRow(), scan.getStopRow(), callable);
  for (BulkDeleteResponse response : result.values()) {
    noOfDeletedRows += response.getRowsDeleted();
  }
  ht.close();
  return noOfDeletedRows;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:31,代码来源:TestBulkDeleteProtocol.java

示例11: ping

import org.apache.hadoop.hbase.client.Table; //导入方法依赖的package包/类
private Map<byte [], String> ping(final Table table, final byte [] start, final byte [] end)
throws ServiceException, Throwable {
  return table.coprocessorService(PingProtos.PingService.class, start, end,
    new Batch.Call<PingProtos.PingService, String>() {
      @Override
      public String call(PingProtos.PingService instance) throws IOException {
        return doPing(instance);
      }
    });
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:11,代码来源:TestServerCustomProtocol.java

示例12: getAccessControlServiceStub

import org.apache.hadoop.hbase.client.Table; //导入方法依赖的package包/类
private static BlockingInterface getAccessControlServiceStub(Table ht)
    throws IOException {
  CoprocessorRpcChannel service = ht.coprocessorService(HConstants.EMPTY_START_ROW);
  BlockingInterface protocol =
      AccessControlProtos.AccessControlService.newBlockingStub(service);
  return protocol;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:8,代码来源:AccessControlClient.java

示例13: multiMutate

import org.apache.hadoop.hbase.client.Table; //导入方法依赖的package包/类
/**
 * Performs an atomic multi-Mutate operation against the given table.
 */
private static void multiMutate(Table table, byte[] row, Mutation... mutations)
    throws IOException {
  CoprocessorRpcChannel channel = table.coprocessorService(row);
  MultiRowMutationProtos.MutateRowsRequest.Builder mmrBuilder
    = MultiRowMutationProtos.MutateRowsRequest.newBuilder();
  for (Mutation mutation : mutations) {
    if (mutation instanceof Put) {
      mmrBuilder.addMutationRequest(ProtobufUtil.toMutation(
        ClientProtos.MutationProto.MutationType.PUT, mutation));
    } else if (mutation instanceof Delete) {
      mmrBuilder.addMutationRequest(ProtobufUtil.toMutation(
        ClientProtos.MutationProto.MutationType.DELETE, mutation));
    } else {
      throw new DoNotRetryIOException("multi in MetaEditor doesn't support "
        + mutation.getClass().getName());
    }
  }

  MultiRowMutationProtos.MultiRowMutationService.BlockingInterface service =
    MultiRowMutationProtos.MultiRowMutationService.newBlockingStub(channel);
  try {
    service.mutateRows(null, mmrBuilder.build());
  } catch (ServiceException ex) {
    ProtobufUtil.toIOException(ex);
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:30,代码来源:MetaTableAccessor.java

示例14: max

import org.apache.hadoop.hbase.client.Table; //导入方法依赖的package包/类
/**
 * It gives the maximum value of a column for a given column family for the
 * given range. In case qualifier is null, a max of all values for the given
 * family is returned.
 * @param table
 * @param ci
 * @param scan
 * @return max val &lt;&gt;
 * @throws Throwable
 *           The caller is supposed to handle the exception as they are thrown
 *           &amp; propagated to it.
 */
public <R, S, P extends Message, Q extends Message, T extends Message>
R max(final Table table, final ColumnInterpreter<R, S, P, Q, T> ci,
    final Scan scan) throws Throwable {
  final AggregateRequest requestArg = validateArgAndGetPB(scan, ci, false);
  class MaxCallBack implements Batch.Callback<R> {
    R max = null;

    R getMax() {
      return max;
    }

    @Override
    public synchronized void update(byte[] region, byte[] row, R result) {
      max = (max == null || (result != null && ci.compare(max, result) < 0)) ? result : max;
    }
  }
  MaxCallBack aMaxCallBack = new MaxCallBack();
  table.coprocessorService(AggregateService.class, scan.getStartRow(), scan.getStopRow(),
      new Batch.Call<AggregateService, R>() {
        @Override
        public R call(AggregateService instance) throws IOException {
          ServerRpcController controller = new ServerRpcController();
          BlockingRpcCallback<AggregateResponse> rpcCallback =
              new BlockingRpcCallback<AggregateResponse>();
          instance.getMax(controller, requestArg, rpcCallback);
          AggregateResponse response = rpcCallback.get();
          if (controller.failedOnException()) {
            throw controller.getFailedOn();
          }
          if (response.getFirstPartCount() > 0) {
            ByteString b = response.getFirstPart(0);
            Q q = ProtobufUtil.getParsedGenericInstance(ci.getClass(), 3, b);
            return ci.getCellValueFromProto(q);
          }
          return null;
        }
      }, aMaxCallBack);
  return aMaxCallBack.getMax();
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:52,代码来源:AggregationClient.java

示例15: rowCount

import org.apache.hadoop.hbase.client.Table; //导入方法依赖的package包/类
/**
 * It gives the row count, by summing up the individual results obtained from
 * regions. In case the qualifier is null, FirstKeyValueFilter is used to
 * optimised the operation. In case qualifier is provided, I can't use the
 * filter as it may set the flag to skip to next row, but the value read is
 * not of the given filter: in this case, this particular row will not be
 * counted ==&gt; an error.
 * @param table
 * @param ci
 * @param scan
 * @return &lt;R, S&gt;
 * @throws Throwable
 */
public <R, S, P extends Message, Q extends Message, T extends Message>
long rowCount(final Table table,
    final ColumnInterpreter<R, S, P, Q, T> ci, final Scan scan) throws Throwable {
  final AggregateRequest requestArg = validateArgAndGetPB(scan, ci, true);
  class RowNumCallback implements Batch.Callback<Long> {
    private final AtomicLong rowCountL = new AtomicLong(0);

    public long getRowNumCount() {
      return rowCountL.get();
    }

    @Override
    public void update(byte[] region, byte[] row, Long result) {
      rowCountL.addAndGet(result.longValue());
    }
  }
  RowNumCallback rowNum = new RowNumCallback();
  table.coprocessorService(AggregateService.class, scan.getStartRow(), scan.getStopRow(),
      new Batch.Call<AggregateService, Long>() {
        @Override
        public Long call(AggregateService instance) throws IOException {
          ServerRpcController controller = new ServerRpcController();
          BlockingRpcCallback<AggregateResponse> rpcCallback =
              new BlockingRpcCallback<AggregateResponse>();
          instance.getRowNum(controller, requestArg, rpcCallback);
          AggregateResponse response = rpcCallback.get();
          if (controller.failedOnException()) {
            throw controller.getFailedOn();
          }
          byte[] bytes = getBytesFromResponse(response.getFirstPart(0));
          ByteBuffer bb = ByteBuffer.allocate(8).put(bytes);
          bb.rewind();
          return bb.getLong();
        }
      }, rowNum);
  return rowNum.getRowNumCount();
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:51,代码来源:AggregationClient.java


注:本文中的org.apache.hadoop.hbase.client.Table.coprocessorService方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。