use of org.voltdb.ServerThread in project voltdb by VoltDB.
the class LocalSingleProcessServer method startUp.
@Override
public void startUp(boolean clearLocalDataDirectories) {
VoltServerConfig.addInstance(this);
if (clearLocalDataDirectories) {
File exportOverflow = new File(m_pathToVoltRoot, "export_overflow");
if (exportOverflow.exists()) {
assert (exportOverflow.isDirectory());
for (File f : exportOverflow.listFiles()) {
if (f.isFile() && f.getName().endsWith(".pbd") || f.getName().endsWith(".ad")) {
f.delete();
}
}
}
}
Configuration config = new Configuration();
config.m_backend = m_target;
config.m_noLoadLibVOLTDB = (m_target == BackendTarget.HSQLDB_BACKEND);
// m_jarFileName is already prefixed with test output path.
config.m_pathToCatalog = m_jarFileName;
config.m_pathToDeployment = m_pathToDeployment;
config.m_startAction = StartAction.CREATE;
config.m_isPaused = m_paused;
if (m_adminPort != -1) {
config.m_adminPort = m_adminPort;
}
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();
}
use of org.voltdb.ServerThread in project voltdb by VoltDB.
the class TestInitStartLocalClusterAllOutOfProcess method getProcJarFromCatalog.
InMemoryJarfile getProcJarFromCatalog() throws IOException {
File jar = File.createTempFile("procedure", ".jar");
Configuration config = new VoltDB.Configuration(new String[] { "get", "classes", "getvoltdbroot", voltDBRootParentPath, "file", jar.getAbsolutePath(), "forceget" });
ServerThread server = new ServerThread(config);
try {
server.cli();
} catch (Throwable ex) {
//Good
}
byte[] bytesRead = Files.readAllBytes(Paths.get(jar.getAbsolutePath()));
assertNotNull(bytesRead);
assertTrue(bytesRead.length > 0);
return new InMemoryJarfile(bytesRead);
}
use of org.voltdb.ServerThread in project voltdb by VoltDB.
the class TestInitStartLocalClusterAllOutOfProcess method testGetSchema.
// Test get schema
public void testGetSchema() throws Exception {
File schema = File.createTempFile("schema", ".sql");
Configuration config = new VoltDB.Configuration(new String[] { "get", "schema", "getvoltdbroot", voltDBRootParentPath, "file", schema.getAbsolutePath(), "forceget" });
ServerThread server = new ServerThread(config);
try {
server.cli();
} catch (Throwable ex) {
//Good
}
byte[] encoded = Files.readAllBytes(Paths.get(schema.getAbsolutePath()));
assertNotNull(encoded);
assertTrue(encoded.length > 0);
String ddl = new String(encoded, StandardCharsets.UTF_8);
assertTrue(ddl.toLowerCase().contains("create table blah ("));
assertTrue(ddl.toLowerCase().contains("ival bigint default '0' not null"));
assertTrue(ddl.toLowerCase().contains("primary key (ival)"));
}
use of org.voltdb.ServerThread in project voltdb by VoltDB.
the class SimpleServer method main.
public static void main(String[] args) throws NumberFormatException, Exception {
VoltProjectBuilder builder = null;
String[] arg;
// default
String schemaFileName = "DDL.sql";
ArrayList<String> host_manager_args = new ArrayList<String>();
int hosts = 1;
int sites = 1;
int k_factor = 0;
for (int i = 0; i < args.length; ++i) {
arg = args[i].split("=");
if (arg[0].equals("schema")) {
schemaFileName = arg[1];
} else if (arg[0].equals("backend")) {
host_manager_args.add(arg[1]);
} else if (arg[0].equals("hosts")) {
hosts = Integer.valueOf(arg[1]);
} else if (arg[0].equals("sitesperhost")) {
sites = Integer.valueOf(arg[1]);
} else if (arg[0].equals("replicas")) {
k_factor = Integer.valueOf(arg[1]);
} else if (args[i] != null) {
host_manager_args.add(args[i]);
}
}
String[] hostargs = new String[host_manager_args.size()];
VoltDB.Configuration config = new VoltDB.Configuration(host_manager_args.toArray(hostargs));
if (config.m_backend != BackendTarget.NATIVE_EE_JNI) {
sites = 1;
hosts = 1;
k_factor = 0;
}
builder = new VoltProjectBuilder();
builder.addSchema(SimpleServer.class.getResource(schemaFileName));
builder.setCompilerDebugPrintStream(System.out);
if (!builder.compile(Configuration.getPathToCatalogForTest("simple.jar"), sites, hosts, k_factor)) {
System.err.println("Compilation failed");
System.exit(-1);
}
MiscUtils.copyFile(builder.getPathToDeployment(), Configuration.getPathToCatalogForTest("simple.xml"));
config.m_pathToCatalog = Configuration.getPathToCatalogForTest("simple.jar");
System.out.println("catalog path: " + config.m_pathToCatalog);
config.m_pathToDeployment = Configuration.getPathToCatalogForTest("simple.xml");
System.out.println("deployment path: " + config.m_pathToDeployment);
config.m_port = VoltDB.DEFAULT_PORT;
ServerThread server = new ServerThread(config);
server.start();
server.join();
}
use of org.voltdb.ServerThread in project voltdb by VoltDB.
the class HTTPDBenchmark method startup.
ServerThread startup() throws Exception {
String simpleSchema = "create table dummy (" + "sval1 varchar(100) not null, " + "sval2 varchar(100) default 'foo', " + "sval3 varchar(100) default 'bar', " + "PRIMARY KEY(sval1));";
File schemaFile = VoltProjectBuilder.writeStringToTempFile(simpleSchema);
String schemaPath = schemaFile.getPath();
schemaPath = URLEncoder.encode(schemaPath, "UTF-8");
VoltProjectBuilder builder = new VoltProjectBuilder();
builder.addSchema(schemaPath);
builder.addPartitionInfo("dummy", "sval1");
builder.addStmtProcedure("Insert", "insert into dummy values (?,?,?);");
builder.addStmtProcedure("Select", "select * from dummy;");
builder.setHTTPDPort(8095);
boolean success = builder.compile(Configuration.getPathToCatalogForTest("jsonperf.jar"), 1, 1, 0);
assert (success);
VoltDB.Configuration config = new VoltDB.Configuration();
config.m_pathToCatalog = Configuration.getPathToCatalogForTest("jsonperf.jar");
config.m_pathToDeployment = builder.getPathToDeployment();
ServerThread server = new ServerThread(config);
server.start();
server.waitForInitialization();
Client client = ClientFactory.createClient();
client.createConnection("localhost");
ClientResponse response1;
response1 = client.callProcedure("Insert", "FOO", "BAR", "BOO");
assert (response1.getStatus() == ClientResponse.SUCCESS);
return server;
}
Aggregations