import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.ListeningExecutorService;
import com.google.common.util.concurrent.MoreExecutors;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.opendaylight.yang.gen.v1.http.org.openroadm.resource.types.rev161014.ResourceTypeEnum;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.format.rev191129.ServiceFormat;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service.list.Services;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.PathDescription;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.PathDescription;
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.servicepath.rev171017.ServicePathList;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.binding.Notification;
import org.opendaylight.yangtools.yang.common.Uint32;
+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 RendererServiceOperationsImpl implements RendererServiceOperations {
private static final Logger LOG = LoggerFactory.getLogger(RendererServiceOperationsImpl.class);
private final PortMapping portMapping;
private ListeningExecutorService executor;
- public RendererServiceOperationsImpl(DeviceRendererService deviceRenderer,
- OtnDeviceRendererService otnDeviceRenderer, TransportpceOlmService olmService,
- DataBroker dataBroker, NotificationPublishService notificationPublishService, PortMapping portMapping) {
+ @Activate
+ public RendererServiceOperationsImpl(@Reference DeviceRendererService deviceRenderer,
+ @Reference OtnDeviceRendererService otnDeviceRenderer,
+ @Reference TransportpceOlmService olmService,
+ @Reference DataBroker dataBroker,
+ @Reference NotificationPublishService notificationPublishService,
+ @Reference PortMapping portMapping) {
this.deviceRenderer = deviceRenderer;
this.otnDeviceRenderer = otnDeviceRenderer;
this.olmService = olmService;
this.notificationPublishService = notificationPublishService;
this.portMapping = portMapping;
this.executor = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(NUMBER_OF_THREADS));
+ LOG.debug("RendererServiceOperationsImpl instantiated");
}
@Override
public ListenableFuture<ServiceImplementationRequestOutput>
- serviceImplementation(ServiceImplementationRequestInput input) {
+ serviceImplementation(ServiceImplementationRequestInput input, boolean isTempService) {
LOG.info("Calling service impl request {}", input.getServiceName());
+ LOG.debug("Check if it is temp-service {}", isTempService);
return executor.submit(new Callable<ServiceImplementationRequestOutput>() {
@Override
case StringConstants.SERVICE_TYPE_OTUC2:
case StringConstants.SERVICE_TYPE_OTUC3:
case StringConstants.SERVICE_TYPE_OTUC4:
- if (!manageServicePathCreation(input, serviceType)) {
+ LOG.debug("Check temp service {}", isTempService);
+ if (!manageServicePathCreation(input, serviceType, isTempService)) {
return ModelMappingUtils
.createServiceImplResponse(ResponseCodes.RESPONSE_FAILED, OPERATION_FAILED);
}
return ModelMappingUtils
.createServiceDeleteResponse(ResponseCodes.RESPONSE_FAILED, OPERATION_FAILED);
}
- PathDescription pathDescription = pathDescriptionOpt.get();
+ PathDescription pathDescription = pathDescriptionOpt.orElseThrow();
String serviceType =
ServiceTypes.getServiceType(
service.getServiceAEnd().getServiceFormat().getName(),
service.getServiceAEnd().getServiceRate(),
service.getServiceAEnd().getTxDirection() == null
- || service.getServiceAEnd().getTxDirection().values().stream().findFirst().get()
+ || service.getServiceAEnd().getTxDirection().values().stream().findFirst().orElseThrow()
.getPort() == null
- || service.getServiceAEnd().getTxDirection().values().stream().findFirst().get()
+ || service.getServiceAEnd().getTxDirection().values().stream().findFirst().orElseThrow()
.getPort().getPortName() == null
? null
: portMapping.getMapping(
service.getServiceAEnd().getNodeId().getValue(),
- service.getServiceAEnd().getTxDirection().values().stream().findFirst().get()
- .getPort().getPortName()));
+ service.getServiceAEnd().getTxDirection().values().stream().findFirst()
+ .orElseThrow().getPort().getPortName()));
switch (serviceType) {
case StringConstants.SERVICE_TYPE_100GE_T:
case StringConstants.SERVICE_TYPE_400GE:
});
}
- @edu.umd.cs.findbugs.annotations.SuppressFBWarnings(
+ @SuppressFBWarnings(
value = "UPM_UNCALLED_PRIVATE_METHOD",
justification = "call in call() method")
private Uint32 getServiceRate(ServiceImplementationRequestInput input) {
.get(serviceName);
}
- @edu.umd.cs.findbugs.annotations.SuppressFBWarnings(
+ @SuppressFBWarnings(
value = "UPM_UNCALLED_PRIVATE_METHOD",
justification = "call in call() method")
private ServicePowerTurndownOutput olmPowerTurndown(ServicePathInputData servicePathInputData)
.getResult();
}
- @edu.umd.cs.findbugs.annotations.SuppressFBWarnings(
+ @SuppressFBWarnings(
value = "UPM_UNCALLED_PRIVATE_METHOD",
justification = "call in call() method")
private Optional<org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118
}
}
- @edu.umd.cs.findbugs.annotations.SuppressFBWarnings(
+ @SuppressFBWarnings(
value = "UPM_UNCALLED_PRIVATE_METHOD",
justification = "call in call() method")
private List<DeviceRenderingResult> deviceRendering(
return renderingResults;
}
- @edu.umd.cs.findbugs.annotations.SuppressFBWarnings(
+ @SuppressFBWarnings(
value = "UPM_UNCALLED_PRIVATE_METHOD",
justification = "call in call() method")
private List<OtnDeviceRenderingResult> otnDeviceRendering(
return otnRenderingResults;
}
- @edu.umd.cs.findbugs.annotations.SuppressFBWarnings(
+ @SuppressFBWarnings(
value = "UPM_UNCALLED_PRIVATE_METHOD",
justification = "call in call() method")
private void olmPowerSetup(
RollbackProcessor rollbackProcessor,
ServicePowerSetupInput powerSetupInputAtoZ,
- ServicePowerSetupInput powerSetupInputZtoA) {
+ ServicePowerSetupInput powerSetupInputZtoA, boolean isTempService) {
//TODO olmPowerSetupFutureAtoZ & olmPowerSetupFutureZtoA & olmFutures used only once
// Do notifications & LOG.info deserve this ?
//TODO use constants for LOG.info & notifications common messages
+ // if the service create is a temp-service, OLM will be skipped
+ if (isTempService) {
+ LOG.info("For temp-service create OLM is not computed and skipped");
+ return;
+ }
LOG.info("Olm power setup A-Z");
sendNotifications(
- ServicePathNotificationTypes.ServiceImplementationRequest,
- powerSetupInputAtoZ.getServiceName(),
- RpcStatusEx.Pending,
- "Olm power setup A-Z");
+ ServicePathNotificationTypes.ServiceImplementationRequest,
+ powerSetupInputAtoZ.getServiceName(),
+ RpcStatusEx.Pending,
+ "Olm power setup A-Z");
ListenableFuture<OLMRenderingResult> olmPowerSetupFutureAtoZ =
- this.executor.submit(new OlmPowerSetupTask(this.olmService, powerSetupInputAtoZ));
+ this.executor.submit(new OlmPowerSetupTask(this.olmService, powerSetupInputAtoZ));
LOG.info("OLM power setup Z-A");
sendNotifications(
- ServicePathNotificationTypes.ServiceImplementationRequest,
- powerSetupInputAtoZ.getServiceName(),
- RpcStatusEx.Pending,
- "Olm power setup Z-A");
+ ServicePathNotificationTypes.ServiceImplementationRequest,
+ powerSetupInputAtoZ.getServiceName(),
+ RpcStatusEx.Pending,
+ "Olm power setup Z-A");
ListenableFuture<OLMRenderingResult> olmPowerSetupFutureZtoA =
- this.executor.submit(new OlmPowerSetupTask(this.olmService, powerSetupInputZtoA));
-
+ this.executor.submit(new OlmPowerSetupTask(this.olmService, powerSetupInputZtoA));
ListenableFuture<List<OLMRenderingResult>> olmFutures =
- Futures.allAsList(olmPowerSetupFutureAtoZ, olmPowerSetupFutureZtoA);
+ Futures.allAsList(olmPowerSetupFutureAtoZ, olmPowerSetupFutureZtoA);
List<OLMRenderingResult> olmResults;
try {
} catch (InterruptedException | ExecutionException | TimeoutException e) {
LOG.warn(OLM_ROLL_BACK_MSG, e);
sendNotifications(
- ServicePathNotificationTypes.ServiceImplementationRequest,
- powerSetupInputAtoZ.getServiceName(),
- RpcStatusEx.Pending,
- OLM_ROLL_BACK_MSG);
+ ServicePathNotificationTypes.ServiceImplementationRequest,
+ powerSetupInputAtoZ.getServiceName(),
+ RpcStatusEx.Pending,
+ OLM_ROLL_BACK_MSG);
rollbackProcessor.addTask(
- new OlmPowerSetupRollbackTask("AtoZOLMTask", true, this.olmService, powerSetupInputAtoZ));
+ new OlmPowerSetupRollbackTask("AtoZOLMTask", true, this.olmService, powerSetupInputAtoZ));
rollbackProcessor.addTask(
- new OlmPowerSetupRollbackTask("ZtoAOLMTask", true, this.olmService, powerSetupInputZtoA));
+ new OlmPowerSetupRollbackTask("ZtoAOLMTask", true, this.olmService, powerSetupInputZtoA));
return;
}
-
rollbackProcessor.addTask(
- new OlmPowerSetupRollbackTask(
- "AtoZOLMTask",
- ! olmResults.get(0).isSuccess(),
- this.olmService,
- powerSetupInputAtoZ));
+ new OlmPowerSetupRollbackTask(
+ "AtoZOLMTask",
+ !olmResults.get(0).isSuccess(),
+ this.olmService,
+ powerSetupInputAtoZ));
rollbackProcessor.addTask(
- new OlmPowerSetupRollbackTask(
- "ZtoAOLMTask",
- ! olmResults.get(1).isSuccess(),
- this.olmService,
- powerSetupInputZtoA));
+ new OlmPowerSetupRollbackTask(
+ "ZtoAOLMTask",
+ !olmResults.get(1).isSuccess(),
+ this.olmService,
+ powerSetupInputZtoA));
}
- @edu.umd.cs.findbugs.annotations.SuppressFBWarnings(
+ @SuppressFBWarnings(
value = "UPM_UNCALLED_PRIVATE_METHOD",
justification = "call in call() method")
private boolean isServiceActivated(String nodeId, String tpId) {
return result <= threshold;
}
- @edu.umd.cs.findbugs.annotations.SuppressFBWarnings(
+ @SuppressFBWarnings(
value = "UPM_UNCALLED_PRIVATE_METHOD",
justification = "call in call() method")
- private boolean manageServicePathCreation(ServiceImplementationRequestInput input, String serviceType) {
+ private boolean manageServicePathCreation(ServiceImplementationRequestInput input, String serviceType,
+ boolean isTempService) {
ServicePathInputData servicePathInputDataAtoZ =
ModelMappingUtils
.rendererCreateServiceInputAToZ(input.getServiceName(), input.getPathDescription(), Action.Create);
//olmPowerSetupInputAtoZ,
ModelMappingUtils.createServicePowerSetupInput(renderingResults.get(0).getOlmList(), input),
//olmPowerSetupInputZtoA
- ModelMappingUtils.createServicePowerSetupInput(renderingResults.get(1).getOlmList(), input));
+ ModelMappingUtils.createServicePowerSetupInput(renderingResults.get(1).getOlmList(), input), isTempService);
if (rollbackProcessor.rollbackAllIfNecessary() > 0) {
sendNotifications(
ServicePathNotificationTypes.ServiceImplementationRequest,
return true;
}
- @edu.umd.cs.findbugs.annotations.SuppressFBWarnings(
+ @SuppressFBWarnings(
value = "UPM_UNCALLED_PRIVATE_METHOD",
justification = "call in call() method")
private boolean manageServicePathDeletion(String serviceName, PathDescription pathDescription, String serviceType)
return true;
}
- @edu.umd.cs.findbugs.annotations.SuppressFBWarnings(
+ @SuppressFBWarnings(
value = "UPM_UNCALLED_PRIVATE_METHOD",
justification = "call in call() method")
private boolean manageOtnServicePathCreation(
return true;
}
- @edu.umd.cs.findbugs.annotations.SuppressFBWarnings(
+ @SuppressFBWarnings(
value = "UPM_UNCALLED_PRIVATE_METHOD",
justification = "call in call() method")
private boolean manageOtnServicePathDeletion(