@Test public void fetchTop() throws FailStoreException { List<Pair<String, Job>> pairs = failStore.fetchTop(5, Job.class); if (CollectionUtils.isNotEmpty(pairs)) { for (Pair<String, Job> pair : pairs) { System.out.println(JSON.toJSONString(pair)); } } }
@Override public <T> List<Pair<String, T>> fetchTop(int size, Type type) throws FailStoreException { List<Pair<String, T>> list = new ArrayList<Pair<String, T>>(size); if (map.size() == 0) { return list; } for (Map.Entry<String, String> entry : map.entrySet()) { String key = entry.getKey(); T value = JSON.parse(entry.getValue(), type); Pair<String, T> pair = new Pair<String, T>(key, value); list.add(pair); if (list.size() >= size) { break; } } return list; }
MapdbFailStore extends AbstractFailStore { @Override public <T> List<Pair<String, T>> fetchTop(int size, Type type) throws FailStoreException { List<Pair<String, T>> list = new ArrayList<Pair<String, T>>(size); if (map.size() == 0) { return list; } for (Map.Entry<String, String> entry : map.entrySet()) { String key = entry.getKey(); T value = JSON.parse(entry.getValue(), type); Pair<String, T> pair = new Pair<String, T>(key, value); list.add(pair); if (list.size() >= size) { break; } } return list; } }
MapdbFailStore extends AbstractFailStore { @Override public <T> List<Pair<String, T>> fetchTop(int size, Type type) throws FailStoreException { List<Pair<String, T>> list = new ArrayList<Pair<String, T>>(size); if (map.size() == 0) { return list; } for (Map.Entry<String, String> entry : map.entrySet()) { String key = entry.getKey(); T value = JSON.parse(entry.getValue(), type); Pair<String, T> pair = new Pair<String, T>(key, value); list.add(pair); if (list.size() >= size) { break; } } return list; } MapdbFailStore(File dbPath, boolean needLock); }
MapdbFailStore extends AbstractFailStore { @Override public <T> List<Pair<String, T>> fetchTop(int size, Type type) throws FailStoreException { List<Pair<String, T>> list = new ArrayList<Pair<String, T>>(size); if (map.size() == 0) { return list; } for (Map.Entry<String, String> entry : map.entrySet()) { String key = entry.getKey(); T value = JSON.parse(entry.getValue(), type); Pair<String, T> pair = new Pair<String, T>(key, value); list.add(pair); if (list.size() >= size) { break; } } return list; } MapdbFailStore(File dbPath, boolean needLock); @Override void open(); @Override void put(String key, Object value); @Override void delete(String key); @Override void delete(List<String> keys); @Override List<Pair<String, T>> fetchTop(int size, Type type); @Override void close(); @Override void destroy(); }
MapdbFailStore extends AbstractFailStore { @Override public <T> List<Pair<String, T>> fetchTop(int size, Type type) throws FailStoreException { List<Pair<String, T>> list = new ArrayList<Pair<String, T>>(size); if (map.size() == 0) { return list; } for (Map.Entry<String, String> entry : map.entrySet()) { String key = entry.getKey(); T value = JSON.parse(entry.getValue(), type); Pair<String, T> pair = new Pair<String, T>(key, value); list.add(pair); if (list.size() >= size) { break; } } return list; } MapdbFailStore(File dbPath, boolean needLock); @Override void open(); @Override void put(String key, Object value); @Override void delete(String key); @Override void delete(List<String> keys); @Override List<Pair<String, T>> fetchTop(int size, Type type); @Override void close(); @Override void destroy(); static final String name; }