aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRam Krishna Verma <ram_krishna.verma@bell.ca>2021-08-09 13:11:12 +0000
committerGerrit Code Review <gerrit@onap.org>2021-08-09 13:11:12 +0000
commit4f9ea31e8caacf1ab4234c86e0a0f86914630e02 (patch)
treea720b0748ef5f1d642bce08345762db409a87c11
parent51a81cbdb39a4d15764e2d28c32b9161a1f5d76c (diff)
parentf9eaa709e739a1596fafe0d840c354087f7ed5ff (diff)
Merge "Use lombok in drools-pdp #3"
-rw-r--r--feature-healthcheck/src/main/java/org/onap/policy/drools/healthcheck/HealthCheck.java95
-rw-r--r--feature-healthcheck/src/main/java/org/onap/policy/drools/healthcheck/HealthCheckConstants.java11
-rw-r--r--feature-healthcheck/src/main/java/org/onap/policy/drools/healthcheck/HealthCheckManager.java38
-rw-r--r--feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/HealthCheckTest.java4
-rw-r--r--feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java6
-rw-r--r--feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeDroolsController.java2
-rw-r--r--feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeArtifactController.java9
-rw-r--r--feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeDroolsController.java9
-rw-r--r--feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/PolicyTypeDroolsControllerTest.java2
-rw-r--r--feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeArtifactControllerTest.java7
-rw-r--r--feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeDroolsControllerTest.java8
-rwxr-xr-xfeature-mdc-filters/src/main/java/org/onap/policy/drools/mdc/filters/MdcTopicFilter.java13
-rw-r--r--feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/DmaapManager.java8
-rw-r--r--feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingFeature.java19
-rw-r--r--feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingManagerImpl.java33
-rw-r--r--feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingProperties.java82
-rw-r--r--feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/Serializer.java9
-rw-r--r--feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/BucketAssignments.java22
-rw-r--r--feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Heartbeat.java32
-rw-r--r--feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Identification.java20
-rw-r--r--feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Leader.java23
-rw-r--r--feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Message.java38
-rw-r--r--feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/MessageWithAssignments.java29
-rw-r--r--feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Offline.java20
-rw-r--r--feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Query.java20
-rw-r--r--feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/ActiveState.java24
-rw-r--r--feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/ProcessingState.java68
-rw-r--r--feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/StartState.java13
-rw-r--r--feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/ProcessingStateTest.java4
29 files changed, 176 insertions, 492 deletions
diff --git a/feature-healthcheck/src/main/java/org/onap/policy/drools/healthcheck/HealthCheck.java b/feature-healthcheck/src/main/java/org/onap/policy/drools/healthcheck/HealthCheck.java
index b7297998..de00df88 100644
--- a/feature-healthcheck/src/main/java/org/onap/policy/drools/healthcheck/HealthCheck.java
+++ b/feature-healthcheck/src/main/java/org/onap/policy/drools/healthcheck/HealthCheck.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* feature-healthcheck
* ================================================================================
- * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2019, 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.
@@ -22,6 +22,9 @@ package org.onap.policy.drools.healthcheck;
import java.util.ArrayList;
import java.util.List;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
import org.onap.policy.common.capabilities.Startable;
/**
@@ -32,6 +35,9 @@ public interface HealthCheck extends Startable {
/**
* Healthcheck Report.
*/
+ @Getter
+ @Setter
+ @ToString
public static class Report {
/**
* Named Entity in the report.
@@ -57,98 +63,17 @@ public interface HealthCheck extends Startable {
* Message from remote entity.
*/
private String message;
-
- @Override
- public String toString() {
- StringBuilder builder = new StringBuilder();
- builder.append("Report [name=");
- builder.append(getName());
- builder.append(", url=");
- builder.append(getUrl());
- builder.append(", healthy=");
- builder.append(isHealthy());
- builder.append(", code=");
- builder.append(getCode());
- builder.append(", message=");
- builder.append(getMessage());
- builder.append("]");
- return builder.toString();
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getUrl() {
- return url;
- }
-
- public void setUrl(String url) {
- this.url = url;
- }
-
- public boolean isHealthy() {
- return healthy;
- }
-
- public void setHealthy(boolean healthy) {
- this.healthy = healthy;
- }
-
- public int getCode() {
- return code;
- }
-
- public void setCode(int code) {
- this.code = code;
- }
-
- public String getMessage() {
- return message;
- }
-
- public void setMessage(String message) {
- this.message = message;
- }
}
/**
* Report aggregation.
*/
+ @Getter
+ @Setter
+ @ToString
public static class Reports {
private boolean healthy;
private List<Report> details = new ArrayList<>();
-
- @Override
- public String toString() {
- StringBuilder builder = new StringBuilder();
- builder.append("Reports [healthy=");
- builder.append(isHealthy());
- builder.append(", details=");
- builder.append(getDetails());
- builder.append("]");
- return builder.toString();
- }
-
- public boolean isHealthy() {
- return healthy;
- }
-
- public void setHealthy(boolean healthy) {
- this.healthy = healthy;
- }
-
- public List<Report> getDetails() {
- return details;
- }
-
- public void setDetails(List<Report> details) {
- this.details = details;
- }
}
/**
diff --git a/feature-healthcheck/src/main/java/org/onap/policy/drools/healthcheck/HealthCheckConstants.java b/feature-healthcheck/src/main/java/org/onap/policy/drools/healthcheck/HealthCheckConstants.java
index 70b241dd..e32d7c10 100644
--- a/feature-healthcheck/src/main/java/org/onap/policy/drools/healthcheck/HealthCheckConstants.java
+++ b/feature-healthcheck/src/main/java/org/onap/policy/drools/healthcheck/HealthCheckConstants.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* feature-healthcheck
* ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019, 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.
@@ -20,17 +20,16 @@
package org.onap.policy.drools.healthcheck;
+import lombok.AccessLevel;
import lombok.Getter;
+import lombok.NoArgsConstructor;
-public class HealthCheckConstants {
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class HealthCheckConstants {
/**
* Healthcheck Monitor.
*/
@Getter
private static final HealthCheck manager = new HealthCheckManager();
-
- private HealthCheckConstants() {
- // do nothing
- }
}
diff --git a/feature-healthcheck/src/main/java/org/onap/policy/drools/healthcheck/HealthCheckManager.java b/feature-healthcheck/src/main/java/org/onap/policy/drools/healthcheck/HealthCheckManager.java
index 38af2d87..418fe8eb 100644
--- a/feature-healthcheck/src/main/java/org/onap/policy/drools/healthcheck/HealthCheckManager.java
+++ b/feature-healthcheck/src/main/java/org/onap/policy/drools/healthcheck/HealthCheckManager.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-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.
@@ -24,6 +24,9 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import javax.ws.rs.core.Response;
+import lombok.AccessLevel;
+import lombok.Getter;
+import lombok.ToString;
import org.onap.policy.common.endpoints.http.client.HttpClient;
import org.onap.policy.common.endpoints.http.client.HttpClientFactory;
import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance;
@@ -40,6 +43,8 @@ import org.slf4j.LoggerFactory;
/**
* Healthcheck Monitor.
*/
+@Getter
+@ToString
public class HealthCheckManager implements HealthCheck {
/**
@@ -60,6 +65,8 @@ public class HealthCheckManager implements HealthCheck {
/**
* Healthcheck configuration.
*/
+ @Getter(AccessLevel.NONE)
+ @ToString.Exclude
protected Properties healthCheckProperties = null;
/**
@@ -171,24 +178,6 @@ public class HealthCheckManager implements HealthCheck {
}
/**
- * Get servers.
- *
- * @return list of attached Http Servers
- */
- public List<HttpServletServer> getServers() {
- return this.servers;
- }
-
- /**
- * Get clients.
- *
- * @return list of attached Http Clients
- */
- public List<HttpClient> getClients() {
- return this.clients;
- }
-
- /**
* Gets the body from the response.
*
* @param response response from which to get the body
@@ -220,17 +209,6 @@ public class HealthCheckManager implements HealthCheck {
}
}
- @Override
- public String toString() {
- StringBuilder builder = new StringBuilder();
- builder.append("HealthCheckMonitor [servers=");
- builder.append(servers);
- builder.append(", clients=");
- builder.append(clients);
- builder.append("]");
- return builder.toString();
- }
-
// the following methods may be overridden by junit tests
protected PolicyEngine getEngineManager() {
diff --git a/feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/HealthCheckTest.java b/feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/HealthCheckTest.java
index 4215aa8c..7040f6d3 100644
--- a/feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/HealthCheckTest.java
+++ b/feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/HealthCheckTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018, 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.
@@ -306,7 +306,7 @@ public class HealthCheckTest {
@Test
public void testHealthCheckMonitor_ToString() {
- assertTrue(monitor.toString().startsWith("HealthCheckMonitor ["));
+ assertTrue(monitor.toString().startsWith("HealthCheckManager("));
}
@Test
diff --git a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java
index 1326c3b0..8e97d3ef 100644
--- a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java
+++ b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java
@@ -164,10 +164,10 @@ public class LifecycleFsm implements Startable {
setPdpType(properties.getProperty(PDP_TYPE, DEFAULT_PDP_TYPE));
policyTypesMap.put(POLICY_TYPE_DROOLS_NATIVE_CONTROLLER,
- new PolicyTypeNativeDroolsController(this, POLICY_TYPE_DROOLS_NATIVE_CONTROLLER));
+ new PolicyTypeNativeDroolsController(POLICY_TYPE_DROOLS_NATIVE_CONTROLLER, this));
policyTypesMap.put(
POLICY_TYPE_DROOLS_NATIVE_RULES,
- new PolicyTypeNativeArtifactController(this, POLICY_TYPE_DROOLS_NATIVE_RULES));
+ new PolicyTypeNativeArtifactController(POLICY_TYPE_DROOLS_NATIVE_RULES, this));
String commaSeparatedPolicyTypes = properties.getProperty(MANDATORY_POLICY_TYPES);
if (!StringUtils.isBlank(commaSeparatedPolicyTypes)) {
@@ -234,7 +234,7 @@ public class LifecycleFsm implements Startable {
for (ToscaConceptIdentifier id : controller.getPolicyTypes()) {
PolicyTypeDroolsController ptDc = (PolicyTypeDroolsController) policyTypesMap.get(id); //NOSONAR
if (ptDc == null) {
- policyTypesMap.put(id, new PolicyTypeDroolsController(this, id, controller));
+ policyTypesMap.put(id, new PolicyTypeDroolsController(id, this, controller));
logger.info("policy-type {} added", id);
} else {
ptDc.add(controller);
diff --git a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeDroolsController.java b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeDroolsController.java
index 41d75878..fa87617d 100644
--- a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeDroolsController.java
+++ b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeDroolsController.java
@@ -62,7 +62,7 @@ public class PolicyTypeDroolsController implements PolicyTypeController {
* Creates a Policy Type Drools Controller.
*/
public PolicyTypeDroolsController(
- LifecycleFsm fsm, ToscaConceptIdentifier policyType, PolicyController controller) {
+ ToscaConceptIdentifier policyType, LifecycleFsm fsm, PolicyController controller) {
this.policyType = policyType;
this.controllers.put(controller.getName(), controller);
this.fsm = fsm;
diff --git a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeArtifactController.java b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeArtifactController.java
index b97d9026..fd98eed3 100644
--- a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeArtifactController.java
+++ b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeArtifactController.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.
* Modifications Copyright (C) 2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -21,6 +21,7 @@
package org.onap.policy.drools.lifecycle;
+import lombok.AllArgsConstructor;
import lombok.Getter;
import org.onap.policy.common.gson.annotation.GsonJsonIgnore;
import org.onap.policy.common.utils.coder.CoderException;
@@ -36,6 +37,7 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+@AllArgsConstructor
public class PolicyTypeNativeArtifactController implements PolicyTypeController {
private static final Logger logger = LoggerFactory.getLogger(PolicyTypeNativeArtifactController.class);
@@ -45,11 +47,6 @@ public class PolicyTypeNativeArtifactController implements PolicyTypeController
@GsonJsonIgnore
protected final LifecycleFsm fsm;
- public PolicyTypeNativeArtifactController(LifecycleFsm fsm, ToscaConceptIdentifier policyType) {
- this.policyType = policyType;
- this.fsm = fsm;
- }
-
@Override
public boolean deploy(ToscaPolicy policy) {
NativeArtifactPolicy nativePolicy;
diff --git a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeDroolsController.java b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeDroolsController.java
index 361b4b10..8e62e2a8 100644
--- a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeDroolsController.java
+++ b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeDroolsController.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.
* Modifications Copyright (C) 2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -26,6 +26,7 @@ import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.stream.Collectors;
+import lombok.AllArgsConstructor;
import lombok.Getter;
import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager;
import org.onap.policy.common.endpoints.event.comm.TopicSink;
@@ -47,6 +48,7 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+@AllArgsConstructor
public class PolicyTypeNativeDroolsController implements PolicyTypeController {
private static final Logger logger = LoggerFactory.getLogger(PolicyTypeNativeDroolsController.class);
@@ -56,11 +58,6 @@ public class PolicyTypeNativeDroolsController implements PolicyTypeController {
@GsonJsonIgnore
protected final LifecycleFsm fsm;
- public PolicyTypeNativeDroolsController(LifecycleFsm fsm, ToscaConceptIdentifier policyType) {
- this.policyType = policyType;
- this.fsm = fsm;
- }
-
@Override
public boolean deploy(ToscaPolicy policy) {
var controllerProps = new Properties();
diff --git a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/PolicyTypeDroolsControllerTest.java b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/PolicyTypeDroolsControllerTest.java
index 18d00fc9..a3b8d8c9 100644
--- a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/PolicyTypeDroolsControllerTest.java
+++ b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/PolicyTypeDroolsControllerTest.java
@@ -54,7 +54,7 @@ public class PolicyTypeDroolsControllerTest extends LifecycleStateRunningTest {
policy = getExamplesPolicy(VCPE_OPERATIONAL_DROOLS_POLICY_JSON, OP_POLICY_NAME_VCPE);
fsm.getDomainMaker().convertTo(policy, OperationalPolicy.class);
controller = new PolicyTypeDroolsController(
- fsm, PolicyTypeDroolsController.compliantType, controllerSupport.getController());
+ PolicyTypeDroolsController.compliantType, fsm, controllerSupport.getController());
assertTrue(controllerSupport.getController().getDrools().isBrained());
assertFalse(controllerSupport.getController().isAlive());
diff --git a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeArtifactControllerTest.java b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeArtifactControllerTest.java
index 3c8be31c..05ed41a4 100644
--- a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeArtifactControllerTest.java
+++ b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeArtifactControllerTest.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.
* Modifications Copyright (C) 2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -60,9 +60,8 @@ public class PolicyTypeNativeArtifactControllerTest extends LifecycleStateRunnin
fsm = makeFsmWithPseudoTime();
policy = getPolicyFromFile(EXAMPLE_NATIVE_DROOLS_POLICY_JSON, EXAMPLE_NATIVE_DROOLS_POLICY_NAME);
nativePolicy = fsm.getDomainMaker().convertTo(policy, NativeArtifactPolicy.class);
- controller =
- new PolicyTypeNativeArtifactController(fsm,
- new ToscaConceptIdentifier("onap.policies.native.drools.Artifact", "1.0.0"));
+ controller = new PolicyTypeNativeArtifactController(
+ new ToscaConceptIdentifier("onap.policies.native.drools.Artifact", "1.0.0"), fsm);
assertTrue(controllerSupport.getController().getDrools().isBrained());
assertFalse(controllerSupport.getController().isAlive());
diff --git a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeDroolsControllerTest.java b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeDroolsControllerTest.java
index b1ef3042..2d8b8688 100644
--- a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeDroolsControllerTest.java
+++ b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeDroolsControllerTest.java
@@ -1,6 +1,6 @@
/*
* ============LICENSE_START=======================================================
- * 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.
@@ -73,7 +73,7 @@ public class PolicyTypeNativeDroolsControllerTest extends LifecycleStateRunningT
ToscaPolicy policy = getPolicyFromFile(EXAMPLE_NATIVE_DROOLS_POLICY_JSON, EXAMPLE_NATIVE_DROOLS_POLICY_NAME);
ControllerPolicy controllerPolicy = fsm.getDomainMaker().convertTo(policy, ControllerPolicy.class);
PolicyTypeNativeDroolsController controller =
- new PolicyTypeNativeDroolsController(fsm, policy.getTypeIdentifier());
+ new PolicyTypeNativeDroolsController(policy.getTypeIdentifier(), fsm);
assertTrue(controller.undeploy(policy));
assertThatIllegalArgumentException().isThrownBy(
() -> PolicyControllerConstants.getFactory().get(controllerPolicy.getName()));
@@ -100,7 +100,7 @@ public class PolicyTypeNativeDroolsControllerTest extends LifecycleStateRunningT
ToscaPolicy nativeControllerPolicy =
getExamplesPolicy("policies/usecases.native.controller.policy.input.tosca.json", "usecases");
PolicyTypeNativeDroolsController controller =
- new PolicyTypeNativeDroolsController(fsm, nativeControllerPolicy.getTypeIdentifier());
+ new PolicyTypeNativeDroolsController(nativeControllerPolicy.getTypeIdentifier(), fsm);
assertTrue(controller.deploy(nativeControllerPolicy));
Properties properties = PolicyControllerConstants.getFactory().get("usecases").getProperties();
@@ -176,4 +176,4 @@ public class PolicyTypeNativeDroolsControllerTest extends LifecycleStateRunningT
assertTrue(controller.undeploy(nativeControllerPolicy));
}
-} \ No newline at end of file
+}
diff --git a/feature-mdc-filters/src/main/java/org/onap/policy/drools/mdc/filters/MdcTopicFilter.java b/feature-mdc-filters/src/main/java/org/onap/policy/drools/mdc/filters/MdcTopicFilter.java
index 4ebe18e1..36f63efd 100755
--- a/feature-mdc-filters/src/main/java/org/onap/policy/drools/mdc/filters/MdcTopicFilter.java
+++ b/feature-mdc-filters/src/main/java/org/onap/policy/drools/mdc/filters/MdcTopicFilter.java
@@ -26,6 +26,7 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import lombok.AllArgsConstructor;
import lombok.Getter;
import org.apache.commons.lang3.StringUtils;
import org.onap.policy.drools.protocol.coders.JsonProtocolFilter;
@@ -44,6 +45,7 @@ public class MdcTopicFilter {
private final Map<String, FilterRule> rules = new HashMap<>();
@Getter
+ @AllArgsConstructor
public static class FilterRule {
private String mdcKey;
private List<String> paths;
@@ -53,17 +55,6 @@ public class MdcTopicFilter {
this.paths = Arrays.asList(path);
}
- /**
- * Constructor.
- *
- * @param mdcKey the key to the filter rule
- * @param paths the list of potential paths to the key
- */
- public FilterRule(String mdcKey, List<String> paths) {
- this.mdcKey = mdcKey;
- this.paths = paths;
- }
-
protected void setMdcKey(String mdcKey) {
if (StringUtils.isBlank(mdcKey)) {
throw new IllegalArgumentException(MDC_KEY_ERROR);
diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/DmaapManager.java b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/DmaapManager.java
index 08c82fea..c0358f65 100644
--- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/DmaapManager.java
+++ b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/DmaapManager.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2018-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018-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.
@@ -21,6 +21,7 @@
package org.onap.policy.drools.pooling;
import java.util.List;
+import lombok.Getter;
import org.onap.policy.common.endpoints.event.comm.TopicEndpoint;
import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager;
import org.onap.policy.common.endpoints.event.comm.TopicListener;
@@ -40,6 +41,7 @@ public class DmaapManager {
/**
* Name of the DMaaP topic.
*/
+ @Getter
private final String topic;
/**
@@ -84,10 +86,6 @@ public class DmaapManager {
}
}
- public String getTopic() {
- return topic;
- }
-
/**
* Finds the topic source associated with the internal DMaaP topic.
*
diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingFeature.java b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingFeature.java
index c7574925..ca7b6e26 100644
--- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingFeature.java
+++ b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingFeature.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2018-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018-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.
@@ -25,6 +25,8 @@ import java.util.Properties;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CountDownLatch;
+import lombok.AccessLevel;
+import lombok.Getter;
import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager;
import org.onap.policy.common.endpoints.event.comm.TopicSink;
@@ -59,6 +61,7 @@ public class PoolingFeature implements PolicyEngineFeatureApi, PolicyControllerF
/**
* ID of this host.
*/
+ @Getter
private final String host;
/**
@@ -74,6 +77,7 @@ public class PoolingFeature implements PolicyEngineFeatureApi, PolicyControllerF
/**
* Decremented each time a manager enters the Active state. Used by junit tests.
*/
+ @Getter(AccessLevel.PROTECTED)
private final CountDownLatch activeLatch = new CountDownLatch(1);
/**
@@ -92,19 +96,6 @@ public class PoolingFeature implements PolicyEngineFeatureApi, PolicyControllerF
this.host = UUID.randomUUID().toString();
}
- public String getHost() {
- return host;
- }
-
- /**
- * Get active latch.
- *
- * @return a latch that will be decremented when a manager enters the active state
- */
- protected CountDownLatch getActiveLatch() {
- return activeLatch;
- }
-
@Override
public int getSequenceNumber() {
return 0;
diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingManagerImpl.java b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingManagerImpl.java
index 9093c7c0..769e703e 100644
--- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingManagerImpl.java
+++ b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingManagerImpl.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2018-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018-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.
@@ -27,6 +27,7 @@ import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
+import lombok.Getter;
import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
import org.onap.policy.common.endpoints.event.comm.TopicListener;
import org.onap.policy.drools.controller.DroolsController;
@@ -65,12 +66,14 @@ public class PoolingManagerImpl implements PoolingManager, TopicListener {
/**
* ID of this host.
*/
+ @Getter
private final String host;
/**
* Properties with which this was configured.
*/
- private final PoolingProperties props;
+ @Getter
+ private final PoolingProperties properties;
/**
* Associated controller.
@@ -90,6 +93,7 @@ public class PoolingManagerImpl implements PoolingManager, TopicListener {
/**
* Internal DMaaP topic used by this controller.
*/
+ @Getter
private final String topic;
/**
@@ -116,6 +120,7 @@ public class PoolingManagerImpl implements PoolingManager, TopicListener {
/**
* Current bucket assignments or {@code null}.
*/
+ @Getter
private BucketAssignments assignments = null;
/**
@@ -136,7 +141,7 @@ public class PoolingManagerImpl implements PoolingManager, TopicListener {
CountDownLatch activeLatch) {
this.host = host;
this.controller = controller;
- this.props = props;
+ this.properties = props;
this.activeLatch = activeLatch;
try {
@@ -168,21 +173,6 @@ public class PoolingManagerImpl implements PoolingManager, TopicListener {
}
}
- @Override
- public String getHost() {
- return host;
- }
-
- @Override
- public String getTopic() {
- return topic;
- }
-
- @Override
- public PoolingProperties getProperties() {
- return props;
- }
-
/**
* Indicates that the controller is about to start. Starts the publisher for the
* internal topic, and creates a thread pool for the timers.
@@ -257,7 +247,7 @@ public class PoolingManagerImpl implements PoolingManager, TopicListener {
* stop the publisher, but allow time for any Offline message to be
* transmitted
*/
- dmaapMgr.stopPublisher(props.getOfflinePubWaitMs());
+ dmaapMgr.stopPublisher(properties.getOfflinePubWaitMs());
}
}
@@ -551,11 +541,6 @@ public class PoolingManagerImpl implements PoolingManager, TopicListener {
}
@Override
- public BucketAssignments getAssignments() {
- return assignments;
- }
-
- @Override
public State goStart() {
return new StartState(this);
}
diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingProperties.java b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingProperties.java
index 29949614..08b2753f 100644
--- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingProperties.java
+++ b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingProperties.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018, 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.
@@ -21,6 +21,8 @@
package org.onap.policy.drools.pooling;
import java.util.Properties;
+import lombok.Getter;
+import lombok.Setter;
import org.onap.policy.common.utils.properties.BeanConfigurator;
import org.onap.policy.common.utils.properties.Property;
import org.onap.policy.common.utils.properties.SpecProperties;
@@ -29,6 +31,8 @@ import org.onap.policy.common.utils.properties.exception.PropertyException;
/**
* Properties used by the pooling feature, specific to a controller.
*/
+@Getter
+@Setter
public class PoolingProperties {
/**
@@ -142,80 +146,4 @@ public class PoolingProperties {
new BeanConfigurator().configureFromProperties(this, new SpecProperties(PREFIX, controllerName, props));
}
-
- public Properties getSource() {
- return source;
- }
-
- public String getPoolingTopic() {
- return poolingTopic;
- }
-
- public int getOfflineLimit() {
- return offlineLimit;
- }
-
- public long getOfflineAgeMs() {
- return offlineAgeMs;
- }
-
- public long getOfflinePubWaitMs() {
- return offlinePubWaitMs;
- }
-
- public long getStartHeartbeatMs() {
- return startHeartbeatMs;
- }
-
- public long getReactivateMs() {
- return reactivateMs;
- }
-
- public long getIdentificationMs() {
- return identificationMs;
- }
-
- public long getActiveHeartbeatMs() {
- return activeHeartbeatMs;
- }
-
- public long getInterHeartbeatMs() {
- return interHeartbeatMs;
- }
-
- public void setPoolingTopic(String poolingTopic) {
- this.poolingTopic = poolingTopic;
- }
-
- public void setOfflineLimit(int offlineLimit) {
- this.offlineLimit = offlineLimit;
- }
-
- public void setOfflineAgeMs(long offlineAgeMs) {
- this.offlineAgeMs = offlineAgeMs;
- }
-
- public void setOfflinePubWaitMs(long offlinePubWaitMs) {
- this.offlinePubWaitMs = offlinePubWaitMs;
- }
-
- public void setStartHeartbeatMs(long startHeartbeatMs) {
- this.startHeartbeatMs = startHeartbeatMs;
- }
-
- public void setReactivateMs(long reactivateMs) {
- this.reactivateMs = reactivateMs;
- }
-
- public void setIdentificationMs(long identificationMs) {
- this.identificationMs = identificationMs;
- }
-
- public void setActiveHeartbeatMs(long activeHeartbeatMs) {
- this.activeHeartbeatMs = activeHeartbeatMs;
- }
-
- public void setInterHeartbeatMs(long interHeartbeatMs) {
- this.interHeartbeatMs = interHeartbeatMs;
- }
}
diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/Serializer.java b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/Serializer.java
index 4627b9eb..15c98e0d 100644
--- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/Serializer.java
+++ b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/Serializer.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2018-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018-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.
@@ -69,13 +69,6 @@ public class Serializer {
}
/**
- * Constructor.
- */
- public Serializer() {
- super();
- }
-
- /**
* Encodes a filter.
*
* @param filter filter to be encoded
diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/BucketAssignments.java b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/BucketAssignments.java
index c78fb17b..d559a6d6 100644
--- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/BucketAssignments.java
+++ b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/BucketAssignments.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2018-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018-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.
@@ -23,6 +23,9 @@ package org.onap.policy.drools.pooling.message;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
import org.onap.policy.drools.pooling.PoolingFeatureException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -30,6 +33,9 @@ import org.slf4j.LoggerFactory;
/**
* Bucket assignments, which is simply an array of host names.
*/
+@Getter
+@Setter
+@NoArgsConstructor
public class BucketAssignments {
private static final Logger logger = LoggerFactory.getLogger(BucketAssignments.class);
@@ -54,12 +60,6 @@ public class BucketAssignments {
*/
private String[] hostArray = null;
- /**
- * Constructor.
- */
- public BucketAssignments() {
- super();
- }
/**
* Constructor.
@@ -71,14 +71,6 @@ public class BucketAssignments {
this.hostArray = hostArray;
}
- public String[] getHostArray() {
- return hostArray;
- }
-
- public void setHostArray(String[] hostArray) {
- this.hostArray = hostArray;
- }
-
/**
* Gets the leader, which is the host with the minimum UUID.
*
diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Heartbeat.java b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Heartbeat.java
index 50a34138..0721fe7a 100644
--- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Heartbeat.java
+++ b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Heartbeat.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018, 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.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,9 +20,16 @@
package org.onap.policy.drools.pooling.message;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+
/**
* Heart beat message sent to self, or to the succeeding host.
*/
+@Getter
+@Setter
+@NoArgsConstructor
public class Heartbeat extends Message {
/**
@@ -32,15 +39,7 @@ public class Heartbeat extends Message {
/**
* Constructor.
- */
- public Heartbeat() {
- super();
-
- }
-
- /**
- * Constructor.
- *
+ *
* @param source host on which the message originated
* @param timestampMs time, in milliseconds, associated with the message
*/
@@ -49,13 +48,4 @@ public class Heartbeat extends Message {
this.timestampMs = timestampMs;
}
-
- public long getTimestampMs() {
- return timestampMs;
- }
-
- public void setTimestampMs(long timestampMs) {
- this.timestampMs = timestampMs;
- }
-
}
diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Identification.java b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Identification.java
index 6bb88363..2ca4dd75 100644
--- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Identification.java
+++ b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Identification.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018, 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.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,27 +20,21 @@
package org.onap.policy.drools.pooling.message;
+import lombok.NoArgsConstructor;
+
/**
* Identifies the source host and the bucket assignments which it knows about.
*/
+@NoArgsConstructor
public class Identification extends MessageWithAssignments {
/**
* Constructor.
- */
- public Identification() {
- super();
-
- }
-
- /**
- * Constructor.
- *
+ *
* @param source host on which the message originated
* @param assignments assignments
*/
public Identification(String source, BucketAssignments assignments) {
super(source, assignments);
}
-
}
diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Leader.java b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Leader.java
index 80149f6e..239f7491 100644
--- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Leader.java
+++ b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Leader.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2018-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018-2019, 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.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,23 +20,18 @@
package org.onap.policy.drools.pooling.message;
+import lombok.NoArgsConstructor;
import org.onap.policy.drools.pooling.PoolingFeatureException;
/**
* Indicates that the "source" of this message is now the "lead" host.
*/
+@NoArgsConstructor
public class Leader extends MessageWithAssignments {
/**
* Constructor.
- */
- public Leader() {
- super();
- }
-
- /**
- * Constructor.
- *
+ *
* @param source host on which the message originated
* @param assignments assignments
*/
@@ -59,11 +54,11 @@ public class Leader extends MessageWithAssignments {
}
String leader = getSource();
-
+
if (!assignments.hasAssignment(leader)) {
- throw new PoolingFeatureException("leader " + leader + " has no bucket assignments");
+ throw new PoolingFeatureException("leader " + leader + " has no bucket assignments");
}
-
+
for (String host : assignments.getHostArray()) {
if (host.compareTo(leader) < 0) {
throw new PoolingFeatureException("invalid leader " + leader + ", should be " + host);
diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Message.java b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Message.java
index 1de87867..0154fc7c 100644
--- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Message.java
+++ b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Message.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2018-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018-2019, 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.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,11 +20,17 @@
package org.onap.policy.drools.pooling.message;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
import org.onap.policy.drools.pooling.PoolingFeatureException;
/**
* Messages sent on the internal topic.
*/
+@Getter
+@Setter
+@NoArgsConstructor
public class Message {
/**
@@ -43,42 +49,20 @@ public class Message {
*/
private String channel;
- /**
- * Constructor.
- */
- public Message() {
- super();
- }
/**
* Constructor.
- *
+ *
* @param source host on which the message originated
*/
public Message(String source) {
this.source = source;
}
- public String getSource() {
- return source;
- }
-
- public void setSource(String source) {
- this.source = source;
- }
-
- public String getChannel() {
- return channel;
- }
-
- public void setChannel(String channel) {
- this.channel = channel;
- }
-
/**
* Checks the validity of the message, including verifying that required
* fields are not missing.
- *
+ *
* @throws PoolingFeatureException if the message is invalid
*/
public void checkValidity() throws PoolingFeatureException {
diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/MessageWithAssignments.java b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/MessageWithAssignments.java
index cfc39231..adf17b25 100644
--- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/MessageWithAssignments.java
+++ b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/MessageWithAssignments.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2018-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018-2019, 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.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,28 +20,28 @@
package org.onap.policy.drools.pooling.message;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
import org.onap.policy.drools.pooling.PoolingFeatureException;
/**
* A Message that includes bucket assignments.
*/
+@NoArgsConstructor
public class MessageWithAssignments extends Message {
/**
* Bucket assignments, as known by the source host.
*/
+ @Getter
+ @Setter
private BucketAssignments assignments;
- /**
- * Constructor.
- */
- public MessageWithAssignments() {
- super();
- }
/**
* Constructor.
- *
+ *
* @param source host on which the message originated
* @param assignments assignements
*/
@@ -49,15 +49,6 @@ public class MessageWithAssignments extends Message {
super(source);
this.assignments = assignments;
-
- }
-
- public BucketAssignments getAssignments() {
- return assignments;
- }
-
- public void setAssignments(BucketAssignments assignments) {
- this.assignments = assignments;
}
/**
diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Offline.java b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Offline.java
index 487c4f3e..7a3a3b47 100644
--- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Offline.java
+++ b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Offline.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018, 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.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,27 +20,21 @@
package org.onap.policy.drools.pooling.message;
+import lombok.NoArgsConstructor;
+
/**
* Indicates that the source host is going offline and will be unable to process
* any further requests.
*/
+@NoArgsConstructor
public class Offline extends Message {
/**
* Constructor.
- */
- public Offline() {
- super();
-
- }
-
- /**
- * Constructor.
- *
+ *
* @param source host on which the message originated
*/
public Offline(String source) {
super(source);
}
-
}
diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Query.java b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Query.java
index 8c9898ee..d349a789 100644
--- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Query.java
+++ b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Query.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018, 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.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,26 +20,20 @@
package org.onap.policy.drools.pooling.message;
+import lombok.NoArgsConstructor;
+
/**
* Query the other hosts for their identification.
*/
+@NoArgsConstructor
public class Query extends Message {
/**
* Constructor.
- */
- public Query() {
- super();
-
- }
-
- /**
- * Constructor.
- *
+ *
* @param source host on which the message originated
*/
public Query(String source) {
super(source);
}
-
}
diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/ActiveState.java b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/ActiveState.java
index c5ee2ae3..9726c721 100644
--- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/ActiveState.java
+++ b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/ActiveState.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2018, 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018, 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.
@@ -22,6 +22,8 @@ package org.onap.policy.drools.pooling.state;
import java.util.Arrays;
import java.util.TreeSet;
+import lombok.AccessLevel;
+import lombok.Getter;
import org.onap.policy.drools.pooling.PoolingManager;
import org.onap.policy.drools.pooling.message.Heartbeat;
import org.onap.policy.drools.pooling.message.Leader;
@@ -34,6 +36,7 @@ import org.slf4j.LoggerFactory;
* processes any events associated with one of its buckets. Other events are forwarded to
* appropriate target hosts.
*/
+@Getter(AccessLevel.PROTECTED)
public class ActiveState extends ProcessingState {
private static final Logger logger = LoggerFactory.getLogger(ActiveState.class);
@@ -41,6 +44,7 @@ public class ActiveState extends ProcessingState {
/**
* Set of hosts that have been assigned a bucket.
*/
+ @Getter(AccessLevel.NONE)
private final TreeSet<String> assigned = new TreeSet<>();
/**
@@ -65,6 +69,7 @@ public class ActiveState extends ProcessingState {
*/
private boolean predHeartbeatSeen = false;
+
/**
* Constructor.
*
@@ -261,21 +266,4 @@ public class ActiveState extends ProcessingState {
return null;
}
}
-
- protected String getSuccHost() {
- return succHost;
- }
-
- protected String getPredHost() {
- return predHost;
- }
-
- protected boolean isMyHeartbeatSeen() {
- return myHeartbeatSeen;
- }
-
- protected boolean isPredHeartbeatSeen() {
- return predHeartbeatSeen;
- }
-
}
diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/ProcessingState.java b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/ProcessingState.java
index 7fed6a15..02d5ab62 100644
--- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/ProcessingState.java
+++ b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/ProcessingState.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018, 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.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -28,6 +28,9 @@ import java.util.Queue;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
+import lombok.Getter;
+import lombok.NonNull;
+import lombok.Setter;
import org.onap.policy.drools.pooling.PoolingManager;
import org.onap.policy.drools.pooling.message.BucketAssignments;
import org.onap.policy.drools.pooling.message.Leader;
@@ -38,6 +41,7 @@ import org.slf4j.LoggerFactory;
/**
* Any state in which events are being processed locally and forwarded, as appropriate.
*/
+@Getter
public class ProcessingState extends State {
private static final Logger logger = LoggerFactory.getLogger(ProcessingState.class);
@@ -45,11 +49,13 @@ public class ProcessingState extends State {
/**
* Current known leader, never {@code null}.
*/
+ @NonNull
+ @Setter
private String leader;
/**
* Constructor.
- *
+ *
* @param mgr pooling manager
* @param leader current known leader, which need not be the same as the assignment
* leader. Never {@code null}
@@ -86,7 +92,7 @@ public class ProcessingState extends State {
/**
* Sets the assignments.
- *
+ *
* @param assignments new assignments, or {@code null}
*/
protected final void setAssignments(BucketAssignments assignments) {
@@ -95,27 +101,9 @@ public class ProcessingState extends State {
}
}
- public String getLeader() {
- return leader;
- }
-
- /**
- * Sets the leader.
- *
- * @param leader the new leader
- * @throws IllegalArgumentException if an argument is invalid
- */
- protected void setLeader(String leader) {
- if (leader == null) {
- throw new IllegalArgumentException("null leader");
- }
-
- this.leader = leader;
- }
-
/**
* Determines if this host is the leader, based on the current assignments.
- *
+ *
* @return {@code true} if this host is the leader, {@code false} otherwise
*/
public boolean isLeader() {
@@ -124,9 +112,9 @@ public class ProcessingState extends State {
/**
* Becomes the leader. Publishes a Leader message and enters the {@link ActiveState}.
- *
+ *
* @param alive hosts that are known to be alive
- *
+ *
* @return the new state
*/
protected State becomeLeader(SortedSet<String> alive) {
@@ -147,9 +135,9 @@ public class ProcessingState extends State {
/**
* Makes a leader message. Assumes "this" host is the leader, and thus appears as the
* first host in the set of hosts that are still alive.
- *
+ *
* @param alive hosts that are known to be alive
- *
+ *
* @return a new message
*/
private Leader makeLeader(Set<String> alive) {
@@ -158,9 +146,9 @@ public class ProcessingState extends State {
/**
* Makes a set of bucket assignments. Assumes "this" host is the leader.
- *
+ *
* @param alive hosts that are known to be alive
- *
+ *
* @return a new set of bucket assignments
*/
private BucketAssignments makeAssignments(Set<String> alive) {
@@ -191,7 +179,7 @@ public class ProcessingState extends State {
/**
* Makes a bucket array, copying the current assignments, if available.
- *
+ *
* @return a new bucket array
*/
private String[] makeBucketArray() {
@@ -214,7 +202,7 @@ public class ProcessingState extends State {
/**
* Removes excess hosts from the set of available hosts. Assumes "this" host is the
* leader, and thus appears as the first host in the set.
- *
+ *
* @param maxHosts maximum number of hosts to be retained
* @param avail available hosts
*/
@@ -236,7 +224,7 @@ public class ProcessingState extends State {
* Adds bucket indices to {@link HostBucket} objects. Buckets that are unassigned or
* assigned to a host that does not appear within the map are re-assigned to a host
* that appears within the map.
- *
+ *
* @param bucket2host bucket assignments
* @param host2data maps a host name to its {@link HostBucket}
*/
@@ -265,7 +253,7 @@ public class ProcessingState extends State {
/**
* Assigns null buckets (i.e., those having no assignment) to available hosts.
- *
+ *
* @param buckets buckets that still need to be assigned to hosts
* @param coll collection of current host-bucket assignments
*/
@@ -287,7 +275,7 @@ public class ProcessingState extends State {
* Re-balances the buckets, taking from those that have a larger count and giving to
* those that have a smaller count. Populates an output array with the new
* assignments.
- *
+ *
* @param coll current bucket assignment
* @param bucket2host array to be populated with the new assignments
*/
@@ -323,7 +311,7 @@ public class ProcessingState extends State {
/**
* Fills the array with the host assignments.
- *
+ *
* @param coll the host assignments
* @param bucket2host array to be filled
*/
@@ -351,7 +339,7 @@ public class ProcessingState extends State {
/**
* Constructor.
- *
+ *
* @param host host
*/
public HostBucket(String host) {
@@ -360,7 +348,7 @@ public class ProcessingState extends State {
/**
* Removes the next bucket from the list.
- *
+ *
* @return the next bucket
*/
public final Integer remove() {
@@ -369,7 +357,7 @@ public class ProcessingState extends State {
/**
* Adds a bucket to the list.
- *
+ *
* @param index index of the bucket to add
*/
public final void add(Integer index) {
@@ -378,7 +366,7 @@ public class ProcessingState extends State {
/**
* Size.
- *
+ *
* @return the number of buckets assigned to this host
*/
public final int size() {
diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/StartState.java b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/StartState.java
index c5761bfd..59bc4fd4 100644
--- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/StartState.java
+++ b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/StartState.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2018, 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018, 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.
@@ -20,6 +20,7 @@
package org.onap.policy.drools.pooling.state;
+import lombok.Getter;
import org.onap.policy.drools.pooling.PoolingManager;
import org.onap.policy.drools.pooling.message.Heartbeat;
import org.slf4j.Logger;
@@ -30,6 +31,7 @@ import org.slf4j.LoggerFactory;
* to look for just that particular message. Once the message is seen, it goes into the
* {@link QueryState}.
*/
+@Getter
public class StartState extends State {
private static final Logger logger = LoggerFactory.getLogger(StartState.class);
@@ -48,15 +50,6 @@ public class StartState extends State {
super(mgr);
}
- /**
- * Get Heart beat time stamp in milliseconds.
- *
- * @return the time stamp inserted into the heart beat message
- */
- public long getHbTimestampMs() {
- return hbTimestampMs;
- }
-
@Override
public void start() {
diff --git a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/ProcessingStateTest.java b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/ProcessingStateTest.java
index e7c9db72..02cbe491 100644
--- a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/ProcessingStateTest.java
+++ b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/ProcessingStateTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2018, 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018, 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.
@@ -159,7 +159,7 @@ public class ProcessingStateTest extends SupportBasicStateTester {
assertEquals(MY_HOST, state.getLeader());
}
- @Test(expected = IllegalArgumentException.class)
+ @Test(expected = NullPointerException.class)
public void testSetLeader_Null() {
state.setLeader(null);
}