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


Java Batch.Call方法代码示例

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


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

示例1: coprocessorService

import org.apache.hadoop.hbase.client.coprocessor.Batch; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public <T extends Service, R> Map<byte[],R> coprocessorService(final Class<T> service,
    byte[] startKey, byte[] endKey, final Batch.Call<T,R> callable)
    throws ServiceException, Throwable {
  final Map<byte[],R> results =  Collections.synchronizedMap(
      new TreeMap<byte[], R>(Bytes.BYTES_COMPARATOR));
  coprocessorService(service, startKey, endKey, callable, new Batch.Callback<R>() {
    @Override
    public void update(byte[] region, byte[] row, R value) {
      if (region != null) {
        results.put(region, value);
      }
    }
  });
  return results;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:20,代码来源:HTable.java

示例2: getAuths

import org.apache.hadoop.hbase.client.coprocessor.Batch; //导入方法依赖的package包/类
/**
 * @param connection the Connection instance to use.
 * @param user
 * @return labels, the given user is globally authorized for.
 * @throws Throwable
 */
public static GetAuthsResponse getAuths(Connection connection, final String user)
    throws Throwable {
    try (Table table = connection.getTable(LABELS_TABLE_NAME)) {
      Batch.Call<VisibilityLabelsService, GetAuthsResponse> callable =
          new Batch.Call<VisibilityLabelsService, GetAuthsResponse>() {
        ServerRpcController controller = new ServerRpcController();
        BlockingRpcCallback<GetAuthsResponse> rpcCallback =
            new BlockingRpcCallback<GetAuthsResponse>();

        public GetAuthsResponse call(VisibilityLabelsService service) throws IOException {
          GetAuthsRequest.Builder getAuthReqBuilder = GetAuthsRequest.newBuilder();
          getAuthReqBuilder.setUser(ByteStringer.wrap(Bytes.toBytes(user)));
          service.getAuths(controller, getAuthReqBuilder.build(), rpcCallback);
          GetAuthsResponse response = rpcCallback.get();
          if (controller.failedOnException()) {
            throw controller.getFailedOn();
          }
          return response;
        }
      };
      Map<byte[], GetAuthsResponse> result =
        table.coprocessorService(VisibilityLabelsService.class,
          HConstants.EMPTY_BYTE_ARRAY, HConstants.EMPTY_BYTE_ARRAY, callable);
      return result.values().iterator().next(); // There will be exactly one region for labels
      // table and so one entry in result Map.
    }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:34,代码来源:VisibilityClient.java

示例3: setOrClearAuths

import org.apache.hadoop.hbase.client.coprocessor.Batch; //导入方法依赖的package包/类
private static VisibilityLabelsResponse setOrClearAuths(Connection connection,
    final String[] auths, final String user, final boolean setOrClear)
        throws IOException, ServiceException, Throwable {

    try (Table table = connection.getTable(LABELS_TABLE_NAME)) {
      Batch.Call<VisibilityLabelsService, VisibilityLabelsResponse> callable =
          new Batch.Call<VisibilityLabelsService, VisibilityLabelsResponse>() {
        ServerRpcController controller = new ServerRpcController();
        BlockingRpcCallback<VisibilityLabelsResponse> rpcCallback =
            new BlockingRpcCallback<VisibilityLabelsResponse>();

        public VisibilityLabelsResponse call(VisibilityLabelsService service) throws IOException {
          SetAuthsRequest.Builder setAuthReqBuilder = SetAuthsRequest.newBuilder();
          setAuthReqBuilder.setUser(ByteStringer.wrap(Bytes.toBytes(user)));
          for (String auth : auths) {
            if (auth.length() > 0) {
              setAuthReqBuilder.addAuth(ByteStringer.wrap(Bytes.toBytes(auth)));
            }
          }
          if (setOrClear) {
            service.setAuths(controller, setAuthReqBuilder.build(), rpcCallback);
          } else {
            service.clearAuths(controller, setAuthReqBuilder.build(), rpcCallback);
          }
          VisibilityLabelsResponse response = rpcCallback.get();
          if (controller.failedOnException()) {
            throw controller.getFailedOn();
          }
          return response;
        }
      };
      Map<byte[], VisibilityLabelsResponse> result = table.coprocessorService(
          VisibilityLabelsService.class, HConstants.EMPTY_BYTE_ARRAY, HConstants.EMPTY_BYTE_ARRAY,
          callable);
      return result.values().iterator().next(); // There will be exactly one region for labels
      // table and so one entry in result Map.
    }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:39,代码来源:VisibilityClient.java

示例4: coprocessorService

import org.apache.hadoop.hbase.client.coprocessor.Batch; //导入方法依赖的package包/类
@Override
public <T extends Service, R> Map<byte[], R> coprocessorService(Class<T> service,
    byte[] startKey, byte[] endKey, Batch.Call<T, R> callable)
    throws ServiceException, Throwable {
  checkState();
  return table.coprocessorService(service, startKey, endKey, callable);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:8,代码来源:HTablePool.java

示例5: invokeBulkDeleteProtocol

import org.apache.hadoop.hbase.client.coprocessor.Batch; //导入方法依赖的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

示例6: coprocessorService

import org.apache.hadoop.hbase.client.coprocessor.Batch; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public <T extends Service, R> Map<byte[], R> coprocessorService(final Class<T> service,
                                                                byte[] startKey, byte[] endKey, final Batch.Call<T, R> callable)
        throws ServiceException {
    throw new RuntimeException(this.getClass() + " does NOT implement this method.");
}
 
开发者ID:rayokota,项目名称:hgraphdb,代码行数:10,代码来源:MockHTable.java

示例7: coprocessorService

import org.apache.hadoop.hbase.client.coprocessor.Batch; //导入方法依赖的package包/类
<T extends Service, R> CompletableFuture<Map<byte[], R>> coprocessorService(final String tableName, final Class<T> service, final Object startRowKey,
        final Object endRowKey, final Batch.Call<T, R> callable) throws Exception {
    return asyncExecutor.execute(new Callable<Map<byte[], R>>() {
        @Override
        public Map<byte[], R> call() throws Exception {
            return hbaseExecutor.coprocessorService(tableName, service, startRowKey, endRowKey, callable);
        }
    });
}
 
开发者ID:landawn,项目名称:AbacusUtil,代码行数:10,代码来源:AsyncHBaseExecutor.java

示例8: coprocessorExec

import org.apache.hadoop.hbase.client.coprocessor.Batch; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public <T extends CoprocessorProtocol, R> Map<byte[], R> coprocessorExec(Class<T> protocol,
    byte[] startKey, byte[] endKey, Batch.Call<T, R> callable) throws IOException, Throwable {

  final Map<byte[], R> results =
      Collections.synchronizedMap(new TreeMap<byte[], R>(Bytes.BYTES_COMPARATOR));
  coprocessorExec(protocol, startKey, endKey, callable, new Batch.Callback<R>() {
    public void update(byte[] region, byte[] row, R value) {
      results.put(region, value);
    }
  });
  return results;
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:17,代码来源:HTable.java

示例9: coprocessorExec

import org.apache.hadoop.hbase.client.coprocessor.Batch; //导入方法依赖的package包/类
@Override
public <T extends CoprocessorProtocol, R> Map<byte[], R> coprocessorExec(
    Class<T> protocol, byte[] startKey, byte[] endKey,
    Batch.Call<T, R> callable)
    throws IOException, Throwable {
  throw new UnsupportedOperationException("coprocessorExec not implemented");
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:8,代码来源:RemoteHTable.java

示例10: invokeBulkDeleteProtocol

import org.apache.hadoop.hbase.client.coprocessor.Batch; //导入方法依赖的package包/类
private long invokeBulkDeleteProtocol(byte[] tableName, final Scan scan, final int rowBatchSize,
    final DeleteType deleteType, final Long timeStamp) throws Throwable {
  HTable 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:tenggyut,项目名称:HIndex,代码行数:31,代码来源:TestBulkDeleteProtocol.java

示例11: setOrClearAuths

import org.apache.hadoop.hbase.client.coprocessor.Batch; //导入方法依赖的package包/类
private static VisibilityLabelsResponse setOrClearAuths(Configuration conf, final String[] auths,
    final String user, final boolean setOrClear) throws IOException, ServiceException, Throwable {
  // TODO: Make it so caller passes in a Connection rather than have us do this expensive
  // setup each time.  This class only used in test and shell at moment though.
  try (Connection connection = ConnectionFactory.createConnection(conf)) {
    try (Table table = connection.getTable(LABELS_TABLE_NAME)) {
      Batch.Call<VisibilityLabelsService, VisibilityLabelsResponse> callable =
          new Batch.Call<VisibilityLabelsService, VisibilityLabelsResponse>() {
        ServerRpcController controller = new ServerRpcController();
        BlockingRpcCallback<VisibilityLabelsResponse> rpcCallback =
            new BlockingRpcCallback<VisibilityLabelsResponse>();

        public VisibilityLabelsResponse call(VisibilityLabelsService service) throws IOException {
          SetAuthsRequest.Builder setAuthReqBuilder = SetAuthsRequest.newBuilder();
          setAuthReqBuilder.setUser(ByteStringer.wrap(Bytes.toBytes(user)));
          for (String auth : auths) {
            if (auth.length() > 0) {
              setAuthReqBuilder.addAuth(ByteStringer.wrap(Bytes.toBytes(auth)));
            }
          }
          if (setOrClear) {
            service.setAuths(controller, setAuthReqBuilder.build(), rpcCallback);
          } else {
            service.clearAuths(controller, setAuthReqBuilder.build(), rpcCallback);
          }
          VisibilityLabelsResponse response = rpcCallback.get();
          if (controller.failedOnException()) {
            throw controller.getFailedOn();
          }
          return response;
        }
      };
      Map<byte[], VisibilityLabelsResponse> result = table.coprocessorService(
          VisibilityLabelsService.class, HConstants.EMPTY_BYTE_ARRAY, HConstants.EMPTY_BYTE_ARRAY,
          callable);
      return result.values().iterator().next(); // There will be exactly one region for labels
      // table and so one entry in result Map.
    }
  }
}
 
开发者ID:grokcoder,项目名称:pbase,代码行数:41,代码来源:VisibilityClient.java

示例12: getAuths

import org.apache.hadoop.hbase.client.coprocessor.Batch; //导入方法依赖的package包/类
/**
 * @param conf
 * @param user
 * @return labels, the given user is globally authorized for.
 * @throws Throwable
 */
public static GetAuthsResponse getAuths(Configuration conf, final String user) throws Throwable {
  HTable ht = null;
  try {
    ht = new HTable(conf, LABELS_TABLE_NAME.getName());
    Batch.Call<VisibilityLabelsService, GetAuthsResponse> callable = 
        new Batch.Call<VisibilityLabelsService, GetAuthsResponse>() {
      ServerRpcController controller = new ServerRpcController();
      BlockingRpcCallback<GetAuthsResponse> rpcCallback = 
          new BlockingRpcCallback<GetAuthsResponse>();

      public GetAuthsResponse call(VisibilityLabelsService service) throws IOException {
        GetAuthsRequest.Builder getAuthReqBuilder = GetAuthsRequest.newBuilder();
        getAuthReqBuilder.setUser(HBaseZeroCopyByteString.wrap(Bytes.toBytes(user)));
        service.getAuths(controller, getAuthReqBuilder.build(), rpcCallback);
        return rpcCallback.get();
      }
    };
    Map<byte[], GetAuthsResponse> result = ht.coprocessorService(VisibilityLabelsService.class,
        HConstants.EMPTY_BYTE_ARRAY, HConstants.EMPTY_BYTE_ARRAY, callable);
    return result.values().iterator().next(); // There will be exactly one region for labels
                                              // table and so one entry in result Map.
  } finally {
    if (ht != null) {
      ht.close();
    }
  }
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:34,代码来源:VisibilityClient.java

示例13: coprocessorService

import org.apache.hadoop.hbase.client.coprocessor.Batch; //导入方法依赖的package包/类
@Override
public <T extends Service, R> Map<byte[], R> coprocessorService(Class<T> service, byte[] startKey, byte[] endKey, Batch.Call<T, R> callable) throws ServiceException, Throwable {
    throw new UnsupportedOperationException("coprocessorService");
}
 
开发者ID:aliyun,项目名称:aliyun-tablestore-hbase-client,代码行数:5,代码来源:TablestoreTable.java

示例14: coprocessorService

import org.apache.hadoop.hbase.client.coprocessor.Batch; //导入方法依赖的package包/类
@Override
public <T extends Service, R> Map<byte[], R> coprocessorService(Class<T> service,
    byte[] startKey, byte[] endKey, Batch.Call<T, R> callable)
    throws ServiceException, Throwable {
  return table.coprocessorService(service, startKey, endKey, callable);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:7,代码来源:HTableWrapper.java

示例15: listLabels

import org.apache.hadoop.hbase.client.coprocessor.Batch; //导入方法依赖的package包/类
/**
 * Retrieve the list of visibility labels defined in the system.
 * @param connection The Connection instance to use.
 * @param regex  The regular expression to filter which labels are returned.
 * @return labels The list of visibility labels defined in the system.
 * @throws Throwable
 */
public static ListLabelsResponse listLabels(Connection connection, final String regex)
    throws Throwable {
  Table table = null;
  try {
    table = connection.getTable(LABELS_TABLE_NAME);
    Batch.Call<VisibilityLabelsService, ListLabelsResponse> callable =
        new Batch.Call<VisibilityLabelsService, ListLabelsResponse>() {
          ServerRpcController controller = new ServerRpcController();
          BlockingRpcCallback<ListLabelsResponse> rpcCallback =
              new BlockingRpcCallback<ListLabelsResponse>();

          public ListLabelsResponse call(VisibilityLabelsService service) throws IOException {
            ListLabelsRequest.Builder listAuthLabelsReqBuilder = ListLabelsRequest.newBuilder();
            if (regex != null) {
              // Compile the regex here to catch any regex exception earlier.
              Pattern pattern = Pattern.compile(regex);
              listAuthLabelsReqBuilder.setRegex(pattern.toString());
            }
            service.listLabels(controller, listAuthLabelsReqBuilder.build(), rpcCallback);
            ListLabelsResponse response = rpcCallback.get();
            if (controller.failedOnException()) {
              throw controller.getFailedOn();
            }
            return response;
          }
        };
    Map<byte[], ListLabelsResponse> result =
        table.coprocessorService(VisibilityLabelsService.class, HConstants.EMPTY_BYTE_ARRAY,
          HConstants.EMPTY_BYTE_ARRAY, callable);
    return result.values().iterator().next(); // There will be exactly one region for labels
    // table and so one entry in result Map.
  }
  finally {
    if (table != null) {
      table.close();
    }
    if (connection != null) {
      connection.close();
    }
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:49,代码来源:VisibilityClient.java


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