You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by up...@apache.org on 2021/03/16 18:54:42 UTC
[geode] 09/36: Pass bind address to BucketRetrievalFunction
This is an automated email from the ASF dual-hosted git repository.
upthewaterspout pushed a commit to branch feature/redis-performance-testing
in repository https://gitbox.apache.org/repos/asf/geode.git
commit 1ae02876b621517b0470fbb777eb1ea72fdbf211
Author: Jens Deppe <jd...@vmware.com>
AuthorDate: Wed Feb 24 07:54:59 2021 -0800
Pass bind address to BucketRetrievalFunction
---
.../geode/redis/internal/GeodeRedisServer.java | 2 +-
.../internal/cluster/BucketRetrievalFunction.java | 25 +++++++++++-----------
2 files changed, 14 insertions(+), 13 deletions(-)
diff --git a/geode-redis/src/main/java/org/apache/geode/redis/internal/GeodeRedisServer.java b/geode-redis/src/main/java/org/apache/geode/redis/internal/GeodeRedisServer.java
index 880fee2..4d970db 100644
--- a/geode-redis/src/main/java/org/apache/geode/redis/internal/GeodeRedisServer.java
+++ b/geode-redis/src/main/java/org/apache/geode/redis/internal/GeodeRedisServer.java
@@ -104,7 +104,7 @@ public class GeodeRedisServer {
this::allowUnsupportedCommands, this::shutdown, port, bindAddress, redisStats,
redisCommandExecutor);
- BucketRetrievalFunction.register(nettyRedisServer.getPort());
+ BucketRetrievalFunction.register(bindAddress, nettyRedisServer.getPort());
}
@VisibleForTesting
diff --git a/geode-redis/src/main/java/org/apache/geode/redis/internal/cluster/BucketRetrievalFunction.java b/geode-redis/src/main/java/org/apache/geode/redis/internal/cluster/BucketRetrievalFunction.java
index 48c4fb6..939cabb 100644
--- a/geode-redis/src/main/java/org/apache/geode/redis/internal/cluster/BucketRetrievalFunction.java
+++ b/geode-redis/src/main/java/org/apache/geode/redis/internal/cluster/BucketRetrievalFunction.java
@@ -32,25 +32,26 @@ import org.apache.geode.redis.internal.data.ByteArrayWrapper;
public class BucketRetrievalFunction implements InternalFunction<Void> {
public static final String ID = "REDIS_BUCKET_SLOT_FUNCTION";
- private static final String hostAddress;
+ private final String hostAddress;
private final int redisPort;
- static {
- InetAddress localhost = null;
- try {
- localhost = LocalHostUtil.getLocalHost();
- } catch (Exception ex) {
+ private BucketRetrievalFunction(String address, int redisPort) {
+ if (address == null || address.isEmpty() || address.equals("0.0.0.0")) {
+ InetAddress localhost = null;
+ try {
+ localhost = LocalHostUtil.getLocalHost();
+ } catch (Exception ignored) {
+ }
+ hostAddress = localhost == null ? "localhost" : localhost.getHostAddress();
+ } else {
+ hostAddress = address;
}
- hostAddress = localhost == null ? "localhost" : localhost.getHostAddress();
- }
-
- public BucketRetrievalFunction(int redisPort) {
this.redisPort = redisPort;
}
- public static void register(int redisPort) {
- FunctionService.registerFunction(new BucketRetrievalFunction(redisPort));
+ public static void register(String address, int redisPort) {
+ FunctionService.registerFunction(new BucketRetrievalFunction(address, redisPort));
}
@Override