use of org.ow2.proactive.resourcemanager.common.event.RMNodeEvent in project scheduling by ow2-proactive.
the class InfrastructureManager method emitEvent.
// **********************************************************************************************//
// *********************** Package private accessors & Helpers
// **********************************//
// **********************************************************************************************//
/**
* To emit an event and register it in the database
*/
private void emitEvent(final RMNodeEvent event) {
NodeSource nsStub = this.nodeSource.getStub();
nsStub.internalEmitDeployingNodeEvent(event);
}
use of org.ow2.proactive.resourcemanager.common.event.RMNodeEvent in project scheduling by ow2-proactive.
the class RMInitialStateChunksTest2 method clientKnowsNothing.
@Test
public void clientKnowsNothing() {
Map<String, RMNodeEvent> accumulatedNodeEvents = new HashMap<>();
Map<String, RMNodeSourceEvent> accumulatedNodeSourceEvents = new HashMap<>();
int numberOfRequests = 0;
long currentCounter = RMInitialState.EMPTY_STATE;
while (true) {
final RMStateDelta rmStateDelta = rmInitialState.cloneAndFilter(currentCounter);
++numberOfRequests;
rmStateDelta.getNodesEvents().forEach(rmNodeEvent -> {
accumulatedNodeEvents.put(rmNodeEvent.getNodeSource() + rmNodeEvent.getNodeUrl(), rmNodeEvent);
});
rmStateDelta.getNodeSource().forEach(rmNodeSourceEvent -> {
accumulatedNodeSourceEvents.put(rmNodeSourceEvent.getSourceName(), rmNodeSourceEvent);
});
if (rmStateDelta.getLatestCounter() == currentCounter) {
break;
} else {
currentCounter = rmStateDelta.getLatestCounter();
}
}
assertEquals(4, accumulatedNodeSourceEvents.size());
assertEquals(200, accumulatedNodeEvents.size());
assertEquals(6, numberOfRequests);
}
use of org.ow2.proactive.resourcemanager.common.event.RMNodeEvent in project scheduling by ow2-proactive.
the class RMGroupEventListener method notify.
public void notify(Collection<RMEvent> events) {
for (RMEvent event : events) {
if (event instanceof RMNodeEvent) {
RMNodeEvent nodeEvent = (RMNodeEvent) event;
nodeEvent(nodeEvent);
} else if (event instanceof RMNodeSourceEvent) {
RMNodeSourceEvent sourceEvent = (RMNodeSourceEvent) event;
nodeSourceEvent(sourceEvent);
} else {
rmEvent(event);
}
}
}
use of org.ow2.proactive.resourcemanager.common.event.RMNodeEvent in project scheduling by ow2-proactive.
the class RMStatisticsConcurrencyTest method concurrentTest.
@Test
public void concurrentTest() throws InterruptedException {
RMStatistics holder = new RMStatistics();
long zero = System.currentTimeMillis();
for (int i = 0; i < 1000000; ++i) {
holder.nodeEvent(new RMNodeEvent(RMEventType.NODE_ADDED, NodeState.FREE));
}
final long start = System.currentTimeMillis();
Thread busy = new Thread(() -> {
for (int i = 0; i < 100000; ++i) {
holder.nodeEvent(new RMNodeEvent(RMEventType.NODE_STATE_CHANGED, NodeState.BUSY, NodeState.FREE));
}
});
Thread free = new Thread(() -> {
for (int i = 0; i < 100000; ++i) {
holder.nodeEvent(new RMNodeEvent(RMEventType.NODE_STATE_CHANGED, NodeState.FREE, NodeState.BUSY));
}
});
Thread remover = new Thread(() -> {
for (int i = 0; i < 100000; ++i) {
holder.nodeEvent(new RMNodeEvent(RMEventType.NODE_REMOVED, NodeState.FREE));
assertEquals(1000000 - i - 1, holder.getAvailableNodesCount());
}
});
busy.start();
free.start();
remover.start();
busy.join();
free.join();
remover.join();
long ms = System.currentTimeMillis() - start;
long total = System.currentTimeMillis() - zero;
System.out.println("Concurrent time: " + ms + " ms.");
System.out.println("Total time: " + total + " ms.");
assertEquals(900000, holder.getAvailableNodesCount());
}
use of org.ow2.proactive.resourcemanager.common.event.RMNodeEvent in project scheduling by ow2-proactive.
the class TestNonForkedScriptTask method nonForkedTasks_SystemExitScript_KillsANode.
@Ignore
@Test
public void nonForkedTasks_SystemExitScript_KillsANode() throws Throwable {
TaskFlowJob job = (TaskFlowJob) StaxJobFactory.getFactory().createJob(new File(nonForked_jobDescriptor.toURI()).getAbsolutePath());
schedulerHelper.submitJob(job);
// busy event when task is scheduler
schedulerHelper.waitForAnyNodeEvent(RMEventType.NODE_STATE_CHANGED);
// down event when node is killed
RMNodeEvent nodeKilledEvent = schedulerHelper.waitForAnyNodeEvent(RMEventType.NODE_STATE_CHANGED);
assertEquals(NodeState.DOWN, nodeKilledEvent.getNodeState());
}
Aggregations