use of com.ms.silverking.cloud.dht.client.DHTClient in project SilverKing by Morgan-Stanley.
the class HelloAsyncDHT method runExample.
public static String runExample(SKGridConfiguration gridConfig) {
try {
AsynchronousNamespacePerspective<String, String> asyncNSP;
AsyncPut<String> asyncPut;
AsyncSingleValueRetrieval<String, String> asyncGet;
asyncNSP = new DHTClient().openSession(gridConfig).openAsyncNamespacePerspective("_MyNamespace", String.class, String.class);
asyncPut = asyncNSP.put("Hello async", "async world!");
asyncPut.waitForCompletion();
asyncGet = asyncNSP.get("Hello async");
asyncGet.waitForCompletion();
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 HelloCallbackDHT method runExample.
public String runExample(SKGridConfiguration gridConfig) {
try {
AsynchronousNamespacePerspective<String, String> asyncNSP;
AsyncPut<String> asyncPut;
AsyncSingleValueRetrieval<String, String> asyncGet;
s = new Semaphore(0);
asyncNSP = new DHTClient().openSession(gridConfig).openAsyncNamespacePerspective("_MyNamespace" + System.currentTimeMillis(), String.class, String.class);
asyncPut = asyncNSP.put("Hello callback", "callback world!");
asyncPut.addListener(this, OperationState.SUCCEEDED, OperationState.FAILED, OperationState.INCOMPLETE);
s.acquire();
s.drainPermits();
asyncGet = asyncNSP.get("Hello callback");
asyncGet.addListener(this);
s.acquire();
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 HelloDHT method runExample.
public static String runExample(SKGridConfiguration gridConfig) {
try {
SynchronousNamespacePerspective<String, String> syncNSP;
syncNSP = new DHTClient().openSession(gridConfig).openSyncNamespacePerspective("_MyNamespace", String.class, String.class);
syncNSP.put("Hello", "world!");
return syncNSP.get("Hello");
} catch (Exception e) {
throw new RuntimeException(e);
}
}
Aggregations