voltDB探索工具

package org.voltdb.regressionsuites;

import java.io.IOException;

import org.voltdb.BackendTarget;
import org.voltdb.client.Client;
import org.voltdb.client.ClientResponse;
import org.voltdb.compiler.VoltProjectBuilder;

public class TestByTestSuite extends RegressionSuite {

    public TestByTestSuite(String name) {
        super(name);
    }

    static private String generateSchema() {
        StringBuilder sb = new StringBuilder();
        sb.append("CREATE TABLE testtable0 (id integer not null primary key,"
                + "name0 varchar(100));"
                + "partition table testtable0 on column id;");
        return sb.toString();
    }

    public static void main(String[] args) throws IOException {

        String simpleSchema = "CREATE TABLE testtable0 (id integer not null primary key,"
                + "name0 varchar(100));"
                + "partition table testtable0 on column id;";

        VoltProjectBuilder builder = new VoltProjectBuilder();
        builder.addLiteralSchema(simpleSchema);

        LocalCluster cluster = new LocalCluster("crash.jar", 1, 2, 0,
                BackendTarget.HSQLDB_BACKEND);
        cluster.setHasLocalServer(true);
        boolean success = cluster.compile(builder);
        assert (success);
        cluster.startUp(true);

    }

    static public junit.framework.Test suite() {
        VoltServerConfig config = null;
        final MultiConfigSuiteBuilder builder = new MultiConfigSuiteBuilder(
                TestByTestSuite.class);
        final VoltProjectBuilder project = new VoltProjectBuilder();
        try {
            project.addLiteralSchema(generateSchema());
        } catch (IOException error) {
            fail(error.getMessage());
        }
        boolean success;
        config = new LocalCluster("iisf-hsql.jar", 2, 2, 0,
                BackendTarget.HSQLDB_BACKEND);
        success = config.compile(project);
        assert (success);
        builder.addServerConfig(config);

        return builder;
    }

    private static void clearTables(Client client) throws Exception {
        ClientResponse resp = client.callProcedure("@AdHoc",
                "delete from testtable0");
        assertEquals(ClientResponse.SUCCESS, resp.getStatus());
    }

    private static void initializeTables(Client client) throws Exception {
        ClientResponse resp = null;
        clearTables(client);
        for (int i = 0; i < 10; i++) {
            resp = client
                    .callProcedure("@AdHoc", "insert into testtable0 values("
                            + i + ",'aaaaa" + i + "')");
            // resp = client.callProcedure("testtable0.insert", i, "aaaaa" + i);
            assertEquals(ClientResponse.SUCCESS, resp.getStatus());
        }
    }

    public void test0() throws Exception {
        final Client client = getClient();
        initializeTables(client);
    }
}

你可能感兴趣的:(VoltDB)