Search in sources :

Example 6 with Event

use of org.onosproject.event.Event in project onos by opennetworkinglab.

the class OFAgentManagerTest method validateEvents.

private void validateEvents(Enum... types) {
    int i = 0;
    assertEquals("Number of events does not match", types.length, testListener.events.size());
    for (Event event : testListener.events) {
        assertEquals("Incorrect event received", types[i], event.type());
        i++;
    }
    testListener.events.clear();
}
Also used : OFAgentEvent(org.onosproject.ofagent.api.OFAgentEvent) Event(org.onosproject.event.Event)

Example 7 with Event

use of org.onosproject.event.Event in project onos by opennetworkinglab.

the class WorkFlowEngine method post.

@Override
protected void post(WorkflowDataEvent event) {
    if (event.subject() == null || !isRelevant(event.subject())) {
        log.debug("ignore event {}", event);
        return;
    }
    // trigger next worklet selection
    WorkflowData dataModelContainer = event.subject();
    switch(event.type()) {
        case INSERT:
        case UPDATE:
            if (dataModelContainer.triggerNext()) {
                log.debug("workflowAccumulator.add: {}", dataModelContainer);
                workflowAccumulator.add(dataModelContainer);
            } else {
                log.debug("pass-workflowAccumulator.add: {}", dataModelContainer);
            }
            break;
        case REMOVE:
            break;
        default:
    }
    // trigger EventTask for WorkflowDataEvent
    eventMapTriggerExecutor.submit(() -> eventMapTrigger(event, // event hint supplier
    (ev) -> {
        if (ev == null || ev.subject() == null) {
            return null;
        }
        if (ev.subject() instanceof WorkflowData) {
            return ((WorkflowData) ev.subject()).name();
        } else {
            return null;
        }
    }));
}
Also used : WorkletDescription(org.onosproject.workflow.api.WorkletDescription) CoreService(org.onosproject.core.CoreService) Tools.groupedThreads(org.onlab.util.Tools.groupedThreads) WorkflowStore(org.onosproject.workflow.api.WorkflowStore) Workflow(org.onosproject.workflow.api.Workflow) Workplace(org.onosproject.workflow.api.Workplace) EventHintSupplier(org.onosproject.workflow.api.EventHintSupplier) Executors.newSingleThreadScheduledExecutor(java.util.concurrent.Executors.newSingleThreadScheduledExecutor) Map(java.util.Map) ApplicationId(org.onosproject.core.ApplicationId) ProgramCounter(org.onosproject.workflow.api.ProgramCounter) WorkPartitionService(org.onosproject.net.intent.WorkPartitionService) Event(org.onosproject.event.Event) NodeId(org.onosproject.cluster.NodeId) REMOVE_AFTER_COMPLETE(org.onosproject.workflow.api.WorkflowAttribute.REMOVE_AFTER_COMPLETE) DefaultWorkplace(org.onosproject.workflow.api.DefaultWorkplace) AbstractListenerManager(org.onosproject.event.AbstractListenerManager) Deactivate(org.osgi.service.component.annotations.Deactivate) Collection(java.util.Collection) Set(java.util.Set) Executors.newSingleThreadExecutor(java.util.concurrent.Executors.newSingleThreadExecutor) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) WorkflowData(org.onosproject.workflow.api.WorkflowData) HandlerTask(org.onosproject.workflow.api.HandlerTask) List(java.util.List) EventTimeoutTask(org.onosproject.workflow.api.EventTimeoutTask) JsonNodeFactory(com.fasterxml.jackson.databind.node.JsonNodeFactory) ClusterService(org.onosproject.cluster.ClusterService) JsonDataModelTree(org.onosproject.workflow.api.JsonDataModelTree) JsonDataModelInjector(org.onosproject.workflow.api.JsonDataModelInjector) WorkflowState(org.onosproject.workflow.api.WorkflowState) HandlerTaskBatchDelegate(org.onosproject.workflow.api.HandlerTaskBatchDelegate) StorageException(org.onosproject.store.service.StorageException) WorkflowException(org.onosproject.workflow.api.WorkflowException) EventTask(org.onosproject.workflow.api.EventTask) WorkplaceStoreDelegate(org.onosproject.workflow.api.WorkplaceStoreDelegate) CompletableFuture(java.util.concurrent.CompletableFuture) WorkflowExecutionService(org.onosproject.workflow.api.WorkflowExecutionService) Worklet(org.onosproject.workflow.api.Worklet) Component(org.osgi.service.component.annotations.Component) WorkflowDataListener(org.onosproject.workflow.api.WorkflowDataListener) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) Activate(org.osgi.service.component.annotations.Activate) TimeoutTask(org.onosproject.workflow.api.TimeoutTask) ContextEventMapStore(org.onosproject.workflow.api.ContextEventMapStore) ExecutorService(java.util.concurrent.ExecutorService) StaticDataModelInjector(org.onosproject.workflow.api.StaticDataModelInjector) Logger(org.slf4j.Logger) WorkflowContext(org.onosproject.workflow.api.WorkflowContext) WorkflowBatchDelegate(org.onosproject.workflow.api.WorkflowBatchDelegate) Executors.newFixedThreadPool(java.util.concurrent.Executors.newFixedThreadPool) ReferenceCardinality(org.osgi.service.component.annotations.ReferenceCardinality) WorkflowDataEvent(org.onosproject.workflow.api.WorkflowDataEvent) SystemWorkflowContext(org.onosproject.workflow.api.SystemWorkflowContext) WorkplaceStore(org.onosproject.workflow.api.WorkplaceStore) TimerChain(org.onosproject.workflow.api.TimerChain) LoggerFactory.getLogger(org.slf4j.LoggerFactory.getLogger) CheckCondition.check(org.onosproject.workflow.api.CheckCondition.check) Reference(org.osgi.service.component.annotations.Reference) LeadershipService(org.onosproject.cluster.LeadershipService) WorkflowData(org.onosproject.workflow.api.WorkflowData)

Example 8 with Event

use of org.onosproject.event.Event in project onos by opennetworkinglab.

the class DeviceKeyManagerTest method validateEvents.

/**
 * Method to validate that actual versus expected device key events were
 * received correctly.
 *
 * @param types expected device key events.
 */
private void validateEvents(Enum... types) {
    TestTools.assertAfter(100, () -> {
        int i = 0;
        assertEquals("wrong events received", types.length, listener.events.size());
        for (Event event : listener.events) {
            assertEquals("incorrect event type", types[i], event.type());
            i++;
        }
        listener.events.clear();
    });
}
Also used : DeviceKeyEvent(org.onosproject.net.key.DeviceKeyEvent) Event(org.onosproject.event.Event)

Example 9 with Event

use of org.onosproject.event.Event in project onos by opennetworkinglab.

the class K8sIngressManagerTest method validateEvents.

private void validateEvents(Enum... types) {
    int i = 0;
    assertEquals("Number of events did not match", types.length, testListener.events.size());
    for (Event event : testListener.events) {
        assertEquals("Incorrect event received", types[i], event.type());
        i++;
    }
    testListener.events.clear();
}
Also used : K8sIngressEvent(org.onosproject.k8snetworking.api.K8sIngressEvent) Event(org.onosproject.event.Event)

Example 10 with Event

use of org.onosproject.event.Event in project onos by opennetworkinglab.

the class K8sNamespaceManagerTest method validateEvents.

private void validateEvents(Enum... types) {
    int i = 0;
    assertEquals("Number of events did not match", types.length, testListener.events.size());
    for (Event event : testListener.events) {
        assertEquals("Incorrect event received", types[i], event.type());
        i++;
    }
    testListener.events.clear();
}
Also used : K8sNamespaceEvent(org.onosproject.k8snetworking.api.K8sNamespaceEvent) Event(org.onosproject.event.Event)

Aggregations

Event (org.onosproject.event.Event)47 TopologyEvent (org.onosproject.net.topology.TopologyEvent)9 DeviceEvent (org.onosproject.net.device.DeviceEvent)7 LinkEvent (org.onosproject.net.link.LinkEvent)6 ConnectPoint (org.onosproject.net.ConnectPoint)5 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 HostEvent (org.onosproject.net.host.HostEvent)3 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2 Map (java.util.Map)2 Set (java.util.Set)2 CompletableFuture (java.util.concurrent.CompletableFuture)2 ExecutorService (java.util.concurrent.ExecutorService)2 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)2 Collectors (java.util.stream.Collectors)2 ClusterEvent (org.onosproject.cluster.ClusterEvent)2 MastershipEvent (org.onosproject.mastership.MastershipEvent)2 Link (org.onosproject.net.Link)2 IntentEvent (org.onosproject.net.intent.IntentEvent)2