Skip to content

Commit d57e80a

Browse files
CritasWangHTHou
authored andcommitted
chore!: Bind real config address for Thrift and Raft services (#16717)
* chore: Bind real internal address for Thrift and Raft services * keep ExternalRpcAddress use config value * Update iotdb-core/datanode/src/main/java/org/apache/iotdb/db/service/ExternalRPCService.java Co-authored-by: Haonan <hhaonan@outlook.com> --------- Co-authored-by: Haonan <hhaonan@outlook.com> (cherry picked from commit 8dbf200)
1 parent 2f3fcbc commit d57e80a

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/ratis/RatisConsensus.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ public RatisConsensus(ConsensusConfig config, IStateMachine.Registry registry) {
156156
this.storageDir = new File(config.getStorageDir());
157157

158158
RaftServerConfigKeys.setStorageDir(properties, Collections.singletonList(storageDir));
159+
GrpcConfigKeys.Server.setHost(properties, config.getThisNodeEndPoint().getIp());
159160
GrpcConfigKeys.Server.setPort(properties, config.getThisNodeEndPoint().getPort());
160161

161162
Utils.initRatisConfig(properties, config.getRatisConfig());

iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/service/AbstractThriftServiceThread.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -271,14 +271,21 @@ private THsHaServer.Args initAsyncedHshaPoolArgs(
271271

272272
@SuppressWarnings("java:S2259")
273273
private TServerTransport openTransport(String bindAddress, int port) throws TTransportException {
274-
// bind any address
275-
return new TServerSocket(new InetSocketAddress(port));
274+
if (bindAddress == null) {
275+
// bind any address
276+
return new TServerSocket(new InetSocketAddress(port));
277+
}
278+
return new TServerSocket(new InetSocketAddress(bindAddress, port));
276279
}
277280

278281
private TServerTransport openNonblockingTransport(
279282
String bindAddress, int port, int connectionTimeoutInMS) throws TTransportException {
280-
// bind any address
281-
return new TNonblockingServerSocket(new InetSocketAddress(port), connectionTimeoutInMS);
283+
if (bindAddress == null) {
284+
// bind any address
285+
return new TNonblockingServerSocket(new InetSocketAddress(port), connectionTimeoutInMS);
286+
}
287+
return new TNonblockingServerSocket(
288+
new InetSocketAddress(bindAddress, port), connectionTimeoutInMS);
282289
}
283290

284291
public void setThreadStopLatch(CountDownLatch threadStopLatch) {

0 commit comments

Comments
 (0)