use of org.voltdb.client.ClientResponse in project voltdb by VoltDB.
the class MatchChecks method checkRowMismatch.
protected static long checkRowMismatch(Client client) {
// check if any rows failed column by colunn comparison so we can fail fast
ClientResponse response = doAdHoc(client, "select key from importcounts where value_mismatch = 1 limit 1;");
VoltTable[] result = response.getResults();
if (// || result[0].asScalarLong() == 0)
result[0].getRowCount() == 0)
return 0;
return result[0].asScalarLong();
}
use of org.voltdb.client.ClientResponse in project voltdb by VoltDB.
the class AsyncBenchmark method runNoArgs.
public static void runNoArgs(boolean readOnly) throws Exception {
Random r = new java.util.Random();
// Run the benchmark loop for the requested duration
long endTime = System.currentTimeMillis() + (1000l * duration);
while (endTime > System.currentTimeMillis() && !stopTheMadness) {
Con.executeAsync(new org.voltdb.client.ProcedureCallback() {
public void clientCallback(ClientResponse clientResponse) throws Exception {
if (clientResponse.getStatus() != ClientResponse.SUCCESS) {
System.out.println(clientResponse.getStatusString());
System.exit(-1);
}
}
}, readOnly ? "NoArgs" : "NoArgsRW", r.nextLong(), resultSize);
// Use the limiter to throttle client activity
limiter.throttle();
}
}
use of org.voltdb.client.ClientResponse in project voltdb by VoltDB.
the class ScanBenchmark method runBenchmark.
/**
* Core benchmark code.
* Connect. Initialize. Run the loop. Cleanup. Print Results.
*
* @throws Exception if anything unexpected happens.
*/
public void runBenchmark() throws Exception {
System.out.print(HORIZONTAL_RULE);
System.out.println(" Setup & Initialization");
System.out.println(HORIZONTAL_RULE);
// connect to one or more servers, loop until success
connect(config.servers);
System.out.print(HORIZONTAL_RULE);
System.out.println("Loading Tuples");
System.out.println(HORIZONTAL_RULE);
String loadproc = null;
String tablename = null;
String scanproc = null;
if (config.test.equals("sequential")) {
loadproc = "NARROW_P.insert";
tablename = "narrow_p";
scanproc = "MinSeqScan";
} else if (config.test.equals("index")) {
loadproc = "NARROW_INDEX_P.insert";
tablename = "narrow_index_p";
scanproc = "MinIndexScan";
}
for (long i = 0; i < config.rows; i++) {
client.callProcedure(new NullCallback(), loadproc, i % 509, /* radom prime */
i);
if ((i % 100000) == 0) {
System.out.printf("Loading row at index %d.\n", i);
}
}
client.drain();
ClientResponse cr = client.callProcedure("@AdHoc", "select count(*) from " + tablename + ";");
long rows = cr.getResults()[0].asScalarLong();
System.out.printf("Loaded %d rows.\n", rows);
assert (rows == config.rows);
System.out.print(HORIZONTAL_RULE);
System.out.println("Starting Benchmark");
System.out.println(HORIZONTAL_RULE);
// reset the stats after warmup
fullStatsContext.fetchAndResetBaseline();
periodicStatsContext.fetchAndResetBaseline();
benchmarkStartTS = System.currentTimeMillis();
System.out.printf("\nRunning %s scan benchmark...\n", config.test);
for (int i = 0; i < config.runs; i++) {
client.callProcedure(scanproc);
}
benchmarkEndTS = System.currentTimeMillis();
// print the summary results
printResults();
// close down the client connections
client.close();
}
use of org.voltdb.client.ClientResponse in project voltdb by VoltDB.
the class SchemaChangeUtility method maxId.
/**
* Find the largest pkey value in the table.
*/
static long maxId(Client client, VoltTable t, int timeout) {
if (t == null) {
return 0;
}
ClientResponse cr = callROProcedureWithRetry(client, "@AdHoc", timeout, String.format("select pkey from %s order by pkey desc limit 1;", TableHelper.getTableName(t)));
assert (cr.getStatus() == ClientResponse.SUCCESS);
VoltTable result = cr.getResults()[0];
return result.getRowCount() > 0 ? result.asScalarLong() : 0;
}
use of org.voltdb.client.ClientResponse in project voltdb by VoltDB.
the class SchemaChangeUtility method callROProcedureWithRetry.
/**
* Call a procedure and check the return code.
* Success just returns the result to the caller.
* Unpossible errors end the process.
* Some errors will retry the call until the global progress timeout with various waits.
* After the global progress timeout, the process is killed.
*/
static ClientResponse callROProcedureWithRetry(Client client, String procName, int timeout, Object... params) {
long startTime = System.currentTimeMillis();
long now = startTime;
int retry = 0;
while (now - startTime < (timeout * 1000)) {
ClientResponse cr = null;
try {
cr = client.callProcedure(procName, params);
} catch (ProcCallException e) {
log.debug("callROProcedureWithRetry operation exception:", e);
cr = e.getClientResponse();
} catch (NoConnectionsException e) {
log.debug("callROProcedureWithRetry operation exception:", e);
// wait a bit to retry
try {
Thread.sleep(1000);
} catch (InterruptedException e1) {
}
} catch (IOException e) {
log.debug("callROProcedureWithRetry operation exception:", e);
// IOException is not cool man
logStackTrace(e);
System.exit(-1);
}
if (cr != null) {
if (cr.getStatus() != ClientResponse.SUCCESS) {
log.debug("callROProcedureWithRetry operation failed: " + ((ClientResponseImpl) cr).toJSONString());
}
switch(cr.getStatus()) {
case ClientResponse.SUCCESS:
// hooray!
return cr;
case ClientResponse.CONNECTION_LOST:
case ClientResponse.CONNECTION_TIMEOUT:
// can retry after a delay
try {
Thread.sleep(5 * 1000);
} catch (Exception e) {
}
break;
case ClientResponse.RESPONSE_UNKNOWN:
// can try again immediately - cluster is up but a node died
break;
case ClientResponse.SERVER_UNAVAILABLE:
// shouldn't be in admin mode (paused) in this app, but can retry after a delay
try {
Thread.sleep(30 * 1000);
} catch (Exception e) {
}
break;
case ClientResponse.GRACEFUL_FAILURE:
//logStackTrace(new Throwable());
return // caller should always check return status
cr;
case ClientResponse.UNEXPECTED_FAILURE:
case ClientResponse.USER_ABORT:
// for starters, I'm assuming these errors can't happen for reads in a sound system
String ss = cr.getStatusString();
if (ss.contains("Statement: select count(*) from")) {
// We might need to retry
log.warn(ss);
if ((ss.matches("(?s).*AdHoc transaction [0-9]+ wasn.t planned against the current catalog version.*") || ss.matches("(?s).*Invalid catalog update. Catalog or deployment change was planned against one version of the cluster configuration but that version was no longer live.*"))) {
log.info("retrying...");
} else {
log.error(String.format("Error in procedure call for: %s", procName));
log.error(((ClientResponseImpl) cr).toJSONString());
assert (false);
System.exit(-1);
}
}
}
}
now = System.currentTimeMillis();
}
log.error(String.format("Error no progress timeout (%d seconds) reached, terminating", timeout));
System.exit(-1);
return null;
}
Aggregations