public void stop() { if (isQuotaEnabled()) { quotaCache.stop("shutdown"); } }
/** * Returns the correct instance of {@link FileArchiverNotifier} for the given table name. * * @param tn The table name * @return A {@link FileArchiverNotifier} instance */ FileArchiverNotifier getNotifierForTable(TableName tn) { return FileArchiverNotifierFactoryImpl.getInstance().get(conn, conf, fs, tn); }
/** * Returns the limiter associated to the specified table. * * @param table the table to limit * @return the limiter associated to the specified table */ public QuotaLimiter getTableLimiter(final TableName table) { return getQuotaState(this.tableQuotaCache, table).getGlobalLimiter(); }
@Override public boolean evaluate() throws Exception { ActivePolicyEnforcement enforcements = manager.getActiveEnforcements(); SpaceViolationPolicyEnforcement enforcement = enforcements.getPolicyEnforcement(tn); // Signifies that we're waiting on the quota snapshot to be fetched if (enforcement instanceof MissingSnapshotViolationPolicyEnforcement) { return false; } return enforcement.getQuotaSnapshot().getQuotaStatus().isInViolation(); } });
private static void throwThrottlingException(final Type type, final long waitInterval) throws ThrottlingException { String msg = MSG_TYPE[type.ordinal()] + MSG_WAIT + formatTime(waitInterval); throw new ThrottlingException(type, waitInterval, msg); }
/** * Checks if the given <code>snapshot</code> is in violation, allowing the snapshot to be null. * If the snapshot is null, this is interpreted as no snapshot which implies not in violation. * * @param snapshot The snapshot to operate on. * @return true if the snapshot is in violation, false otherwise. */ boolean isInViolation(SpaceQuotaSnapshot snapshot) { if (snapshot == null) { return false; } return snapshot.getQuotaStatus().isInViolation(); }
/** * Creates an object well-suited for the RegionServer to use in verifying active policies. */ public ActivePolicyEnforcement getActiveEnforcements() { return new ActivePolicyEnforcement(copyActiveEnforcements(), copyQuotaSnapshots(), rsServices); }
@Override protected QuotaGlobalsSettingsBypass merge(QuotaSettings newSettings) throws IOException { if (newSettings instanceof QuotaGlobalsSettingsBypass) { QuotaGlobalsSettingsBypass other = (QuotaGlobalsSettingsBypass) newSettings; validateQuotaTarget(other); if (getBypass() != other.getBypass()) { return other; } } return this; } }
@Override public void addScanResult(final List<Result> results) { operationSize[OperationType.SCAN.ordinal()] += QuotaUtil.calculateResultSize(results); }
@Override public void addMutation(final Mutation mutation) { operationSize[OperationType.MUTATE.ordinal()] += QuotaUtil.calculateMutationSize(mutation); }
/** * Remove the throttling for the specified user on the specified table. * * @param userName the user * @param tableName the table * @return the quota settings */ public static QuotaSettings unthrottleUser(final String userName, final TableName tableName) { return throttle(userName, tableName, null, null, null, 0, null); }
@Override public boolean evaluate(SpaceQuotaSnapshot snapshot) throws Exception { return snapshot.getUsage() >= finalSize; } });
@Override public Void call() throws Exception { try (Connection conn = getConnection()) { helper.writeData(tn, 3L * SpaceQuotaHelperForTests.ONE_MEGABYTE); return null; } } });
/** * Returns the limiter associated to the specified namespace. * * @param namespace the namespace to limit * @return the limiter associated to the specified namespace */ public QuotaLimiter getNamespaceLimiter(final String namespace) { return getQuotaState(this.namespaceQuotaCache, namespace).getGlobalLimiter(); }
@Override public void addGetResult(final Result result) { operationSize[OperationType.GET.ordinal()] += QuotaUtil.calculateResultSize(result); }
/** * Remove the throttling for the specified user on the specified namespace. * * @param userName the user * @param namespace the namespace * @return the quota settings */ public static QuotaSettings unthrottleUser(final String userName, final String namespace) { return throttle(userName, null, namespace, null, null, 0, null); }
@Override public Void call() throws Exception { try (Connection conn = getConnection()) { helper.writeData(tn, 3L * SpaceQuotaHelperForTests.ONE_MEGABYTE); return null; } } });
/** * Returns the limiter associated to the specified region server. * * @param regionServer the region server to limit * @return the limiter associated to the specified region server */ public QuotaLimiter getRegionServerQuotaLimiter(final String regionServer) { return getQuotaState(this.regionServerQuotaCache, regionServer).getGlobalLimiter(); }
/** * Remove the throttling for the specified region server. * * @param regionServer the region Server * @return the quota settings */ public static QuotaSettings unthrottleRegionServer(final String regionServer) { return throttle(null, null, null, regionServer, null, 0, null); }