Stubrenderer Update 63/64563/4
authorMartial COULIBALY <martial.coulibaly@gfi.fr>
Fri, 20 Oct 2017 09:40:22 +0000 (11:40 +0200)
committerguillaume.lambert <guillaume.lambert@orange.com>
Thu, 21 Dec 2017 15:35:55 +0000 (16:35 +0100)
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 <martial.coulibaly@gfi.fr>
Signed-off-by: Olivier RENAIS <olivier.renais@orange.com>
(cherry picked from commit 54d80c088d157e5f02ccad86eedcca477ef0e8a8)

tests/stubrenderer/src/main/java/org/opendaylight/transportpce/stubrenderer/SendingRendererRPCs.java
tests/stubrenderer/src/main/java/org/opendaylight/transportpce/stubrenderer/StubrendererCompliancyCheck.java [new file with mode: 0644]
tests/stubrenderer/src/main/java/org/opendaylight/transportpce/stubrenderer/impl/StubrendererImpl.java
tests/stubrenderer/src/main/java/org/opendaylight/transportpce/stubrenderer/impl/StubrendererProvider.java

index 8f17cc0d6980cd2a3c1c195b8c62e73d08a1ffc5..c7f587c7fe00e52a63c3b57c0edd13098dda2690 100644 (file)
@@ -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<br>
+    /** define type of request<br>
      * <code>true</code> pathcomputation <br>
      * <code>false</code> cancelresourcereserve. */
     private TopologyBuilder topology;
     private List<AToZ> atoz;
     private List<ZToA> 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<ZToA>();
     }
 
-    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<Boolean> serviceDelete() {
+        LOG.info("ServiceDelete request ...");
+        success = false;
+        return executor.submit(new Callable<Boolean>() {
+            @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<Boolean> serviceImplementation() {
+        LOG.info("serviceImplementation request ...");
+        success = false;
+        return executor.submit(new Callable<Boolean>() {
+            @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 (file)
index 0000000..173e7d0
--- /dev/null
@@ -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 <a href="mailto:martial.coulibaly@gfi.com">Martial Coulibaly</a> 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;
+    }
+}
index 16132378cea15cf2cbaab98c048d6badbd5b2e55..1be07aa7b52262157dcfd8f65aff61c5b1474055 100644 (file)
@@ -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<RpcResult<ServiceImplementationRequestOutput>> 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<Boolean> rendererCallback =
+                    new FutureCallback<Boolean>() {
+                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<Boolean> 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<RpcResult<ServiceDeleteOutput>> 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<Boolean> rendererCallback = new FutureCallback<Boolean>() {
+                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<Boolean> 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<RpcResult<CancelResourceReserveOutput>> cancelResourceReserve(CancelResourceReserveInput input) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public Future<RpcResult<PathComputationRequestOutput>> pathComputationRequest(PathComputationRequestInput input) {
+        // TODO Auto-generated method stub
+        return null;
     }
 }
index 066bf1897f0d16b0142df78f3fa7d4113974a983..dff06285e2e10435417069c43d942dd9f0f717b9 100644 (file)
@@ -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 <a href="mailto:martial.coulibaly@gfi.com">Martial Coulibaly</a> on behalf of Orange
  *
  */
 public class StubrendererProvider {
@@ -30,12 +30,12 @@ public class StubrendererProvider {
     private final NotificationPublishService notificationPublishService;
 
 
-    private BindingAwareBroker.RpcRegistration<StubrendererService> rpcRegistration;
-    private ListenerRegistration<StubrendererListener> stubRendererlistenerRegistration;
+    private BindingAwareBroker.RpcRegistration<TransportpceServicepathService> rpcRegistration;
+    private ListenerRegistration<TransportpceServicepathListener> 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);
     }
 
     /**