use of org.voltdb.client.NoConnectionsException in project voltdb by VoltDB.
the class TestSnapshotConverter method testSnapshotConverter.
// Regression test for ENG-8609
public void testSnapshotConverter() throws NoConnectionsException, IOException, ProcCallException {
// not supported in community
if (!MiscUtils.isPro()) {
return;
}
if (isValgrind())
return;
Client client = getClient();
int expectedLines = 10;
Random r = new Random(Calendar.getInstance().getTimeInMillis());
for (int i = 0; i < expectedLines; i++) {
int id = r.nextInt();
client.callProcedure("T_SP.insert", String.format("Test String %s:%d", "SP", i), id, "blab", "blab");
client.callProcedure("T_MP.insert", String.format("Test String %s:%d", "MP", i), id, "blab", "blab");
}
VoltTable[] results = null;
try {
results = client.callProcedure("@SnapshotSave", TMPDIR, TESTNONCE, 1).getResults();
} catch (Exception ex) {
ex.printStackTrace();
fail();
}
System.out.println(results[0]);
try {
results = client.callProcedure("@SnapshotStatus").getResults();
} catch (NoConnectionsException e) {
e.printStackTrace();
} catch (Exception ex) {
fail();
}
System.out.println(results[0]);
// better be two rows
assertEquals(2, results[0].getRowCount());
// start convert to MP snapshot to csv
String[] argsMP = { "--table", "T_MP", "--type", "CSV", "--dir", TMPDIR, "--outdir", TMPDIR, TESTNONCE };
try {
SnapshotConverter.main(argsMP);
} catch (Exception ex) {
fail();
}
File mpFile = new File(TMPDIR + "/T_MP.csv");
assertEquals(expectedLines, countLines(mpFile));
mpFile.deleteOnExit();
// start convert to SP snapshot to csv
String[] argsSP = { "--table", "T_SP", "--type", "CSV", "--dir", TMPDIR, "--outdir", TMPDIR, TESTNONCE };
try {
SnapshotConverter.main(argsSP);
} catch (Exception ex) {
fail();
}
File spFile = new File(TMPDIR + "/T_SP.csv");
// this test will fail frequently with different lines before ENG-8609
assertEquals(expectedLines, countLines(spFile));
spFile.deleteOnExit();
}
use of org.voltdb.client.NoConnectionsException in project voltdb by VoltDB.
the class TestInitStartLocalClusterInProcess method loadAndAddProcs.
void loadAndAddProcs() throws IOException, NoConnectionsException {
ClientResponse resp = null;
long numberOfClasses = 0;
try {
resp = client.callProcedure("@SystemCatalog", "CLASSES");
} catch (ProcCallException excp) {
assert false : "@SystemCatalogClasses failed";
}
numberOfClasses = resp.getResults()[0].getRowCount();
InMemoryJarfile jarfile = new InMemoryJarfile();
VoltCompiler comp = new VoltCompiler(false);
try {
comp.addClassToJar(jarfile, org.voltdb_testprocs.updateclasses.testImportProc.class);
comp.addClassToJar(jarfile, org.voltdb_testprocs.updateclasses.testCreateProcFromClassProc.class);
comp.addClassToJar(jarfile, org.voltdb_testprocs.updateclasses.InnerClassesTestProc.class);
comp.addClassToJar(jarfile, RangeCount.class);
} catch (Exception e) {
assert false : "Failed add class to jar: " + e.getMessage();
}
try {
client.callProcedure("@UpdateClasses", jarfile.getFullJarBytes(), null);
} catch (ProcCallException excp) {
assert false : "Failed updating the class";
}
try {
resp = client.callProcedure("@SystemCatalog", "CLASSES");
} catch (ProcCallException excp) {
assert false : "@SystemCatalogClasses failed";
}
assertTrue((numberOfClasses + jarfile.getLoader().getClassNames().size()) == resp.getResults()[0].getRowCount());
}
use of org.voltdb.client.NoConnectionsException in project voltdb by VoltDB.
the class KafkaImportBenchmark method endTest.
public static void endTest(boolean testResult, Config config) {
// Write stats to file if requested
try {
if ((config.statsfile != null) && (config.statsfile.length() != 0)) {
log.info("Stats file: " + config.statsfile);
FileWriter fw = new FileWriter(config.statsfile);
// stats: row count, latest time, earliest time
long[] stats = MatchChecks.getStats(client);
log.info("rows: " + stats[0] + ". End timestamp: " + stats[1] + ". Start timestamp: " + stats[2]);
// Date date = new Date(stats[2]);
// LocalDateTime.ofInstant(Instant.ofEpochMilli(stats[2]*1000), ZoneId.systemDefault());
double tps = stats[0] / ((double) stats[1] - (double) stats[2]);
log.info("TPS: " + tps);
log.info("Stats string: " + String.format("%d,%d,%d,%d,%d,%d,%d,0,0,0,0,0,0\n", stats[2], config.duration, 0, 0, 0, 0, (long) tps));
fw.append(String.format("%d,%d,%d,%d,%d,%d,%d,0,0,0,0,0,0\n", stats[2], (stats[1] - stats[2]) * 1000, stats[0], 0, 0, 0, 0));
fw.close();
}
} catch (IOException e) {
System.err.println("Error writing stats file");
e.printStackTrace();
}
try {
client.drain();
client.close();
} catch (NoConnectionsException | InterruptedException e) {
e.printStackTrace();
}
if (testResult == true) {
log.info("Test passed!");
System.exit(0);
} else {
log.info("Test failed!");
System.exit(1);
}
}
use of org.voltdb.client.NoConnectionsException in project voltdb by VoltDB.
the class CSVTupleDataLoader method insertRow.
@Override
public void insertRow(RowWithMetaData metaData, Object[] values) throws InterruptedException {
try {
PartitionSingleExecuteProcedureCallback cbmt = new PartitionSingleExecuteProcedureCallback(metaData);
if (!m_client.callProcedure(cbmt, m_insertProcedure, values)) {
m_log.fatal("Failed to send CSV insert to VoltDB cluster.");
ClientResponse response = new ClientResponseImpl(ClientResponseImpl.SERVER_UNAVAILABLE, new VoltTable[0], "Failed to call procedure.", 0);
m_errHandler.handleError(metaData, response, "Failed to call procedure.");
}
} catch (NoConnectionsException ex) {
ClientResponse response = new ClientResponseImpl(ClientResponseImpl.SERVER_UNAVAILABLE, new VoltTable[0], "Failed to call procedure.", 0);
m_errHandler.handleError(metaData, response, "Failed to call procedure.");
} catch (IOException ex) {
ClientResponse response = new ClientResponseImpl(ClientResponseImpl.SERVER_UNAVAILABLE, new VoltTable[0], "Failed to call procedure.", 0);
m_errHandler.handleError(metaData, response, "Failed to call procedure.");
} catch (Exception ex) {
m_errHandler.handleError(metaData, null, ex.toString());
}
}
use of org.voltdb.client.NoConnectionsException in project voltdb by VoltDB.
the class TestNTProcs method testSlamNTProcs.
public void testSlamNTProcs() throws Exception {
final Set<Long> outstanding = Collections.synchronizedSet(new HashSet<Long>());
ServerThread localServer = start();
final AtomicLong called = new AtomicLong(0);
Client client = ClientFactory.createClient();
client.createConnection("localhost");
final Client firehoseClient = ClientFactory.createClient();
firehoseClient.createConnection("localhost");
final AtomicBoolean keepFirehosing = new AtomicBoolean(true);
final AtomicBoolean keepChecking = new AtomicBoolean(true);
Thread firehoseThread = new Thread() {
@Override
public void run() {
long id = 0;
while (keepFirehosing.get()) {
SlamCallback scb = new SlamCallback(++id, outstanding);
outstanding.add(scb.m_id);
try {
boolean status = firehoseClient.callProcedure(scb, "TestNTProcs$NTProcThatSlams", "TestNTProcs$TrivialNTProc", // params
new byte[0], NTProcThatSlams.COLLECT_ASYNC, 1);
assertTrue(status);
called.incrementAndGet();
} catch (IOException e) {
e.printStackTrace();
fail();
}
}
try {
firehoseClient.drain();
} catch (NoConnectionsException | InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
fail();
}
}
};
firehoseThread.start();
long nanoTime1 = System.nanoTime();
Thread.sleep(5000);
long nanoTime2 = System.nanoTime();
long nowCalled = called.get();
long leftToRespond = outstanding.size();
System.out.printf("Ran for %.2f seconds. Called %d procs with %d outstanding.\n", (nanoTime2 - nanoTime1) / 1000000000.0, nowCalled, leftToRespond);
System.out.printf("NTProcThatSlams reports %d starts and %d returns.\n", NTProcThatSlams.m_runCount.get(), NTProcThatSlams.m_returnCount.get());
System.out.printf("TrivialNTProc reports %d starts and %d returns.\n", TrivialNTProc.m_runCount.get(), TrivialNTProc.m_returnCount.get());
keepFirehosing.set(false);
Thread statsThread = new Thread() {
@Override
public void run() {
while (keepChecking.get()) {
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
long nowCalled = called.get();
long leftToRespond = outstanding.size();
System.out.printf("Update: Called %d procs with %d outstanding.\n", nowCalled, leftToRespond);
System.out.printf(" NTProcThatSlams reports %d starts and %d returns.\n", NTProcThatSlams.m_runCount.get(), NTProcThatSlams.m_returnCount.get());
System.out.printf(" TrivialNTProc reports %d starts and %d returns.\n", TrivialNTProc.m_runCount.get(), TrivialNTProc.m_returnCount.get());
if (outstanding.size() > 0) {
Set<Long> copySet = new HashSet<>();
copySet.addAll(outstanding);
System.out.print(" Outstanding: ");
copySet.stream().forEach(l -> System.out.printf("%d, ", l));
System.out.println();
}
System.out.printf(" SlamCallback reports %d processed.\n", SlamCallback.m_count.get());
}
}
};
statsThread.start();
firehoseThread.join();
keepChecking.set(false);
long nanoTime3 = System.nanoTime();
System.out.printf("Drained for %.2f seconds. %d outstanding.\n", (nanoTime3 - nanoTime2) / 1000000000.0, outstanding.size());
System.out.printf("NTProcThatSlams reports %d starts and %d returns.\n", NTProcThatSlams.m_runCount.get(), NTProcThatSlams.m_returnCount.get());
System.out.printf("TrivialNTProc reports %d starts and %d returns.\n", TrivialNTProc.m_runCount.get(), TrivialNTProc.m_returnCount.get());
// CHECK STATS
VoltTable statsT = getStats(client, "PROCEDURE");
System.out.println("STATS: " + statsT.toFormattedString());
assertTrue(VoltTableUtil.tableContainsString(statsT, "NTProcThatSlams", true));
client.close();
firehoseClient.close();
localServer.shutdown();
localServer.join();
}
Aggregations