use of org.voltdb.VoltDB.Configuration in project voltdb by VoltDB.
the class TestInitStartAction method testInitWithClassesAndArtifacts.
/** Tests that when there are base classes and non-class files in the stored procedures,
* that these also exist in the staged catalog.
* @throws Exception upon failure or error
*/
@Test
public void testInitWithClassesAndArtifacts() throws Exception {
System.out.println("Loading the schema from testprocs");
File resource = new File("tests/testprocs/org/voltdb_testprocs/fakeusecase/greetings/ddl.sql");
InputStream schemaReader = new FileInputStream(resource);
assertNotNull("Could not find " + resource, schemaReader);
String schema = CharStreams.toString(new InputStreamReader(schemaReader));
System.out.println("Creating a .jar file using all of the classes associated with this test.");
InMemoryJarfile originalInMemoryJar = new InMemoryJarfile();
VoltCompiler compiler = new VoltCompiler(false, false);
ClassPath classpath = ClassPath.from(this.getClass().getClassLoader());
String packageName = "org.voltdb_testprocs.fakeusecase.greetings";
int classesFound = 0;
for (ClassInfo myclass : classpath.getTopLevelClassesRecursive(packageName)) {
compiler.addClassToJar(originalInMemoryJar, myclass.load());
classesFound++;
}
// check that classes were found and loaded. If another test modifies "fakeusecase.greetings" it should modify this assert also.
assertEquals(5, classesFound);
System.out.println("Writing " + classesFound + " classes to jar file");
File classesJarfile = File.createTempFile("TestInitStartWithClasses-procedures", ".jar");
classesJarfile.deleteOnExit();
originalInMemoryJar.writeToFile(classesJarfile);
Configuration c1 = new Configuration(new String[] { "initialize", "voltdbroot", rootDH.getPath(), "force", "schema", resource.getPath(), "classes", classesJarfile.getPath() });
ServerThread server = new ServerThread(c1);
server.setUncaughtExceptionHandler(handleUncaught);
server.start();
server.join();
validateStagedCatalog(schema, originalInMemoryJar);
}
use of org.voltdb.VoltDB.Configuration in project voltdb by VoltDB.
the class TestJDBCLoader 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, " + "PRIMARY KEY(clm_integer) " + ");\n" + "create table JBLAH (" + "clm_integer integer not null, " + "clm_tinyint tinyint default 0, " + "clm_smallint smallint default 0, " + "clm_bigint bigint default 0, " + "clm_string varchar(16) default null, " + "clm_decimal decimal default null, " + "clm_float float default null, " + "clm_timestamp timestamp default null, " + "PRIMARY KEY(clm_integer) " + ");");
builder.addPartitionInfo("BLAH", "clm_integer");
builder.addPartitionInfo("JBLAH", "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 LocalSingleProcessServer method startUp.
@Override
public void startUp(boolean clearLocalDataDirectories) {
VoltServerConfig.addInstance(this);
if (clearLocalDataDirectories) {
File exportOverflow = new File(m_pathToVoltRoot, "export_overflow");
if (exportOverflow.exists()) {
assert (exportOverflow.isDirectory());
for (File f : exportOverflow.listFiles()) {
if (f.isFile() && f.getName().endsWith(".pbd") || f.getName().endsWith(".ad")) {
f.delete();
}
}
}
}
Configuration config = new Configuration();
config.m_backend = m_target;
config.m_noLoadLibVOLTDB = (m_target == BackendTarget.HSQLDB_BACKEND);
// m_jarFileName is already prefixed with test output path.
config.m_pathToCatalog = m_jarFileName;
config.m_pathToDeployment = m_pathToDeployment;
config.m_startAction = StartAction.CREATE;
config.m_isPaused = m_paused;
if (m_adminPort != -1) {
config.m_adminPort = m_adminPort;
}
m_siteProcess = new EEProcess(m_target, m_siteCount, "LocalSingleProcessServer.log");
config.m_ipcPort = m_siteProcess.port();
m_server = new ServerThread(config);
m_server.start();
m_server.waitForInitialization();
}
use of org.voltdb.VoltDB.Configuration in project voltdb by VoltDB.
the class TestInitStartLocalClusterAllOutOfProcess 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 TestInitStartLocalClusterAllOutOfProcess 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)"));
}
Aggregations