Search in sources :

Example 6 with DeploymentBuilder

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

the class TestLiveTableSchemaMigration method migrateSchemaUsingAlter.

/**
     * Assuming given tables have schema metadata, fill them with random data
     * and compare a pure-java schema migration with an EE schema migration.
     */
void migrateSchemaUsingAlter(VoltTable t1, VoltTable t2, boolean withData) throws Exception {
    ServerThread server = null;
    Client client = null;
    TableHelper helper = new TableHelper();
    try {
        String alterText = TableHelper.getAlterTableDDLToMigrate(t1, t2);
        if (withData) {
            helper.randomFill(t1, 1000, 1024);
        }
        String catPath1 = catalogPathForTable(t1, "t1.jar");
        DeploymentBuilder depBuilder = new DeploymentBuilder(1, 1, 0);
        depBuilder.setVoltRoot("/tmp/rootbar");
        depBuilder.setUseDDLSchema(true);
        // disable logging
        depBuilder.configureLogging("/tmp/foobar", "/tmp/goobar", false, false, 1, 1, 3);
        String deployment = depBuilder.getXML();
        File deploymentFile = VoltProjectBuilder.writeStringToTempFile(deployment);
        VoltDB.Configuration config = new VoltDB.Configuration();
        config.m_pathToDeployment = deploymentFile.getAbsolutePath();
        config.m_pathToCatalog = catPath1;
        config.m_ipcPort = 10000;
        //config.m_backend = BackendTarget.NATIVE_EE_IPC;
        server = new ServerThread(config);
        server.start();
        server.waitForInitialization();
        System.out.printf("PRE:  %s\n", TableHelper.ddlForTable(t1, false));
        System.out.printf("POST: %s\n", TableHelper.ddlForTable(t2, false));
        TableHelper.migrateTable(t1, t2);
        t2 = TableHelper.sortTable(t2);
        ClientConfig clientConfig = new ClientConfig();
        client = ClientFactory.createClient(clientConfig);
        client.createConnection("localhost");
        TableHelper.loadTable(client, t1);
        if (alterText.trim().length() > 0) {
            ClientResponseImpl response = (ClientResponseImpl) client.callProcedure("@AdHoc", alterText, null);
            System.out.println(response.toJSONString());
        }
        VoltTable t3 = client.callProcedure("@AdHoc", "select * from FOO").getResults()[0];
        t3 = TableHelper.sortTable(t3);
        // compare the tables
        StringBuilder sb = new StringBuilder();
        if (!TableHelper.deepEqualsWithErrorMsg(t2, t3, sb)) {
            System.out.println("Table Mismatch");
            //System.out.printf("PRE:  %s\n", t2.toFormattedString());
            //System.out.printf("POST: %s\n", t3.toFormattedString());
            System.out.println(sb.toString());
            fail();
        }
    } finally {
        if (client != null) {
            client.close();
        }
        if (server != null) {
            server.shutdown();
        }
    }
}
Also used : Configuration(org.voltdb.VoltDB.Configuration) VoltTable(org.voltdb.VoltTable) VoltDB(org.voltdb.VoltDB) ServerThread(org.voltdb.ServerThread) TableHelper(org.voltdb.TableHelper) Configuration(org.voltdb.VoltDB.Configuration) ClientResponseImpl(org.voltdb.ClientResponseImpl) Client(org.voltdb.client.Client) ClientConfig(org.voltdb.client.ClientConfig) File(java.io.File) DeploymentBuilder(org.voltdb.compiler.DeploymentBuilder)

Example 7 with DeploymentBuilder

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

the class TestClientClose method setUp.

@Override
public void setUp() {
    try {
        CatalogBuilder catBuilder = new CatalogBuilder();
        catBuilder.addSchema(getClass().getResource("clientfeatures.sql"));
        catBuilder.addProcedures(ArbitraryDurationProc.class);
        boolean success = catBuilder.compile(Configuration.getPathToCatalogForTest("timeouts.jar"));
        assert (success);
        depBuilder = new DeploymentBuilder(1, 1, 0);
        depBuilder.writeXML(Configuration.getPathToCatalogForTest("timeouts.xml"));
        VoltDB.Configuration config = new VoltDB.Configuration();
        config.m_pathToCatalog = Configuration.getPathToCatalogForTest("timeouts.jar");
        config.m_pathToDeployment = Configuration.getPathToCatalogForTest("timeouts.xml");
        localServer = new ServerThread(config);
        localServer.start();
        localServer.waitForInitialization();
        ClientFactory.m_preserveResources = false;
        while (ClientFactory.m_activeClientCount > 0) {
            try {
                ClientFactory.decreaseClientNum();
            } catch (InterruptedException e) {
            }
        }
        // The DNS cache is always initialized in the started state
        ReverseDNSCache.start();
    } catch (Exception e) {
        e.printStackTrace();
        fail();
    }
}
Also used : VoltDB(org.voltdb.VoltDB) Configuration(org.voltdb.VoltDB.Configuration) CatalogBuilder(org.voltdb.compiler.CatalogBuilder) Configuration(org.voltdb.VoltDB.Configuration) ServerThread(org.voltdb.ServerThread) DeploymentBuilder(org.voltdb.compiler.DeploymentBuilder) IOException(java.io.IOException)

Aggregations

DeploymentBuilder (org.voltdb.compiler.DeploymentBuilder)7 Configuration (org.voltdb.VoltDB.Configuration)6 IOException (java.io.IOException)5 ServerThread (org.voltdb.ServerThread)5 VoltDB (org.voltdb.VoltDB)5 File (java.io.File)4 Client (org.voltdb.client.Client)4 ClientConfig (org.voltdb.client.ClientConfig)3 ClientResponseImpl (org.voltdb.ClientResponseImpl)2 TableHelper (org.voltdb.TableHelper)2 VoltTable (org.voltdb.VoltTable)2 ProcCallException (org.voltdb.client.ProcCallException)2 CatalogBuilder (org.voltdb.compiler.CatalogBuilder)2 UnknownHostException (java.net.UnknownHostException)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 Test (org.junit.Test)1 ClientResponse (org.voltdb.client.ClientResponse)1 NoConnectionsException (org.voltdb.client.NoConnectionsException)1 UserInfo (org.voltdb.compiler.DeploymentBuilder.UserInfo)1 VoltProjectBuilder (org.voltdb.compiler.VoltProjectBuilder)1