use of com.ms.silverking.cloud.dht.client.StoredValue in project SilverKing by Morgan-Stanley.
the class AsyncRetrievalOperationImpl method getLatestStoredValues.
@Override
public Map<K, ? extends StoredValue<V>> getLatestStoredValues() throws RetrievalException {
Map<K, StoredValue<V>> storedValueMap;
storedValueMap = new HashMap<>(retrievalOperation.size() - latestStoredReturned.size());
for (Map.Entry<K, RetrievalResultBase<V>> resultEntry : results.entrySet()) {
K key;
DHTKey dhtKey;
key = resultEntry.getKey();
dhtKey = keyToDHTKey.get(key);
if (!latestStoredReturned.contains(dhtKey)) {
RetrievalResultBase<V> value;
latestStoredReturned.add(dhtKey);
value = resultEntry.getValue();
if (value.getOpResult() == OpResult.SUCCEEDED) {
storedValueMap.put(resultEntry.getKey(), value);
}
}
}
return storedValueMap;
}
use of com.ms.silverking.cloud.dht.client.StoredValue in project SilverKing by Morgan-Stanley.
the class SilverKingClient method retrieveAllValuesForKey.
private Map<String, ? extends StoredValue<byte[]>> retrieveAllValuesForKey(String key) throws RetrievalException {
RetrievalOptions retrievalOptions;
Map<String, StoredValue<byte[]>> keyValues;
keyValues = new HashMap<>();
retrievalOptions = syncNSP.getOptions().getDefaultGetOptions().retrievalType(RetrievalType.META_DATA).nonExistenceResponse(NonExistenceResponse.NULL_VALUE).versionConstraint(VersionConstraint.greatest).returnInvalidations(true);
try {
do {
StoredValue<byte[]> storedValue;
// System.out.printf("%s\t%s\n", key, retrievalOptions);
storedValue = syncNSP.retrieve(key, retrievalOptions);
if (storedValue != null) {
String keyAndVersion;
keyAndVersion = String.format("%s %d %d %s", key, storedValue.getVersion(), storedValue.getCreationTime().inNanos(), storedValue.getCreationTime().toDateString());
keyValues.put(keyAndVersion, storedValue);
// System.out.printf("%d\t%d\n", storedValue.getMetaData().getVersion(), storedValue.getMetaData().getCreationTime().inNanos());
// retrievalOptions = retrievalOptions.versionConstraint(retrievalOptions.getVersionConstraint().maxCreationTime(storedValue.getCreationTime().inNanos() - 1));
retrievalOptions = retrievalOptions.versionConstraint(retrievalOptions.getVersionConstraint().maxBelowOrEqual(storedValue.getVersion() - 1));
// ThreadUtil.sleep(1000);
} else {
break;
}
} while (true);
} catch (RetrievalException re) {
displayRetrievalExceptionDetails(re);
throw re;
}
return keyValues;
}
Aggregations