Use lombok in drools-pdp #3 60/123160/1
authorJim Hahn <jrh3@att.com>
Thu, 5 Aug 2021 19:45:21 +0000 (15:45 -0400)
committerJim Hahn <jrh3@att.com>
Thu, 5 Aug 2021 20:09:01 +0000 (16:09 -0400)
Updated feature-healthcheck thru feature-pooling-dmaap.

Issue-ID: POLICY-3397
Change-Id: Ia7b00a521cdb82ed0eb22bdaed03d02665fbbff1
Signed-off-by: Jim Hahn <jrh3@att.com>
29 files changed:
feature-healthcheck/src/main/java/org/onap/policy/drools/healthcheck/HealthCheck.java
feature-healthcheck/src/main/java/org/onap/policy/drools/healthcheck/HealthCheckConstants.java
feature-healthcheck/src/main/java/org/onap/policy/drools/healthcheck/HealthCheckManager.java
feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/HealthCheckTest.java
feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java
feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeDroolsController.java
feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeArtifactController.java
feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeDroolsController.java
feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/PolicyTypeDroolsControllerTest.java
feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeArtifactControllerTest.java
feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeDroolsControllerTest.java
feature-mdc-filters/src/main/java/org/onap/policy/drools/mdc/filters/MdcTopicFilter.java
feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/DmaapManager.java
feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingFeature.java
feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingManagerImpl.java
feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingProperties.java
feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/Serializer.java
feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/BucketAssignments.java
feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Heartbeat.java
feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Identification.java
feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Leader.java
feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Message.java
feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/MessageWithAssignments.java
feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Offline.java
feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Query.java
feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/ActiveState.java
feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/ProcessingState.java
feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/StartState.java
feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/ProcessingStateTest.java

index b729799..de00df8 100644 (file)
@@ -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;
-        }
     }
 
     /**
index 70b241d..e32d7c1 100644 (file)
@@ -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.
 
 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
-    }
 }
index 38af2d8..418fe8e 100644 (file)
@@ -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;
 
     /**
@@ -170,24 +177,6 @@ public class HealthCheckManager implements HealthCheck {
         return this.healthCheckProperties != null;
     }
 
-    /**
-     * 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.
      *
@@ -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() {
index 4215aa8..7040f6d 100644 (file)
@@ -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
index 1326c3b..8e97d3e 100644 (file)
@@ -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);
index 41d7587..fa87617 100644 (file)
@@ -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;
index b97d902..fd98eed 100644 (file)
@@ -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;
index 361b4b1..8e62e2a 100644 (file)
@@ -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();
index 18d00fc..a3b8d8c 100644 (file)
@@ -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());
index 3c8be31..05ed41a 100644 (file)
@@ -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());
index b1ef304..2d8b868 100644 (file)
@@ -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
+}
index 4ebe18e..36f63ef 100755 (executable)
@@ -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);
index 08c82fe..c0358f6 100644 (file)
@@ -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.
      *
index c757492..ca7b6e2 100644 (file)
@@ -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;
index 9093c7c..769e703 100644 (file)
@@ -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());
         }
     }
 
@@ -550,11 +540,6 @@ public class PoolingManagerImpl implements PoolingManager, TopicListener {
         }
     }
 
-    @Override
-    public BucketAssignments getAssignments() {
-        return assignments;
-    }
-
     @Override
     public State goStart() {
         return new StartState(this);
index 2994961..08b2753 100644 (file)
@@ -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;
-    }
 }
index 4627b9e..15c98e0 100644 (file)
@@ -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.
@@ -68,13 +68,6 @@ public class Serializer {
         class2type.forEach((clazz, type) -> type2class.put(type, clazz));
     }
 
-    /**
-     * Constructor.
-     */
-    public Serializer() {
-        super();
-    }
-
     /**
      * Encodes a filter.
      *
index c78fb17..d559a6d 100644 (file)
@@ -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.
      *
index 50a3413..0721fe7 100644 (file)
@@ -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.
 
 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;
-    }
-
 }
index 6bb8836..2ca4dd7 100644 (file)
@@ -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.
 
 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);
     }
-
 }
index 80149f6..239f749 100644 (file)
@@ -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.
 
 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);
index 1de8786..0154fc7 100644 (file)
@@ -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.
 
 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 {
index cfc3923..adf17b2 100644 (file)
@@ -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.
 
 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;
     }
 
     /**
index 487c4f3..7a3a3b4 100644 (file)
@@ -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.
 
 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);
     }
-
 }
index 8c9898e..d349a78 100644 (file)
@@ -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.
 
 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);
     }
-
 }
index c5ee2ae..9726c72 100644 (file)
@@ -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;
-    }
-
 }
index 7fed6a1..02d5ab6 100644 (file)
@@ -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() {
index c5761bf..59bc4fd 100644 (file)
@@ -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() {
 
index e7c9db7..02cbe49 100644 (file)
@@ -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);
     }