Java 类org.apache.hadoop.hbase.quotas.QuotaSettings 实例源码

项目:ditb    文件:HBaseAdmin.java   
/**
 * Apply the new quota settings.
 * @param quota the quota settings
 * @throws IOException if a remote or network exception occurs
 */
@Override
public void setQuota(final QuotaSettings quota) throws IOException {
  executeCallable(new MasterCallable<Void>(getConnection()) {
    @Override
    public Void call(int callTimeout) throws ServiceException {
      PayloadCarryingRpcController controller = rpcControllerFactory.newController();
      controller.setCallTimeout(callTimeout);
      this.master.setQuota(controller, QuotaSettings.buildSetQuotaRequestProto(quota));
      return null;
    }
  });
}
项目:hbase    文件:TestAsyncQuotaAdminApi.java   
@Test
public void testThrottleType() throws Exception {
  String userName = User.getCurrent().getShortName();

  admin.setQuota(
    QuotaSettingsFactory.throttleUser(userName, ThrottleType.READ_NUMBER, 6, TimeUnit.MINUTES))
      .get();
  admin.setQuota(
    QuotaSettingsFactory.throttleUser(userName, ThrottleType.WRITE_NUMBER, 12, TimeUnit.MINUTES))
      .get();
  admin.setQuota(QuotaSettingsFactory.bypassGlobals(userName, true)).get();

  int countThrottle = 0;
  int countGlobalBypass = 0;
  for (QuotaSettings settings : admin.getQuota(null).get()) {
    switch (settings.getQuotaType()) {
    case THROTTLE:
      countThrottle++;
      break;
    case GLOBAL_BYPASS:
      countGlobalBypass++;
      break;
    default:
      fail("unexpected settings type: " + settings.getQuotaType());
    }
  }
  assertEquals(2, countThrottle);
  assertEquals(1, countGlobalBypass);

  admin.setQuota(QuotaSettingsFactory.unthrottleUser(userName)).get();
  assertNumResults(1, null);
  admin.setQuota(QuotaSettingsFactory.bypassGlobals(userName, false)).get();
  assertNumResults(0, null);
}
项目:hbase    文件:TestAsyncQuotaAdminApi.java   
private int countResults(final QuotaFilter filter) throws Exception {
  int count = 0;
  for (QuotaSettings settings : admin.getQuota(filter).get()) {
    LOG.debug(Objects.toString(settings));
    count++;
  }
  return count;
}
项目:hbase    文件:HBaseAdmin.java   
@Override
public void setQuota(final QuotaSettings quota) throws IOException {
  executeCallable(new MasterCallable<Void>(getConnection(), getRpcControllerFactory()) {
    @Override
    protected Void rpcCall() throws Exception {
      this.master.setQuota(getRpcController(), QuotaSettings.buildSetQuotaRequestProto(quota));
      return null;
    }
  });
}
项目:hbase    文件:HBaseAdmin.java   
@Override
public List<QuotaSettings> getQuota(QuotaFilter filter) throws IOException {
  List<QuotaSettings> quotas = new LinkedList<>();
  try (QuotaRetriever retriever = QuotaRetriever.open(conf, filter)) {
    Iterator<QuotaSettings> iterator = retriever.iterator();
    while (iterator.hasNext()) {
      quotas.add(iterator.next());
    }
  }
  return quotas;
}
项目:hbase    文件:RawAsyncHBaseAdmin.java   
@Override
public CompletableFuture<Void> setQuota(QuotaSettings quota) {
  return this
      .<Void> newMasterCaller()
      .action(
        (controller, stub) -> this.<SetQuotaRequest, SetQuotaResponse, Void> call(controller,
          stub, QuotaSettings.buildSetQuotaRequestProto(quota),
          (s, c, req, done) -> s.setQuota(c, req, done), (resp) -> null)).call();
}
项目:hbase    文件:RawAsyncHBaseAdmin.java   
@Override
public CompletableFuture<List<QuotaSettings>> getQuota(QuotaFilter filter) {
  CompletableFuture<List<QuotaSettings>> future = new CompletableFuture<>();
  Scan scan = QuotaTableUtil.makeScan(filter);
  this.connection.getTableBuilder(QuotaTableUtil.QUOTA_TABLE_NAME).build()
      .scan(scan, new AdvancedScanResultConsumer() {
        List<QuotaSettings> settings = new ArrayList<>();

        @Override
        public void onNext(Result[] results, ScanController controller) {
          for (Result result : results) {
            try {
              QuotaTableUtil.parseResultToCollection(result, settings);
            } catch (IOException e) {
              controller.terminate();
              future.completeExceptionally(e);
            }
          }
        }

        @Override
        public void onError(Throwable error) {
          future.completeExceptionally(error);
        }

        @Override
        public void onComplete() {
          future.complete(settings);
        }
      });
  return future;
}
项目:aliyun-tablestore-hbase-client    文件:TablestoreAdmin.java   
@Override
public void setQuota(QuotaSettings quota) throws IOException {
    throw new UnsupportedOperationException("setQuota");
}
项目:ColumnManagerForHBase    文件:MAdmin.java   
@Override
public void setQuota(QuotaSettings qs) throws IOException {
  wrappedHbaseAdmin.setQuota(qs);
}
项目:hbase    文件:AsyncHBaseAdmin.java   
@Override
public CompletableFuture<Void> setQuota(QuotaSettings quota) {
  return wrap(rawAdmin.setQuota(quota));
}
项目:hbase    文件:AsyncHBaseAdmin.java   
@Override
public CompletableFuture<List<QuotaSettings>> getQuota(QuotaFilter filter) {
  return wrap(rawAdmin.getQuota(filter));
}
项目:ditb    文件:Admin.java   
/**
 * Apply the new quota settings.
 * @param quota the quota settings
 * @throws IOException if a remote or network exception occurs
 */
void setQuota(final QuotaSettings quota) throws IOException;
项目:hbase    文件:Admin.java   
/**
 * Apply the new quota settings.
 *
 * @param quota the quota settings
 * @throws IOException if a remote or network exception occurs
 */
void setQuota(QuotaSettings quota) throws IOException;
项目:hbase    文件:Admin.java   
/**
 * List the quotas based on the filter.
 * @param filter the quota settings filter
 * @return the QuotaSetting list
 * @throws IOException if a remote or network exception occurs
 */
List<QuotaSettings> getQuota(QuotaFilter filter) throws IOException;
项目:hbase    文件:AsyncAdmin.java   
/**
 * Apply the new quota settings.
 * @param quota the quota settings
 */
CompletableFuture<Void> setQuota(QuotaSettings quota);
项目:hbase    文件:AsyncAdmin.java   
/**
 * List the quotas based on the filter.
 * @param filter the quota settings filter
 * @return the QuotaSetting list, which wrapped by a CompletableFuture.
 */
CompletableFuture<List<QuotaSettings>> getQuota(QuotaFilter filter);