From 7657ad92b7ca389623fbb195e19c94148dfdfe0a Mon Sep 17 00:00:00 2001 From: Martial COULIBALY Date: Fri, 20 Oct 2017 11:40:22 +0200 Subject: [PATCH] Stubrenderer Update this commit includes : - stubrenderer.yang removed - stubrenderer will now gets his RPCs from transportpce-service-path.yang. - solving the following javadoc warning 'IllegalCatch : Catching "Exception" is not allowed'. - update servicehandler dependency - move stubpce and stubrenderer to tests folder - add dependency 'Version update to 1.6 of the service-path model'. Change-Id: I3fe58dae7e613517312de69a13877dd16bf4f4e4 Signed-off-by: Martial COULIBALY Signed-off-by: Olivier RENAIS (cherry picked from commit 54d80c088d157e5f02ccad86eedcca477ef0e8a8) --- .../stubrenderer/SendingRendererRPCs.java | 93 +++-- .../StubrendererCompliancyCheck.java | 95 +++++ .../stubrenderer/impl/StubrendererImpl.java | 331 +++++++++++++----- .../impl/StubrendererProvider.java | 16 +- 4 files changed, 413 insertions(+), 122 deletions(-) create mode 100644 tests/stubrenderer/src/main/java/org/opendaylight/transportpce/stubrenderer/StubrendererCompliancyCheck.java diff --git a/tests/stubrenderer/src/main/java/org/opendaylight/transportpce/stubrenderer/SendingRendererRPCs.java b/tests/stubrenderer/src/main/java/org/opendaylight/transportpce/stubrenderer/SendingRendererRPCs.java index 8f17cc0d6..c7f587c7f 100644 --- a/tests/stubrenderer/src/main/java/org/opendaylight/transportpce/stubrenderer/SendingRendererRPCs.java +++ b/tests/stubrenderer/src/main/java/org/opendaylight/transportpce/stubrenderer/SendingRendererRPCs.java @@ -8,8 +8,12 @@ package org.opendaylight.transportpce.stubrenderer; +import com.google.common.util.concurrent.ListenableFuture; +import com.google.common.util.concurrent.ListeningExecutorService; + import java.util.ArrayList; import java.util.List; +import java.util.concurrent.Callable; import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.TopologyBuilder; import org.opendaylight.yang.gen.v1.http.org.openroadm.topology.rev161014.topology.AToZ; @@ -18,27 +22,32 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * Class for Sending Renderer requests : + *Class for Sending + * Renderer requests : * - Service-implementation-request * - Service-delete-request. * @author Martial Coulibaly ( martial.coulibaly@gfi.com ) on behalf of Orange * */ public class SendingRendererRPCs { - /* Logging. */ + /** Logging. */ private static final Logger LOG = LoggerFactory.getLogger(SendingRendererRPCs.class); - /* define procedure success (or not ). */ + /** define procedure success (or not ). */ private Boolean success; - /* define type of request
+ /** define type of request
* true pathcomputation
* false cancelresourcereserve. */ private TopologyBuilder topology; private List atoz; private List ztoa; + private String error; + private final ListeningExecutorService executor; - public SendingRendererRPCs() { + public SendingRendererRPCs(ListeningExecutorService executor) { success = true; setTopology(null); + this.executor = executor; + setError(""); } private void buildAtoZ() { @@ -49,30 +58,52 @@ public class SendingRendererRPCs { ztoa = new ArrayList(); } - public void serviceDelete() { - LOG.info("Wait for 10s til beginning the Renderer ServiceDelete request"); - try { - Thread.sleep(10000); //sleep for 10s - } catch (InterruptedException e) { - LOG.error(e.toString()); - } - LOG.info("ServiceDelete ..."); + public ListenableFuture serviceDelete() { + LOG.info("ServiceDelete request ..."); + success = false; + return executor.submit(new Callable() { + @Override + public Boolean call() throws Exception { + Boolean output = true; + LOG.info("Wait for 10s til beginning the Renderer serviceDelete request"); + try { + Thread.sleep(10000); //sleep for 10s + } catch (InterruptedException e) { + output = false; + LOG.error(e.toString()); + } + buildAtoZ(); + buildZtoA(); + success = true; + return output; + } + }); } - public void serviceImplementation() { - LOG.info("Wait for 10s til beginning the Renderer serviceImplementation request"); - try { - Thread.sleep(10000); //sleep for 10s - } catch (InterruptedException e) { - LOG.error(e.toString()); - } - LOG.info("serviceImplementation ..."); - buildAtoZ(); - buildZtoA(); - - setTopology(new TopologyBuilder() - .setAToZ(atoz) - .setZToA(ztoa)); + public ListenableFuture serviceImplementation() { + LOG.info("serviceImplementation request ..."); + success = false; + return executor.submit(new Callable() { + @Override + public Boolean call() throws Exception { + Boolean output = true; + LOG.info("Wait for 10s til beginning the Renderer serviceDelete request"); + try { + Thread.sleep(10000); //sleep for 10s + } catch (InterruptedException e) { + output = false; + LOG.error(e.toString()); + } + buildAtoZ(); + buildZtoA(); + setTopology(new TopologyBuilder() + .setAToZ(atoz) + .setZToA(ztoa)); + output = true; + success = true; + return output; + } + }); } public Boolean getSuccess() { @@ -90,4 +121,12 @@ public class SendingRendererRPCs { public void setTopology(TopologyBuilder topo) { this.topology = topo; } + + public String getError() { + return error; + } + + public void setError(String error) { + this.error = error; + } } diff --git a/tests/stubrenderer/src/main/java/org/opendaylight/transportpce/stubrenderer/StubrendererCompliancyCheck.java b/tests/stubrenderer/src/main/java/org/opendaylight/transportpce/stubrenderer/StubrendererCompliancyCheck.java new file mode 100644 index 000000000..173e7d0ef --- /dev/null +++ b/tests/stubrenderer/src/main/java/org/opendaylight/transportpce/stubrenderer/StubrendererCompliancyCheck.java @@ -0,0 +1,95 @@ +/* + * Copyright © 2017 Orange, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.transportpce.stubrenderer; + +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.service.handler.header.ServiceHandlerHeader; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Class for checking service sdnc-request-header compliancy. + * + * @author Martial Coulibaly on behalf of Orange + * + */ +public class StubrendererCompliancyCheck { + /** Logging. */ + private static final Logger LOG = LoggerFactory.getLogger(StubrendererCompliancyCheck.class); + /** SdncRequestHeader. */ + private ServiceHandlerHeader serviceHandlerHeader; + /** Service Name. */ + private String serviceName; + /** Response message from procedure. */ + private String message; + + + public StubrendererCompliancyCheck(String serviceName,ServiceHandlerHeader serviceHandlerHeader) { + this.serviceName = serviceName; + this.serviceHandlerHeader = serviceHandlerHeader; + this.setMessage(""); + } + + /** + * Check if a String is not null and not equal to void. + * + * @param value + * String value + * @return true if String ok false if not + */ + public Boolean checkString(String value) { + Boolean result = false; + if (value != null && value.compareTo("") != 0) { + result = true; + } + return result; + + } + + /** + * Check Compliancy of Service request. + * + * @param contype + * Boolean to check connection Type + * @param servicehandler + * Boolean to check sndcRequestHeader + * + * @return true if String ok false if not + */ + public Boolean check(Boolean contype, Boolean servicehandler) { + Boolean result = true; + if (!checkString(serviceName)) { + result = false; + message = "Service Name is not set"; + LOG.info(message); + } + if (servicehandler) { + if (serviceHandlerHeader != null) { + String requestId = serviceHandlerHeader.getRequestId(); + if (!checkString(requestId)) { + result = false; + message = "Service serviceHandlerHeader 'request-id' is not set"; + LOG.info(message); + } + } else { + result = false; + message = "Service serviceHandlerHeader is not set "; + LOG.info(message); + } + } + return result; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } +} diff --git a/tests/stubrenderer/src/main/java/org/opendaylight/transportpce/stubrenderer/impl/StubrendererImpl.java b/tests/stubrenderer/src/main/java/org/opendaylight/transportpce/stubrenderer/impl/StubrendererImpl.java index 16132378c..1be07aa7b 100644 --- a/tests/stubrenderer/src/main/java/org/opendaylight/transportpce/stubrenderer/impl/StubrendererImpl.java +++ b/tests/stubrenderer/src/main/java/org/opendaylight/transportpce/stubrenderer/impl/StubrendererImpl.java @@ -9,42 +9,59 @@ package org.opendaylight.transportpce.stubrenderer.impl; +import com.google.common.util.concurrent.FutureCallback; +import com.google.common.util.concurrent.Futures; +import com.google.common.util.concurrent.ListenableFuture; +import com.google.common.util.concurrent.ListeningExecutorService; +import com.google.common.util.concurrent.MoreExecutors; + +import java.util.concurrent.Executors; import java.util.concurrent.Future; import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; import org.opendaylight.transportpce.stubrenderer.SendingRendererRPCs; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.ServiceDeleteInput; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.ServiceDeleteOutput; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.ServiceDeleteOutputBuilder; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.ServiceImplementationRequestInput; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.ServiceImplementationRequestOutput; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.ServiceImplementationRequestOutputBuilder; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.ServiceRpcResultSp; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.ServiceRpcResultSpBuilder; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.StubrendererService; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.service.rpc.result.sp.PathTopology; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.service.rpc.result.sp.PathTopologyBuilder; +import org.opendaylight.transportpce.stubrenderer.StubrendererCompliancyCheck; import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.configuration.response.common.ConfigurationResponseCommonBuilder; import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.TopologyBuilder; import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.RpcStatusEx; import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.ServicePathNotificationTypes; +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.CancelResourceReserveInput; +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.CancelResourceReserveOutput; +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.PathComputationRequestInput; +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.PathComputationRequestOutput; +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.ServiceDeleteInput; +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.ServiceDeleteOutput; +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.ServiceDeleteOutputBuilder; +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.ServiceImplementationRequestInput; +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.ServiceImplementationRequestOutput; +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.ServiceImplementationRequestOutputBuilder; +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.ServiceRpcResultSp; +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.ServiceRpcResultSpBuilder; +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.TransportpceServicepathService; +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.service.rpc.result.sp.PathTopology; +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.service.rpc.result.sp.PathTopologyBuilder; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; + /** * Class to implement StubrendererService. * @author Martial Coulibaly ( martial.coulibaly@gfi.com ) on behalf of Orange * */ -public class StubrendererImpl implements StubrendererService { - /* Logging. */ +public class StubrendererImpl implements TransportpceServicepathService { + /** Logging. */ private static final Logger LOG = LoggerFactory.getLogger(StubrendererImpl.class); - /* send notification. */ + /** send notification. */ private NotificationPublishService notificationPublishService; private ServiceRpcResultSp notification; + private final ListeningExecutorService executor = MoreExecutors + .listeningDecorator(Executors.newFixedThreadPool(10)); + /** check service sdnc-request-header compliancy. */ + private StubrendererCompliancyCheck compliancyCheck; public StubrendererImpl(NotificationPublishService notificationPublishService) { this.notificationPublishService = notificationPublishService; @@ -53,58 +70,125 @@ public class StubrendererImpl implements StubrendererService { @Override public Future> serviceImplementationRequest( ServiceImplementationRequestInput input) { - String message = ""; LOG.info("RPC serviceImplementationRequest request received"); + String responseCode = ""; + String message = ""; + ConfigurationResponseCommonBuilder configurationResponseCommon = null; - notification = new ServiceRpcResultSpBuilder() - .setNotificationType(ServicePathNotificationTypes.ServiceImplementationRequest) - .setServiceName(input.getServiceName()) - .setStatus(RpcStatusEx.Pending) - .setStatusMessage("Service compliant, submitting serviceImplementation Request ...") - .build(); - try { - notificationPublishService.putNotification(notification); - } catch (InterruptedException e) { - LOG.info("notification offer rejected : " + e); - } + compliancyCheck = new StubrendererCompliancyCheck(input.getServiceName(), input.getServiceHandlerHeader()); + if (compliancyCheck.check(false, true)) { + LOG.info("Service compliant !"); + /** + * If compliant, service-request parameters are verified in order to + * check if there is no missing parameter that prevents calculating + * a path and implement a service. + */ - SendingRendererRPCs sendingRenderer = new SendingRendererRPCs(); - sendingRenderer.serviceImplementation(); - if (sendingRenderer.getSuccess()) { - message = "Service implemented !"; - ServiceRpcResultSpBuilder tmp = new ServiceRpcResultSpBuilder() - .setNotificationType(ServicePathNotificationTypes.ServiceImplementationRequest) - .setServiceName(input.getServiceName()) - .setStatus(RpcStatusEx.Successful) - .setStatusMessage(message); - TopologyBuilder topo = sendingRenderer.getTopology(); - if (topo != null) { - PathTopology path = new PathTopologyBuilder() - .setAToZ(topo.getAToZ()) - .setZToA(topo.getZToA()) + notification = new ServiceRpcResultSpBuilder() + .setNotificationType(ServicePathNotificationTypes.ServiceImplementationRequest) + .setServiceName(input.getServiceName()) + .setStatus(RpcStatusEx.Pending) + .setStatusMessage("Service compliant, submitting serviceImplementation Request ...") .build(); - tmp.setPathTopology(path); - } - notification = tmp.build(); try { notificationPublishService.putNotification(notification); } catch (InterruptedException e) { LOG.info("notification offer rejected : " + e); } + SendingRendererRPCs sendingRenderer = new SendingRendererRPCs(executor); + FutureCallback rendererCallback = + new FutureCallback() { + String message = ""; + ServiceRpcResultSp notification = null; + + @Override + public void onFailure(Throwable arg0) { + LOG.error("Failure message : " + arg0.toString()); + LOG.error("Service implementation failed !"); + notification = new ServiceRpcResultSpBuilder() + .setNotificationType(ServicePathNotificationTypes.ServiceImplementationRequest) + .setServiceName(input.getServiceName()).setStatus(RpcStatusEx.Failed) + .setStatusMessage("PCR Request failed : " + arg0.getMessage()).build(); + try { + notificationPublishService.putNotification(notification); + } catch (InterruptedException e) { + LOG.info("notification offer rejected : " + e); + } + } + + @Override + public void onSuccess(Boolean response) { + LOG.info("response : " + response); + if (response) { + message = "Service implemented !"; + TopologyBuilder topo = sendingRenderer.getTopology(); + ServiceRpcResultSpBuilder tmp = new ServiceRpcResultSpBuilder() + .setNotificationType(ServicePathNotificationTypes.ServiceImplementationRequest) + .setServiceName(input.getServiceName()) + .setStatus(RpcStatusEx.Successful) + .setStatusMessage(message); + if (topo != null) { + PathTopology value = new PathTopologyBuilder() + .setAToZ(topo.getAToZ()) + .setZToA(topo.getZToA()) + .build(); + tmp.setPathTopology(value); + } + notification = tmp.build(); + } else { + message = "Service implementation failed : " + sendingRenderer.getError(); + notification = new ServiceRpcResultSpBuilder() + .setNotificationType(ServicePathNotificationTypes.ServiceImplementationRequest) + .setServiceName("") + .setStatus(RpcStatusEx.Failed).setStatusMessage(message) + .build(); + } + LOG.info(notification.toString()); + try { + notificationPublishService.putNotification(notification); + } catch (InterruptedException e) { + LOG.info("notification offer rejected : " + e); + } + LOG.info(message); + } + }; + ListenableFuture renderer = sendingRenderer.serviceImplementation(); + Futures.addCallback(renderer, rendererCallback, executor); + LOG.info("Service implmentation Request in progress "); + configurationResponseCommon = new ConfigurationResponseCommonBuilder() + .setAckFinalIndicator("Yes") + .setRequestId(input.getServiceHandlerHeader().getRequestId()) + .setResponseCode("200") + .setResponseMessage("Service implementation Request in progress "); + + ServiceImplementationRequestOutput output = new ServiceImplementationRequestOutputBuilder() + .setConfigurationResponseCommon(configurationResponseCommon.build()) + .build(); + return RpcResultBuilder.success(output).buildFuture(); } else { - message = "Service not implemented !"; + message = compliancyCheck.getMessage(); + responseCode = "500"; + LOG.info("Service not compliant caused by : " + message); + notification = new ServiceRpcResultSpBuilder() + .setNotificationType(ServicePathNotificationTypes.ServiceDelete) + .setServiceName(input.getServiceName()).setStatus(RpcStatusEx.Failed) + .setStatusMessage("Service not compliant caused by : " + message) + .build(); + try { + notificationPublishService.putNotification(notification); + } catch (InterruptedException e) { + LOG.info("notification offer rejected : " + e); + } } - LOG.info(message); - ConfigurationResponseCommonBuilder configurationResponseCommon = new ConfigurationResponseCommonBuilder() - .setAckFinalIndicator("Yes") - .setRequestId(input.getServiceHandlerHeader().getRequestId()) - .setResponseCode("200") - .setResponseMessage(message); - + configurationResponseCommon = new ConfigurationResponseCommonBuilder() + .setAckFinalIndicator("yes") + .setRequestId(input.getServiceHandlerHeader().getRequestId()) + .setResponseCode(responseCode) + .setResponseMessage(message); ServiceImplementationRequestOutput output = new ServiceImplementationRequestOutputBuilder() - .setConfigurationResponseCommon(configurationResponseCommon.build()) - .build(); + .setConfigurationResponseCommon(configurationResponseCommon.build()) + .build(); return RpcResultBuilder.success(output).buildFuture(); } @@ -112,50 +196,123 @@ public class StubrendererImpl implements StubrendererService { @Override public Future> serviceDelete(ServiceDeleteInput input) { String message = ""; - LOG.info("RPC serviceDelete request received"); - - notification = new ServiceRpcResultSpBuilder() - .setNotificationType(ServicePathNotificationTypes.ServiceDelete) - .setServiceName(input.getServiceName()) - .setStatus(RpcStatusEx.Pending) - .setStatusMessage("Service compliant, submitting ServiceDelete Request ...") - .build(); - try { - notificationPublishService.putNotification(notification); - } catch (InterruptedException e) { - LOG.info("notification offer rejected : " + e); - } + LOG.info("RPC serviceDelete request received"); + String responseCode = ""; + ConfigurationResponseCommonBuilder configurationResponseCommon = null; + compliancyCheck = new StubrendererCompliancyCheck(input.getServiceName(), input.getServiceHandlerHeader()); + if (compliancyCheck.check(false, true)) { + LOG.info("Service compliant !"); + /** + * If compliant, service-request parameters are verified in order to + * check if there is no missing parameter that prevents calculating + * a path and implement a service. + */ - SendingRendererRPCs sendingRenderer = new SendingRendererRPCs(); - sendingRenderer.serviceDelete(); - if (sendingRenderer.getSuccess()) { - message = "Service deleted ! "; - LOG.info(message); - ServiceRpcResultSpBuilder tmp = new ServiceRpcResultSpBuilder() - .setNotificationType(ServicePathNotificationTypes.ServiceDelete) - .setServiceName(input.getServiceName()) - .setStatus(RpcStatusEx.Successful) - .setStatusMessage(message); - notification = tmp.build(); + notification = new ServiceRpcResultSpBuilder() + .setNotificationType(ServicePathNotificationTypes.ServiceDelete) + .setServiceName(input.getServiceName()) + .setStatus(RpcStatusEx.Pending) + .setStatusMessage("Service compliant, submitting serviceDelete Request ...") + .build(); try { notificationPublishService.putNotification(notification); } catch (InterruptedException e) { LOG.info("notification offer rejected : " + e); } + SendingRendererRPCs sendingRenderer = new SendingRendererRPCs(executor); + FutureCallback rendererCallback = new FutureCallback() { + String message = ""; + ServiceRpcResultSp notification = null; + + @Override + public void onFailure(Throwable arg0) { + LOG.error("Failure message : " + arg0.toString()); + LOG.error("Service delete failed !"); + notification = new ServiceRpcResultSpBuilder() + .setNotificationType(ServicePathNotificationTypes.ServiceDelete) + .setServiceName(input.getServiceName()).setStatus(RpcStatusEx.Failed) + .setStatusMessage("PCR Request failed : " + arg0.getMessage()).build(); + try { + notificationPublishService.putNotification(notification); + } catch (InterruptedException e) { + LOG.info("notification offer rejected : " + e); + } + } + + @Override + public void onSuccess(Boolean response) { + LOG.info("response : " + response); + if (response) { + message = "Service deleted !"; + notification = new ServiceRpcResultSpBuilder() + .setNotificationType(ServicePathNotificationTypes.ServiceDelete) + .setServiceName(input.getServiceName()).setStatus(RpcStatusEx.Successful) + .setStatusMessage(message).build(); + } else { + message = "Service delete failed : " + sendingRenderer.getError(); + notification = new ServiceRpcResultSpBuilder() + .setNotificationType(ServicePathNotificationTypes.ServiceDelete) + .setServiceName("") + .setStatus(RpcStatusEx.Failed).setStatusMessage(message) + .build(); + } + LOG.info(notification.toString()); + try { + notificationPublishService.putNotification(notification); + } catch (InterruptedException e) { + LOG.info("notification offer rejected : " + e); + } + LOG.info(message); + } + }; + ListenableFuture renderer = sendingRenderer.serviceDelete(); + Futures.addCallback(renderer, rendererCallback, executor); + message = "Service delete Request in progress ..."; + LOG.info(message); + configurationResponseCommon = new ConfigurationResponseCommonBuilder() + .setAckFinalIndicator("Yes") + .setRequestId(input.getServiceHandlerHeader().getRequestId()) + .setResponseCode("200") + .setResponseMessage(message); + ServiceDeleteOutput output = new ServiceDeleteOutputBuilder() + .setConfigurationResponseCommon(configurationResponseCommon.build()) + .build(); + return RpcResultBuilder.success(output).buildFuture(); } else { - message = "Service not deleted !"; + message = compliancyCheck.getMessage(); + LOG.info("Service not compliant caused by : " + message); + responseCode = "500"; + notification = new ServiceRpcResultSpBuilder() + .setNotificationType(ServicePathNotificationTypes.ServiceDelete) + .setServiceName(input.getServiceName()).setStatus(RpcStatusEx.Failed) + .setStatusMessage("Service not compliant caused by : " + message) + .build(); + try { + notificationPublishService.putNotification(notification); + } catch (InterruptedException e) { + LOG.info("notification offer rejected : " + e); + } } - LOG.info(message); - ConfigurationResponseCommonBuilder configurationResponseCommon = new ConfigurationResponseCommonBuilder() - .setAckFinalIndicator("yes") - .setRequestId(input.getServiceHandlerHeader().getRequestId()) - .setResponseCode("200") - .setResponseMessage(message); + configurationResponseCommon = new ConfigurationResponseCommonBuilder() + .setAckFinalIndicator("yes") + .setRequestId(input.getServiceHandlerHeader().getRequestId()) + .setResponseCode(responseCode) + .setResponseMessage(message); ServiceDeleteOutput output = new ServiceDeleteOutputBuilder() - .setConfigurationResponseCommon(configurationResponseCommon.build()) - .build(); - + .setConfigurationResponseCommon(configurationResponseCommon.build()) + .build(); return RpcResultBuilder.success(output).buildFuture(); + } + @Override + public Future> cancelResourceReserve(CancelResourceReserveInput input) { + // TODO Auto-generated method stub + return null; + } + + @Override + public Future> pathComputationRequest(PathComputationRequestInput input) { + // TODO Auto-generated method stub + return null; } } diff --git a/tests/stubrenderer/src/main/java/org/opendaylight/transportpce/stubrenderer/impl/StubrendererProvider.java b/tests/stubrenderer/src/main/java/org/opendaylight/transportpce/stubrenderer/impl/StubrendererProvider.java index 066bf1897..dff06285e 100644 --- a/tests/stubrenderer/src/main/java/org/opendaylight/transportpce/stubrenderer/impl/StubrendererProvider.java +++ b/tests/stubrenderer/src/main/java/org/opendaylight/transportpce/stubrenderer/impl/StubrendererProvider.java @@ -13,15 +13,15 @@ import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService import org.opendaylight.controller.md.sal.binding.api.NotificationService; import org.opendaylight.controller.sal.binding.api.BindingAwareBroker; import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.StubrendererListener; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.StubrendererService; +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.TransportpceServicepathListener; +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.TransportpceServicepathService; import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * Class to register Stubrenderer Service and Notification. - * @author Martial Coulibaly ( martial.coulibaly@gfi.com ) on behalf of Orange + * @author Martial Coulibaly on behalf of Orange * */ public class StubrendererProvider { @@ -30,12 +30,12 @@ public class StubrendererProvider { private final NotificationPublishService notificationPublishService; - private BindingAwareBroker.RpcRegistration rpcRegistration; - private ListenerRegistration stubRendererlistenerRegistration; + private BindingAwareBroker.RpcRegistration rpcRegistration; + private ListenerRegistration stubRendererlistenerRegistration; public StubrendererProvider(RpcProviderRegistry rpcProviderRegistry, - NotificationService notificationService, - NotificationPublishService notificationPublishService) { + NotificationService notificationService, + NotificationPublishService notificationPublishService) { this.rpcRegistry = rpcProviderRegistry; this.notificationPublishService = notificationPublishService; } @@ -46,7 +46,7 @@ public class StubrendererProvider { public void init() { LOG.info("StubrendererProvider Session Initiated"); final StubrendererImpl consumer = new StubrendererImpl(notificationPublishService); - rpcRegistration = rpcRegistry.addRpcImplementation(StubrendererService.class, consumer); + rpcRegistration = rpcRegistry.addRpcImplementation(TransportpceServicepathService.class, consumer); } /** -- 2.36.6