diff options
author | 2019-07-02 15:50:56 +0000 | |
---|---|---|
committer | 2019-07-02 15:50:56 +0000 | |
commit | 9f0678f3ab333949076b5b9747158cf40e08fbef (patch) | |
tree | 6cd31546cbbda461eb90518df0af867ccf0066bd /core/core-deployment/src/main | |
parent | 791ef7832edc7478ec344ed47c90aa5826e95b8e (diff) |
ApexPDP: Fixed jenkin failure in Nordix
getLocalHost() fails in Nordix jenkins test build - misconfiguration of
nordix jenkins vms/containers
Change-Id: I726fc141ced07f15cfaa8a9815b4d090dbb74c9a
Issue-ID: POLICY-1879
Signed-off-by: JohnKeeney <John.Keeney@est.tech>
Diffstat (limited to 'core/core-deployment/src/main')
-rw-r--r-- | core/core-deployment/src/main/java/org/onap/policy/apex/core/deployment/DeploymentClient.java | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/core/core-deployment/src/main/java/org/onap/policy/apex/core/deployment/DeploymentClient.java b/core/core-deployment/src/main/java/org/onap/policy/apex/core/deployment/DeploymentClient.java index eb51271d5..900e0a2f8 100644 --- a/core/core-deployment/src/main/java/org/onap/policy/apex/core/deployment/DeploymentClient.java +++ b/core/core-deployment/src/main/java/org/onap/policy/apex/core/deployment/DeploymentClient.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,12 +22,12 @@ package org.onap.policy.apex.core.deployment; import com.google.common.eventbus.Subscribe; - +import java.net.InetAddress; import java.net.URI; +import java.net.UnknownHostException; import java.util.concurrent.BlockingQueue; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.TimeUnit; - import org.onap.policy.apex.core.infrastructure.messaging.MessageHolder; import org.onap.policy.apex.core.infrastructure.messaging.MessageListener; import org.onap.policy.apex.core.infrastructure.messaging.MessagingService; @@ -66,7 +67,7 @@ public class DeploymentClient implements Runnable { // Thread management fields private boolean started = false; private Thread thisThread = null; - + // Number of messages processed private long messagesSent = 0; private long messagesReceived = 0; @@ -127,7 +128,8 @@ public class DeploymentClient implements Runnable { } // Send the message in its message holder - final MessageHolder<Message> messageHolder = new MessageHolder<>(MessagingUtils.getHost()); + InetAddress local = getLocalAddress(); + final MessageHolder<Message> messageHolder = new MessageHolder<>(local); messageHolder.addMessage(messageForSending); service.send(messageHolder); messagesSent++; @@ -138,11 +140,24 @@ public class DeploymentClient implements Runnable { thisThread.interrupt(); return false; } - + return true; } /** + * Get the local address for the WS MessageHolder, or null if there is a problem. + */ + private InetAddress getLocalAddress() { + try { + return MessagingUtils.getLocalHostLanAddress(); + } + catch (UnknownHostException e) { + LOGGER.debug("engine<-->deployment client failed to find the localhost address - continuing ...", e); + return null; + } + } + + /** * Gets the host. * * @return the host |