Package org.voltdb

Examples of org.voltdb.ServerThread


        VoltDB.Configuration config = new VoltDB.Configuration();
        config.m_pathToCatalog = Configuration.getPathToCatalogForTest("bigfatblobs.jar");
        config.m_pathToDeployment = Configuration.getPathToCatalogForTest("bigfatblobs.xml");
        config.m_backend = BackendTarget.NATIVE_EE_JNI;

        ServerThread localServer = null;
        Client client = null;

        try {
            localServer = new ServerThread(config);
            localServer.start();
            localServer.waitForInitialization();

            client = ClientFactory.createClient();
            client.createConnection("localhost");

            byte[] b = new byte[5000000];
            char[] c = new char[5000000];
            for (int i = 0; i < b.length; i++) {
                b[i] = (byte) (i % 256);
                c[i] = (char) (i % 128);
            }
            String s = new String(c);
            ClientResponse cr = client.callProcedure("BigFatBlobAndStringMD5", b, s);
            assertEquals(ClientResponse.SUCCESS, cr.getStatus());
            VoltTable t = cr.getResults()[0];
            assertEquals(1, t.getRowCount());
            assertTrue(t.advanceRow());
            // Validate MD5 sums instead of the actual data. The returned VoltTable
            // can't hold it anyway due to a 1 MB limit.
            MessageDigest md5 = MessageDigest.getInstance("MD5");
            assertTrue(Arrays.equals(md5.digest(b), t.getVarbinary("b_md5")));
            assertTrue(Arrays.equals(md5.digest(s.getBytes()), t.getVarbinary("s_md5")));
        }
        finally {
            // stop execution
            if (client != null) {
                client.close();
            }
            if (localServer != null) {
                localServer.shutdown();
                localServer.join();
            }
        }
    }
View Full Code Here


    /**
     * Assuming given tables have schema metadata, fill them with random data
     * and compare a pure-java schema migration with an EE schema migration.
     */
    void migrateSchema(VoltTable t1, VoltTable t2, boolean withData) throws Exception {
        ServerThread server = null;
        Client client = null;

        try {
            if (withData) {
                TableHelper.randomFill(t1, 1000, 1024, new Random(0));
            }

            String catPath1 = catalogPathForTable(t1, "t1.jar");
            String catPath2 = catalogPathForTable(t2, "t2.jar");
            byte[] catBytes2 = MiscUtils.fileToBytes(new File(catPath2));

            DeploymentBuilder depBuilder = new DeploymentBuilder(1, 1, 0);
            depBuilder.setVoltRoot("/tmp/foobar");
            // disable logging
            depBuilder.configureLogging("/tmp/foobar", "/tmp/foobar", 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));
            System.out.printf("POST: %s\n", TableHelper.ddlForTable(t2));

            ClientConfig clientConfig = new ClientConfig();
            client = ClientFactory.createClient(clientConfig);
            client.createConnection("localhost");

            TableHelper.loadTable(client, t1);

            ClientResponseImpl response = (ClientResponseImpl) client.callProcedure(
                    "@UpdateApplicationCatalog", catBytes2, null);
            System.out.println(response.toJSONString());

            VoltTable t3 = client.callProcedure("@AdHoc", "select * from FOO").getResults()[0];
            t3 = TableHelper.sortTable(t3);

            // compute the migrated table entirely in Java for comparison purposes
            TableHelper.migrateTable(t1, t2);
            t2 = TableHelper.sortTable(t2);

            // 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();
            }
        }
    }
View Full Code Here

     * 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;

        try {
            String alterText = TableHelper.getAlterTableDDLToMigrate(t1, t2);

            if (withData) {
                TableHelper.randomFill(t1, 1000, 1024, new Random(0));
            }

            String catPath1 = catalogPathForTable(t1, "t1.jar");

            DeploymentBuilder depBuilder = new DeploymentBuilder(1, 1, 0);
            depBuilder.setVoltRoot("/tmp/foobar");
            depBuilder.setUseDDLSchema(true);
            // disable logging
            depBuilder.configureLogging("/tmp/foobar", "/tmp/foobar", 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));
            System.out.printf("POST: %s\n", TableHelper.ddlForTable(t2));

            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();
            }
        }
    }
View Full Code Here

        config.m_startAction = StartAction.CREATE;

        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();
    }
View Full Code Here

        f.delete();
    }

    private static void startServer()
    {
        m_server = new ServerThread(m_testJar, m_projectBuilder.getPathToDeployment(),
                                  BackendTarget.NATIVE_EE_JNI);
        m_server.start();
        m_server.waitForInitialization();
    }
View Full Code Here

        // cmdln.dumpToFile("/Users/rbetts/cmd_" + Integer.toString(portGenerator.next()));

        m_cluster.add(null);
        m_pipes.add(null);
        m_cmdLines.add(cmdln);
        m_localServer = new ServerThread(cmdln);
        m_localServer.start();
    }
View Full Code Here

TOP

Related Classes of org.voltdb.ServerThread

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.