use of com.ms.silverking.cloud.dht.client.PutException 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;
}
}
use of com.ms.silverking.cloud.dht.client.PutException in project SilverKing by Morgan-Stanley.
the class SilverKingClient method doInvalidation.
private void doInvalidation(String[] args) throws OperationException, IOException {
Set<String> set;
ImmutableSet.Builder<String> builder;
builder = ImmutableSet.builder();
for (int i = 0; i < args.length; i++) {
builder.add(translateKey(args[i]));
}
set = builder.build();
opMessage("Invalidating");
sw.reset();
try {
for (int i = 0; i < reps; i++) {
syncNSP.invalidate(set);
}
} 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 AsyncPingMultiPong method clientIteration.
public void clientIteration(String pingKey, String pongKeyBase, long version) throws OperationException {
Set<String> pongKeys;
AsyncRetrieval<String, byte[]> asyncRetrieval;
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 {
AsyncPut<String> put;
put = asyncNSP.put(pingKey, pingKey.getBytes(), defaultPutOptions.version(version));
put.waitForCompletion();
} catch (PutException pe) {
System.out.println("ignoring put exception");
}
if (verbose) {
System.out.println("WaitFor: " + pongKeyBase);
}
asyncRetrieval = asyncNSP.waitFor(pongKeys, asyncNSP.getOptions().getDefaultWaitOptions().versionConstraint(VersionConstraint.exactMatch(version)));
while (asyncRetrieval.getState() == OperationState.INCOMPLETE) {
asyncRetrieval.waitForCompletion(checkIntervalMS, TimeUnit.MILLISECONDS);
if (asyncRetrieval.getState() == OperationState.INCOMPLETE) {
Set<String> incompleteKeys;
incompleteKeys = asyncRetrieval.getIncompleteKeys();
System.out.println("IncompleteKeys: " + incompleteKeys.size());
for (String key : incompleteKeys) {
System.out.println(key);
}
System.out.println();
}
}
if (verbose) {
System.out.println("Received: " + pongKeyBase);
}
}
use of com.ms.silverking.cloud.dht.client.PutException in project SilverKing by Morgan-Stanley.
the class NamespaceOptionsClient method storeNamespaceProperties.
public void storeNamespaceProperties(long namespace, NamespaceProperties nsProperties) throws NamespaceCreationException {
boolean retry;
retry = false;
do {
NamespaceProperties existingProperties;
try {
existingProperties = getNamespaceProperties(namespace, seTimeoutController.getMaxRelativeTimeoutMillis(null));
} catch (TimeoutException te) {
Log.warning("Failed to store namespace due to timeout " + String.format("%x", namespace));
throw new NamespaceCreationException(Long.toHexString(namespace), te);
} catch (RetrievalException re) {
Log.warning(re.getDetailedFailureMessage());
throw new NamespaceCreationException("RetrievalException during first property check", re);
}
if (existingProperties != null) {
if (!existingProperties.equals(nsProperties)) {
Log.warning("existingProperties", existingProperties);
Log.warning("nsProperties", nsProperties);
throw new NamespaceCreationException("Namespace already created with incompatible properties");
} else {
// Already created with the same options. No further action required.
}
} else {
try {
if (debug) {
System.out.printf("storeNamespaceProperties(%x, %s)\n", namespace, nsProperties);
}
syncNSP.put(getOptionsKey(namespace), nsProperties.toString());
if (debug) {
System.out.println("Done storeNamespaceOptions");
}
} catch (PutException pe) {
// For other errors, we try this also on the
try {
boolean optionsMatch;
try {
optionsMatch = verifyNamespaceProperties(namespace, nsProperties);
if (!optionsMatch) {
throw new NamespaceCreationException("Namespace already created with incompatible properties");
}
} catch (NamespaceNotCreatedException nnce) {
// Should not be possible any more, but leave old retry in for now.
retry = true;
} catch (RuntimeException re) {
Log.logErrorWarning(re);
Log.warning(pe.getDetailedFailureMessage());
Log.logErrorWarning(pe, "Couldn't store options due to exception");
}
} catch (RetrievalException re) {
Log.warning("storeNamespaceProperties failing");
Log.warning("PutException");
pe.printStackTrace();
Log.warning("RetrievalException");
re.printStackTrace();
throw new NamespaceCreationException(re);
}
}
}
} while (retry);
}
Aggregations