use of org.voltdb.client.ClientResponse in project voltdb by VoltDB.
the class TestBlobType method testBigFatBlobs.
public void testBigFatBlobs() throws Exception {
String simpleSchema = "create table blah (" + "ival bigint default 0 not null, " + "b varbinary(256) default null, " + "s varchar(256) default null, " + "PRIMARY KEY(ival));";
VoltProjectBuilder builder = new VoltProjectBuilder();
builder.addLiteralSchema(simpleSchema);
builder.addProcedures(BigFatBlobAndStringMD5.class);
boolean success = builder.compile(Configuration.getPathToCatalogForTest("bigfatblobs.jar"), 1, 1, 0);
assertTrue("Failed to compile catalog", success);
MiscUtils.copyFile(builder.getPathToDeployment(), Configuration.getPathToCatalogForTest("bigfatblobs.xml"));
VoltDB.Configuration config = new VoltDB.Configuration();
config.m_pathToCatalog = Configuration.getPathToCatalogForTest("bigfatblobs.jar");
config.m_pathToDeployment = Configuration.getPathToCatalogForTest("bigfatblobs.xml");
config.m_backend = BackendTarget.NATIVE_EE_JNI;
ServerThread localServer = null;
Client client = null;
try {
localServer = new ServerThread(config);
localServer.start();
localServer.waitForInitialization();
client = ClientFactory.createClient();
client.createConnection("localhost");
byte[] b = new byte[5000000];
char[] c = new char[5000000];
for (int i = 0; i < b.length; i++) {
b[i] = (byte) (i % 256);
c[i] = (char) (i % 128);
}
String s = new String(c);
ClientResponse cr = client.callProcedure("BigFatBlobAndStringMD5", b, s);
assertEquals(ClientResponse.SUCCESS, cr.getStatus());
VoltTable t = cr.getResults()[0];
assertEquals(1, t.getRowCount());
assertTrue(t.advanceRow());
// Validate MD5 sums instead of the actual data. The returned VoltTable
// can't hold it anyway due to a 1 MB limit.
MessageDigest md5 = MessageDigest.getInstance("MD5");
assertTrue(Arrays.equals(md5.digest(b), t.getVarbinary("b_md5")));
assertTrue(Arrays.equals(md5.digest(s.getBytes()), t.getVarbinary("s_md5")));
} finally {
// stop execution
if (client != null) {
client.close();
}
if (localServer != null) {
localServer.shutdown();
localServer.join();
}
}
}
use of org.voltdb.client.ClientResponse in project voltdb by VoltDB.
the class TestCSVLoader method tearDown.
@After
public void tearDown() throws IOException, ProcCallException {
final ClientResponse response = client.callProcedure("@AdHoc", "TRUNCATE TABLE BLAH;");
assertEquals(ClientResponse.SUCCESS, response.getStatus());
}
use of org.voltdb.client.ClientResponse in project voltdb by VoltDB.
the class TestJDBCLoader method setup.
@Before
public void setup() throws IOException, ProcCallException {
ClientResponse response = client.callProcedure("@AdHoc", "SELECT COUNT(*) FROM BLAH;");
assertEquals(0, response.getResults()[0].asScalarLong());
response = client.callProcedure("@AdHoc", "SELECT COUNT(*) FROM JBLAH;");
assertEquals(0, response.getResults()[0].asScalarLong());
}
use of org.voltdb.client.ClientResponse in project voltdb by VoltDB.
the class DeletesClient method performSnapshot.
public static void performSnapshot(Client client) {
checkSnapshotComplete(client);
if (m_snapshotInProgress) {
System.out.println("Snapshot still in progress, bailing");
return;
}
try {
VoltTable[] results = client.callProcedure("@SnapshotDelete", new String[] { m_snapshotDir }, new String[] { m_snapshotId }).getResults();
} catch (NoConnectionsException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (ProcCallException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
// m_totalRows should be accurate at this point
m_snapshotSizes.add(m_totalRows);
System.out.println("Performing Snapshot with total rows: " + m_totalRows);
try {
if (m_blockingSnapshots) {
ClientResponse response = client.callProcedure("@SnapshotSave", m_snapshotDir, m_snapshotId, 1);
if (response.getStatus() != ClientResponse.SUCCESS) {
System.out.println("failed snapshot");
System.out.println(response.getStatusString());
}
} else {
client.callProcedure(new ProcedureCallback() {
@Override
public void clientCallback(ClientResponse response) {
if (response.getStatus() != ClientResponse.SUCCESS) {
System.out.println("failed snapshot");
System.out.println(response.getStatusString());
}
}
}, "@SnapshotSave", m_snapshotDir, m_snapshotId, 0);
}
} catch (NoConnectionsException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ProcCallException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
use of org.voltdb.client.ClientResponse in project voltdb by VoltDB.
the class DeletesClient method collectStats.
static void collectStats(Client client) {
try {
ClientResponse resp = client.callProcedure("@Statistics", "management", 0);
parseStats(resp);
} catch (NoConnectionsException e) {
System.err.println("Lost connection to database, terminating");
System.exit(-1);
} catch (IOException e) {
e.printStackTrace();
} catch (ProcCallException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Aggregations