diff options
author | Liam Fallon <liam.fallon@est.tech> | 2019-03-18 23:01:15 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2019-03-18 23:01:15 +0000 |
commit | 5d8847cef17818f95b1dd6eebbd01be8ea7ed662 (patch) | |
tree | 839e9255a022b70f0d1de3e094927d2a480724d8 /policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event | |
parent | 146284191ee01ea92441fdf3159e9dcd84a6f11a (diff) | |
parent | 57a44626324326fc3b29042398d2ccdaec5a7758 (diff) |
Merge "Add Network Logging Feature"
Diffstat (limited to 'policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event')
5 files changed, 21 insertions, 26 deletions
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicEndpoint.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicEndpoint.java index a2ad4d3d..ef002f52 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicEndpoint.java +++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicEndpoint.java @@ -23,7 +23,8 @@ package org.onap.policy.common.endpoints.event.comm.bus; import java.util.List; import org.onap.policy.common.endpoints.event.comm.bus.internal.TopicBase; -import org.onap.policy.common.utils.slf4j.LoggerFactoryWrapper; +import org.onap.policy.common.endpoints.utils.NetLoggerUtil; +import org.onap.policy.common.endpoints.utils.NetLoggerUtil.EventType; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -38,11 +39,6 @@ public abstract class NoopTopicEndpoint extends TopicBase { private static Logger logger = LoggerFactory.getLogger(NoopTopicEndpoint.class); /** - * Network logger. - */ - private static final Logger netLogger = LoggerFactoryWrapper.getNetworkLogger(); - - /** * {@inheritDoc}. */ public NoopTopicEndpoint(List<String> servers, String topic) { @@ -52,10 +48,11 @@ public abstract class NoopTopicEndpoint extends TopicBase { /** * I/O. * + * @param type "IN" or "OUT". * @param message message. - * @return true if sucessful. + * @return true if successful. */ - protected boolean io(String message) { + protected boolean io(EventType type, String message) { if (message == null || message.isEmpty()) { throw new IllegalArgumentException("Message is empty"); @@ -70,8 +67,7 @@ public abstract class NoopTopicEndpoint extends TopicBase { this.recentEvents.add(message); } - netLogger.info("[OUT|{}|{}]{}{}", this.getTopicCommInfrastructure(), this.topic, System.lineSeparator(), - message); + NetLoggerUtil.log(type, this.getTopicCommInfrastructure(), this.topic, message); broadcast(message); } catch (Exception e) { diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicSink.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicSink.java index f6ad433d..d3745940 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicSink.java +++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicSink.java @@ -7,9 +7,9 @@ * 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. @@ -22,6 +22,7 @@ package org.onap.policy.common.endpoints.event.comm.bus; import java.util.List; import org.onap.policy.common.endpoints.event.comm.TopicSink; +import org.onap.policy.common.endpoints.utils.NetLoggerUtil.EventType; /** * No Operation Topic Sink. @@ -45,7 +46,7 @@ public class NoopTopicSink extends NoopTopicEndpoint implements TopicSink { */ @Override public boolean send(String message) { - return super.io(message); + return super.io(EventType.OUT, message); } /** diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicSource.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicSource.java index c3215e04..95ed0fe6 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicSource.java +++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicSource.java @@ -22,6 +22,7 @@ package org.onap.policy.common.endpoints.event.comm.bus; import java.util.List; import org.onap.policy.common.endpoints.event.comm.TopicSource; +import org.onap.policy.common.endpoints.utils.NetLoggerUtil.EventType; /** * No Operation Topic Source. @@ -45,7 +46,7 @@ public class NoopTopicSource extends NoopTopicEndpoint implements TopicSource { */ @Override public boolean offer(String event) { - return super.io(event); + return super.io(EventType.IN, event); } /** diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineBusTopicSink.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineBusTopicSink.java index d6ca824e..e94bdffa 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineBusTopicSink.java +++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineBusTopicSink.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * policy-endpoints * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2018-2019 Samsung Electronics Co., Ltd. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -24,7 +24,8 @@ package org.onap.policy.common.endpoints.event.comm.bus.internal; import java.util.UUID; import org.onap.policy.common.endpoints.event.comm.bus.BusTopicSink; -import org.onap.policy.common.utils.slf4j.LoggerFactoryWrapper; +import org.onap.policy.common.endpoints.utils.NetLoggerUtil; +import org.onap.policy.common.endpoints.utils.NetLoggerUtil.EventType; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -39,7 +40,6 @@ public abstract class InlineBusTopicSink extends BusTopicBase implements BusTopi * Loggers. */ private static Logger logger = LoggerFactory.getLogger(InlineBusTopicSink.class); - private static final Logger netLogger = LoggerFactoryWrapper.getNetworkLogger(); /** * The partition key to publish to. @@ -140,8 +140,7 @@ public abstract class InlineBusTopicSink extends BusTopicBase implements BusTopi this.recentEvents.add(message); } - netLogger.info("[OUT|{}|{}]{}{}", this.getTopicCommInfrastructure(), this.topic, System.lineSeparator(), - message); + NetLoggerUtil.log(EventType.OUT, this.getTopicCommInfrastructure(), this.topic, message); publisher.send(this.partitionId, message); broadcast(message); diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedBusTopicSource.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedBusTopicSource.java index 83f3760b..98e30e27 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedBusTopicSource.java +++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedBusTopicSource.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * policy-endpoints * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2018-2019 Samsung Electronics Co., Ltd. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -28,8 +28,9 @@ import org.onap.policy.common.endpoints.event.comm.FilterableTopicSource; import org.onap.policy.common.endpoints.event.comm.TopicListener; import org.onap.policy.common.endpoints.event.comm.bus.BusTopicSource; import org.onap.policy.common.endpoints.event.comm.bus.internal.BusConsumer.FilterableBusConsumer; +import org.onap.policy.common.endpoints.utils.NetLoggerUtil; +import org.onap.policy.common.endpoints.utils.NetLoggerUtil.EventType; import org.onap.policy.common.utils.network.NetworkUtil; -import org.onap.policy.common.utils.slf4j.LoggerFactoryWrapper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -45,7 +46,6 @@ public abstract class SingleThreadedBusTopicSource extends BusTopicBase * that in a single file in a concise format. */ private static Logger logger = LoggerFactory.getLogger(InlineBusTopicSink.class); - private static final Logger netLogger = LoggerFactoryWrapper.getNetworkLogger(); /** * Bus consumer group. @@ -228,8 +228,7 @@ public abstract class SingleThreadedBusTopicSource extends BusTopicBase this.recentEvents.add(event); } - netLogger.info("[IN|{}|{}]{}{}", this.getTopicCommInfrastructure(), this.topic, - System.lineSeparator(), event); + NetLoggerUtil.log(EventType.IN, this.getTopicCommInfrastructure(), this.topic, event); broadcast(event); @@ -255,8 +254,7 @@ public abstract class SingleThreadedBusTopicSource extends BusTopicBase this.recentEvents.add(event); } - netLogger.info("[IN|{}|{}]{}{}", this.getTopicCommInfrastructure(), this.topic, System.lineSeparator(), event); - + NetLoggerUtil.log(EventType.IN, this.getTopicCommInfrastructure(), this.topic, event); return broadcast(event); } |