1 package com.trendmicro.grid.acl.ds.cache.commands;
2
3 import java.util.Collection;
4 import java.util.Map;
5 import java.util.concurrent.atomic.AtomicLong;
6
7
8
9
10
11
12
13 public abstract class GetFromSourceCommand<K, V> extends AbstractCommand<K, V> {
14
15 private final AtomicLong fetchedKeyCount;
16
17
18
19
20
21
22
23
24 protected GetFromSourceCommand(AtomicLong fetchedKeyCount, Collection<K> keys) {
25 super(keys);
26 this.fetchedKeyCount = fetchedKeyCount;
27 }
28
29 @Override
30 public final Map<K, V> call() throws Exception {
31 if (keys != null) fetchedKeyCount.addAndGet(keys.size());
32 return doCall();
33 }
34
35 protected abstract Map<K, V> doCall() throws Exception;
36 }