/** * Perform an update of the quota state based on the other quota state object. * (This operation is executed by the QuotaCache) */ @Override public synchronized void update(final QuotaState other) { super.update(other); if (other instanceof UserQuotaState) { UserQuotaState uOther = (UserQuotaState)other; tableLimiters = updateLimiters(tableLimiters, uOther.tableLimiters); namespaceLimiters = updateLimiters(namespaceLimiters, uOther.namespaceLimiters); bypassGlobals = uOther.bypassGlobals; } else { tableLimiters = null; namespaceLimiters = null; bypassGlobals = false; } }
V quotaInfo = quotasMap.putIfAbsent(entry.getKey(), entry.getValue()); if (quotaInfo != null) { quotaInfo.update(entry.getValue());
assertFalse(otherQuotaState.isBypass()); quotaInfo.update(otherQuotaState); assertEquals(LAST_UPDATE_1, quotaInfo.getLastUpdate()); assertFalse(quotaInfo.isBypass()); assertFalse(otherQuotaState.isBypass()); quotaInfo.update(otherQuotaState); assertEquals(LAST_UPDATE_2, quotaInfo.getLastUpdate()); assertFalse(quotaInfo.isBypass()); assertTrue(otherQuotaState.isBypass()); quotaInfo.update(otherQuotaState); assertEquals(LAST_UPDATE_3, quotaInfo.getLastUpdate()); assertTrue(quotaInfo.isBypass());
/** * Perform an update of the quota state based on the other quota state object. (This operation is * executed by the QuotaCache) */ @Override public synchronized void update(final QuotaState other) { super.update(other); if (other instanceof UserQuotaState) { UserQuotaState uOther = (UserQuotaState) other; tableLimiters = updateLimiters(tableLimiters, uOther.tableLimiters); namespaceLimiters = updateLimiters(namespaceLimiters, uOther.namespaceLimiters); bypassGlobals = uOther.bypassGlobals; } else { tableLimiters = null; namespaceLimiters = null; bypassGlobals = false; } }
V quotaInfo = quotasMap.putIfAbsent(entry.getKey(), entry.getValue()); if (quotaInfo != null) { quotaInfo.update(entry.getValue());
assertFalse(otherQuotaState.isBypass()); quotaInfo.update(otherQuotaState); assertEquals(LAST_UPDATE_1, quotaInfo.getLastUpdate()); assertFalse(quotaInfo.isBypass()); assertFalse(otherQuotaState.isBypass()); quotaInfo.update(otherQuotaState); assertEquals(LAST_UPDATE_2, quotaInfo.getLastUpdate()); assertFalse(quotaInfo.isBypass()); assertTrue(otherQuotaState.isBypass()); quotaInfo.update(otherQuotaState); assertEquals(LAST_UPDATE_3, quotaInfo.getLastUpdate()); assertTrue(quotaInfo.isBypass());