Search in sources :

Example 6 with RawRetrievalResult

use of com.ms.silverking.cloud.dht.common.RawRetrievalResult 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)

Aggregations

RawRetrievalResult (com.ms.silverking.cloud.dht.common.RawRetrievalResult)6 ByteBuffer (java.nio.ByteBuffer)4 CorruptValueException (com.ms.silverking.cloud.dht.common.CorruptValueException)3 VersionConstraint (com.ms.silverking.cloud.dht.VersionConstraint)1 DHTKey (com.ms.silverking.cloud.dht.common.DHTKey)1 OpResult (com.ms.silverking.cloud.dht.common.OpResult)1 StorageValueAndParameters (com.ms.silverking.cloud.dht.daemon.storage.StorageValueAndParameters)1