Search in sources :

Example 1 with PutException

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);
    }
}
Also used : PutException(com.ms.silverking.cloud.dht.client.PutException) VersionConstraint(com.ms.silverking.cloud.dht.VersionConstraint)

Example 2 with PutException

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();
}
Also used : PutException(com.ms.silverking.cloud.dht.client.PutException) ImmutableMap(com.google.common.collect.ImmutableMap) PutOptions(com.ms.silverking.cloud.dht.PutOptions) VersionConstraint(com.ms.silverking.cloud.dht.VersionConstraint)

Example 3 with PutException

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();
}
Also used : PutException(com.ms.silverking.cloud.dht.client.PutException) ImmutableMap(com.google.common.collect.ImmutableMap) VersionConstraint(com.ms.silverking.cloud.dht.VersionConstraint)

Example 4 with PutException

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();
}
Also used : PutException(com.ms.silverking.cloud.dht.client.PutException) PutOptions(com.ms.silverking.cloud.dht.PutOptions) ImmutableMap(com.google.common.collect.ImmutableMap) VersionConstraint(com.ms.silverking.cloud.dht.VersionConstraint)

Example 5 with PutException

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();
}
Also used : PutException(com.ms.silverking.cloud.dht.client.PutException) PutOptions(com.ms.silverking.cloud.dht.PutOptions) VersionConstraint(com.ms.silverking.cloud.dht.VersionConstraint)

Aggregations

PutException (com.ms.silverking.cloud.dht.client.PutException)9 VersionConstraint (com.ms.silverking.cloud.dht.VersionConstraint)7 ImmutableMap (com.google.common.collect.ImmutableMap)3 PutOptions (com.ms.silverking.cloud.dht.PutOptions)3 ImmutableSet (com.google.common.collect.ImmutableSet)1 AsyncPut (com.ms.silverking.cloud.dht.client.AsyncPut)1 NamespaceCreationException (com.ms.silverking.cloud.dht.client.NamespaceCreationException)1 OperationException (com.ms.silverking.cloud.dht.client.OperationException)1 RetrievalException (com.ms.silverking.cloud.dht.client.RetrievalException)1 NamespaceNotCreatedException (com.ms.silverking.cloud.dht.daemon.storage.NamespaceNotCreatedException)1