use of org.voltdb.client.NoConnectionsException in project voltdb by VoltDB.
the class AsyncBenchmark method runBenchmark.
/**
* Core benchmark code.
* Connect. Initialize. Run the loop. Cleanup. Print Results.
*
* @throws Exception if anything unexpected happens.
*/
public void runBenchmark() throws Exception {
log.info(HORIZONTAL_RULE);
log.info(" Setup & Initialization");
log.info(HORIZONTAL_RULE);
// connect to one or more servers, loop until success
connect();
VoltTable[] rowResults = null;
VoltTable[] replicatedResults = null;
boolean succeeded = false;
// If server fails during initialization, try again
while (!succeeded) {
Client initClient = clients.get(0);
try {
// initialize using synchronous call
initClient.callProcedure("Initialize");
ClientResponse rowResp = initClient.callProcedure("getLastRow");
rowResults = rowResp.getResults();
assert (rowResp.getStatus() == ClientResponse.SUCCESS);
ClientResponse replicatedRowResp = initClient.callProcedure("getLastReplicatedRow");
replicatedResults = replicatedRowResp.getResults();
assert (replicatedRowResp.getStatus() == ClientResponse.SUCCESS);
succeeded = true;
} catch (Exception e) {
log.error("Exception on init. Will sleep.", e);
sleepUntilConnected(initClient, System.currentTimeMillis() + config.duration * 1000);
}
}
// total of 127 cids
final int cidCount = 127;
final long windowPerCid = config.windowsize / cidCount;
// rids per cid
final Map<Integer, Long> rids = new HashMap<Integer, Long>();
// reset all cids to 0 and initialize inFlight queues
for (int i = -1; i < cidCount; i++) {
rids.put(i, 0l);
}
// populate the rids with values from previous run
while (rowResults[0].advanceRow()) {
long cid = rowResults[0].getLong("cid");
long last_rid = rowResults[0].getLong("last_rid");
rids.put((int) cid, last_rid + 1);
}
rids.put(-1, replicatedResults[0].asScalarLong() + 1);
log.info(HORIZONTAL_RULE);
log.info("Starting Benchmark");
log.info(HORIZONTAL_RULE);
java.util.Random r = new java.util.Random(2);
// print periodic statistics to the console
benchmarkStartTS = System.currentTimeMillis();
schedulePeriodicStats();
// Run the benchmark loop for the requested duration
// The throughput may be throttled depending on client configuration
final long benchmarkEndTime = System.currentTimeMillis() + (1000l * config.duration);
while (benchmarkEndTime > System.currentTimeMillis()) {
int cid;
if (r.nextDouble() < config.multisingleratio) {
// MP uses cid -1
cid = -1;
} else {
cid = (byte) r.nextInt(cidCount);
}
long rid = rids.get(cid);
// txns for the same cid go to the same client
Client client = null;
try {
if (cid == -1) {
client = clients.get(0);
// skip this work if the client is not connected
if (client.getConnectedHostList().size() == 0) {
continue;
}
// update the replicated table
try {
client.callProcedure(new updateReplicatedCallback(), "updateReplicated", rid);
} catch (NoConnectionsException e) {
log.error("ClientThread got NoConnectionsException on updateReplicated proc call.");
}
} else {
client = clients.get(cid % clients.size());
// skip this work if the client is not connected
if (client.getConnectedHostList().size() == 0) {
continue;
}
// asynchronously call the "doTxn" procedure
try {
client.callProcedure(new doTxnCallback(), "doTxn", cid, rid, rid > windowPerCid ? rid - windowPerCid : 0, processor.generateForStore().getStoreValue());
} catch (NoConnectionsException e) {
log.error("ClientThread got NoConnectionsException on doTxn proc call.");
}
}
} catch (Exception e) {
log.error("Benchark had a unexpected exception", e);
System.exit(-1);
}
rids.put(cid, rid + 1);
}
// cancel periodic stats printing
timer.cancel();
shutdown.set(true);
/* don't wait for a proper cleanup just go away the system may not be healthy -pr
// block until all outstanding txns return
for (Client client : clients) {
client.drain();
client.close();
}*/
log.info(HORIZONTAL_RULE);
log.info("Benchmark Complete");
}
use of org.voltdb.client.NoConnectionsException in project voltdb by VoltDB.
the class ClientRandom method main.
public static void main(String[] args) {
boolean backPressure = false;
long transactions_per_second = (long) Long.valueOf(args[0]);
long transactions_per_milli = transactions_per_second / 1000l;
long client_feedback_interval_secs = (long) Long.valueOf(args[1]);
long test_duration_secs = (long) Long.valueOf(args[2]);
int max_playerId = (int) Integer.valueOf(args[3]);
int max_field1 = (int) Integer.valueOf(args[4]);
long day_offset = (long) Long.valueOf(args[5]);
long lag_latency_seconds = (long) Long.valueOf(args[6]);
long lag_latency_millis = lag_latency_seconds * 1000l;
long thisOutstanding = 0;
long lastOutstanding = 0;
String serverList = args[7];
long reset_latency_seconds = (long) Long.valueOf(args[8]);
long reset_latency_millis = reset_latency_seconds * 1000l;
m_logger.info(String.format("Submitting %,d SP Calls/sec", transactions_per_second));
m_logger.info(String.format("Feedback interval = %,d second(s)", client_feedback_interval_secs));
m_logger.info(String.format("Running for %,d second(s)", test_duration_secs));
m_logger.info(String.format("Max playerId = %,d", max_playerId));
m_logger.info(String.format("Max field1 = %,d", max_field1));
m_logger.info(String.format("Offsetting insert timestamps by %d day(s)", day_offset));
m_logger.info(String.format("Latency not recorded for %d second(s)", lag_latency_seconds));
m_logger.info(String.format("Resetting min/max/avg latency every %d second(s)", reset_latency_seconds));
long playerId;
long field1;
long field2 = 1l;
long field3 = 1l;
long visitTimeMillis;
long transactions_this_second = 0;
long last_millisecond = System.currentTimeMillis();
long this_millisecond = System.currentTimeMillis();
long milliseconds_offset = day_offset * 1000l * 60 * 60 * 24;
AsyncCallback callBack = new AsyncCallback();
// create generic client
final org.voltdb.client.Client voltclient = ClientFactory.createClient();
// create HEAVYWEIGHT client with expected message size of 128 bytes
// final org.voltdb.client.Client voltclient = ClientFactory.createClient(128,null,true,null);
String[] voltServers = serverList.split(",");
for (String thisServer : voltServers) {
try {
thisServer = thisServer.trim();
m_logger.info(String.format("Connecting to server: %s", thisServer));
voltclient.createConnection(thisServer, "program", "none");
} catch (IOException e) {
m_logger.error(e.toString());
System.exit(-1);
}
}
// make random object totally random (set my milliseconds) so we can have multiple clients running simultaneously
java.util.Random rand = new java.util.Random();
long startTime = System.currentTimeMillis();
long endTime = startTime + (1000l * test_duration_secs);
long currentTime = startTime;
long lastFeedbackTime = startTime;
long num_sp_calls = 0;
long startRecordingLatency = startTime + lag_latency_millis;
long nextLatencyReset = startTime + reset_latency_millis;
int hourOfDay = Calendar.getInstance().get(Calendar.HOUR_OF_DAY) + 1;
int minuteOfHour = Calendar.getInstance().get(Calendar.MINUTE) + 1;
long nextHourCheck = -1;
int timeLimitedMaxPlayerId = 1;
while (endTime > currentTime) {
num_sp_calls++;
if (currentTime > nextHourCheck) {
// check the hour of the day once per minute
hourOfDay = Calendar.getInstance().get(Calendar.HOUR_OF_DAY);
minuteOfHour = Calendar.getInstance().get(Calendar.MINUTE);
nextHourCheck = currentTime + (1000l * 60l);
if (day_offset > 0) {
// all player IDs allowed in system, backfilling yesterday data
timeLimitedMaxPlayerId = max_playerId;
m_logger.info(String.format("day_offset > 0, player pool governer disabled : hourLimitedMaxPlayerId = %d", timeLimitedMaxPlayerId));
} else {
// only allow 5% of total player pool per hour to enter the system
timeLimitedMaxPlayerId = (int) ((((double) hourOfDay + ((double) minuteOfHour / 60.0)) * 5.0 / 100.0) * (double) max_playerId);
if (timeLimitedMaxPlayerId > max_playerId) {
timeLimitedMaxPlayerId = max_playerId;
} else if (timeLimitedMaxPlayerId < 1) {
timeLimitedMaxPlayerId = 1;
}
m_logger.info(String.format("hourOfDay = %d : minuteOfHour = %d : hourLimitedMaxPlayerId = %d", hourOfDay, minuteOfHour, timeLimitedMaxPlayerId));
}
}
playerId = (long) rand.nextInt(timeLimitedMaxPlayerId);
field1 = (long) rand.nextInt(max_field1);
field2 = 1l;
field3 = 1l;
visitTimeMillis = System.currentTimeMillis();
try {
voltclient.callProcedure(callBack, "RecordHit", playerId, field1, field2, field3, (visitTimeMillis - milliseconds_offset), visitTimeMillis);
} catch (IOException e) {
m_logger.error(e.toString());
System.exit(-1);
}
transactions_this_second++;
if (transactions_this_second >= transactions_per_milli) {
this_millisecond = System.currentTimeMillis();
while (this_millisecond <= last_millisecond) {
this_millisecond = System.currentTimeMillis();
}
last_millisecond = this_millisecond;
transactions_this_second = 0;
}
currentTime = System.currentTimeMillis();
if ((!checkLatency) && (currentTime >= startRecordingLatency)) {
// time to start recording latency information
checkLatency = true;
}
if (currentTime >= nextLatencyReset) {
synchronized (callBack) {
nextLatencyReset = currentTime + reset_latency_millis;
min_execution_milliseconds = 999999999l;
max_execution_milliseconds = -1l;
tot_execution_milliseconds = 0;
tot_executions_latency = 0;
m_logger.info("...Resetting latency min/max/avg");
}
}
if (currentTime >= (lastFeedbackTime + (client_feedback_interval_secs * 1000))) {
synchronized (callBack) {
lastFeedbackTime = currentTime;
long elapsedTimeMillis2 = System.currentTimeMillis() - startTime;
float elapsedTimeSec2 = elapsedTimeMillis2 / 1000F;
if (tot_executions_latency == 0) {
tot_executions_latency = 1;
}
thisOutstanding = num_sp_calls - tot_executions;
long runTimeMillis = endTime - startTime;
double percentComplete = ((double) elapsedTimeMillis2 / (double) runTimeMillis) * 100;
if (percentComplete > 100.0) {
percentComplete = 100.0;
}
String currentDate = new Date().toString();
m_logger.info(String.format("[%s] %.3f%% Complete | SP Calls: %,d at %,.2f SP/sec | outstanding = %d (%d) | min = %d | max = %d | avg = %.2f", currentDate, percentComplete, num_sp_calls, (num_sp_calls / elapsedTimeSec2), thisOutstanding, (thisOutstanding - lastOutstanding), min_execution_milliseconds, max_execution_milliseconds, (double) ((double) tot_execution_milliseconds / (double) tot_executions_latency)));
lastOutstanding = thisOutstanding;
}
}
}
try {
voltclient.drain();
} catch (InterruptedException e) {
m_logger.error(e.toString());
System.exit(-1);
} catch (NoConnectionsException e) {
m_logger.error(e.toString());
System.exit(-1);
}
long elapsedTimeMillis = System.currentTimeMillis() - startTime;
float elapsedTimeSec = elapsedTimeMillis / 1000F;
m_logger.info("*************************************************************************");
m_logger.info("Checking results");
m_logger.info("*************************************************************************");
m_logger.info(String.format(" - System ran for %12.4f seconds", elapsedTimeSec));
m_logger.info(String.format(" - Performed %,d SP calls", num_sp_calls));
m_logger.info(String.format(" - At %,.2f calls per second", num_sp_calls / elapsedTimeSec));
m_logger.info(String.format(" - Average Latency = %.2f ms", (double) ((double) tot_execution_milliseconds / (double) tot_executions_latency)));
m_logger.info(String.format(" - Latency 0ms - 25ms = %,d", latency_counter[0]));
m_logger.info(String.format(" - Latency 25ms - 50ms = %,d", latency_counter[1]));
m_logger.info(String.format(" - Latency 50ms - 75ms = %,d", latency_counter[2]));
m_logger.info(String.format(" - Latency 75ms - 100ms = %,d", latency_counter[3]));
m_logger.info(String.format(" - Latency 100ms - 125ms = %,d", latency_counter[4]));
m_logger.info(String.format(" - Latency 125ms - 150ms = %,d", latency_counter[5]));
m_logger.info(String.format(" - Latency 150ms - 175ms = %,d", latency_counter[6]));
m_logger.info(String.format(" - Latency 175ms - 200ms = %,d", latency_counter[7]));
m_logger.info(String.format(" - Latency 200ms+ = %,d", latency_counter[8]));
try {
voltclient.close();
} catch (Exception e) {
e.printStackTrace();
System.exit(-1);
}
}
use of org.voltdb.client.NoConnectionsException in project voltdb by VoltDB.
the class DeletesClient method performSnapshot.
public static void performSnapshot(Client client) {
checkSnapshotComplete(client);
if (m_snapshotInProgress) {
System.out.println("Snapshot still in progress, bailing");
return;
}
try {
VoltTable[] results = client.callProcedure("@SnapshotDelete", new String[] { m_snapshotDir }, new String[] { m_snapshotId }).getResults();
} catch (NoConnectionsException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (ProcCallException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
// m_totalRows should be accurate at this point
m_snapshotSizes.add(m_totalRows);
System.out.println("Performing Snapshot with total rows: " + m_totalRows);
try {
if (m_blockingSnapshots) {
ClientResponse response = client.callProcedure("@SnapshotSave", m_snapshotDir, m_snapshotId, 1);
if (response.getStatus() != ClientResponse.SUCCESS) {
System.out.println("failed snapshot");
System.out.println(response.getStatusString());
}
} else {
client.callProcedure(new ProcedureCallback() {
@Override
public void clientCallback(ClientResponse response) {
if (response.getStatus() != ClientResponse.SUCCESS) {
System.out.println("failed snapshot");
System.out.println(response.getStatusString());
}
}
}, "@SnapshotSave", m_snapshotDir, m_snapshotId, 0);
}
} catch (NoConnectionsException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ProcCallException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
use of org.voltdb.client.NoConnectionsException in project voltdb by VoltDB.
the class LoadT method processFile.
private static void processFile(org.voltdb.client.Client myApp, int lines) throws Exception {
FileInputStream fstream = null;
DataInputStream in = null;
String strLine = null;
long totalLines = 0;
try {
for (long workspaceId = 1; workspaceId < 6; workspaceId++) {
System.out.println(String.format("Loading workspaceId %d", workspaceId));
long lines_per_workspaceId = lines;
long countoflines = 0;
while (countoflines < lines_per_workspaceId) {
++countoflines;
totalLines++;
strLine = String.format("%d|%d|N|aaaa|%d|bbbb|cccc|dddd|eeee|ffff|Y|gggg|hhhh|jjjj|kkkk|llll|mmmm|US|01012000|nnnn|01022000|oooo|pppp|Y|qqqq|rrrr|ssss|N|tttt|2222|uuuu|01032000|vvvv|01042000|100.01|xxxx|1|2|3|4|5|6|Y|5555|01052000|yyyy|zzzz|AAAA|BBBB|CCCC|7777", workspaceId, countoflines, countoflines);
Object[] parameterargs = getEachLine(strLine);
try {
myApp.callProcedure(new MyAsyncCallback(), "InsertT", parameterargs);
} catch (NoConnectionsException e) {
e.printStackTrace();
}
if ((countoflines % 50000) == 0) {
System.out.printf("On Line %,d\n", countoflines);
}
}
}
} catch (Exception exp) {
exp.printStackTrace();
} finally {
System.out.println("This is the last line" + strLine);
System.out.println("Count of lines " + totalLines);
// Close the input stream
if (in != null) {
in.close();
}
if (fstream != null) {
fstream.close();
}
}
}
use of org.voltdb.client.NoConnectionsException in project voltdb by VoltDB.
the class ClientMoverEL method main.
public static void main(String[] args) {
long numMoves = (long) Long.valueOf(args[0]);
String serverList = args[1];
long clientDurationSeconds = (long) Long.valueOf(args[2]);
long loopPauseSeconds = (long) Long.valueOf(args[3]);
m_logger.info(String.format("Executing %,d moves per transaction", numMoves));
m_logger.info(String.format("Running for %,d second(s)", clientDurationSeconds));
int num_partitions = 0;
long playerId;
long gameId;
long socialId;
long clientId;
long visitTime;
int intCounter;
long longCounter;
final org.voltdb.client.Client voltclient = ClientFactory.createClient();
String[] voltServers = serverList.split(",");
for (String thisServer : voltServers) {
try {
thisServer = thisServer.trim();
m_logger.info(String.format("Connecting to server: %s", thisServer));
voltclient.createConnection(thisServer, "program", "none");
} catch (IOException e) {
m_logger.error(e.toString());
System.exit(-1);
}
}
java.util.Random rand = new java.util.Random(0);
long startTime = System.currentTimeMillis();
long endTime = startTime + (1000l * clientDurationSeconds);
long currentTime = startTime;
// get the # of partitions in my cluster
try {
VoltTable[] vtPartitionInfo = voltclient.callProcedure("@Statistics", "partitioncount", 0l).getResults();
num_partitions = (int) vtPartitionInfo[0].fetchRow(0).getLong(0);
m_logger.info("System is running with " + num_partitions + " partition(s).");
} catch (ProcCallException e) {
m_logger.error("ProcCallException:");
m_logger.error(e.toString());
} catch (IOException e) {
m_logger.error("IOException:");
m_logger.error(e.toString());
System.exit(-1);
}
boolean foundRows = true;
boolean foundFullRowset = false;
while (endTime > currentTime) {
// do a single archive at each partition
foundRows = false;
foundFullRowset = false;
long callTimeMillis = System.currentTimeMillis();
try {
for (longCounter = 0; longCounter < num_partitions; longCounter++) {
try {
long callTimeBegin = System.currentTimeMillis();
VoltTable[] vtArchiveVisits = voltclient.callProcedure("ArchiveVisitsEL", longCounter, numMoves, callTimeMillis).getResults();
long callTimeEnd = System.currentTimeMillis();
int rowCount = (int) vtArchiveVisits[0].fetchRow(0).getLong(1);
if (rowCount > 0) {
// write out the rows
foundRows = true;
if (rowCount == numMoves) {
foundFullRowset = true;
}
}
String currentDate = new Date().toString();
m_logger.info(String.format("[%s] Ran archive on partition %d : archived %,d row(s) in %,d milliseconds", currentDate, longCounter, rowCount, (callTimeEnd - callTimeBegin)));
} catch (ProcCallException e) {
m_logger.error("ProcCallException:");
m_logger.error(e.toString());
} catch (NoConnectionsException e) {
m_logger.error("IOException:");
m_logger.error(e.toString());
System.exit(-1);
}
}
if (!foundRows) {
// no rows found
m_logger.info("No rows found for this run.");
// pause for 5 seconds
m_logger.info(String.format("Pausing for %d seconds...", loopPauseSeconds));
long pauseCurrentMillis = System.currentTimeMillis();
long pauseEndMillis = pauseCurrentMillis + (loopPauseSeconds * 1000l);
while (pauseCurrentMillis < pauseEndMillis) {
pauseCurrentMillis = System.currentTimeMillis();
}
} else if (!foundFullRowset) {
// none of the rowsets were full (amount requested)
// pause for given number seconds
m_logger.info(String.format("No full rowsets found, pausing for %d seconds...", loopPauseSeconds));
long pauseCurrentMillis = System.currentTimeMillis();
long pauseEndMillis = pauseCurrentMillis + (loopPauseSeconds * 1000l);
while (pauseCurrentMillis < pauseEndMillis) {
pauseCurrentMillis = System.currentTimeMillis();
}
}
} catch (IOException e) {
m_logger.error(e.toString());
System.exit(-1);
}
currentTime = System.currentTimeMillis();
}
try {
voltclient.drain();
} catch (InterruptedException e) {
m_logger.error(e.toString());
System.exit(-1);
} catch (NoConnectionsException e) {
m_logger.error(e.toString());
System.exit(-1);
}
try {
voltclient.close();
} catch (Exception e) {
m_logger.error(e.toString());
System.exit(-1);
}
}
Aggregations