use of org.voltdb.client.ClientResponse in project voltdb by VoltDB.
the class TestSubQueriesSuite method loadData.
private void loadData(boolean extra) throws Exception {
Client client = this.getClient();
ClientResponse cr = null;
// Empty data from table.
for (String tb : tbs) {
cr = client.callProcedure("@AdHoc", "delete from " + tb);
assertEquals(ClientResponse.SUCCESS, cr.getStatus());
// Insert records into the table.
String proc = tb + ".insert";
// id,wage,dept,tm
cr = client.callProcedure(proc, 1, 10, 1, "2013-06-18 02:00:00.123457");
assertEquals(ClientResponse.SUCCESS, cr.getStatus());
cr = client.callProcedure(proc, 2, 20, 1, "2013-07-18 02:00:00.123457");
assertEquals(ClientResponse.SUCCESS, cr.getStatus());
cr = client.callProcedure(proc, 3, 30, 1, "2013-07-18 10:40:01.123457");
assertEquals(ClientResponse.SUCCESS, cr.getStatus());
cr = client.callProcedure(proc, 4, 40, 2, "2013-08-18 02:00:00.123457");
assertEquals(ClientResponse.SUCCESS, cr.getStatus());
cr = client.callProcedure(proc, 5, 50, 2, "2013-09-18 02:00:00.123457");
assertEquals(ClientResponse.SUCCESS, cr.getStatus());
if (extra) {
// id,wage,dept,tm
cr = client.callProcedure(proc, 6, 10, 2, "2013-07-18 02:00:00.123457");
assertEquals(ClientResponse.SUCCESS, cr.getStatus());
cr = client.callProcedure(proc, 7, 40, 2, "2013-09-18 02:00:00.123457");
assertEquals(ClientResponse.SUCCESS, cr.getStatus());
}
}
}
use of org.voltdb.client.ClientResponse in project voltdb by VoltDB.
the class TestUpdateClasses method testBadInitializerClasses.
@Test
public void testBadInitializerClasses() throws Exception {
System.out.println("\n\n-----\n testBadInitializerClasses \n-----\n\n");
String pathToCatalog = Configuration.getPathToCatalogForTest("updateclasses.jar");
String pathToDeployment = Configuration.getPathToCatalogForTest("updateclasses.xml");
VoltProjectBuilder builder = new VoltProjectBuilder();
builder.addLiteralSchema("-- Don't care");
builder.setUseDDLSchema(true);
boolean success = builder.compile(pathToCatalog, 2, 1, 0);
assertTrue("Schema compilation failed", success);
MiscUtils.copyFile(builder.getPathToDeployment(), pathToDeployment);
try {
VoltDB.Configuration config = new VoltDB.Configuration();
config.m_pathToCatalog = pathToCatalog;
config.m_pathToDeployment = pathToDeployment;
startSystem(config);
ClientResponse resp;
InMemoryJarfile boom = new InMemoryJarfile();
VoltCompiler comp = new VoltCompiler(false);
comp.addClassToJar(boom, org.voltdb_testprocs.updateclasses.testBadInitializerProc.class);
boolean threw = false;
try {
resp = m_client.callProcedure("@UpdateClasses", boom.getFullJarBytes(), null);
System.out.println(((ClientResponseImpl) resp).toJSONString());
} catch (ProcCallException pce) {
pce.printStackTrace();
threw = true;
}
assertTrue("Bad class jar should have thrown", threw);
threw = false;
boom = new InMemoryJarfile();
comp = new VoltCompiler(false);
comp.addClassToJar(boom, org.voltdb_testprocs.updateclasses.BadClassLoadClass.class);
try {
resp = m_client.callProcedure("@UpdateClasses", boom.getFullJarBytes(), null);
System.out.println(((ClientResponseImpl) resp).toJSONString());
} catch (ProcCallException pce) {
pce.printStackTrace();
threw = true;
}
assertTrue("Bad class jar should have thrown", threw);
} finally {
teardownSystem();
}
}
use of org.voltdb.client.ClientResponse in project voltdb by VoltDB.
the class TestUpdateClasses method testDeleteClasses.
// Delete tests:
// single file match
// * match
// ** match
// comma-separated matches
// combine new jarfile with deleted stuff
// deleting inner classes
@Test
public void testDeleteClasses() throws Exception {
System.out.println("\n\n-----\n testCollidingProc \n-----\n\n");
String pathToCatalog = Configuration.getPathToCatalogForTest("updateclasses.jar");
String pathToDeployment = Configuration.getPathToCatalogForTest("updateclasses.xml");
VoltProjectBuilder builder = new VoltProjectBuilder();
builder.addLiteralSchema("-- Don't care");
builder.setUseDDLSchema(true);
boolean success = builder.compile(pathToCatalog, 2, 1, 0);
assertTrue("Schema compilation failed", success);
MiscUtils.copyFile(builder.getPathToDeployment(), pathToDeployment);
// This is maybe cheating a little bit?
InMemoryJarfile jarfile = new InMemoryJarfile();
for (Class<?> clazz : PROC_CLASSES) {
VoltCompiler comp = new VoltCompiler(false);
comp.addClassToJar(jarfile, clazz);
}
for (Class<?> clazz : EXTRA_CLASSES) {
VoltCompiler comp = new VoltCompiler(false);
comp.addClassToJar(jarfile, clazz);
}
for (Class<?> clazz : COLLIDING_CLASSES) {
VoltCompiler comp = new VoltCompiler(false);
comp.addClassToJar(jarfile, clazz);
}
try {
VoltDB.Configuration config = new VoltDB.Configuration();
config.m_pathToCatalog = pathToCatalog;
config.m_pathToDeployment = pathToDeployment;
startSystem(config);
ClientResponse resp;
// Make sure we're clean
resp = m_client.callProcedure("@SystemCatalog", "CLASSES");
assertEquals(0, resp.getResults()[0].getRowCount());
// Add the jarfile we built
resp = m_client.callProcedure("@UpdateClasses", jarfile.getFullJarBytes(), null);
resp = m_client.callProcedure("@SystemCatalog", "CLASSES");
assertEquals(PROC_CLASSES.length + EXTRA_CLASSES.length + COLLIDING_CLASSES.length, resp.getResults()[0].getRowCount());
// remove one class
assertTrue(findClassInSystemCatalog(PROC_CLASSES[0].getCanonicalName()));
resp = m_client.callProcedure("@UpdateClasses", null, PROC_CLASSES[0].getCanonicalName());
assertFalse(findClassInSystemCatalog(PROC_CLASSES[0].getCanonicalName()));
// remove everything under fullddlfeatures
assertTrue(findClassInSystemCatalog(COLLIDING_CLASSES[0].getCanonicalName()));
assertTrue(findClassInSystemCatalog(COLLIDING_CLASSES[1].getCanonicalName()));
resp = m_client.callProcedure("@UpdateClasses", null, "org.voltdb_testprocs.fullddlfeatures.*");
assertFalse(findClassInSystemCatalog(COLLIDING_CLASSES[0].getCanonicalName()));
assertFalse(findClassInSystemCatalog(COLLIDING_CLASSES[1].getCanonicalName()));
// Remove everything left
assertTrue(findClassInSystemCatalog(PROC_CLASSES[1].getCanonicalName()));
assertTrue(findClassInSystemCatalog(EXTRA_CLASSES[0].getCanonicalName()));
resp = m_client.callProcedure("@UpdateClasses", null, "org.voltdb**");
assertFalse(findClassInSystemCatalog(PROC_CLASSES[1].getCanonicalName()));
assertFalse(findClassInSystemCatalog(EXTRA_CLASSES[0].getCanonicalName()));
resp = m_client.callProcedure("@SystemCatalog", "CLASSES");
assertEquals(0, resp.getResults()[0].getRowCount());
// put everything back
// Add the jarfile we built
resp = m_client.callProcedure("@UpdateClasses", jarfile.getFullJarBytes(), null);
resp = m_client.callProcedure("@SystemCatalog", "CLASSES");
assertEquals(PROC_CLASSES.length + EXTRA_CLASSES.length + COLLIDING_CLASSES.length, resp.getResults()[0].getRowCount());
// delete the common simple names from both packages simultaneously
resp = m_client.callProcedure("@UpdateClasses", null, "**testImportProc , **testCreateProcFromClassProc");
resp = m_client.callProcedure("@SystemCatalog", "CLASSES");
// should be the only thing left
assertEquals(1, resp.getResults()[0].getRowCount());
assertTrue(findClassInSystemCatalog(EXTRA_CLASSES[0].getCanonicalName()));
// make a jar without the extra
InMemoryJarfile jarfile2 = new InMemoryJarfile();
for (Class<?> clazz : PROC_CLASSES) {
VoltCompiler comp = new VoltCompiler(false);
comp.addClassToJar(jarfile2, clazz);
}
for (Class<?> clazz : COLLIDING_CLASSES) {
VoltCompiler comp = new VoltCompiler(false);
comp.addClassToJar(jarfile2, clazz);
}
// finally, delete what's left and put the new jar in simultaneously
resp = m_client.callProcedure("@UpdateClasses", jarfile2.getFullJarBytes(), "**updateclasses.*");
resp = m_client.callProcedure("@SystemCatalog", "CLASSES");
// extra class should be gone, others installed
assertEquals(PROC_CLASSES.length + COLLIDING_CLASSES.length, resp.getResults()[0].getRowCount());
assertFalse(findClassInSystemCatalog(EXTRA_CLASSES[0].getCanonicalName()));
assertTrue(findClassInSystemCatalog(PROC_CLASSES[0].getCanonicalName()));
assertTrue(findClassInSystemCatalog(PROC_CLASSES[1].getCanonicalName()));
assertTrue(findClassInSystemCatalog(COLLIDING_CLASSES[0].getCanonicalName()));
assertTrue(findClassInSystemCatalog(COLLIDING_CLASSES[1].getCanonicalName()));
// now add a class with inner classes
InMemoryJarfile inner = new InMemoryJarfile();
VoltCompiler comp = new VoltCompiler(false);
comp.addClassToJar(inner, org.voltdb_testprocs.updateclasses.InnerClassesTestProc.class);
resp = m_client.callProcedure("@UpdateClasses", inner.getFullJarBytes(), null);
// old stuff should have survived
assertTrue(findClassInSystemCatalog(PROC_CLASSES[0].getCanonicalName()));
assertTrue(findClassInSystemCatalog(PROC_CLASSES[1].getCanonicalName()));
assertTrue(findClassInSystemCatalog(COLLIDING_CLASSES[0].getCanonicalName()));
assertTrue(findClassInSystemCatalog(COLLIDING_CLASSES[1].getCanonicalName()));
// Did we get the new class and inner classes too?
assertTrue(findClassInSystemCatalog("org.voltdb_testprocs.updateclasses.InnerClassesTestProc"));
assertTrue(findClassInSystemCatalog("org.voltdb_testprocs.updateclasses.InnerClassesTestProc$InnerNotPublic"));
assertTrue(findClassInSystemCatalog("org.voltdb_testprocs.updateclasses.InnerClassesTestProc$InnerWithConstructorArgs"));
assertTrue(findClassInSystemCatalog("org.voltdb_testprocs.updateclasses.InnerClassesTestProc$InnerWithEasyConstructor"));
assertTrue(findClassInSystemCatalog("org.voltdb_testprocs.updateclasses.InnerClassesTestProc$InnerWithNoConstructor"));
// now just delete the parent class
resp = m_client.callProcedure("@UpdateClasses", null, "org.voltdb_testprocs.updateclasses.InnerClassesTestProc");
// old stuff should have survived
resp = m_client.callProcedure("@SystemCatalog", "CLASSES");
// Non-inner stuff should have survived
assertEquals(PROC_CLASSES.length + COLLIDING_CLASSES.length, resp.getResults()[0].getRowCount());
assertTrue(findClassInSystemCatalog(PROC_CLASSES[0].getCanonicalName()));
assertTrue(findClassInSystemCatalog(PROC_CLASSES[1].getCanonicalName()));
assertTrue(findClassInSystemCatalog(COLLIDING_CLASSES[0].getCanonicalName()));
assertTrue(findClassInSystemCatalog(COLLIDING_CLASSES[1].getCanonicalName()));
// Inner classes and parent gone
assertFalse(findClassInSystemCatalog("org.voltdb_testprocs.updateclasses.InnerClassesTestProc"));
assertFalse(findClassInSystemCatalog("org.voltdb_testprocs.updateclasses.InnerClassesTestProc$InnerNotPublic"));
assertFalse(findClassInSystemCatalog("org.voltdb_testprocs.updateclasses.InnerClassesTestProc$InnerWithConstructorArgs"));
assertFalse(findClassInSystemCatalog("org.voltdb_testprocs.updateclasses.InnerClassesTestProc$InnerWithEasyConstructor"));
assertFalse(findClassInSystemCatalog("org.voltdb_testprocs.updateclasses.InnerClassesTestProc$InnerWithNoConstructor"));
// Empty string has no effect
resp = m_client.callProcedure("@UpdateClasses", null, "");
// old stuff should have survived
resp = m_client.callProcedure("@SystemCatalog", "CLASSES");
// Non-inner stuff should have survived
assertEquals(PROC_CLASSES.length + COLLIDING_CLASSES.length, resp.getResults()[0].getRowCount());
assertTrue(findClassInSystemCatalog(PROC_CLASSES[0].getCanonicalName()));
assertTrue(findClassInSystemCatalog(PROC_CLASSES[1].getCanonicalName()));
assertTrue(findClassInSystemCatalog(COLLIDING_CLASSES[0].getCanonicalName()));
assertTrue(findClassInSystemCatalog(COLLIDING_CLASSES[1].getCanonicalName()));
// pattern that matches nothing has no effect
resp = m_client.callProcedure("@UpdateClasses", null, "com.voltdb.*");
// old stuff should have survived
resp = m_client.callProcedure("@SystemCatalog", "CLASSES");
// Non-inner stuff should have survived
assertEquals(PROC_CLASSES.length + COLLIDING_CLASSES.length, resp.getResults()[0].getRowCount());
assertTrue(findClassInSystemCatalog(PROC_CLASSES[0].getCanonicalName()));
assertTrue(findClassInSystemCatalog(PROC_CLASSES[1].getCanonicalName()));
assertTrue(findClassInSystemCatalog(COLLIDING_CLASSES[0].getCanonicalName()));
assertTrue(findClassInSystemCatalog(COLLIDING_CLASSES[1].getCanonicalName()));
} finally {
teardownSystem();
}
}
use of org.voltdb.client.ClientResponse in project voltdb by VoltDB.
the class TestSystemProcedureSuite method testProfCtl.
// verify that these commands don't blow up
public void testProfCtl() throws Exception {
Client client = getClient();
//
// SAMPLER_START
//
ClientResponse resp = client.callProcedure("@ProfCtl", "SAMPLER_START");
VoltTable vt = resp.getResults()[0];
boolean foundResponse = false;
while (vt.advanceRow()) {
String profCtlResult = vt.getString("Result");
if ("SAMPLER_START".equalsIgnoreCase(profCtlResult)) {
foundResponse = true;
} else {
fail("Was not expecting @ProfCtl result: " + profCtlResult);
}
}
assertTrue(foundResponse);
//
// GPERF_ENABLE
//
resp = client.callProcedure("@ProfCtl", "GPERF_ENABLE");
vt = resp.getResults()[0];
foundResponse = false;
while (vt.advanceRow()) {
String profCtlResult = vt.getString("Result");
if ("GPERF_ENABLE".equalsIgnoreCase(profCtlResult)) {
foundResponse = true;
} else {
assertTrue("GPERF_NOOP".equalsIgnoreCase(profCtlResult));
}
}
assertTrue(foundResponse);
//
// GPERF_DISABLE
//
resp = client.callProcedure("@ProfCtl", "GPERF_DISABLE");
vt = resp.getResults()[0];
foundResponse = false;
while (vt.advanceRow()) {
String profCtlResult = vt.getString("Result");
if ("GPERF_DISABLE".equalsIgnoreCase(profCtlResult)) {
foundResponse = true;
} else {
assertTrue("GPERF_NOOP".equalsIgnoreCase(profCtlResult));
}
}
assertTrue(foundResponse);
//
// garbage
//
resp = client.callProcedure("@ProfCtl", "MakeAPony");
vt = resp.getResults()[0];
}
use of org.voltdb.client.ClientResponse in project voltdb by VoltDB.
the class TestBlobType method testTPCCCustomerLookup.
public void testTPCCCustomerLookup() throws Exception {
// constants used int the benchmark
final short W_ID = 3;
final byte D_ID = 7;
final int C_ID = 42;
VoltProjectBuilder builder = new VoltProjectBuilder();
builder.addSchema(TPCCProjectBuilder.ddlURL);
for (String[] pair : TPCCProjectBuilder.partitioning) {
builder.addPartitionInfo(pair[0], pair[1]);
}
builder.addStmtProcedure("InsertCustomer", "INSERT INTO CUSTOMER VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);", "CUSTOMER.C_W_ID: 2");
builder.addStmtProcedure("Fake1", "SELECT C_ID, C_FIRST, C_MIDDLE, C_LAST, C_STREET_1, C_STREET_2, C_CITY, C_STATE, C_ZIP, C_PHONE, C_SINCE, C_CREDIT, C_CREDIT_LIM, C_DISCOUNT, C_BALANCE, C_YTD_PAYMENT, C_PAYMENT_CNT, C_DATA FROM CUSTOMER WHERE C_LAST = ? AND C_D_ID = ? AND C_W_ID = ? ORDER BY C_FIRST;");
builder.addProcedures(FakeCustomerLookup.class);
boolean success = builder.compile(Configuration.getPathToCatalogForTest("binarytest2.jar"), 1, 1, 0);
assert (success);
MiscUtils.copyFile(builder.getPathToDeployment(), Configuration.getPathToCatalogForTest("binarytest2.xml"));
ServerThread localServer = null;
Client client = null;
try {
VoltDB.Configuration config = new VoltDB.Configuration();
config.m_pathToCatalog = Configuration.getPathToCatalogForTest("binarytest2.jar");
config.m_pathToDeployment = Configuration.getPathToCatalogForTest("binarytest2.xml");
config.m_backend = BackendTarget.NATIVE_EE_JNI;
localServer = new ServerThread(config);
localServer.start();
localServer.waitForInitialization();
client = ClientFactory.createClient();
client.createConnection("localhost");
// insert data
// long c_id, long c_d_id, long c_w_id, String c_first, String c_middle,
// String c_last, String c_street_1, String c_street_2, String d_city,
// String d_state, String d_zip, String c_phone, Date c_since, String
// c_credit, double c_credit_lim, double c_discount, double c_balance,
// double c_ytd_payment, double c_payment_cnt, double c_delivery_cnt,
// String c_data
final double initialBalance = 15.75;
final double initialYTD = 15241.45;
VoltTable customer1 = client.callProcedure("InsertCustomer", C_ID, D_ID, W_ID, "I", "Be", "lastname", "Place", "Place2", "BiggerPlace", "AL", "91083", "(193) 099 - 9082", new TimestampType(), "BC", 19298943.12, .13, initialBalance, initialYTD, 0L, 15L, "Some History").getResults()[0];
// check for successful insertion.
assertEquals(1L, customer1.asScalarLong());
VoltTable customer2 = client.callProcedure("InsertCustomer", C_ID + 1, D_ID, W_ID, "We", "R", "Customer", "Random Department", "Place2", "BiggerPlace", "AL", "13908", "(913) 909 - 0928", new TimestampType(), "GC", 19298943.12, .13, initialBalance, initialYTD, 1L, 15L, "Some History").getResults()[0];
// check for successful insertion.
assertEquals(1L, customer2.asScalarLong());
VoltTable customer3 = client.callProcedure("InsertCustomer", C_ID + 2, D_ID, W_ID, "Who", "Is", "Customer", "Receiving", "450 Mass F.X.", "BiggerPlace", "CI", "91083", "(541) 931 - 0928", new TimestampType(), "GC", 19899324.21, .13, initialBalance, initialYTD, 2L, 15L, "Some History").getResults()[0];
// check for successful insertion.
assertEquals(1L, customer3.asScalarLong());
VoltTable customer4 = client.callProcedure("InsertCustomer", C_ID + 3, D_ID, W_ID, "ICanBe", "", "Customer", "street", "place", "BiggerPlace", "MA", "91083", "(913) 909 - 0928", new TimestampType(), "GC", 19298943.12, .13, initialBalance, initialYTD, 3L, 15L, "Some History").getResults()[0];
// check for successful insertion.
assertEquals(1L, customer4.asScalarLong());
// make sure strings as bytes works
ClientResponse cr = client.callProcedure("Fake1", "Customer".getBytes("UTF-8"), D_ID, W_ID);
assertTrue(cr.getStatus() == ClientResponse.SUCCESS);
assertEquals(3, cr.getResults()[0].getRowCount());
cr = client.callProcedure("Fake1", "Customer", D_ID, W_ID);
assertTrue(cr.getStatus() == ClientResponse.SUCCESS);
assertEquals(3, cr.getResults()[0].getRowCount());
cr = client.callProcedure("FakeCustomerLookup", W_ID, W_ID, D_ID, "Customer".getBytes("UTF-8"));
assertTrue(cr.getStatus() == ClientResponse.SUCCESS);
} finally {
// stop execution
if (client != null) {
client.close();
}
if (localServer != null) {
localServer.shutdown();
localServer.join();
}
}
}
Aggregations