+++ /dev/null
-/*-
- * ============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.ParticipantState;
-
-/**
- * Class to represent the PARTICIPANT_STATE_CHANGE message that the control loop runtime will send to participants
- * to change their state.
- */
-@Getter
-@Setter
-@ToString(callSuper = true)
-public class ParticipantStateChange extends ParticipantMessage {
- private ParticipantState state;
-
- /**
- * Constructor for instantiating ParticipantStateChange class with message name.
- *
- */
- public ParticipantStateChange() {
- super(ParticipantMessageType.PARTICIPANT_STATE_CHANGE);
- }
-
- /**
- * Constructs the object, making a deep copy.
- *
- * @param source source from which to copy
- */
- public ParticipantStateChange(ParticipantStateChange source) {
- super(source);
-
- this.state = source.state;
- }
-}
@Test
void testCopyConstructor() {
- assertThatThrownBy(() -> new ParticipantStateChange(null)).isInstanceOf(NullPointerException.class);
+ assertThatThrownBy(() -> new ParticipantControlLoopStateChange(null)).isInstanceOf(NullPointerException.class);
ParticipantControlLoopStateChange orig = new ParticipantControlLoopStateChange();
@Test
void testCopyConstructor() {
- assertThatThrownBy(() -> new ParticipantStateChange(null)).isInstanceOf(NullPointerException.class);
+ assertThatThrownBy(() -> new ParticipantHealthCheck(null)).isInstanceOf(NullPointerException.class);
ParticipantHealthCheck orig = new ParticipantHealthCheck();
+++ /dev/null
-/*-
- * ============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 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.jupiter.api.Test;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantState;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
-
-/**
- * Test the copy constructor and the other methods.
- */
-class ParticipantStateChangeTest {
-
- @Test
- void testCopyConstructor() {
- assertThatThrownBy(() -> new ParticipantStateChange(null)).isInstanceOf(NullPointerException.class);
-
- ParticipantStateChange orig = new ParticipantStateChange();
-
- // verify with null values
- assertEquals(removeVariableFields(orig.toString()),
- removeVariableFields(new ParticipantStateChange(orig).toString()));
-
- // verify with all values
- ToscaConceptIdentifier id = new ToscaConceptIdentifier();
- id.setName("id");
- id.setVersion("1.2.3");
- orig.setControlLoopId(id);
- orig.setParticipantId(id);
- orig.setMessageId(UUID.randomUUID());
- orig.setState(ParticipantState.ACTIVE);
- orig.setTimestamp(Instant.ofEpochMilli(3000));
-
- assertEquals(removeVariableFields(orig.toString()),
- removeVariableFields(new ParticipantStateChange(orig).toString()));
- }
-}
import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ControlLoopUpdate;
import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantControlLoopStateChange;
import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantHealthCheck;
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantStateChange;
import org.onap.policy.common.utils.coder.Coder;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoder;
return controlLoop;
}
- /**
- * Method to create ParticipantStateChange message from the arguments passed.
- *
- * @param participantState participant State
- *
- * @return ParticipantStateChange message
- */
- public static ParticipantStateChange createParticipantStateChangeMsg(final ParticipantState participantState) {
- final ParticipantStateChange participantStateChangeMsg = new ParticipantStateChange();
- ToscaConceptIdentifier participantId = new ToscaConceptIdentifier();
- participantId.setName("DCAEParticipant0");
- participantId.setVersion("1.0.0");
-
- participantStateChangeMsg.setParticipantId(participantId);
- participantStateChangeMsg.setTimestamp(Instant.now());
- participantStateChangeMsg.setState(participantState);
-
- return participantStateChangeMsg;
- }
-
/**
* Method to create ControlLoopStateChange message from the arguments passed.
*
import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ControlLoopUpdate;
import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantControlLoopStateChange;
import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantHealthCheck;
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantStateChange;
import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantUpdate;
import org.onap.policy.clamp.controlloop.participant.policy.main.parameters.CommonTestData;
import org.onap.policy.common.utils.coder.Coder;
return controlLoop;
}
- /**
- * Method to create ParticipantStateChange message from the arguments passed.
- *
- * @param participantState participant State
- *
- * @return ParticipantStateChange message
- */
- public static ParticipantStateChange createParticipantStateChangeMsg(final ParticipantState participantState) {
- final ParticipantStateChange participantStateChangeMsg = new ParticipantStateChange();
- ToscaConceptIdentifier participantId = new ToscaConceptIdentifier();
- participantId.setName("org.onap.PM_Policy");
- participantId.setVersion("0.0.0");
-
- participantStateChangeMsg.setParticipantId(participantId);
- participantStateChangeMsg.setTimestamp(Instant.now());
- participantStateChangeMsg.setState(participantState);
-
- return participantStateChangeMsg;
- }
-
/**
* Method to create ControlLoopStateChange message from the arguments passed.
*
import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantState;
import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ControlLoopUpdate;
import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantControlLoopStateChange;
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantStateChange;
import org.onap.policy.clamp.controlloop.participant.simulator.main.parameters.CommonTestData;
import org.onap.policy.common.utils.coder.Coder;
import org.onap.policy.common.utils.coder.CoderException;
return controlLoop;
}
- /**
- * Method to create ParticipantStateChange message from the arguments passed.
- *
- * @param participantState participant State
- *
- * @return ParticipantStateChange message
- */
- public static ParticipantStateChange createParticipantStateChangeMsg(final ParticipantState participantState) {
- final ParticipantStateChange participantStateChangeMsg = new ParticipantStateChange();
- ToscaConceptIdentifier participantId = new ToscaConceptIdentifier("org.onap.PM_CDS_Blueprint", "1.0.0");
-
- participantStateChangeMsg.setParticipantId(participantId);
- participantStateChangeMsg.setTimestamp(Instant.now());
- participantStateChangeMsg.setState(participantState);
-
- return participantStateChangeMsg;
- }
-
/**
* Method to create ControlLoopStateChange message from the arguments passed.
*
+++ /dev/null
-/*-
- * ============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.participant.intermediary.comm;
-
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantStateChange;
-import org.onap.policy.clamp.controlloop.participant.intermediary.handler.ParticipantHandler;
-import org.springframework.stereotype.Component;
-
-/**
- * Listener for Participant State Change messages sent by CLAMP.
- *
- */
-@Component
-public class ParticipantStateChangeListener extends ParticipantListener<ParticipantStateChange> {
-
- /**
- * Constructs the object.
- *
- * @param participantHandler the handler for managing the state of the participant
- */
- public ParticipantStateChangeListener(final ParticipantHandler participantHandler) {
- super(ParticipantStateChange.class, participantHandler, participantHandler::handleParticipantStateChange);
- }
-}
import org.onap.policy.clamp.controlloop.participant.intermediary.comm.ParticipantDeregisterAckListener;
import org.onap.policy.clamp.controlloop.participant.intermediary.comm.ParticipantHealthCheckListener;
import org.onap.policy.clamp.controlloop.participant.intermediary.comm.ParticipantRegisterAckListener;
-import org.onap.policy.clamp.controlloop.participant.intermediary.comm.ParticipantStateChangeListener;
import org.onap.policy.clamp.controlloop.participant.intermediary.comm.ParticipantUpdateListener;
import org.onap.policy.clamp.controlloop.participant.intermediary.parameters.ParticipantParameters;
import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager;
private void registerMsgDispatcher() {
MessageTypeDispatcher msgDispatcher = applicationContext.getBean(MessageTypeDispatcher.class);
- msgDispatcher.register(ParticipantMessageType.PARTICIPANT_STATE_CHANGE.name(),
- applicationContext.getBean(ParticipantStateChangeListener.class));
-
msgDispatcher.register(ParticipantMessageType.PARTICIPANT_HEALTH_CHECK.name(),
applicationContext.getBean(ParticipantHealthCheckListener.class));
import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantRegisterAck;
import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantResponseDetails;
import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantResponseStatus;
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantStateChange;
import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantStatus;
import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantUpdate;
import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantUpdateAck;
sender.close();
}
- /**
- * Method which handles a participant state change event from clamp.
- *
- * @param stateChangeMsg participant state change message
- */
- public void handleParticipantStateChange(final ParticipantStateChange stateChangeMsg) {
-
- if (!stateChangeMsg.appliesTo(participantType, participantId)) {
- return;
- }
-
- var response = new ParticipantResponseDetails(stateChangeMsg);
-
- switch (stateChangeMsg.getState()) {
- case PASSIVE:
- handlePassiveState(response);
- break;
- case ACTIVE:
- handleActiveState(response);
- break;
- case SAFE:
- handleSafeState(response);
- break;
- case TEST:
- handleTestState(response);
- break;
- case TERMINATED:
- handleTerminatedState(response);
- break;
- default:
- LOGGER.debug("StateChange message has no state, state is null {}", stateChangeMsg.getParticipantId());
- response.setResponseStatus(ParticipantResponseStatus.FAIL);
- response.setResponseMessage(
- "StateChange message has invalid state for participantId " + stateChangeMsg.getParticipantId());
- break;
- }
-
- sender.sendResponse(response);
- }
-
/**
* Method which handles a participant health check event from clamp.
*
controlLoopHandler.handleControlLoopStateChange(stateChangeMsg);
}
- /**
- * Method to handle when the new state from participant is active.
- *
- * @param response participant response
- */
- private void handleActiveState(final ParticipantResponseDetails response) {
- handleStateChange(ParticipantState.ACTIVE, response);
- }
-
- /**
- * Method to handle when the new state from participant is passive.
- *
- * @param response participant response
- */
- private void handlePassiveState(final ParticipantResponseDetails response) {
- handleStateChange(ParticipantState.PASSIVE, response);
- }
-
- /**
- * Method to handle when the new state from participant is safe.
- *
- * @param response participant response
- */
- private void handleSafeState(final ParticipantResponseDetails response) {
- handleStateChange(ParticipantState.SAFE, response);
- }
-
- /**
- * Method to handle when the new state from participant is TEST.
- *
- * @param response participant response
- */
- private void handleTestState(final ParticipantResponseDetails response) {
- handleStateChange(ParticipantState.TEST, response);
- }
-
- /**
- * Method to handle when the new state from participant is Terminated.
- *
- * @param response participant response
- */
- private void handleTerminatedState(final ParticipantResponseDetails response) {
- handleStateChange(ParticipantState.TERMINATED, response);
- }
-
private void handleStateChange(ParticipantState newParticipantState, ParticipantResponseDetails response) {
if (state.equals(newParticipantState)) {
response.setResponseStatus(ParticipantResponseStatus.SUCCESS);
@Min(value = 0)
private long supervisionScannerIntervalSec;
- @Min(value = 0)
- private long participantStateChangeIntervalSec;
-
@Min(value = 0)
private long participantClUpdateIntervalSec;
@Valid
@NotNull
private ParticipantUpdateParameters updateParameters;
-
- @Valid
- @NotNull
- private ParticipantStateChangeParameters stateChangeParameters;
-
}
+++ /dev/null
-/*
- * ============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.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.clamp.controlloop.runtime.main.parameters;
-
-import javax.validation.constraints.Min;
-import lombok.Getter;
-import lombok.Setter;
-import org.springframework.validation.annotation.Validated;
-
-/**
- * Parameters for Participant STATE-CHANGE requests.
- */
-@Getter
-@Setter
-@Validated
-public class ParticipantStateChangeParameters {
-
- /**
- * Maximum number of times to re-send a request to a PDP.
- */
- @Min(value = 0)
- private int maxRetryCount;
-
- /**
- * Maximum time to wait, in milliseconds, for a PDP response.
- */
- @Min(value = 0)
- private long maxWaitMs;
-
-}
import org.onap.policy.clamp.controlloop.runtime.supervision.comm.ParticipantControlLoopStateChangePublisher;
import org.onap.policy.clamp.controlloop.runtime.supervision.comm.ParticipantDeregisterAckPublisher;
import org.onap.policy.clamp.controlloop.runtime.supervision.comm.ParticipantRegisterAckPublisher;
-import org.onap.policy.clamp.controlloop.runtime.supervision.comm.ParticipantStateChangePublisher;
import org.onap.policy.clamp.controlloop.runtime.supervision.comm.ParticipantStatusListener;
import org.onap.policy.clamp.controlloop.runtime.supervision.comm.ParticipantUpdatePublisher;
import org.onap.policy.common.endpoints.event.comm.TopicSink;
+++ /dev/null
-/*-
- * ============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.runtime.supervision.comm;
-
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantStateChange;
-import org.springframework.stereotype.Component;
-
-/**
- * This class is used to send ParticipantStateChange messages to participants on DMaaP.
- */
-@Component
-public class ParticipantStateChangePublisher extends AbstractParticipantPublisher<ParticipantStateChange> {
-
-}
runtime:
supervisionScannerIntervalSec: 1000
- participantStateChangeIntervalSec: 1000
participantClUpdateIntervalSec: 1000
participantClStateChangeIntervalSec: 1000
participantParameters:
server.error.path=/error
runtime.supervisionScannerIntervalSec=1000
-runtime.participantStateChangeIntervalSec=1000
runtime.participantClUpdateIntervalSec=1000
runtime.participantClStateChangeIntervalSec=1000
runtime.participantParameters.heartBeatMs=120000
{
"name": "ControlLoopRuntimeGroup",
"supervisionScannerIntervalSec": 1000,
- "participantStateChangeIntervalSec": 1000,
"participantClUpdateIntervalSec": 1000,
"participantClStateChangeIntervalSec": 1000,
"participantParameters": {