use of com.ms.silverking.cloud.dht.common.DHTKey in project SilverKing by Morgan-Stanley.
the class ActivePutListeners method receivedPutResponse.
public <K, V> void receivedPutResponse(MessageGroup message) {
if (enableMultipleOpsPerMessage) {
long version;
ConcurrentMap<DHTKey, WeakReference<ActiveKeyedOperationResultListener<OpResult>>> listenerMap;
version = message.getBuffers()[0].getLong(0);
// Log.warning("receivedPutResponse version ", version);
listenerMap = activePutListeners.get(message.getUUID());
if (listenerMap != null) {
for (MessageGroupKeyOrdinalEntry entry : message.getKeyOrdinalIterator()) {
WeakReference<ActiveKeyedOperationResultListener<OpResult>> listenerRef;
ActiveKeyedOperationResultListener<OpResult> listener;
if (debug) {
System.out.println(new SimpleKey(entry.getKey()));
}
listenerRef = listenerMap.get(entry.getKey());
listener = listenerRef.get();
if (listener != null) {
listener.resultReceived(entry.getKey(), EnumValues.opResult[entry.getOrdinal()]);
} else {
Log.info("receivedPutResponse. null listener ref for: ", message.getUUID() + "\t" + entry.getKey());
}
}
} else {
// If we're receiving the error, then it's possible that we lost the
// reference that was stored in the weak map.
Log.warning("receivedPutResponse. No listenerMap for: ", message.getUUID());
}
} else {
ActiveKeyedOperationResultListener<OpResult> listener;
listener = activeOpListeners.get(message.getUUID());
if (listener == null) {
Log.info("receivedRetrievalResponse. No listener for uuid: ", message.getUUID());
} else {
for (MessageGroupKeyOrdinalEntry entry : message.getKeyOrdinalIterator()) {
listener.resultReceived(entry.getKey(), EnumValues.opResult[entry.getOrdinal()]);
}
}
}
}
use of com.ms.silverking.cloud.dht.common.DHTKey in project SilverKing by Morgan-Stanley.
the class SegmentedPutValue method checkForCompletion.
@Override
protected void checkForCompletion() {
OpResult result;
result = OpResult.SUCCEEDED;
for (DHTKey key : keys) {
if (getResult(key) != OpResult.SUCCEEDED) {
result = getResult(key);
}
}
if (getResult(relayKey) != OpResult.SUCCEEDED) {
result = getResult(relayKey);
}
parent.resultReceived(relayKey, result);
}
use of com.ms.silverking.cloud.dht.common.DHTKey in project SilverKing by Morgan-Stanley.
the class ArrayMD5KeyCreator method createKey.
@Override
public DHTKey createKey(byte[] key) {
DHTKey dhtKey;
// dhtKey = cachedKeys.get(key);
// if (dhtKey == null) {
dhtKey = md5KeyDigest.computeKey(key);
// }
return dhtKey;
}
use of com.ms.silverking.cloud.dht.common.DHTKey in project SilverKing by Morgan-Stanley.
the class ArrayMD5KeyCreator method main.
public static void main(String[] args) {
ArrayMD5KeyCreator stringMD5KeyCreator;
DHTKey key;
DHTKey[] subKeys;
int numSubKeys;
stringMD5KeyCreator = new ArrayMD5KeyCreator();
key = stringMD5KeyCreator.createKey("GeorgeWashington".getBytes());
numSubKeys = 5;
subKeys = stringMD5KeyCreator.createSubKeys(key, numSubKeys);
System.out.println(key);
for (int i = 0; i < subKeys.length; i++) {
System.out.printf("%d\t%s\n", i, subKeys[i]);
}
}
use of com.ms.silverking.cloud.dht.common.DHTKey in project SilverKing by Morgan-Stanley.
the class TreeMatcher method match.
public static MatchResult match(ChecksumNode n0, ChecksumNode n1) {
MatchResult result;
Iterator<KeyAndVersionChecksum> i0;
Iterator<KeyAndVersionChecksum> i1;
KeyAndVersionChecksum kvc0;
KeyAndVersionChecksum kvc1;
boolean advance0;
boolean advance1;
RingRegion.ensureIdentical(n0.getRegion(), n1.getRegion());
result = new MatchResult();
i0 = n0.iterator();
i1 = n1.iterator();
kvc0 = null;
kvc1 = null;
advance0 = true;
advance1 = true;
while (i0.hasNext() && i1.hasNext()) {
if (advance0) {
kvc0 = i0.next();
}
if (advance1) {
kvc1 = i1.next();
}
if (kvc0.equals(kvc1)) {
// match
advance0 = true;
advance1 = true;
} else {
DHTKey k0;
DHTKey k1;
int comparisonResult;
k0 = kvc0.getKey();
k1 = kvc1.getKey();
comparisonResult = UnsignedKeyComparator.instance.compare(k0, k1);
if (comparisonResult == 0) {
// keys match, version checksums must not
result.addChecksumMismatch(kvc0);
advance0 = true;
advance1 = true;
} else {
// keys don't match; somebody has an entry not present in the other
if (comparisonResult < 0) {
// local key not present in other
result.addSourceNotInDest(kvc0);
advance0 = true;
advance1 = false;
} else {
// > 0
// other key not present locally
result.addDestNotInSource(kvc1);
advance0 = false;
advance1 = true;
}
}
}
}
// Check for the case where one index is not at the end.
if (i0.hasNext()) {
while (i0.hasNext()) {
result.addSourceNotInDest(i0.next());
}
} else {
while (i1.hasNext()) {
result.addDestNotInSource(i1.next());
}
}
return result;
}
Aggregations