aboutsummaryrefslogtreecommitdiffstats
path: root/policy-core/src/main/java/org/onap/policy/drools/core
AgeCommit message (Collapse)AuthorFilesLines
2024-04-24Fix topic configurations.adheli.tavares1-1/+1
- adjust kafka configurations - remove UEB references Issue-ID: POLICY-4955 Change-Id: Ie3ff62a0ba5531ae4c0d123f214a50bb7f721807 Signed-off-by: adheli.tavares <adheli.tavares@est.tech>
2024-03-15Make drools-pdp work with drools and java versions compatibleadheli.tavares2-4/+0
with current DRL rules files syntax. Issue-ID: POLICY-4857 Change-Id: If4b385bdef865d07114b8ea0e69abb4589f3a97b Signed-off-by: adheli.tavares <adheli.tavares@est.tech>
2024-02-09Removing deprecated DMAAP libraryadheli.tavares5-14/+21
Issue-ID: POLICY-4402 Change-Id: I4ce5b303cb3a775010683d3c7102b0bd065280ea Signed-off-by: adheli.tavares <adheli.tavares@est.tech>
2021-08-05Use lombok in drools-pdp #2Jim Hahn7-91/+44
Updated feature-session-persistence thru drools-domains. Issue-ID: POLICY-3397 Change-Id: I0b1c6da8b2301c00dd792675e8cf1f49888edb9f Signed-off-by: Jim Hahn <jrh3@att.com>
2021-05-10interrupted exception and var usage sonarsjhh1-4/+5
Issue-ID: POLICY-3230 Signed-off-by: jhh <jorge.hernandez-herrero@att.com> Change-Id: I50a4ee81f0a1c97df25732a4e4507e8b7f8c8e4d
2021-03-09add no locking featurejhh1-0/+64
It provides an interface to applications for locking purposes that always succeeds. It does not deny acquiring resource locks. Issue-ID: POLICY-3114 Signed-off-by: jhh <jorge.hernandez-herrero@att.com> Change-Id: I6aebb5f40e4176e0ff7b0e6c6d4042a79dd0b7a3 Signed-off-by: jhh <jorge.hernandez-herrero@att.com>
2020-09-30Fix new sonars in drools-pdpJim Hahn1-1/+6
Addressed the following sonar issues: - extract common test method - too many assertions in test method - don't always return the same value Issue-ID: POLICY-2616 Change-Id: Iab836cdcd667b35e2db9db7d6ffc7896df33e1c8 Signed-off-by: Jim Hahn <jrh3@att.com>
2020-08-25Address more sonars in drools-pdpJim Hahn1-0/+12
Addressed the following sonars: - either log or rethrow - call "remove()" for thread-local-storage - use assertEquals - only one method call in exception test - swap arguments in assertEquals - add assertion to assertThatThrownBy() - explain @Ignore Also addressed eclipse warnings: - unused fields and methods Issue-ID: POLICY-2616 Change-Id: I6590c0d2b103885bc933014d48bf5fd92401cd80 Signed-off-by: Jim Hahn <jrh3@att.com>
2020-06-19Address checkstyle version issues in drools-pdpJim Hahn3-7/+3
Also added serializationId to several classes to address eclipse warnings. Issue-ID: POLICY-2188 Change-Id: I3df5e8abaad8da9261c0d5cd19a93ed68dceb870 Signed-off-by: Jim Hahn <jrh3@att.com>
2020-04-08Address more sonar issues in drools-pdpJim Hahn1-6/+8
Addressed the following sonar issues: - use of "synchronized" - use Files.delete() instead of File.delete() Issue-ID: POLICY-2305 Change-Id: Id55628fe12d9d764616e57321382a70cb5704ba1 Signed-off-by: Jim Hahn <jrh3@att.com>
2020-04-06Address sonar issues in drools-pdpJim Hahn3-52/+53
Addressed the following sonar issues: - add "final" to public static fields - commented code; some were bogus - just updated the comments so sonar is happy - use "{}" instead of string concatenation - junit should assert something - when using logger, invoke compute-intensive tasks conditionally - use superclass name instead of subclass name to access static fields - don't always return the same value - remove "transient" from fields of classes that aren't Serializable - don't nest try/catch blocks - use appropriate class name in Logger.getLogger() - use Predicate<T> instead of Function<T,Boolean> - remove unused parameters from private methods - either log or throw - remove duplicate methods - use remove() TLS instead of set(null) - null check is implicit in instanceof check - do something with return value - don't use volatile - don't return "null" list; used Optional instead - add no-arg constructor to non-Serializable superclass - add callSuper=true for EqualsAndHashCode - don't declare "throws XXX" where XXX is a subclass of RuntimeException - remove serialVersionUID field if the class isn't Serializable Also addressed some eclipse warnings: - unused fields - suppress generic typic cast warnings Issue-ID: POLICY-2305 Change-Id: I906d5bf71c1f86531423e23b3667a585cdba45e1 Signed-off-by: Jim Hahn <jrh3@att.com>
2020-02-25Add DroolsExecutor for DroolsRunnableJim Hahn1-0/+47
Added DroolsExecutor, which is an Executor that works by injecting its commands into drools working memory via DroolsRunnable objects. Issue-ID: POLICY-2385 Signed-off-by: Jim Hahn <jrh3@att.com> Change-Id: I59a57bc431249c84cb08f87089f6239993d7d2c4
2020-01-13policy/drools-pdp jdk11 upgradesHockla, Ali (ah999m)1-5/+9
Issue-ID: POLICY-1589 Change-Id: I0ed05c6e471a7da6658e02a4ba3115d3a117cedd Signed-off-by: Hockla, Ali (ah999m) <ah999m@att.com>
2019-11-14Add 'DroolsRunnable' classStraubs, Ralph (rs8887)2-0/+71
This provides a simple way to run arbitrary Java code within the Drools thread. This change also includes a general way to specify Drools rules that are automatically added to every Drools session. Change-Id: I5ddcca4c807dc552fbcbd4a19dce311a4d358279 Issue-ID: POLICY-1948 Signed-off-by: Straubs, Ralph (rs8887) <rs8887@att.com>
2019-11-08Miscellaneous code clean upjhh4-18/+18
Issue-ID: POLICY-2203 Signed-off-by: jhh <jorge.hernandez-herrero@att.com> Change-Id: I5731d4636bd2aaecbc486406298bcba1b19e8f4d Signed-off-by: jhh <jorge.hernandez-herrero@att.com>
2019-10-29Cleanup eclipse warnings in drools-pdpJim Hahn1-1/+1
Issue-ID: POLICY-2203 Signed-off-by: Jim Hahn <jrh3@att.com> Change-Id: I3e854b1ea1986cd4992dc2ff84d799e970e443a9
2019-10-17Reimplement Lock API using Lock objectsJim Hahn8-888/+358
Modified PolicyResourceLockManager to just return a feature, deferring the lock() call/method to the feature, itself. The manager was also modified so that, if it can't find an enabled provider, it will return a default provider, whose lock() methods always fail. Once a feature has been identified, the manager will cache it for use thereafter. Modified the feature API to return lock objects and simplified the interface to remove the beforeXxx and afterXxx methods. Moved the unlock and refresh methods from the feature API into the lock class, renaming them to free and extend, respectively. Added a separate, feature-simple-locking project, which implements a simple version of the locking feature, over a single JVM. Extensively revised the distributed locking feature to fit in with the new API. Added support for persistence so that the various LockImpl classes can be serialized and still function correctly when they are deserialized back into new feature instances Added default implementations of free & extend to LockImpl. Modified API to take the ownerKey string, instead of the owner object. Removed Extractor as unneeded - may add via another review, if still useful. Updates per review comments: - Updated licenses in feature-simple-locking - Added beforeCreateLock & afterCreateLock to feature API - Moved SimpleLockingFeature into policy-management so that it's always available - Moved the executor service, "exsvc", into PolicyEngine - Moved Extrator into policy-utils - Changed Extractor logging level for exceptions - Fixed feature sequence numbers - Fixed mixing of seconds and milliseconds - Renamed exsvc - Modified to use property method with default value - Configured scheduled executor - Added suffix to Extractor.register() - Eliminated Feature Api and tied lock manager into engine - Added non-null checks to LockImpl parameters - Added non-null checks to createLock() parameters - Checked that lockManager is initialized Change-Id: Iddba38157ddc5f7277656979c0e679e5489eb7b1 Issue-ID: POLICY-2113 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-10-15Add 'PolicySession.insertDrools' methodStraubs, Ralph (rs8887)3-2/+40
This change includes feature hooks, so a "smart insert" could forward the object to a remote host, and do the insert there. The methods 'insert' and 'insertAll' in 'PolicyContainer' now make use of this smart insert. Change-Id: I69f0e874b6fda09d1f457e4353e4b30d63696210 Issue-ID: POLICY-2160 Signed-off-by: Straubs, Ralph (rs8887) <rs8887@att.com>
2019-08-15Fix more sonar issues in drools-pdpJim Hahn1-18/+24
Addressed issues of cyclomatic complexity and deep nesting by refactoring code into separate methods. In some cases, had to refactor the code into nested classes to avoid passing too many parameters to the newly extracted methods. Addressed issue "too many conditionals" by breaking conditionals apart. Addressed issue "Remove usage of generic wildcard type" by eliminating "? extends" from return values. Addressed issue "Remove this use of 'Thread.sleep()'" in junit tests by introducing latches or using Awaitility. Note: this won't build until ApiUtils has been merged. Change-Id: I0d5596b4cb918a36bc22f426f426bd238195b458 Issue-ID: POLICY-1968 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-08-13Fix sonar issues in drools-pdpJim Hahn7-47/+109
Address sonar issue, "Move constants to a class or enum", by moving them from interfaces to classes: ActiveStandbyFeatureApi StateManagementFeatureApi PolicyResourceLockFeatureApi PolicySessionFeatureApi DroolsController DroolsControllerFeatureApi PolicyControllerFeatureApi PolicyEngineFeatureApi HealthCheck SystemPersistence EventProtocolCoder PolicyController PolicyEngine TestTransaction MdcTransaction Address sonar issue, "Move constants to a class or enum", by change the interface to a class: DroolsProperties Address sonar issue, "Override the "equals" method in this class", by adding equals & hashCode to: DroolsPdpEntity DroolsPdpImpl Use lombok for a number of getters & setters. Address sonar issue, "Define a constant instead of duplicating this literal" in: DroolsPdpsElectionHandler JpaDroolsPdpsConnector MavenDroolsController GenericEventProtocolCoder GsonProtocolCoderToolset RestManager Address sonar issue, "Remove the parentheses around the parameter" in: MavenDroolsController Address sonar issue, "Replace this lambda with a method reference" in: LifecycleFsm Address sonar issue, "Move this constructor to comply with Java Code Conventions" in: LifecycleStateRunning Address sonar issue, "Replace this 'switch' statement by 'if' statements to increase readability", as specified in: PolicyEngineManager Address sonar issue, "Rename field to prevent any misunderstanding/clash with field" in: MdcTransactionImpl Address sonar issue, "Either log or rethrow this exception", in: RestManager Address sonar issue, "Rename this constant name to" uppercase, by replacing enums with static lists in: RestManager Addressed review comments: Fixed license dates. Renamed getSiteName/setSiteName methods to getSite/setSite in the interface to match the field names in the implementation classes. Renamed *Instance classes to *Constants. Next round of review comments. Change-Id: I1c26af9f194833dd773f2b25dc5f60cde163201c Issue-ID: POLICY-1968 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-07-16Fix checkstyle issues in policy-coreJim Hahn3-14/+14
Also deleted the checkstyle suppression file. Change-Id: I93e9f9154b614b56f7826ec978e1a99bd9369348 Issue-ID: POLICY-1907 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-03-19Remove OrderedService referencesDaniel Cruz2-21/+21
Removed OrderedService and OrderedServiceImpl from the drools-pdp repo to use OrderedService and OrderedServiceImpl from the common repo. All feature interfaces were updated occordingly. Issue-ID: POLICY-1499 Change-Id: Icc80dd1cbe73a97d4832f95ad2dad52d948b711a Signed-off-by: Daniel Cruz <dc443y@att.com>
2018-11-29Remove Factory from various drools-pdp classesJim Hahn1-36/+13
Also merged changes from 'Rename test classes in drools-pdp'. Change-Id: I4d0a3a1b0b5523eadf38d1edb5aa86c404b69d19 Issue-ID: POLICY-1288 Signed-off-by: Jim Hahn <jrh3@att.com>
2018-10-05Add coverage to policy-coreJim Hahn1-69/+27
Added easy junit test coverage cases. Fixed sonar issue: removed sleep from DroolsContainerTest. Fixed sonar bug in ClassExtractors. Change-Id: I942badf17c42346c1735bc3951450fc31c02a769 Issue-ID: POLICY-1148 Signed-off-by: Jim Hahn <jrh3@att.com>
2018-10-01Set drools-pdp checkstyle configPamela Dragosh4-47/+45
Fixed last remaining checkstyle issues along with setting the pom.xml to the correct path setting. Fixed forbidden summary fragments, not allowed to prepend summary with "This method returns" Issue-ID: POLICY-1153 Change-Id: I267842080494132a7b5507731e14f027a3f6fe44 Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
2018-09-10Fix checkstyle policy-corePamela Dragosh10-233/+274
Working on the policy-core submodule in drools pdp. Issue-ID: POLICY-882 Change-Id: I58d418110fe0fda90f97117ef17edfc13d648ccc Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
2018-08-20Fix sonar issues in drools-pdpKrishnajinka2-589/+536
Fix sonar issues about nested control loops in drools-pdp. Rework1 build failed due to incorrect condition. fixing it Fix checkstyle. Add modified copyright notice Issue-ID: POLICY-1017 Change-Id: I21a4ad9399b1d234b8d5416ab0d595302a441f10 Signed-off-by: Krishnajinka <kris.jinka@samsung.com>
2018-07-25Copy policy-endpoints from drools-pdp to commonmmis1-820/+657
Removed policy-endpoints, and 3 classes from policy-core. Replaced refenences to the deleted classes with references to the corresponding classes in policy-common Issue-ID: POLICY-967 Change-Id: I547cde4894424b8f40b7ddd4e2342ebb729cb588 Signed-off-by: mmis <michael.morris@ericsson.com>
2018-07-18Deny subsequent lock()Jim Hahn2-12/+7
This is the final step of separating the lock "refresh" operation from the original "lock" operation. This step entails rejecting subsequent "lock" requests, even by the same owner, when a resource is already locked; "refresh" should now be used, instead, to extend a lock. Modified comments to indicate that the lock can only be extended using "refresh". Change-Id: I406cf60c076dbce87afbd94fb301732359dbd2db Issue-ID: POLICY-872 Signed-off-by: Jim Hahn <jrh3@att.com>
2018-07-16Distinguish lock from refreshJim Hahn3-0/+93
This is the first step of separating the lock "refresh" operation from the original "lock" operation. This step entails adding the refresh() method to both the default and the feature-distriubted locking mechanisms. Change method call, in junit test, from lock to refresh. Change branch name in git review. Change-Id: I506de7a96cb3ee786839aca04ad67cdd7378832c Issue-ID: POLICY-872 Signed-off-by: Jim Hahn <jrh3@att.com>
2018-07-03Merge "Fix sonar issues on new code"Jorge Hernandez1-3/+1
2018-07-03Fix sonar issues on new codeJim Hahn1-3/+1
Removed new technical debt. Change-Id: I04e86b85897ab42deca17ecee55f29d48cc24427 Issue-ID: POLICY-872 Signed-off-by: Jim Hahn <jrh3@att.com>
2018-06-29Final piece to remove lock CallbackJim Hahn2-31/+0
Now that drools-applications no longer uses the lock Callback, it can be removed from drools-pdp. Change-Id: Ie82a6d382b54041ab612e73ad8c96176bd01a9f6 Issue-ID: POLICY-872 Signed-off-by: Jim Hahn <jrh3@att.com>
2018-06-27Add time limit to locking facilityJim Hahn5-340/+58
Modified the locking facility to add a time limit and remove the callback parameter. This affected both the default facility as well as the distributed locking feature. It will also require a change to the rules for Closed Loop. Changed testUnlock() to try locking with a different owner. Default feature API should be OPER_UNHANDLED. Put a few things back so-as not to break the drools-applications build. They can be removed once drools-applications is updated. Fix newlines in API java. Change-Id: I3ed7835cac6a582493a9bc8f6d1d4f3e6cb6289e Issue-ID: POLICY-872 Signed-off-by: Jim Hahn <jrh3@att.com>
2018-06-25Added expiration timer to default locking strategyJim Hahn1-8/+190
Fixed comment (missing "}"). Changed default age from 15 hours to 15 minutes. Only increment test time by 1 when testing hashCode. Change-Id: I70ef6cfd34e31ded45b3975f33e5b0ba22afa627 Issue-ID: POLICY-912 Signed-off-by: Jim Hahn <jrh3@att.com>
2018-04-14Sonar cleanupMagnusen, Drew (dm741q)3-11/+9
Sonar cleanup for distributed-locking Issue-ID: POLICY-728 Change-Id: I52523a0149436805509706a4a732d1da8a1b4511 Signed-off-by: Magnusen, Drew (dm741q) <dm741q@att.com>
2018-04-12Sonar fixes for policy-core locksJim Hahn3-67/+90
Made a number of changes to the locking code in policy-core, to address sonar issues. This entaileed changing some of the Lock API methods to return OperResult instead of Boolean. Updated distributed locking with the new API return types. Simplified Thread creation using functional methods. Change-Id: If32bf7a435d2aedb969de1b77c7e7e27e110ecb0 Issue-ID: POLICY-728 Signed-off-by: Jim Hahn <jrh3@att.com>
2018-04-03Add api-resource-locks featureJim Hahn5-0/+989
Added ResourceLockFeatureAPI, to provide an interface for PolicyGuard to use to access other locking mechanisms. Move lock API to policy-core. Changed the interface and added Callback support. Added a class to invoke the API implementers. Changed to set a future instead of expecting the callback to implement the future interface. Also refactored, creating "lock" sub-package. Add junit tests. Increase junit coverage. IsLocked & isLockedBy should check all arguments. Make ImplFuture protected instead of public. Simplify locking - move callback support to an optional feature. Move Reference class to policy-utils. Return plain Future instead of LockRequestFuture. Change-Id: I65154d33833914b4332e02d1ef2512f4c5f09b16 Issue-ID: POLICY-577 Signed-off-by: Jim Hahn <jrh3@att.com>
2018-02-20Sonar fixes to drools-pdpJim Hahn2-8/+7
Fixed most of the instances of the following sonar issues: Moved array designator Used diamond operator Changed System.out/err to use a logger Changed several Thread.sleep() in test code to a single sleep() Useless assignments Replaced comparison with "" to string.isEmpty() Merged if's Replaced ArrayList with List in method returns Reordered type modifiers Reordered constructor methods Defined constants for literals, or replaced them with method calls Removed "throws Xxx" for subclasses of RuntimeException Combined identical "catch" blocks Re-interrupted the current thread after catching an InterruptedException Removed tests against the literal "false" Fix indentation of new makeTopicOperError() method. Fix exception variable name in new methods, logNoUebEncoder() and logNoDmaapEncoder(). Change-Id: Iddae5210553662f733b67333b372dec8c3fe2c94 Issue-ID: POLICY-336 Signed-off-by: Jim Hahn <jrh3@att.com>
2017-11-29Fix Sonar issues in policy-coreCharles Cole3-22/+24
Fixed the Sonar issues in policy-core that required minimal refactoring of the code. Issue-ID: POLICY-461 Change-Id: I3d0f7c4411855b2c75d5ae6968665753b50bde75 Signed-off-by: Charles Cole <cc847m@att.com>
2017-09-21Removed useless parenthesesrama-huawei2-2/+10
Added the diamond symbol on RHS side Issue-ID: POLICY-239 Change-Id: Ie49d64124a3d314f0747f35e3627ec329338f0ff Signed-off-by: rama-huawei <rama.subba.reddy.s@huawei.com>
2017-09-21Removed useless parenthesesrama-huawei3-60/+66
Added the "@Override" annotation Issue-ID: POLICY-239 Change-Id: I9896f3130b5f8ecaa557d5386c0118e9a09008d2 Signed-off-by: rama-huawei <rama.subba.reddy.s@huawei.com>
2017-09-14Eliminate hanging when updating Drools containersRalph Straubs1-1/+10
'PolicyContainer.updateToVersion(...)' now hangs unless the Drools session threads are stopped prior to the update. This wasn't an issue in the past, and it isn't clear what causes it to happen now. It also happened in the Junit tests I am currently working on. In any case, the 'updateToVersion' method has now been changed to stop the threads prior to an update attempt, do the update, and then restart the threads. Change-Id: I577a67c6e99a68bcbe3c2f476f93c0a72b93451a Issue-ID: POLICY-234 Signed-off-by: Ralph Straubs <rs8887@att.com>
2017-08-16Fix "critical" Sonar issueRalph Straubs1-1/+1
Change-Id: I46e59d9a017722370cff4112250bcdfa0f0d0b23 Issue-ID: POLICY-160 Signed-off-by: Ralph Straubs <rs8887@att.com>
2017-07-28[POLICY-72] replace openecomp for drools-pdpGuo Ruijing6-0/+1672
Change-Id: I8aa8e32d3ba10f7c655b50e97aaf6865514d4777 Signed-off-by: Guo Ruijing <ruijing.guo@intel.com>