Servicehandler Tests
[transportpce.git] / servicehandler / src / main / java / org / opendaylight / transportpce / servicehandler / MappingAndSendingSIRequest.java
1 /*
2  * Copyright © 2017 Orange, Inc. and others.  All rights reserved.
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
9 package org.opendaylight.transportpce.servicehandler;
10
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.concurrent.Callable;
15 import java.util.concurrent.CancellationException;
16 import java.util.concurrent.ExecutionException;
17 import java.util.concurrent.Executors;
18 import java.util.concurrent.Future;
19
20 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
21 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.PathComputationRequestOutput;
22 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.ServiceDeleteInput;
23 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.ServiceDeleteInputBuilder;
24 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.ServiceDeleteOutput;
25 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.ServiceImplementationRequestInput;
26 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.ServiceImplementationRequestInputBuilder;
27 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.ServiceImplementationRequestOutput;
28 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.StubrendererService;
29 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.service.implementation.request.input.PathDescriptionBuilder;
30 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.service.implementation.request.input.ServiceAEnd;
31 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.service.implementation.request.input.ServiceAEndBuilder;
32 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.service.implementation.request.input.ServiceZEnd;
33 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.service.implementation.request.input.ServiceZEndBuilder;
34 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.ServiceFormat;
35 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.sdnc.request.header.SdncRequestHeader;
36 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceCreateInput;
37 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceReconfigureInput;
38 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.list.Services;
39 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.service.endpoint.sp.RxDirection;
40 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.service.endpoint.sp.RxDirectionBuilder;
41 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.service.endpoint.sp.TxDirection;
42 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.service.endpoint.sp.TxDirectionBuilder;
43 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.service.handler.header.ServiceHandlerHeaderBuilder;
44 import org.opendaylight.yangtools.yang.common.RpcResult;
45 import org.slf4j.Logger;
46 import org.slf4j.LoggerFactory;
47
48
49
50 /**
51  * Class for Mapping and Sending
52  * Service Implemention requests :
53  * - service implementation
54  * - service delete.
55  * @author Martial Coulibaly ( martial.coulibaly@gfi.com ) on behalf of Orange
56  *
57  */
58 public class MappingAndSendingSIRequest {
59     /** Logging. */
60     private static final Logger LOG = LoggerFactory.getLogger(MappingAndSendingSIRequest.class);
61     /** Permit to call Renderer RPCs. */
62     private StubrendererService service;
63     /** define procedure success (or not ). */
64     private Boolean success = false;
65     /** permit to call bundle service (PCE, Renderer, Servicehandler. */
66     private RpcProviderRegistry rpcRegistry;
67     /** store all error messages. */
68     private String error;
69     ServiceImplementationRequestInput serviceImplementationRequestInput = null;
70     ServiceDeleteInput serviceDeleteInput = null;
71
72     private final ListeningExecutorService executor = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(5));
73
74
75     /**
76      * MappingAndSendingSIRequest class constructor
77      * for RPC serviceCreate.
78      *
79      * @param rpcRegistry rpcRegistry
80      * @param serviceCreateInput serviceCreateInput
81      * @param pathComputationOutput pathComputationOutput
82      */
83     public MappingAndSendingSIRequest(RpcProviderRegistry rpcRegistry,
84             ServiceCreateInput serviceCreateInput,PathComputationRequestOutput pathComputationOutput) {
85         this.setRpcRegistry(rpcRegistry);
86         if (rpcRegistry != null) {
87             service = rpcRegistry.getRpcService(StubrendererService.class);
88         }
89         setSuccess(false);
90         setError("");
91
92         /** Building ServiceImplementationRequestInput  / ServiceDeleteInput serviceDeleteInput. */
93         ServiceHandlerHeaderBuilder serviceHandlerHeader = new ServiceHandlerHeaderBuilder();
94         if (serviceCreateInput.getSdncRequestHeader() != null) {
95             serviceHandlerHeader.setRequestId(serviceCreateInput.getSdncRequestHeader().getRequestId());
96         }
97         mappingSIRequest(pathComputationOutput, serviceHandlerHeader, serviceCreateInput.getServiceAEnd(),
98                 serviceCreateInput.getServiceZEnd(), serviceCreateInput.getServiceName());
99         /*
100
101         org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev161014
102             .service.create.input.ServiceAEnd tempA = serviceCreateInput.getServiceAEnd();
103
104         org.opendaylight.yang.gen.v1.http.org.openroadm.common
105             .service.types.rev161014.service.port.Port tempAPortRx =
106             serviceCreateInput.getServiceAEnd().getRxDirection().getPort();
107
108         org.opendaylight.yang.gen.v1.http.org.openroadm.common
109             .service.types.rev161014.service.port.Port tempAPortTx =
110             serviceCreateInput.getServiceAEnd().getTxDirection().getPort();
111
112         RxDirection rxDirectionAEnd = getRxDirection(tempAPortRx);
113
114         TxDirection txDirectionAEnd = getTxDirection(tempAPortTx);
115
116         ServiceAEnd serviceAEnd = new ServiceAEndBuilder()
117             .setClli(tempA.getClli())
118             .setNodeId(tempA.getNodeId())
119             .setServiceFormat(ServiceFormat.valueOf(tempA.getServiceFormat().getName()))
120             .setServiceRate(tempA.getServiceRate())
121             .setRxDirection(rxDirectionAEnd)
122             .setTxDirection(txDirectionAEnd)
123             .build();
124
125         org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev161014
126             .service.create.input.ServiceZEnd tempZ = serviceCreateInput.getServiceZEnd();
127
128         org.opendaylight.yang.gen.v1.http.org.openroadm.common
129             .service.types.rev161014.service.port.Port tempZPortRx =
130             serviceCreateInput.getServiceZEnd().getRxDirection().getPort();
131
132         org.opendaylight.yang.gen.v1.http.org.openroadm.common
133             .service.types.rev161014.service.port.Port tempZPortTx =
134             serviceCreateInput.getServiceZEnd().getTxDirection().getPort();
135
136         RxDirection rxDirectionZEnd = getRxDirection(tempZPortRx);
137
138         TxDirection txDirectionZEnd = getTxDirection(tempZPortTx);
139
140         ServiceZEnd serviceZEnd = new ServiceZEndBuilder()
141             .setClli(tempZ.getClli())
142             .setNodeId(tempZ.getNodeId())
143             .setServiceFormat(ServiceFormat.valueOf(tempZ.getServiceFormat().getName()))
144             .setServiceRate(tempZ.getServiceRate())
145             .setRxDirection(rxDirectionZEnd)
146             .setTxDirection(txDirectionZEnd)
147             .build();
148
149         org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types
150             .rev170426.response.parameters.sp.response.parameters.PathDescription tmp = null;
151         try {
152             tmp = pathComputationOutput.getResponseParameters().getPathDescription();
153         } catch (NullPointerException e) {
154             LOG.error("PathDescription is null : {}", e.toString());
155         }
156         PathDescriptionBuilder pathDescription = new PathDescriptionBuilder();
157         if (tmp != null) {
158             pathDescription = new PathDescriptionBuilder(tmp);
159         }
160         serviceImplementationRequestInput  = new ServiceImplementationRequestInputBuilder()
161         .setPathDescription(pathDescription.build())
162         .setServiceHandlerHeader(serviceHandlerHeader.build())
163         .setServiceName(serviceCreateInput.getServiceName())
164         .setServiceAEnd(serviceAEnd)
165         .setServiceZEnd(serviceZEnd)
166         .build();*/
167
168         mappingSIRequest(pathComputationOutput, serviceHandlerHeader, serviceCreateInput.getServiceAEnd(),
169                 serviceCreateInput.getServiceZEnd(), serviceCreateInput.getServiceName());
170     }
171
172     /**
173      * MappingAndSendingSIRequest class constructor
174      * for RPC serviceReconfigure.
175      *
176      * @param rpcRegistry rpcRegistry
177      * @param serviceReconfigureInput serviceReconfigureInput
178      * @param pathComputationOutput pathComputationOutput
179      */
180
181     public MappingAndSendingSIRequest(RpcProviderRegistry rpcRegistry,
182             ServiceReconfigureInput serviceReconfigureInput,PathComputationRequestOutput pathComputationOutput) {
183         this.setRpcRegistry(rpcRegistry);
184         if (rpcRegistry != null) {
185             service = rpcRegistry.getRpcService(StubrendererService.class);
186         }
187         setSuccess(false);
188         setError("");
189
190         /** Building ServiceImplementationRequestInput  / ServiceDeleteInput serviceDeleteInput .*/
191         ServiceHandlerHeaderBuilder serviceHandlerHeader = new ServiceHandlerHeaderBuilder()
192                 .setRequestId("reconfigure_" + serviceReconfigureInput.getNewServiceName());
193         mappingSIRequest(pathComputationOutput, serviceHandlerHeader, serviceReconfigureInput.getServiceAEnd(),
194                 serviceReconfigureInput.getServiceZEnd(), serviceReconfigureInput.getNewServiceName());
195
196         /*
197         org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev161014
198             .service.reconfigure.input.ServiceAEnd tempA = serviceReconfigureInput.getServiceAEnd();
199
200         org.opendaylight.yang.gen.v1.http.org.openroadm.common
201             .service.types.rev161014.service.port.Port tempAPortRx =
202             serviceReconfigureInput.getServiceAEnd().getRxDirection().getPort();
203
204         org.opendaylight.yang.gen.v1.http.org.openroadm.common
205             .service.types.rev161014.service.port.Port tempAPortTx =
206             serviceReconfigureInput.getServiceAEnd().getTxDirection().getPort();
207
208         RxDirection rxDirectionAEnd = getRxDirection(tempAPortRx);
209
210         TxDirection txDirectionAEnd = getTxDirection(tempAPortTx);
211
212         ServiceAEnd serviceAEnd = new ServiceAEndBuilder()
213             .setClli(tempA.getClli())
214             .setNodeId(tempA.getNodeId())
215             .setServiceFormat(ServiceFormat.valueOf(tempA.getServiceFormat().getName()))
216             .setServiceRate(tempA.getServiceRate())
217             .setRxDirection(rxDirectionAEnd)
218             .setTxDirection(txDirectionAEnd)
219             .build();
220
221         org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev161014
222             .service.reconfigure.input.ServiceZEnd tempZ = serviceReconfigureInput.getServiceZEnd();
223
224         org.opendaylight.yang.gen.v1.http.org.openroadm.common
225             .service.types.rev161014.service.port.Port tempZPortRx =
226             serviceReconfigureInput.getServiceZEnd().getRxDirection().getPort();
227
228         org.opendaylight.yang.gen.v1.http.org.openroadm.common
229             .service.types.rev161014.service.port.Port tempZPortTx =
230             serviceReconfigureInput.getServiceZEnd().getTxDirection().getPort();
231
232
233         RxDirection rxDirectionZEnd = getRxDirection(tempZPortRx);
234         TxDirection txDirectionZEnd = getTxDirection(tempZPortTx);
235
236         ServiceZEnd serviceZEnd = new ServiceZEndBuilder()
237             .setClli(tempZ.getClli())
238             .setNodeId(tempZ.getNodeId())
239             .setServiceFormat(ServiceFormat.valueOf(tempZ.getServiceFormat().getName()))
240             .setServiceRate(tempZ.getServiceRate())
241             .setRxDirection(rxDirectionZEnd)
242             .setTxDirection(txDirectionZEnd)
243             .build();
244
245         org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types
246             .rev170426.response.parameters.sp.response.parameters.PathDescription tmp = null;
247         try {
248             tmp = pathComputationOutput.getResponseParameters().getPathDescription();
249         } catch (NullPointerException e) {
250             LOG.error("PathDescription is null : {}", e.toString());
251         }
252         PathDescriptionBuilder pathDescription = new PathDescriptionBuilder();
253         if (tmp != null) {
254             pathDescription = new PathDescriptionBuilder(tmp);
255         }
256         serviceImplementationRequestInput  = new ServiceImplementationRequestInputBuilder()
257         .setPathDescription(pathDescription.build())
258         .setServiceHandlerHeader(serviceHandlerHeader.build())
259         .setServiceName(serviceReconfigureInput.getNewServiceName())
260         .setServiceAEnd(serviceAEnd)
261         .setServiceZEnd(serviceZEnd)
262         .build();
263         LOG.info("ServiceImplementationRequestInput : {}", serviceImplementationRequestInput.toString());*/
264     }
265
266
267     /**
268      * MappingAndSendingSIRequest class constructor
269      * for RPC serviceDelete.
270      *
271      * @param rpcRegistry RpcProviderRegistry
272      * @param requestId Request ID
273      * @param serviceName Service name
274      */
275     public MappingAndSendingSIRequest(RpcProviderRegistry rpcRegistry,String requestId, String serviceName) {
276         this.setRpcRegistry(rpcRegistry);
277         if (rpcRegistry != null) {
278             service = rpcRegistry.getRpcService(StubrendererService.class);
279         }
280         setSuccess(false);
281         setError("");
282
283         /** ServiceDeleteInput Build .*/
284         ServiceHandlerHeaderBuilder serviceHandlerHeader = new ServiceHandlerHeaderBuilder();
285         if (requestId != null) {
286             serviceHandlerHeader.setRequestId(requestId);
287         }
288
289         serviceDeleteInput = new ServiceDeleteInputBuilder()
290                 .setServiceHandlerHeader(serviceHandlerHeader.build())
291                 .setServiceName(serviceName)
292                 .build();
293     }
294
295     /**
296      * MappingAndSendingSIRequest Class constructor
297      * for modify Service in ODL Datastore.
298      *
299      * @param rpcRegistry RpcProviderRegistry
300      * @param services Services
301      * @param pathComputationOutput PathComputationRequestOutput
302      */
303     public MappingAndSendingSIRequest(RpcProviderRegistry rpcRegistry,Services services,
304             PathComputationRequestOutput pathComputationOutput) {
305         this.setRpcRegistry(rpcRegistry);
306         if (rpcRegistry != null) {
307             service = rpcRegistry.getRpcService(StubrendererService.class);
308         }
309         setSuccess(false);
310         setError("");
311
312         /** Building ServiceImplementationRequestInput  / ServiceDeleteInput serviceDeleteInput .*/
313         ServiceHandlerHeaderBuilder serviceHandlerHeader = new ServiceHandlerHeaderBuilder();
314         SdncRequestHeader sdnc = services.getSdncRequestHeader();
315         if (sdnc != null) {
316             String requestId = services.getSdncRequestHeader().getRequestId();
317             if (requestId != null) {
318                 serviceHandlerHeader.setRequestId(requestId);
319             }
320         }
321         mappingSIRequest(pathComputationOutput, serviceHandlerHeader, services.getServiceAEnd(),
322                 services.getServiceZEnd(), services.getServiceName());
323         /*org.opendaylight.yang.gen.v1.http.org.openroadm.common.service
324             .types.rev161014.service.ServiceAEnd tempA = services.getServiceAEnd();
325
326         org.opendaylight.yang.gen.v1.http.org.openroadm.common
327             .service.types.rev161014.service.port.Port tempAPortRx = tempA.getRxDirection().getPort();
328
329         org.opendaylight.yang.gen.v1.http.org.openroadm.common
330             .service.types.rev161014.service.port.Port tempAPortTx = tempA.getTxDirection().getPort();
331
332
333         RxDirection rxDirectionAEnd = getRxDirection(tempAPortRx);
334
335         TxDirection txDirectionAEnd = getTxDirection(tempAPortTx);
336
337         ServiceAEnd serviceAEnd = new ServiceAEndBuilder()
338             .setClli(tempA.getClli())
339             .setNodeId(tempA.getNodeId())
340             .setServiceFormat(ServiceFormat.valueOf(tempA.getServiceFormat().getName()))
341             .setServiceRate(tempA.getServiceRate())
342             .setRxDirection(rxDirectionAEnd)
343             .setTxDirection(txDirectionAEnd)
344             .build();
345         org.opendaylight.yang.gen.v1.http.org.openroadm.common.service
346             .types.rev161014.service.ServiceZEnd tempZ = services.getServiceZEnd();
347
348         org.opendaylight.yang.gen.v1.http.org.openroadm.common
349             .service.types.rev161014.service.port.Port tempZPortRx = tempZ.getRxDirection().getPort();
350
351         org.opendaylight.yang.gen.v1.http.org.openroadm.common
352             .service.types.rev161014.service.port.Port tempZPortTx = tempZ.getTxDirection().getPort();
353
354         RxDirection rxDirectionZEnd = getRxDirection(tempZPortRx);
355         TxDirection txDirectionZEnd = getTxDirection(tempZPortTx);
356
357         ServiceZEnd serviceZEnd = new ServiceZEndBuilder()
358             .setClli(tempZ.getClli())
359             .setNodeId(tempZ.getNodeId())
360             .setServiceFormat(ServiceFormat.valueOf(tempZ.getServiceFormat().getName()))
361             .setServiceRate(tempZ.getServiceRate())
362             .setRxDirection(rxDirectionZEnd)
363             .setTxDirection(txDirectionZEnd)
364             .build();
365         org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types
366         .rev170426.response.parameters.sp.response.parameters.PathDescription tmp = null;
367         try {
368             tmp = pathComputationOutput.getResponseParameters().getPathDescription();
369         } catch (NullPointerException e) {
370             LOG.error("PathDescription is null : {}", e);
371         }
372         PathDescriptionBuilder pathDescription = new PathDescriptionBuilder();
373         if (tmp != null) {
374             pathDescription = new PathDescriptionBuilder(tmp);
375         }
376
377         serviceImplementationRequestInput  = new ServiceImplementationRequestInputBuilder()
378         .setPathDescription(pathDescription.build())
379         .setServiceHandlerHeader(serviceHandlerHeader.build())
380         .setServiceName(services.getServiceName())
381         .setServiceAEnd(serviceAEnd)
382         .setServiceZEnd(serviceZEnd)
383         .build();
384         LOG.info("ServiceImplementationRequestInput : {}", serviceImplementationRequestInput.toString());*/
385     }
386
387     /**
388      *Build serviceImplementationRequestInput with
389      *input parameters from ServiceCreateInput or
390      *Services or serviceReconfigureInput.
391      *
392      * @param pathComputationOutput PathComputationRequestOutput
393      * @param serviceHandlerHeader ServiceHandlerHeaderBuilder
394      * @param aend Beginning ServiceEndpoint
395      * @param zend Ending ServiceEndpoint
396      * @param serviceName Service Name
397      */
398     private void mappingSIRequest(PathComputationRequestOutput pathComputationOutput,
399             ServiceHandlerHeaderBuilder serviceHandlerHeader, org.opendaylight.yang.gen .v1.http.org.openroadm.common
400             .service.types.rev161014.ServiceEndpoint aend , org.opendaylight.yang.gen.v1.http.org.openroadm.common
401             .service.types.rev161014.ServiceEndpoint zend, String serviceName) {
402         LOG.info("Mapping ServiceCreateInput or Services or serviceReconfigureInput to SIR requests");
403         /** ServiceAEnd Build. */
404         RxDirection rxDirectionAEnd = new RxDirectionBuilder()
405                 .setPort(aend.getRxDirection().getPort())
406                 .build();
407         TxDirection txDirectionAEnd = new TxDirectionBuilder()
408                 .setPort(aend.getTxDirection().getPort())
409                 .build();
410
411         ServiceAEnd serviceAEnd = new ServiceAEndBuilder()
412                 .setClli(aend.getClli())
413                 .setNodeId(aend.getNodeId())
414                 .setServiceFormat(ServiceFormat.valueOf(aend.getServiceFormat().getName()))
415                 .setServiceRate(aend.getServiceRate())
416                 .setRxDirection(rxDirectionAEnd)
417                 .setTxDirection(txDirectionAEnd)
418                 .build();
419
420         /** ServiceZEnd Build. */
421         RxDirection rxDirectionZEnd = new RxDirectionBuilder()
422                 .setPort(zend.getRxDirection().getPort())
423                 .build();
424
425         TxDirection txDirectionZEnd = new TxDirectionBuilder()
426                 .setPort(zend.getTxDirection().getPort())
427                 .build();
428
429         ServiceZEnd serviceZEnd = new ServiceZEndBuilder()
430                 .setClli(zend.getClli())
431                 .setNodeId(zend.getNodeId())
432                 .setServiceFormat(ServiceFormat.valueOf(zend.getServiceFormat().getName()))
433                 .setServiceRate(zend.getServiceRate())
434                 .setRxDirection(rxDirectionZEnd)
435                 .setTxDirection(txDirectionZEnd)
436                 .build();
437
438
439         /** ServiceImplementationRequestInput  Build. */
440         org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types
441             .rev170426.response.parameters.sp.response.parameters.PathDescription tmp = null;
442         try {
443             tmp = pathComputationOutput.getResponseParameters().getPathDescription();
444         } catch (NullPointerException e) {
445             LOG.error("PathDescription is null : {}", e.toString());
446         }
447         PathDescriptionBuilder pathDescription = new PathDescriptionBuilder();
448         if (tmp != null) {
449             pathDescription = new PathDescriptionBuilder(tmp);
450         }
451         serviceImplementationRequestInput  = new ServiceImplementationRequestInputBuilder()
452                 .setPathDescription(pathDescription.build())
453                 .setServiceHandlerHeader(serviceHandlerHeader.build())
454                 .setServiceName(serviceName)
455                 .setServiceAEnd(serviceAEnd)
456                 .setServiceZEnd(serviceZEnd)
457                 .build();
458
459     }
460
461     /**
462      * Send serviceImplementation request to Render.
463      *
464      * @return ServiceImplementationRequestOutput data response from Renderer
465      */
466     public ListenableFuture<Boolean> serviceImplementation() {
467         setSuccess(false);
468         return executor.submit(new Callable<Boolean>() {
469             @Override
470             public Boolean call() throws Exception {
471                 Boolean output = null;
472                 if (serviceImplementationRequestInput != null) {
473                     RpcResult<ServiceImplementationRequestOutput> rendererOutputResult = null;
474                     Future<RpcResult<ServiceImplementationRequestOutput>> rendererOutputFuture =
475                             service.serviceImplementationRequest(serviceImplementationRequestInput);
476                     try {
477                         rendererOutputResult = rendererOutputFuture.get();//wait to get  the result
478                     } catch (InterruptedException | CancellationException | ExecutionException e) {
479                         setError("Did not receive the expected response from renderer to pathComputationRequest RPC "
480                                 + e.toString());
481                         LOG.error(error);
482                         rendererOutputFuture.cancel(true);
483                     }
484
485                     if (rendererOutputResult != null && rendererOutputResult.isSuccessful()) {
486                         LOG.info("Renderer replied to serviceImplementation Request !");
487                         setSuccess(true);
488                         output = true;
489                         setSuccess(true);
490                     }
491                 } else {
492                     LOG.info("serviceImplementationRequestInput is not valid");
493                 }
494
495                 return output;
496             }
497         });
498
499     }
500
501     /**
502      * Send serviceDelete request to Render.
503      *
504      * @return ServiceDeleteOutput data response from Renderer
505      */
506     public ListenableFuture<Boolean> serviceDelete() {
507         setSuccess(false);
508         return executor.submit(new Callable<Boolean>() {
509             @Override
510             public Boolean call() throws Exception {
511                 Boolean output = null;
512                 if (serviceDeleteInput != null) {
513                     RpcResult<ServiceDeleteOutput> rendererOutputResult = null;
514                     Future<RpcResult<ServiceDeleteOutput>> rendererOutputFuture =
515                             service.serviceDelete(serviceDeleteInput);
516                     try {
517                         rendererOutputResult = rendererOutputFuture.get();//wait to get  the result
518                     } catch (InterruptedException | CancellationException | ExecutionException e) {
519                         setError("Did not receive the expected response from renderer to pathComputationRequest RPC "
520                                 + e.toString());
521                         LOG.error(error);
522                         rendererOutputFuture.cancel(true);
523                     }
524
525                     if (rendererOutputResult != null && rendererOutputResult.isSuccessful()) {
526                         LOG.info("Renderer replied to serviceDelete Request!");
527                         setSuccess(true);
528                         output = true;
529                     }
530                 }
531                 return output;
532             }
533         });
534
535     }
536
537
538     public Boolean getSuccess() {
539         return success;
540     }
541
542     public void setSuccess(Boolean success) {
543         this.success = success;
544     }
545
546     public String getError() {
547         return error;
548     }
549
550     public void setError(String error) {
551         this.error = error;
552     }
553
554     public RpcProviderRegistry getRpcRegistry() {
555         return rpcRegistry;
556     }
557
558     public void setRpcRegistry(RpcProviderRegistry rpcRegistry) {
559         this.rpcRegistry = rpcRegistry;
560     }
561
562 }