summaryrefslogtreecommitdiffstats
path: root/controlloop/common/eventmanager
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2021-05-07 15:50:22 -0400
committerJim Hahn <jrh3@att.com>2021-05-07 16:04:58 -0400
commitc2cbd89fea87897b6868b036d87d97916e89734e (patch)
treeff611957eba521fabac337d8436bb0a415330430 /controlloop/common/eventmanager
parent2faa81d80569ce38a014e2a2ab404b1ea9f6899e (diff)
Fix sonars in drools-apps
Fixed: - use "var" - add @Override annotation - change constructor to "protected" - use Xxx.class::isIstance Issue-ID: POLICY-3290 Change-Id: I7f0795af306ea5afb46d12a4fe0b22adcbce683a Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'controlloop/common/eventmanager')
-rw-r--r--controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ClEventManagerWithEvent.java4
-rw-r--r--controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ClEventManagerWithOutcome.java8
-rw-r--r--controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ClEventManagerWithSteps.java5
-rw-r--r--controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java4
-rw-r--r--controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/EventManagerServices.java6
-rw-r--r--controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/LockData.java4
-rw-r--r--controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/ophistory/OperationHistoryDataManagerImpl.java36
-rw-r--r--controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/processor/ControlLoopProcessor.java2
8 files changed, 34 insertions, 35 deletions
diff --git a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ClEventManagerWithEvent.java b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ClEventManagerWithEvent.java
index fef35e498..5a0352bfe 100644
--- a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ClEventManagerWithEvent.java
+++ b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ClEventManagerWithEvent.java
@@ -68,7 +68,7 @@ public abstract class ClEventManagerWithEvent<T extends Step> extends ClEventMan
* @throws ControlLoopException if the event is invalid or if a YAML processor cannot
* be created
*/
- public ClEventManagerWithEvent(EventManagerServices services, ControlLoopParams params,
+ protected ClEventManagerWithEvent(EventManagerServices services, ControlLoopParams params,
VirtualControlLoopEvent event, WorkingMemory workMem) throws ControlLoopException {
super(services, params, event.getRequestId(), workMem);
@@ -108,7 +108,7 @@ public abstract class ClEventManagerWithEvent<T extends Step> extends ClEventMan
@Override
public ControlLoopResponse makeControlLoopResponse(OperationOutcome outcome) {
- ControlLoopResponse clRsp = super.makeControlLoopResponse(outcome);
+ var clRsp = super.makeControlLoopResponse(outcome);
clRsp.setTarget("DCAE");
clRsp.setClosedLoopControlName(event.getClosedLoopControlName());
diff --git a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ClEventManagerWithOutcome.java b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ClEventManagerWithOutcome.java
index 9d5d15808..79fe0b78d 100644
--- a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ClEventManagerWithOutcome.java
+++ b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ClEventManagerWithOutcome.java
@@ -77,7 +77,7 @@ public abstract class ClEventManagerWithOutcome<T extends Step> extends ClEventM
* @throws ControlLoopException if the event is invalid or if a YAML processor cannot
* be created
*/
- public ClEventManagerWithOutcome(EventManagerServices services, ControlLoopParams params, UUID requestId,
+ protected ClEventManagerWithOutcome(EventManagerServices services, ControlLoopParams params, UUID requestId,
WorkingMemory workMem) throws ControlLoopException {
super(services, params, requestId, workMem);
@@ -130,7 +130,7 @@ public abstract class ClEventManagerWithOutcome<T extends Step> extends ClEventM
}
}
- OperationOutcome2 outcome2 = makeOperationOutcome2(outcome);
+ var outcome2 = makeOperationOutcome2(outcome);
partialHistory.add(outcome2);
fullHistory.add(outcome2);
}
@@ -141,7 +141,7 @@ public abstract class ClEventManagerWithOutcome<T extends Step> extends ClEventM
* @return a new notification
*/
public VirtualControlLoopNotification makeNotification() {
- VirtualControlLoopNotification notif = new VirtualControlLoopNotification();
+ var notif = new VirtualControlLoopNotification();
populateNotification(notif);
if (getFinalResult() != null) {
@@ -187,7 +187,7 @@ public abstract class ClEventManagerWithOutcome<T extends Step> extends ClEventM
* @return a new control loop response, or {@code null} if none is required
*/
public ControlLoopResponse makeControlLoopResponse(OperationOutcome outcome) {
- ControlLoopResponse clRsp = new ControlLoopResponse();
+ var clRsp = new ControlLoopResponse();
clRsp.setFrom(outcome.getActor());
return clRsp;
diff --git a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ClEventManagerWithSteps.java b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ClEventManagerWithSteps.java
index 0187db751..db0bfae9e 100644
--- a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ClEventManagerWithSteps.java
+++ b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ClEventManagerWithSteps.java
@@ -39,7 +39,6 @@ import org.onap.policy.controlloop.actorserviceprovider.OperationResult;
import org.onap.policy.controlloop.actorserviceprovider.TargetType;
import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams;
import org.onap.policy.controlloop.drl.legacy.ControlLoopParams;
-import org.onap.policy.drools.domain.models.operational.ActorOperation;
import org.onap.policy.drools.domain.models.operational.Operation;
import org.onap.policy.drools.domain.models.operational.OperationalTarget;
import org.onap.policy.drools.system.PolicyEngine;
@@ -137,7 +136,7 @@ public abstract class ClEventManagerWithSteps<T extends Step> extends ControlLoo
* @throws ControlLoopException if the event is invalid or if a YAML processor cannot
* be created
*/
- public ClEventManagerWithSteps(EventManagerServices services, ControlLoopParams params, UUID requestId,
+ protected ClEventManagerWithSteps(EventManagerServices services, ControlLoopParams params, UUID requestId,
WorkingMemory workMem) throws ControlLoopException {
super(services, params, requestId);
@@ -218,7 +217,7 @@ public abstract class ClEventManagerWithSteps<T extends Step> extends ControlLoo
policy = getProcessor().getCurrentPolicy();
- ActorOperation actor = policy.getActorOperation();
+ var actor = policy.getActorOperation();
OperationalTarget target = actor.getTarget();
String targetType = (target != null ? target.getTargetType() : null);
diff --git a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java
index f23f559e4..3a7531c03 100644
--- a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java
+++ b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java
@@ -203,7 +203,7 @@ public class ControlLoopEventManager implements StepContext, Serializable {
int remainingSec = 15 + Math.max(0, (int) TimeUnit.SECONDS.convert(remainingMs, TimeUnit.MILLISECONDS));
LockData data = target2lock.computeIfAbsent(targetEntity, key -> {
- LockData data2 = new LockData(key, requestId);
+ var data2 = new LockData(key, requestId);
makeLock(targetEntity, requestId.toString(), remainingSec, data2);
data2.addUnavailableCallback(this::onComplete);
@@ -255,7 +255,7 @@ public class ControlLoopEventManager implements StepContext, Serializable {
}
private OperationOutcome makeUnlockOutcome(String targetEntity) {
- OperationOutcome outcome = new OperationOutcome();
+ var outcome = new OperationOutcome();
outcome.setActor(ActorConstants.LOCK_ACTOR);
outcome.setOperation(ActorConstants.UNLOCK_OPERATION);
outcome.setTarget(targetEntity);
diff --git a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/EventManagerServices.java b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/EventManagerServices.java
index 42bc3d141..4fef9f9d4 100644
--- a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/EventManagerServices.java
+++ b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/EventManagerServices.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -80,7 +80,7 @@ public class EventManagerServices {
*/
public Properties startActorService(String configFileName) {
try {
- Properties props = SystemPersistenceConstants.getManager().getProperties(configFileName);
+ var props = SystemPersistenceConstants.getManager().getProperties(configFileName);
Map<String, Object> parameters = PropertyObjectUtils.toObject(props, ACTOR_SERVICE_PROPERTIES);
PropertyObjectUtils.compressLists(parameters);
@@ -145,7 +145,7 @@ public class EventManagerServices {
throw new IllegalArgumentException("invalid data manager properties:\n" + result.getResult());
}
- OperationHistoryDataManagerImpl mgr = new OperationHistoryDataManagerImpl(params);
+ var mgr = new OperationHistoryDataManagerImpl(params);
mgr.start();
return mgr;
diff --git a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/LockData.java b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/LockData.java
index 67eddba34..3b14928b8 100644
--- a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/LockData.java
+++ b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/LockData.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -168,7 +168,7 @@ public class LockData implements LockCallback {
* @return a new lock operation outcome
*/
private OperationOutcome makeOutcome() {
- OperationOutcome outcome = new OperationOutcome();
+ var outcome = new OperationOutcome();
outcome.setActor(ActorConstants.LOCK_ACTOR);
outcome.setOperation(ActorConstants.LOCK_OPERATION);
outcome.setTarget(targetEntity);
diff --git a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/ophistory/OperationHistoryDataManagerImpl.java b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/ophistory/OperationHistoryDataManagerImpl.java
index 7632a087f..8e8b1e5c7 100644
--- a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/ophistory/OperationHistoryDataManagerImpl.java
+++ b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/ophistory/OperationHistoryDataManagerImpl.java
@@ -113,7 +113,7 @@ public class OperationHistoryDataManagerImpl implements OperationHistoryDataMana
this.batchSize = params.getBatchSize();
// create the factory using the properties
- Properties props = toProperties(params);
+ var props = toProperties(params);
this.emFactory = makeEntityManagerFactory(params.getPersistenceUnit(), props);
}
@@ -225,20 +225,20 @@ public class OperationHistoryDataManagerImpl implements OperationHistoryDataMana
private void storeBatch(EntityManager entityManager, Record firstRecord) {
logger.info("store operation history record batch");
- try (EntityMgrCloser emc = new EntityMgrCloser(entityManager);
- EntityTransCloser trans = new EntityTransCloser(entityManager.getTransaction())) {
+ try (var emc = new EntityMgrCloser(entityManager);
+ var trans = new EntityTransCloser(entityManager.getTransaction())) {
- int nrecords = 0;
- Record record = firstRecord;
+ var nrecords = 0;
+ var rec = firstRecord;
- while (record != null && record != END_MARKER) {
- storeRecord(entityManager, record);
+ while (rec != null && rec != END_MARKER) {
+ storeRecord(entityManager, rec);
if (++nrecords >= batchSize) {
break;
}
- record = operations.poll();
+ rec = operations.poll();
}
trans.commit();
@@ -250,13 +250,13 @@ public class OperationHistoryDataManagerImpl implements OperationHistoryDataMana
* Stores a record.
*
* @param entityManager entity manager
- * @param record record to be stored
+ * @param rec record to be stored
*/
- private void storeRecord(EntityManager entityMgr, Record record) {
+ private void storeRecord(EntityManager entityMgr, Record rec) {
- final String reqId = record.getRequestId();
- final String clName = record.getClName();
- final ControlLoopOperation operation = record.getOperation();
+ final String reqId = rec.getRequestId();
+ final String clName = rec.getClName();
+ final ControlLoopOperation operation = rec.getOperation();
logger.info("store operation history record for {}", reqId);
@@ -264,9 +264,9 @@ public class OperationHistoryDataManagerImpl implements OperationHistoryDataMana
.createQuery("select e from OperationsHistory e" + " where e.closedLoopName= ?1"
+ " and e.requestId= ?2" + " and e.subrequestId= ?3" + " and e.actor= ?4"
+ " and e.operation= ?5" + " and e.target= ?6", OperationsHistory.class)
- .setParameter(1, clName).setParameter(2, record.getRequestId())
+ .setParameter(1, clName).setParameter(2, rec.getRequestId())
.setParameter(3, operation.getSubRequestId()).setParameter(4, operation.getActor())
- .setParameter(5, operation.getOperation()).setParameter(6, record.getTargetEntity())
+ .setParameter(5, operation.getOperation()).setParameter(6, rec.getTargetEntity())
.getResultList();
if (results.size() > 1) {
@@ -276,10 +276,10 @@ public class OperationHistoryDataManagerImpl implements OperationHistoryDataMana
OperationsHistory entry = (results.isEmpty() ? new OperationsHistory() : results.get(0));
entry.setClosedLoopName(clName);
- entry.setRequestId(record.getRequestId());
+ entry.setRequestId(rec.getRequestId());
entry.setActor(operation.getActor());
entry.setOperation(operation.getOperation());
- entry.setTarget(record.getTargetEntity());
+ entry.setTarget(rec.getTargetEntity());
entry.setSubrequestId(operation.getSubRequestId());
entry.setMessage(operation.getMessage());
entry.setOutcome(operation.getOutcome());
@@ -312,7 +312,7 @@ public class OperationHistoryDataManagerImpl implements OperationHistoryDataMana
* @return a new property set
*/
private Properties toProperties(OperationHistoryDataManagerParams params) {
- Properties props = new Properties();
+ var props = new Properties();
props.put(PersistenceUnitProperties.JDBC_DRIVER, params.getDriver());
props.put(PersistenceUnitProperties.JDBC_URL, params.getUrl());
props.put(PersistenceUnitProperties.JDBC_USER, params.getUserName());
diff --git a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/processor/ControlLoopProcessor.java b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/processor/ControlLoopProcessor.java
index 39c32fa83..cf9cf90d5 100644
--- a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/processor/ControlLoopProcessor.java
+++ b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/processor/ControlLoopProcessor.java
@@ -92,7 +92,7 @@ public class ControlLoopProcessor implements Serializable {
* Get ControlLoopParams.
*/
public ControlLoopParams getControlLoopParams() {
- ControlLoopParams controlLoopParams = new ControlLoopParams();
+ var controlLoopParams = new ControlLoopParams();
controlLoopParams.setClosedLoopControlName(this.policy.getProperties().getId());
controlLoopParams.setPolicyScope(policy.getType() + ":" + policy.getTypeVersion());