use of org.voltdb.client.ClientResponse in project voltdb by VoltDB.
the class TestMPMultiRoundTripSuite method testMultiRoundRead.
public void testMultiRoundRead() throws Exception {
final Client client = this.getClient();
loadData(client);
ClientResponse resp = client.callProcedure("MultiRoundP1Count", 10);
assertTrue("Successful multi-roundtrip read.", resp.getStatus() == ClientResponse.SUCCESS);
assertEquals("Expect count=100", 100L, resp.getResults()[0].asScalarLong());
}
use of org.voltdb.client.ClientResponse in project voltdb by VoltDB.
the class TestMPMultiRoundTripSuite method loadData.
void loadData(String procname, Client client) throws IOException, ProcCallException {
// inserts
for (int i = 0; i < 10; i++) {
ClientResponse resp = client.callProcedure(procname, i, i, i, Integer.toHexString(i));
assertTrue(resp.getStatus() == ClientResponse.SUCCESS);
assertTrue(resp.getResults()[0].asScalarLong() == 1);
}
}
use of org.voltdb.client.ClientResponse in project voltdb by VoltDB.
the class TestMPMultiRoundTripSuite method testMultiRoundtripMixReadsAndWrites.
public void testMultiRoundtripMixReadsAndWrites() throws Exception {
final Client client = this.getClient();
// Make the die setting > than the # of batches to avoid death
ClientResponse resp = client.callProcedure("MultiRoundMixReadsAndWrites", 10, 20);
assertTrue("Successful multi-roundtrip read/write.", resp.getStatus() == ClientResponse.SUCCESS);
assertEquals("Expect count=55", 55L, resp.getResults()[0].asScalarLong());
}
use of org.voltdb.client.ClientResponse in project voltdb by VoltDB.
the class TestMPMultiRoundTripSuite method testMultiRoundTripMixReadsWritesConstraintViolation.
public void testMultiRoundTripMixReadsWritesConstraintViolation() throws Exception {
final Client client = this.getClient();
boolean caught = false;
try {
client.callProcedure("MultiRoundMixReadsAndWrites", 10, 6);
assertFalse("Failed to produce constraint violation", true);
} catch (ProcCallException e) {
assertEquals("Client response is rollback.", ClientResponse.GRACEFUL_FAILURE, e.getClientResponse().getStatus());
caught = true;
}
assertTrue("Expected exception.", caught);
// Entire proc should have been rolled back
ClientResponse resp = client.callProcedure("CountP1");
assertEquals("Expected count=0", 0L, resp.getResults()[0].asScalarLong());
}
use of org.voltdb.client.ClientResponse in project voltdb by VoltDB.
the class Reporter method run.
@Override
public void run() {
boolean success = true;
Map<Integer, Long> averagesForWindows = new TreeMap<Integer, Long>();
// See ddl.sql for the actual SQL being run by the 'Average' procedure.
for (int seconds : new int[] { 1, 5, 10, 30 }) {
try {
// SQL BEING RUN:
// SELECT SUM(sum_values) / SUM(count_values)
// FROM agg_by_second
// WHERE second_ts >= TO_TIMESTAMP(SECOND, SINCE_EPOCH(SECOND, NOW) - ?);
ClientResponse cr = app.client.callProcedure("Average", -seconds);
VoltTable result = cr.getResults()[0];
long average = result.asScalarLong();
if (!result.wasNull()) {
averagesForWindows.put(seconds, average);
} else {
// If there are no rows in the selected time window (for example
// if we stop the client and then start it up again), then the
// average will be NULL.
averagesForWindows.put(seconds, null);
}
} catch (IOException | ProcCallException e) {
// Note any failure for reporting later.
success = false;
}
}
// this report printing.
synchronized (app) {
long now = System.currentTimeMillis();
long time = Math.round((now - app.startTS) / 1000.0);
// Print out how long the processing has been running
System.out.printf("%02d:%02d:%02d Report:\n", time / 3600, (time / 60) % 60, time % 60);
// If possible, print out the averages over several time windows.
if (success) {
System.out.println(" Average values over time windows:");
for (Entry<Integer, Long> e : averagesForWindows.entrySet()) {
System.out.printf(" Average for past %2ds: %d\n", e.getKey(), e.getValue());
}
} else {
System.out.println(" Unable to retrieve average values at this time.");
}
System.out.println(" Partition statistics:");
for (Entry<Long, PartitionInfo> e : app.getPartitionData().entrySet()) {
PartitionInfo pinfo = e.getValue();
System.out.printf(" Partition %2d: %9d tuples, youngest: %6.3fs, oldest: %6.3fs\n", e.getKey(), pinfo.tupleCount, pinfo.youngestTupleAge / 1000.0, pinfo.oldestTupleAge / 1000.0);
}
// Let the inserter process print a one line report.
app.inserter.printReport();
//
// FAILURE REPORTING FOR PERIODIC OPERATIONS
//
long partitionTrackerFailures = app.partitionTracker.failureCount.getAndSet(0);
if (partitionTrackerFailures > 0) {
System.out.printf(" Partition Tracker failed %d times since last report.\n", partitionTrackerFailures);
}
long maxTrackerFailures = app.maxTracker.failureCount.getAndSet(0);
if (maxTrackerFailures > 0) {
System.out.printf(" Max Tracker failed %d times since last report.\n", maxTrackerFailures);
}
System.out.println();
System.out.flush();
}
}
Aggregations