use of com.hazelcast.simulator.protocol.core.SimulatorAddress in project hazelcast-simulator by hazelcast.
the class CoordinatorClient method invokeOnAllAgents.
public List<String> invokeOnAllAgents(SimulatorOperation op, long timeoutMillis) throws TimeoutException, InterruptedException, ExecutionException {
Map<SimulatorAddress, Future<String>> futures = new HashMap<SimulatorAddress, Future<String>>();
for (RemoteBroker broker : remoteBrokers.values()) {
SimulatorAddress agent = broker.agentAddress;
futures.put(agent, submit(agent, op));
}
List<String> responses = new ArrayList<String>();
long deadLine = currentTimeMillis() + timeoutMillis;
for (Map.Entry<SimulatorAddress, Future<String>> entry : futures.entrySet()) {
long remainingTimeout = deadLine - currentTimeMillis();
if (remainingTimeout <= 0) {
throw new TimeoutException();
}
Future<String> f = entry.getValue();
responses.add(f.get(remainingTimeout, MILLISECONDS));
}
return responses;
}
use of com.hazelcast.simulator.protocol.core.SimulatorAddress in project hazelcast-simulator by hazelcast.
the class FailureCollectorTest method notify_whenNonExistingWorker_thenIgnore.
@Test
public void notify_whenNonExistingWorker_thenIgnore() {
SimulatorAddress nonExistingWorkerAddress = workerAddress(agentAddress.getAgentIndex(), 100);
FailureOperation failure = new FailureOperation("exception", WORKER_EXCEPTION, nonExistingWorkerAddress, agentAddress.toString(), "workerId", "testId", null);
failureCollector.notify(failure);
assertEquals(0, failureCollector.getFailureCount());
}
use of com.hazelcast.simulator.protocol.core.SimulatorAddress in project hazelcast-simulator by hazelcast.
the class Example method main.
public static void main(String[] args) throws Exception {
String username = "peter";
String password = "password";
Broker broker = new Broker().setCredentials(username, password).start();
CoordinatorClient coordinatorClient = new CoordinatorClient().connectToAgentBroker(SimulatorAddress.fromString("A1"), Inet4Address.getLocalHost().getHostAddress()).start();
Server agentServer = new Server("agents").setProcessor(new OperationProcessor() {
@Override
public void process(SimulatorOperation op, SimulatorAddress source, Promise promise) throws Exception {
}
}).setSelfAddress(SimulatorAddress.fromString("A1")).setBrokerURL(broker.getBrokerURL()).start();
Server workerServer = new Server("workers").setProcessor(new OperationProcessor() {
@Override
public void process(SimulatorOperation op, SimulatorAddress source, Promise promise) throws Exception {
System.out.println("worker:" + op);
}
}).setSelfAddress(SimulatorAddress.fromString("A1_W1")).setBrokerURL(broker.getBrokerURL()).start();
SimulatorAddress address = SimulatorAddress.fromString("A1_W1");
Future f = coordinatorClient.submit(address, new LogOperation("foo"));
System.out.println(f.get());
// client.send(address, new AuthOperation());
Thread.sleep(5000);
agentServer.close();
workerServer.close();
coordinatorClient.close();
broker.close();
}
use of com.hazelcast.simulator.protocol.core.SimulatorAddress in project hazelcast-simulator by hazelcast.
the class PerformanceStatsCollector method calculatePerformanceStats.
void calculatePerformanceStats(String testId, PerformanceStats totalPerformanceStats, Map<SimulatorAddress, PerformanceStats> agentPerformanceStatsMap) {
for (Map.Entry<SimulatorAddress, WorkerPerformance> entry : workerPerformanceInfoMap.entrySet()) {
SimulatorAddress workerAddress = entry.getKey();
SimulatorAddress agentAddress = workerAddress.getParent();
PerformanceStats agentPerformanceStats = agentPerformanceStatsMap.get(agentAddress);
if (agentPerformanceStats == null) {
agentPerformanceStats = new PerformanceStats();
agentPerformanceStatsMap.put(agentAddress, agentPerformanceStats);
}
WorkerPerformance workerPerformance = entry.getValue();
PerformanceStats workerTestPerformanceStats = workerPerformance.get(testId, true);
if (workerTestPerformanceStats != null) {
agentPerformanceStats.add(workerTestPerformanceStats);
totalPerformanceStats.add(workerTestPerformanceStats);
}
}
}
use of com.hazelcast.simulator.protocol.core.SimulatorAddress in project hazelcast-simulator by hazelcast.
the class PerformanceStatsCollector method detailedPerformanceInfo.
public String detailedPerformanceInfo(String testId, long runningTimeMs) {
PerformanceStats totalPerformanceStats = new PerformanceStats();
Map<SimulatorAddress, PerformanceStats> agentPerformanceStatsMap = new HashMap<SimulatorAddress, PerformanceStats>();
calculatePerformanceStats(testId, totalPerformanceStats, agentPerformanceStatsMap);
long totalOperationCount = totalPerformanceStats.getOperationCount();
if (totalOperationCount < 1) {
return "Performance information is not available!";
}
double runningTimeSeconds = (runningTimeMs * 1d) / SECONDS.toMillis(1);
StringBuilder sb = new StringBuilder();
double throughput = totalOperationCount / runningTimeSeconds;
sb.append("Total running time " + secondsToHuman(Math.round(runningTimeSeconds)) + "\n");
sb.append(format("Total throughput %s%% %s ops %s ops/s\n", formatPercentage(1, 1), formatLong(totalOperationCount, OPERATION_COUNT_FORMAT_LENGTH), formatDouble(throughput, THROUGHPUT_FORMAT_LENGTH)));
for (SimulatorAddress address : sort(agentPerformanceStatsMap.keySet())) {
PerformanceStats performanceStats = agentPerformanceStatsMap.get(address);
long operationCount = performanceStats.getOperationCount();
sb.append(format(" Agent %-15s %s%% %s ops %s ops/s\n", address, formatPercentage(operationCount, totalOperationCount), formatLong(operationCount, OPERATION_COUNT_FORMAT_LENGTH), formatDouble(operationCount / runningTimeSeconds, THROUGHPUT_FORMAT_LENGTH)));
}
return sb.toString();
}
Aggregations