diff options
author | liamfallon <liam.fallon@est.tech> | 2022-02-11 00:43:14 +0000 |
---|---|---|
committer | liamfallon <liam.fallon@est.tech> | 2022-02-11 00:43:18 +0000 |
commit | f0fd964e343fe5a9cc2044d417fadf6cdd1ef0d1 (patch) | |
tree | c316685cbee53330570bcbf0509bc327ad118196 /plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/main | |
parent | 8534756d13531ffec9c2d7b2ffe0a53ee1d3aaef (diff) |
Remove apex-pdp unused core modules
This is the final review in the refactoring of the model code in
apex-pdp.
The core-messaging and core-infrastructure modules are unused in
apex-pdp except for websocket communication. Websocket communication is
also not used in any deployment.
This review:
- removes the core-mesaging module, which had an apex-specific websocket
implementation, except for the MessageException class, which is moved
to the base core module
- removes the core-infrastructure module, except for the ThreadUtils
class, which is moved to the base core module
- removes the websocket event protocol, which used core-messaging but is
not used in any deployment
- collapses all three "core" submodules into a single module
- Updates dependencies where needed
Issue-ID: POLICY-1820
Change-Id: Ieae30063e99570e61943372d3fa23b77a211462c
Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/main')
4 files changed, 0 insertions, 356 deletions
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/main/java/org/onap/policy/apex/plugins/event/carrier/websocket/ApexWebSocketConsumer.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/main/java/org/onap/policy/apex/plugins/event/carrier/websocket/ApexWebSocketConsumer.java deleted file mode 100644 index c776e154f..000000000 --- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/main/java/org/onap/policy/apex/plugins/event/carrier/websocket/ApexWebSocketConsumer.java +++ /dev/null @@ -1,126 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * * Modifications Copyright (C) 2020 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.apex.plugins.event.carrier.websocket; - -import java.util.Properties; -import org.onap.policy.apex.core.infrastructure.messaging.MessagingException; -import org.onap.policy.apex.core.infrastructure.messaging.stringmessaging.WsStringMessageClient; -import org.onap.policy.apex.core.infrastructure.messaging.stringmessaging.WsStringMessageListener; -import org.onap.policy.apex.core.infrastructure.messaging.stringmessaging.WsStringMessageServer; -import org.onap.policy.apex.core.infrastructure.messaging.stringmessaging.WsStringMessager; -import org.onap.policy.apex.core.infrastructure.threading.ThreadUtilities; -import org.onap.policy.apex.service.engine.event.ApexEventException; -import org.onap.policy.apex.service.engine.event.ApexEventReceiver; -import org.onap.policy.apex.service.engine.event.ApexPluginsEventConsumer; -import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Concrete implementation an Apex event consumer that receives events using Kafka. - * - * @author Liam Fallon (liam.fallon@ericsson.com) - */ -public class ApexWebSocketConsumer extends ApexPluginsEventConsumer implements WsStringMessageListener { - private static final int WEB_SOCKET_WAIT_SLEEP_TIME = 100; - - // Get a reference to the logger - private static final Logger LOGGER = LoggerFactory.getLogger(ApexWebSocketConsumer.class); - - // The web socket messager, may be WS a server or a client - private WsStringMessager wsStringMessager; - - // The event receiver that will receive events from this consumer - private ApexEventReceiver eventReceiver; - - // The number of events read to date - private int eventsRead = 0; - - @Override - public void init(final String consumerName, final EventHandlerParameters consumerParameters, - final ApexEventReceiver incomingEventReceiver) throws ApexEventException { - this.eventReceiver = incomingEventReceiver; - this.name = consumerName; - - // Check and get the Kafka Properties - if (!(consumerParameters.getCarrierTechnologyParameters() instanceof WebSocketCarrierTechnologyParameters)) { - LOGGER.warn("specified consumer properties are not applicable to a web socket consumer"); - throw new ApexEventException("specified consumer properties are not applicable to a web socket consumer"); - } - - // The Web Socket properties - WebSocketCarrierTechnologyParameters webSocketConsumerProperties = - (WebSocketCarrierTechnologyParameters) consumerParameters.getCarrierTechnologyParameters(); - - // Check if this is a server or a client Web Socket - if (webSocketConsumerProperties.isWsClient()) { - // Create a WS client - wsStringMessager = new WsStringMessageClient(webSocketConsumerProperties.getHost(), - webSocketConsumerProperties.getPort()); - } else { - wsStringMessager = new WsStringMessageServer(webSocketConsumerProperties.getPort()); - } - - // Start reception of event strings on the web socket - try { - wsStringMessager.start(this); - } catch (final MessagingException e) { - LOGGER.warn("could not start web socket consumer", e); - } - } - - /** - * {@inheritDoc}. - */ - @Override - public void run() { - while (consumerThread.isAlive() && !stopOrderedFlag) { - ThreadUtilities.sleep(WEB_SOCKET_WAIT_SLEEP_TIME); - } - } - - /** - * {@inheritDoc}. - */ - @Override - public void stop() { - if (wsStringMessager != null) { - wsStringMessager.stop(); - } - stopOrderedFlag = true; - } - - /** - * {@inheritDoc}. - */ - @Override - public void receiveString(final String eventString) { - try { - eventReceiver.receiveEvent(new Properties(), eventString); - eventsRead++; - } catch (final Exception e) { - final String errorMessage = "Error sending event " + name + '_' + eventsRead + ", " + e.getMessage() - + ", event:\n" + eventString; - LOGGER.warn(errorMessage, e); - } - } -} diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/main/java/org/onap/policy/apex/plugins/event/carrier/websocket/ApexWebSocketProducer.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/main/java/org/onap/policy/apex/plugins/event/carrier/websocket/ApexWebSocketProducer.java deleted file mode 100644 index 6256ec425..000000000 --- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/main/java/org/onap/policy/apex/plugins/event/carrier/websocket/ApexWebSocketProducer.java +++ /dev/null @@ -1,112 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2020 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.apex.plugins.event.carrier.websocket; - -import java.util.Properties; -import org.onap.policy.apex.core.infrastructure.messaging.MessagingException; -import org.onap.policy.apex.core.infrastructure.messaging.stringmessaging.WsStringMessageClient; -import org.onap.policy.apex.core.infrastructure.messaging.stringmessaging.WsStringMessageListener; -import org.onap.policy.apex.core.infrastructure.messaging.stringmessaging.WsStringMessageServer; -import org.onap.policy.apex.core.infrastructure.messaging.stringmessaging.WsStringMessager; -import org.onap.policy.apex.service.engine.event.ApexEventException; -import org.onap.policy.apex.service.engine.event.ApexPluginsEventProducer; -import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Concrete implementation of an Apex event producer that sends events using a web socket. - * - * @author Liam Fallon (liam.fallon@ericsson.com) - */ -public class ApexWebSocketProducer extends ApexPluginsEventProducer implements WsStringMessageListener { - // Get a reference to the logger - private static final Logger LOGGER = LoggerFactory.getLogger(ApexWebSocketProducer.class); - - // The web socket messager, may be WS a server or a client - private WsStringMessager wsStringMessager; - - @Override - public void init(final String producerName, final EventHandlerParameters producerParameters) - throws ApexEventException { - this.name = producerName; - - // Check and get the web socket Properties - if (!(producerParameters.getCarrierTechnologyParameters() instanceof WebSocketCarrierTechnologyParameters)) { - String message = - "specified producer properties for " + this.name + "are not applicable to a web socket producer"; - LOGGER.warn(message); - throw new ApexEventException("specified producer properties are not applicable to a web socket producer"); - } - // The Web Socket properties - WebSocketCarrierTechnologyParameters webSocketProducerProperties = - (WebSocketCarrierTechnologyParameters) producerParameters.getCarrierTechnologyParameters(); - - // Check if this is a server or a client Web Socket - if (webSocketProducerProperties.isWsClient()) { - // Create a WS client - wsStringMessager = new WsStringMessageClient(webSocketProducerProperties.getHost(), - webSocketProducerProperties.getPort()); - } else { - wsStringMessager = new WsStringMessageServer(webSocketProducerProperties.getPort()); - } - - // Start reception of event strings on the web socket - try { - wsStringMessager.start(this); - } catch (final MessagingException e) { - String message = "could not start web socket producer (" + this.name + ")"; - LOGGER.warn(message, e); - } - } - - /** - * {@inheritDoc}. - */ - @Override - public void sendEvent(final long executionId, final Properties executionProperties, final String eventName, - final Object event) { - super.sendEvent(executionId, executionProperties, eventName, event); - - wsStringMessager.sendString((String) event); - } - - /** - * {@inheritDoc}. - */ - @Override - public void stop() { - if (wsStringMessager != null) { - wsStringMessager.stop(); - } - } - - /** - * {@inheritDoc}. - */ - @Override - public void receiveString(final String messageString) { - String message = "received message \"" + messageString + "\" on web socket producer (" + this.name - + ") , no messages should be received on a web socket producer"; - LOGGER.warn(message); - } -} diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/main/java/org/onap/policy/apex/plugins/event/carrier/websocket/WebSocketCarrierTechnologyParameters.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/main/java/org/onap/policy/apex/plugins/event/carrier/websocket/WebSocketCarrierTechnologyParameters.java deleted file mode 100644 index 89588ec37..000000000 --- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/main/java/org/onap/policy/apex/plugins/event/carrier/websocket/WebSocketCarrierTechnologyParameters.java +++ /dev/null @@ -1,91 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 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. - * 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.apex.plugins.event.carrier.websocket; - -import lombok.Getter; -import org.apache.commons.lang3.StringUtils; -import org.onap.policy.apex.service.parameters.carriertechnology.CarrierTechnologyParameters; -import org.onap.policy.common.parameters.BeanValidationResult; -import org.onap.policy.common.parameters.ValidationStatus; -import org.onap.policy.common.parameters.annotations.Max; -import org.onap.policy.common.parameters.annotations.Min; -import org.onap.policy.models.base.Validated; - -/** - * Apex parameters for Kafka as an event carrier technology. - * - * @author Liam Fallon (liam.fallon@ericsson.com) - */ -@Getter -public class WebSocketCarrierTechnologyParameters extends CarrierTechnologyParameters { - // @formatter:off - private static final int MIN_USER_PORT = 1024; - private static final int MAX_USER_PORT = 65535; - - /** The label of this carrier technology. */ - public static final String WEB_SCOKET_CARRIER_TECHNOLOGY_LABEL = "WEBSOCKET"; - - /** The producer plugin class for the web socket carrier technology. */ - public static final String WEB_SCOKET_EVENT_PRODUCER_PLUGIN_CLASS = ApexWebSocketProducer.class.getName(); - - /** The consumer plugin class for the web socket carrier technology. */ - public static final String KWEB_SCOKET_EVENT_CONSUMER_PLUGIN_CLASS = ApexWebSocketConsumer.class.getName(); - - // Default parameter values - private static final String DEFAULT_HOST = "localhost"; - private static final int DEFAULT_PORT = -1; - - // Web socket parameters - private boolean wsClient = true; - private String host = DEFAULT_HOST; - @Min(MIN_USER_PORT) - @Max(MAX_USER_PORT) - private int port = DEFAULT_PORT; - // @formatter:on - - /** - * Constructor to create a web socket carrier technology parameters instance and register the instance with the - * parameter service. - */ - public WebSocketCarrierTechnologyParameters() { - super(); - - // Set the carrier technology properties for the web socket carrier technology - this.setLabel(WEB_SCOKET_CARRIER_TECHNOLOGY_LABEL); - this.setEventProducerPluginClass(WEB_SCOKET_EVENT_PRODUCER_PLUGIN_CLASS); - this.setEventConsumerPluginClass(KWEB_SCOKET_EVENT_CONSUMER_PLUGIN_CLASS); - } - - /** - * {@inheritDoc}. - */ - @Override - public BeanValidationResult validate() { - final BeanValidationResult result = super.validate(); - - if (wsClient && StringUtils.isBlank(host)) { - result.addResult("host", host, ValidationStatus.INVALID, Validated.IS_BLANK); - } - - return result; - } -} diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/main/java/org/onap/policy/apex/plugins/event/carrier/websocket/package-info.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/main/java/org/onap/policy/apex/plugins/event/carrier/websocket/package-info.java deleted file mode 100644 index 9555ea447..000000000 --- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/main/java/org/onap/policy/apex/plugins/event/carrier/websocket/package-info.java +++ /dev/null @@ -1,27 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2016-2018 Ericsson. 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. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -/** - * Implements the APEX event carrier technology plugin for web sockets. - * - * @author Liam Fallon (liam.fallon@ericsson.com) - */ - -package org.onap.policy.apex.plugins.event.carrier.websocket; |