-
- /**
- *Put Service status to up
- *and add topology information
- *after receiving Stubrenderer
- *service implementation
- *notification.
- *
- * @param input ServiceCreateInput or
- */
- private <T> void updateServiceStatus(T input) {
- LOG.info("Updating Service Status ...");
- ServiceRpcResultSh notification = null;
- String message = "";
- String serviceName = null;
- ServiceNotificationTypes notif = null;
- if (input instanceof ServiceCreateInput) {
- LOG.info("Updating Service Status came from RPC serviceCreateInput ...");
- serviceName = serviceCreateInput.getServiceName();
- notif = ServiceNotificationTypes.ServiceCreateResult;
- } else if (input instanceof ServiceReconfigureInput) {
- LOG.info("Updating Service Status came from RPC serviceReconfigure ...");
- serviceName = serviceReconfigureInput.getNewServiceName();
- notif = ServiceNotificationTypes.ServiceReconfigureResult;
- } else if (input instanceof Services) {
- LOG.info("Updating Service Status came from RPC serviceRestoration ...");
- serviceName = service.getServiceName();
- notif = ServiceNotificationTypes.ServiceRestorationResult;
- }
- if (serviceName != null && notif != null) {
- if (pathTopology != null) {
- LOG.info("PathTopology contains in Stubrenderer notification received !");
- Topology topo = new TopologyBuilder()
- .setAToZ(pathTopology.getAToZ())
- .setZToA(pathTopology.getZToA())
- .build();
-
- /**
- * Service implemented setting
- * Service op status to up.
- */
- if (writeOrModifyOrDeleteServiceList(serviceName, null,topo,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 ServiceRpcResultShBuilder()
- .setNotificationType(notif)
- .setServiceName(serviceName)
- .setStatus(RpcStatusEx.Successful).setStatusMessage(message)
- .build();
- try {
- notificationPublishService.putNotification(notification);
- } catch (InterruptedException e) {
- LOG.info("notification offer rejected : {}", e);
- }
- } else {
- message = "pathTopology not in stubrenderer notification, cancelling pce resource reserve ...";
- LOG.info(message);
- notification = new ServiceRpcResultShBuilder()
- .setNotificationType(ServiceNotificationTypes.ServiceCreateResult)
- .setServiceName(serviceCreateInput.getServiceName())
- .setStatus(RpcStatusEx.Failed)
- .setStatusMessage("message")
- .build();
- try {
- notificationPublishService.putNotification(notification);
- } catch (InterruptedException e) {
- LOG.info("notification offer rejected : {}", e);
- }
- pceCancelResResource();
- }
- } else {
- LOG.info("Parameters 'serviceName' or/ and 'notiftype' is null");
- }
- }
-
- /**
- * Send pathComputation
- * request to PCE.
- *
- * @param input ServiceCreate or ServiceReconfigure or Services
- */
- private <T> void pcePathComputation(T input) {
- LOG.info("sending pathcomputation request to pce ...");
- ServiceRpcResultSh notification = null;
- String serviceName = null;
- ServiceNotificationTypes type = null;
- /**
- * Before sending the PCE request, input data need to be
- * formatted according to the Service Handler PCE
- * interface data model.
- */
- if (input instanceof ServiceReconfigureInput) {
- LOG.info("PCR came from RPC serviceReconfigure ...");
- ServiceReconfigureInput tmp = (ServiceReconfigureInput)input;
- serviceName = tmp.getNewServiceName();
- type = ServiceNotificationTypes.ServiceReconfigureResult;
- mappingAndSendingPCRequest = new MappingAndSendingPCRequest(rpcRegistry, tmp, true);
- } else if (input instanceof ServiceCreateInput) {
- LOG.info("PCR came from RPC serviceCreate ...");
- ServiceCreateInput tmp = (ServiceCreateInput)input;
- serviceName = tmp.getServiceName();
- type = ServiceNotificationTypes.ServiceCreateResult;
- mappingAndSendingPCRequest = new MappingAndSendingPCRequest(rpcRegistry, tmp, true);
- } else if (input instanceof Services) {
- LOG.info("PCR came from RPC serviceRestoration ...");
- Services tmp = (Services)input;
- serviceName = tmp.getServiceName();
- type = ServiceNotificationTypes.ServiceRestorationResult;
- mappingAndSendingPCRequest = new MappingAndSendingPCRequest(rpcRegistry, tmp, true);
- } else if (input instanceof ServiceFeasibilityCheckInput) {
- LOG.info("PCR came from RPC ServiceFeasibilityCheck ...");
- ServiceFeasibilityCheckInput tmp = (ServiceFeasibilityCheckInput)input;
- serviceName = "no name";
- type = ServiceNotificationTypes.ServiceCreateResult;
- mappingAndSendingPCRequest = new MappingAndSendingPCRequest(rpcRegistry, tmp, false);
- }
- final String name = serviceName;
- final ServiceNotificationTypes notifType = type;
-
- /**
- * Once PCE request is being sent to the PCE on
- * interface B, PCE reply is expected until a timer
- * expires.
- */
- notification = new ServiceRpcResultShBuilder()
- .setNotificationType(notifType)
- .setServiceName(serviceName).setStatus(RpcStatusEx.Pending)
- .setStatusMessage("Service compliant, submitting PathComputation Request ...").build();
- try {
- notificationPublishService.putNotification(notification);
- } catch (InterruptedException e) {
- LOG.info("notification offer rejected : {}", e);
- }
- FutureCallback<Boolean> pceCallback = new FutureCallback<Boolean>() {
- String message = "";
- ServiceRpcResultSh notification = null;
-
- @Override
- public void onSuccess(Boolean response) {
- if (response) {
- /**
- * 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(message);
- notification = new ServiceRpcResultShBuilder()
- .setNotificationType(notifType)
- .setServiceName(name).setStatus(RpcStatusEx.Pending)
- .setStatusMessage(message).build();
- try {
- notificationPublishService.putNotification(notification);
- } catch (InterruptedException e) {
- LOG.info("notification offer rejected : {}", e);
- }
- } else {
- message = mappingAndSendingPCRequest.getError();
- 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(name).setStatus(RpcStatusEx.Failed)
- .setStatusMessage("PCR Request failed : " + arg0.getMessage()).build();
- try {
- notificationPublishService.putNotification(notification);
- } catch (InterruptedException e) {
- LOG.info("notification offer rejected : {}", e);
- }
-
- }
- };
- ListenableFuture<Boolean> pce = mappingAndSendingPCRequest.pathComputationRequest();
- Futures.addCallback(pce, pceCallback, executor);
- }
-
- /**
- * Send RPC cancel reserve
- * resource to PCE.
- */
- private void pceCancelResResource() {
- LOG.info("sending RPC cancel reserve resource to PCE ...");
- Services pceService = null;
- ServiceNotificationTypes notif = null;
- if (serviceDeleteInput != null) {
- LOG.info("pceCancelResResource came from RPC serviceDelete");
- notif = ServiceNotificationTypes.ServiceDeleteResult;
- String serviceName = serviceDeleteInput.getServiceDeleteReqInfo().getServiceName();
- if (serviceName != null) {
- pceService = readServiceList(serviceName);
- } else {
- LOG.info("Parameter 'serviceName' for pceCancelResResource is null");
- }
- } else if (service != null) {
- notif = ServiceNotificationTypes.ServiceRestorationResult;
- LOG.info("pceCancelResResource came from RPC serviceRestoration");
- pceService = service;
- } else if (serviceReconfigureInput != null) {
- notif = ServiceNotificationTypes.ServiceReconfigureResult;
- LOG.info("pceCancelResResource came from RPC serviceReconfigure");
- String serviceName = serviceReconfigureInput.getServiceName();
- if (serviceName != null) {
- pceService = readServiceList(serviceName);
- } else {
- LOG.info("Parameter 'serviceName' for pceCancelResResource is null");
- }
- } else if (serviceCreateInput != null) {
- notif = ServiceNotificationTypes.ServiceCreateResult;
- LOG.info("pceCancelResResource came from RPC serviceCreate");
- String serviceName = serviceCreateInput.getServiceName();
- if (serviceName != null) {
- pceService = readServiceList(serviceName);
- } else {
- LOG.info("Parameter 'serviceName' for pceCancelResResource is null");
- }
- }
- if (pceService != null && notif != null) {
- final Services cancelService = pceService;
- final ServiceNotificationTypes type = notif;
- mappingAndSendingPCRequest = new MappingAndSendingPCRequest(rpcRegistry, pceService, false);
- FutureCallback<Boolean> pceCallback = new FutureCallback<Boolean>() {
- String message = "";
- ServiceRpcResultSh notification = null;
- @Override
- public void onSuccess(Boolean response) {
- if (response) {
- /**
- * 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 cancel resource Request !";
- LOG.info(message);
- notification = new ServiceRpcResultShBuilder()
- .setNotificationType(type)
- .setServiceName(cancelService.getServiceName()).setStatus(RpcStatusEx.Pending)
- .setStatusMessage(message).build();
- try {
- notificationPublishService.putNotification(notification);
- } catch (InterruptedException e) {
- LOG.info("notification offer rejected : {}", e);
- }
- } else {
- message = mappingAndSendingPCRequest.getError();
- notification = new ServiceRpcResultShBuilder()
- .setNotificationType(type)
- .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) {
- message = "Cancel resource request failed !";
- LOG.error(message);
- notification = new ServiceRpcResultShBuilder()
- .setNotificationType(type)
- .setServiceName(cancelService.getServiceName()).setStatus(RpcStatusEx.Failed)
- .setStatusMessage(message + " : " + arg0.getMessage()).build();
- try {
- notificationPublishService.putNotification(notification);
- } catch (InterruptedException e) {
- LOG.info("notification offer rejected : {}", e);
- }
-
- }
- };
- ListenableFuture<Boolean> pce = mappingAndSendingPCRequest.cancelResourceReserve();
- Futures.addCallback(pce, pceCallback, executor);
- }
- }
-
- private void stubrendererDelete() {
- LOG.info("sending RPC service delete to stubrenderer ...");
- String tmp = null;
- String id = null;
- if (service != null) {
- LOG.info("RPC service delete came from RPC serviceRestoration !");
- tmp = service.getServiceName();
- id = service.getCommonId();
- } else if (serviceDeleteInput != null) {
- LOG.info("RPC service delete came from ServiceDelete !");
- tmp = serviceDeleteInput.getServiceDeleteReqInfo().getServiceName();
- id = serviceDeleteInput.getSdncRequestHeader().getRequestId();