Reimplement Lock API using Lock objects 97/96197/27
authorJim Hahn <jrh3@att.com>
Tue, 24 Sep 2019 14:51:21 +0000 (10:51 -0400)
committerJim Hahn <jrh3@att.com>
Thu, 17 Oct 2019 19:40:32 +0000 (15:40 -0400)
commit6e0b450abe7e62fa47ffe14e95a67d035174dbdb
treee91c7bfb7365f9a06ad5674bc83e041b7237e378
parent1528214803af722cd660b7c4a3129f3de5b4ea7f
Reimplement Lock API using Lock objects

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>
38 files changed:
feature-distributed-locking/pom.xml
feature-distributed-locking/src/main/java/org/onap/policy/distributed/locking/DistributedLockManager.java [new file with mode: 0644]
feature-distributed-locking/src/main/java/org/onap/policy/distributed/locking/DistributedLockManagerException.java [moved from feature-distributed-locking/src/main/java/org/onap/policy/distributed/locking/DistributedLockingFeatureException.java with 83% similarity]
feature-distributed-locking/src/main/java/org/onap/policy/distributed/locking/DistributedLockProperties.java [new file with mode: 0644]
feature-distributed-locking/src/main/java/org/onap/policy/distributed/locking/DistributedLockingFeature.java [deleted file]
feature-distributed-locking/src/main/java/org/onap/policy/distributed/locking/DistributedLockingProperties.java [deleted file]
feature-distributed-locking/src/main/java/org/onap/policy/distributed/locking/TargetLock.java [deleted file]
feature-distributed-locking/src/main/resources/META-INF/services/org.onap.policy.drools.core.lock.PolicyResourceLockFeatureApi [deleted file]
feature-distributed-locking/src/main/resources/META-INF/services/org.onap.policy.drools.features.PolicyEngineFeatureApi
feature-distributed-locking/src/test/java/org/onap/policy/distributed/locking/DistributedLockManagerExceptionTest.java [moved from feature-distributed-locking/src/test/java/org/onap/policy/distributed/locking/DistributedLockingFeatureExceptionTest.java with 78% similarity]
feature-distributed-locking/src/test/java/org/onap/policy/distributed/locking/DistributedLockManagerTest.java [new file with mode: 0644]
feature-distributed-locking/src/test/java/org/onap/policy/distributed/locking/DistributedLockPropertiesTest.java [new file with mode: 0644]
feature-distributed-locking/src/test/java/org/onap/policy/distributed/locking/DistributedLockingFeatureTest.java [deleted file]
feature-distributed-locking/src/test/java/org/onap/policy/distributed/locking/TargetLockTest.java [deleted file]
feature-distributed-locking/src/test/resources/feature-distributed-locking.properties
policy-core/src/main/java/org/onap/policy/drools/core/lock/AlwaysFailLock.java [new file with mode: 0644]
policy-core/src/main/java/org/onap/policy/drools/core/lock/Lock.java
policy-core/src/main/java/org/onap/policy/drools/core/lock/LockCallback.java [moved from policy-core/src/main/java/org/onap/policy/drools/core/lock/PolicyResourceLockFeatureApiConstants.java with 65% similarity]
policy-core/src/main/java/org/onap/policy/drools/core/lock/LockImpl.java [new file with mode: 0644]
policy-core/src/main/java/org/onap/policy/drools/core/lock/LockState.java [new file with mode: 0644]
policy-core/src/main/java/org/onap/policy/drools/core/lock/PolicyResourceLockFeatureApi.java [deleted file]
policy-core/src/main/java/org/onap/policy/drools/core/lock/PolicyResourceLockManager.java
policy-core/src/main/java/org/onap/policy/drools/core/lock/SimpleLockManager.java [deleted file]
policy-core/src/test/java/org/onap/policy/drools/core/lock/AlwaysFailLockTest.java [new file with mode: 0644]
policy-core/src/test/java/org/onap/policy/drools/core/lock/LockImplTest.java [new file with mode: 0644]
policy-core/src/test/java/org/onap/policy/drools/core/lock/LockTest.java [deleted file]
policy-core/src/test/java/org/onap/policy/drools/core/lock/PolicyResourceLockFeatureApiTest.java [deleted file]
policy-core/src/test/java/org/onap/policy/drools/core/lock/PolicyResourceLockManagerTest.java [deleted file]
policy-core/src/test/java/org/onap/policy/drools/core/lock/SimpleLockManagerTest.java [deleted file]
policy-management/src/main/java/org/onap/policy/drools/features/PolicyEngineFeatureApi.java
policy-management/src/main/java/org/onap/policy/drools/system/PolicyEngine.java
policy-management/src/main/java/org/onap/policy/drools/system/PolicyEngineManager.java
policy-management/src/main/java/org/onap/policy/drools/system/internal/SimpleLockManager.java [new file with mode: 0644]
policy-management/src/main/java/org/onap/policy/drools/system/internal/SimpleLockManagerException.java [new file with mode: 0644]
policy-management/src/main/java/org/onap/policy/drools/system/internal/SimpleLockProperties.java [new file with mode: 0644]
policy-management/src/test/java/org/onap/policy/drools/system/PolicyEngineManagerTest.java
policy-management/src/test/java/org/onap/policy/drools/system/internal/SimpleLockManagerExceptionTest.java [new file with mode: 0644]
policy-management/src/test/java/org/onap/policy/drools/system/internal/SimpleLockManagerTest.java [new file with mode: 0644]