use of org.voltdb.compiler.CatalogBuilder in project voltdb by VoltDB.
the class TestClientFeatures method testPerCallTimeout.
public void testPerCallTimeout() throws Exception {
CSL csl = new CSL();
ClientConfig config = new ClientConfig(null, null, csl, ClientAuthScheme.HASH_SHA1);
config.setProcedureCallTimeout(500);
Client client = ClientFactory.createClient(config);
client.createConnection("localhost");
ClientResponse response = client.callProcedure("ArbitraryDurationProc", 0);
assertEquals(ClientResponse.SUCCESS, response.getStatus());
try {
client.callProcedure("ArbitraryDurationProc", 3000);
fail();
} catch (ProcCallException e) {
assertTrue(e.getMessage().startsWith("No response received in the allotted time"));
}
// make sure the callback gets called
assertTrue(csl.waitForCall(6000));
if (MiscUtils.isPro()) {
// build a catalog with a ton of indexes so catalog update will be slow
CatalogBuilder builder = new CatalogBuilder();
builder.addSchema(getClass().getResource("clientfeatures-wellindexed.sql"));
builder.addProcedures(ArbitraryDurationProc.class);
byte[] catalogToUpdate = builder.compileToBytes();
assert (catalogToUpdate != null);
// make a copy of the table from ddl for loading
// (shouldn't have to do this, but for now, the table loader requires
// a VoltTable, and can't read schema. Could fix by using this VoltTable
// to generate schema or by teaching to loader how to discover tables)
TableHelper.Configuration helperConfig = new TableHelper.Configuration();
helperConfig.rand = new Random();
TableHelper helper = new TableHelper(helperConfig);
VoltTable t = TableHelper.quickTable("indexme (pkey:bigint, " + "c01:varchar63, " + "c02:varchar63, " + "c03:varchar63, " + "c04:varchar63, " + "c05:varchar63, " + "c06:varchar63, " + "c07:varchar63, " + "c08:varchar63, " + "c09:varchar63, " + "c10:varchar63) " + "PKEY(pkey)");
// get a client with a normal timout
Client client2 = ClientFactory.createClient();
client2.createConnection("localhost");
helper.fillTableWithBigintPkey(t, 400, 0, client2, 0, 1);
long start;
double duration;
// run a catalog update that *might* normally timeout
start = System.nanoTime();
response = client.callProcedure("@UpdateApplicationCatalog", catalogToUpdate, depBuilder.getXML());
duration = (System.nanoTime() - start) / 1000000000.0;
System.out.printf("Catalog update duration in seconds: %.2f\n", duration);
assertEquals(ClientResponse.SUCCESS, response.getStatus());
// run a blocking snapshot that *might* normally timeout
start = System.nanoTime();
response = client.callProcedure("@SnapshotSave", Configuration.getPathToCatalogForTest(""), "slow", 1);
duration = (System.nanoTime() - start) / 1000000000.0;
System.out.printf("Snapshot save duration in seconds: %.2f\n", duration);
assertEquals(ClientResponse.SUCCESS, response.getStatus());
}
}
use of org.voltdb.compiler.CatalogBuilder in project voltdb by VoltDB.
the class TestClientFeatures method setUp.
@Override
public void setUp() {
try {
CatalogBuilder catBuilder = new CatalogBuilder();
catBuilder.addSchema(getClass().getResource("clientfeatures.sql"));
catBuilder.addProcedures(ArbitraryDurationProc.class);
boolean success = catBuilder.compile(Configuration.getPathToCatalogForTest("timeouts.jar"));
assert (success);
depBuilder = new DeploymentBuilder(1, 1, 0);
depBuilder.writeXML(Configuration.getPathToCatalogForTest("timeouts.xml"));
VoltDB.Configuration config = new VoltDB.Configuration();
config.m_pathToCatalog = Configuration.getPathToCatalogForTest("timeouts.jar");
config.m_pathToDeployment = Configuration.getPathToCatalogForTest("timeouts.xml");
localServer = new ServerThread(config);
localServer.start();
localServer.waitForInitialization();
} catch (Exception e) {
e.printStackTrace();
fail();
}
}
use of org.voltdb.compiler.CatalogBuilder in project voltdb by VoltDB.
the class TestLiveTableSchemaMigration method catalogPathForTable.
/**
* Assuming given table has schema metadata, make a catalog containing
* that table on disk.
*/
String catalogPathForTable(VoltTable t, String jarname) throws IOException {
CatalogBuilder builder = new CatalogBuilder();
String ddl = TableHelper.ddlForTable(t, false);
builder.addLiteralSchema(ddl);
String retval = Configuration.getPathToCatalogForTest(jarname);
boolean success = builder.compile(retval);
// good spot below for a breakpoint if compiling fails
if (!success) {
fail();
}
return retval;
}
use of org.voltdb.compiler.CatalogBuilder in project voltdb by VoltDB.
the class TestClientClose method setUp.
@Override
public void setUp() {
try {
CatalogBuilder catBuilder = new CatalogBuilder();
catBuilder.addSchema(getClass().getResource("clientfeatures.sql"));
catBuilder.addProcedures(ArbitraryDurationProc.class);
boolean success = catBuilder.compile(Configuration.getPathToCatalogForTest("timeouts.jar"));
assert (success);
depBuilder = new DeploymentBuilder(1, 1, 0);
depBuilder.writeXML(Configuration.getPathToCatalogForTest("timeouts.xml"));
VoltDB.Configuration config = new VoltDB.Configuration();
config.m_pathToCatalog = Configuration.getPathToCatalogForTest("timeouts.jar");
config.m_pathToDeployment = Configuration.getPathToCatalogForTest("timeouts.xml");
localServer = new ServerThread(config);
localServer.start();
localServer.waitForInitialization();
ClientFactory.m_preserveResources = false;
while (ClientFactory.m_activeClientCount > 0) {
try {
ClientFactory.decreaseClientNum();
} catch (InterruptedException e) {
}
}
// The DNS cache is always initialized in the started state
ReverseDNSCache.start();
} catch (Exception e) {
e.printStackTrace();
fail();
}
}
use of org.voltdb.compiler.CatalogBuilder in project voltdb by VoltDB.
the class TestCatalogDiffs method getCatalogForTable.
private Catalog getCatalogForTable(String tableName, String catname, VoltTable t, boolean export) throws IOException {
CatalogBuilder builder = new CatalogBuilder();
builder.addLiteralSchema(TableHelper.ddlForTable(t, export));
String testDir = BuildDirectoryUtils.getBuildDirectoryPath();
assertTrue("Failed to compile schema", builder.compile(testDir + File.separator + "test-" + catname + ".jar"));
Catalog cat = catalogForJar(testDir + File.separator + "test-" + catname + ".jar");
return cat;
}
Aggregations