Search in sources :

Example 11 with Configuration

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);
}
Also used : ClassPath(com.google_voltpatches.common.reflect.ClassPath) VoltCompiler(org.voltdb.compiler.VoltCompiler) InputStreamReader(java.io.InputStreamReader) Configuration(org.voltdb.VoltDB.Configuration) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) InMemoryJarfile(org.voltdb.utils.InMemoryJarfile) VoltFile(org.voltdb.utils.VoltFile) File(java.io.File) FileInputStream(java.io.FileInputStream) ClassInfo(com.google_voltpatches.common.reflect.ClassPath.ClassInfo) Test(org.junit.Test)

Example 12 with Configuration

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");
}
Also used : Configuration(org.voltdb.VoltDB.Configuration) VoltProjectBuilder(org.voltdb.compiler.VoltProjectBuilder) ServerThread(org.voltdb.ServerThread) ClientConfig(org.voltdb.client.ClientConfig) BeforeClass(org.junit.BeforeClass)

Example 13 with Configuration

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();
}
Also used : Configuration(org.voltdb.VoltDB.Configuration) ServerThread(org.voltdb.ServerThread) File(java.io.File)

Example 14 with Configuration

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);
}
Also used : Configuration(org.voltdb.VoltDB.Configuration) InMemoryJarfile(org.voltdb.utils.InMemoryJarfile) ServerThread(org.voltdb.ServerThread) File(java.io.File)

Example 15 with Configuration

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)"));
}
Also used : Configuration(org.voltdb.VoltDB.Configuration) ServerThread(org.voltdb.ServerThread) File(java.io.File)

Aggregations

Configuration (org.voltdb.VoltDB.Configuration)15 File (java.io.File)13 ServerThread (org.voltdb.ServerThread)9 Test (org.junit.Test)6 VoltFile (org.voltdb.utils.VoltFile)6 SimulatedExitException (org.voltdb.VoltDB.SimulatedExitException)3 InMemoryJarfile (org.voltdb.utils.InMemoryJarfile)3 BeforeClass (org.junit.BeforeClass)2 ClientConfig (org.voltdb.client.ClientConfig)2 VoltProjectBuilder (org.voltdb.compiler.VoltProjectBuilder)2 DeploymentType (org.voltdb.compiler.deploymentfile.DeploymentType)2 ClassPath (com.google_voltpatches.common.reflect.ClassPath)1 ClassInfo (com.google_voltpatches.common.reflect.ClassPath.ClassInfo)1 FileInputStream (java.io.FileInputStream)1 FileOutputStream (java.io.FileOutputStream)1 InputStream (java.io.InputStream)1 InputStreamReader (java.io.InputStreamReader)1 VoltCompiler (org.voltdb.compiler.VoltCompiler)1