Search in sources :

Example 6 with Configuration

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

Example 7 with Configuration

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

Example 8 with Configuration

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");
}
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 9 with Configuration

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

Example 10 with Configuration

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

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