use of com.ms.silverking.cloud.dht.PutOptions 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.PutOptions 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);
}
use of com.ms.silverking.cloud.dht.PutOptions in project SilverKing by Morgan-Stanley.
the class SilverKingClient method doPut.
private void doPut(String[] args) throws OperationException, IOException {
Map<String, byte[]> map;
ImmutableMap.Builder<String, byte[]> builder;
PutOptions putOptions;
if (args[0].startsWith("{")) {
if (!args[0].endsWith("}")) {
err.printf("putOptions missing closing }\n");
return;
} else {
String[] newArgs;
newArgs = new String[args.length - 1];
System.arraycopy(args, 1, newArgs, 0, newArgs.length);
putOptions = ((PutOptions) ObjectDefParser2.parse(PutOptions.class, args[0].substring(1, args[0].length() - 1)));
if (verbose) {
out.printf("putOptions: %s\n", putOptions);
}
args = newArgs;
}
} else {
putOptions = syncNSP.getNamespace().getOptions().getDefaultPutOptions();
}
builder = ImmutableMap.builder();
for (int i = 0; i < args.length; i += 2) {
builder.put(translateKey(args[i]), translateValue(args[i + 1]));
}
map = builder.build();
opMessage("Putting");
sw.reset();
try {
for (int i = 0; i < reps; i++) {
syncNSP.put(map, putOptions);
}
} catch (PutException pe) {
out.println(pe.getDetailedFailureMessage());
throw pe;
}
sw.stop();
}
use of com.ms.silverking.cloud.dht.PutOptions in project SilverKing by Morgan-Stanley.
the class ClientTool method doMultiPut.
private void doMultiPut(ClientOptions options, DHTSession session, SynchronousNamespacePerspective<String, byte[]> syncNSP, Stopwatch sw) throws OperationException, IOException {
PutOptions putOptions;
long version;
Map<String, byte[]> map;
ImmutableMap.Builder<String, byte[]> builder;
version = options.version;
builder = ImmutableMap.builder();
for (int i = 0; i < options.numKeys; i++) {
builder.put(options.key + "." + i, options.getValue());
}
map = builder.build();
putOptions = session.getDefaultPutOptions().compression(options.compression != null ? options.compression : Compression.NONE).checksumType(options.checksumType).version(version);
Log.warning("Putting value for version:", version);
sw.reset();
try {
for (int i = 0; i < options.reps; i++) {
syncNSP.put(map, putOptions);
}
} catch (PutException pe) {
System.out.println(pe.getDetailedFailureMessage());
throw pe;
}
sw.stop();
}
use of com.ms.silverking.cloud.dht.PutOptions in project SilverKing by Morgan-Stanley.
the class ClientTool method doPut.
private void doPut(ClientOptions options, DHTSession session, SynchronousNamespacePerspective<String, byte[]> syncNSP, Stopwatch sw) throws OperationException, IOException {
PutOptions putOptions;
long version;
byte[] value;
version = options.version;
putOptions = session.getDefaultPutOptions().compression(options.compression != null ? options.compression : Compression.NONE).checksumType(options.checksumType).version(version);
Log.warning("Putting value for version:", version);
value = options.getValue();
sw.reset();
try {
for (int i = 0; i < options.reps; i++) {
syncNSP.put(options.key, value);
// syncNSP.put(options.key, value, putOptions);
}
} catch (PutException pe) {
System.out.println(pe.getDetailedFailureMessage());
throw pe;
}
sw.stop();
}
Aggregations