Search in sources :

Example 21 with VoltProjectBuilder

use of org.voltdb.compiler.VoltProjectBuilder in project voltdb by VoltDB.

the class TestAdhocCompilerException method testEng7653UnexpectedException.

@Test
public void testEng7653UnexpectedException() throws Exception {
    // Enables special DDL string triggering artificial exception in AsyncCompilerAgent.
    System.setProperty("asynccompilerdebug", "true");
    String pathToCatalog = Configuration.getPathToCatalogForTest("adhocddl.jar");
    String pathToDeployment = Configuration.getPathToCatalogForTest("adhocddl.xml");
    VoltProjectBuilder builder = new VoltProjectBuilder();
    builder.setUseDDLSchema(true);
    boolean success = builder.compile(pathToCatalog, 1, 1, 0);
    assertTrue("Schema compilation failed", success);
    MiscUtils.copyFile(builder.getPathToDeployment(), pathToDeployment);
    VoltDB.Configuration config = new VoltDB.Configuration();
    config.m_pathToCatalog = pathToCatalog;
    config.m_pathToDeployment = pathToDeployment;
    // Trigger an exception inside AsyncCompilerAgent
    try {
        startSystem(config);
        boolean threw = false;
        try {
            // Ten seconds should be long enough to detect a hang.
            String toxicDDL = AdHocNTBase.DEBUG_EXCEPTION_DDL + ";";
            ((ClientImpl) m_client).callProcedureWithClientTimeout(BatchTimeoutOverrideType.NO_TIMEOUT, "@AdHoc", 10, TimeUnit.SECONDS, toxicDDL);
        } catch (ProcCallException pce) {
            String message = pce.getLocalizedMessage();
            if (message.startsWith("No response received in the allotted time")) {
                // Check that a network thread didn't die.
                tryOldClientWithValidDDL();
                tryNewClientWithValidDDL();
                fail("Timeout, server was probably hung. " + message);
            }
            assertTrue(String.format("Unexpected exception message: %s...", message), message.contains(AdHocNTBase.DEBUG_EXCEPTION_DDL));
            threw = true;
        }
        assertTrue("Expected exception", threw);
    } finally {
        teardownSystem();
    }
}
Also used : Configuration(org.voltdb.VoltDB.Configuration) VoltProjectBuilder(org.voltdb.compiler.VoltProjectBuilder) Configuration(org.voltdb.VoltDB.Configuration) ClientImpl(org.voltdb.client.ClientImpl) ProcCallException(org.voltdb.client.ProcCallException) Test(org.junit.Test)

Example 22 with VoltProjectBuilder

use of org.voltdb.compiler.VoltProjectBuilder in project voltdb by VoltDB.

the class TestAdhocCreateDropIndex method createSchema.

private void createSchema(VoltDB.Configuration config, String ddl, final int sitesPerHost, final int hostCount, final int replication) throws Exception {
    VoltProjectBuilder builder = new VoltProjectBuilder();
    builder.addLiteralSchema(ddl);
    builder.setUseDDLSchema(true);
    config.m_pathToCatalog = Configuration.getPathToCatalogForTest("adhocddl.jar");
    boolean success = builder.compile(config.m_pathToCatalog, sitesPerHost, hostCount, replication);
    assertTrue("Schema compilation failed", success);
    config.m_pathToDeployment = Configuration.getPathToCatalogForTest("adhocddl.xml");
    MiscUtils.copyFile(builder.getPathToDeployment(), config.m_pathToDeployment);
}
Also used : VoltProjectBuilder(org.voltdb.compiler.VoltProjectBuilder)

Example 23 with VoltProjectBuilder

use of org.voltdb.compiler.VoltProjectBuilder in project voltdb by VoltDB.

the class TestLiveDDLSchemaSwitch method generateCatalogsAndDeployments.

void generateCatalogsAndDeployments(boolean useLiveDDL) throws Exception {
    m_pathToCatalog = Configuration.getPathToCatalogForTest("adhocddl.jar");
    m_pathToDeployment = Configuration.getPathToCatalogForTest("adhocddl.xml");
    m_pathToReplicaDeployment = Configuration.getPathToCatalogForTest("replicaadhocddl.xml");
    m_pathToOtherCatalog = Configuration.getPathToCatalogForTest("newadhocddl.jar");
    m_pathToOtherDeployment = Configuration.getPathToCatalogForTest("newadhocddl.xml");
    m_pathToOtherReplicaDeployment = Configuration.getPathToCatalogForTest("newreplicaadhocddl.xml");
    VoltProjectBuilder builder = new VoltProjectBuilder();
    builder.addLiteralSchema("create table FOO (" + "ID integer not null," + "VAL bigint, " + "constraint PK_TREE primary key (ID)" + ");\n" + "create table FOO_R (" + "ID integer not null," + "VAL bigint, " + "constraint PK_TREE_R primary key (ID)" + ");\n");
    builder.addPartitionInfo("FOO", "ID");
    builder.setUseDDLSchema(useLiveDDL);
    // fake DR connection so that replica can start
    builder.setDRMasterHost("localhost");
    boolean success = builder.compile(m_pathToCatalog, 2, 1, 0);
    assertTrue("Schema compilation failed", success);
    MiscUtils.copyFile(builder.getPathToDeployment(), m_pathToDeployment);
    builder.setDrReplica();
    success = builder.compile(m_pathToCatalog, 2, 1, 0);
    assertTrue("Schema compilation failed", success);
    MiscUtils.copyFile(builder.getPathToDeployment(), m_pathToReplicaDeployment);
    // get an alternate deployment file
    builder = new VoltProjectBuilder();
    builder.addLiteralSchema("create table BAZ (" + "ID integer not null," + "VAL bigint, " + "constraint PK_TREE primary key (ID)" + ");\n" + "create table FOO_R (" + "ID integer not null," + "VAL bigint, " + "constraint PK_TREE_R primary key (ID)" + ");\n");
    builder.addPartitionInfo("BAZ", "ID");
    builder.setUseDDLSchema(useLiveDDL);
    builder.setDRMasterHost("localhost");
    builder.setDeadHostTimeout(6);
    success = builder.compile(m_pathToOtherCatalog, 2, 1, 0);
    assertTrue("2nd schema compilation failed", success);
    MiscUtils.copyFile(builder.getPathToDeployment(), m_pathToOtherDeployment);
    builder.setDrReplica();
    success = builder.compile(m_pathToOtherCatalog, 2, 1, 0);
    assertTrue("2nd schema compilation failed", success);
    MiscUtils.copyFile(builder.getPathToDeployment(), m_pathToOtherReplicaDeployment);
}
Also used : VoltProjectBuilder(org.voltdb.compiler.VoltProjectBuilder)

Example 24 with VoltProjectBuilder

use of org.voltdb.compiler.VoltProjectBuilder in project voltdb by VoltDB.

the class TestNTProcs method testRunEverywhereNTRoundTripCluster.

public void testRunEverywhereNTRoundTripCluster() throws Exception {
    VoltProjectBuilder pb = new VoltProjectBuilder();
    pb.addLiteralSchema(SCHEMA);
    LocalCluster cluster = new LocalCluster("compileNT.jar", 4, 3, 1, BackendTarget.NATIVE_EE_JNI);
    boolean success = cluster.compile(pb);
    assertTrue(success);
    cluster.startUp();
    Client client = ClientFactory.createClient();
    client.createConnection(cluster.getListenerAddress(0));
    ClientResponseImpl response;
    response = (ClientResponseImpl) client.callProcedure("TestNTProcs$RunEverywhereNTProc");
    assertEquals(ClientResponse.SUCCESS, response.getStatus());
    System.out.println("Client got trivial response");
    System.out.println(response.toJSONString());
    // CHECK STATS
    VoltTable statsT = getStats(client, "PROCEDURE");
    assertTrue(VoltTableUtil.tableContainsString(statsT, "RunEverywhereNTProc", true));
    assertTrue(VoltTableUtil.tableContainsString(statsT, "TrivialNTProcPriority", true));
    Map<String, Long> stats = aggregateProcRow(client, RunEverywhereNTProc.class.getName());
    assertEquals(1, stats.get("INVOCATIONS").longValue());
    stats = aggregateProcRow(client, TrivialNTProcPriority.class.getName());
    assertEquals(3, stats.get("INVOCATIONS").longValue());
    client.close();
    cluster.shutDown();
}
Also used : LocalCluster(org.voltdb.regressionsuites.LocalCluster) VoltProjectBuilder(org.voltdb.compiler.VoltProjectBuilder) AtomicLong(java.util.concurrent.atomic.AtomicLong) Client(org.voltdb.client.Client)

Example 25 with VoltProjectBuilder

use of org.voltdb.compiler.VoltProjectBuilder in project voltdb by VoltDB.

the class TestNTProcs method compile.

private void compile() throws Exception {
    VoltProjectBuilder pb = new VoltProjectBuilder();
    pb.addLiteralSchema(SCHEMA);
    assertTrue(pb.compile(Configuration.getPathToCatalogForTest("compileNT.jar")));
    MiscUtils.copyFile(pb.getPathToDeployment(), Configuration.getPathToCatalogForTest("compileNT.xml"));
}
Also used : VoltProjectBuilder(org.voltdb.compiler.VoltProjectBuilder)

Aggregations

VoltProjectBuilder (org.voltdb.compiler.VoltProjectBuilder)269 Configuration (org.voltdb.VoltDB.Configuration)89 IOException (java.io.IOException)49 Test (org.junit.Test)45 File (java.io.File)40 ProcCallException (org.voltdb.client.ProcCallException)38 ClientResponse (org.voltdb.client.ClientResponse)37 VoltDB (org.voltdb.VoltDB)22 LocalCluster (org.voltdb.regressionsuites.LocalCluster)18 Client (org.voltdb.client.Client)17 Before (org.junit.Before)14 HashMap (java.util.HashMap)13 VoltTable (org.voltdb.VoltTable)13 ServerThread (org.voltdb.ServerThread)12 InMemoryJarfile (org.voltdb.utils.InMemoryJarfile)12 VoltCompiler (org.voltdb.compiler.VoltCompiler)11 HttpResponse (org.apache.http.HttpResponse)10 BeforeClass (org.junit.BeforeClass)8 ClientConfig (org.voltdb.client.ClientConfig)7 UserInfo (org.voltdb.compiler.VoltProjectBuilder.UserInfo)7