Search in sources :

Example 1 with AsyncPut

use of com.ms.silverking.cloud.dht.client.AsyncPut in project SilverKing by Morgan-Stanley.

the class GroupingSilverkingDB method insert.

@Override
public int insert(String table, String key, HashMap<String, ByteIterator> values) {
    try {
        // }
        if (System.currentTimeMillis() == 0) {
            syncNSP.put(key, values);
        }
        /**/
        {
            AsyncPut asyncPut;
            // System.out.println("Waiting for: "+ key);
            asyncPut = asyncNSP.put(key, values);
            try {
                asyncPut.waitForCompletion(30, TimeUnit.SECONDS);
                if (asyncPut.getState() == OperationState.INCOMPLETE) {
                    System.out.println("Incomplete: " + key);
                    System.out.flush();
                    System.exit(-1);
                }
            } catch (OperationException e) {
                PutException pe;
                pe = (PutException) e;
                if (pe.getFailureCause(key) == FailureCause.INVALID_VERSION) {
                    System.out.println("Ignoring INVALID_VERSION");
                    System.err.println("Ignoring INVALID_VERSION");
                    return 1;
                } else {
                    throw new RuntimeException(pe);
                }
            }
        }
        // System.out.println("Done waiting for: "+ key);
        return 0;
    } catch (PutException pe) {
        System.out.println("Key failed: " + key);
        return 1;
    }
}
Also used : PutException(com.ms.silverking.cloud.dht.client.PutException) AsyncPut(com.ms.silverking.cloud.dht.client.AsyncPut) OperationException(com.ms.silverking.cloud.dht.client.OperationException)

Aggregations

AsyncPut (com.ms.silverking.cloud.dht.client.AsyncPut)1 OperationException (com.ms.silverking.cloud.dht.client.OperationException)1 PutException (com.ms.silverking.cloud.dht.client.PutException)1