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
9 package org.opendaylight.transportpce.servicehandler;
11 import com.google.common.util.concurrent.ListenableFuture;
12 import com.google.common.util.concurrent.ListeningExecutorService;
13 import com.google.common.util.concurrent.MoreExecutors;
14 import java.util.ArrayList;
15 import java.util.List;
16 import java.util.concurrent.Callable;
17 import java.util.concurrent.CancellationException;
18 import java.util.concurrent.ExecutionException;
19 import java.util.concurrent.Executors;
20 import java.util.concurrent.Future;
22 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
23 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev161014.ServiceCreateInput;
24 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev161014.ServiceReconfigureInput;
25 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev161014.service.list.Services;
26 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.PathComputationRequestOutput;
27 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.ServiceDeleteInput;
28 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.ServiceDeleteInputBuilder;
29 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.ServiceDeleteOutput;
30 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.ServiceDeleteOutputBuilder;
31 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.ServiceImplementationRequestInput;
32 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.ServiceImplementationRequestInputBuilder;
33 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.ServiceImplementationRequestOutput;
34 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.ServiceImplementationRequestOutputBuilder;
35 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.StubrendererService;
36 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.service.implementation.request.input.PathDescription;
37 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.service.implementation.request.input.PathDescriptionBuilder;
38 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.service.implementation.request.input.ServiceAEnd;
39 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.service.implementation.request.input.ServiceAEndBuilder;
40 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.service.implementation.request.input.ServiceZEnd;
41 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.service.implementation.request.input.ServiceZEndBuilder;
42 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.ServiceFormat;
43 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.port.Port;
44 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.port.PortBuilder;
45 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.path.description.AToZDirection;
46 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.path.description.AToZDirectionBuilder;
47 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.path.description.ZToADirection;
48 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.path.description.ZToADirectionBuilder;
49 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.path.description.atoz.direction.AToZ;
50 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.path.description.atoz.direction.AToZBuilder;
51 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.path.description.atoz.direction.AToZKey;
52 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.path.description.ztoa.direction.ZToA;
53 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.path.description.ztoa.direction.ZToABuilder;
54 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.path.description.ztoa.direction.ZToAKey;
55 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.pce.resource.Resource;
56 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.pce.resource.ResourceBuilder;
57 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.service.endpoint.sp.RxDirection;
58 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.service.endpoint.sp.RxDirectionBuilder;
59 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.service.endpoint.sp.TxDirection;
60 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.service.endpoint.sp.TxDirectionBuilder;
61 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.service.handler.header.ServiceHandlerHeaderBuilder;
62 import org.opendaylight.yangtools.yang.common.RpcResult;
63 import org.slf4j.Logger;
64 import org.slf4j.LoggerFactory;
69 * Class for Mapping and Sending
70 * Service Implemention requests :
71 * - service implementation
73 * @author Martial Coulibaly ( martial.coulibaly@gfi.com ) on behalf of Orange
76 public class MappingAndSendingSIRequest {
78 private static final Logger LOG = LoggerFactory.getLogger(MappingAndSendingSIRequest.class);
79 /* Permit to call Renderer RPCs. */
80 private StubrendererService service;
81 /* define procedure success (or not ). */
82 private Boolean success = false;
83 /* permit to call bundle service (PCE, Renderer, Servicehandler. */
84 private RpcProviderRegistry rpcRegistry;
85 /* store all error messages. */
87 ServiceImplementationRequestInput serviceImplementationRequestInput = null;
88 ServiceDeleteInput serviceDeleteInput = null;
90 private final ListeningExecutorService executor = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(5));
94 * MappingAndSendingSIRequest class constructor
95 * for RPC serviceCreate.
97 * @param rpcRegistry rpcRegistry
98 * @param serviceCreateInput serviceCreateInput
99 * @param pathComputationOutput pathComputationOutput
101 public MappingAndSendingSIRequest(RpcProviderRegistry rpcRegistry,
102 ServiceCreateInput serviceCreateInput,PathComputationRequestOutput pathComputationOutput) {
103 this.rpcRegistry = rpcRegistry;
104 if (rpcRegistry != null) {
105 service = rpcRegistry.getRpcService(StubrendererService.class);
110 /* Building ServiceImplementationRequestInput / ServiceDeleteInput serviceDeleteInput. */
111 ServiceHandlerHeaderBuilder serviceHandlerHeader = new ServiceHandlerHeaderBuilder();
112 if (serviceCreateInput.getSdncRequestHeader() != null) {
113 serviceHandlerHeader.setRequestId(serviceCreateInput.getSdncRequestHeader().getRequestId());
117 /*ServiceAEnd Build */
118 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev161014
119 .service.create.input.ServiceAEnd tempA = serviceCreateInput.getServiceAEnd();
121 org.opendaylight.yang.gen.v1.http.org.openroadm.common
122 .service.types.rev161014.service.port.Port tempAPortRx =
123 serviceCreateInput.getServiceAEnd().getRxDirection().getPort();
125 org.opendaylight.yang.gen.v1.http.org.openroadm.common
126 .service.types.rev161014.service.port.Port tempAPortTx =
127 serviceCreateInput.getServiceAEnd().getTxDirection().getPort();
129 /*Port portARx = new PortBuilder()
130 .setPortDeviceName(tempAPortRx.getPortDeviceName())
131 .setPortName(tempAPortRx.getPortName())
132 .setPortRack(tempAPortRx.getPortRack())
133 .setPortShelf(tempAPortRx.getPortShelf())
134 .setPortSlot(tempAPortRx.getPortSlot())
135 .setPortSubSlot(tempAPortRx.getPortSubSlot())
136 .setPortType(tempAPortRx.getPortType())
139 Port portATx = new PortBuilder()
140 .setPortDeviceName(tempAPortTx.getPortDeviceName())
141 .setPortName(tempAPortTx.getPortName())
142 .setPortRack(tempAPortTx.getPortRack())
143 .setPortShelf(tempAPortTx.getPortShelf())
144 .setPortSlot(tempAPortTx.getPortSlot())
145 .setPortSubSlot(tempAPortTx.getPortSubSlot())
146 .setPortType(tempAPortTx.getPortType())
149 RxDirection rxDirectionAEnd = new RxDirectionBuilder()
153 TxDirection txDirectionAEnd = new TxDirectionBuilder()
157 RxDirection rxDirectionAEnd = getRxDirection(tempAPortRx);
159 TxDirection txDirectionAEnd = getTxDirection(tempAPortTx);
161 ServiceAEnd serviceAEnd = new ServiceAEndBuilder()
162 .setClli(tempA.getClli())
163 .setNodeId(tempA.getNodeId())
164 .setServiceFormat(ServiceFormat.valueOf(tempA.getServiceFormat().getName()))
165 .setServiceRate(tempA.getServiceRate())
166 .setRxDirection(rxDirectionAEnd)
167 .setTxDirection(txDirectionAEnd)
170 /* ServiceZEnd Build */
171 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev161014
172 .service.create.input.ServiceZEnd tempZ = serviceCreateInput.getServiceZEnd();
174 org.opendaylight.yang.gen.v1.http.org.openroadm.common
175 .service.types.rev161014.service.port.Port tempZPortRx =
176 serviceCreateInput.getServiceZEnd().getRxDirection().getPort();
178 org.opendaylight.yang.gen.v1.http.org.openroadm.common
179 .service.types.rev161014.service.port.Port tempZPortTx =
180 serviceCreateInput.getServiceZEnd().getTxDirection().getPort();
182 /*Port portZRx = new PortBuilder()
183 .setPortDeviceName(tempZPortRx.getPortDeviceName())
184 .setPortName(tempZPortRx.getPortName())
185 .setPortRack(tempZPortRx.getPortRack())
186 .setPortShelf(tempZPortRx.getPortShelf())
187 .setPortSlot(tempZPortRx.getPortSlot())
188 .setPortSubSlot(tempZPortRx.getPortSubSlot())
189 .setPortType(tempZPortRx.getPortType())
192 Port portZTx = new PortBuilder()
193 .setPortDeviceName(tempZPortTx.getPortDeviceName())
194 .setPortName(tempZPortTx.getPortName())
195 .setPortRack(tempZPortTx.getPortRack())
196 .setPortShelf(tempZPortTx.getPortShelf())
197 .setPortSlot(tempZPortTx.getPortSlot())
198 .setPortSubSlot(tempZPortTx.getPortSubSlot())
199 .setPortType(tempZPortTx.getPortType())
202 RxDirection rxDirectionZEnd = new RxDirectionBuilder()
206 TxDirection txDirectionZEnd = new TxDirectionBuilder()
210 RxDirection rxDirectionZEnd = getRxDirection(tempZPortRx);
212 TxDirection txDirectionZEnd = getTxDirection(tempZPortTx);
214 ServiceZEnd serviceZEnd = new ServiceZEndBuilder()
215 .setClli(tempZ.getClli())
216 .setNodeId(tempZ.getNodeId())
217 .setServiceFormat(ServiceFormat.valueOf(tempZ.getServiceFormat().getName()))
218 .setServiceRate(tempZ.getServiceRate())
219 .setRxDirection(rxDirectionZEnd)
220 .setTxDirection(txDirectionZEnd)
224 /* ServiceImplementationRequestInput Build*/
225 org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types
226 .rev170426.response.parameters.sp.response.parameters.PathDescription tmp = null;
228 tmp = pathComputationOutput.getResponseParameters().getPathDescription();
229 } catch (NullPointerException e) {
230 LOG.error("PathDescription is null : " + e.toString());
232 PathDescriptionBuilder pathDescription = new PathDescriptionBuilder();
234 pathDescription = new PathDescriptionBuilder(tmp);
236 serviceImplementationRequestInput = new ServiceImplementationRequestInputBuilder()
237 .setPathDescription(pathDescription.build())
238 .setServiceHandlerHeader(serviceHandlerHeader.build())
239 .setServiceName(serviceCreateInput.getServiceName())
240 .setServiceAEnd(serviceAEnd)
241 .setServiceZEnd(serviceZEnd)
246 * MappingAndSendingSIRequest class constructor
247 * for RPC serviceReconfigure.
249 * @param rpcRegistry rpcRegistry
250 * @param serviceReconfigureInput serviceReconfigureInput
251 * @param pathComputationOutput pathComputationOutput
254 public MappingAndSendingSIRequest(RpcProviderRegistry rpcRegistry,
255 ServiceReconfigureInput serviceReconfigureInput,PathComputationRequestOutput pathComputationOutput) {
256 this.rpcRegistry = rpcRegistry;
257 if (rpcRegistry != null) {
258 service = rpcRegistry.getRpcService(StubrendererService.class);
263 /* Building ServiceImplementationRequestInput / ServiceDeleteInput serviceDeleteInput .*/
264 ServiceHandlerHeaderBuilder serviceHandlerHeader = new ServiceHandlerHeaderBuilder();
266 /*ServiceAEnd Build .*/
267 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev161014
268 .service.reconfigure.input.ServiceAEnd tempA = serviceReconfigureInput.getServiceAEnd();
270 org.opendaylight.yang.gen.v1.http.org.openroadm.common
271 .service.types.rev161014.service.port.Port tempAPortRx =
272 serviceReconfigureInput.getServiceAEnd().getRxDirection().getPort();
274 org.opendaylight.yang.gen.v1.http.org.openroadm.common
275 .service.types.rev161014.service.port.Port tempAPortTx =
276 serviceReconfigureInput.getServiceAEnd().getTxDirection().getPort();
278 /*Port portARx = new PortBuilder()
279 .setPortDeviceName(tempAPortRx.getPortDeviceName())
280 .setPortName(tempAPortRx.getPortName())
281 .setPortRack(tempAPortRx.getPortRack())
282 .setPortShelf(tempAPortRx.getPortShelf())
283 .setPortSlot(tempAPortRx.getPortSlot())
284 .setPortSubSlot(tempAPortRx.getPortSubSlot())
285 .setPortType(tempAPortRx.getPortType())
288 Port portATx = new PortBuilder()
289 .setPortDeviceName(tempAPortTx.getPortDeviceName())
290 .setPortName(tempAPortTx.getPortName())
291 .setPortRack(tempAPortTx.getPortRack())
292 .setPortShelf(tempAPortTx.getPortShelf())
293 .setPortSlot(tempAPortTx.getPortSlot())
294 .setPortSubSlot(tempAPortTx.getPortSubSlot())
295 .setPortType(tempAPortTx.getPortType())
298 RxDirection rxDirectionAEnd = new RxDirectionBuilder()
302 TxDirection txDirectionAEnd = new TxDirectionBuilder()
306 RxDirection rxDirectionAEnd = getRxDirection(tempAPortRx);
308 TxDirection txDirectionAEnd = getTxDirection(tempAPortTx);
310 ServiceAEnd serviceAEnd = new ServiceAEndBuilder()
311 .setClli(tempA.getClli())
312 .setNodeId(tempA.getNodeId())
313 .setServiceFormat(ServiceFormat.valueOf(tempA.getServiceFormat().getName()))
314 .setServiceRate(tempA.getServiceRate())
315 .setRxDirection(rxDirectionAEnd)
316 .setTxDirection(txDirectionAEnd)
319 /* ServiceZEnd Build .*/
320 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev161014
321 .service.reconfigure.input.ServiceZEnd tempZ = serviceReconfigureInput.getServiceZEnd();
323 org.opendaylight.yang.gen.v1.http.org.openroadm.common
324 .service.types.rev161014.service.port.Port tempZPortRx =
325 serviceReconfigureInput.getServiceZEnd().getRxDirection().getPort();
327 org.opendaylight.yang.gen.v1.http.org.openroadm.common
328 .service.types.rev161014.service.port.Port tempZPortTx =
329 serviceReconfigureInput.getServiceZEnd().getTxDirection().getPort();
331 /*Port portZRx = new PortBuilder()
332 .setPortDeviceName(tempZPortRx.getPortDeviceName())
333 .setPortName(tempZPortRx.getPortName())
334 .setPortRack(tempZPortRx.getPortRack())
335 .setPortShelf(tempZPortRx.getPortShelf())
336 .setPortSlot(tempZPortRx.getPortSlot())
337 .setPortSubSlot(tempZPortRx.getPortSubSlot())
338 .setPortType(tempZPortRx.getPortType())
341 Port portZTx = new PortBuilder()
342 .setPortDeviceName(tempZPortTx.getPortDeviceName())
343 .setPortName(tempZPortTx.getPortName())
344 .setPortRack(tempZPortTx.getPortRack())
345 .setPortShelf(tempZPortTx.getPortShelf())
346 .setPortSlot(tempZPortTx.getPortSlot())
347 .setPortSubSlot(tempZPortTx.getPortSubSlot())
348 .setPortType(tempZPortTx.getPortType())
351 RxDirection rxDirectionZEnd = new RxDirectionBuilder()
355 TxDirection txDirectionZEnd = new TxDirectionBuilder()
359 RxDirection rxDirectionZEnd = getRxDirection(tempZPortRx);
360 TxDirection txDirectionZEnd = getTxDirection(tempZPortTx);
362 ServiceZEnd serviceZEnd = new ServiceZEndBuilder()
363 .setClli(tempZ.getClli())
364 .setNodeId(tempZ.getNodeId())
365 .setServiceFormat(ServiceFormat.valueOf(tempZ.getServiceFormat().getName()))
366 .setServiceRate(tempZ.getServiceRate())
367 .setRxDirection(rxDirectionZEnd)
368 .setTxDirection(txDirectionZEnd)
372 /* ServiceImplementationRequestInput Build.*/
374 org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types
375 .rev170426.response.parameters.sp.response.parameters.PathDescription tmp = null;
377 tmp = pathComputationOutput.getResponseParameters().getPathDescription();
378 } catch (NullPointerException e) {
379 LOG.error("PathDescription is null : " + e.toString());
381 PathDescriptionBuilder pathDescription = new PathDescriptionBuilder();
383 pathDescription = new PathDescriptionBuilder(tmp);
385 serviceImplementationRequestInput = new ServiceImplementationRequestInputBuilder()
386 .setPathDescription(pathDescription.build())
387 .setServiceHandlerHeader(serviceHandlerHeader.build())
388 .setServiceName(serviceReconfigureInput.getNewServiceName())
389 .setServiceAEnd(serviceAEnd)
390 .setServiceZEnd(serviceZEnd)
392 LOG.info("ServiceImplementationRequestInput : " + serviceImplementationRequestInput.toString());
397 * MappingAndSendingSIRequest class constructor
398 * for RPC serviceDelete.
400 * @param rpcRegistry RpcProviderRegistry
401 * @param requestId Request ID
402 * @param serviceName Service name
404 public MappingAndSendingSIRequest(RpcProviderRegistry rpcRegistry,String requestId, String serviceName) {
405 this.rpcRegistry = rpcRegistry;
406 if (rpcRegistry != null) {
407 service = rpcRegistry.getRpcService(StubrendererService.class);
412 /* ServiceDeleteInput Build .*/
413 ServiceHandlerHeaderBuilder serviceHandlerHeader = new ServiceHandlerHeaderBuilder();
414 if (requestId != null) {
415 serviceHandlerHeader.setRequestId(requestId);
418 serviceDeleteInput = new ServiceDeleteInputBuilder()
419 .setServiceHandlerHeader(serviceHandlerHeader.build())
420 .setServiceName(serviceName)
425 * MappingAndSendingSIRequest Class constructor
426 * for modify Service in ODL Datastore.
428 * @param rpcRegistry RpcProviderRegistry
429 * @param services Services
431 public MappingAndSendingSIRequest(RpcProviderRegistry rpcRegistry,Services services) {
432 this.rpcRegistry = rpcRegistry;
433 if (rpcRegistry != null) {
434 service = rpcRegistry.getRpcService(StubrendererService.class);
439 /* Building ServiceImplementationRequestInput / ServiceDeleteInput serviceDeleteInput .*/
440 ServiceHandlerHeaderBuilder serviceHandlerHeader = new ServiceHandlerHeaderBuilder();
442 /*ServiceAEnd Build .*/
443 org.opendaylight.yang.gen.v1.http.org.openroadm.common.service
444 .types.rev161014.service.ServiceAEnd tempA = services.getServiceAEnd();
446 org.opendaylight.yang.gen.v1.http.org.openroadm.common
447 .service.types.rev161014.service.port.Port tempAPortRx = tempA.getRxDirection().getPort();
449 org.opendaylight.yang.gen.v1.http.org.openroadm.common
450 .service.types.rev161014.service.port.Port tempAPortTx = tempA.getTxDirection().getPort();
453 RxDirection rxDirectionAEnd = getRxDirection(tempAPortRx);
455 TxDirection txDirectionAEnd = getTxDirection(tempAPortTx);
457 ServiceAEnd serviceAEnd = new ServiceAEndBuilder()
458 .setClli(tempA.getClli())
459 .setNodeId(tempA.getNodeId())
460 .setServiceFormat(ServiceFormat.valueOf(tempA.getServiceFormat().getName()))
461 .setServiceRate(tempA.getServiceRate())
462 .setRxDirection(rxDirectionAEnd)
463 .setTxDirection(txDirectionAEnd)
466 /* ServiceZEnd Build .*/
467 org.opendaylight.yang.gen.v1.http.org.openroadm.common.service
468 .types.rev161014.service.ServiceZEnd tempZ = services.getServiceZEnd();
470 org.opendaylight.yang.gen.v1.http.org.openroadm.common
471 .service.types.rev161014.service.port.Port tempZPortRx = tempZ.getRxDirection().getPort();
473 org.opendaylight.yang.gen.v1.http.org.openroadm.common
474 .service.types.rev161014.service.port.Port tempZPortTx = tempZ.getTxDirection().getPort();
476 RxDirection rxDirectionZEnd = getRxDirection(tempZPortRx);
477 TxDirection txDirectionZEnd = getTxDirection(tempZPortTx);
479 ServiceZEnd serviceZEnd = new ServiceZEndBuilder()
480 .setClli(tempZ.getClli())
481 .setNodeId(tempZ.getNodeId())
482 .setServiceFormat(ServiceFormat.valueOf(tempZ.getServiceFormat().getName()))
483 .setServiceRate(tempZ.getServiceRate())
484 .setRxDirection(rxDirectionZEnd)
485 .setTxDirection(txDirectionZEnd)
489 /* ServiceImplementationRequestInput Build.*/
492 List<AToZ> atozList = new ArrayList<AToZ>();
493 List<ZToA> ztoaList = new ArrayList<ZToA>();
495 for (org.opendaylight.yang.gen.v1.http.org.openroadm.topology.rev161014.topology.AToZ
496 tmp : services.getTopology().getAToZ()) {
498 AToZKey key = new AToZKey(tmp.getKey().getId());
499 Resource atozresource = new ResourceBuilder()
501 AToZ atoz = new AToZBuilder()
504 .setResource(atozresource)
509 for (org.opendaylight.yang.gen.v1.http.org.openroadm.topology.rev161014.topology.ZToA
510 tmp : services.getTopology().getZToA()) {
511 ZToAKey key = new ZToAKey(tmp.getKey().getId());
512 Resource ztoaresource = new ResourceBuilder()
514 ZToA ztoa = new ZToABuilder()
517 .setResource(ztoaresource)
522 AToZDirection atozdirection = new AToZDirectionBuilder()
526 ZToADirection ztoadirection = new ZToADirectionBuilder()
531 PathDescription pathDescription = new PathDescriptionBuilder()
532 .setAToZDirection(atozdirection)
533 .setZToADirection(ztoadirection)
536 serviceImplementationRequestInput = new ServiceImplementationRequestInputBuilder()
537 .setPathDescription(pathDescription)
538 .setServiceHandlerHeader(serviceHandlerHeader.build())
539 .setServiceName(services.getServiceName())
540 .setServiceAEnd(serviceAEnd)
541 .setServiceZEnd(serviceZEnd)
543 LOG.info("ServiceImplementationRequestInput : " + serviceImplementationRequestInput.toString());
547 * Create RxDirection with Port
550 * @param tempPort Port
551 * @return RxDirection
553 public RxDirection getRxDirection(org.opendaylight.yang.gen.v1.http.org.openroadm.common
554 .service.types.rev161014.service.port.Port tempPort) {
555 Port port = new PortBuilder()
556 .setPortDeviceName(tempPort.getPortDeviceName())
557 .setPortName(tempPort.getPortName())
558 .setPortRack(tempPort.getPortRack())
559 .setPortShelf(tempPort.getPortShelf())
560 .setPortSlot(tempPort.getPortSlot())
561 .setPortSubSlot(tempPort.getPortSubSlot())
562 .setPortType(tempPort.getPortType())
565 RxDirection result = new RxDirectionBuilder()
573 * Create TxDirection with Port
576 * @param tempPort Port
577 * @return TxDirection TxDirection
579 public TxDirection getTxDirection(org.opendaylight.yang.gen.v1.http.org.openroadm.common
580 .service.types.rev161014.service.port.Port tempPort) {
581 Port port = new PortBuilder()
582 .setPortDeviceName(tempPort.getPortDeviceName())
583 .setPortName(tempPort.getPortName())
584 .setPortRack(tempPort.getPortRack())
585 .setPortShelf(tempPort.getPortShelf())
586 .setPortSlot(tempPort.getPortSlot())
587 .setPortSubSlot(tempPort.getPortSubSlot())
588 .setPortType(tempPort.getPortType())
591 TxDirection result = new TxDirectionBuilder()
599 * Send serviceImplementation request to Render.
601 * @return ServiceImplementationRequestOutput data response from Renderer
603 public ListenableFuture<ServiceImplementationRequestOutput> serviceImplementation() {
605 return executor.submit(new Callable<ServiceImplementationRequestOutput>() {
608 public ServiceImplementationRequestOutput call() throws Exception {
609 ServiceImplementationRequestOutput output = null;
610 if (serviceImplementationRequestInput != null) {
611 RpcResult<ServiceImplementationRequestOutput> rendererOutputResult = null;
612 Future<RpcResult<ServiceImplementationRequestOutput>> rendererOutputFuture =
613 service.serviceImplementationRequest(serviceImplementationRequestInput);
615 rendererOutputResult = rendererOutputFuture.get();//wait to get the result
616 } catch (InterruptedException | CancellationException | ExecutionException e) {
617 setError("Did not receive the expected response from renderer to pathComputationRequest RPC "
620 rendererOutputFuture.cancel(true);
623 if (rendererOutputResult != null && rendererOutputResult.isSuccessful()) {
624 LOG.info("Renderer replied to serviceImplementation Request !");
626 ServiceImplementationRequestOutput rendererOutput = rendererOutputResult.getResult();
627 output = new ServiceImplementationRequestOutputBuilder()
628 .setConfigurationResponseCommon(rendererOutput.getConfigurationResponseCommon())
633 LOG.info("serviceImplementationRequestInput is not valid");
643 * Send serviceDelete request to Render.
645 * @return ServiceDeleteOutput data response from Renderer
647 public ListenableFuture<ServiceDeleteOutput> serviceDelete() {
649 return executor.submit(new Callable<ServiceDeleteOutput>() {
652 public ServiceDeleteOutput call() throws Exception {
653 ServiceDeleteOutput output = null;
654 if (serviceDeleteInput != null) {
655 RpcResult<ServiceDeleteOutput> rendererOutputResult = null;
656 Future<RpcResult<ServiceDeleteOutput>> rendererOutputFuture =
657 service.serviceDelete(serviceDeleteInput);
660 rendererOutputResult = rendererOutputFuture.get();//wait to get the result
661 } catch (InterruptedException | CancellationException | ExecutionException e) {
662 setError("Did not receive the expected response from renderer to pathComputationRequest RPC "
665 rendererOutputFuture.cancel(true);
668 if (rendererOutputResult != null && rendererOutputResult.isSuccessful()) {
669 LOG.info("Renderer replied to serviceDelete Request!");
671 ServiceDeleteOutput rendererOutput = rendererOutputResult.getResult();
672 output = new ServiceDeleteOutputBuilder()
673 .setConfigurationResponseCommon(rendererOutput.getConfigurationResponseCommon())
685 public Boolean getSuccess() {
689 public void setSuccess(Boolean success) {
690 this.success = success;
693 public String getError() {
697 public void setError(String error) {