Merge "Changed the current WIP Pipeline Orchestrator to a more simplified Static...
[ovsdb.git] / openstack / net-virt-providers / src / main / java / org / opendaylight / ovsdb / openstack / netvirt / providers / openflow13 / PipelineOrchestratorImpl.java
1 /*
2  * Copyright (C) 2014 Red Hat, Inc.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Authors : Dave Tucker, Madhu Venugopal
9  */
10
11 package org.opendaylight.ovsdb.openstack.netvirt.providers.openflow13;
12
13 import java.util.List;
14 import java.util.Map;
15
16 import com.google.common.collect.Lists;
17 import com.google.common.collect.Maps;
18
19 public class PipelineOrchestratorImpl implements PipelineOrchestrator {
20
21     private List<Service> staticPipeline = Lists.newArrayList(
22                                                                 Service.CLASSIFIER,
23                                                                 Service.DIRECTOR,
24                                                                 Service.ARP_RESPONDER,
25                                                                 Service.INBOUND_NAT,
26                                                                 Service.INGRESS_ACL,
27                                                                 Service.LOAD_BALANCER,
28                                                                 Service.ROUTING,
29                                                                 Service.L2_REWRITE,
30                                                                 Service.L2_FORWARDING,
31                                                                 Service.EGRESS_ACL,
32                                                                 Service.OUTBOUND_NAT
33                                                               );
34     Map<Service, AbstractServiceInstance> serviceRegistry = Maps.newConcurrentMap();
35
36     public PipelineOrchestratorImpl() {
37     }
38     @Override
39     public void registerService(Service service,
40             AbstractServiceInstance serviceInstance) {
41         serviceRegistry.put(service, serviceInstance);
42     }
43
44     @Override
45     public void unregisterService(Service service) {
46         serviceRegistry.remove(service);
47     }
48
49     @Override
50     public Service getNextServiceInPipeline(Service service) {
51         int index = staticPipeline.indexOf(service);
52         if (index >= staticPipeline.size() - 1) return null;
53         return staticPipeline.get(index + 1);
54     }
55
56     @Override
57     public AbstractServiceInstance getServiceInstance(Service service) {
58         if (service == null) return null;
59         return serviceRegistry.get(service);
60     }
61 }