2 * Copyright © 2017 Orange, Inc. and others. All rights reserved.
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
8 package org.opendaylight.transportpce.servicehandler.impl;
10 import com.google.common.collect.ImmutableClassToInstanceMap;
11 import org.opendaylight.mdsal.binding.api.NotificationPublishService;
12 import org.opendaylight.mdsal.binding.api.RpcProviderService;
13 import org.opendaylight.transportpce.pce.service.PathComputationService;
14 import org.opendaylight.transportpce.renderer.provisiondevice.RendererServiceOperations;
15 import org.opendaylight.transportpce.servicehandler.catalog.CatalogDataStoreOperations;
16 import org.opendaylight.transportpce.servicehandler.listeners.NetworkListener;
17 import org.opendaylight.transportpce.servicehandler.listeners.PceListener;
18 import org.opendaylight.transportpce.servicehandler.listeners.RendererListener;
19 import org.opendaylight.transportpce.servicehandler.service.PCEServiceWrapper;
20 import org.opendaylight.transportpce.servicehandler.service.RendererServiceWrapper;
21 import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperations;
22 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.AddOpenroadmOperationalModesToCatalog;
23 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.AddSpecificOperationalModesToCatalog;
24 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceCreate;
25 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceDelete;
26 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceFeasibilityCheck;
27 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceReconfigure;
28 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceReroute;
29 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceRestoration;
30 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.TempServiceCreate;
31 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.TempServiceDelete;
32 import org.opendaylight.yangtools.concepts.Registration;
33 import org.opendaylight.yangtools.yang.binding.Rpc;
34 import org.osgi.service.component.annotations.Activate;
35 import org.osgi.service.component.annotations.Component;
36 import org.osgi.service.component.annotations.Deactivate;
37 import org.osgi.service.component.annotations.Reference;
38 import org.slf4j.Logger;
39 import org.slf4j.LoggerFactory;
43 * Top level service interface providing main OpenROADM controller services.
46 public class ServicehandlerImpl {
47 private static final Logger LOG = LoggerFactory.getLogger(ServicehandlerImpl.class);
49 private ServiceDataStoreOperations serviceDataStoreOperations;
50 private PceListener pceListenerImpl;
51 private RendererListener rendererListenerImpl;
52 private NetworkListener networkModelListenerImpl;
53 private CatalogDataStoreOperations catalogDataStoreOperations;
54 private NotificationPublishService notificationPublishService;
55 private PCEServiceWrapper pceServiceWrapper;
56 private RendererServiceWrapper rendererServiceWrapper;
57 private Registration reg;
60 public ServicehandlerImpl(@Reference RpcProviderService rpcProviderService,
61 @Reference ServiceDataStoreOperations serviceDataStoreOperations,
62 @Reference PceListener pceListenerImpl,
63 @Reference RendererListener rendererListenerImpl,
64 @Reference NetworkListener networkModelListenerImpl,
65 @Reference CatalogDataStoreOperations catalogDataStoreOperations,
66 @Reference PathComputationService pathComputationService,
67 @Reference RendererServiceOperations rendererServiceOperations,
68 @Reference NotificationPublishService notificationPublishService) {
69 this.serviceDataStoreOperations = serviceDataStoreOperations;
70 this.pceListenerImpl = pceListenerImpl;
71 this.rendererListenerImpl = rendererListenerImpl;
72 this.networkModelListenerImpl = networkModelListenerImpl;
73 this.catalogDataStoreOperations = catalogDataStoreOperations;
74 this.notificationPublishService = notificationPublishService;
75 this.pceServiceWrapper = new PCEServiceWrapper(pathComputationService, notificationPublishService);
76 this.rendererServiceWrapper = new RendererServiceWrapper(rendererServiceOperations, notificationPublishService);
77 this.reg = rpcProviderService.registerRpcImplementations(registerRPCs());
78 LOG.info("ServicehandlerImpl Initiated");
84 LOG.info("ServicehandlerImpl Closed");
87 public Registration getRegisteredRpc() {
91 private ImmutableClassToInstanceMap<Rpc<?, ?>> registerRPCs() {
92 return ImmutableClassToInstanceMap.<Rpc<?, ?>>builder()
93 .put(ServiceCreate.class, new ServiceCreateImpl(serviceDataStoreOperations, pceListenerImpl,
94 rendererListenerImpl, networkModelListenerImpl, pceServiceWrapper, notificationPublishService))
95 .put(ServiceDelete.class, new ServiceDeleteImpl(serviceDataStoreOperations, pceListenerImpl,
96 rendererListenerImpl, networkModelListenerImpl, rendererServiceWrapper, notificationPublishService))
97 .put(ServiceFeasibilityCheck.class, new ServiceFeasibilityCheckImpl(serviceDataStoreOperations,
98 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl, pceServiceWrapper))
99 .put(ServiceReconfigure.class, new ServiceReconfigureImpl(serviceDataStoreOperations, pceListenerImpl,
100 rendererListenerImpl, networkModelListenerImpl, rendererServiceWrapper))
101 .put(ServiceRestoration.class, new ServiceRestorationImpl(serviceDataStoreOperations, pceListenerImpl,
102 rendererListenerImpl, networkModelListenerImpl, rendererServiceWrapper))
103 .put(ServiceReroute.class, new ServiceRerouteImpl(serviceDataStoreOperations, pceServiceWrapper))
104 .put(TempServiceCreate.class, new TempServiceCreateImpl(serviceDataStoreOperations, pceListenerImpl,
105 rendererListenerImpl, networkModelListenerImpl, pceServiceWrapper))
106 .put(TempServiceDelete.class, new TempServiceDeleteImpl(serviceDataStoreOperations, pceListenerImpl,
107 rendererListenerImpl, rendererServiceWrapper))
108 .put(AddOpenroadmOperationalModesToCatalog.class,
109 new AddOpenroadmOperationalModesToCatalogImpl(catalogDataStoreOperations))
110 .put(AddSpecificOperationalModesToCatalog.class,
111 new AddSpecificOperationalModesToCatalogImpl(catalogDataStoreOperations))
115 // This is class is public so that these messages can be accessed from Junit (avoid duplications).
116 public static final class LogMessages {
118 public static final String PCE_CALLING;
119 public static final String ABORT_PCE_FAILED;
120 public static final String PCE_FAILED;
121 public static final String ABORT_SERVICE_NON_COMPLIANT;
122 public static final String SERVICE_NON_COMPLIANT;
123 public static final String RENDERER_DELETE_FAILED;
124 public static final String ABORT_VALID_FAILED;
125 public static final String ABORT_OR_TO_CATALOG_FAILED;
126 public static final String ABORT_SPECIFIC_TO_CATALOG_FAILED;
128 // Static blocks are generated once and spare memory.
130 PCE_CALLING = "Calling PCE";
131 ABORT_PCE_FAILED = "Aborting: PCE calculation failed ";
132 PCE_FAILED = "PCE calculation failed";
133 ABORT_SERVICE_NON_COMPLIANT = "Aborting: non-compliant service ";
134 SERVICE_NON_COMPLIANT = "non-compliant service";
135 RENDERER_DELETE_FAILED = "Renderer service delete failed";
136 ABORT_VALID_FAILED = "Aborting: validation of service create request failed";
137 ABORT_OR_TO_CATALOG_FAILED = "Aborting: validation of add OR to catalog request failed";
138 ABORT_SPECIFIC_TO_CATALOG_FAILED = "Aborting: validation of add Specific to catalog request failed";
141 public static String serviceInDS(String serviceName) {
142 return "Service '" + serviceName + "' already exists in datastore";
145 public static String serviceNotInDS(String serviceName) {
146 return "Service '" + serviceName + "' does not exist in datastore";
149 public static String servicePathNotInDS(String serviceName) {
150 return "Service Path from '" + serviceName + "' does not exist in datastore";
153 public static String serviceInService(String serviceName) {
154 return "Service '" + serviceName + "' is in 'inService' state";
157 private LogMessages() {