use of org.voltdb.ClientResponseImpl in project voltdb by VoltDB.
the class TestLiveTableSchemaMigration method migrateSchemaUsingAlter.
/**
* Assuming given tables have schema metadata, fill them with random data
* and compare a pure-java schema migration with an EE schema migration.
*/
void migrateSchemaUsingAlter(VoltTable t1, VoltTable t2, boolean withData) throws Exception {
ServerThread server = null;
Client client = null;
TableHelper helper = new TableHelper();
try {
String alterText = TableHelper.getAlterTableDDLToMigrate(t1, t2);
if (withData) {
helper.randomFill(t1, 1000, 1024);
}
String catPath1 = catalogPathForTable(t1, "t1.jar");
DeploymentBuilder depBuilder = new DeploymentBuilder(1, 1, 0);
depBuilder.setVoltRoot("/tmp/rootbar");
depBuilder.setUseDDLSchema(true);
// disable logging
depBuilder.configureLogging("/tmp/foobar", "/tmp/goobar", false, false, 1, 1, 3);
String deployment = depBuilder.getXML();
File deploymentFile = VoltProjectBuilder.writeStringToTempFile(deployment);
VoltDB.Configuration config = new VoltDB.Configuration();
config.m_pathToDeployment = deploymentFile.getAbsolutePath();
config.m_pathToCatalog = catPath1;
config.m_ipcPort = 10000;
//config.m_backend = BackendTarget.NATIVE_EE_IPC;
server = new ServerThread(config);
server.start();
server.waitForInitialization();
System.out.printf("PRE: %s\n", TableHelper.ddlForTable(t1, false));
System.out.printf("POST: %s\n", TableHelper.ddlForTable(t2, false));
TableHelper.migrateTable(t1, t2);
t2 = TableHelper.sortTable(t2);
ClientConfig clientConfig = new ClientConfig();
client = ClientFactory.createClient(clientConfig);
client.createConnection("localhost");
TableHelper.loadTable(client, t1);
if (alterText.trim().length() > 0) {
ClientResponseImpl response = (ClientResponseImpl) client.callProcedure("@AdHoc", alterText, null);
System.out.println(response.toJSONString());
}
VoltTable t3 = client.callProcedure("@AdHoc", "select * from FOO").getResults()[0];
t3 = TableHelper.sortTable(t3);
// compare the tables
StringBuilder sb = new StringBuilder();
if (!TableHelper.deepEqualsWithErrorMsg(t2, t3, sb)) {
System.out.println("Table Mismatch");
//System.out.printf("PRE: %s\n", t2.toFormattedString());
//System.out.printf("POST: %s\n", t3.toFormattedString());
System.out.println(sb.toString());
fail();
}
} finally {
if (client != null) {
client.close();
}
if (server != null) {
server.shutdown();
}
}
}
use of org.voltdb.ClientResponseImpl in project voltdb by VoltDB.
the class Benchmark method runBenchmark.
/**
* Core benchmark code.
* Connect. Initialize. Run the loop. Cleanup. Print Results.
*
* @throws Exception if anything unexpected happens.
*/
public void runBenchmark() throws Exception {
byte exitcode = 0;
log.info(HORIZONTAL_RULE);
log.info(" Setup & Initialization");
log.info(HORIZONTAL_RULE);
// Only rate limit the ClientThread for now. Share the same permits for all type of invocations.
Semaphore permits = rateLimiter.addType(0, 1);
final int cidCount = 128;
final long[] lastRid = new long[cidCount];
for (int i = 0; i < lastRid.length; i++) {
lastRid[i] = 0;
}
// connect to one or more servers, loop until success
connect();
// get partition count
int partitionCount = 0;
int trycount = 12;
while (trycount-- > 0) {
try {
partitionCount = getUniquePartitionCount();
break;
} catch (Exception e) {
}
Thread.sleep(10000);
}
// get stats
try {
ClientResponse cr = TxnId2Utils.doProcCall(client, "Summarize_Replica", config.threadoffset, config.threads);
if (cr.getStatus() != ClientResponse.SUCCESS) {
log.error("Failed to call Summarize proc at startup. Exiting.");
log.error(((ClientResponseImpl) cr).toJSONString());
printJStack();
System.exit(-1);
}
// successfully called summarize
VoltTable t = cr.getResults()[0];
long ts = t.fetchRow(0).getLong("ts");
String tsStr = ts == 0 ? "NO TIMESTAMPS" : String.valueOf(ts) + " / " + new Date(ts).toString();
long count = t.fetchRow(0).getLong("count");
log.info("STARTUP TIMESTAMP OF LAST UPDATE (GMT): " + tsStr);
log.info("UPDATES RUN AGAINST THIS DB TO DATE: " + count);
} catch (ProcCallException e) {
log.error("Failed to call Summarize proc at startup. Exiting.", e);
log.error(((ClientResponseImpl) e.getClientResponse()).toJSONString());
printJStack();
System.exit(-1);
}
clientThreads = new ArrayList<ClientThread>();
if (!config.disabledThreads.contains("clients")) {
for (byte cid = (byte) config.threadoffset; cid < config.threadoffset + config.threads; cid++) {
ClientThread clientThread = new ClientThread(cid, txnCount, client, processor, permits, config.allowinprocadhoc, config.mpratio);
//clientThread.start(); # started after preload is complete
clientThreads.add(clientThread);
}
}
log.info(HORIZONTAL_RULE);
log.info("Loading Filler Tables...");
log.info(HORIZONTAL_RULE);
// Big Partitioned Loader
if (!(config.disabledThreads.contains("partBiglt") || config.disabledThreads.contains("Biglt"))) {
partBiglt = new BigTableLoader(client, "bigp", (config.partfillerrowmb * 1024 * 1024) / config.fillerrowsize, config.fillerrowsize, 50, permits, partitionCount);
partBiglt.start();
}
replBiglt = null;
if (config.mpratio > 0.0 && !(config.disabledThreads.contains("replBiglt") || config.disabledThreads.contains("Biglt"))) {
replBiglt = new BigTableLoader(client, "bigr", (config.replfillerrowmb * 1024 * 1024) / config.fillerrowsize, config.fillerrowsize, 3, permits, partitionCount);
replBiglt.start();
}
// wait for the filler tables to load up
//partBiglt.join();
//replBiglt.join();
log.info(HORIZONTAL_RULE);
log.info("Starting Benchmark");
log.info(HORIZONTAL_RULE);
// print periodic statistics to the console
benchmarkStartTS = System.currentTimeMillis();
scheduleRunTimer();
// reset progress tracker
lastProgressTimestamp = System.currentTimeMillis();
schedulePeriodicStats();
schedulePeriodicCheckpoint();
scheduleRefreshPermits();
// Run the benchmark loop for the requested duration
// The throughput may be throttled depending on client configuration
log.info("Running benchmark...");
while (((ClientImpl) client).isHashinatorInitialized() == false) {
Thread.sleep(1000);
System.out.println("Wait for hashinator..");
}
if (!config.disabledThreads.contains("clients")) {
for (ClientThread t : clientThreads) {
t.start();
}
}
if (!(config.disabledThreads.contains("partTrunclt") || config.disabledThreads.contains("Trunclt"))) {
partTrunclt = new TruncateTableLoader(client, "trup", (config.partfillerrowmb * 1024 * 1024) / config.fillerrowsize, config.fillerrowsize, 50, permits, config.mpratio, config.swapratio);
partTrunclt.start();
}
replTrunclt = null;
if (config.mpratio > 0.0 && !(config.disabledThreads.contains("replTrunclt") || config.disabledThreads.contains("Trunclt"))) {
replTrunclt = new TruncateTableLoader(client, "trur", (config.replfillerrowmb * 1024 * 1024) / config.fillerrowsize, config.fillerrowsize, 3, permits, config.mpratio, config.swapratio);
replTrunclt.start();
}
if (!(config.disabledThreads.contains("partCappedlt") || config.disabledThreads.contains("Cappedlt"))) {
partCappedlt = new // more
CappedTableLoader(// more
client, // more
"capp", (config.partfillerrowmb * 1024 * 1024) / config.fillerrowsize, config.fillerrowsize, 50, permits, config.mpratio);
partCappedlt.start();
}
if (config.mpratio > 0.0 && !(config.disabledThreads.contains("replCappedlt") || config.disabledThreads.contains("Cappedlt"))) {
replCappedlt = new // more
CappedTableLoader(// more
client, // more
"capr", (config.replfillerrowmb * 1024 * 1024) / config.fillerrowsize, config.fillerrowsize, 3, permits, config.mpratio);
replCappedlt.start();
}
if (!(config.disabledThreads.contains("partLoadlt") || config.disabledThreads.contains("Loadlt"))) {
partLoadlt = new LoadTableLoader(client, "loadp", (config.partfillerrowmb * 1024 * 1024) / config.fillerrowsize, 50, permits, false, 0);
partLoadlt.start();
}
replLoadlt = null;
if (config.mpratio > 0.0 && !(config.disabledThreads.contains("replLoadlt") || config.disabledThreads.contains("Loadlt"))) {
replLoadlt = new LoadTableLoader(client, "loadmp", (config.replfillerrowmb * 1024 * 1024) / config.fillerrowsize, 3, permits, true, -1);
replLoadlt.start();
}
if (!config.disabledThreads.contains("readThread")) {
readThread = new ReadThread(client, config.threads, config.threadoffset, config.allowinprocadhoc, config.mpratio, permits);
readThread.start();
}
if (!config.disabledThreads.contains("adHocMayhemThread")) {
adHocMayhemThread = new AdHocMayhemThread(client, config.mpratio, permits);
if (!config.disableadhoc) {
adHocMayhemThread.start();
}
}
if (!config.disabledThreads.contains("idpt")) {
idpt = new InvokeDroppedProcedureThread(client);
idpt.start();
}
if (!config.disabledThreads.contains("ddlt")) {
ddlt = new DdlThread(client);
// XXX/PSR ddlt.start();
}
log.info("All threads started...");
while (true) {
Thread.sleep(Integer.MAX_VALUE);
}
}
Aggregations