aboutsummaryrefslogtreecommitdiffstats
path: root/core/core-infrastructure
diff options
context:
space:
mode:
Diffstat (limited to 'core/core-infrastructure')
-rw-r--r--core/core-infrastructure/src/main/java/org/onap/policy/apex/core/infrastructure/messaging/stringmessaging/WsStringMessageServer.java31
-rw-r--r--core/core-infrastructure/src/main/java/org/onap/policy/apex/core/infrastructure/messaging/util/MessagingUtils.java5
2 files changed, 25 insertions, 11 deletions
diff --git a/core/core-infrastructure/src/main/java/org/onap/policy/apex/core/infrastructure/messaging/stringmessaging/WsStringMessageServer.java b/core/core-infrastructure/src/main/java/org/onap/policy/apex/core/infrastructure/messaging/stringmessaging/WsStringMessageServer.java
index b244feab0..41fb82a9e 100644
--- a/core/core-infrastructure/src/main/java/org/onap/policy/apex/core/infrastructure/messaging/stringmessaging/WsStringMessageServer.java
+++ b/core/core-infrastructure/src/main/java/org/onap/policy/apex/core/infrastructure/messaging/stringmessaging/WsStringMessageServer.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,10 +22,9 @@
package org.onap.policy.apex.core.infrastructure.messaging.stringmessaging;
import com.google.common.eventbus.Subscribe;
-
import java.net.InetAddress;
import java.net.InetSocketAddress;
-
+import java.net.UnknownHostException;
import org.onap.policy.apex.core.infrastructure.messaging.MessageListener;
import org.onap.policy.apex.core.infrastructure.messaging.MessagingException;
import org.onap.policy.apex.core.infrastructure.messaging.MessagingService;
@@ -66,19 +66,32 @@ public class WsStringMessageServer implements WsStringMessager {
*/
@Override
public void start(final WsStringMessageListener newWsStringMessageListener) throws MessagingException {
- this.wsStringMessageListener = newWsStringMessageListener;
LOGGER.entry("web socket event consumer server starting . . .");
+ if (LOGGER.isDebugEnabled()) {
+ String lanaddress = "unknown";
+ try {
+ lanaddress = MessagingUtils.getLocalHostLanAddress().getHostAddress();
+ }
+ catch (final UnknownHostException ignore) {
+ LOGGER.debug("Failed to find name of local address name",ignore);
+ }
+ LOGGER.debug("web socket string message server LAN address=" + lanaddress);
+ String hostaddress = "unknown";
+ try {
+ hostaddress = InetAddress.getLocalHost().getHostAddress();
+ }
+ catch (final UnknownHostException ignore) {
+ LOGGER.debug("Failed to find name of local address",ignore);
+ }
+ LOGGER.debug("web socket string message server host address=" + hostaddress);
+ }
- try {
- final InetAddress addrLan = MessagingUtils.getLocalHostLanAddress();
- LOGGER.debug("web socket string message server LAN address=" + addrLan.getHostAddress());
- final InetAddress addr = InetAddress.getLocalHost();
- LOGGER.debug("web socket string message server host address=" + addr.getHostAddress());
+ this.wsStringMessageListener = newWsStringMessageListener;
+ try {
service = factory.createServer(new InetSocketAddress(port));
service.addMessageListener(new WsStringMessageServerListener());
-
service.startConnection();
} catch (final Exception e) {
LOGGER.warn("web socket string message server start failed", e);
diff --git a/core/core-infrastructure/src/main/java/org/onap/policy/apex/core/infrastructure/messaging/util/MessagingUtils.java b/core/core-infrastructure/src/main/java/org/onap/policy/apex/core/infrastructure/messaging/util/MessagingUtils.java
index a501a66d6..a6c3c5854 100644
--- a/core/core-infrastructure/src/main/java/org/onap/policy/apex/core/infrastructure/messaging/util/MessagingUtils.java
+++ b/core/core-infrastructure/src/main/java/org/onap/policy/apex/core/infrastructure/messaging/util/MessagingUtils.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,7 +29,6 @@ import java.net.NetworkInterface;
import java.net.Socket;
import java.net.UnknownHostException;
import java.util.Enumeration;
-
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
@@ -101,7 +101,7 @@ public final class MessagingUtils {
/**
* Check if port is available or not.
- *
+ *
* @param port the port to test
* @return true if port is available
*/
@@ -118,6 +118,7 @@ public final class MessagingUtils {
* Returns the local host address.
*
* @return the local host address
+ * @throws IllegalStateException if the local host's address cannot be found
*/
public static InetAddress getHost() {
try {