Skip to content
Permalink
Browse files
fix: use ip instead of hostname due to can't resolved on k8s (#73)
  • Loading branch information
coderzc committed Jul 28, 2021
1 parent 6686f63 commit eb7a949a148179ec13237267386740c4153948c3
Showing 3 changed files with 12 additions and 2 deletions.
@@ -26,6 +26,7 @@
import com.baidu.hugegraph.computer.core.io.RandomAccessOutput;
import com.baidu.hugegraph.computer.core.io.Readable;
import com.baidu.hugegraph.computer.core.io.Writable;
import com.baidu.hugegraph.computer.core.network.TransportUtil;
import com.baidu.hugegraph.computer.core.util.JsonUtil;
import com.baidu.hugegraph.util.E;

@@ -92,7 +93,7 @@ public String uniqueName() {
}

public void updateAddress(InetSocketAddress address) {
this.hostname = address.getHostName();
this.hostname = TransportUtil.host(address);
this.dataPort = address.getPort();
}

@@ -40,6 +40,7 @@
import com.baidu.hugegraph.computer.core.graph.value.ValueType;
import com.baidu.hugegraph.computer.core.input.MasterInputManager;
import com.baidu.hugegraph.computer.core.manager.Managers;
import com.baidu.hugegraph.computer.core.network.TransportUtil;
import com.baidu.hugegraph.computer.core.rpc.MasterRpcManager;
import com.baidu.hugegraph.computer.core.worker.WorkerStat;
import com.baidu.hugegraph.util.E;
@@ -84,7 +85,7 @@ public void init(Config config) {
InetSocketAddress rpcAddress = this.initManagers();

this.masterInfo = new ContainerInfo(ContainerInfo.MASTER_ID,
rpcAddress.getHostName(),
TransportUtil.host(rpcAddress),
rpcAddress.getPort());
/*
* Connect to BSP server and clean the old data may be left by the
@@ -90,6 +90,14 @@ public static InetSocketAddress resolvedSocketAddress(String host,
return resolvedAddress;
}

public static String host(InetSocketAddress socketAddress) {
InetAddress address = socketAddress.getAddress();
if (address != null) {
return address.getHostAddress();
}
return socketAddress.getHostName();
}

public static List<String> getLocalIPAddress() {
List<String> ips = new ArrayList<>();
try {

0 comments on commit eb7a949

Please sign in to comment.