private static ChunkKey chunk(Collection<ObjectInfo> info) { if (info == null || info.isEmpty()) return null; List<ObjectInfo> infoList = new ArrayList<ObjectInfo>(info); ObjectInfo.sort(infoList); return infoList.get(0).getChunkKey(); }
private static ChunkKey chunk(Collection<ObjectInfo> info) { if (info == null || info.isEmpty()) return null; List<ObjectInfo> infoList = new ArrayList<ObjectInfo>(info); ObjectInfo.sort(infoList); return infoList.get(0).getChunkKey(); }
public void run() { List<Change> ops = new ArrayList<Change>(toPut.size()); for (Map.Entry<ObjectIndexKey, Collection<ObjectInfo>> e : all(toPut)) { List<ObjectInfo> items = copy(e.getValue()); ObjectInfo.sort(items); ops.add(Change.put(ns.key(e.getKey()), encode(items))); } client.modify(ops, Sync.<Void> none()); }
public void run() { List<Change> ops = new ArrayList<Change>(toPut.size()); for (Map.Entry<ObjectIndexKey, Collection<ObjectInfo>> e : all(toPut)) { List<ObjectInfo> items = copy(e.getValue()); ObjectInfo.sort(items); ops.add(Change.put(ns.key(e.getKey()), encode(items))); } client.modify(ops, Sync.<Void> none()); }
private void processResults(Context context, Map<ObjectIndexKey, T> batch, Map<ObjectIndexKey, Collection<ObjectInfo>> objects) { for (T obj : batch.values()) { Collection<ObjectInfo> matches = objects.get(obj); if (matches == null || matches.isEmpty()) { if (retryMissingObjects && context == Context.FAST_MISSING_OK) retry.add(obj); continue; } tmp.clear(); tmp.addAll(matches); ObjectInfo.sort(tmp); if (cacheLoadedInfo) reader.getRecentInfoCache().put(obj, tmp); onResult(obj, tmp); } if (progress != null) progress.update(objects.size()); }
private void processResults(Context context, Map<ObjectIndexKey, T> batch, Map<ObjectIndexKey, Collection<ObjectInfo>> objects) { for (T obj : batch.values()) { Collection<ObjectInfo> matches = objects.get(obj); if (matches == null || matches.isEmpty()) { if (retryMissingObjects && context == Context.FAST_MISSING_OK) retry.add(obj); continue; } tmp.clear(); tmp.addAll(matches); ObjectInfo.sort(tmp); if (cacheLoadedInfo) reader.getRecentInfoCache().put(obj, tmp); onResult(obj, tmp); } if (progress != null) progress.update(objects.size()); }
private synchronized void processResults(Context ctx, Map<ObjectIndexKey, T> batch, Map<ObjectIndexKey, Collection<ObjectInfo>> objects) { for (T obj : batch.values()) { Collection<ObjectInfo> matches = objects.get(obj); if (matches == null || matches.isEmpty()) { if (ctx == Context.FAST_MISSING_OK) toRetry.add(obj); else if (reportMissing) push(obj, (ChunkKey) null); continue; } tmp.clear(); tmp.addAll(matches); ObjectInfo.sort(tmp); if (cacheLoadedInfo) reader.getRecentInfoCache().put(obj, tmp); push(obj, tmp.get(0)); } runningBatches--; notify(); }
private synchronized void processResults(Context ctx, Map<ObjectIndexKey, T> batch, Map<ObjectIndexKey, Collection<ObjectInfo>> objects) { for (T obj : batch.values()) { Collection<ObjectInfo> matches = objects.get(obj); if (matches == null || matches.isEmpty()) { if (ctx == Context.FAST_MISSING_OK) toRetry.add(obj); else if (reportMissing) push(obj, (ChunkKey) null); continue; } tmp.clear(); tmp.addAll(matches); ObjectInfo.sort(tmp); if (cacheLoadedInfo) reader.getRecentInfoCache().put(obj, tmp); push(obj, tmp.get(0)); } runningBatches--; notify(); }
private List<ObjectInfo> find(AnyObjectId obj) throws DhtException { List<ObjectInfo> info = recentInfo.get(obj); if (info != null) return info; stats.cntObjectIndex_Load++; ObjectIndexKey idxKey = ObjectIndexKey.create(repo, obj); Context opt = Context.READ_REPAIR; Sync<Map<ObjectIndexKey, Collection<ObjectInfo>>> sync = Sync.create(); db.objectIndex().get(opt, Collections.singleton(idxKey), sync); try { Collection<ObjectInfo> m; m = sync.get(getOptions().getTimeout()).get(idxKey); if (m == null || m.isEmpty()) return Collections.emptyList(); info = new ArrayList<ObjectInfo>(m); ObjectInfo.sort(info); recentInfo.put(obj, info); return info; } catch (InterruptedException e) { throw new DhtTimeoutException(e); } catch (TimeoutException e) { throw new DhtTimeoutException(e); } }
private List<ObjectInfo> find(AnyObjectId obj) throws DhtException { List<ObjectInfo> info = recentInfo.get(obj); if (info != null) return info; stats.cntObjectIndex_Load++; ObjectIndexKey idxKey = ObjectIndexKey.create(repo, obj); Context opt = Context.READ_REPAIR; Sync<Map<ObjectIndexKey, Collection<ObjectInfo>>> sync = Sync.create(); db.objectIndex().get(opt, Collections.singleton(idxKey), sync); try { Collection<ObjectInfo> m; m = sync.get(getOptions().getTimeout()).get(idxKey); if (m == null || m.isEmpty()) return Collections.emptyList(); info = new ArrayList<ObjectInfo>(m); ObjectInfo.sort(info); recentInfo.put(obj, info); return info; } catch (InterruptedException e) { throw new DhtTimeoutException(e); } catch (TimeoutException e) { throw new DhtTimeoutException(e); } }