aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoops.java10
-rw-r--r--tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessage.java5
-rw-r--r--tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantResponseDetails.java11
-rw-r--r--tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantResponseStatus.java7
-rw-r--r--tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatus.java16
-rw-r--r--tosca-controlloop/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopTest.java2
-rw-r--r--tosca-controlloop/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantControlLoopStateChangeTest.java5
-rw-r--r--tosca-controlloop/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantControlLoopUpdateTest.java5
-rw-r--r--tosca-controlloop/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantHealthCheckTest.java5
-rw-r--r--tosca-controlloop/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessageTest.java13
-rw-r--r--tosca-controlloop/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessageUtils.java2
-rw-r--r--tosca-controlloop/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStateChangeTest.java5
-rw-r--r--tosca-controlloop/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatusTest.java5
13 files changed, 58 insertions, 33 deletions
diff --git a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoops.java b/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoops.java
index 7fb6a1ad2..0c7ed07d0 100644
--- a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoops.java
+++ b/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoops.java
@@ -24,6 +24,7 @@ import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
+import org.onap.policy.models.base.PfUtils;
@Getter
@Setter
@@ -32,4 +33,13 @@ import lombok.ToString;
@AllArgsConstructor
public class ControlLoops {
private List<ControlLoop> controlLoopList;
+
+ /**
+ * Copy contructor, does a deep copy.
+ *
+ * @param otherControlLoops the other element to copy from
+ */
+ public ControlLoops(final ControlLoops otherControlLoops) {
+ this.controlLoopList = PfUtils.mapList(controlLoopList, ControlLoop::new);
+ }
}
diff --git a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessage.java b/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessage.java
index 2146f7dc2..4b27e0df3 100644
--- a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessage.java
+++ b/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessage.java
@@ -20,6 +20,7 @@
package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant;
+import java.time.Instant;
import java.util.UUID;
import lombok.AccessLevel;
import lombok.Getter;
@@ -39,13 +40,13 @@ public class ParticipantMessage {
@Setter(AccessLevel.NONE)
private ParticipantMessageType messageType;
- private UUID requestId = UUID.randomUUID();
+ private UUID messageId = UUID.randomUUID();
/**
* Time-stamp, in milliseconds, when the message was created. Defaults to the current
* time.
*/
- private long timestampMs = System.currentTimeMillis();
+ private Instant timestamp = Instant.now();
/**
* Participant ID, or {@code null} for state-change broadcast messages.
diff --git a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantResponseDetails.java b/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantResponseDetails.java
index 2c9bcd911..4c771b405 100644
--- a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantResponseDetails.java
+++ b/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantResponseDetails.java
@@ -41,6 +41,17 @@ public class ParticipantResponseDetails {
private String responseMessage;
/**
+ * Constructs the object as a response to.
+ *
+ * @param triggerMessage the message to which this is a response
+ */
+ public ParticipantResponseDetails(ParticipantMessage triggerMessage) {
+ this.responseMessage = null;
+ this.responseStatus = ParticipantResponseStatus.FAIL;
+ this.responseTo = triggerMessage.getMessageId();
+ }
+
+ /**
* Constructs the object, making a deep copy.
*
* @param source source from which to copy
diff --git a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantResponseStatus.java b/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantResponseStatus.java
index 95e9d7429..f014529b3 100644
--- a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantResponseStatus.java
+++ b/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantResponseStatus.java
@@ -33,5 +33,10 @@ public enum ParticipantResponseStatus {
/**
* participant operation failed.
*/
- FAIL
+ FAIL,
+
+ /**
+ * periodic response.
+ */
+ PERIODIC
}
diff --git a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatus.java b/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatus.java
index 4bc865c3f..b7140d4b8 100644
--- a/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatus.java
+++ b/tosca-controlloop/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatus.java
@@ -20,17 +20,12 @@
package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.UUID;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoops;
import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantHealthStatus;
import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantState;
-import org.onap.policy.models.base.PfUtils;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
/**
* Class to represent the PARTICIPANT_STATUS message that all the participants send to the control loop runtime.
@@ -46,11 +41,8 @@ public class ParticipantStatus extends ParticipantMessage {
private ParticipantState state;
private ParticipantHealthStatus healthStatus;
- // This map is a map of the state of all control loop elements the participant has. The ToscaConceptIdentifier key
- // of the outer map is a key that identifies the control loop. There is an inner map for each control loop the
- // participant has. Each inner map has the UUID that identifies the ControlLoopElement instance, and the value is
- // the ControlLoopInstance itself.
- private Map<ToscaConceptIdentifier, Map<UUID, ControlLoopElement>> elements;
+ // Control Loops on the participant
+ private ControlLoops controlLoops;
// Description. May be left {@code null}.
private String message;
@@ -74,7 +66,7 @@ public class ParticipantStatus extends ParticipantMessage {
this.state = source.state;
this.healthStatus = source.healthStatus;
this.message = source.message;
- this.elements = PfUtils.mapMap(elements, LinkedHashMap::new);
+ this.controlLoops = (source.controlLoops == null ? null : new ControlLoops(source.controlLoops));
this.response = (source.response == null ? null : new ParticipantResponseDetails(source.response));
}
}
diff --git a/tosca-controlloop/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopTest.java b/tosca-controlloop/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopTest.java
index 05721b6a4..2c0a45541 100644
--- a/tosca-controlloop/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopTest.java
+++ b/tosca-controlloop/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopTest.java
@@ -53,7 +53,7 @@ public class ControlLoopTest {
ControlLoop cl0 = new ControlLoop();
assertThat(cl0.toString()).contains("ControlLoop(");
- assertEquals(false, cl0.hashCode() == 0);
+ assertThat(cl0.hashCode()).isNotZero();
assertEquals(true, cl0.equals(cl0));
assertEquals(false, cl0.equals(null));
diff --git a/tosca-controlloop/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantControlLoopStateChangeTest.java b/tosca-controlloop/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantControlLoopStateChangeTest.java
index 3250ce713..06d6ecf77 100644
--- a/tosca-controlloop/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantControlLoopStateChangeTest.java
+++ b/tosca-controlloop/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantControlLoopStateChangeTest.java
@@ -24,6 +24,7 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.removeVariableFields;
+import java.time.Instant;
import java.util.UUID;
import org.junit.Test;
import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState;
@@ -50,9 +51,9 @@ public class ParticipantControlLoopStateChangeTest {
id.setVersion("1.2.3");
orig.setControlLoopId(id);
orig.setParticipantId(id);
- orig.setRequestId(UUID.randomUUID());
+ orig.setMessageId(UUID.randomUUID());
orig.setOrderedState(ControlLoopOrderedState.RUNNING);
- orig.setTimestampMs(Long.valueOf(3000));
+ orig.setTimestamp(Instant.ofEpochMilli(3000));
assertEquals(removeVariableFields(orig.toString()),
removeVariableFields(new ParticipantControlLoopStateChange(orig).toString()));
diff --git a/tosca-controlloop/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantControlLoopUpdateTest.java b/tosca-controlloop/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantControlLoopUpdateTest.java
index 6be84ca8b..4397bf158 100644
--- a/tosca-controlloop/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantControlLoopUpdateTest.java
+++ b/tosca-controlloop/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantControlLoopUpdateTest.java
@@ -25,6 +25,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotSame;
import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.removeVariableFields;
+import java.time.Instant;
import java.util.UUID;
import org.junit.Test;
import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop;
@@ -46,8 +47,8 @@ public class ParticipantControlLoopUpdateTest {
id.setVersion("1.2.3");
orig.setControlLoopId(id);
orig.setParticipantId(id);
- orig.setRequestId(UUID.randomUUID());
- orig.setTimestampMs(Long.valueOf(3000));
+ orig.setMessageId(UUID.randomUUID());
+ orig.setTimestamp(Instant.ofEpochMilli(3000));
ControlLoop controlLoop = new ControlLoop();
controlLoop.setName("controlLoop");
diff --git a/tosca-controlloop/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantHealthCheckTest.java b/tosca-controlloop/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantHealthCheckTest.java
index f78365c00..1cc356627 100644
--- a/tosca-controlloop/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantHealthCheckTest.java
+++ b/tosca-controlloop/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantHealthCheckTest.java
@@ -24,6 +24,7 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.removeVariableFields;
+import java.time.Instant;
import java.util.UUID;
import org.junit.Test;
import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantState;
@@ -50,9 +51,9 @@ public class ParticipantHealthCheckTest {
id.setVersion("1.2.3");
orig.setControlLoopId(id);
orig.setParticipantId(id);
- orig.setRequestId(UUID.randomUUID());
+ orig.setMessageId(UUID.randomUUID());
orig.setState(ParticipantState.ACTIVE);
- orig.setTimestampMs(Long.valueOf(3000));
+ orig.setTimestamp(Instant.ofEpochMilli(3000));
assertEquals(removeVariableFields(orig.toString()),
removeVariableFields(new ParticipantHealthCheck(orig).toString()));
diff --git a/tosca-controlloop/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessageTest.java b/tosca-controlloop/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessageTest.java
index a17b0f873..f66c99262 100644
--- a/tosca-controlloop/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessageTest.java
+++ b/tosca-controlloop/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessageTest.java
@@ -25,6 +25,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
+import java.time.Instant;
import java.util.UUID;
import org.junit.Test;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
@@ -40,15 +41,15 @@ public class ParticipantMessageTest {
// verify with null values
message = new ParticipantMessage(ParticipantMessageType.PARTICIPANT_STATE_CHANGE);
ParticipantMessage newmsg = new ParticipantMessage(message);
- newmsg.setRequestId(message.getRequestId());
- newmsg.setTimestampMs(message.getTimestampMs());
+ newmsg.setMessageId(message.getMessageId());
+ newmsg.setTimestamp(message.getTimestamp());
assertEquals(message.toString(), newmsg.toString());
// verify with all values
message = makeMessage();
newmsg = new ParticipantMessage(message);
- newmsg.setRequestId(message.getRequestId());
- newmsg.setTimestampMs(message.getTimestampMs());
+ newmsg.setMessageId(message.getMessageId());
+ newmsg.setTimestamp(message.getTimestamp());
assertEquals(message.toString(), newmsg.toString());
}
@@ -93,8 +94,8 @@ public class ParticipantMessageTest {
id.setVersion("1.2.3");
msg.setControlLoopId(id);
msg.setParticipantId(id);
- msg.setRequestId(UUID.randomUUID());
- msg.setTimestampMs(Long.valueOf(3000));
+ msg.setMessageId(UUID.randomUUID());
+ msg.setTimestamp(Instant.ofEpochMilli(3000));
return msg;
}
diff --git a/tosca-controlloop/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessageUtils.java b/tosca-controlloop/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessageUtils.java
index a7a76c05b..dfbc25d1b 100644
--- a/tosca-controlloop/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessageUtils.java
+++ b/tosca-controlloop/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessageUtils.java
@@ -30,6 +30,6 @@ public class ParticipantMessageUtils {
}
public static String removeVariableFields(String text) {
- return text.replaceAll("requestId=[^,]*", "requestId=xxx").replaceAll("timestampMs=[^,]*", "timestampMs=nnn");
+ return text.replaceAll("messageId=[^,]*", "messageId=xxx").replaceAll("timestamp=[^,]*", "timestamp=nnn");
}
}
diff --git a/tosca-controlloop/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStateChangeTest.java b/tosca-controlloop/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStateChangeTest.java
index 192f36342..235532681 100644
--- a/tosca-controlloop/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStateChangeTest.java
+++ b/tosca-controlloop/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStateChangeTest.java
@@ -24,6 +24,7 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.removeVariableFields;
+import java.time.Instant;
import java.util.UUID;
import org.junit.Test;
import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantState;
@@ -50,9 +51,9 @@ public class ParticipantStateChangeTest {
id.setVersion("1.2.3");
orig.setControlLoopId(id);
orig.setParticipantId(id);
- orig.setRequestId(UUID.randomUUID());
+ orig.setMessageId(UUID.randomUUID());
orig.setState(ParticipantState.ACTIVE);
- orig.setTimestampMs(Long.valueOf(3000));
+ orig.setTimestamp(Instant.ofEpochMilli(3000));
assertEquals(removeVariableFields(orig.toString()),
removeVariableFields(new ParticipantStateChange(orig).toString()));
diff --git a/tosca-controlloop/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatusTest.java b/tosca-controlloop/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatusTest.java
index 62b3d9d02..9b5722bce 100644
--- a/tosca-controlloop/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatusTest.java
+++ b/tosca-controlloop/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatusTest.java
@@ -24,6 +24,7 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.removeVariableFields;
+import java.time.Instant;
import java.util.UUID;
import org.junit.Test;
import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantState;
@@ -47,9 +48,9 @@ public class ParticipantStatusTest {
id.setVersion("1.2.3");
orig.setControlLoopId(id);
orig.setParticipantId(id);
- orig.setRequestId(UUID.randomUUID());
+ orig.setMessageId(UUID.randomUUID());
orig.setState(ParticipantState.ACTIVE);
- orig.setTimestampMs(Long.valueOf(3000));
+ orig.setTimestamp(Instant.ofEpochMilli(3000));
final ParticipantResponseDetails resp = new ParticipantResponseDetails();
resp.setResponseMessage("my-response");