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; }
@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; }
@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; }
@Override public QuotaRetriever getQuotaRetriever(QuotaFilter filter) throws IOException { throw new UnsupportedOperationException("getQuotaRetriever"); }
@Override public QuotaRetriever getQuotaRetriever(QuotaFilter qf) throws IOException { return wrappedHbaseAdmin.getQuotaRetriever(qf); }
private void assertNumResults(int expected, final QuotaFilter filter) throws Exception { assertEquals(expected, countResults(filter)); }
@Override public QuotaRetriever getQuotaRetriever(final QuotaFilter filter) throws IOException { return QuotaRetriever.open(conf, filter); }
@Override public CompletableFuture<List<QuotaSettings>> getQuota(QuotaFilter filter) { return wrap(rawAdmin.getQuota(filter)); }
/** * Return a Quota Scanner to list the quotas based on the filter. * @param filter the quota settings filter * @return the quota scanner * @throws IOException if a remote or network exception occurs */ @Override public QuotaRetriever getQuotaRetriever(final QuotaFilter filter) throws IOException { return QuotaRetriever.open(conf, filter); }
/** * Return a QuotaRetriever to list the quotas based on the filter. * @param filter the quota settings filter * @return the quota retriever * @throws IOException if a remote or network exception occurs */ QuotaRetriever getQuotaRetriever(final QuotaFilter filter) throws IOException;
/** * Return a QuotaRetriever to list the quotas based on the filter. * @param filter the quota settings filter * @return the quota retriever * @throws IOException if a remote or network exception occurs * @deprecated Since 2.0.0. Will be removed in 3.0.0. Use {@link #getQuota(QuotaFilter)}. */ @Deprecated QuotaRetriever getQuotaRetriever(QuotaFilter filter) throws IOException;
/** * 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;
/** * 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);