Search in sources :

Example 1 with RMNodeEvent

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);
}
Also used : NodeSource(org.ow2.proactive.resourcemanager.nodesource.NodeSource)

Example 2 with RMNodeEvent

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);
}
Also used : HashMap(java.util.HashMap) RMStateDelta(org.ow2.proactive.resourcemanager.common.event.dto.RMStateDelta) Test(org.junit.Test)

Example 3 with RMNodeEvent

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);
        }
    }
}
Also used : RMNodeSourceEvent(org.ow2.proactive.resourcemanager.common.event.RMNodeSourceEvent) RMEvent(org.ow2.proactive.resourcemanager.common.event.RMEvent) RMNodeEvent(org.ow2.proactive.resourcemanager.common.event.RMNodeEvent)

Example 4 with RMNodeEvent

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());
}
Also used : RMNodeEvent(org.ow2.proactive.resourcemanager.common.event.RMNodeEvent) Test(org.junit.Test)

Example 5 with RMNodeEvent

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());
}
Also used : TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) File(java.io.File) RMNodeEvent(org.ow2.proactive.resourcemanager.common.event.RMNodeEvent) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

RMNodeEvent (org.ow2.proactive.resourcemanager.common.event.RMNodeEvent)39 Test (org.junit.Test)24 RMFunctionalTest (functionaltests.utils.RMFunctionalTest)19 NodeSet (org.ow2.proactive.utils.NodeSet)16 File (java.io.File)15 ResourceManager (org.ow2.proactive.resourcemanager.frontend.ResourceManager)15 TestNode (functionaltests.utils.TestNode)8 HashMap (java.util.HashMap)8 NodeState (org.ow2.proactive.resourcemanager.common.NodeState)8 Node (org.objectweb.proactive.core.node.Node)7 SelectionScript (org.ow2.proactive.scripting.SelectionScript)7 RMNodeSourceEvent (org.ow2.proactive.resourcemanager.common.event.RMNodeSourceEvent)6 StaticPolicy (org.ow2.proactive.resourcemanager.nodesource.policy.StaticPolicy)6 RMDeployingNode (org.ow2.proactive.resourcemanager.rmnode.RMDeployingNode)6 Criteria (org.ow2.proactive.utils.Criteria)6 RMMonitorEventReceiver (functionaltests.monitor.RMMonitorEventReceiver)5 RMTHelper (functionaltests.utils.RMTHelper)5 HashSet (java.util.HashSet)5 BooleanWrapper (org.objectweb.proactive.core.util.wrapper.BooleanWrapper)5 ArrayList (java.util.ArrayList)4