use of org.voltdb.VoltTable.ColumnInfo in project voltdb by VoltDB.
the class TestStatisticsSuite method testIOStatistics.
public void testIOStatistics() throws Exception {
System.out.println("\n\nTESTING IO STATS\n\n\n");
Client client = getFullyConnectedClient();
// Based on doc, not code
// HOST_ID, SITE_ID, and PARTITION_ID all differ. Fixed to match
// reality so tests would pass, but, ugh.
ColumnInfo[] expectedSchema = new ColumnInfo[9];
expectedSchema[0] = new ColumnInfo("TIMESTAMP", VoltType.BIGINT);
expectedSchema[1] = new ColumnInfo("HOST_ID", VoltType.INTEGER);
expectedSchema[2] = new ColumnInfo("HOSTNAME", VoltType.STRING);
expectedSchema[3] = new ColumnInfo("CONNECTION_ID", VoltType.BIGINT);
expectedSchema[4] = new ColumnInfo("CONNECTION_HOSTNAME", VoltType.STRING);
expectedSchema[5] = new ColumnInfo("BYTES_READ", VoltType.BIGINT);
expectedSchema[6] = new ColumnInfo("MESSAGES_READ", VoltType.BIGINT);
expectedSchema[7] = new ColumnInfo("BYTES_WRITTEN", VoltType.BIGINT);
expectedSchema[8] = new ColumnInfo("MESSAGES_WRITTEN", VoltType.BIGINT);
VoltTable expectedTable = new VoltTable(expectedSchema);
VoltTable[] results = null;
//
// iostats
//
results = client.callProcedure("@Statistics", "iostats", 0).getResults();
System.out.println("Test iostats table: " + results[0].toString());
// one aggregate table returned
assertEquals(1, results.length);
validateSchema(results[0], expectedTable);
}
use of org.voltdb.VoltTable.ColumnInfo in project voltdb by VoltDB.
the class TestStatisticsSuite method testInitiatorStatistics.
public void testInitiatorStatistics() throws Exception {
System.out.println("\n\nTESTING INITIATOR STATS\n\n\n");
Client client = getFullyConnectedClient();
ColumnInfo[] expectedSchema = new ColumnInfo[13];
expectedSchema[0] = new ColumnInfo("TIMESTAMP", VoltType.BIGINT);
expectedSchema[1] = new ColumnInfo("HOST_ID", VoltType.INTEGER);
expectedSchema[2] = new ColumnInfo("HOSTNAME", VoltType.STRING);
expectedSchema[3] = new ColumnInfo("SITE_ID", VoltType.INTEGER);
expectedSchema[4] = new ColumnInfo("CONNECTION_ID", VoltType.BIGINT);
expectedSchema[5] = new ColumnInfo("CONNECTION_HOSTNAME", VoltType.STRING);
expectedSchema[6] = new ColumnInfo("PROCEDURE_NAME", VoltType.STRING);
expectedSchema[7] = new ColumnInfo("INVOCATIONS", VoltType.BIGINT);
expectedSchema[8] = new ColumnInfo("AVG_EXECUTION_TIME", VoltType.INTEGER);
expectedSchema[9] = new ColumnInfo("MIN_EXECUTION_TIME", VoltType.INTEGER);
expectedSchema[10] = new ColumnInfo("MAX_EXECUTION_TIME", VoltType.INTEGER);
expectedSchema[11] = new ColumnInfo("ABORTS", VoltType.BIGINT);
expectedSchema[12] = new ColumnInfo("FAILURES", VoltType.BIGINT);
VoltTable expectedTable = new VoltTable(expectedSchema);
//
// initiator selector
//
VoltTable[] results = null;
// This should get us an invocation at each host
for (int i = 0; i < 1000; i++) {
results = client.callProcedure("NEW_ORDER.insert", i).getResults();
}
results = client.callProcedure("@Statistics", "INITIATOR", 0).getResults();
// one aggregate table returned
assertEquals(1, results.length);
System.out.println("Test initiators table: " + results[0].toString());
// Check the schema
validateSchema(results[0], expectedTable);
// One WAREHOUSE.select row per host
System.out.println(results[0].toFormattedString());
assertTrue(results[0].getRowCount() >= HOSTS);
// Verify the invocation counts
int counts = 0;
while (results[0].advanceRow()) {
String procName = results[0].getString("PROCEDURE_NAME");
if (procName.equals("@SystemCatalog")) {
// One for each connection from the client
assertEquals(HOSTS, results[0].getLong("INVOCATIONS"));
} else if (procName.equals("NEW_ORDER.insert")) {
counts += results[0].getLong("INVOCATIONS");
}
}
assertEquals(1000, counts);
// verify that each node saw a NEW_ORDER.insert initiation
Map<String, String> columnTargets = new HashMap<String, String>();
columnTargets.put("PROCEDURE_NAME", "NEW_ORDER.insert");
validateRowSeenAtAllHosts(results[0], columnTargets, true);
}
use of org.voltdb.VoltTable.ColumnInfo in project voltdb by VoltDB.
the class TestStatisticsSuite method testPartitionCount.
public void testPartitionCount() throws Exception {
System.out.println("\n\nTESTING PARTITION COUNT\n\n\n");
Client client = getFullyConnectedClient();
ColumnInfo[] expectedSchema = new ColumnInfo[4];
expectedSchema[0] = new ColumnInfo("TIMESTAMP", VoltType.BIGINT);
expectedSchema[1] = new ColumnInfo("HOST_ID", VoltType.INTEGER);
expectedSchema[2] = new ColumnInfo("HOSTNAME", VoltType.STRING);
expectedSchema[3] = new ColumnInfo("PARTITION_COUNT", VoltType.INTEGER);
VoltTable expectedTable = new VoltTable(expectedSchema);
VoltTable[] results = null;
results = client.callProcedure("@Statistics", "PARTITIONCOUNT", 0).getResults();
// Only one table returned
assertEquals(1, results.length);
validateSchema(results[0], expectedTable);
// Should only get one row, total
assertEquals(1, results[0].getRowCount());
results[0].advanceRow();
int partCount = (int) results[0].getLong("PARTITION_COUNT");
assertEquals(PARTITIONS, partCount);
}
use of org.voltdb.VoltTable.ColumnInfo in project voltdb by VoltDB.
the class Vote method run.
public VoltTable[] run(long phoneNumber, int contestantNumber, long maxVotesPerPhoneNumber) {
VoltTable result = new VoltTable(new ColumnInfo("STATUS", VoltType.BIGINT), new ColumnInfo("REJECTED", VoltType.BIGINT));
// Queue up validation statements
voltQueueSQL(checkContestantStmt, EXPECT_ZERO_OR_ONE_ROW, contestantNumber);
voltQueueSQL(checkVoterStmt, EXPECT_ZERO_OR_ONE_ROW, phoneNumber);
voltQueueSQL(checkStateStmt, EXPECT_ZERO_OR_ONE_ROW, (short) (phoneNumber / 10000000l));
voltQueueSQL(checkRejectedVotesStmt, EXPECT_ZERO_OR_ONE_ROW, phoneNumber);
VoltTable[] validation = voltExecuteSQL();
if (validation[0].getRowCount() == 0) {
result.addRow(ERR_INVALID_CONTESTANT, -1);
return new VoltTable[] { result };
}
// Get rejected votes
long rejectedVotes = 1;
if (validation[3].getRowCount() == 1) {
rejectedVotes = validation[3].asScalarLong() + 1;
}
if ((validation[1].getRowCount() == 1) && (validation[1].asScalarLong() >= maxVotesPerPhoneNumber)) {
if (validation[3].getRowCount() == 1) {
// Increment count
voltQueueSQL(incrementRejectedVotesStmt, phoneNumber);
} else {
// insert
voltQueueSQL(insertRejectedVotesStmt, phoneNumber, 1);
}
voltExecuteSQL();
result.addRow(ERR_VOTER_OVER_VOTE_LIMIT, rejectedVotes);
return new VoltTable[] { result };
}
// Some sample client libraries use the legacy random phone generation that mostly
// created invalid phone numbers. Until refactoring, re-assign all such votes to
// the "XX" fake state (those votes will not appear on the Live Statistics dashboard,
// but are tracked as legitimate instead of invalid, as old clients would mostly get
// it wrong and see all their transactions rejected).
final String state = (validation[2].getRowCount() > 0) ? validation[2].fetchRow(0).getString(0) : "XX";
// Post the vote
voltQueueSQL(insertVoteStmt, EXPECT_SCALAR_MATCH(1), phoneNumber, state, contestantNumber);
voltExecuteSQL(true);
// Set the return value to 0: successful vote
result.addRow(VOTE_SUCCESSFUL, rejectedVotes);
return new VoltTable[] { result };
}
Aggregations