* @return ConstraintsSp HardConstraintsSp or HardConstraintsSp
*/
private <T> ConstraintsSp getConstraints(T input) {
- CoRoutingOrGeneral coRoutingOrGeneral = null;
HardConstraintsBuilder tempHard = new HardConstraintsBuilder();
SoftConstraintsBuilder tempSoft = new SoftConstraintsBuilder();
if ((input != null) && (input instanceof Constraints)) {
- Constraints constraints = (Constraints)input;
- coRoutingOrGeneral = constraints.getCoRoutingOrGeneral();
- General tmpGeneral = null;
- CoRouting tmpCoRouting = null;
- if (coRoutingOrGeneral != null) {
- org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints
- .rev171017.constraints.sp.co.routing.or.general.GeneralBuilder finalGeneral =
- new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints
- .rev171017.constraints.sp.co.routing.or.general.GeneralBuilder();
- org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints
- .rev171017.constraints.sp.co.routing.or.general.CoRoutingBuilder finalCoRouting =
- new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints
- .rev171017.constraints.sp.co.routing.or.general.CoRoutingBuilder();
- if (coRoutingOrGeneral instanceof General) {
- tmpGeneral = (General) coRoutingOrGeneral;
- if (tmpGeneral != null) {
- Diversity tmpDiversity = tmpGeneral.getDiversity();
- if (tmpDiversity != null) {
- finalGeneral.setDiversity(
- new DiversityBuilder()
- .setExistingService(tmpDiversity.getExistingService())
- .setExistingServiceApplicability(
- new ExistingServiceApplicabilityBuilder()
- .setClli(tmpDiversity.getExistingServiceApplicability().isSite())
- .setNode(tmpDiversity.getExistingServiceApplicability().isNode())
- .setSrlg(tmpDiversity.getExistingServiceApplicability().isSrlg())
- .build())
- .build());
- }
- Exclude tmpExclude = tmpGeneral.getExclude();
- if (tmpExclude != null) {
- List<String> nodeIdList = new ArrayList<>();
- for (NodeIdType nodeId : tmpExclude.getNodeId()) {
- nodeIdList.add(nodeId.getValue());
- }
- finalGeneral.setExclude(
- new ExcludeBuilder()
- .setSupportingServiceName(tmpExclude.getSupportingServiceName())
- .setClli(tmpExclude.getSite())
- .setNodeId(nodeIdList)
- //.setAffinity(value)
- //.setSRLG(value)
- .build());
- }
- Include tmpInclude = tmpGeneral.getInclude();
- if (tmpInclude != null) {
- finalGeneral.setInclude(
- new IncludeBuilder()
- //.setOrderedHops()
- .build());
- }
- Latency tmpLatency = tmpGeneral.getLatency();
- if (tmpLatency != null) {
- finalGeneral.setLatency(
- new LatencyBuilder()
- .setMaxLatency(tmpLatency.getMaxLatency())
- .build());
- }
- }
- tempHard.setCoRoutingOrGeneral(finalGeneral.build())
- .setCustomerCode(constraints.getCustomerCode());
- tempSoft.setCoRoutingOrGeneral(finalGeneral.build())
- .setCustomerCode(constraints.getCustomerCode());
- } else if (coRoutingOrGeneral instanceof CoRouting) {
- tmpCoRouting = (CoRouting)coRoutingOrGeneral;
- if (tmpCoRouting != null) {
- org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev190329
- .constraints.co.routing.or.general.co.routing.CoRouting tmpCoRoutingCoRouting =
- tmpCoRouting.getCoRouting();
- if (tmpCoRoutingCoRouting != null) {
- finalCoRouting.setCoRouting(
- new CoRoutingBuilder()
- .setExistingService(tmpCoRoutingCoRouting.getExistingService())
- .build());
- }
- }
- tempHard.setCoRoutingOrGeneral(finalCoRouting.build())
- .setCustomerCode(constraints.getCustomerCode());
- tempSoft.setCoRoutingOrGeneral(finalCoRouting.build())
- .setCustomerCode(constraints.getCustomerCode());
- }
- }
+ updateConstraintBuilders(input, tempHard, tempSoft);
}
if (input instanceof HardConstraints) {
return tempHard.build();
}
}
+ /**
+ * Update hardConstraintsBuilder and softConstraintsBuilder regarding input.
+ * @param <T> T
+ * @param input T
+ * @param hardConstraintsBuilder HardConstraintsBuilder
+ * @param softConstraintsBuilder SoftConstraintsBuilder
+ */
+ private <T> void updateConstraintBuilders(T input,
+ HardConstraintsBuilder hardConstraintsBuilder,
+ SoftConstraintsBuilder softConstraintsBuilder) {
+ Constraints constraints = (Constraints)input;
+ CoRoutingOrGeneral coRoutingOrGeneral = constraints.getCoRoutingOrGeneral();
+ if (coRoutingOrGeneral != null) {
+ if (coRoutingOrGeneral instanceof General) {
+ updateConstraintBuilders4General(hardConstraintsBuilder, softConstraintsBuilder, constraints);
+ } else if (coRoutingOrGeneral instanceof CoRouting) {
+ updateConstraintBuilders4Corouting(hardConstraintsBuilder, softConstraintsBuilder, constraints);
+ }
+ }
+ }
+
+ /**
+ * Update hardConstraintsBuilder and softConstraintsBuilder for corouting constraints.
+ * @param hardConstraintsBuilder HardConstraintsBuilder
+ * @param softConstraintsBuilder SoftConstraintsBuilder
+ * @param constraints Constraints
+ */
+ private void updateConstraintBuilders4Corouting(HardConstraintsBuilder hardConstraintsBuilder,
+ SoftConstraintsBuilder softConstraintsBuilder, Constraints constraints) {
+ org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev171017
+ .constraints.sp.co.routing.or.general.CoRoutingBuilder finalCoRouting =
+ new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev171017
+ .constraints.sp.co.routing.or.general.CoRoutingBuilder();
+ CoRouting tmpCoRouting = (CoRouting)constraints.getCoRoutingOrGeneral();
+ if (tmpCoRouting != null) {
+ org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev190329
+ .constraints.co.routing.or.general.co.routing.CoRouting tmpCoRoutingCoRouting =
+ tmpCoRouting.getCoRouting();
+ if (tmpCoRoutingCoRouting != null) {
+ finalCoRouting.setCoRouting(
+ new CoRoutingBuilder()
+ .setExistingService(tmpCoRoutingCoRouting.getExistingService())
+ .build());
+ }
+ }
+ hardConstraintsBuilder.setCoRoutingOrGeneral(finalCoRouting.build())
+ .setCustomerCode(constraints.getCustomerCode());
+ softConstraintsBuilder.setCoRoutingOrGeneral(finalCoRouting.build())
+ .setCustomerCode(constraints.getCustomerCode());
+ }
+
+ /**
+ * Update hardConstraintsBuilder and softConstraintsBuilder for general constraints.
+ * @param hardConstraintsBuilder HardConstraintsBuilder
+ * @param softConstraintsBuilder SoftConstraintsBuilder
+ * @param constraints Constraints
+ */
+ private void updateConstraintBuilders4General(HardConstraintsBuilder hardConstraintsBuilder,
+ SoftConstraintsBuilder softConstraintsBuilder, Constraints constraints) {
+ org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev171017
+ .constraints.sp.co.routing.or.general.GeneralBuilder finalGeneral =
+ new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev171017
+ .constraints.sp.co.routing.or.general.GeneralBuilder();
+ General tmpGeneral = (General) constraints.getCoRoutingOrGeneral();
+ if (tmpGeneral != null) {
+ Diversity tmpDiversity = tmpGeneral.getDiversity();
+ if (tmpDiversity != null) {
+ finalGeneral.setDiversity(
+ new DiversityBuilder()
+ .setExistingService(tmpDiversity.getExistingService())
+ .setExistingServiceApplicability(
+ new ExistingServiceApplicabilityBuilder()
+ .setClli(tmpDiversity.getExistingServiceApplicability().isSite())
+ .setNode(tmpDiversity.getExistingServiceApplicability().isNode())
+ .setSrlg(tmpDiversity.getExistingServiceApplicability().isSrlg())
+ .build())
+ .build());
+ }
+ Exclude tmpExclude = tmpGeneral.getExclude();
+ if (tmpExclude != null) {
+ List<String> nodeIdList = new ArrayList<>();
+ for (NodeIdType nodeId : tmpExclude.getNodeId()) {
+ nodeIdList.add(nodeId.getValue());
+ }
+ finalGeneral.setExclude(
+ new ExcludeBuilder()
+ .setSupportingServiceName(tmpExclude.getSupportingServiceName())
+ .setClli(tmpExclude.getSite())
+ .setNodeId(nodeIdList)
+ .build());
+ }
+ Include tmpInclude = tmpGeneral.getInclude();
+ if (tmpInclude != null) {
+ finalGeneral.setInclude(
+ new IncludeBuilder()
+ .build());
+ }
+ Latency tmpLatency = tmpGeneral.getLatency();
+ if (tmpLatency != null) {
+ finalGeneral.setLatency(
+ new LatencyBuilder()
+ .setMaxLatency(tmpLatency.getMaxLatency())
+ .build());
+ }
+ }
+ hardConstraintsBuilder.setCoRoutingOrGeneral(finalGeneral.build())
+ .setCustomerCode(constraints.getCustomerCode());
+ softConstraintsBuilder.setCoRoutingOrGeneral(finalGeneral.build())
+ .setCustomerCode(constraints.getCustomerCode());
+ }
+
/**
* map hard/soft constraints from Service 1.2
* to ServicePath 1.4.
import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev171017.service.path.list.ServicePathsBuilder;
import org.opendaylight.yangtools.yang.common.RpcResult;
import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
public final class ModelMappingUtils {
- private static final Logger LOG =
- LoggerFactory.getLogger(org.opendaylight.transportpce.servicehandler.ModelMappingUtils.class);
- private static final String TERMINATION_POINT = "TerminationPoint";
-
private ModelMappingUtils() {
}
.setOtuServiceRate(input.getServiceAEnd().getOtuServiceRate())
.setOduServiceRate(input.getServiceAEnd().getOduServiceRate())
.setClli(input.getServiceAEnd().getClli())
- .setOtuServiceRate(input.getServiceAEnd().getOtuServiceRate()) // set otu and odu
+ // set otu and odu
+ .setOtuServiceRate(input.getServiceAEnd().getOtuServiceRate())
.setOduServiceRate(input.getServiceZEnd().getOduServiceRate())
.setClli(input.getServiceAEnd().getClli())
.setNodeId(new NodeIdType(input.getServiceAEnd().getNodeId().getValue()).getValue())
.setOtuServiceRate(input.getServiceZEnd().getOtuServiceRate())
.setOduServiceRate(input.getServiceZEnd().getOduServiceRate())
.setClli(input.getServiceZEnd().getClli())
- .setOtuServiceRate(input.getServiceAEnd().getOtuServiceRate()) // set otu and odu
+ // set otu and odu
+ .setOtuServiceRate(input.getServiceAEnd().getOtuServiceRate())
.setOduServiceRate(input.getServiceZEnd().getOduServiceRate())
.setClli(input.getServiceZEnd().getClli())
.setNodeId(new NodeIdType(input.getServiceZEnd().getNodeId().getValue()).getValue())
* Top level service interface providing main OpenROADM controller services.
*/
public class ServicehandlerImpl implements OrgOpenroadmServiceService {
-
private static final Logger LOG = LoggerFactory.getLogger(ServicehandlerImpl.class);
+ private static final String TEMP_SERVICE_CREATE_MSG = "tempServiceCreate: {}";
+ private static final String TEMP_SERVICE_DELETE_MSG = "tempServiceDelete: {}";
+ private static final String SERVICE_RESTORATION_MSG = "serviceRestoration: {}";
+ private static final String SERVICE_RECONFIGURE_MSG = "serviceReconfigure: {}";
+ private static final String SERVICE_FEASABILITY_CHECK_MSG = "serviceFeasabilityCheck: {}";
+ private static final String SERVICE_DELETE_MSG = "serviceDelete: {}";
+ private static final String SERVICE_CREATE_MSG = "serviceCreate: {}";
private DataBroker db;
private ServiceDataStoreOperations serviceDataStoreOperations;
OperationResult validationResult = ServiceCreateValidation.validateServiceCreateRequest(
new ServiceInput(input), RpcActions.ServiceCreate);
if (! validationResult.isSuccess()) {
- LOG.warn("serviceCreate: {}", LogMessages.ABORT_VALID_FAILED);
+ LOG.warn(SERVICE_CREATE_MSG, LogMessages.ABORT_VALID_FAILED);
return ModelMappingUtils.createCreateServiceReply(
input, ResponseCodes.FINAL_ACK_YES,
validationResult.getResultMessage(), ResponseCodes.RESPONSE_FAILED);
this.pceListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
this.rendererListenerImpl.setserviceDataStoreOperations(serviceDataStoreOperations);
this.rendererListenerImpl.setServiceInput(new ServiceInput(input));
- LOG.debug("serviceCreate: {}", LogMessages.PCE_CALLING);
+ LOG.debug(SERVICE_CREATE_MSG, LogMessages.PCE_CALLING);
PathComputationRequestOutput output = this.pceServiceWrapper.performPCE(input, true);
if (output == null) {
- LOG.warn("serviceCreate: {}", LogMessages.ABORT_PCE_FAILED);
+ LOG.warn(SERVICE_CREATE_MSG, LogMessages.ABORT_PCE_FAILED);
return ModelMappingUtils.createCreateServiceReply(input, ResponseCodes.FINAL_ACK_YES,
LogMessages.PCE_FAILED, ResponseCodes.RESPONSE_FAILED);
}
input.getServiceDeleteReqInfo().getServiceName(),
input.getSdncRequestHeader(), null, RpcActions.ServiceDelete, false, true);
if (!serviceHandlerCheckResult.hasPassed()) {
- LOG.warn("serviceDelete: {}", LogMessages.ABORT_SERVICE_NON_COMPLIANT);
+ LOG.warn(SERVICE_DELETE_MSG, LogMessages.ABORT_SERVICE_NON_COMPLIANT);
return ModelMappingUtils.createDeleteServiceReply(
input, ResponseCodes.FINAL_ACK_YES,
LogMessages.SERVICE_NON_COMPLIANT, ResponseCodes.RESPONSE_FAILED);
}
//Check presence of service to be deleted
-//TODO check if an expected bug was justifying this NPE handling
-// try {
Optional<Services> serviceOpt = this.serviceDataStoreOperations.getService(serviceName);
-// } catch (NullPointerException e) {
-// LOG.error("Something wrong when retrieving service '{}' from datastore : ", serviceName, e);
-// return ModelMappingUtils.createDeleteServiceReply(
-// input, ResponseCodes.FINAL_ACK_YES,
-// LogMessages.serviceNotInDS(serviceName), ResponseCodes.RESPONSE_FAILED);
-// }
Services service;
if (!serviceOpt.isPresent()) {
- LOG.warn("serviceDelete: {}", LogMessages.serviceNotInDS(serviceName));
+ LOG.warn(SERVICE_DELETE_MSG, LogMessages.serviceNotInDS(serviceName));
return ModelMappingUtils.createDeleteServiceReply(
input, ResponseCodes.FINAL_ACK_YES,
LogMessages.serviceNotInDS(serviceName), ResponseCodes.RESPONSE_FAILED);
serviceDeleteInput, ServiceNotificationTypes.ServiceDeleteResult, service);
if (output == null) {
- LOG.error("serviceDelete: {}", LogMessages.RENDERER_DELETE_FAILED);
+ LOG.error(SERVICE_DELETE_MSG, LogMessages.RENDERER_DELETE_FAILED);
return ModelMappingUtils.createDeleteServiceReply(
input, ResponseCodes.FINAL_ACK_YES,
LogMessages.RENDERER_DELETE_FAILED, ResponseCodes.RESPONSE_FAILED);
OperationResult validationResult = ServiceCreateValidation.validateServiceCreateRequest(serviceInput,
RpcActions.ServiceFeasibilityCheck);
if (! validationResult.isSuccess()) {
- LOG.warn("serviceFeasabilityCheck: {}", LogMessages.ABORT_VALID_FAILED);
+ LOG.warn(SERVICE_FEASABILITY_CHECK_MSG, LogMessages.ABORT_VALID_FAILED);
return ModelMappingUtils.createCreateServiceReply(
input, ResponseCodes.FINAL_ACK_YES,
validationResult.getResultMessage(), ResponseCodes.RESPONSE_FAILED);
this.pceListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
this.rendererListenerImpl.setserviceDataStoreOperations(serviceDataStoreOperations);
this.rendererListenerImpl.setServiceInput(new ServiceInput(input));
- LOG.debug("serviceFeasabilityCheck: {}", LogMessages.PCE_CALLING);
+ LOG.debug(SERVICE_FEASABILITY_CHECK_MSG, LogMessages.PCE_CALLING);
PathComputationRequestOutput output = this.pceServiceWrapper.performPCE(input, true);
if (output == null) {
- LOG.warn("serviceFeasabilityCheck: {}", LogMessages.ABORT_PCE_FAILED);
+ LOG.warn(SERVICE_FEASABILITY_CHECK_MSG, LogMessages.ABORT_PCE_FAILED);
return ModelMappingUtils.createCreateServiceReply(input, ResponseCodes.FINAL_ACK_YES,
LogMessages.PCE_FAILED, ResponseCodes.RESPONSE_FAILED);
}
LOG.info("RPC serviceReconfigure received for {}", serviceName);
Optional<Services> servicesObject = this.serviceDataStoreOperations.getService(serviceName);
if (!servicesObject.isPresent()) {
- LOG.warn("serviceReconfigure: {}", LogMessages.serviceNotInDS(serviceName));
+ LOG.warn(SERVICE_RECONFIGURE_MSG, LogMessages.serviceNotInDS(serviceName));
return ModelMappingUtils.createCreateServiceReply(
input,
LogMessages.serviceNotInDS(serviceName), RpcStatus.Failed);
OperationResult validationResult = ServiceCreateValidation
.validateServiceCreateRequest(new ServiceInput(input), RpcActions.ServiceReconfigure);
if (!validationResult.isSuccess()) {
- LOG.warn("serviceReconfigure: {}", LogMessages.ABORT_VALID_FAILED);
+ LOG.warn(SERVICE_RECONFIGURE_MSG, LogMessages.ABORT_VALID_FAILED);
return ModelMappingUtils.createCreateServiceReply(
input,
validationResult.getResultMessage(), RpcStatus.Failed);
.ServiceDeleteOutput output = this.rendererServiceWrapper.performRenderer(serviceDeleteInput,
ServiceNotificationTypes.ServiceDeleteResult, null);
if (output == null) {
- LOG.error("serviceReconfigure: {}", LogMessages.RENDERER_DELETE_FAILED);
+ LOG.error(SERVICE_RECONFIGURE_MSG, LogMessages.RENDERER_DELETE_FAILED);
return ModelMappingUtils.createCreateServiceReply(
input,
LogMessages.RENDERER_DELETE_FAILED, RpcStatus.Successful);
Optional<Services> servicesObject = this.serviceDataStoreOperations.getService(serviceName);
if (!servicesObject.isPresent()) {
- LOG.warn("serviceRestoration: {}", LogMessages.serviceNotInDS(serviceName));
+ LOG.warn(SERVICE_RESTORATION_MSG, LogMessages.serviceNotInDS(serviceName));
return ModelMappingUtils.createRestoreServiceReply(
LogMessages.serviceNotInDS(serviceName), RpcStatus.Failed);
}
State state = service.getOperationalState();
if (state == State.InService) {
- LOG.error("serviceRestoration: {}", LogMessages.serviceInService(serviceName));
+ LOG.error(SERVICE_RESTORATION_MSG, LogMessages.serviceInService(serviceName));
return ModelMappingUtils.createRestoreServiceReply(
LogMessages.serviceInService(serviceName), RpcStatus.Failed);
}
.ServiceDeleteOutput output = this.rendererServiceWrapper.performRenderer(serviceDeleteInput,
ServiceNotificationTypes.ServiceDeleteResult, null);
if (output == null) {
- LOG.error("serviceRestoration: {}", LogMessages.RENDERER_DELETE_FAILED);
+ LOG.error(SERVICE_RESTORATION_MSG, LogMessages.RENDERER_DELETE_FAILED);
return ModelMappingUtils.createRestoreServiceReply(
LogMessages.RENDERER_DELETE_FAILED, RpcStatus.Failed);
}
commonId, null, null, RpcActions.ServiceDelete, false, false
);
if (!serviceHandlerCheckResult.hasPassed()) {
- LOG.warn("tempServiceDelete: {}", LogMessages.ABORT_SERVICE_NON_COMPLIANT);
+ LOG.warn(TEMP_SERVICE_DELETE_MSG, LogMessages.ABORT_SERVICE_NON_COMPLIANT);
return ModelMappingUtils.createDeleteServiceReply(
input, ResponseCodes.FINAL_ACK_YES,
LogMessages.SERVICE_NON_COMPLIANT, ResponseCodes.RESPONSE_FAILED);
//Check presence of service to be deleted
LOG.debug("service common-id '{}' is compliant", commonId);
-//TODO check if an expected bug was justifying this NPE handling
-// try {
Optional<org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.temp.service.list.Services>
service =
this.serviceDataStoreOperations.getTempService(commonId);
-// } catch (NullPointerException e) {
-// LOG.info("failed to get service '{}' from datastore : ", commonId, e);
-// return ModelMappingUtils.createDeleteServiceReply(
-// input, ResponseCodes.FINAL_ACK_YES,
-// LogMessages.serviceNotInDS(CommonId), ResponseCodes.RESPONSE_FAILED);
-// }
if (!service.isPresent()) {
- LOG.error("tempServiceDelete: {}", LogMessages.serviceNotInDS(commonId));
+ LOG.error(TEMP_SERVICE_DELETE_MSG, LogMessages.serviceNotInDS(commonId));
return ModelMappingUtils.createDeleteServiceReply(
input, ResponseCodes.FINAL_ACK_YES,
LogMessages.serviceNotInDS(commonId), ResponseCodes.RESPONSE_FAILED);
org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev200520.ServiceDeleteOutput output =
this.rendererServiceWrapper.performRenderer(input, ServiceNotificationTypes.ServiceDeleteResult);
if (output == null) {
- LOG.error("tempServiceDelete: {}", LogMessages.RENDERER_DELETE_FAILED);
+ LOG.error(TEMP_SERVICE_DELETE_MSG, LogMessages.RENDERER_DELETE_FAILED);
return ModelMappingUtils.createDeleteServiceReply(
input, ResponseCodes.FINAL_ACK_YES,
LogMessages.RENDERER_DELETE_FAILED, ResponseCodes.RESPONSE_FAILED);
OperationResult validationResult = ServiceCreateValidation.validateServiceCreateRequest(
new ServiceInput(input), RpcActions.TempServiceCreate);
if (! validationResult.isSuccess()) {
- LOG.warn("tempServiceCreate: {}", LogMessages.ABORT_VALID_FAILED);
+ LOG.warn(TEMP_SERVICE_CREATE_MSG, LogMessages.ABORT_VALID_FAILED);
return ModelMappingUtils.createCreateServiceReply(
input, ResponseCodes.FINAL_ACK_YES,
validationResult.getResultMessage(), ResponseCodes.RESPONSE_FAILED);
}
// Starting service create operation
- LOG.debug("tempServiceCreate: {}", LogMessages.PCE_CALLING);
+ LOG.debug(TEMP_SERVICE_CREATE_MSG, LogMessages.PCE_CALLING);
this.pceListenerImpl.setInput(new ServiceInput(input));
this.pceListenerImpl.setServiceReconfigure(false);
this.pceListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
this.rendererListenerImpl.setTempService(true);
PathComputationRequestOutput output = this.pceServiceWrapper.performPCE(input, true);
if (output == null) {
- LOG.warn("tempServiceCreate: {}", LogMessages.ABORT_PCE_FAILED);
+ LOG.warn(TEMP_SERVICE_CREATE_MSG, LogMessages.ABORT_PCE_FAILED);
return ModelMappingUtils.createCreateServiceReply(
input, ResponseCodes.FINAL_ACK_YES,
LogMessages.PCE_FAILED, ResponseCodes.RESPONSE_FAILED);
public void onServicePathRpcResult(ServicePathRpcResult notification) {
if (!compareServicePathRpcResult(notification)) {
servicePathRpcResult = notification;
- PathDescription pathDescription = null;
switch (servicePathRpcResult.getNotificationType().getIntValue()) {
/* path-computation-request. */
case 1:
- LOG.info("PCE '{}' Notification received : {}",servicePathRpcResult.getNotificationType().getName(),
- notification);
- if (servicePathRpcResult.getStatus() == RpcStatusEx.Successful) {
- LOG.info("PCE calculation done OK !");
- if (servicePathRpcResult.getPathDescription() != null) {
- pathDescription = new PathDescriptionBuilder()
- .setAToZDirection(servicePathRpcResult.getPathDescription().getAToZDirection())
- .setZToADirection(servicePathRpcResult.getPathDescription().getZToADirection()).build();
- LOG.info("PathDescription gets : {}", pathDescription);
- if (!serviceFeasiblity) {
- if (input == null) {
- LOG.error("Input is null !");
- return;
- }
- OperationResult operationResult = null;
- if (tempService) {
- operationResult = this.serviceDataStoreOperations
- .createTempService(input.getTempServiceCreateInput());
- if (!operationResult.isSuccess()) {
- LOG.error("Temp Service not created in datastore !");
- }
- } else {
- operationResult = this.serviceDataStoreOperations
- .createService(input.getServiceCreateInput());
- if (!operationResult.isSuccess()) {
- LOG.error("Service not created in datastore !");
- }
- }
- ResponseParameters responseParameters = new ResponseParametersBuilder()
- .setPathDescription(new org.opendaylight.yang.gen.v1.http.org
- .transportpce.b.c._interface.service.types.rev200128
- .response.parameters.sp.response.parameters
- .PathDescriptionBuilder(pathDescription).build())
- .build();
- PathComputationRequestOutput pceResponse = new PathComputationRequestOutputBuilder()
- .setResponseParameters(responseParameters).build();
- OperationResult operationServicePathSaveResult =
- this.serviceDataStoreOperations.createServicePath(input, pceResponse);
- if (!operationServicePathSaveResult.isSuccess()) {
- LOG.error("Service Path not created in datastore !");
- }
- ServiceImplementationRequestInput serviceImplementationRequest =
- ModelMappingUtils.createServiceImplementationRequest(input, pathDescription);
- LOG.info("Sending serviceImplementation request : {}", serviceImplementationRequest);
- this.rendererServiceOperations.serviceImplementation(serviceImplementationRequest);
- } else {
- LOG.warn("service-feasibility-check RPC ");
- }
- } else {
- LOG.error("'PathDescription' parameter is null ");
- return;
- }
- } else if (servicePathRpcResult.getStatus() == RpcStatusEx.Failed) {
- LOG.error("PCE path computation failed !");
- return;
- }
+ onPathComputationResult(notification);
break;
/* cancel-resource-reserve. */
case 2:
- if (servicePathRpcResult.getStatus() == RpcStatusEx.Successful) {
- LOG.info("PCE cancel resource done OK !");
- OperationResult deleteServicePathOperationResult =
- this.serviceDataStoreOperations.deleteServicePath(input.getServiceName());
- if (!deleteServicePathOperationResult.isSuccess()) {
- LOG.warn("Service path was not removed from datastore!");
- }
- OperationResult deleteServiceOperationResult = null;
+ onCancelResourceResult();
+ break;
+ default:
+ break;
+ }
+ } else {
+ LOG.warn("ServicePathRpcResult already wired !");
+ }
+ }
+
+ /**
+ * Process path computation request result.
+ * @param notification the result notification.
+ */
+ private void onPathComputationResult(ServicePathRpcResult notification) {
+ LOG.info("PCE '{}' Notification received : {}",servicePathRpcResult.getNotificationType().getName(),
+ notification);
+ if (servicePathRpcResult.getStatus() == RpcStatusEx.Successful) {
+ LOG.info("PCE calculation done OK !");
+ if (servicePathRpcResult.getPathDescription() != null) {
+ PathDescription pathDescription = new PathDescriptionBuilder()
+ .setAToZDirection(servicePathRpcResult.getPathDescription().getAToZDirection())
+ .setZToADirection(servicePathRpcResult.getPathDescription().getZToADirection()).build();
+ LOG.info("PathDescription gets : {}", pathDescription);
+ if (!serviceFeasiblity) {
+ if (input == null) {
+ LOG.error("Input is null !");
+ } else {
+ OperationResult operationResult = null;
if (tempService) {
- deleteServiceOperationResult =
- this.serviceDataStoreOperations.deleteTempService(input.getServiceName());
- if (!deleteServiceOperationResult.isSuccess()) {
- LOG.warn("Service was not removed from datastore!");
+ operationResult = this.serviceDataStoreOperations
+ .createTempService(input.getTempServiceCreateInput());
+ if (!operationResult.isSuccess()) {
+ LOG.error("Temp Service not created in datastore !");
}
} else {
- deleteServiceOperationResult =
- this.serviceDataStoreOperations.deleteService(input.getServiceName());
- if (!deleteServiceOperationResult.isSuccess()) {
- LOG.warn("Service was not removed from datastore!");
+ operationResult = this.serviceDataStoreOperations
+ .createService(input.getServiceCreateInput());
+ if (!operationResult.isSuccess()) {
+ LOG.error("Service not created in datastore !");
}
}
- /**
- * if it was an RPC serviceReconfigure, re-launch PCR.
- */
- if (this.serviceReconfigure) {
- LOG.info("cancel resource reserve done, relaunching PCE path computation ...");
- this.pceServiceWrapper.performPCE(input.getServiceCreateInput(), true);
- this.serviceReconfigure = false;
+ ResponseParameters responseParameters = new ResponseParametersBuilder()
+ .setPathDescription(new org.opendaylight.yang.gen.v1.http.org
+ .transportpce.b.c._interface.service.types.rev200128
+ .response.parameters.sp.response.parameters
+ .PathDescriptionBuilder(pathDescription).build())
+ .build();
+ PathComputationRequestOutput pceResponse = new PathComputationRequestOutputBuilder()
+ .setResponseParameters(responseParameters).build();
+ OperationResult operationServicePathSaveResult = this.serviceDataStoreOperations
+ .createServicePath(input, pceResponse);
+ if (!operationServicePathSaveResult.isSuccess()) {
+ LOG.error("Service Path not created in datastore !");
}
- } else if (servicePathRpcResult.getStatus() == RpcStatusEx.Failed) {
- LOG.info("PCE cancel resource failed !");
+ ServiceImplementationRequestInput serviceImplementationRequest = ModelMappingUtils
+ .createServiceImplementationRequest(input, pathDescription);
+ LOG.info("Sending serviceImplementation request : {}", serviceImplementationRequest);
+ this.rendererServiceOperations.serviceImplementation(serviceImplementationRequest);
}
- break;
- default:
- break;
+ } else {
+ LOG.warn("service-feasibility-check RPC ");
+ }
+ } else {
+ LOG.error("'PathDescription' parameter is null ");
}
- } else {
- LOG.warn("ServicePathRpcResult already wired !");
+ } else if (servicePathRpcResult.getStatus() == RpcStatusEx.Failed) {
+ LOG.error("PCE path computation failed !");
+ }
+ }
+
+ /**
+ * Process cancel resource result.
+ */
+ private void onCancelResourceResult() {
+ if (servicePathRpcResult.getStatus() == RpcStatusEx.Successful) {
+ LOG.info("PCE cancel resource done OK !");
+ OperationResult deleteServicePathOperationResult =
+ this.serviceDataStoreOperations.deleteServicePath(input.getServiceName());
+ if (!deleteServicePathOperationResult.isSuccess()) {
+ LOG.warn("Service path was not removed from datastore!");
+ }
+ OperationResult deleteServiceOperationResult = null;
+ if (tempService) {
+ deleteServiceOperationResult =
+ this.serviceDataStoreOperations.deleteTempService(input.getServiceName());
+ if (!deleteServiceOperationResult.isSuccess()) {
+ LOG.warn("Service was not removed from datastore!");
+ }
+ } else {
+ deleteServiceOperationResult =
+ this.serviceDataStoreOperations.deleteService(input.getServiceName());
+ if (!deleteServiceOperationResult.isSuccess()) {
+ LOG.warn("Service was not removed from datastore!");
+ }
+ }
+ /**
+ * if it was an RPC serviceReconfigure, re-launch PCR.
+ */
+ if (this.serviceReconfigure) {
+ LOG.info("cancel resource reserve done, relaunching PCE path computation ...");
+ this.pceServiceWrapper.performPCE(input.getServiceCreateInput(), true);
+ this.serviceReconfigure = false;
+ }
+ } else if (servicePathRpcResult.getStatus() == RpcStatusEx.Failed) {
+ LOG.info("PCE cancel resource failed !");
}
}
switch (notifType) {
/* service-implementation-request. */
case 3 :
- if (serviceRpcResultSp.getStatus() == RpcStatusEx.Successful) {
- LOG.info("Service implemented !");
- if (serviceDataStoreOperations == null) {
- return;
- }
- OperationResult operationResult = null;
- if (tempService) {
- operationResult = this.serviceDataStoreOperations.modifyTempService(
- serviceRpcResultSp.getServiceName(),
- State.InService, AdminStates.InService);
- if (!operationResult.isSuccess()) {
- LOG.warn("Temp Service status not updated in datastore !");
- }
- } else {
- operationResult = this.serviceDataStoreOperations.modifyService(
- serviceRpcResultSp.getServiceName(),
- State.InService, AdminStates.InService);
- if (!operationResult.isSuccess()) {
- LOG.warn("Service status not updated in datastore !");
- }
- }
- } else if (serviceRpcResultSp.getStatus() == RpcStatusEx.Failed) {
- LOG.error("Renderer implementation failed !");
- OperationResult deleteServicePathOperationResult =
- this.serviceDataStoreOperations.deleteServicePath(serviceName);
- if (!deleteServicePathOperationResult.isSuccess()) {
- LOG.warn("Service path was not removed from datastore!");
- }
- if (tempService) {
- OperationResult deleteServiceOperationResult =
- this.serviceDataStoreOperations.deleteTempService(serviceName);
- if (!deleteServiceOperationResult.isSuccess()) {
- LOG.warn("Temp Service was not removed from datastore!");
- }
- } else {
- OperationResult deleteServiceOperationResult =
- this.serviceDataStoreOperations.deleteService(serviceName);
- if (!deleteServiceOperationResult.isSuccess()) {
- LOG.warn("Service was not removed from datastore!");
- }
- }
- }
+ onServiceImplementationResult(serviceName);
break;
/* service-delete. */
case 4 :
- if (serviceRpcResultSp.getStatus() == RpcStatusEx.Successful) {
- LOG.info("Service '{}' deleted !", serviceName);
- if (this.input != null) {
- LOG.info("sending PCE cancel resource reserve for '{}'", this.input.getServiceName());
- this.pceServiceWrapper.cancelPCEResource(this.input.getServiceName(),
- ServiceNotificationTypes.ServiceDeleteResult);
- } else {
- LOG.error("ServiceInput parameter is null !");
- }
- } else if (serviceRpcResultSp.getStatus() == RpcStatusEx.Failed) {
- LOG.error("Renderer service delete failed !");
- return;
- }
+ onServiceDeleteResult(serviceName);
break;
default:
break;
}
}
+ /**
+ * Process service delete result for serviceName.
+ * @param serviceName String
+ */
+ private void onServiceDeleteResult(String serviceName) {
+ if (serviceRpcResultSp.getStatus() == RpcStatusEx.Successful) {
+ LOG.info("Service '{}' deleted !", serviceName);
+ if (this.input != null) {
+ LOG.info("sending PCE cancel resource reserve for '{}'", this.input.getServiceName());
+ this.pceServiceWrapper.cancelPCEResource(this.input.getServiceName(),
+ ServiceNotificationTypes.ServiceDeleteResult);
+ } else {
+ LOG.error("ServiceInput parameter is null !");
+ }
+ } else if (serviceRpcResultSp.getStatus() == RpcStatusEx.Failed) {
+ LOG.error("Renderer service delete failed !");
+ }
+ }
+
+ /**
+ * Process service implementation result for serviceName.
+ * @param serviceName String
+ * @param serviceName String
+ */
+ private void onServiceImplementationResult(String serviceName) {
+ if (serviceRpcResultSp.getStatus() == RpcStatusEx.Successful) {
+ onSuccededServiceImplementation();
+ } else if (serviceRpcResultSp.getStatus() == RpcStatusEx.Failed) {
+ onFailedServiceImplementation(serviceName);
+ }
+ }
+
+ /**
+ * Process succeeded service implementation for service.
+ */
+ private void onSuccededServiceImplementation() {
+ LOG.info("Service implemented !");
+ if (serviceDataStoreOperations != null) {
+ OperationResult operationResult = null;
+ if (tempService) {
+ operationResult = this.serviceDataStoreOperations.modifyTempService(
+ serviceRpcResultSp.getServiceName(), State.InService, AdminStates.InService);
+ if (!operationResult.isSuccess()) {
+ LOG.warn("Temp Service status not updated in datastore !");
+ }
+ } else {
+ operationResult = this.serviceDataStoreOperations
+ .modifyService(serviceRpcResultSp.getServiceName(),
+ State.InService, AdminStates.InService);
+ if (!operationResult.isSuccess()) {
+ LOG.warn("Service status not updated in datastore !");
+ }
+ }
+ }
+ }
+
+ /**
+ * Process failed service implementation for serviceName.
+ * @param serviceName String
+ */
+ private void onFailedServiceImplementation(String serviceName) {
+ LOG.error("Renderer implementation failed !");
+ OperationResult deleteServicePathOperationResult =
+ this.serviceDataStoreOperations.deleteServicePath(serviceName);
+ if (!deleteServicePathOperationResult.isSuccess()) {
+ LOG.warn("Service path was not removed from datastore!");
+ }
+ if (tempService) {
+ OperationResult deleteServiceOperationResult =
+ this.serviceDataStoreOperations.deleteTempService(serviceName);
+ if (!deleteServiceOperationResult.isSuccess()) {
+ LOG.warn("Temp Service was not removed from datastore!");
+ }
+ } else {
+ OperationResult deleteServiceOperationResult =
+ this.serviceDataStoreOperations.deleteService(serviceName);
+ if (!deleteServiceOperationResult.isSuccess()) {
+ LOG.warn("Service was not removed from datastore!");
+ }
+ }
+ }
+
@SuppressFBWarnings(
value = "ES_COMPARING_STRINGS_WITH_EQ",
justification = "false positives, not strings but real object references comparisons")
public class PCEServiceWrapper {
+ private static final String NOTIFICATION_OFFER_REJECTED_MSG = "notification offer rejected : ";
+
+ private static final String PERFORMING_PCE_MSG = "performing PCE ...";
+
private static final Logger LOG = LoggerFactory.getLogger(PCEServiceWrapper.class);
private final PathComputationService pathComputationService;
}
public PathComputationRequestOutput performPCE(ServiceCreateInput serviceCreateInput, boolean reserveResource) {
- LOG.info("performing PCE ...");
+ LOG.info(PERFORMING_PCE_MSG);
if (validateParams(serviceCreateInput.getServiceName(), serviceCreateInput.getSdncRequestHeader())) {
return performPCE(serviceCreateInput.getHardConstraints(), serviceCreateInput.getSoftConstraints(),
serviceCreateInput.getServiceName(), serviceCreateInput.getSdncRequestHeader(),
public PathComputationRequestOutput performPCE(TempServiceCreateInput tempServiceCreateInput,
boolean reserveResource) {
- LOG.info("performing PCE ...");
+ LOG.info(PERFORMING_PCE_MSG);
if (validateParams(tempServiceCreateInput.getCommonId(), tempServiceCreateInput.getSdncRequestHeader())) {
return performPCE(tempServiceCreateInput.getHardConstraints(), tempServiceCreateInput.getSoftConstraints(),
tempServiceCreateInput.getCommonId(), tempServiceCreateInput.getSdncRequestHeader(),
public PathComputationRequestOutput performPCE(ServiceFeasibilityCheckInput serviceFeasibilityCheckInput,
boolean reserveResource) {
- LOG.info("performing PCE ...");
+ LOG.info(PERFORMING_PCE_MSG);
if (validateParams(serviceFeasibilityCheckInput.getCommonId(),
serviceFeasibilityCheckInput.getSdncRequestHeader())) {
return performPCE(serviceFeasibilityCheckInput.getHardConstraints(),
try {
notificationPublishService.putNotification(notification);
} catch (InterruptedException e) {
- LOG.info("notification offer rejected : ", e);
+ LOG.info(NOTIFICATION_OFFER_REJECTED_MSG, e);
}
- FutureCallback<PathComputationRequestOutput> pceCallback = new FutureCallback<PathComputationRequestOutput>() {
- String message = "";
- ServiceRpcResultSh notification = null;
-
- @Override
- public void onSuccess(PathComputationRequestOutput response) {
- if (response != null) {
- /**
- * If PCE reply is received before timer expiration with a positive result, a
- * service is created with admin and operational status 'down'.
- */
- message = "PCE replied to PCR Request !";
- LOG.info("PCE replied to PCR Request : {}", response);
- notification = new ServiceRpcResultShBuilder().setNotificationType(notifType)
- .setServiceName(serviceName)
- .setStatus(RpcStatusEx.Successful).setStatusMessage(message).build();
- try {
- notificationPublishService.putNotification(notification);
- } catch (InterruptedException e) {
- LOG.info("notification offer rejected : ", e);
- }
- } else {
- message = "PCE failed ";
- notification = new ServiceRpcResultShBuilder().setNotificationType(notifType).setServiceName("")
- .setStatus(RpcStatusEx.Failed).setStatusMessage(message).build();
- try {
- notificationPublishService.putNotification(notification);
- } catch (InterruptedException e) {
- LOG.info("notification offer rejected : ", e);
- }
- }
- }
-
- @Override
- public void onFailure(Throwable arg0) {
- LOG.error("Path not calculated..");
- notification = new ServiceRpcResultShBuilder().setNotificationType(notifType)
- .setServiceName(serviceName)
- .setStatus(RpcStatusEx.Failed).setStatusMessage("PCR Request failed : " + arg0.getMessage())
- .build();
- try {
- notificationPublishService.putNotification(notification);
- } catch (InterruptedException e) {
- LOG.info("notification offer rejected : ", e);
- }
- }
- };
+ FutureCallback<PathComputationRequestOutput> pceCallback =
+ new PathComputationRequestOutputCallback(notifType, serviceName);
PathComputationRequestInput pathComputationRequestInput = createPceRequestInput(serviceName, sdncRequestHeader,
mappingConstraints.getServicePathHardConstraints(), mappingConstraints.getServicePathSoftConstraints(),
reserveResource, serviceAEnd, serviceZEnd);
try {
notificationPublishService.putNotification(notification);
} catch (InterruptedException e) {
- LOG.info("notification offer rejected : ", e);
+ LOG.info(NOTIFICATION_OFFER_REJECTED_MSG, e);
}
- FutureCallback<CancelResourceReserveOutput> pceCallback = new FutureCallback<CancelResourceReserveOutput>() {
-
- String message = "";
- ServiceRpcResultSh notification = null;
-
- @Override
- public void onSuccess(CancelResourceReserveOutput response) {
- if (response != null) {
- /**
- * If PCE reply is received before timer expiration with a positive result, a
- * service is created with admin and operational status 'down'.
- */
- message = "PCE replied to CRR Request !";
- LOG.info("PCE replied to CRR Request : {}", response);
- notification =
- new ServiceRpcResultShBuilder().setNotificationType(notifType).setServiceName(serviceName)
- .setStatus(RpcStatusEx.Successful).setStatusMessage(message).build();
- try {
- notificationPublishService.putNotification(notification);
- } catch (InterruptedException e) {
- LOG.info("notification offer rejected : ", e);
- }
- } else {
- message = "PCE failed ";
- notification = new ServiceRpcResultShBuilder().setNotificationType(notifType).setServiceName("")
- .setStatus(RpcStatusEx.Failed).setStatusMessage(message).build();
- try {
- notificationPublishService.putNotification(notification);
- } catch (InterruptedException e) {
- LOG.info("notification offer rejected : ", e);
- }
- }
- }
-
- @Override
- public void onFailure(Throwable arg0) {
- LOG.error("Cancel resource failed !");
- notification = new ServiceRpcResultShBuilder().setNotificationType(notifType)
- .setServiceName(serviceName).setStatus(RpcStatusEx.Failed)
- .setStatusMessage("CRR Request failed : " + arg0.getMessage()).build();
- try {
- notificationPublishService.putNotification(notification);
- } catch (InterruptedException e) {
- LOG.info("notification offer rejected : ", e);
- }
- }
- };
+ FutureCallback<CancelResourceReserveOutput> pceCallback =
+ new CancelResourceReserveOutputFutureCallback(notifType, serviceName);
CancelResourceReserveInput cancelResourceReserveInput = mappingCancelResourceReserve(serviceName, null);
ConfigurationResponseCommonBuilder configurationResponseCommon = new ConfigurationResponseCommonBuilder();
if (cancelResourceReserveInput != null) {
private static boolean checkString(String value) {
return ((value != null) && (value.compareTo("") != 0));
}
+
+ private final class CancelResourceReserveOutputFutureCallback
+ implements FutureCallback<CancelResourceReserveOutput> {
+ private final ServiceNotificationTypes notifType;
+ private final String serviceName;
+ String message = "";
+ ServiceRpcResultSh notification = null;
+
+ private CancelResourceReserveOutputFutureCallback(ServiceNotificationTypes notifType, String serviceName) {
+ this.notifType = notifType;
+ this.serviceName = serviceName;
+ }
+
+ @Override
+ public void onSuccess(CancelResourceReserveOutput response) {
+ if (response != null) {
+ /**
+ * If PCE reply is received before timer expiration with a positive result, a
+ * service is created with admin and operational status 'down'.
+ */
+ message = "PCE replied to CRR Request !";
+ LOG.info("PCE replied to CRR Request : {}", response);
+ notification =
+ new ServiceRpcResultShBuilder().setNotificationType(notifType).setServiceName(serviceName)
+ .setStatus(RpcStatusEx.Successful).setStatusMessage(message).build();
+ try {
+ notificationPublishService.putNotification(notification);
+ } catch (InterruptedException e) {
+ LOG.info(NOTIFICATION_OFFER_REJECTED_MSG, e);
+ }
+ } else {
+ message = "PCE failed ";
+ notification = new ServiceRpcResultShBuilder().setNotificationType(notifType).setServiceName("")
+ .setStatus(RpcStatusEx.Failed).setStatusMessage(message).build();
+ try {
+ notificationPublishService.putNotification(notification);
+ } catch (InterruptedException e) {
+ LOG.info(NOTIFICATION_OFFER_REJECTED_MSG, e);
+ }
+ }
+ }
+
+ @Override
+ public void onFailure(Throwable arg0) {
+ LOG.error("Cancel resource failed !");
+ notification = new ServiceRpcResultShBuilder().setNotificationType(notifType)
+ .setServiceName(serviceName).setStatus(RpcStatusEx.Failed)
+ .setStatusMessage("CRR Request failed : " + arg0.getMessage()).build();
+ try {
+ notificationPublishService.putNotification(notification);
+ } catch (InterruptedException e) {
+ LOG.info(NOTIFICATION_OFFER_REJECTED_MSG, e);
+ }
+ }
+ }
+
+ private final class PathComputationRequestOutputCallback implements FutureCallback<PathComputationRequestOutput> {
+ private final ServiceNotificationTypes notifType;
+ private final String serviceName;
+ String message = "";
+ ServiceRpcResultSh notification = null;
+
+ private PathComputationRequestOutputCallback(ServiceNotificationTypes notifType, String serviceName) {
+ this.notifType = notifType;
+ this.serviceName = serviceName;
+ }
+
+ @Override
+ public void onSuccess(PathComputationRequestOutput response) {
+ if (response != null) {
+ /**
+ * If PCE reply is received before timer expiration with a positive result, a
+ * service is created with admin and operational status 'down'.
+ */
+ message = "PCE replied to PCR Request !";
+ LOG.info("PCE replied to PCR Request : {}", response);
+ notification = new ServiceRpcResultShBuilder().setNotificationType(notifType)
+ .setServiceName(serviceName)
+ .setStatus(RpcStatusEx.Successful).setStatusMessage(message).build();
+ try {
+ notificationPublishService.putNotification(notification);
+ } catch (InterruptedException e) {
+ LOG.info(NOTIFICATION_OFFER_REJECTED_MSG, e);
+ }
+ } else {
+ message = "PCE failed ";
+ notification = new ServiceRpcResultShBuilder().setNotificationType(notifType).setServiceName("")
+ .setStatus(RpcStatusEx.Failed).setStatusMessage(message).build();
+ try {
+ notificationPublishService.putNotification(notification);
+ } catch (InterruptedException e) {
+ LOG.info(NOTIFICATION_OFFER_REJECTED_MSG, e);
+ }
+ }
+ }
+
+ @Override
+ public void onFailure(Throwable arg0) {
+ LOG.error("Path not calculated..");
+ notification = new ServiceRpcResultShBuilder().setNotificationType(notifType)
+ .setServiceName(serviceName)
+ .setStatus(RpcStatusEx.Failed).setStatusMessage("PCR Request failed : " + arg0.getMessage())
+ .build();
+ try {
+ notificationPublishService.putNotification(notification);
+ } catch (InterruptedException e) {
+ LOG.info(NOTIFICATION_OFFER_REJECTED_MSG, e);
+ }
+ }
+ }
}
.setStatus(RpcStatusEx.Pending)
.setStatusMessage("Service compliant, submitting temp service delete Request ...").build();
sendNotifications(notification);
- FutureCallback<ServiceDeleteOutput> rendererCallback = new FutureCallback<ServiceDeleteOutput>() {
-
- String message = "";
- ServiceRpcResultSh notification = null;
-
- @Override
- public void onSuccess(ServiceDeleteOutput response) {
- if (response != null) {
- /**
- * If PCE reply is received before timer expiration with a positive result, a
- * service is created with admin and operational status 'down'.
- */
- message = "Renderer replied to service delete Request !";
- LOG.info("Renderer replied to service delete Request : {}", response);
- notification =
- new ServiceRpcResultShBuilder().setNotificationType(notifType).setServiceName(serviceName)
- .setStatus(RpcStatusEx.Successful).setStatusMessage(message).build();
- sendNotifications(notification);
- } else {
- message = "Renderer service delete failed ";
- notification = new ServiceRpcResultShBuilder().setNotificationType(notifType).setServiceName("")
- .setStatus(RpcStatusEx.Failed).setStatusMessage(message).build();
- sendNotifications(notification);
- }
- }
-
- @Override
- public void onFailure(Throwable arg0) {
- LOG.error("Renderer service delete failed !");
- notification = new ServiceRpcResultShBuilder().setNotificationType(notifType)
- .setServiceName(serviceName)
- .setStatus(RpcStatusEx.Failed)
- .setStatusMessage("Renderer service delete request failed : " + arg0.getMessage()).build();
- sendNotifications(notification);
- }
- };
+ FutureCallback<ServiceDeleteOutput> rendererCallback =
+ new ServiceDeleteOutputFutureCallback(notifType, serviceName);
ServiceDeleteInput serviceDeleteInput = createRendererRequestInput(serviceName, serviceHandlerHeader);
ListenableFuture<ServiceDeleteOutput> renderer =
this.rendererServiceOperations.serviceDelete(serviceDeleteInput, service);
private static boolean checkString(String value) {
return ((value != null) && (value.compareTo("") != 0));
}
+
+ private final class ServiceDeleteOutputFutureCallback implements FutureCallback<ServiceDeleteOutput> {
+ private final ServiceNotificationTypes notifType;
+ private final String serviceName;
+ String message = "";
+ ServiceRpcResultSh notification = null;
+
+ private ServiceDeleteOutputFutureCallback(ServiceNotificationTypes notifType, String serviceName) {
+ this.notifType = notifType;
+ this.serviceName = serviceName;
+ }
+
+ @Override
+ public void onSuccess(ServiceDeleteOutput response) {
+ if (response != null) {
+ /**
+ * If PCE reply is received before timer expiration with a positive result, a
+ * service is created with admin and operational status 'down'.
+ */
+ message = "Renderer replied to service delete Request !";
+ LOG.info("Renderer replied to service delete Request : {}", response);
+ notification = new ServiceRpcResultShBuilder().setNotificationType(notifType)
+ .setServiceName(serviceName).setStatus(RpcStatusEx.Successful).setStatusMessage(message)
+ .build();
+ sendNotifications(notification);
+ } else {
+ message = "Renderer service delete failed ";
+ notification = new ServiceRpcResultShBuilder().setNotificationType(notifType).setServiceName("")
+ .setStatus(RpcStatusEx.Failed).setStatusMessage(message).build();
+ sendNotifications(notification);
+ }
+ }
+
+ @Override
+ public void onFailure(Throwable arg0) {
+ LOG.error("Renderer service delete failed !");
+ notification = new ServiceRpcResultShBuilder().setNotificationType(notifType).setServiceName(serviceName)
+ .setStatus(RpcStatusEx.Failed)
+ .setStatusMessage("Renderer service delete request failed : " + arg0.getMessage()).build();
+ sendNotifications(notification);
+ }
+ }
}
public class ServiceDataStoreOperationsImpl implements ServiceDataStoreOperations {
private static final Logger LOG = LoggerFactory.getLogger(ServiceDataStoreOperationsImpl.class);
+ private static final String CREATE_MSG = "create";
+ private static final String DELETING_SERVICE_MSG = "Deleting '{}' Service";
private DataBroker dataBroker;
// This is class is public so that these messages can be accessed from Junit (avoid duplications).
@Override
public OperationResult deleteService(String serviceName) {
- LOG.debug("Deleting '{}' Service", serviceName);
+ LOG.debug(DELETING_SERVICE_MSG, serviceName);
try {
WriteTransaction writeTx = this.dataBroker.newWriteOnlyTransaction();
InstanceIdentifier<Services> iid =
@Override
public OperationResult deleteTempService(String commonId) {
- LOG.debug("Deleting '{}' Service", commonId);
+ LOG.debug(DELETING_SERVICE_MSG, commonId);
try {
WriteTransaction writeTx = this.dataBroker.newWriteOnlyTransaction();
InstanceIdentifier<org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.temp.service.list
writeTx.commit().get(Timeouts.DATASTORE_WRITE, TimeUnit.MILLISECONDS);
return OperationResult.ok(LogMessages.SUCCESSFUL_MESSAGE);
} catch (TimeoutException | InterruptedException | ExecutionException e) {
- LOG.warn("createService : {}", LogMessages.failedTo("create", serviceCreateInput.getServiceName()), e);
- return OperationResult.failed(LogMessages.failedTo("create", serviceCreateInput.getServiceName()));
+ LOG.warn("createService : {}", LogMessages.failedTo(CREATE_MSG, serviceCreateInput.getServiceName()), e);
+ return OperationResult.failed(LogMessages.failedTo(CREATE_MSG, serviceCreateInput.getServiceName()));
}
}
writeTx.commit().get(Timeouts.DATASTORE_WRITE, TimeUnit.MILLISECONDS);
return null;
} catch (InterruptedException | TimeoutException | ExecutionException e) {
- LOG.error("writeOrModifyOrDeleteServiceList : {}", LogMessages.failedTo("create", serviceName), e);
- return LogMessages.failedTo("create", serviceName);
+ LOG.error("writeOrModifyOrDeleteServiceList : {}", LogMessages.failedTo(CREATE_MSG, serviceName), e);
+ return LogMessages.failedTo(CREATE_MSG, serviceName);
}
}
action = "modifyService";
break;
case 1 : /* Delete */
- LOG.debug("Deleting '{}' Service", serviceName);
+ LOG.debug(DELETING_SERVICE_MSG, serviceName);
writeTx.delete(LogicalDatastoreType.OPERATIONAL, iid);
action = "deleteService";
break;
// This is class is public so that these messages can be accessed from Junit (avoid duplications).
public static final class LogMessages {
+ private static final String SERVICE = "Service ";
public static final String TXDIR_NOT_SET;
public static final String TXDIR_PORT_NOT_SET;
public static final String TXDIR_LGX_NOT_SET;
}
public static String endpointTypeNotSet(ServiceEndpointType endpointType) {
- return "Service " + endpointType + " is not set";
+ return SERVICE + endpointType + " is not set";
}
public static String rateNotSet(ServiceEndpointType endpointType) {
- return "Service " + endpointType + " rate is not set";
+ return SERVICE + endpointType + " rate is not set";
}
public static String formatNotSet(ServiceEndpointType endpointType) {
- return "Service " + endpointType + " format is not set";
+ return SERVICE + endpointType + " format is not set";
}
public static String clliNotSet(ServiceEndpointType endpointType) {
- return "Service " + endpointType + " clli is not set";
+ return SERVICE + endpointType + " clli is not set";
}
private LogMessages() {
* @return true if String ok false if not
*/
public static boolean checkString(String value) {
- return ((value != null) && (value.compareTo("") != 0));
+ return (value != null && !value.isEmpty());
}
/**
* port info
* @return true if String ok false if not
*/
+ @SuppressWarnings("java:S1067")
+ //sonar issue Reduce the number of conditional operators (4) used in the expression (maximum allowed 3)
+ //won't be fixed because of functional checks needed
public static boolean checkPort(Port port) {
boolean result = false;
if (port != null) {
String portRack = port.getPortRack();
String portShelf = port.getPortShelf();
- if (checkString(portDeviceName) && checkString(portType) && checkString(portName) && checkString(portRack)
- && checkString(portShelf)) {
- result = true;
- }
+ return checkString(portDeviceName)
+ && checkString(portType)
+ && checkString(portName)
+ && checkString(portRack)
+ && checkString(portShelf);
}
return result;
}
return new ComplianceCheckResult(false, LogMessages.endpointTypeNotSet(endpointType));
}
-//TODO check if an expected bug was justifying this NPE handling
-// try {
+ if (serviceEnd.getServiceRate() == null) {
+ String message = "Something wrong when accessing Service " + endpointType + " rate, format or clli";
+ return new ComplianceCheckResult(false, message);
+ }
Long serviceRate = serviceEnd.getServiceRate().toJava();
ServiceFormat serviceformat = serviceEnd.getServiceFormat();
String clli = serviceEnd.getClli();
-// } catch (NullPointerException e) {
-// String message = "Something wrong when accessing Service " + endpointType + " rate, format or clli";
-// LOG.error("Service TxRx info check: {}",message, e);
-// return new ComplianceCheckResult(false, message);
-// }
-
- if ((serviceRate == null) || (serviceRate <= 0)) {
+ if (serviceRate <= 0) {
return new ComplianceCheckResult(false, LogMessages.rateNotSet(endpointType));
}
if (serviceformat == null) {