use of org.voltdb.regressionsuites.LocalCluster in project voltdb by VoltDB.
the class TestSSL method ntestLocalClusterRejoin.
@Test
public void ntestLocalClusterRejoin() throws Exception {
org.voltdb.utils.VoltFile.resetSubrootForThisProcess();
VoltProjectBuilder builder = getBuilderForTest();
builder.setKeyStoreInfo(getResourcePath(KEYSTORE_RESOURCE), KEYSTORE_PASSWD);
builder.setCertStoreInfo(getResourcePath(KEYSTORE_RESOURCE), KEYSTORE_PASSWD);
int sitesPerHost = 2;
int hostCount = 3;
int kFactor = 2;
m_cluster = new LocalCluster("sslRejoin.jar", sitesPerHost, hostCount, kFactor, BackendTarget.NATIVE_EE_JNI, false);
m_cluster.setMaxHeap(1400);
m_cluster.overrideAnyRequestForValgrind();
m_cluster.setHasLocalServer(false);
boolean success = m_cluster.compile(builder);
assertTrue(success);
MiscUtils.copyFile(builder.getPathToDeployment(), Configuration.getPathToCatalogForTest("sslRejoin.xml"));
m_cluster.startUp();
ClientConfig clientConfig = new ClientConfig("", "", null);
clientConfig.setTrustStoreConfigFromPropertyFile(getResourcePath(SSL_PROPS_FILE));
clientConfig.enableSSL();
ClientResponse response;
Client client;
client = ClientFactory.createClient(clientConfig);
client.createConnection("localhost", m_cluster.port(0));
response = client.callProcedure("InsertA", 1, 1);
assertEquals(ClientResponse.SUCCESS, response.getStatus());
response = client.callProcedure("CountA");
assertEquals(ClientResponse.SUCCESS, response.getStatus());
assertEquals(1, response.getResults()[0].asScalarLong());
client.drain();
client.close();
client = ClientFactory.createClient(clientConfig);
client.createConnection("localhost", m_cluster.port(1));
response = client.callProcedure("InsertA", 2, 2);
assertEquals(ClientResponse.SUCCESS, response.getStatus());
response = client.callProcedure("CountA");
assertEquals(ClientResponse.SUCCESS, response.getStatus());
assertEquals(2, response.getResults()[0].asScalarLong());
client.drain();
client.close();
m_cluster.killSingleHost(0);
Thread.sleep(100);
VoltDB.Configuration config = new VoltDB.Configuration(m_cluster.portGenerator);
config.m_startAction = m_cluster.isNewCli() ? StartAction.PROBE : StartAction.REJOIN;
config.m_pathToCatalog = Configuration.getPathToCatalogForTest("sslRejoin.jar");
if (m_cluster.isNewCli()) {
config.m_voltdbRoot = new File(m_cluster.getServerSpecificRoot("0"));
config.m_forceVoltdbCreate = false;
config.m_hostCount = hostCount;
}
config.m_pathToDeployment = Configuration.getPathToCatalogForTest("sslRejoin.xml");
config.m_leader = ":" + m_cluster.internalPort(1);
config.m_coordinators = m_cluster.coordinators(1);
config.m_isRejoinTest = true;
m_cluster.setPortsFromConfig(0, config);
m_server = new ServerThread(config);
m_server.start();
m_server.waitForRejoin();
Thread.sleep(5000);
System.out.println("ServerThread joined");
client = ClientFactory.createClient(clientConfig);
System.out.println("Try connect to port:" + m_cluster.port(0));
client.createConnection("localhost", m_cluster.port(0));
System.out.println("Start Proc");
response = client.callProcedure("InsertA", 3, 3);
assertEquals(ClientResponse.SUCCESS, response.getStatus());
response = client.callProcedure("CountA");
assertEquals(ClientResponse.SUCCESS, response.getStatus());
assertEquals(3, response.getResults()[0].asScalarLong());
client.drain();
client.close();
client = ClientFactory.createClient(clientConfig);
System.out.println("Try connect to port:" + m_cluster.port(2));
client.createConnection("localhost", m_cluster.port(2));
System.out.println("Start Proc");
response = client.callProcedure("InsertA", 4, 4);
assertEquals(ClientResponse.SUCCESS, response.getStatus());
response = client.callProcedure("CountA");
assertEquals(ClientResponse.SUCCESS, response.getStatus());
assertEquals(4, response.getResults()[0].asScalarLong());
client.drain();
client.close();
m_server.shutdown();
m_cluster.shutDown();
}
use of org.voltdb.regressionsuites.LocalCluster in project voltdb by VoltDB.
the class LatencyManualTest method main.
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws Exception {
try {
String simpleSchema = "create stream blah partition on column ival (" + "ival bigint default 0 not null, " + "PRIMARY KEY(ival));";
VoltProjectBuilder builder = new VoltProjectBuilder();
builder.addLiteralSchema(simpleSchema);
builder.addStmtProcedure("Insert", "insert into blah values (?);", null);
LocalCluster cluster = new LocalCluster("latencycheck.jar", 2, 1, 0, BackendTarget.NATIVE_EE_JNI);
cluster.setHasLocalServer(true);
boolean success = cluster.compile(builder);
assert (success);
cluster.startUp(true);
final String listener = cluster.getListenerAddresses().get(0);
final Client client = ClientFactory.createClient();
client.createConnection(listener);
long iterations = 10000;
long start = System.nanoTime();
for (int i = 0; i < iterations; i++) {
client.callProcedure("Insert", i);
}
long end = System.nanoTime();
double ms = (end - start) / 1000000.0;
client.close();
cluster.shutDown();
System.out.printf("Avg latency was %.3f ms.\n", ms / iterations);
} catch (Exception e) {
e.printStackTrace();
} finally {
File jar = new File("latencycheck.jar");
jar.delete();
}
}
use of org.voltdb.regressionsuites.LocalCluster in project voltdb by VoltDB.
the class ScanPerfTest method testHaltLiveRejoinOnOverflow.
@Test
public void testHaltLiveRejoinOnOverflow() throws Exception {
LocalCluster cluster = null;
Client client = null;
VoltTable pTable = TableHelper.quickTable("P (ID:BIGINT-N, VALUE:BIGINT-N) PK(ID)");
// build and compile a catalog
System.out.println("Compiling catalog.");
VoltProjectBuilder builder = new VoltProjectBuilder();
builder.addLiteralSchema(TableHelper.ddlForTable(pTable, false));
builder.addLiteralSchema("PARTITION TABLE P ON COLUMN ID;\n" + "CREATE PROCEDURE FROM CLASS org.voltdb.planner.ScanPerfTest$ScanTable;\n" + "PARTITION PROCEDURE ScanPerfTest$ScanTable ON TABLE P COLUMN ID;\n");
cluster = new LocalCluster("scanperf.jar", 8, 1, 0, BackendTarget.NATIVE_EE_JNI);
//cluster.setMaxHeap(10);
boolean success = cluster.compile(builder);
assertTrue(success);
//fail();
System.out.println("Starting cluster.");
cluster.setHasLocalServer(false);
cluster.overrideAnyRequestForValgrind();
cluster.startUp(true);
System.out.println("Getting client connected.");
ClientConfig clientConfig = new ClientConfig();
client = ClientFactory.createClient(clientConfig);
for (String address : cluster.getListenerAddresses()) {
client.createConnection(address);
}
System.out.println("Loading");
Random r = new Random();
// load up > 1gb data
fillTable(6000, client, r);
System.out.println("100% loaded.");
client.drain();
client.close();
System.out.println("Getting client re-connected.");
clientConfig = new ClientConfig();
clientConfig.setProcedureCallTimeout(Long.MAX_VALUE);
clientConfig.setMaxOutstandingTxns(50);
client = ClientFactory.createClient(clientConfig);
for (String address : cluster.getListenerAddresses()) {
client.createConnection(address);
}
long start = System.currentTimeMillis();
for (int i = 0; i < 12; i++) {
while ((System.currentTimeMillis() - start) < ((i + 1) * 5000)) {
client.callProcedure(new ScanCallback(), "ScanPerfTest$ScanTable", r.nextLong());
}
System.out.printf("Scanned at %.2f rows/sec when %.0f%% done.\n", rows.get() / (nanos.get() / 1000000000.0), ((i + 1) / 12.0) * 100);
System.out.printf("%d scans on an average of %d rows/partition\n", scans.get(), rows.get() / scans.get());
System.out.printf("%.2f scans per second\n", scans.get() / (nanos.get() / 1000000000.0));
}
System.out.println("Draining.");
client.drain();
client.close();
System.out.printf("Scanned at %f rows/sec after drain.\n", rows.get() / (nanos.get() / 1000000000.0));
cluster.shutDown();
}
use of org.voltdb.regressionsuites.LocalCluster in project voltdb by VoltDB.
the class TestCollector method setUp.
@Before
public void setUp() throws Exception {
String simpleSchema = "create table blah (" + "ival bigint default 0 not null, " + "PRIMARY KEY(ival));";
builder = new VoltProjectBuilder();
builder.addLiteralSchema(simpleSchema);
builder.addProcedures(CrashJVM.class);
builder.addProcedures(CrashVoltDBProc.class);
cluster = new LocalCluster("collect.jar", 2, 1, 0, BackendTarget.NATIVE_EE_JNI);
cluster.setHasLocalServer(false);
boolean success = cluster.compile(builder);
assert (success);
File voltDbRoot;
cluster.startUp(true);
//Get server specific root after startup.
if (cluster.isNewCli()) {
voltDbRoot = new File(cluster.getServerSpecificRoot("0"));
} else {
String voltDbFilePrefix = cluster.getSubRoots().get(0).getPath();
voltDbRoot = new File(voltDbFilePrefix, builder.getPathToVoltRoot().getPath());
}
m_voltDbRootPath = voltDbRoot.getPath();
listener = cluster.getListenerAddresses().get(0);
client = ClientFactory.createClient();
client.createConnection(listener);
m_outputFileName = "";
m_pid = getpid(m_voltDbRootPath);
m_prefix = "";
System.setProperty("VOLT_JUSTATEST", "true");
}
Aggregations