diff options
author | Sirisha_Manchikanti <sirisha.manchikanti@est.tech> | 2021-07-02 08:53:07 +0100 |
---|---|---|
committer | Sirisha_Manchikanti <sirisha.manchikanti@est.tech> | 2021-07-09 11:08:40 +0100 |
commit | f76591c7f98e5b96bdfa33533753ed17ea483f2a (patch) | |
tree | e1f01cae3723f158585ee6224ba477cc5db561a4 /models/src/main/java | |
parent | 22a9e7eed2eaed9846cdf07cecb712764b23b651 (diff) |
Add models for register,deregister and update
This commit adds models for ParticipantRegister, ParticipantDeregister
and ParticipantUpdate messages. Handling of these messages will be
taken care in a later commit.
Issue-ID: POLICY-3414
Signed-off-by: Sirisha_Manchikanti <sirisha.manchikanti@est.tech>
Change-Id: I622b98b03df09eecaac160ba564c8a21b449c642
Diffstat (limited to 'models/src/main/java')
9 files changed, 508 insertions, 8 deletions
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopElementDefinition.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopElementDefinition.java new file mode 100644 index 000000000..7daf8974c --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopElementDefinition.java @@ -0,0 +1,63 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.controlloop.models.controlloop.concepts; + +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.UUID; +import java.util.function.UnaryOperator; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.NonNull; +import lombok.ToString; +import org.onap.policy.models.base.PfUtils; +import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; + +/** + * Class to represent a control loop element definition instance. + */ +@NoArgsConstructor +@Data +@ToString +public class ControlLoopElementDefinition { + + @NonNull + private UUID id = UUID.randomUUID(); + + // The definition of the Control Loop Element in TOSCA + private ToscaServiceTemplate controlLoopElementToscaServiceTemplate; + + // A map indexed by the property name. Each map entry is the serialized value of the property, + // which can be deserialized into an instance of the type of the property. + private Map<String, String> commonPropertiesMap = new LinkedHashMap<>(); + + /** + * Copy constructor, does a deep copy but as all fields here are immutable, it's just a regular copy. + * + * @param clElementDefinition the controlloop element definition to copy from + */ + public ControlLoopElementDefinition(final ControlLoopElementDefinition clElementDefinition) { + this.id = clElementDefinition.id; + this.controlLoopElementToscaServiceTemplate = + new ToscaServiceTemplate(clElementDefinition.controlLoopElementToscaServiceTemplate); + this.commonPropertiesMap = PfUtils.mapMap(clElementDefinition.commonPropertiesMap, UnaryOperator.identity()); + } +} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantAckMessage.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantAckMessage.java new file mode 100644 index 000000000..1e53921dd --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantAckMessage.java @@ -0,0 +1,67 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant; + +import java.util.UUID; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +/** + * Class to represent participant Ack message. + */ +@Getter +@Setter +@ToString +public class ParticipantAckMessage { + + // The responseTo field should match the original request id in the request. + private UUID responseTo; + + // Result: Success/Fail. + private Boolean result; + + // Message indicating reason for failure + private String message; + + private ParticipantMessageType messageType; + + /** + * Constructor for instantiating a participant ack message class. + * + * @param messageType the message type + */ + public ParticipantAckMessage(final ParticipantMessageType messageType) { + this.messageType = messageType; + } + + /** + * Constructs the object, making a deep copy. + * + * @param source source from which to copy + */ + public ParticipantAckMessage(ParticipantAckMessage source) { + this.responseTo = source.responseTo; + this.result = source.result; + this.message = source.message; + this.messageType = source.messageType; + } +} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantDeregister.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantDeregister.java new file mode 100644 index 000000000..e8759b302 --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantDeregister.java @@ -0,0 +1,55 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +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.clamp.controlloop.models.controlloop.concepts.ParticipantStatistics; + +/** + * Class to represent the PARTICIPANT_DEREGISTER message that all the participants send to control loop runtime. + */ +@Getter +@Setter +@ToString(callSuper = true) +public class ParticipantDeregister extends ParticipantMessage { + + /** + * Constructor for instantiating ParticipantDeregister class with message name. + * + */ + public ParticipantDeregister() { + super(ParticipantMessageType.PARTICIPANT_DEREGISTER); + } + + /** + * Constructs the object, making a deep copy. + * + * @param source source from which to copy + */ + public ParticipantDeregister(final ParticipantDeregister source) { + super(source); + } +} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantDeregisterAck.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantDeregisterAck.java new file mode 100644 index 000000000..69406beb7 --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantDeregisterAck.java @@ -0,0 +1,51 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +/** + * Class to represent the PARTICIPANT_DEREGISTER_ACK message that control loop runtime sends to the participant. + */ +@Getter +@Setter +@ToString(callSuper = true) +public class ParticipantDeregisterAck extends ParticipantAckMessage { + + /** + * Constructor for instantiating ParticipantDeregisterAck class with message name. + * + */ + public ParticipantDeregisterAck() { + super(ParticipantMessageType.PARTICIPANT_DEREGISTER_ACK); + } + + /** + * Constructs the object, making a deep copy. + * + * @param source source from which to copy + */ + public ParticipantDeregisterAck(final ParticipantDeregisterAck source) { + super(source); + } +} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessageType.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessageType.java index 77a50bd36..94d484620 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessageType.java +++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessageType.java @@ -31,26 +31,57 @@ public enum ParticipantMessageType { PARTICIPANT_STATUS, /** - * Used by the control loop runtime to change the state of participants, triggers a PARTICIPANT_STATUS message with - * the result of the PARTICIPANT_STATE_CHANGE operation. + * Used by the controlloop runtime to change the state of participants, triggers a + * PARTICIPANT_STATUS message with the result of the PARTICIPANT_STATE_CHANGE operation. */ PARTICIPANT_STATE_CHANGE, /** - * Used by the control loop runtime to update the control loops running on participants, triggers a + * Used by controlloop runtime to update the controlloops running on participants, triggers a * PARTICIPANT_STATUS message with the result of the PARTICIPANT_CONTROL_LOOP_UPDATE operation. */ PARTICIPANT_CONTROL_LOOP_UPDATE, /** - * Used by the control loop runtime to change the state of control loops in participants, triggers a - * PARTICIPANT_STATUS message with the result of the PARTICIPANT_CONTROL_LOOP_STATE_CHANGE operation. + * Used by controlloop runtime to change the state of controlloops in participants, triggers a + * PARTICIPANT_STATUS message with result of PARTICIPANT_CONTROL_LOOP_STATE_CHANGE operation. */ PARTICIPANT_CONTROL_LOOP_STATE_CHANGE, /** - * Used by the control loop runtime to order a health check on participants, triggers a PARTICIPANT_STATUS message - * with the result of the PARTICIPANT_HEALTH_CHECK operation. + * Used by the control loop runtime to order a health check on participants, triggers a + * PARTICIPANT_STATUS message with the result of the PARTICIPANT_HEALTH_CHECK operation. */ - PARTICIPANT_HEALTH_CHECK + PARTICIPANT_HEALTH_CHECK, + + /** + * Used by participant to register itself with control loop runtime. + */ + PARTICIPANT_REGISTER, + + /** + * Used by control loop runtime to respond to participant registration. + */ + PARTICIPANT_REGISTER_ACK, + + /** + * Used by participant to deregister itself with control loop runtime. + */ + PARTICIPANT_DEREGISTER, + + /** + * Used by control loop runtime to respond to participant deregistration. + */ + PARTICIPANT_DEREGISTER_ACK, + + /** + * Used by control loop runtime to send ToscaServiceTemplate to participant. + */ + PARTICIPANT_UPDATE, + + /** + * Used by participant to acknowledge the receipt of Participant_Update message + * from control loop runtime. + */ + PARTICIPANT_UPDATE_ACK } diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantRegister.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantRegister.java new file mode 100644 index 000000000..7319d99db --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantRegister.java @@ -0,0 +1,55 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +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.clamp.controlloop.models.controlloop.concepts.ParticipantStatistics; + +/** + * Class to represent the PARTICIPANT_REGISTER message that all the participants send to control loop runtime. + */ +@Getter +@Setter +@ToString(callSuper = true) +public class ParticipantRegister extends ParticipantMessage { + + /** + * Constructor for instantiating ParticipantRegister class with message name. + * + */ + public ParticipantRegister() { + super(ParticipantMessageType.PARTICIPANT_REGISTER); + } + + /** + * Constructs the object, making a deep copy. + * + * @param source source from which to copy + */ + public ParticipantRegister(final ParticipantRegister source) { + super(source); + } +} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantRegisterAck.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantRegisterAck.java new file mode 100644 index 000000000..3d55c3690 --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantRegisterAck.java @@ -0,0 +1,55 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +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.clamp.controlloop.models.controlloop.concepts.ParticipantStatistics; + +/** + * Class to represent the PARTICIPANT_REGISTER_ACK message that control loop runtime sends to registered participant. + */ +@Getter +@Setter +@ToString(callSuper = true) +public class ParticipantRegisterAck extends ParticipantAckMessage { + + /** + * Constructor for instantiating ParticipantRegisterAck class with message name. + * + */ + public ParticipantRegisterAck() { + super(ParticipantMessageType.PARTICIPANT_REGISTER_ACK); + } + + /** + * Constructs the object, making a deep copy. + * + * @param source source from which to copy + */ + public ParticipantRegisterAck(final ParticipantRegisterAck source) { + super(source); + } +} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantUpdate.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantUpdate.java new file mode 100644 index 000000000..5fd00e278 --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantUpdate.java @@ -0,0 +1,68 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant; + +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.UUID; +import java.util.function.UnaryOperator; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElementDefinition; +import org.onap.policy.models.base.PfUtils; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; +import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; + +/** + * Class to represent the PARTICIPANT_UPDATE message that the control loop runtime sends to a participant. + * CLAMP Runtime sends Control Loop Element Definitions and Common Parameter Values to Participants. + */ +@Getter +@Setter +@ToString(callSuper = true) +public class ParticipantUpdate extends ParticipantMessage { + + // A map with Participant ID as its key, and a map of ControlLoopElements as value. + private Map<ToscaConceptIdentifier, Map<UUID, ControlLoopElementDefinition>> + participantDefinitionUpdateMap = new LinkedHashMap<>(); + + /** + * Constructor for instantiating ParticipantUpdate class with message name. + * + */ + public ParticipantUpdate() { + super(ParticipantMessageType.PARTICIPANT_UPDATE); + } + + /** + * Constructs the object, making a deep copy. + * + * @param source source from which to copy + */ + public ParticipantUpdate(ParticipantUpdate source) { + super(source); + + this.participantDefinitionUpdateMap = PfUtils.mapMap(source.participantDefinitionUpdateMap, + clElementDefinitionMap -> PfUtils.mapMap(clElementDefinitionMap, + ControlLoopElementDefinition::new)); + } +} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantUpdateAck.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantUpdateAck.java new file mode 100644 index 000000000..0f065e9e6 --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantUpdateAck.java @@ -0,0 +1,55 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +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.clamp.controlloop.models.controlloop.concepts.ParticipantStatistics; + +/** + * Class to represent the PARTICIPANT_UPDATE_ACK message that registered participant sends to controlloop runtime. + */ +@Getter +@Setter +@ToString(callSuper = true) +public class ParticipantUpdateAck extends ParticipantAckMessage { + + /** + * Constructor for instantiating ParticipantUpdateAck class with message name. + * + */ + public ParticipantUpdateAck() { + super(ParticipantMessageType.PARTICIPANT_UPDATE_ACK); + } + + /** + * Constructs the object, making a deep copy. + * + * @param source source from which to copy + */ + public ParticipantUpdateAck(final ParticipantUpdateAck source) { + super(source); + } +} |