Search in sources :

Example 1 with ExecuteScriptOperation

use of com.hazelcast.simulator.worker.operations.ExecuteScriptOperation in project hazelcast-simulator by hazelcast.

the class KillWorkersTask method killWorkers.

private void killWorkers(List<WorkerData> victims) {
    LOGGER.info(format("Killing [%s]", toAddressString(victims)));
    for (WorkerData victim : victims) {
        victim.setIgnoreFailures(true);
        client.submit(victim.getAddress(), new ExecuteScriptOperation(command, true));
        LOGGER.info("Kill send to worker [" + victim.getAddress() + "]");
    }
}
Also used : WorkerData(com.hazelcast.simulator.coordinator.registry.WorkerData) ExecuteScriptOperation(com.hazelcast.simulator.worker.operations.ExecuteScriptOperation)

Example 2 with ExecuteScriptOperation

use of com.hazelcast.simulator.worker.operations.ExecuteScriptOperation in project hazelcast-simulator by hazelcast.

the class ScriptExecutorTest method whenFireSndForget_thenErrorNotNoticed.

@Test
public void whenFireSndForget_thenErrorNotNoticed() {
    ExecuteScriptOperation scriptOperation = new ExecuteScriptOperation("bash:foobar", true);
    StubPromise promise = new StubPromise();
    scriptExecutor.execute(scriptOperation, promise);
    promise.assertCompletesEventually();
    assertTrue(promise.getAnswer() instanceof String);
}
Also used : ExecuteScriptOperation(com.hazelcast.simulator.worker.operations.ExecuteScriptOperation) StubPromise(com.hazelcast.simulator.protocol.StubPromise) Test(org.junit.Test)

Example 3 with ExecuteScriptOperation

use of com.hazelcast.simulator.worker.operations.ExecuteScriptOperation in project hazelcast-simulator by hazelcast.

the class ScriptExecutorTest method bash.

@Test
public void bash() {
    ExecuteScriptOperation scriptOperation = new ExecuteScriptOperation("bash:ls", false);
    StubPromise promise = new StubPromise();
    scriptExecutor.execute(scriptOperation, promise);
    promise.assertCompletesEventually();
    assertTrue(promise.getAnswer() instanceof String);
}
Also used : ExecuteScriptOperation(com.hazelcast.simulator.worker.operations.ExecuteScriptOperation) StubPromise(com.hazelcast.simulator.protocol.StubPromise) Test(org.junit.Test)

Example 4 with ExecuteScriptOperation

use of com.hazelcast.simulator.worker.operations.ExecuteScriptOperation in project hazelcast-simulator by hazelcast.

the class Coordinator method workerScript.

public String workerScript(RcWorkerScriptOperation operation) throws Exception {
    List<WorkerData> workers = operation.getWorkerQuery().execute(registry.getWorkers());
    LOGGER.info(format("Script [%s] on %s workers ...", operation.getCommand(), workers.size()));
    Map<WorkerData, Future<String>> futures = new HashMap<WorkerData, Future<String>>();
    for (WorkerData worker : workers) {
        Future<String> f = client.submit(worker.getAddress(), new ExecuteScriptOperation(operation.getCommand(), operation.isFireAndForget()));
        futures.put(worker, f);
        LOGGER.info("Script send to worker [" + worker.getAddress() + "]");
    }
    if (operation.isFireAndForget()) {
        return null;
    }
    StringBuilder sb = new StringBuilder();
    for (Map.Entry<WorkerData, Future<String>> entry : futures.entrySet()) {
        WorkerData worker = entry.getKey();
        String result = entry.getValue().get();
        sb.append(worker.getAddress()).append("=").append(result).append("\n");
    }
    LOGGER.info(format("Script [%s] on %s workers completed!", operation.getCommand(), workers.size()));
    return sb.toString();
}
Also used : HashMap(java.util.HashMap) Future(java.util.concurrent.Future) WorkerData(com.hazelcast.simulator.coordinator.registry.WorkerData) ExecuteScriptOperation(com.hazelcast.simulator.worker.operations.ExecuteScriptOperation) Map(java.util.Map) HashMap(java.util.HashMap)

Example 5 with ExecuteScriptOperation

use of com.hazelcast.simulator.worker.operations.ExecuteScriptOperation in project hazelcast-simulator by hazelcast.

the class WorkerOperationProcessorTest method test_ExecuteScriptOperation.

@Test
public void test_ExecuteScriptOperation() throws Exception {
    ExecuteScriptOperation op = new ExecuteScriptOperation("bash:ls", true);
    processor.process(op, sourceAddress, promise);
    verify(scriptExecutor).execute(op, promise);
}
Also used : ExecuteScriptOperation(com.hazelcast.simulator.worker.operations.ExecuteScriptOperation) Test(org.junit.Test)

Aggregations

ExecuteScriptOperation (com.hazelcast.simulator.worker.operations.ExecuteScriptOperation)6 Test (org.junit.Test)4 StubPromise (com.hazelcast.simulator.protocol.StubPromise)3 WorkerData (com.hazelcast.simulator.coordinator.registry.WorkerData)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Future (java.util.concurrent.Future)1