2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
6 * Modifications Copyright (C) 2019 Samsung Electronics Co., Ltd.
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
22 package org.onap.policy.common.endpoints.event.comm.bus;
24 import java.util.List;
25 import org.onap.policy.common.endpoints.event.comm.bus.internal.TopicBase;
26 import org.onap.policy.common.utils.slf4j.LoggerFactoryWrapper;
27 import org.slf4j.Logger;
28 import org.slf4j.LoggerFactory;
31 * No Operation topic endpoint.
33 public abstract class NoopTopicEndpoint extends TopicBase {
38 private static Logger logger = LoggerFactory.getLogger(NoopTopicEndpoint.class);
43 private static final Logger netLogger = LoggerFactoryWrapper.getNetworkLogger();
48 public NoopTopicEndpoint(List<String> servers, String topic) {
49 super(servers, topic);
55 * @param message message.
56 * @return true if sucessful.
58 protected boolean io(String message) {
60 if (message == null || message.isEmpty()) {
61 throw new IllegalArgumentException("Message is empty");
65 throw new IllegalStateException(this + " is stopped");
70 this.recentEvents.add(message);
73 netLogger.info("[OUT|{}|{}]{}{}", this.getTopicCommInfrastructure(), this.topic, System.lineSeparator(),
77 } catch (Exception e) {
78 logger.warn("{}: cannot send because of {}", this, e.getMessage(), e);
89 public CommInfrastructure getTopicCommInfrastructure() {
90 return CommInfrastructure.NOOP;
97 public boolean start() {
98 logger.info("{}: starting", this);
100 synchronized (this) {
107 throw new IllegalStateException(this + " is locked.");
120 public boolean stop() {
121 logger.info("{}: stopping", this);
123 synchronized (this) {
133 public void shutdown() {
134 logger.info("{}: shutdown", this);
143 public String toString() {
144 return "NoopTopicEndpoint[" + super.toString() + "]";