Search in sources :

Example 1 with StorageValueAndParameters

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
    }
}
Also used : RawRetrievalResult(com.ms.silverking.cloud.dht.common.RawRetrievalResult) StorageValueAndParameters(com.ms.silverking.cloud.dht.daemon.storage.StorageValueAndParameters) ByteBuffer(java.nio.ByteBuffer) CorruptValueException(com.ms.silverking.cloud.dht.common.CorruptValueException)

Example 2 with StorageValueAndParameters

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();
}
Also used : StorageValueAndParameters(com.ms.silverking.cloud.dht.daemon.storage.StorageValueAndParameters) MessageGroupRetrievalResponseEntry(com.ms.silverking.cloud.dht.net.MessageGroupRetrievalResponseEntry)

Example 3 with StorageValueAndParameters

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();
}
Also used : StorageValueAndParameters(com.ms.silverking.cloud.dht.daemon.storage.StorageValueAndParameters) MessageGroupRetrievalResponseEntry(com.ms.silverking.cloud.dht.net.MessageGroupRetrievalResponseEntry)

Example 4 with StorageValueAndParameters

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);
    }
}
Also used : MessageGroupKeyOrdinalEntry(com.ms.silverking.cloud.dht.net.MessageGroupKeyOrdinalEntry) PutCommunicator(com.ms.silverking.cloud.dht.daemon.storage.protocol.PutCommunicator) DHTKey(com.ms.silverking.cloud.dht.common.DHTKey) PutOperationContainer(com.ms.silverking.cloud.dht.daemon.storage.protocol.PutOperationContainer) StorageValueAndParameters(com.ms.silverking.cloud.dht.daemon.storage.StorageValueAndParameters) MessageGroupPutEntry(com.ms.silverking.cloud.dht.net.MessageGroupPutEntry)

Aggregations

StorageValueAndParameters (com.ms.silverking.cloud.dht.daemon.storage.StorageValueAndParameters)4 MessageGroupRetrievalResponseEntry (com.ms.silverking.cloud.dht.net.MessageGroupRetrievalResponseEntry)2 CorruptValueException (com.ms.silverking.cloud.dht.common.CorruptValueException)1 DHTKey (com.ms.silverking.cloud.dht.common.DHTKey)1 RawRetrievalResult (com.ms.silverking.cloud.dht.common.RawRetrievalResult)1 PutCommunicator (com.ms.silverking.cloud.dht.daemon.storage.protocol.PutCommunicator)1 PutOperationContainer (com.ms.silverking.cloud.dht.daemon.storage.protocol.PutOperationContainer)1 MessageGroupKeyOrdinalEntry (com.ms.silverking.cloud.dht.net.MessageGroupKeyOrdinalEntry)1 MessageGroupPutEntry (com.ms.silverking.cloud.dht.net.MessageGroupPutEntry)1 ByteBuffer (java.nio.ByteBuffer)1