use of com.ms.silverking.cloud.dht.client.PutException in project SilverKing by Morgan-Stanley.
the class PingMultiPong method clientIteration.
public void clientIteration(String pingKey, String pongKeyBase, long version) throws PutException, RetrievalException {
Set<String> pongKeys;
pongKeys = new HashSet<>(numServers);
for (int i = 0; i < numServers; i++) {
for (int j = 0; j < threadsPerServer; j++) {
pongKeys.add(pongKeyBase + "." + i + "." + j);
}
}
if (verbose) {
System.out.println("Put: " + pingKey);
}
if (delayMS != 0) {
if (verbose) {
System.out.print("Sleeping...");
}
ThreadUtil.sleep(delayMS);
if (verbose) {
System.out.println("Awake.");
}
}
try {
syncNSP.put(pingKey, pingKey.getBytes(), defaultPutOptions.version(version));
} catch (PutException pe) {
System.out.println("ignoring put exception");
}
if (verbose) {
System.out.println("WaitFor: " + pongKeyBase);
}
syncNSP.waitFor(pongKeys, syncNSP.getOptions().getDefaultWaitOptions().versionConstraint(VersionConstraint.exactMatch(version)));
if (verbose) {
System.out.println("Received: " + pongKeyBase);
}
}
use of com.ms.silverking.cloud.dht.client.PutException 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.client.PutException in project SilverKing by Morgan-Stanley.
the class SilverKingClient method doPutRandom.
private void doPutRandom(String[] args) throws OperationException, IOException {
Map<String, byte[]> map;
ImmutableMap.Builder<String, byte[]> builder;
builder = ImmutableMap.builder();
for (int i = 0; i < args.length; i += 2) {
builder.put(translateKey(args[i]), translateRandomValue(args[i + 1]));
}
map = builder.build();
opMessage("Putting");
sw.reset();
try {
for (int i = 0; i < reps; i++) {
syncNSP.put(map);
}
} catch (PutException pe) {
out.println(pe.getDetailedFailureMessage());
throw pe;
}
sw.stop();
}
use of com.ms.silverking.cloud.dht.client.PutException 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.client.PutException 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