use of org.voltdb.VoltDB.Configuration in project voltdb by VoltDB.
the class TestInitStartLocalClusterInProcess method getProcJarFromCatalog.
InMemoryJarfile getProcJarFromCatalog() throws IOException {
File jar = File.createTempFile("procedure", ".jar");
Configuration config = new VoltDB.Configuration(new String[] { "get", "classes", "getvoltdbroot", voltDBRootParentPath, "file", jar.getAbsolutePath(), "forceget" });
ServerThread server = new ServerThread(config);
try {
server.cli();
} catch (Throwable ex) {
//Good
}
byte[] bytesRead = Files.readAllBytes(Paths.get(jar.getAbsolutePath()));
assertNotNull(bytesRead);
assertTrue(bytesRead.length > 0);
return new InMemoryJarfile(bytesRead);
}
use of org.voltdb.VoltDB.Configuration in project voltdb by VoltDB.
the class TestInitStartLocalClusterInProcess method testGetSchema.
// Test get schema
public void testGetSchema() throws Exception {
File schema = File.createTempFile("schema", ".sql");
Configuration config = new VoltDB.Configuration(new String[] { "get", "schema", "getvoltdbroot", voltDBRootParentPath, "file", schema.getAbsolutePath(), "forceget" });
ServerThread server = new ServerThread(config);
try {
server.cli();
} catch (Throwable ex) {
//Good
}
byte[] encoded = Files.readAllBytes(Paths.get(schema.getAbsolutePath()));
assertNotNull(encoded);
assertTrue(encoded.length > 0);
String ddl = new String(encoded, StandardCharsets.UTF_8);
assertTrue(ddl.toLowerCase().contains("create table blah ("));
assertTrue(ddl.toLowerCase().contains("ival bigint default '0' not null"));
assertTrue(ddl.toLowerCase().contains("primary key (ival)"));
}
use of org.voltdb.VoltDB.Configuration in project voltdb by VoltDB.
the class TestCSVLoader method startDatabase.
@BeforeClass
public static void startDatabase() throws Exception {
prepare();
String pathToCatalog = Configuration.getPathToCatalogForTest("csv.jar");
String pathToDeployment = Configuration.getPathToCatalogForTest("csv.xml");
VoltProjectBuilder builder = new VoltProjectBuilder();
builder.addLiteralSchema("create table BLAH (" + "clm_integer integer not null, " + "clm_tinyint tinyint default 0, " + "clm_smallint smallint default 0, " + "clm_bigint bigint default 0, " + "clm_string varchar(20) default null, " + "clm_decimal decimal default null, " + "clm_float float default null, " + "clm_timestamp timestamp default null, " + "clm_point geography_point default null, " + "clm_geography geography default null, " + "PRIMARY KEY(clm_integer) " + ");");
builder.addPartitionInfo("BLAH", "clm_integer");
boolean success = builder.compile(pathToCatalog, 2, 1, 0);
assertTrue(success);
MiscUtils.copyFile(builder.getPathToDeployment(), pathToDeployment);
Configuration config = new Configuration();
config.m_pathToCatalog = pathToCatalog;
config.m_pathToDeployment = pathToDeployment;
localServer = new ServerThread(config);
client = null;
localServer.start();
localServer.waitForInitialization();
client = ClientFactory.createClient(new ClientConfig());
client.createConnection("localhost");
}
use of org.voltdb.VoltDB.Configuration in project voltdb by VoltDB.
the class TestInitStartAction method testInitWithSchemaValidWithProcedures.
/** Test that a valid schema with procedures can be used to stage a matching catalog,
* but running a second time without 'init --force' fails due to existing artifacts.
* @throws Exception upon failure or error
*/
@Test
public void testInitWithSchemaValidWithProcedures() throws Exception {
String schema = "create table books" + " (cash integer default 23 not null," + " title varchar(3) default 'foo'," + " PRIMARY KEY(cash));" + "PARTITION TABLE books ON COLUMN cash;" + "CREATE PROCEDURE FROM CLASS org.voltdb.compiler.procedures.AddBook;";
File schemaFile = VoltProjectBuilder.writeStringToTempFile(schema);
{
// valid use case
Configuration c1 = new Configuration(new String[] { "initialize", "force", "voltdbroot", rootDH.getPath(), "schema", schemaFile.getPath() });
ServerThread server = new ServerThread(c1);
server.setUncaughtExceptionHandler(handleUncaught);
server.start();
server.join();
expectSimulatedExit(0);
validateStagedCatalog(schema, null);
clearCrash();
}
try {
// second attempt is not valid due to existing artifacts
new Configuration(new String[] { "initialize", "voltdbroot", rootDH.getPath(), "schema", schemaFile.getPath() });
} catch (SimulatedExitException e) {
assertEquals(e.getStatus(), -1);
}
assertEquals(true, schemaFile.delete());
}
use of org.voltdb.VoltDB.Configuration in project voltdb by VoltDB.
the class TestInitStartAction method testInitWithSchemaValidNoProcedures.
/** Test that a valid schema with no procedures can be used to stage a matching catalog.
* @throws Exception upon failure or error
*/
@Test
public void testInitWithSchemaValidNoProcedures() throws Exception {
final String schema = "create table books (cash integer default 23 not null, title varchar(3) default 'foo', PRIMARY KEY(cash));" + "create procedure Foo as select * from books;\n" + "PARTITION TABLE books ON COLUMN cash;";
File schemaFile = VoltProjectBuilder.writeStringToTempFile(schema);
Configuration c1 = new Configuration(new String[] { "initialize", "voltdbroot", rootDH.getPath(), "force", "schema", schemaFile.getPath() });
ServerThread server = new ServerThread(c1);
server.setUncaughtExceptionHandler(handleUncaught);
server.start();
server.join();
expectSimulatedExit(0);
validateStagedCatalog(schema, null);
assertEquals(true, schemaFile.delete());
}
Aggregations