use of org.voltdb.client.ProcCallException in project voltdb by VoltDB.
the class BidGenerator method getMaxBidId.
/**
* Find the current highest bid id in the bids table. We'll start generating
* new bids at this number plus one.
* @param client A connection to the database
* @return current highest bid id
*/
private static long getMaxBidId(Client client) {
long currentMaxBidId = 0;
try {
VoltTable vt = client.callProcedure("@AdHoc", "select max(id) from bids").getResults()[0];
vt.advanceRow();
currentMaxBidId = vt.getLong(0);
if (vt.wasNull()) {
currentMaxBidId = 0;
}
} catch (IOException | ProcCallException e) {
e.printStackTrace();
}
return currentMaxBidId;
}
use of org.voltdb.client.ProcCallException in project voltdb by VoltDB.
the class JDBCVoltVerifier method processRows.
/**
* compare each column in a batch of rows, batches are processed by this query:
* select * from export_mirror_partitioned_table where rowid between ? and ? order by rowid limit ?
* @param rvr
* @param client
* @param jdbcclient
* @return
*/
public static boolean processRows(ReadVoltRows rvr, Client client, Connection jdbcclient) {
int batchSize = 200;
long rowid = 0;
long rowCount = 0;
VoltTable v = null;
boolean checkStatus = true;
do {
try {
v = rvr.readSomeRows(rowid, batchSize);
} catch (IOException | ProcCallException e) {
e.printStackTrace();
}
rowCount = v.getRowCount();
rowid += batchSize;
rowCheckTotal += rowCount;
if (rowCount > 0) {
checkStatus = rvr.checkTable(v, jdbcclient);
// Fail fast
if (!checkStatus && FAILFAST) {
break;
}
}
System.out.println("Current row id: " + rowid);
} while (rowCount > 0);
return checkStatus;
}
use of org.voltdb.client.ProcCallException in project voltdb by VoltDB.
the class LogAnalyzer method analyzeOperation.
public void analyzeOperation(String name) {
int seconds = 10;
long minuteBeforeNow = System.currentTimeMillis() - seconds * 1000;
ClientResponse response = null;
try {
response = m_voltClient.callProcedure("FetchLogRowsProcedure", minuteBeforeNow, name);
} catch (ProcCallException | IOException e) {
System.out.println("Error executing analyzer stmt: " + e.getMessage());
e.printStackTrace();
return;
}
if (response.getStatus() != ClientResponse.SUCCESS) {
System.out.println("Procedure execution failed with status " + response.getStatus());
return;
}
VoltTable[] results = response.getResults();
if (results.length == 0 || results[0].getRowCount() == 0) {
System.out.println("No entries found for " + name + " in the last " + seconds + " seconds");
return;
}
int count = 0;
long totalTime = 0;
int min = 0;
int max = 0;
System.out.println("rowCount=" + results[0].getRowCount());
for (int i = 0; i < results[0].getRowCount(); i++) {
VoltTableRow row = results[0].fetchRow(i);
int time = getTimeFromLogMesg((String) row.get(0, VoltType.STRING));
if (time >= 0) {
min = Math.min(min, time);
max = Math.max(max, time);
totalTime += time;
count++;
}
}
if (count == 0) {
System.out.println("No good log entries found for " + name + " in the last " + seconds + " seconds");
} else {
System.out.println(String.format("Operation time for %s in the last %d seconds: min=%d, max=%d, avg=%f", name, seconds, min, max, totalTime * 1.0 / count));
}
}
use of org.voltdb.client.ProcCallException in project voltdb by VoltDB.
the class TestUpdateClasses method testRoleControl.
@Test
public void testRoleControl() throws Exception {
System.out.println("\n\n-----\n testRoleControl \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);
RoleInfo[] groups = new RoleInfo[] { new RoleInfo("adhoc", true, false, false, false, false, false) };
UserInfo[] users = new UserInfo[] { new UserInfo("adhocuser", "adhocuser", new String[] { "adhoc" }), new UserInfo("sysuser", "sysuser", new String[] { "ADMINISTRATOR" }) };
builder.addRoles(groups);
builder.addUsers(users);
// Test defines its own ADMIN user
builder.setSecurityEnabled(true, false);
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);
}
Client auth_client = null;
try {
VoltDB.Configuration config = new VoltDB.Configuration();
config.m_pathToCatalog = pathToCatalog;
config.m_pathToDeployment = pathToDeployment;
// Default client auth is going to fail, catch and keep chugging
try {
startSystem(config);
} catch (IOException ioe) {
assertTrue(ioe.getMessage().contains("Authentication rejected"));
}
m_client.close();
// reconnect m_client with auth that will connect but no sysproc powers
ClientConfig bad_config = new ClientConfig("adhocuser", "adhocuser");
m_client = ClientFactory.createClient(bad_config);
m_client.createConnection("localhost");
// Need a client with the right auth
ClientConfig auth_config = new ClientConfig("sysuser", "sysuser");
auth_client = ClientFactory.createClient(auth_config);
auth_client.createConnection("localhost");
ClientResponse resp;
resp = auth_client.callProcedure("@SystemCatalog", "CLASSES");
System.out.println(resp.getResults()[0]);
// New cluster, you're like summer vacation...
assertEquals(0, resp.getResults()[0].getRowCount());
assertFalse(VoltTableTestHelpers.moveToMatchingRow(resp.getResults()[0], "CLASS_NAME", PROC_CLASSES[0].getCanonicalName()));
boolean threw = false;
try {
resp = auth_client.callProcedure(PROC_CLASSES[0].getSimpleName());
} catch (ProcCallException pce) {
assertTrue(pce.getMessage().contains("was not found"));
threw = true;
}
assertTrue(threw);
threw = false;
try {
resp = m_client.callProcedure("@UpdateClasses", jarfile.getFullJarBytes(), null);
} catch (ProcCallException pce) {
assertTrue(pce.getMessage().contains("does not have admin permission"));
threw = true;
}
assertTrue(threw);
resp = auth_client.callProcedure("@UpdateClasses", jarfile.getFullJarBytes(), null);
assertEquals(ClientResponse.SUCCESS, resp.getStatus());
// Are we still like summer vacation?
resp = auth_client.callProcedure("@SystemCatalog", "CLASSES");
VoltTable results = resp.getResults()[0];
System.out.println(results);
assertEquals(3, results.getRowCount());
assertTrue(VoltTableTestHelpers.moveToMatchingRow(results, "CLASS_NAME", PROC_CLASSES[0].getCanonicalName()));
assertEquals(1L, results.getLong("VOLT_PROCEDURE"));
assertEquals(0L, results.getLong("ACTIVE_PROC"));
} finally {
if (auth_client != null) {
auth_client.close();
}
teardownSystem();
}
}
use of org.voltdb.client.ProcCallException in project voltdb by VoltDB.
the class TestUpdateClasses method testBasic.
@Test
public void testBasic() throws Exception {
System.out.println("\n\n-----\n testBasic \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);
}
// Add a deployment file just to have something other than classes in the jar
jarfile.put("deployment.xml", new File(pathToDeployment));
try {
VoltDB.Configuration config = new VoltDB.Configuration();
config.m_pathToCatalog = pathToCatalog;
config.m_pathToDeployment = pathToDeployment;
startSystem(config);
ClientResponse resp;
resp = m_client.callProcedure("@SystemCatalog", "CLASSES");
System.out.println(resp.getResults()[0]);
// New cluster, you're like summer vacation...
assertEquals(0, resp.getResults()[0].getRowCount());
assertFalse(VoltTableTestHelpers.moveToMatchingRow(resp.getResults()[0], "CLASS_NAME", PROC_CLASSES[0].getCanonicalName()));
boolean threw = false;
try {
resp = m_client.callProcedure(PROC_CLASSES[0].getSimpleName());
} catch (ProcCallException pce) {
assertTrue(pce.getMessage().contains("was not found"));
threw = true;
}
assertTrue(threw);
// First, some tests of incorrect parameters
// only 1 param
threw = false;
try {
resp = m_client.callProcedure("@UpdateClasses", jarfile.getFullJarBytes());
} catch (ProcCallException pce) {
assertTrue(pce.getMessage().contains("UpdateClasses system procedure requires exactly two parameters"));
threw = true;
}
assertTrue(threw);
// wrong jarfile param type
threw = false;
try {
resp = m_client.callProcedure("@UpdateClasses", 10L, null);
} catch (ProcCallException pce) {
assertTrue(pce.getMessage().contains("UpdateClasses system procedure takes the jarfile bytes as a byte array"));
threw = true;
}
assertTrue(threw);
// wrong delete string param type
threw = false;
try {
resp = m_client.callProcedure("@UpdateClasses", jarfile.getFullJarBytes(), 10L);
} catch (ProcCallException pce) {
assertTrue(pce.getMessage().contains("UpdateClasses system procedure takes the list of classes"));
threw = true;
}
assertTrue(threw);
resp = m_client.callProcedure("@UpdateClasses", jarfile.getFullJarBytes(), null);
System.out.println(((ClientResponseImpl) resp).toJSONString());
// Are we still like summer vacation?
resp = m_client.callProcedure("@SystemCatalog", "CLASSES");
VoltTable results = resp.getResults()[0];
System.out.println(results);
assertEquals(3, results.getRowCount());
assertTrue(VoltTableTestHelpers.moveToMatchingRow(results, "CLASS_NAME", PROC_CLASSES[0].getCanonicalName()));
assertEquals(1L, results.getLong("VOLT_PROCEDURE"));
assertEquals(0L, results.getLong("ACTIVE_PROC"));
// Can we turn it into a procedure?
resp = m_client.callProcedure("@AdHoc", "create procedure from class " + PROC_CLASSES[0].getCanonicalName() + ";");
System.out.println(((ClientResponseImpl) resp).toJSONString());
resp = m_client.callProcedure(PROC_CLASSES[0].getSimpleName());
assertEquals(ClientResponse.SUCCESS, resp.getStatus());
results = resp.getResults()[0];
assertEquals(10L, results.asScalarLong());
} finally {
teardownSystem();
}
}
Aggregations