- private final ListeningExecutorService executor;
-
- private ServicePathRpcResult servicePathRpcResult = null;
- private ServiceRpcResultSp serviceRpcResultSp = null;
-
- private String notificationUrl = "";
- private RpcActions action;
-
- public ServicehandlerImpl(DataBroker databroker, RpcProviderRegistry rpcRegistry,
- NotificationPublishService notificationPublishService) {
- this.db = databroker;
- this.rpcRegistry = rpcRegistry;
- this.notificationPublishService = notificationPublishService;
- executor = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(5));
- initializeDataTree(db);
- }
-
- @Override
- public Future<RpcResult<ServiceCreateOutput>> serviceCreate(ServiceCreateInput input) {
- LOG.info("RPC service creation received");
- action = RpcActions.ServiceCreate;
- boolean commonId = true;
- boolean coherencyHardSoft = false;
- ServiceRpcResult notification = null;
- notificationUrl = null;// input.getSdncRequestHeader().getnotificationUrl();
- LOG.info("notificationUrl : " + notificationUrl);
-
- ResponseParametersBuilder responseParameters = new ResponseParametersBuilder();
- ConfigurationResponseCommon configurationResponseCommon;
- String message = "";
- String responseCode = "";
-
- LOG.info("checking Service Compliancy ...");
- /*
- * Upon receipt of service
- * -create RPC, service header and sdnc
- * -request header compliancy are verified.
- */
- compliancyCheck = new ServicehandlerCompliancyCheck(input.getSdncRequestHeader(), input.getServiceName(),
- input.getConnectionType(), RpcActions.ServiceCreate);
- if (compliancyCheck.check(true, 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.
- */
- LOG.info("checking Tx/Rx Info for AEnd ...");
- txrxCheck = new ServicehandlerTxRxCheck(input.getServiceAEnd(), 1);
- if (txrxCheck.check()) {
- LOG.info("Tx/Rx Info for AEnd checked !");
- LOG.info("checking Tx/Rx Info for ZEnd ...");
- txrxCheck = new ServicehandlerTxRxCheck(input.getServiceZEnd(), 2);
- if (txrxCheck.check()) {
- LOG.info("Tx/Rx Info for ZEnd checked");
- /*
- * If OK, common-id is verified in order to see if there is
- * no routing policy provided. If yes, the routing
- * constraints of the policy are recovered and coherency
- * with hard/soft constraints provided in the input of the
- * RPC.
- */
- if (input.getCommonId() != null) {
- LOG.info("Common-id specified");
- /*
- * Check coherency with hard/soft constraints
- */
-
- checkCoherencyHardSoft = new CheckCoherencyHardSoft(input.getHardConstraints(),
- input.getSoftConstraints());
- if (checkCoherencyHardSoft.check()) {
- LOG.info("hard/soft constraints coherent !");
- coherencyHardSoft = true;
- } else {
- LOG.info("hard/soft constraints are not coherent !");
- message = "hard/soft constraints are not coherent !";
- responseCode = "500";
- }
- } else {
- commonId = false;
- }
-
- if (!commonId || (commonId && coherencyHardSoft)) {
- /*
- * Before sending the PCE request, input data need to be
- * formatted according to the Service Handler PCE
- * interface data model.
- */
- mappingAndSendingPCRequest = new MappingAndSendingPCRequest(rpcRegistry, input, true);
- /*
- * Once PCE request is being sent to the PCE on
- * interface B, PCE reply is expected until a timer
- * expires.
- */
- notification = new ServiceRpcResultBuilder()
- .setNotificationType(ServiceNotificationTypes.ServiceCreateResult)
- .setServiceName(input.getServiceName()).setStatus(RpcStatusEx.Pending)
- .setStatusMessage("Service compliant, submitting PathComputation Request ...").build();
- try {
- notificationPublishService.putNotification(notification);
- } catch (InterruptedException e) {
- LOG.info("notification offer rejected : " + e);
- }
- sendNotifToUrl(notification, notificationUrl);
- FutureCallback<PathComputationRequestOutput> pceCallback =
- new FutureCallback<PathComputationRequestOutput>() {
- String message = "";
- String responseCode = "";
- ServiceRpcResult notification = null;
-
- @Override
- public void onSuccess(PathComputationRequestOutput response) {
- if (mappingAndSendingPCRequest.getSuccess() && response != null) {
- /*
- * If PCE reply is received before timer
- * expiration with a positive result, a
- * service is created with admin and
- * operational status 'down'.
- */
- LOG.info("PCE replied to PCR Request !");
-
- message = response.getConfigurationResponseCommon().getResponseMessage();
- notification = new ServiceRpcResultBuilder()
- .setNotificationType(ServiceNotificationTypes.ServiceCreateResult)
- .setServiceName(input.getServiceName()).setStatus(RpcStatusEx.Pending)
- .setStatusMessage("PCE replied to PCR Request !").build();
- try {
- notificationPublishService.putNotification(notification);
- } catch (InterruptedException e) {
- LOG.info("notification offer rejected : " + e);
- }
- sendNotifToUrl(notification, notificationUrl);
- String result = null;
- if ((result = writeOrModifyOrDeleteServiceList(input.getServiceName(), input,
- response, 2)) != null) {
- StringBuilder build = new StringBuilder();
- build.append(message);
- build.append(" " + result);
- message = build.toString();
- } else {
- /*
- * Send Implementation order to renderer
- */
- mappingAndSendingSIRequest = new MappingAndSendingSIRequest(rpcRegistry, input,
- response);
-
- notification = new ServiceRpcResultBuilder()
- .setNotificationType(ServiceNotificationTypes.ServiceCreateResult)
- .setServiceName(input.getServiceName()).setStatus(RpcStatusEx.Pending)
- .setStatusMessage("Submitting ServiceImplementation Request ...")
- .build();
- try {
- notificationPublishService.putNotification(notification);
- } catch (InterruptedException e) {
- LOG.info("notification offer rejected : " + e);
- }
- sendNotifToUrl(notification, notificationUrl);
-
- /*
- * Once PCE request is being sent to the
- * PCE on interface B, PCE reply is
- * expected until a timer expires.
- */
- ServiceImplementationRequestOutput siOutput = null;
- try {
- siOutput = mappingAndSendingSIRequest.serviceImplementation().get();
- } catch (InterruptedException | ExecutionException e2) {
- LOG.error("mappingAndSendingSIRequest.serviceImplementation().get() : "
- + e2.getMessage());
- }
- if (siOutput == null) {
- LOG.info("siOutput is null ");
- LOG.info("Success : " + mappingAndSendingPCRequest.getSuccess());
- }
- if (mappingAndSendingSIRequest.getSuccess() && siOutput != null) {
- ConfigurationResponseCommon siCommon = siOutput
- .getConfigurationResponseCommon();
- // message =
- // siCommon.getResponseMessage();
- responseCode = siCommon.getResponseCode();
- message = "Service implemented !";
- LOG.info(message);
- notification = new ServiceRpcResultBuilder()
- .setNotificationType(ServiceNotificationTypes.ServiceCreateResult)
- .setServiceName(input.getServiceName())
- .setStatus(RpcStatusEx.Successful).setStatusMessage(message)
- .build();
- try {
- notificationPublishService.putNotification(notification);
- } catch (InterruptedException e) {
- LOG.info("notification offer rejected : " + e);
- }
- sendNotifToUrl(notification, notificationUrl);
- /*
- * Service implemented setting
- * Service op status to up
- */
- if (writeOrModifyOrDeleteServiceList(input.getServiceName(), null, null,
- 0) == null) {
- /*
- * Service modified.
- */
- StringBuilder build = new StringBuilder();
- build.append(message);
- build.append(" : Service Op Status changed to Up !");
- message = build.toString();
- } else {
- StringBuilder build = new StringBuilder();
- build.append(message);
- build.append(" but Failed to modify service from Service List !");
- message = build.toString();
- }
- notification = new ServiceRpcResultBuilder()
- .setNotificationType(ServiceNotificationTypes.ServiceCreateResult)
- .setServiceName(input.getServiceName())
- .setStatus(RpcStatusEx.Successful).setStatusMessage(message)
- .build();
- try {
- notificationPublishService.putNotification(notification);
- } catch (InterruptedException e) {
- LOG.info("notification offer rejected : " + e);
- }
- sendNotifToUrl(notification, notificationUrl);
- } else {
- LOG.info("Service not implemented !");
- message = response.getConfigurationResponseCommon().getResponseMessage();
- notification = new ServiceRpcResultBuilder()
- .setNotificationType(ServiceNotificationTypes.ServiceCreateResult)
- .setServiceName(input.getServiceName())
- .setStatus(RpcStatusEx.Failed)
- .setStatusMessage(
- "Service not implemented, cancelling ResourceResv ...")
- .build();
- try {
- notificationPublishService.putNotification(notification);
- } catch (InterruptedException e) {
- LOG.info("notification offer rejected : " + e);
- }
- sendNotifToUrl(notification, notificationUrl);
- mappingAndSendingPCRequest = new MappingAndSendingPCRequest(rpcRegistry,
- input, false);
- /*
- * Send Cancel resource Request to
- * PCE.
- */
- CancelResourceReserveOutput cancelOuptut = null;
- try {
- cancelOuptut = mappingAndSendingPCRequest.cancelResourceReserve().get();
- } catch (InterruptedException | ExecutionException e1) {
- LOG.error(e1.getMessage());
- }
- if (mappingAndSendingPCRequest.getSuccess() && cancelOuptut != null) {
- LOG.info("Service ResourceResv cancelled !");
- message = response.getConfigurationResponseCommon()
- .getResponseMessage();
- notification = new ServiceRpcResultBuilder()
- .setNotificationType(
- ServiceNotificationTypes.ServiceCreateResult)
- .setServiceName(input.getServiceName())
- .setStatus(RpcStatusEx.Failed)
- .setStatusMessage("Service ResourceResv cancelled").build();
- try {
- notificationPublishService.putNotification(notification);
- } catch (InterruptedException e) {
- LOG.info("notification offer rejected : " + e);
- }
- sendNotifToUrl(notification, notificationUrl);
-
- message = cancelOuptut.getConfigurationResponseCommon()
- .getResponseMessage();
- responseCode = cancelOuptut.getConfigurationResponseCommon()
- .getResponseCode();
-
- StringBuilder build = new StringBuilder();
- build.append("Service not implemented - ");
- build.append(message);
- message = build.toString();
-
- LOG.info("PCE replied to CancelResourceResv Request !");
- } else {
- message = "Cancelling Resource reserved failed ";
- LOG.info(message);
- responseCode = "500";
- StringBuilder build = new StringBuilder();
- build.append("Service not implemented - ");
- build.append(message);
- message = build.toString();
-
- message = response.getConfigurationResponseCommon()
- .getResponseMessage();
- notification = new ServiceRpcResultBuilder()
- .setNotificationType(
- ServiceNotificationTypes.ServiceCreateResult)
- .setServiceName(input.getServiceName())
- .setStatus(RpcStatusEx.Failed)
- .setStatusMessage("Cancelling Resource reserved failed")
- .build();
- try {
- notificationPublishService.putNotification(notification);
- } catch (InterruptedException e) {
- LOG.info("notification offer rejected : " + e);
- }
- sendNotifToUrl(notification, notificationUrl);
- }
-
- }
- }
- } else {
- message = mappingAndSendingPCRequest.getError();// "Path
- // not
- // calculated";
- responseCode = "500";
- notification = new ServiceRpcResultBuilder()
- .setNotificationType(ServiceNotificationTypes.ServiceCreateResult)
- .setServiceName("").setStatus(RpcStatusEx.Failed).setStatusMessage(message)
- .build();
- try {
- notificationPublishService.putNotification(notification);
- } catch (InterruptedException e) {
- LOG.info("notification offer rejected : " + e);
- }
- sendNotifToUrl(notification, notificationUrl);
- }
-
- }
-
- @Override
- public void onFailure(Throwable arg0) {
- LOG.error("Path not calculated..");
- notification = new ServiceRpcResultBuilder()
- .setNotificationType(ServiceNotificationTypes.ServiceCreateResult)
- .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);
- }
- sendNotifToUrl(notification, notificationUrl);
- }
- };
- ListenableFuture<PathComputationRequestOutput> pce = mappingAndSendingPCRequest
- .pathComputationRequest();
- Futures.addCallback(pce, pceCallback);
- LOG.info("PCR Request in progress ");
- configurationResponseCommon = new ConfigurationResponseCommonBuilder()
- .setAckFinalIndicator("No").setRequestId(input.getSdncRequestHeader().getRequestId())
- .setResponseMessage("Service compliant, serviceCreate in progress...")
- .setResponseCode("200").build();
-
- ServiceCreateOutputBuilder output = new ServiceCreateOutputBuilder()
- .setConfigurationResponseCommon(configurationResponseCommon)
- .setResponseParameters(responseParameters.build());
-
- return RpcResultBuilder.success(output.build()).buildFuture();
- }
- } else {
- message = txrxCheck.getMessage();
- responseCode = "500";
- }
- } else {
- message = txrxCheck.getMessage();
- responseCode = "500";
- }
- } else {
- message = compliancyCheck.getMessage();
- responseCode = "500";
- }
-
- configurationResponseCommon = new ConfigurationResponseCommonBuilder().setAckFinalIndicator("Yes")
- .setRequestId(input.getSdncRequestHeader().getRequestId()).setResponseMessage(message)
- .setResponseCode(responseCode).build();
-
- ServiceCreateOutputBuilder output = new ServiceCreateOutputBuilder()
- .setConfigurationResponseCommon(configurationResponseCommon)
- .setResponseParameters(responseParameters.build());
-
- return RpcResultBuilder.success(output.build()).buildFuture();
-
- }
-
- @Override
- public Future<RpcResult<ServiceDeleteOutput>> serviceDelete(ServiceDeleteInput input) {
- LOG.info("RPC serviceDelete request received for Service '" + input.getServiceDeleteReqInfo().getServiceName()
- + "'");
- notificationUrl = null;// input.getSdncRequestHeader().getnotificationUrl();
- String message = "";
- String responseCode = "";
- ServiceRpcResult notification = null;
- ResponseParametersBuilder responseParameters = new ResponseParametersBuilder();
- LOG.info("checking Service Compliancy ...");
- /*
- * Upon receipt of service-delete RPC, service header and sdnc-request
- * header compliancy are verified.
- */
- compliancyCheck = new ServicehandlerCompliancyCheck(input.getSdncRequestHeader(),
- input.getServiceDeleteReqInfo().getServiceName(), RpcActions.ServiceDelete);
- if (compliancyCheck.check(false, true)) {
- LOG.info("Service compliant !");
- String serviceName = input.getServiceDeleteReqInfo().getServiceName();
- Services service = readServiceList(serviceName);
- if (service != null) {
- LOG.debug("Service '" + serviceName + "' present in datastore !");
- /*
- * If compliant, service-delete order is send to renderer.
- */
- mappingAndSendingSIRequest = new MappingAndSendingSIRequest(rpcRegistry,
- input.getSdncRequestHeader().getRequestId(), input.getServiceDeleteReqInfo().getServiceName());
-
- notification = new ServiceRpcResultBuilder()
- .setNotificationType(ServiceNotificationTypes.ServiceDeleteResult).setServiceName(serviceName)
- .setStatus(RpcStatusEx.Pending)
- .setStatusMessage("Service compliant, submitting serviceDelete Request ...").build();
- try {
- notificationPublishService.putNotification(notification);
- } catch (InterruptedException e) {
- LOG.info("notification offer rejected : " + e);
- }
- sendNotifToUrl(notification, notificationUrl);
- FutureCallback<org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce
- .stubrenderer.rev170426.ServiceDeleteOutput> rendererCallback =
- new FutureCallback<org.opendaylight.yang.gen.v1.http.org.opendaylight
- .transportpce.stubrenderer.rev170426.ServiceDeleteOutput>() {
- String message = "";
- String responseCode = "";
- ServiceRpcResult notification = null;
-
- @Override
- public void onFailure(Throwable arg0) {
- LOG.error("ServiceDelete Request failed !");
- notification = new ServiceRpcResultBuilder()
- .setNotificationType(ServiceNotificationTypes.ServiceDeleteResult)
- .setServiceName(serviceName).setStatus(RpcStatusEx.Failed)
- .setStatusMessage("ServiceDelete Request failed !").build();
- try {
- notificationPublishService.putNotification(notification);
- } catch (InterruptedException e) {
- LOG.info("notification offer rejected : " + e);
- }
- sendNotifToUrl(notification, notificationUrl);
- }
-
- @Override
- public void onSuccess(org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce
- .stubrenderer.rev170426.ServiceDeleteOutput arg0) {
-
- if (mappingAndSendingPCRequest.getSuccess() && arg0 != null) {
- message = "Service deleted !";
- LOG.info(message);
- notification = new ServiceRpcResultBuilder()
- .setNotificationType(ServiceNotificationTypes.ServiceDeleteResult)
- .setServiceName(input.getServiceDeleteReqInfo().getServiceName())
- .setStatus(RpcStatusEx.Successful).setStatusMessage("Service deleted !").build();
- try {
- notificationPublishService.putNotification(notification);
- } catch (InterruptedException e) {
- LOG.info("notification offer rejected : " + e);
- }
- sendNotifToUrl(notification, notificationUrl);
-
- // message =
- // result.getConfigurationResponseCommon().getResponseMessage();
- responseCode = arg0.getConfigurationResponseCommon().getResponseCode();
- /*
- * Service delete confirmed deleting service from
- * database
- */
- if (writeOrModifyOrDeleteServiceList(input.getServiceDeleteReqInfo().getServiceName(), null,
- null, 1) == null) {
- /* Service delete. */
- StringBuilder build = new StringBuilder();
- build.append(message);
- build.append(" : Service deleted from database");
- message = build.toString();
- } else {
- StringBuilder build = new StringBuilder();
- build.append(message);
- build.append(" but Failed to delete service from database !");
- message = build.toString();
- }
- LOG.info(message);
- notification = new ServiceRpcResultBuilder()
- .setNotificationType(ServiceNotificationTypes.ServiceDeleteResult)
- .setServiceName(input.getServiceDeleteReqInfo().getServiceName())
- .setStatus(RpcStatusEx.Successful).setStatusMessage(message).build();
- try {
- notificationPublishService.putNotification(notification);
- } catch (InterruptedException e) {
- LOG.info("notification offer rejected : " + e);
- }
- sendNotifToUrl(notification, notificationUrl);
- } else {
- message = "deleting service failed";
- responseCode = "500";
- notification = new ServiceRpcResultBuilder()
- .setNotificationType(ServiceNotificationTypes.ServiceDeleteResult)
- .setServiceName(input.getServiceDeleteReqInfo().getServiceName())
- .setStatus(RpcStatusEx.Failed).setStatusMessage(message).build();
- try {
- notificationPublishService.putNotification(notification);
- } catch (InterruptedException e) {
- LOG.info("notification offer rejected : " + e);
- }
- sendNotifToUrl(notification, notificationUrl);
- }
- }
- };
- ListenableFuture<org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce
- .stubrenderer.rev170426.ServiceDeleteOutput> renderer =
- mappingAndSendingSIRequest.serviceDelete();
- Futures.addCallback(renderer, rendererCallback);
- LOG.info("ServiceDelete Request in progress ... ");
- ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
- .setAckFinalIndicator("No").setRequestId(input.getSdncRequestHeader().getRequestId())
- .setResponseMessage("ServiceDelete Request in progress ...").setResponseCode("200").build();
- ServiceDeleteOutput output = new ServiceDeleteOutputBuilder()
- .setConfigurationResponseCommon(configurationResponseCommon).build();
- return RpcResultBuilder.success(output).buildFuture();
- } else {
- message = "Service '" + serviceName + "' not exists in datastore";
- LOG.error(message);
- }
-
- } else {
- message = "Service not compliant !";
- responseCode = "500";
- }
-
- /*
- * Building output response.
- */
-
- ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
- .setAckFinalIndicator("Yes").setRequestId(input.getSdncRequestHeader().getRequestId())
- .setResponseMessage(message).setResponseCode(responseCode).build();
- ServiceDeleteOutput output = new ServiceDeleteOutputBuilder()
- .setConfigurationResponseCommon(configurationResponseCommon).build();
- return RpcResultBuilder.success(output).buildFuture();
- }
-
- @Override
- public Future<RpcResult<ServiceFeasibilityCheckOutput>> serviceFeasibilityCheck(
- ServiceFeasibilityCheckInput input) {
- notificationUrl = null;// input.getSdncRequestHeader().getnotificationUrl();
- action = RpcActions.ServiceFeasibilityCheck;
- LOG.info("RPC service feasibilityCheck received");
- boolean commonId = true;
- boolean coherencyHardSoft = false;
- ServiceRpcResult notification = null;
- String name = "no name";
- mappingAndSendingPCRequest = null;
-
- ConfigurationResponseCommon configurationResponseCommon = null;
- String message = "";
- String responseCode = "";
- LOG.info("checking Service Compliancy ...");
- /*
- * Upon receipt of service-create RPC, service header and sdnc-request
- * header compliancy are verified.
- */
- compliancyCheck = new ServicehandlerCompliancyCheck(input.getSdncRequestHeader(), name,
- input.getConnectionType(), RpcActions.ServiceFeasibilityCheck);
- if (compliancyCheck.check(true, 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.
- */
- LOG.info("checking Tx/Rx Info for AEnd ...");
- txrxCheck = new ServicehandlerTxRxCheck(input.getServiceAEnd(), 1);
- if (txrxCheck.check()) {
- LOG.info("Tx/Rx Info for AEnd checked !");
- LOG.info("checking Tx/Rx Info for ZEnd ...");
- txrxCheck = new ServicehandlerTxRxCheck(input.getServiceZEnd(), 2);
- if (txrxCheck.check()) {
- LOG.info("Tx/Rx Info for ZEnd checked");
- /*
- * If OK, common-id is verified in order to see if there is
- * no routing policy provided. If yes, the routing
- * constraints of the policy are recovered and coherency
- * with hard/soft constraints provided in the input of the
- * RPC.
- */
- if (input.getCommonId() != null) {
- LOG.info("Common-id specified");
- /*
- * Check coherency with hard/soft constraints
- */
-
- checkCoherencyHardSoft = new CheckCoherencyHardSoft(input.getHardConstraints(),
- input.getSoftConstraints());
- if (checkCoherencyHardSoft.check()) {
- LOG.info("hard/soft constraints coherent !");
- coherencyHardSoft = true;
- } else {
- LOG.info("hard/soft constraints are not coherent !");
- message = "hard/soft constraints are not coherent !";
- responseCode = "500";
- }
- } else {
- commonId = false;
- }
-
- if (!commonId || (commonId && coherencyHardSoft)) {
- /*
- * Before sending the PCE request, input data need to be
- * formatted according to the Service Handler - PCE
- * interface data model.
- */
- mappingAndSendingPCRequest = new MappingAndSendingPCRequest(rpcRegistry, input, false);
- /*
- * Once PCE request is being sent to the PCE on
- * interface B, PCE reply is expected until a timer
- * expires.
- */
- notification = new ServiceRpcResultBuilder()
- .setNotificationType(ServiceNotificationTypes.ServiceCreateResult).setServiceName(name)
- .setStatus(RpcStatusEx.Pending)
- .setStatusMessage("Service compliant, Submitting PathComputation Request ...").build();
- try {
- notificationPublishService.putNotification(notification);
- } catch (InterruptedException e) {
- LOG.info("notification offer rejected : " + e);
- }
- sendNotifToUrl(notification, notificationUrl);
-
- FutureCallback<PathComputationRequestOutput> pceCallback =
- new FutureCallback<PathComputationRequestOutput>() {
- String message = "";
- String responseCode = "";
- ServiceRpcResult notification = null;
-
- @Override
- public void onFailure(Throwable arg0) {
- LOG.error("Path not calculated..");
- notification = new ServiceRpcResultBuilder()
- .setNotificationType(ServiceNotificationTypes.ServiceCreateResult)
- .setServiceName(name).setStatus(RpcStatusEx.Failed)
- .setStatusMessage("PCR Request failed !").build();
- try {
- notificationPublishService.putNotification(notification);
- } catch (InterruptedException e) {
- LOG.info("notification offer rejected : " + e);
- }
- sendNotifToUrl(notification, notificationUrl);
-
- }
-
- @Override
- public void onSuccess(PathComputationRequestOutput response) {
-
- if (mappingAndSendingPCRequest.getSuccess() && response != null) {
- /*
- * If PCE reply is received before timer
- * expiration with a positive result, a
- * service is created with admin and
- * operational status 'down'.
- */
- LOG.info("PCE replied to PCR Request !");
- notification = new ServiceRpcResultBuilder()
- .setNotificationType(ServiceNotificationTypes.ServiceCreateResult)
- .setServiceName("").setStatus(RpcStatusEx.Successful)
- .setStatusMessage("Service Feasility Checked").build();
- try {
- notificationPublishService.putNotification(notification);
- } catch (InterruptedException e) {
- LOG.info("notification offer rejected : " + e);
- }
- message = response.getConfigurationResponseCommon().getResponseMessage();
- sendNotifToUrl(notification, notificationUrl);
- } else {
- message = mappingAndSendingPCRequest.getError();// "Path
- // not
- // calculated";
- responseCode = "500";
- notification = new ServiceRpcResultBuilder()
- .setNotificationType(ServiceNotificationTypes.ServiceCreateResult)
- .setServiceName("").setStatus(RpcStatusEx.Failed).setStatusMessage(message)
- .build();
- try {
- notificationPublishService.putNotification(notification);
- } catch (InterruptedException e) {
- LOG.info("notification offer rejected : " + e);
- }
- sendNotifToUrl(notification, notificationUrl);
- }
- }
-
- };
- ListenableFuture<PathComputationRequestOutput> pce = mappingAndSendingPCRequest
- .pathComputationRequest();
- Futures.addCallback(pce, pceCallback);
- LOG.info("PCR Request in progress ");
- configurationResponseCommon = new ConfigurationResponseCommonBuilder()
- .setAckFinalIndicator("No").setRequestId(input.getSdncRequestHeader().getRequestId())
- .setResponseMessage("Service compliant, ServiceFeasibilityCheck in progress...")
- .setResponseCode("200").build();
-
- ServiceFeasibilityCheckOutput output = new ServiceFeasibilityCheckOutputBuilder()
- .setConfigurationResponseCommon(configurationResponseCommon).build();
-
- return RpcResultBuilder.success(output).buildFuture();
-
- }
- } else {
- message = txrxCheck.getMessage();
- responseCode = "500";
- }
- } else {
- message = txrxCheck.getMessage();
- responseCode = "500";
- }
- } else {
- message = compliancyCheck.getMessage();
- responseCode = "500";
- }
-
- configurationResponseCommon = new ConfigurationResponseCommonBuilder().setAckFinalIndicator("Yes")
- .setRequestId(input.getSdncRequestHeader().getRequestId()).setResponseMessage(message)
- .setResponseCode(responseCode).build();
-
- ResponseParameters responseParameters = new ResponseParametersBuilder()
- .setHardConstraints(input.getHardConstraints())
- // .setPceMetric(input.getPceMetric())
- .setSoftConstraints(input.getSoftConstraints())
- // .setLocallyProtectedLinks(input.isLocallyProtectedLinks())
- .build();
-
- org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev161014.service.feasibility
- .check.output.ServiceAEnd serviceAEnd = new org.opendaylight.yang.gen.v1.http.org.opendaylight
- .transportpce.servicehandler.rev161014.service.feasibility
- .check.output.ServiceAEndBuilder(input.getServiceAEnd()).build();
-
- org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev161014.service.feasibility
- .check.output.ServiceZEnd serviceZEnd = new org.opendaylight.yang.gen.v1.http.org.opendaylight
- .transportpce.servicehandler.rev161014.service.feasibility
- .check.output.ServiceZEndBuilder(input.getServiceZEnd()).build();
-
- /* TxDirection. */
- Port txPort = new PortBuilder().setPortDeviceName("ROUTER_SNJSCAMCJW1_000000.00_00").setPortType("router")
- .setPortName("Gigabit Ethernet_Tx.ge-1/0/0.0").setPortRack("000000.00").setPortShelf("00").build();
- Lgx txLgx = new LgxBuilder().setLgxDeviceName("LGX Panel_SNJSCAMCJW1_000000.00_00")
- .setLgxPortName("LGX_Back.23").setLgxPortRack("000000.00").setLgxPortShelf("00").build();
- TxDirection txDirection = new TxDirectionBuilder().setPort(txPort).setLgx(txLgx).build();
-
- /* RxDirection. */
- Port rxPort = new PortBuilder().setPortDeviceName("ROUTER_SNJSCAMCJW1_000000.00_00").setPortType("router")
- .setPortName("Gigabit Ethernet_Rx.ge-1/0/0.0").setPortRack("000000.00").setPortShelf("00").build();
- Lgx rxLgx = new LgxBuilder().setLgxDeviceName("LGX Panel_SNJSCAMCJW1_000000.00_00").setLgxPortName("LGX_Back.6")
- .setLgxPortRack("000000.00").setLgxPortShelf("00").build();
- RxDirection rxDirection = new RxDirectionBuilder().setPort(rxPort).setLgx(rxLgx).build();
-
- IntermediateSites inter = new IntermediateSitesBuilder().setClli("SNJSCAMCJW1").setServiceRate((long) 100)
- .setServiceFormat(ServiceFormat.Ethernet).setOpticType(OpticTypes.Gray).setTxDirection(txDirection)
- .setRxDirection(rxDirection).build();
-
- List<IntermediateSites> intersites = new ArrayList<IntermediateSites>();
- intersites.add(inter);
- ServiceFeasibilityCheckOutput output = new ServiceFeasibilityCheckOutputBuilder()
- .setIntermediateSites(intersites).setResponseParameters(responseParameters)
- .setConfigurationResponseCommon(configurationResponseCommon).setServiceAEnd(serviceAEnd)
- .setServiceZEnd(serviceZEnd).build();
-
- return RpcResultBuilder.success(output).buildFuture();
- }
-
- @Override
- public Future<RpcResult<ServiceReconfigureOutput>> serviceReconfigure(ServiceReconfigureInput input) {
-
- LOG.info("RPC service reconfigure received");
- notificationUrl = null;// input.getnotificationUrl();
- boolean commonId = true;
- boolean coherencyHardSoft = false;
- ServiceRpcResult notification = null;
-
- String message = "";
- LOG.info("checking Service Compliancy ...");
- /*
- * Upon receipt of service-create RPC, service header and sdnc-request
- * header compliancy are verified.
- */
- compliancyCheck = new ServicehandlerCompliancyCheck(input.getServiceName(), input.getConnectionType(),
- RpcActions.ServiceReconfigure);
- if (compliancyCheck.check(true, false)) {
- 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.
- */
- LOG.info("checking Tx/Rx Info for AEnd ...");
- txrxCheck = new ServicehandlerTxRxCheck(input.getServiceAEnd(), 1);
- if (txrxCheck.check()) {
- LOG.info("Tx/Rx Info for AEnd checked !");
- LOG.info("checking Tx/Rx Info for ZEnd ...");
- txrxCheck = new ServicehandlerTxRxCheck(input.getServiceZEnd(), 2);
- if (txrxCheck.check()) {
- LOG.info("Tx/Rx Info for ZEnd checked");
- /*
- * If OK, common-id is verified in order to see if there is
- * no routing policy provided. If yes, the routing
- * constraints of the policy are recovered and coherency
- * with hard/soft constraints provided in the input of the
- * RPC.
- */
- if (input.getCommonId() != null) {
- LOG.info("Common-id specified");
- /*
- * Check coherency with hard/soft constraints
- */
-
- checkCoherencyHardSoft = new CheckCoherencyHardSoft(input.getHardConstraints(),
- input.getSoftConstraints());
- if (checkCoherencyHardSoft.check()) {
- LOG.info("hard/soft constraints coherent !");
- coherencyHardSoft = true;
- } else {
- LOG.info("hard/soft constraints are not coherent !");
- message = "hard/soft constraints are not coherent !";
- }
- } else {
- commonId = false;
- }
-
- if (!commonId || (commonId && coherencyHardSoft)) {
- /*
- * Retrieving initial service topology.
- */
- String serviceName = input.getServiceName();
- Services service = readServiceList(serviceName);
- if (service != null) {
- LOG.debug("Service '" + serviceName + "' present in datastore !");
- /*
- * Sending cancel resource resv request to PCE
- */
-
- mappingAndSendingPCRequest = new MappingAndSendingPCRequest(rpcRegistry, input, false);
- notification = new ServiceRpcResultBuilder()
- .setNotificationType(ServiceNotificationTypes.ServiceReconfigureResult)
- .setServiceName(input.getServiceName()).setStatus(RpcStatusEx.Pending)
- .setStatusMessage("Cancelling ResourceResv ...").build();
- try {
- notificationPublishService.putNotification(notification);
- } catch (InterruptedException e) {
- LOG.info("notification offer rejected : " + e);
- }
- sendNotifToUrl(notification, notificationUrl);
- FutureCallback<CancelResourceReserveOutput> pceCallback =
- new FutureCallback<CancelResourceReserveOutput>() {
- String message = "";
- String responseCode = "";
- ServiceRpcResult notification = null;
-
- @Override
- public void onFailure(Throwable arg0) {
- LOG.error("Failed to cancel ResourceResv ! ");
- notification = new ServiceRpcResultBuilder()
- .setNotificationType(ServiceNotificationTypes.ServiceCreateResult)
- .setServiceName(serviceName).setStatus(RpcStatusEx.Failed)
- .setStatusMessage("PCR Request failed !").build();
- try {
- notificationPublishService.putNotification(notification);
- } catch (InterruptedException e) {
- LOG.info("notification offer rejected : " + e);
- }
-
- }
-
- @Override
- public void onSuccess(CancelResourceReserveOutput arg0) {
- if (mappingAndSendingPCRequest.getSuccess() && arg0 != null) {
- LOG.info("Service ResourceResv cancelled !");
- notification = new ServiceRpcResultBuilder()
- .setNotificationType(ServiceNotificationTypes.ServiceReconfigureResult)
- .setServiceName(input.getServiceName()).setStatus(RpcStatusEx.Pending)
- .setStatusMessage(
- "Service '" + serviceName + "' ResourceResv cancelled")
- .build();
- try {
- notificationPublishService.putNotification(notification);
- } catch (InterruptedException e) {
- LOG.info("notification offer rejected : " + e);
- }
- sendNotifToUrl(notification, notificationUrl);
-
- message = "Service '" + serviceName + "' ResourceResv cancelled";
-
- LOG.info("PCE replied to CancelResourceResv Request !");
- /*
- * Before sending the PCE request, input
- * data need to be formatted according
- * to the Service Handler - PCE
- * interface data model.
- */
- mappingAndSendingPCRequest = new MappingAndSendingPCRequest(rpcRegistry, input,
- true);
- /*
- * Once PCE request is being sent to the
- * PCE on interface B, PCE reply is
- * expected until a timer expires.
- */
- notification = new ServiceRpcResultBuilder()
- .setNotificationType(ServiceNotificationTypes.ServiceReconfigureResult)
- .setServiceName(serviceName).setStatus(RpcStatusEx.Pending)
- .setStatusMessage(message + ", submitting PathComputation Request ...")
- .build();
- try {
- notificationPublishService.putNotification(notification);
- } catch (InterruptedException e) {
- LOG.info("notification offer rejected : " + e);
- }
- sendNotifToUrl(notification, notificationUrl);
- PathComputationRequestOutput response = null;
- try {
- response = mappingAndSendingPCRequest.pathComputationRequest().get();
- } catch (InterruptedException | ExecutionException e2) {
- LOG.error(e2.getMessage());
- }
-
- if (mappingAndSendingPCRequest.getSuccess() && response != null) {
- /*
- * If PCE reply is received before
- * timer expiration with a positive
- * result, a service is created with
- * admin and operational status
- * 'down'.
- */
- LOG.info("PCE replied to PCR Request !");
- message = response.getConfigurationResponseCommon().getResponseMessage();
- notification = new ServiceRpcResultBuilder()
- .setNotificationType(
- ServiceNotificationTypes.ServiceReconfigureResult)
- .setServiceName(serviceName).setStatus(RpcStatusEx.Pending)
- .setStatusMessage("PCE replied to PCR Request !").build();
- try {
- notificationPublishService.putNotification(notification);
- } catch (InterruptedException e) {
- LOG.info("notification offer rejected : " + e);
- }
- sendNotifToUrl(notification, notificationUrl);
- /*
- * Send Implementation order to
- * renderer
- */
- mappingAndSendingSIRequest = new MappingAndSendingSIRequest(rpcRegistry,
- input, response);
-
- notification = new ServiceRpcResultBuilder()
- .setNotificationType(
- ServiceNotificationTypes.ServiceReconfigureResult)
- .setServiceName(input.getServiceName())
- .setStatus(RpcStatusEx.Pending)
- .setStatusMessage("Submitting ServiceImplementation Request ...")
- .build();
- try {
- notificationPublishService.putNotification(notification);
- } catch (InterruptedException e) {
- LOG.info("notification offer rejected : " + e);
- }
- sendNotifToUrl(notification, notificationUrl);
-
- ServiceImplementationRequestOutput siOutput = null;
- try {
- siOutput = mappingAndSendingSIRequest.serviceImplementation().get();
- } catch (InterruptedException | ExecutionException e2) {
- LOG.error(e2.getMessage());
- }
- ConfigurationResponseCommon siCommon = siOutput
- .getConfigurationResponseCommon();
- message = siCommon.getResponseMessage();
-
- if (mappingAndSendingSIRequest.getSuccess() && siOutput != null) {
- message = "Service reconfigured ";
- LOG.info("Service reconfigured !");
- notification = new ServiceRpcResultBuilder()
- .setNotificationType(
- ServiceNotificationTypes.ServiceReconfigureResult)
- .setServiceName(input.getServiceName())
- .setStatus(RpcStatusEx.Pending)
- .setStatusMessage("Service reconfigure !").build();
- try {
- notificationPublishService.putNotification(notification);
- } catch (InterruptedException e) {
- LOG.info("notification offer rejected : " + e);
- }
- sendNotifToUrl(notification, notificationUrl);
- /*
- * Service implemented Update in
- * DB.
- */
- Boolean update = false;
- Boolean delete = false;
- Services modifService = mappingServices(null, input, response);
- InstanceIdentifier<Services> iid = InstanceIdentifier
- .create(ServiceList.class)
- .child(Services.class, new ServicesKey(serviceName));
- WriteTransaction writeTx = db.newWriteOnlyTransaction();
- writeTx.delete(LogicalDatastoreType.OPERATIONAL, iid);
- try {
- LOG.info("Deleting service info ...");
- writeTx.submit().checkedGet();
- delete = true;
- } catch (TransactionCommitFailedException e) {
- LOG.error("Failed to delete service from Service List");
- }
- if (delete) {
- iid = InstanceIdentifier.create(ServiceList.class).child(
- Services.class, new ServicesKey(input.getNewServiceName()));
- writeTx = db.newWriteOnlyTransaction();
- writeTx.put(LogicalDatastoreType.OPERATIONAL, iid, modifService);
- try {
- LOG.info("Updating service info ...");
- writeTx.submit().checkedGet();
- update = true;
- } catch (TransactionCommitFailedException e) {
- LOG.error("Failed to modify service from Service List");
- }
- }
- if (update) {
- LOG.info("Service '" + serviceName + "' updated with new name '"
- + input.getNewServiceName() + "' ! ");
- StringBuilder build = new StringBuilder();
- build.append(message);
- build.append(" : Service updated on DataBase !");
- message = build.toString();
- } else {
- LOG.info("Service '" + serviceName + "' update failed ! ");
- StringBuilder build = new StringBuilder();
- build.append(message);
- build.append(" : Failed to modify service from Service List ");
- message = build.toString();
- }
- } else {
- LOG.info("Service not implemented !");
- message = response.getConfigurationResponseCommon()
- .getResponseMessage();
- notification = new ServiceRpcResultBuilder()
- .setNotificationType(
- ServiceNotificationTypes.ServiceReconfigureResult)
- .setServiceName(input.getServiceName())
- .setStatus(RpcStatusEx.Failed)
- .setStatusMessage(
- "Service not implemented, cancelling ResourceResv")
- .build();
- try {
- notificationPublishService.putNotification(notification);
- } catch (InterruptedException e) {
- LOG.info("notification offer rejected : " + e);
- }
- sendNotifToUrl(notification, notificationUrl);
- mappingAndSendingPCRequest = new MappingAndSendingPCRequest(rpcRegistry,
- input, false);
- /*
- * Send Cancel resource Request
- * to PCE.
- */
- CancelResourceReserveOutput cancelOuptut = null;
- try {
- cancelOuptut = mappingAndSendingPCRequest.cancelResourceReserve()
- .get();
- } catch (InterruptedException | ExecutionException e1) {
- LOG.error(e1.getMessage());
- }
- if (mappingAndSendingPCRequest.getSuccess() && cancelOuptut != null) {
- LOG.info("Service ResourceResv cancelled !");
- message = response.getConfigurationResponseCommon()
- .getResponseMessage();
- notification = new ServiceRpcResultBuilder()
- .setNotificationType(
- ServiceNotificationTypes.ServiceReconfigureResult)
- .setServiceName(input.getServiceName())
- .setStatus(RpcStatusEx.Failed)
- .setStatusMessage("Service ResourceResv cancelled").build();
- try {
- notificationPublishService.putNotification(notification);
- } catch (InterruptedException e) {
- LOG.info("notification offer rejected : " + e);
- }
- sendNotifToUrl(notification, notificationUrl);
-
- message = cancelOuptut.getConfigurationResponseCommon()
- .getResponseMessage();
-
- StringBuilder build = new StringBuilder();
- build.append("Service not implemented - ");
- build.append(message);
- message = build.toString();
-
- LOG.info("PCE replied to CancelResourceResv Request !");
- } else {
- message = "Cancelling Resource reserved failed ";
- LOG.info(message);
- StringBuilder build = new StringBuilder();
- build.append("Service not implemented - ");
- build.append(message);
- message = build.toString();
-
- message = response.getConfigurationResponseCommon()
- .getResponseMessage();
- notification = new ServiceRpcResultBuilder()
- .setNotificationType(
- ServiceNotificationTypes.ServiceReconfigureResult)
- .setServiceName(input.getServiceName())
- .setStatus(RpcStatusEx.Failed)
- .setStatusMessage("Cancelling Resource reserved failed")
- .build();
- try {
- notificationPublishService.putNotification(notification);
- } catch (InterruptedException e) {
- LOG.info("notification offer rejected : " + e);
- }
- sendNotifToUrl(notification, notificationUrl);
- }
- }
-
- } else {
- LOG.error("PCE pathcomputation request failed !");
- message = "PCE pathcomputation request failed : "
- + mappingAndSendingPCRequest.getError();// "Path
- // not
- // calculated";
- }
- } else {
- message = "Cancelling Resource reserved failed ";
- LOG.info(message);
- StringBuilder build = new StringBuilder();
- build.append("Service not implemented - ");
- build.append(message);
- message = build.toString();
-
- notification = new ServiceRpcResultBuilder()
- .setNotificationType(ServiceNotificationTypes.ServiceReconfigureResult)
- .setServiceName(input.getServiceName()).setStatus(RpcStatusEx.Failed)
- .setStatusMessage("Cancelling Resource reserved failed").build();
- try {
- notificationPublishService.putNotification(notification);
- } catch (InterruptedException e) {
- LOG.info("notification offer rejected : " + e);
- }
- sendNotifToUrl(notification, notificationUrl);
- }
-
- }
- };
- ListenableFuture<CancelResourceReserveOutput> pce = mappingAndSendingPCRequest
- .cancelResourceReserve();
- Futures.addCallback(pce, pceCallback);
- LOG.info("CancelResRev Request in progress ");
- ServiceReconfigureOutput output = new ServiceReconfigureOutputBuilder()
- .setStatus(RpcStatusEx.Pending).setStatusMessage(message).build();
-
- return RpcResultBuilder.success(output).buildFuture();
-
- } else {
- message = "Service '" + serviceName + "' not exists in datastore";
- LOG.error(message);
- }
- }
- } else {
- message = txrxCheck.getMessage();
- }
- } else {
- message = txrxCheck.getMessage();
- }
- } else {
- message = compliancyCheck.getMessage();