Search in sources :

Example 1 with SimulatorAddress

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;
}
Also used : HashMap(java.util.HashMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) ArrayList(java.util.ArrayList) UuidUtil.newUnsecureUuidString(com.hazelcast.simulator.utils.UuidUtil.newUnsecureUuidString) SimulatorAddress(com.hazelcast.simulator.protocol.core.SimulatorAddress) Future(java.util.concurrent.Future) HashMap(java.util.HashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) TimeoutException(java.util.concurrent.TimeoutException)

Example 2 with SimulatorAddress

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());
}
Also used : SimulatorAddress(com.hazelcast.simulator.protocol.core.SimulatorAddress) FailureOperation(com.hazelcast.simulator.coordinator.operations.FailureOperation) Test(org.junit.Test)

Example 3 with SimulatorAddress

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();
}
Also used : LogOperation(com.hazelcast.simulator.protocol.operation.LogOperation) SimulatorOperation(com.hazelcast.simulator.protocol.operation.SimulatorOperation) Future(java.util.concurrent.Future) SimulatorAddress(com.hazelcast.simulator.protocol.core.SimulatorAddress)

Example 4 with SimulatorAddress

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);
        }
    }
}
Also used : PerformanceStats(com.hazelcast.simulator.worker.performance.PerformanceStats) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap) Map(java.util.Map) SimulatorAddress(com.hazelcast.simulator.protocol.core.SimulatorAddress)

Example 5 with SimulatorAddress

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();
}
Also used : PerformanceStats(com.hazelcast.simulator.worker.performance.PerformanceStats) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) SimulatorAddress(com.hazelcast.simulator.protocol.core.SimulatorAddress)

Aggregations

SimulatorAddress (com.hazelcast.simulator.protocol.core.SimulatorAddress)30 Test (org.junit.Test)20 WorkerParameters (com.hazelcast.simulator.agent.workerprocess.WorkerParameters)8 HashMap (java.util.HashMap)8 Future (java.util.concurrent.Future)7 PerformanceStats (com.hazelcast.simulator.worker.performance.PerformanceStats)6 List (java.util.List)5 LogOperation (com.hazelcast.simulator.protocol.operation.LogOperation)4 SimulatorOperation (com.hazelcast.simulator.protocol.operation.SimulatorOperation)4 ExecutionException (java.util.concurrent.ExecutionException)4 CreateWorkerOperation (com.hazelcast.simulator.agent.operations.CreateWorkerOperation)3 Map (java.util.Map)3 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)3 JMSException (javax.jms.JMSException)3 FailureOperation (com.hazelcast.simulator.coordinator.operations.FailureOperation)2 AssertTask (com.hazelcast.simulator.utils.AssertTask)2 ArrayList (java.util.ArrayList)2 LinkedList (java.util.LinkedList)2 ConcurrentMap (java.util.concurrent.ConcurrentMap)2 AgentData (com.hazelcast.simulator.coordinator.registry.AgentData)1