Search in sources :

Example 1 with ConstantVersionProvider

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

the class PerspectiveTest method testDefaultsPuts.

@Test
public void testDefaultsPuts() throws ClientException, IOException {
    Namespace ns = session.createNamespace(namespaceName, session.getDefaultNamespaceOptions().versionMode(NamespaceVersionMode.CLIENT_SPECIFIED).revisionMode(RevisionMode.UNRESTRICTED_REVISIONS).defaultPutOptions(session.getDefaultPutOptions().version(5)));
    SynchronousNamespacePerspective<String, String> syncNsp = ns.openSyncPerspective(String.class, String.class);
    PutOptions putOptions = syncNsp.getOptions().getDefaultPutOptions();
    GetOptions getOptions = syncNsp.getOptions().getDefaultGetOptions();
    syncNsp.put("k", "v1");
    printKeyVals(syncNsp, "k", getOptions);
    syncNsp.put("k", "v2", putOptions.version(1));
    printKeyVals(syncNsp, "k", getOptions);
    syncNsp.put("k", "v3");
    printKeyVals(syncNsp, "k", getOptions);
    // this guy is not working as expected
    syncNsp.setDefaultVersion(4);
    syncNsp.put("k", "v4");
    printKeyVals(syncNsp, "k", getOptions);
    // this guy is not working as expected
    syncNsp.setDefaultVersionProvider(new ConstantVersionProvider(6));
    syncNsp.put("k", "v5");
    printKeyVals(syncNsp, "k", getOptions);
    syncNsp.put("k", "v6", putOptions.version(8));
    printKeyVals(syncNsp, "k", getOptions);
}
Also used : ConstantVersionProvider(com.ms.silverking.cloud.dht.client.ConstantVersionProvider) GetOptions(com.ms.silverking.cloud.dht.GetOptions) Namespace(com.ms.silverking.cloud.dht.client.Namespace) PutOptions(com.ms.silverking.cloud.dht.PutOptions) Test(org.junit.Test)

Aggregations

GetOptions (com.ms.silverking.cloud.dht.GetOptions)1 PutOptions (com.ms.silverking.cloud.dht.PutOptions)1 ConstantVersionProvider (com.ms.silverking.cloud.dht.client.ConstantVersionProvider)1 Namespace (com.ms.silverking.cloud.dht.client.Namespace)1 Test (org.junit.Test)1