Search in sources :

Example 1 with KeyAndInteger

use of com.ms.silverking.cloud.dht.common.KeyAndInteger in project SilverKing by Morgan-Stanley.

the class NamespaceStore method retrieve_nongroupedImpl.

public List<ByteBuffer> retrieve_nongroupedImpl(List<? extends DHTKey> keys, InternalRetrievalOptions options, UUIDBase opUUID) {
    List<ByteBuffer> results;
    KeyAndInteger[] _keys;
    if (debugVersion) {
        System.out.printf("retrieve internal options: %s\n", options);
    }
    results = new ArrayList<>(keys.size());
    for (DHTKey key : keys) {
        // for (KeyAndInteger key : _keys) {
        ByteBuffer result;
        /*
                if (bufferGroup != null) {
                    result = bufferGroup[j];
                } else {
                    result = null;
                }
                */
        if (retrieveTrigger != null) {
            result = retrieveTrigger.retrieve(this, key, options);
        } else {
            result = _retrieve(key, options);
        }
        if (parent != null) {
            VersionConstraint vc;
            if (debugParent) {
                Log.warning("parent != null");
            }
            vc = options.getVersionConstraint();
            if (result == null) {
                if (debugParent) {
                    Log.warningf("%x null result. Checking parent %x.", ns, parent.getNamespace());
                }
                // If result from this ns is null, look in the parent.
                result = parent._retrieve(key, makeOptionsForNestedRetrieve(options));
                if (debugParent) {
                    if (result != null) {
                        Log.warning("Found result in parent");
                    }
                }
            } else {
                // Otherwise for the LEAST case, look in the parent to see if it has a better result.
                if (vc.getMode() == VersionConstraint.Mode.LEAST) {
                    ByteBuffer parentResult;
                    if (debugParent) {
                        Log.warning("Non-null result, but mode LEAST. checking parent");
                    }
                    parentResult = parent._retrieve(key, makeOptionsForNestedRetrieve(options));
                    if (parentResult != null) {
                        // if the parent had any valid result, then - by virtue of the fact
                        // that all parent versions are < child versions - the parent
                        // result is preferred
                        result = parentResult;
                        if (result != null) {
                            Log.warning("Found result in parent");
                        }
                    }
                }
            }
        }
        if (result == null && options.getWaitMode() == WaitMode.WAIT_FOR && options.getVersionConstraint().getMax() > curSnapshot) {
            // Note that since we hold the readLock, a write cannot come
            // in while we add the pending wait for.
            addPendingWaitFor(key, options.getRetrievalOptions(), opUUID);
        }
        if (options.getVerifyIntegrity()) {
            result = verifyIntegrity(key, result);
        }
        results.add(result);
    }
    // }
    return results;
}
Also used : VersionConstraint(com.ms.silverking.cloud.dht.VersionConstraint) KeyAndInteger(com.ms.silverking.cloud.dht.common.KeyAndInteger) DHTKey(com.ms.silverking.cloud.dht.common.DHTKey) ByteBuffer(java.nio.ByteBuffer)

Aggregations

VersionConstraint (com.ms.silverking.cloud.dht.VersionConstraint)1 DHTKey (com.ms.silverking.cloud.dht.common.DHTKey)1 KeyAndInteger (com.ms.silverking.cloud.dht.common.KeyAndInteger)1 ByteBuffer (java.nio.ByteBuffer)1