ShardedCounter { void updateLimit(StorageTransaction tx, String counterId, long limit) throws IOException { tx.updateLimitForCounter(counterId, limit); } ShardedCounter(Stats stats, CounterSnapshotFactory counterSnapshotFactory); boolean counterHasSpareCapacity(String resourceId); void updateCounter(StorageTransaction transaction, String counterId, long delta); static final int NUM_SHARDS; static final String KIND_COUNTER_LIMIT; static final String PROPERTY_LIMIT; static final String KIND_COUNTER_SHARD; static final String PROPERTY_SHARD_VALUE; static final String PROPERTY_SHARD_INDEX; static final String PROPERTY_COUNTER_ID; }
@Test public void shouldCreateLimit() throws IOException { assertNull(getLimitFromStorage(COUNTER_ID3)); storage.runInTransactionWithRetries(transaction -> { shardedCounter.updateLimit(transaction, COUNTER_ID3, 500); return null; }); assertEquals(500L, getLimitFromStorage(COUNTER_ID3).getLong(PROPERTY_LIMIT)); }