private int countResults(final QuotaFilter filter) throws Exception { QuotaRetriever scanner = QuotaRetriever.open(TEST_UTIL.getConfiguration(), filter); try { int count = 0; for (QuotaSettings settings: scanner) { LOG.debug(Objects.toString(settings)); count++; } return count; } finally { scanner.close(); } } }
/** * Open a QuotaRetriever with the specified filter. * @param conf Configuration object to use. * @param filter the QuotaFilter * @return the QuotaRetriever * @throws IOException if a remote or network exception occurs */ public static QuotaRetriever open(final Configuration conf, final QuotaFilter filter) throws IOException { Scan scan = QuotaTableUtil.makeScan(filter); QuotaRetriever scanner = new QuotaRetriever(); scanner.init(conf, scan); return scanner; } }
@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; }
QuotaRetriever scanner = QuotaRetriever.open(admin.getConfiguration()); try { assertSpaceQuota(sizeLimit, violationPolicy, Iterables.getOnlyElement(scanner)); } finally { scanner.close(); scanner = QuotaRetriever.open(admin.getConfiguration()); try { assertNull("Did not expect to find a quota entry", scanner.next()); } finally { scanner.close();
/** * Open a QuotaRetriever with no filter, all the quota settings will be returned. * @param conf Configuration object to use. * @return the QuotaRetriever * @throws IOException if a remote or network exception occurs */ public static QuotaRetriever open(final Configuration conf) throws IOException { return open(conf, null); }
public Iter() { try { cache = QuotaRetriever.this.next(); } catch (IOException e) { LOG.warn(StringUtils.stringifyException(e)); } }
void init(final Connection conn, final Scan scan) throws IOException { this.connection = Objects.requireNonNull(conn); this.table = this.connection.getTable(QuotaTableUtil.QUOTA_TABLE_NAME); try { scanner = table.getScanner(scan); } catch (IOException e) { try { close(); } catch (IOException ioe) { LOG.warn("Failed getting scanner and then failed close on cleanup", e); } throw e; } }
void init(final Configuration conf, final Scan scan) throws IOException { // Set this before creating the connection and passing it down to make sure // it's cleaned up if we fail to construct the Scanner. this.isManagedConnection = true; init(ConnectionFactory.createConnection(conf), scan); }
QuotaRetriever quotaScanner = QuotaRetriever.open(admin.getConfiguration()); try { assertSpaceQuota(originalSizeLimit, violationPolicy, Iterables.getOnlyElement(quotaScanner)); } finally { quotaScanner.close(); quotaScanner = QuotaRetriever.open(admin.getConfiguration()); try { assertSpaceQuota(newSizeLimit, newViolationPolicy, Iterables.getOnlyElement(quotaScanner)); } finally { quotaScanner.close(); quotaScanner = QuotaRetriever.open(admin.getConfiguration()); try { assertNull("Did not expect to find a quota entry", quotaScanner.next()); } finally { quotaScanner.close();
@Override public QuotaRetriever getQuotaRetriever(final QuotaFilter filter) throws IOException { return QuotaRetriever.open(conf, filter); }
@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 QuotaSettings next() { QuotaSettings result = cache; try { cache = QuotaRetriever.this.next(); } catch (IOException e) { LOG.warn(StringUtils.stringifyException(e)); } return result; }
void init(final Connection conn, final Scan scan) throws IOException { this.connection = Objects.requireNonNull(conn); this.table = this.connection.getTable(QuotaTableUtil.QUOTA_TABLE_NAME); try { scanner = table.getScanner(scan); } catch (IOException e) { try { close(); } catch (IOException ioe) { LOG.warn("Failed getting scanner and then failed close on cleanup", e); } throw e; } }
void init(final Configuration conf, final Scan scan) throws IOException { // Set this before creating the connection and passing it down to make sure // it's cleaned up if we fail to construct the Scanner. this.isManagedConnection = true; init(ConnectionFactory.createConnection(conf), scan); }
QuotaRetriever scanner = QuotaRetriever.open(admin.getConfiguration()); try { assertSpaceQuota(sizeLimit, violationPolicy, Iterables.getOnlyElement(scanner)); } finally { scanner.close(); scanner = QuotaRetriever.open(admin.getConfiguration()); try { assertNull("Did not expect to find a quota entry", scanner.next()); } finally { scanner.close();
/** * Returns the number of quotas defined in the HBase quota table. */ long listNumDefinedQuotas(Connection conn) throws IOException { QuotaRetriever scanner = QuotaRetriever.open(conn.getConfiguration()); try { return Iterables.size(scanner); } finally { if (scanner != null) { scanner.close(); } } }
try (Admin admin = conn.getAdmin()) { for (QuotaSettings qs : QuotaRetriever.open(conf, filter)) { if (qs.getQuotaType() == QuotaType.SPACE) { String ns = qs.getNamespace();
final Scan scan = QuotaTableUtil.makeScan(null); final TablesWithQuotas tablesWithQuotas = new TablesWithQuotas(conn, conf); try (final QuotaRetriever scanner = new QuotaRetriever()) { scanner.init(conn, scan); for (QuotaSettings quotaSettings : scanner) {