예제 #1
0
  private static List<DelayedEntry> filterItemsLessThanOrEqualToTime(
      WriteBehindQueue<DelayedEntry> queue, long now) {
    if (queue == null || queue.size() == 0) {
      return Collections.emptyList();
    }

    return queue.filterItems(now);
  }
예제 #2
0
 private void removeProcessed(
     String mapName, Map<Integer, List<DelayedEntry>> entryListPerPartition) {
   for (Map.Entry<Integer, List<DelayedEntry>> entry : entryListPerPartition.entrySet()) {
     final int partitionId = entry.getKey();
     final RecordStore recordStore = getRecordStoreOrNull(mapName, partitionId);
     if (recordStore == null) {
       continue;
     }
     final WriteBehindQueue<DelayedEntry> queue = getWriteBehindQueue(recordStore);
     final List<DelayedEntry> entries = entry.getValue();
     queue.removeAll(entries);
   }
 }
 @Override
 public void addFirst(Collection<E> collection) {
   if (collection == null || collection.isEmpty()) {
     return;
   }
   synchronized (mutex) {
     queue.addFirst(collection);
   }
 }
예제 #4
0
 private void addFailsToQueue(String mapName, Map<Integer, List<DelayedEntry>> failsPerPartition) {
   if (failsPerPartition.isEmpty()) {
     return;
   }
   for (Map.Entry<Integer, List<DelayedEntry>> entry : failsPerPartition.entrySet()) {
     final Integer partitionId = entry.getKey();
     final List<DelayedEntry> fails = failsPerPartition.get(partitionId);
     if (fails == null || fails.isEmpty()) {
       continue;
     }
     final RecordStore recordStore = getRecordStoreOrNull(mapName, partitionId);
     if (recordStore == null) {
       continue;
     }
     final WriteBehindQueue<DelayedEntry> queue = getWriteBehindQueue(recordStore);
     queue.addFront(fails);
   }
 }
 @Override
 public int drainTo(Collection<E> collection) {
   synchronized (mutex) {
     return queue.drainTo(collection);
   }
 }
 @Override
 public void clear() {
   synchronized (mutex) {
     queue.clear();
   }
 }
 @Override
 public int size() {
   synchronized (mutex) {
     return queue.size();
   }
 }
 @Override
 public boolean contains(E e) {
   synchronized (mutex) {
     return queue.contains(e);
   }
 }
 /**
  * Removes the first occurrence of the specified element in this queue when searching it by
  * starting from the head of this queue.
  *
  * @param e element to be removed.
  * @return <code>true</code> if removed successfully, <code>false</code> otherwise
  */
 @Override
 public boolean removeFirstOccurrence(E e) {
   synchronized (mutex) {
     return queue.removeFirstOccurrence(e);
   }
 }
 @Override
 public void addLast(E e) {
   synchronized (mutex) {
     queue.addLast(e);
   }
 }
 @Override
 public void getFrontByNumber(int numberOfElements, Collection<E> collection) {
   synchronized (mutex) {
     queue.getFrontByNumber(numberOfElements, collection);
   }
 }
 @Override
 public void getFrontByTime(long time, Collection<E> collection) {
   synchronized (mutex) {
     queue.getFrontByTime(time, collection);
   }
 }
 @Override
 public List<E> asList() {
   synchronized (mutex) {
     return queue.asList();
   }
 }