コード例 #1
0
  /** Shrinks queue to maximum allowed size. */
  private void shrink() {
    long maxSize = this.maxSize;
    int maxBlocks = this.maxBlocks;

    int cnt = queue.sizex();

    for (int i = 0;
        i < cnt
            && (maxBlocks > 0 && queue.sizex() > maxBlocks
                || maxSize > 0 && curSize.longValue() > maxSize);
        i++) {
      GridCacheEntry<GridGgfsBlockKey, byte[]> entry = queue.poll();

      if (entry == null) break; // Queue is empty.

      byte[] val = entry.peek();

      if (val != null)
        changeSize(-val.length); // Change current size as we polled entry from the queue.

      if (!entry.evict()) {
        // Reorder entries which we failed to evict.
        entry.removeMeta(META_NODE);

        touch(entry);
      }
    }
  }
コード例 #2
0
 @Test
 public void test() {
   Command<KVStore> initial = commands.remove(0);
   sm.applyFunction().apply(0L, initial);
   commands.forEach(
       c -> {
         final long index = la.longValue();
         sm.applyFunction().apply(index, c);
         la.increment();
       });
   KVStore kvsm = (KVStore) sm;
   kvsm.getKvMap().forEach((k, v) -> System.out.println(k + " --> " + v));
   assertTrue(kvsm.getKvMap().size() == 10);
 }
コード例 #3
0
 /** {@inheritDoc} */
 @Override
 public long getCurrentSize() {
   return curSize.longValue();
 }
コード例 #4
0
ファイル: Clock.java プロジェクト: ToastNumber/Simulizer
 public long getTicks() {
   return ticks.longValue();
 }