Search in sources :

Example 6 with CommandLine

use of org.voltdb.utils.CommandLine in project voltdb by VoltDB.

the class LocalCluster method initLocalServer.

void initLocalServer(int hostId, boolean clearLocalDataDirectories) throws IOException {
    // Make the local Configuration object...
    CommandLine cmdln = (templateCmdLine.makeCopy());
    cmdln.startCommand(StartAction.INITIALIZE);
    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 (new Integer(hostId).equals(m_mismatchNode)) {
        assert m_usesStagedSchema;
        cmdln.m_userSchema = m_mismatchSchema == null ? null : VoltProjectBuilder.createFileForSchema(m_mismatchSchema);
    }
    cmdln.setForceVoltdbCreate(clearLocalDataDirectories);
    //If we are initializing lets wait for it to finish.
    ServerThread th = new ServerThread(cmdln);
    File root = VoltFile.getServerSpecificRoot(String.valueOf(hostId), clearLocalDataDirectories);
    assert (root.getName().equals(Constants.DBROOT) == false) : root.getAbsolutePath();
    cmdln.voltdbRoot(new File(root, Constants.DBROOT));
    try {
        th.initialize();
    } catch (VoltDB.SimulatedExitException expected) {
    //All ok
    } catch (Exception ex) {
        log.error("Failed to initialize cluster process:" + ex.getMessage(), ex);
        assert (false);
    }
    //Keep track by hostid the voltdbroot
    String hostIdStr = cmdln.getJavaProperty(clusterHostIdProperty);
    m_hostRoots.put(hostIdStr, root.getAbsolutePath());
}
Also used : VoltDB(org.voltdb.VoltDB) CommandLine(org.voltdb.utils.CommandLine) ServerThread(org.voltdb.ServerThread) VoltFile(org.voltdb.utils.VoltFile) File(java.io.File) IOException(java.io.IOException)

Example 7 with CommandLine

use of org.voltdb.utils.CommandLine in project voltdb by VoltDB.

the class LocalCluster method getListenerAddresses.

@Override
public List<String> getListenerAddresses() {
    if (!m_running) {
        return null;
    }
    ArrayList<String> listeners = new ArrayList<>();
    for (int i = 0; i < m_cmdLines.size(); i++) {
        CommandLine cl = m_cmdLines.get(i);
        Process p = m_cluster.get(i);
        // if the process is alive, or is the in-process server
        if ((p != null) || (i == 0 && m_hasLocalServer)) {
            listeners.add("localhost:" + cl.m_port);
        }
    }
    return listeners;
}
Also used : CommandLine(org.voltdb.utils.CommandLine) ArrayList(java.util.ArrayList)

Example 8 with CommandLine

use of org.voltdb.utils.CommandLine in project voltdb by VoltDB.

the class LocalCluster method getListenerAddress.

private String getListenerAddress(int hostId, boolean useAdmin) {
    if (!m_running) {
        return null;
    }
    for (int i = 0; i < m_cmdLines.size(); i++) {
        CommandLine cl = m_cmdLines.get(i);
        String hostIdStr = cl.getJavaProperty(clusterHostIdProperty);
        if (hostIdStr.equals(String.valueOf(hostId))) {
            Process p = m_cluster.get(i);
            // if the process is alive, or is the in-process server
            if ((p != null) || (i == 0 && m_hasLocalServer)) {
                return "localhost:" + (useAdmin ? cl.m_adminPort : cl.m_port);
            }
        }
    }
    return null;
}
Also used : CommandLine(org.voltdb.utils.CommandLine)

Aggregations

CommandLine (org.voltdb.utils.CommandLine)8 File (java.io.File)5 IOException (java.io.IOException)5 VoltFile (org.voltdb.utils.VoltFile)5 ServerThread (org.voltdb.ServerThread)3 ArrayList (java.util.ArrayList)1 VoltDB (org.voltdb.VoltDB)1