use of com.ms.silverking.cloud.dht.client.DHTClient in project SilverKing by Morgan-Stanley.
the class PerspectiveTest method test.
// @Test
public void test() {
try {
SynchronousNamespacePerspective<String, String> syncNSP = new DHTClient().openSession(Util.getTestGridConfig()).openSyncNamespacePerspective("_VersionTest", String.class, String.class);
syncNSP.setDefaultRetrievalVersionConstraint(VersionConstraint.defaultConstraint);
// syncNSP.setDefaultVersionProvider(syncNSP.getNamespace().getOptions().versionMode(NamespaceVersionMode.CLIENT_SPECIFIED).getVersionMode());
// syncNSP.set
printNsoAndNspo(syncNSP);
PutOptions po = syncNSP.getOptions().getDefaultPutOptions();
GetOptions go = syncNSP.getOptions().getDefaultGetOptions();
// syncNSP.setOptions( syncNSP.getOptions().defaultPutOptions( po ));
System.out.println("\n\n" + go);
syncNSP.getNamespace().getOptions().versionMode(NamespaceVersionMode.CLIENT_SPECIFIED).revisionMode(RevisionMode.UNRESTRICTED_REVISIONS);
printNsoAndNspo(syncNSP);
syncNSP.put("k", "v1", po.version(1));
// syncNSP.put("k", "v2", po.version(2));
System.out.println(syncNSP.get("k"));
// System.out.println( syncNSP.get("k", go));
// syncNSP.setOptions( syncNSP.getOptions().defaultPutOptions( new PutOptions(opTimeoutController, secondaryTargets, compression, checksumType, checksumCompressedValues, version, userData)));
//
// syncNSP.put(mapA);
} catch (Exception e) {
e.printStackTrace();
}
}
use of com.ms.silverking.cloud.dht.client.DHTClient in project SilverKing by Morgan-Stanley.
the class AsyncInvalidationExample method runExample.
public static String runExample(SKGridConfiguration gridConfig) {
try {
AsynchronousNamespacePerspective<String, String> asyncNSP;
AsyncInvalidation<String> asyncInvalidation;
AsyncPut<String> asyncPut;
AsyncSingleValueRetrieval<String, String> asyncGet;
DHTSession session;
Namespace ns;
session = new DHTClient().openSession(gridConfig);
ns = session.createNamespace("MyNamespace" + System.currentTimeMillis(), session.getDefaultNamespaceOptions().versionMode(NamespaceVersionMode.SYSTEM_TIME_NANOS));
System.out.printf("Using namespace %s\n", ns.getName());
asyncNSP = ns.openAsyncPerspective(String.class, String.class);
asyncPut = asyncNSP.put(key, value);
asyncPut.waitForCompletion();
asyncPut = asyncNSP.put(key, value);
asyncPut.waitForCompletion();
asyncGet = asyncNSP.get(key);
asyncGet.waitForCompletion();
System.out.printf("Before invalidation %s\n", asyncGet.getValue());
asyncInvalidation = asyncNSP.invalidate(key);
asyncInvalidation.waitForCompletion();
asyncGet = asyncNSP.get(key);
asyncGet.waitForCompletion();
System.out.printf("After invalidation %s\n", asyncGet.getValue());
return asyncGet.getValue();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
use of com.ms.silverking.cloud.dht.client.DHTClient in project SilverKing by Morgan-Stanley.
the class AsyncWaitForCompletion method runExample.
public static String runExample(SKGridConfiguration gridConfig) {
try {
AsynchronousNamespacePerspective<String, String> asyncNSP;
AsyncSingleValueRetrieval<String, String> asyncWaitFor;
asyncNSP = new DHTClient().openSession(gridConfig).openAsyncNamespacePerspective("_MyNamespace", String.class, String.class);
asyncWaitFor = asyncNSP.waitFor("key.1");
asyncNSP.put("key.1", "value.1");
System.out.println("Waiting for active ops");
asyncNSP.waitForActiveOps();
System.out.println("Wait complete");
return asyncWaitFor.getValue();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
use of com.ms.silverking.cloud.dht.client.DHTClient in project SilverKing by Morgan-Stanley.
the class HelloEmbeddedDHT method runExample.
public static String runExample() {
try {
SynchronousNamespacePerspective<String, String> syncNSP;
ClientDHTConfiguration dhtConfig;
System.out.println("Creating embedded SK instance");
dhtConfig = ClientDHTConfiguration.embeddedKVS;
System.out.println("Embedded SK instance running at: " + dhtConfig);
syncNSP = new DHTClient().openSession(dhtConfig).openSyncNamespacePerspective("_MyNamespace", String.class, String.class);
syncNSP.put("Hello", "world!");
return syncNSP.get("Hello");
} catch (Exception e) {
throw new RuntimeException(e);
}
}
use of com.ms.silverking.cloud.dht.client.DHTClient in project SilverKing by Morgan-Stanley.
the class HelloEmbeddedDHT2 method runExample.
public static String runExample() {
try {
SynchronousNamespacePerspective<String, String> syncNSP;
ClientDHTConfiguration dhtConfig;
System.out.println("Creating embedded SK instance");
dhtConfig = EmbeddedSK.createEmbeddedSKInstance();
System.out.println("Embedded SK instance running at: " + dhtConfig);
syncNSP = new DHTClient().openSession(dhtConfig).openSyncNamespacePerspective("_MyNamespace", String.class, String.class);
syncNSP.put("Hello", "world!");
return syncNSP.get("Hello");
} catch (Exception e) {
throw new RuntimeException(e);
}
}
Aggregations