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() + "]");
}
}
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);
}
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);
}
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();
}
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);
}
Aggregations