Search in sources :

Example 6 with ServerThread

use of org.voltdb.ServerThread in project voltdb by VoltDB.

the class TestJDBCAutoReconnectOnLoss method startServer.

private void startServer() {
    m_server = new ServerThread(m_testjar, m_builder.getPathToDeployment(), BackendTarget.NATIVE_EE_JNI);
    m_server.start();
    m_server.waitForInitialization();
}
Also used : ServerThread(org.voltdb.ServerThread)

Example 7 with ServerThread

use of org.voltdb.ServerThread in project voltdb by VoltDB.

the class LocalCluster method startLocalServer.

private void startLocalServer(int hostId, boolean clearLocalDataDirectories, StartAction action) throws IOException {
    // Generate a new root for the in-process server if clearing directories.
    File subroot = null;
    if (!isNewCli) {
        try {
            if (m_filePrefix != null) {
                subroot = m_filePrefix;
                m_subRoots.add(subroot);
            } else if (clearLocalDataDirectories) {
                subroot = VoltFile.initNewSubrootForThisProcess();
                m_subRoots.add(subroot);
            } else {
                if (m_subRoots.size() <= hostId) {
                    m_subRoots.add(VoltFile.initNewSubrootForThisProcess());
                }
                subroot = m_subRoots.get(hostId);
            }
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
    // Make the local Configuration object...
    CommandLine cmdln = (templateCmdLine.makeCopy());
    cmdln.startCommand(action);
    cmdln.setJavaProperty(clusterHostIdProperty, String.valueOf(hostId));
    if (this.m_additionalProcessEnv != null) {
        for (String name : this.m_additionalProcessEnv.keySet()) {
            cmdln.setJavaProperty(name, this.m_additionalProcessEnv.get(name));
        }
    }
    if (!isNewCli) {
        cmdln.voltFilePrefix(subroot.getPath());
    }
    cmdln.internalPort(internalPortGenerator.nextInternalPort(hostId));
    cmdln.coordinators(internalPortGenerator.getCoordinators());
    cmdln.port(portGenerator.nextClient());
    cmdln.adminPort(portGenerator.nextAdmin());
    cmdln.zkport(portGenerator.nextZkPort());
    cmdln.httpPort(portGenerator.nextHttp());
    // replication port and its two automatic followers.
    cmdln.drAgentStartPort(m_replicationPort != -1 ? m_replicationPort : portGenerator.nextReplicationPort());
    portGenerator.nextReplicationPort();
    portGenerator.nextReplicationPort();
    if (m_target == BackendTarget.NATIVE_EE_VALGRIND_IPC) {
        EEProcess proc = m_eeProcs.get(hostId);
        assert (proc != null);
        cmdln.m_ipcPort = proc.port();
    }
    if (m_target == BackendTarget.NATIVE_EE_IPC) {
        cmdln.m_ipcPort = portGenerator.next();
    }
    if ((m_versionOverrides != null) && (m_versionOverrides.length > hostId)) {
        assert (m_versionOverrides[hostId] != null);
        assert (m_versionCheckRegexOverrides[hostId] != null);
        cmdln.m_versionStringOverrideForTest = m_versionOverrides[hostId];
        cmdln.m_versionCompatibilityRegexOverrideForTest = m_versionCheckRegexOverrides[hostId];
        if ((m_buildStringOverrides != null) && (m_buildStringOverrides.length > hostId)) {
            assert (m_buildStringOverrides[hostId] != null);
            cmdln.m_buildStringOverrideForTest = m_buildStringOverrides[hostId];
        }
    }
    if ((m_modeOverrides != null) && (m_modeOverrides.length > hostId)) {
        assert (m_modeOverrides[hostId] != null);
        cmdln.m_modeOverrideForTest = m_modeOverrides[hostId];
        cmdln.m_isPaused = true;
    }
    if ((m_sitesperhostOverrides != null) && (m_sitesperhostOverrides.size() > hostId)) {
        assert (m_sitesperhostOverrides.containsKey(hostId));
        cmdln.m_sitesperhost = m_sitesperhostOverrides.get(hostId);
    }
    // for debug, dump the command line to a unique file.
    // cmdln.dumpToFile("/Users/rbetts/cmd_" + Integer.toString(portGenerator.next()));
    m_cluster.add(null);
    m_pipes.add(null);
    m_cmdLines.add(cmdln);
    if (isNewCli) {
        cmdln.m_startAction = StartAction.PROBE;
        cmdln.enableAdd(action == StartAction.JOIN);
        cmdln.m_hostCount = m_hostCount;
        String hostIdStr = cmdln.getJavaProperty(clusterHostIdProperty);
        String root = m_hostRoots.get(hostIdStr);
        //For new CLI dont pass deployment for probe.
        cmdln.pathToDeployment(null);
        cmdln.voltdbRoot(root + File.separator + Constants.DBROOT);
    }
    m_localServer = new ServerThread(cmdln);
    if (m_usesStagedSchema) {
        // ServerThread sets this to true, always - override with our desired behavior.
        // Only do this for staged schema tests - preserve old behavior for others.
        cmdln.setForceVoltdbCreate(clearLocalDataDirectories);
    }
    m_localServer.start();
}
Also used : CommandLine(org.voltdb.utils.CommandLine) ServerThread(org.voltdb.ServerThread) IOException(java.io.IOException) VoltFile(org.voltdb.utils.VoltFile) File(java.io.File)

Example 8 with ServerThread

use of org.voltdb.ServerThread in project voltdb by VoltDB.

the class Runner method main.

public static void main(String[] args) throws Exception {
    // compile the catalog
    VoltProjectBuilder project = new VoltProjectBuilder();
    project.addLiteralSchema("create table items (id bigint not null, created bigint not null, primary key (id));");
    project.addLiteralSchema("create index idx_item_tree on items (created, id);");
    project.addStmtProcedure("CreateItem", "insert into items (id, created) values (?,?);", "items.id:0");
    project.addStmtProcedure("GetItems", "select id, created from items " + "where created <= ? and id < ? " + "order by created desc, id desc " + "limit ?;", "items.id:1");
    project.addPartitionInfo("items", "id");
    boolean success = project.compile(Configuration.getPathToCatalogForTest("poc.jar"));
    if (!success) {
        System.err.println("Failure to compile catalog.");
        System.exit(-1);
    }
    String pathToDeployment = project.getPathToDeployment();
    // start up voltdb
    ServerThread server = new ServerThread(Configuration.getPathToCatalogForTest("poc.jar"), pathToDeployment, BackendTarget.NATIVE_EE_JNI);
    server.start();
    server.waitForInitialization();
    final org.voltdb.client.Client voltclient = ClientFactory.createClient();
    voltclient.createConnection("localhost");
    // create initial items
    voltclient.callProcedure("CreateItem", 0, 10);
    voltclient.callProcedure("CreateItem", 1, 11);
    voltclient.callProcedure("CreateItem", 2, 12);
    // check that the query does the right thing
    VoltTable result = voltclient.callProcedure("GetItems", 11, 1, 1).getResults()[0];
    System.out.println(result.toJSONString());
    if (result.getRowCount() != 1) {
        System.err.printf("Call failed with %d rows\n", result.getRowCount());
    }
    // clean up / shutdown
    voltclient.close();
    server.shutdown();
    server.join();
}
Also used : VoltProjectBuilder(org.voltdb.compiler.VoltProjectBuilder) ServerThread(org.voltdb.ServerThread) VoltTable(org.voltdb.VoltTable)

Example 9 with ServerThread

use of org.voltdb.ServerThread in project voltdb by VoltDB.

the class TestInitStartLocalClusterAllOutOfProcess method testGetDeployment.

// Test get deployment
public void testGetDeployment() throws Exception {
    File deployment = File.createTempFile("get_deployment", ".xm");
    if (deployment.exists())
        deployment.delete();
    Configuration config = new VoltDB.Configuration(new String[] { "get", "deployment", "getvoltdbroot", voltDBRootParentPath, "file", deployment.getAbsolutePath() + "l", "forceget" });
    ServerThread server = new ServerThread(config);
    try {
        server.cli();
    } catch (Throwable ex) {
    //Good
    }
    DeploymentType dt = CatalogUtil.parseDeployment(deployment.getAbsolutePath() + "l");
    assertNotNull(dt);
    assertEquals(dt.getPaths().getVoltdbroot().getPath(), voltDbRootPath);
}
Also used : Configuration(org.voltdb.VoltDB.Configuration) ServerThread(org.voltdb.ServerThread) DeploymentType(org.voltdb.compiler.deploymentfile.DeploymentType) File(java.io.File)

Example 10 with ServerThread

use of org.voltdb.ServerThread in project voltdb by VoltDB.

the class TestInitStartLocalClusterInProcess method testGetDeployment.

// Test get deployment
public void testGetDeployment() throws Exception {
    File deployment = File.createTempFile("get_deployment", ".xm");
    Configuration config = new VoltDB.Configuration(new String[] { "get", "deployment", "getvoltdbroot", voltDBRootParentPath, "file", deployment.getAbsolutePath() + "l", "forceget" });
    ServerThread server = new ServerThread(config);
    try {
        server.cli();
    } catch (Throwable ex) {
    //Good
    }
    DeploymentType dt = CatalogUtil.parseDeployment(deployment.getAbsolutePath() + "l");
    assertNotNull(dt);
    assertEquals(dt.getPaths().getVoltdbroot().getPath(), voltDbRootPath);
}
Also used : Configuration(org.voltdb.VoltDB.Configuration) ServerThread(org.voltdb.ServerThread) DeploymentType(org.voltdb.compiler.deploymentfile.DeploymentType) File(java.io.File)

Aggregations

ServerThread (org.voltdb.ServerThread)36 Configuration (org.voltdb.VoltDB.Configuration)24 VoltDB (org.voltdb.VoltDB)16 File (java.io.File)12 VoltProjectBuilder (org.voltdb.compiler.VoltProjectBuilder)12 VoltTable (org.voltdb.VoltTable)9 Client (org.voltdb.client.Client)7 ClientResponse (org.voltdb.client.ClientResponse)6 IOException (java.io.IOException)5 ClientConfig (org.voltdb.client.ClientConfig)5 DeploymentBuilder (org.voltdb.compiler.DeploymentBuilder)5 BeforeClass (org.junit.BeforeClass)2 ClientResponseImpl (org.voltdb.ClientResponseImpl)2 TableHelper (org.voltdb.TableHelper)2 TPCCProjectBuilder (org.voltdb.benchmark.tpcc.TPCCProjectBuilder)2 ProcCallException (org.voltdb.client.ProcCallException)2 VoltBulkLoader (org.voltdb.client.VoltBulkLoader.VoltBulkLoader)2 CatalogBuilder (org.voltdb.compiler.CatalogBuilder)2 DeploymentType (org.voltdb.compiler.deploymentfile.DeploymentType)2 CommandLine (org.voltdb.utils.CommandLine)2