Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Jira
serverONAP Jira
columnIdsissuekey,summary,issuetype,created,updated,duedate,assignee,reporter,priority,status,resolution
columnskey,summary,type,created,updated,due,assignee,reporter,priority,status,resolution
serverId425b2b0a-557c-3c0c-b515-579789cceedb
keyCPS-738


Issue Reported:

Application start up failing due to cyclic dependency :

┌─────┐
|  notificationService defined in URL
[jar:file:/app/libs/cps-service-2.0.1-SNAPSHOT.jar!/org/onap/cps/notification/NotificationService.class]
↑     ↓
|  cpsDataUpdatedEventFactory defined in URL
[jar:file:/app/libs/cps-service-2.0.1-SNAPSHOT.jar!/org/onap/cps/notification/CpsDataUpdatedEventFactory.class]
↑     ↓
|  cpsDataServiceImpl (field private
org.onap.cps.notification.NotificationService
org.onap.cps.api.impl.CpsDataServiceImpl.notificationService)
└─────┘Why

What caused the cyclic dependency

...

:

At present, cps-temporal always sends the entire data. When a patch update is made to the data in cps, :

CpsDataServiceImpl publishes the updated data to NotificationService.

NotificationServices again makes a call to CPSDataServiceImpk. And then the entire data is obtained from cps and then sent back to NotificationService for publishing to cps-temporal.

This has led to the cyclic dependency.

Spring by default performs the bean initialization at the startup of the application. Hence cyclic dependencies lead to issues because each components keep waiting for its dependencies to be initialized first.


Image Added


Proposal 1: To remove the cyclic dependency


Image Added


Pros:

Instead of going back to cpsDataServiceImpl for making calls to persistence layer, make a direct call to persistence layer from NotificationService.

Proposal 2:

  • Removes Cyclic Dependency
  • Makes getDataNode and getAnchor method calls synchronous, thus addressing the issue related to data corruption in case of concurrent update.

Cons:

  • Making getDataNode and getAnchor method calls synchronous could lead to increased latency of the APIs

Proposal 2 : Fixing the issue by Lazy Initialization

Lazy Intitialization of cpsDataServiceImpl in cpsDataUpdatedEventFactory component. The lazy initialization concept simply means initialize something when needed. So lazy initialization of bean means bean will be initialized at the time of its demand instead of start up. This will help in .

Lazy Intitialization of cpsDataServiceImpl in cpsDataUpdatedEventFactory component.  This will ensure that CpsDataUpdatedEventFactory will not keep waiting for CpsDataServiceImpl to be initialized first thus resolving the cyclic dependency error at start up.