summaryrefslogtreecommitdiffstats
path: root/feature-pooling-dmaap/src/main/java
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2021-08-05 15:45:21 -0400
committerJim Hahn <jrh3@att.com>2021-08-05 16:09:01 -0400
commitf9eaa709e739a1596fafe0d840c354087f7ed5ff (patch)
tree155559ca797819233511a8e49e1ad61400580f62 /feature-pooling-dmaap/src/main/java
parentda1b7d9f04453e94fb77ebe4213f456a0be63fc2 (diff)
Use lombok in drools-pdp #3
Updated feature-healthcheck thru feature-pooling-dmaap. Issue-ID: POLICY-3397 Change-Id: Ia7b00a521cdb82ed0eb22bdaed03d02665fbbff1 Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'feature-pooling-dmaap/src/main/java')
-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
16 files changed, 129 insertions, 331 deletions
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() {