import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.ListeningExecutorService;
import com.google.common.util.concurrent.MoreExecutors;
+
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
+
import org.opendaylight.mdsal.binding.api.DataBroker;
import org.opendaylight.mdsal.binding.api.NotificationPublishService;
import org.opendaylight.mdsal.binding.api.ReadTransaction;
public class RendererServiceOperationsImpl implements RendererServiceOperations {
+ private static final String DEVICE_RENDERING_ROLL_BACK_MSG =
+ "Device rendering was not successful! Rendering will be rolled back.";
+ private static final String OLM_ROLL_BACK_MSG =
+ "OLM power setup was not successful! Rendering and OLM will be rolled back.";
+ private static final String RENDERING_DEVICES_A_Z_MSG = "Rendering devices A-Z";
+ private static final String TURNING_DOWN_POWER_ON_A_TO_Z_PATH_MSG = "Turning down power on A-to-Z path";
private static final Logger LOG = LoggerFactory.getLogger(RendererServiceOperationsImpl.class);
private static final String FAILED = "Failed";
private static final String OPERATION_FAILED = "Operation Failed";
deviceRendering(rollbackProcessor, servicePathInputDataAtoZ, servicePathInputDataZtoA);
if (rollbackProcessor.rollbackAllIfNecessary() > 0) {
sendNotifications(ServicePathNotificationTypes.ServiceImplementationRequest, input.getServiceName(),
- RpcStatusEx.Failed, "Device rendering was not successful! Rendering will be rolled back.");
+ RpcStatusEx.Failed, DEVICE_RENDERING_ROLL_BACK_MSG);
return ModelMappingUtils.createServiceImplResponse(ResponseCodes.RESPONSE_FAILED, OPERATION_FAILED);
}
ServicePowerSetupInput olmPowerSetupInputAtoZ =
if (rollbackProcessor.rollbackAllIfNecessary() > 0) {
sendNotifications(ServicePathNotificationTypes.ServiceImplementationRequest, input.getServiceName(),
RpcStatusEx.Failed,
- "OLM power setup was not successful! Rendering and OLM will be rolled back.");
+ OLM_ROLL_BACK_MSG);
return ModelMappingUtils.createServiceImplResponse(ResponseCodes.RESPONSE_FAILED, OPERATION_FAILED);
}
// run service activation test twice - once on source node and once on
});
}
+ @Override
@SuppressWarnings("checkstyle:IllegalCatch")
public OperationResult reserveResource(PathDescription pathDescription) {
return OperationResult.ok("Resources reserved successfully in network model");
}
+ @Override
@SuppressWarnings("checkstyle:IllegalCatch")
public OperationResult freeResource(PathDescription pathDescription) {
ModelMappingUtils.rendererCreateServiceInputZToA(serviceName, pathDescription);
// OLM turn down power
try {
- LOG.debug("Turning down power on A-to-Z path");
+ LOG.debug(TURNING_DOWN_POWER_ON_A_TO_Z_PATH_MSG);
sendNotifications(ServicePathNotificationTypes.ServiceDelete,
- input.getServiceName(), RpcStatusEx.Pending, "Turning down power on A-to-Z path");
+ input.getServiceName(), RpcStatusEx.Pending, TURNING_DOWN_POWER_ON_A_TO_Z_PATH_MSG);
ServicePowerTurndownOutput atozPowerTurndownOutput = olmPowerTurndown(servicePathInputDataAtoZ);
// TODO add some flag rather than string
if (FAILED.equals(atozPowerTurndownOutput.getResult())) {
}
+ @edu.umd.cs.findbugs.annotations.SuppressFBWarnings(
+ value = "UPM_UNCALLED_PRIVATE_METHOD",
+ justification = "call in call() method")
private ServicePowerTurndownOutput olmPowerTurndown(ServicePathInputData servicePathInputData)
throws InterruptedException, ExecutionException, TimeoutException {
- LOG.debug("Turning down power on A-to-Z path");
+ LOG.debug(TURNING_DOWN_POWER_ON_A_TO_Z_PATH_MSG);
Future<RpcResult<ServicePowerTurndownOutput>> powerTurndownFuture = this.olmService.servicePowerTurndown(
new ServicePowerTurndownInputBuilder(servicePathInputData.getServicePathInput()).build());
return powerTurndownFuture.get(Timeouts.DATASTORE_READ, TimeUnit.MILLISECONDS).getResult();
}
+ @edu.umd.cs.findbugs.annotations.SuppressFBWarnings(
+ value = "UPM_UNCALLED_PRIVATE_METHOD",
+ justification = "call in call() method")
private Optional<PathDescription> getPathDescriptionFromDatastore(String serviceName) {
InstanceIdentifier<PathDescription> pathDescriptionIID = InstanceIdentifier.create(ServicePathList.class)
.child(ServicePaths.class, new ServicePathsKey(serviceName)).child(PathDescription.class);
}
}
+ @edu.umd.cs.findbugs.annotations.SuppressFBWarnings(
+ value = "UPM_UNCALLED_PRIVATE_METHOD",
+ justification = "call in call() method")
private List<DeviceRenderingResult> deviceRendering(RollbackProcessor rollbackProcessor,
ServicePathInputData servicePathDataAtoZ, ServicePathInputData servicePathDataZtoA) {
- LOG.info("Rendering devices A-Z");
+ LOG.info(RENDERING_DEVICES_A_Z_MSG);
sendNotifications(ServicePathNotificationTypes.ServiceImplementationRequest,
servicePathDataAtoZ.getServicePathInput().getServiceName(), RpcStatusEx.Pending,
- "Rendering devices A-Z");
+ RENDERING_DEVICES_A_Z_MSG);
ListenableFuture<DeviceRenderingResult> atozrenderingFuture =
this.executor.submit(new DeviceRenderingTask(this.deviceRenderer, servicePathDataAtoZ,
ServicePathDirection.A_TO_Z));
LOG.info("Rendering devices Z-A");
sendNotifications(ServicePathNotificationTypes.ServiceImplementationRequest,
servicePathDataAtoZ.getServicePathInput().getServiceName(), RpcStatusEx.Pending,
- "Rendering devices A-Z");
+ RENDERING_DEVICES_A_Z_MSG);
ListenableFuture<DeviceRenderingResult> ztoarenderingFuture =
this.executor.submit(new DeviceRenderingTask(this.deviceRenderer, servicePathDataZtoA,
ServicePathDirection.Z_TO_A));
LOG.info("Waiting for A-Z and Z-A device renderers ...");
renderingResults = renderingCombinedFuture.get(Timeouts.RENDERING_TIMEOUT, TimeUnit.MILLISECONDS);
} catch (InterruptedException | ExecutionException | TimeoutException e) {
- LOG.warn("Device rendering was not successful! Rendering will be rolled back.", e);
+ LOG.warn(DEVICE_RENDERING_ROLL_BACK_MSG, e);
sendNotifications(ServicePathNotificationTypes.ServiceImplementationRequest,
servicePathDataAtoZ.getServicePathInput().getServiceName(), RpcStatusEx.Pending,
- "Device rendering was not successful! Rendering will be rolled back.");
+ DEVICE_RENDERING_ROLL_BACK_MSG);
//FIXME we can't do rollback here, because we don't have rendering results.
return renderingResults;
}
return renderingResults;
}
+ @edu.umd.cs.findbugs.annotations.SuppressFBWarnings(
+ value = "UPM_UNCALLED_PRIVATE_METHOD",
+ justification = "call in call() method")
private void olmPowerSetup(RollbackProcessor rollbackProcessor, ServicePowerSetupInput powerSetupInputAtoZ,
ServicePowerSetupInput powerSetupInputZtoA) {
LOG.info("Olm power setup A-Z");
LOG.info("Waiting for A-Z and Z-A OLM power setup ...");
olmResults = olmFutures.get(Timeouts.OLM_TIMEOUT, TimeUnit.MILLISECONDS);
} catch (InterruptedException | ExecutionException | TimeoutException e) {
- LOG.warn("OLM power setup was not successful! Rendering and OLM will be rolled back.", e);
+ LOG.warn(OLM_ROLL_BACK_MSG, e);
sendNotifications(ServicePathNotificationTypes.ServiceImplementationRequest,
powerSetupInputAtoZ.getServiceName(), RpcStatusEx.Pending,
- "OLM power setup was not successful! Rendering and OLM will be rolled back.");
+ OLM_ROLL_BACK_MSG);
rollbackProcessor.addTask(new OlmPowerSetupRollbackTask("AtoZOLMTask", true,
this.olmService, powerSetupInputAtoZ));
rollbackProcessor.addTask(new OlmPowerSetupRollbackTask("ZtoAOLMTask", true,
this.olmService, powerSetupInputZtoA));
}
+ @edu.umd.cs.findbugs.annotations.SuppressFBWarnings(
+ value = "UPM_UNCALLED_PRIVATE_METHOD",
+ justification = "call in call() method")
private boolean isServiceActivated(String nodeId, String tpId) {
LOG.info("Starting service activation test on node {} and tp {}", nodeId, tpId);
for (int i = 0; i < 3; i++) {