use of org.voltdb.client.ProcCallException in project voltdb by VoltDB.
the class TestLoadingSuite method testSinglePartitionLoad.
public void testSinglePartitionLoad() throws Exception {
Client client = getClient();
VoltTable table;
ClientResponse r;
// test simple success
table = m_template.clone(100);
table.addRow(1, 1, 1, "1", 1.0);
table.addRow(2, 1, 2, "2", 2.0);
r = client.callProcedure("@LoadSinglepartitionTable", VoltType.valueToBytes(1), "PARTITIONED", upsertMode, table);
assertEquals(ClientResponse.SUCCESS, r.getStatus());
assertEquals(1, r.getResults().length);
assertEquals(2, r.getResults()[0].asScalarLong());
assertEquals(2, countPartitionedRows(client));
// test failure to load replicated table from SP proc
try {
r = client.callProcedure("@LoadSinglepartitionTable", VoltType.valueToBytes(1), "REPLICATED", upsertMode, table);
// prev stmt should throw exception
fail();
} catch (ProcCallException e) {
e.printStackTrace();
}
assertEquals(0, countReplicatedRows(client));
// test rollback for constraint
table = m_template.clone(100);
table.addRow(3, 2, 3, "3", 3.0);
table.addRow(3, 2, 3, "3", 3.0);
try {
r = client.callProcedure("@LoadSinglepartitionTable", VoltType.valueToBytes(2), "PARTITIONED", upsertMode, table);
// prev stmt should throw exception
fail();
} catch (ProcCallException e) {
e.printStackTrace();
}
// 2 rows in the db from the previous test (3 for hsql)
if (// sadly, hsql is not super transactional as a backend
isHSQL())
assertEquals(3, countPartitionedRows(client));
else
assertEquals(2, countPartitionedRows(client));
}
use of org.voltdb.client.ProcCallException in project voltdb by VoltDB.
the class TestMPBasecaseSuite method testOneShotConstraintViolationAllSites.
public void testOneShotConstraintViolationAllSites() throws Exception {
final Client client = this.getClient();
loadData(client);
boolean caught = false;
try {
client.callProcedure("ConstraintViolationUpdate");
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);
// verify initial result is unchanged (transactions!)
ClientResponse resp = client.callProcedure("SumB1");
assertTrue("Verified updates", resp.getStatus() == ClientResponse.SUCCESS);
assertEquals("Updated sum=45", 45L, resp.getResults()[0].asScalarLong());
}
use of org.voltdb.client.ProcCallException 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.ProcCallException 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();
}
}
use of org.voltdb.client.ProcCallException in project voltdb by VoltDB.
the class MaxTracker method run.
@Override
public void run() {
try {
// Call a proc (synchronously) to get the maximum value.
// See ddl.sql for the actual SQL being run.
// Note this is a cross-partition transaction, but as
// of VoltDB 4.0, it should be fast as it's a read that
// only needs to make one round trip to all partitions.
//
// SQL BEING RUN:
// SELECT MAX(val) FROM timedata;
ClientResponse cr = app.client.callProcedure("MaxValue");
long currentMax = cr.getResults()[0].asScalarLong();
if (currentMax == previousMax) {
return;
}
// of other reporting lines.
synchronized (app) {
if (previousMax == Long.MIN_VALUE) {
System.out.printf("The initial maximum value for the dataset has been set to %d.\n\n", currentMax);
} else {
System.out.printf("The maximum value for the dataset has changed from %d to %d.\n\n", previousMax, currentMax);
}
}
previousMax = currentMax;
} catch (IOException | ProcCallException e) {
// track failures in a pretty simple way for the reporter task
failureCount.incrementAndGet();
}
}
Aggregations