Search in sources :

Example 1 with NamespaceVersionMode

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

the class NamespaceVersionModeTest method testIsSystemSpecified.

@Test
public void testIsSystemSpecified() {
    Object[][] testCases = { { SINGLE_VERSION, false }, { CLIENT_SPECIFIED, false }, { SEQUENTIAL, true }, { SYSTEM_TIME_MILLIS, true }, { SYSTEM_TIME_NANOS, true } };
    for (Object[] testCase : testCases) {
        NamespaceVersionMode mode = (NamespaceVersionMode) testCase[0];
        boolean expected = (boolean) testCase[1];
        assertEquals(expected, mode.isSystemSpecified());
    }
}
Also used : NamespaceVersionMode(com.ms.silverking.cloud.dht.NamespaceVersionMode) Test(org.junit.Test)

Example 2 with NamespaceVersionMode

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

the class NamespaceStore method put.

public void put(List<StorageValueAndParameters> values, byte[] userData, KeyedOpResultListener resultListener) {
    Set<Waiter> triggeredWaitFors;
    NamespaceVersionMode nsVersionMode;
    boolean locked;
    triggeredWaitFors = null;
    nsVersionMode = nsOptions.getVersionMode();
    // LWTThreadUtil.setBlocked();
    writeLock.lock();
    try {
        // System.out.printf("NamespaceStore.put() group size: %d\n", values.size());
        for (StorageValueAndParameters value : values) {
            OpResult storageResult;
            if (putTrigger != null) {
                storageResult = putTrigger.put(this, value.getKey(), value.getValue(), new SSStorageParametersImpl(value, value.getValue().remaining()), userData, nsVersionMode);
            } else {
                storageResult = _put(value.getKey(), value.getValue(), value, userData, nsVersionMode);
            }
            // if (storageResult != OpResult.SUCCEEDED) Log.warningf("fail _put %s %s %d", KeyUtil.keyToString(value.getKey()), storageResult, value.getVersion()); // for debugging
            resultListener.sendResult(value.getKey(), storageResult);
            if (storageResult == OpResult.SUCCEEDED) {
                Set<Waiter> _triggeredWaitFors;
                _triggeredWaitFors = checkPendingWaitFors(value.getKey());
                if (_triggeredWaitFors != null) {
                    if (triggeredWaitFors == null) {
                        triggeredWaitFors = new HashSet<>();
                    }
                    triggeredWaitFors.addAll(_triggeredWaitFors);
                }
            }
        }
    } finally {
        writeLock.unlock();
    // LWTThreadUtil.setNonBlocked();
    }
    if (triggeredWaitFors != null) {
        handleTriggeredWaitFors(triggeredWaitFors);
    }
}
Also used : OpResult(com.ms.silverking.cloud.dht.common.OpResult) NamespaceVersionMode(com.ms.silverking.cloud.dht.NamespaceVersionMode) Waiter(com.ms.silverking.cloud.dht.daemon.Waiter)

Aggregations

NamespaceVersionMode (com.ms.silverking.cloud.dht.NamespaceVersionMode)2 OpResult (com.ms.silverking.cloud.dht.common.OpResult)1 Waiter (com.ms.silverking.cloud.dht.daemon.Waiter)1 Test (org.junit.Test)1