Hi,
I don't know if you can directly pull the change from our rep at
git://
git.berlios.de/s4fokus. So I'll also paste the patch below.
Max
Date: Wed, 20 Apr 2011 10:42:13 +0200
Subject: [PATCH] Fix handling of hostnames for task assignment
---
.../java/io/s4/comm/file/StaticTaskManager.java | 24 ++++++++++++
++++---
1 files changed, 20 insertions(+), 4 deletions(-)
diff --git a/src/main/java/io/s4/comm/file/StaticTaskManager.java b/
src/main/java/io/s4/comm/file/StaticTaskManager.java
index 89836d3..1c18b51 100644
--- a/src/main/java/io/s4/comm/file/StaticTaskManager.java
+++ b/src/main/java/io/s4/comm/file/StaticTaskManager.java
@@ -25,6 +25,7 @@ import
io.s4.comm.util.ConfigParser.Cluster.ClusterType;
import java.io.File;
import java.io.FileOutputStream;
import java.net.InetAddress;
+import java.net.NetworkInterface;
import java.nio.channels.FileLock;
import java.util.HashMap;
import java.util.HashSet;
@@ -162,16 +163,31 @@ public class StaticTaskManager implements
TaskManager {
}
}
+ private boolean isAddressValid(InetAddress inetAddress) {
+ boolean result = false;
+ try {
+ if (InetAddress.getLocalHost().equals(inetAddress)) {
+ result = true;
+ } else {
+ result =
NetworkInterface.getByInetAddress(inetAddress) != null;
+ }
+ } catch (Exception e) {
+ logger.warn(e.getMessage(), e);
+ result = false;
+ }
+ return result;
+ }
+
private boolean canTakeupProcess(Map<String, String>
processConfig) {
String host = processConfig.get("process.host");
try {
InetAddress inetAddress = InetAddress.getByName(host);
logger.info("Host Name: "
+
InetAddress.getLocalHost().getCanonicalHostName());
- if (!host.equals("localhost")) {
- if (!InetAddress.getLocalHost().equals(inetAddress))
{
- return false;
- }
+ if (!isAddressValid(inetAddress)) {
+ logger.error(host + " is not a valid address for this
machine."+
+ " Check the configuration.");
+ return false;
}
} catch (Exception e) {
logger.error("Invalid host:" + host);
--
1.7.0.4