use of com.ms.silverking.cloud.dht.daemon.storage.StorageValueAndParameters in project SilverKing by Morgan-Stanley.
the class ConvergenceController2 method incomingSyncRetrievalResponse.
// Currently unused
private void incomingSyncRetrievalResponse(MessageGroupRetrievalResponseEntry entry) {
try {
RawRetrievalResult rawRetrievalResult;
if (entry.getValue() == null) {
Log.warning("Couldn't find value for: ", entry);
return;
} else {
if (debug) {
System.out.printf("Found %s\n", entry);
}
}
rawRetrievalResult = new RawRetrievalResult(RetrievalType.VALUE_AND_META_DATA);
rawRetrievalResult.setStoredValue(entry.getValue(), true, false, null);
StorageValueAndParameters valueAndParameters;
ByteBuffer rawValueBuffer;
ByteBuffer valueBuffer;
// valueBuffer = (ByteBuffer)entry.getValue().duplicate().limit(rawRetrievalResult.getStoredLength());
rawValueBuffer = entry.getValue();
if (debug && true) {
System.out.printf("key %s buf %s storedLength %d uncompressedLength %d compressedLength %d\n", entry, rawValueBuffer, rawRetrievalResult.getStoredLength(), rawRetrievalResult.getUncompressedLength(), MetaDataUtil.getCompressedLength(rawValueBuffer, 0));
System.out.printf("rawValueBuffer %s\n", StringUtil.byteBufferToHexString(rawValueBuffer));
}
valueBuffer = (ByteBuffer) rawValueBuffer.duplicate().position(rawValueBuffer.position() + MetaDataUtil.getDataOffset(rawValueBuffer, 0));
// FUTURE - consider making the nsstore allow a put that just accepts the buffer as is
// to improve performance
valueAndParameters = new StorageValueAndParameters(entry, valueBuffer, rawRetrievalResult.getVersion(), rawRetrievalResult.getUncompressedLength(), MetaDataUtil.getCompressedLength(rawValueBuffer, 0), rawRetrievalResult.getCCSS(), rawRetrievalResult.getChecksum(), rawRetrievalResult.getCreator().getBytes(), rawRetrievalResult.getCreationTimeRaw());
nsStore.put(ImmutableList.of(valueAndParameters), emptyUserData, this);
// FUTURE - preserve user data
} catch (CorruptValueException cve) {
Log.logErrorWarning(cve);
// FUTURE - let this replica know that it's bad
}
}
use of com.ms.silverking.cloud.dht.daemon.storage.StorageValueAndParameters in project SilverKing by Morgan-Stanley.
the class ConvergenceController2 method incomingSyncRetrievalResponse.
// ////////////////////////////////////////////////////////////////////
// Handle incoming convergence data
public void incomingSyncRetrievalResponse(MessageGroup message) {
List<StorageValueAndParameters> svpList;
SyncRetrievalRequest srr;
srr = outstandingSyncRetrievalRequests.get(message.getUUID());
outstandingMessages.decrementAndGet();
if (outstandingMessages.get() < 0) {
outstandingMessages.set(0);
}
if (debug) {
Log.warningAsyncf("incomingSyncRetrievalResponse");
}
svpList = new ArrayList<>();
for (MessageGroupRetrievalResponseEntry entry : message.getRetrievalResponseValueKeyIterator()) {
StorageValueAndParameters svp;
if (srr != null) {
srr.outstandingKeys.remove(entry);
}
svp = StorageValueAndParameters.createSVP(entry);
if (svp != null) {
svpList.add(svp);
}
}
if (!svpList.isEmpty()) {
// FUTURE - support migration of user data
nsStore.put(svpList, emptyUserData, this);
}
if (srr != null && srr.outstandingKeys.isEmpty()) {
outstandingSyncRetrievalRequests.remove(message.getUUID());
}
checkQueuedChecksumTreeRequests();
checkMGQueue();
checkForCompletion();
}
use of com.ms.silverking.cloud.dht.daemon.storage.StorageValueAndParameters in project SilverKing by Morgan-Stanley.
the class ActiveRegionSync method incomingSyncRetrievalResponse.
// //////////////////////////////////////////////////////////////////
public void incomingSyncRetrievalResponse(MessageGroup message) {
List<StorageValueAndParameters> svpList;
SyncRetrievalRequest srr;
lastUpdateMillis = SystemTimeSource.instance.absTimeMillis();
srr = outstandingSyncRetrievalRequests.get(message.getUUID());
if (debug) {
Log.warning("incomingSyncRetrievalResponse");
}
svpList = new ArrayList<>();
for (MessageGroupRetrievalResponseEntry entry : message.getRetrievalResponseValueKeyIterator()) {
StorageValueAndParameters svp;
if (debug) {
Log.warningf("%s", entry.toString());
}
if (srr != null) {
srr.outstandingKeys.remove(entry);
}
svp = StorageValueAndParameters.createSVP(entry);
if (svp != null) {
svpList.add(svp);
}
}
if (!svpList.isEmpty()) {
if (nsStore != null) {
// FUTURE - support migration of user data
nsStore.put(svpList, emptyUserData, this);
}
}
if (srr != null && srr.outstandingKeys.isEmpty()) {
Log.warningAsyncf("ars %s complete-srr %s", uuid, srr.getUUID());
outstandingSyncRetrievalRequests.remove(srr.getUUID());
inprocessSyncRetrievalRequests.remove(srr.getUUID());
}
// checkMGQueue();
checkForCompletion();
}
use of com.ms.silverking.cloud.dht.daemon.storage.StorageValueAndParameters in project SilverKing by Morgan-Stanley.
the class ActiveProxyPut method localOp.
protected void localOp(List<? extends DHTKey> _entries, OpCommunicator<MessageGroupKeyEntry, PutResult> comm) {
boolean useUpdate;
PutCommunicator pComm;
pComm = (PutCommunicator) comm;
useUpdate = _entries.size() > 0 && (_entries.get(0) instanceof MessageGroupKeyOrdinalEntry);
if (!useUpdate) {
List<StorageValueAndParameters> values;
long creationTime;
creationTime = SystemTimeUtil.systemTimeSource.absTimeNanos();
values = new ArrayList<>(_entries.size());
for (DHTKey _entry : _entries) {
values.add(new StorageValueAndParameters((MessageGroupPutEntry) _entry, (PutOperationContainer) this, creationTime));
if (debug) {
System.out.printf("localOp: %s\n", _entry);
}
// Log.fine(entry);
}
getStorage().put(getContext(), values, getUserData(), pComm);
if (forwardingMode.forwards()) {
for (DHTKey _entry : _entries) {
storageOperation.localUpdate(_entry, StorageProtocolUtil.initialStorageStateOrdinal, OpResult.SUCCEEDED, pComm);
}
}
} else {
localOp_putupdate(_entries, pComm);
}
}
Aggregations