X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=pce%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Ftransportpce%2Fpce%2Fservice%2FPathComputationServiceImpl.java;h=5fae25035f2d97185e04e137235ec1505fa53acd;hb=5a59a59e40a4c6d8176666965f469d0c3f6d7487;hp=4e4e0cb42f7cee43256f08abe5f375807f2eb618;hpb=bbbb9c996a7ed10318bdf32f6ad301a0c240d787;p=transportpce.git diff --git a/pce/src/main/java/org/opendaylight/transportpce/pce/service/PathComputationServiceImpl.java b/pce/src/main/java/org/opendaylight/transportpce/pce/service/PathComputationServiceImpl.java index 4e4e0cb42..5fae25035 100644 --- a/pce/src/main/java/org/opendaylight/transportpce/pce/service/PathComputationServiceImpl.java +++ b/pce/src/main/java/org/opendaylight/transportpce/pce/service/PathComputationServiceImpl.java @@ -25,32 +25,43 @@ import org.opendaylight.transportpce.pce.PceSendingPceRPCs; import org.opendaylight.transportpce.pce.gnpy.GnpyResult; import org.opendaylight.transportpce.pce.gnpy.consumer.GnpyConsumer; import org.opendaylight.yang.gen.v1.gnpy.path.rev220615.result.Response; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220118.CancelResourceReserveInput; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220118.CancelResourceReserveOutput; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220118.CancelResourceReserveOutputBuilder; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220118.PathComputationRequestInput; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220118.PathComputationRequestOutput; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220118.PathComputationRequestOutputBuilder; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220118.ServicePathRpcResult; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220118.ServicePathRpcResultBuilder; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220118.gnpy.GnpyResponse; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220118.gnpy.GnpyResponseBuilder; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220118.gnpy.gnpy.response.response.type.NoPathCaseBuilder; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220118.gnpy.gnpy.response.response.type.PathCaseBuilder; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220118.path.performance.PathPropertiesBuilder; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220118.path.performance.path.properties.PathMetric; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220118.path.performance.path.properties.PathMetricBuilder; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220118.service.path.rpc.result.PathDescription; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220118.service.path.rpc.result.PathDescriptionBuilder; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.CancelResourceReserveInput; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.CancelResourceReserveOutput; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.CancelResourceReserveOutputBuilder; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.PathComputationRequestInput; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.PathComputationRequestInputBuilder; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.PathComputationRequestOutput; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.PathComputationRequestOutputBuilder; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.PathComputationRerouteRequestInput; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.PathComputationRerouteRequestOutput; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.PathComputationRerouteRequestOutputBuilder; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.ServicePathRpcResult; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.ServicePathRpcResultBuilder; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.gnpy.GnpyResponse; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.gnpy.GnpyResponseBuilder; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.gnpy.gnpy.response.response.type.NoPathCaseBuilder; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.gnpy.gnpy.response.response.type.PathCaseBuilder; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.path.computation.request.input.ServiceAEndBuilder; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.path.computation.request.input.ServiceZEndBuilder; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.path.performance.PathPropertiesBuilder; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.path.performance.path.properties.PathMetric; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.path.performance.path.properties.PathMetricBuilder; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.service.path.rpc.result.PathDescription; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.service.path.rpc.result.PathDescriptionBuilder; import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.configuration.response.common.ConfigurationResponseCommonBuilder; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.path.description.AToZDirection; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.path.description.ZToADirection; +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.AToZDirection; +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.ZToADirection; import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118.RpcStatusEx; import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118.ServicePathNotificationTypes; import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118.response.parameters.sp.ResponseParametersBuilder; +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118.service.handler.header.ServiceHandlerHeaderBuilder; +import org.osgi.service.component.annotations.Activate; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.Reference; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +@Component(immediate = true) public class PathComputationServiceImpl implements PathComputationService { private static final Logger LOG = LoggerFactory.getLogger(PathComputationServiceImpl.class); @@ -61,22 +72,17 @@ public class PathComputationServiceImpl implements PathComputationService { private final GnpyConsumer gnpyConsumer; private PortMapping portMapping; - public PathComputationServiceImpl(NetworkTransactionService networkTransactionService, - NotificationPublishService notificationPublishService, - GnpyConsumer gnpyConsumer, PortMapping portMapping) { + @Activate + public PathComputationServiceImpl(@Reference NetworkTransactionService networkTransactionService, + @Reference NotificationPublishService notificationPublishService, + @Reference GnpyConsumer gnpyConsumer, + @Reference PortMapping portMapping) { this.notificationPublishService = notificationPublishService; this.networkTransactionService = networkTransactionService; this.executor = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(5)); this.gnpyConsumer = gnpyConsumer; this.portMapping = portMapping; - } - - public void init() { - LOG.info("init ..."); - } - - public void close() { - LOG.info("close."); + LOG.debug("PathComputationServiceImpl instantiated"); } @SuppressFBWarnings( @@ -145,7 +151,7 @@ public class PathComputationServiceImpl implements PathComputationService { @Override public ListenableFuture pathComputationRequest(PathComputationRequestInput input) { - LOG.info("pathComputationRequest"); + LOG.debug("input parameters are : input = {}", input.toString()); return executor.submit(new Callable() { @Override @@ -222,8 +228,7 @@ public class PathComputationServiceImpl implements PathComputationService { } // Path calculator returned Success PathDescription pathDescription = - new org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220118 - .service.path.rpc.result.PathDescriptionBuilder() + new PathDescriptionBuilder() .setAToZDirection(path.getAToZDirection()) .setZToADirection(path.getZToADirection()) .build(); @@ -254,7 +259,7 @@ public class PathComputationServiceImpl implements PathComputationService { AToZDirection atoz = pathDescription.getAToZDirection(); if ((atoz != null) && (atoz.getAToZ() != null)) { LOG.debug("Impl AtoZ Notification: [{}] elements in description", atoz.getAToZ().size()); - for (org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705 + for (org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501 .path.description.atoz.direction.AToZKey key : atoz.getAToZ().keySet()) { LOG.debug("Impl AtoZ Notification: [{}] {}", key, atoz.getAToZ().get(key)); } @@ -262,7 +267,7 @@ public class PathComputationServiceImpl implements PathComputationService { ZToADirection ztoa = pathDescription.getZToADirection(); if ((ztoa != null) && (ztoa.getZToA() != null)) { LOG.debug("Impl ZtoA Notification: [{}] elements in description", ztoa.getZToA().size()); - for (org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705 + for (org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501 .path.description.ztoa.direction.ZToAKey key : ztoa.getZToA().keySet()) { LOG.debug("Impl ZtoA Notification: [{}] {}", key, ztoa.getZToA().get(key)); } @@ -272,6 +277,52 @@ public class PathComputationServiceImpl implements PathComputationService { }); } + @Override + public ListenableFuture pathComputationRerouteRequest( + PathComputationRerouteRequestInput input) { + return executor.submit(() -> { + PathComputationRerouteRequestOutputBuilder output = new PathComputationRerouteRequestOutputBuilder(); + ConfigurationResponseCommonBuilder configurationResponseCommon = new ConfigurationResponseCommonBuilder() + .setRequestId("none"); + PceComplianceCheckResult check = PceComplianceCheck.check(input); + if (!check.hasPassed()) { + LOG.error("Path not calculated, path computation reroute request not compliant : {}", + check.getMessage()); + configurationResponseCommon + .setAckFinalIndicator("Yes") + .setResponseCode("Path not calculated") + .setResponseMessage(check.getMessage()); + return output + .setConfigurationResponseCommon(configurationResponseCommon.build()) + .build(); + } + PathComputationRequestInput pathComputationInput = new PathComputationRequestInputBuilder() + .setServiceName("no_name") + .setServiceHandlerHeader(new ServiceHandlerHeaderBuilder().setRequestId("none").build()) + .setServiceAEnd(new ServiceAEndBuilder(input.getServiceAEnd()).build()) + .setServiceZEnd(new ServiceZEndBuilder(input.getServiceZEnd()).build()) + .setHardConstraints(input.getHardConstraints()) + .setPceRoutingMetric(input.getPceRoutingMetric()) + .setResourceReserve(false) + .setSoftConstraints(input.getSoftConstraints()) + .setRoutingMetric(input.getRoutingMetric()) + .build(); + PceSendingPceRPCs sendingPCE = new PceSendingPceRPCs(pathComputationInput, networkTransactionService, + gnpyConsumer, portMapping, input.getEndpoints()); + sendingPCE.pathComputation(); + String message = sendingPCE.getMessage(); + String responseCode = sendingPCE.getResponseCode(); + LOG.info("PCE response: {} {}", message, responseCode); + return output.setConfigurationResponseCommon( + configurationResponseCommon + .setAckFinalIndicator("Yes") + .setResponseCode(responseCode) + .setResponseMessage(message) + .build()) + .build(); + }); + } + public GnpyResponse generateGnpyResponse(Response responseGnpy, String pathDir) { if (responseGnpy == null) { return new GnpyResponseBuilder()