in dubbo-registry-extensions/dubbo-registry-redis/src/main/java/org/apache/dubbo/registry/redis/RedisRegistry.java [104:137]
public RedisRegistry(URL url) {
super(url);
String type = url.getParameter(REDIS_CLIENT_KEY, MONO_REDIS);
if (SENTINEL_REDIS.equals(type)) {
redisClient = new SentinelRedisClient(url);
} else if (CLUSTER_REDIS.equals(type)) {
redisClient = new ClusterRedisClient(url);
} else {
redisClient = new MonoRedisClient(url);
}
if (url.isAnyHost()) {
throw new IllegalStateException("registry address == null");
}
this.reconnectPeriod = url.getParameter(REGISTRY_RECONNECT_PERIOD_KEY, DEFAULT_REGISTRY_RECONNECT_PERIOD);
String group = url.getParameter(GROUP_KEY, DEFAULT_ROOT);
if (!group.startsWith(PATH_SEPARATOR)) {
group = PATH_SEPARATOR + group;
}
if (!group.endsWith(PATH_SEPARATOR)) {
group = group + PATH_SEPARATOR;
}
this.root = group;
this.expirePeriod = url.getParameter(SESSION_TIMEOUT_KEY, DEFAULT_SESSION_TIMEOUT);
this.expireFuture = expireExecutor.scheduleWithFixedDelay(() -> {
try {
deferExpired(); // Extend the expiration time
} catch (Throwable t) { // Defensive fault tolerance
logger.error("Unexpected exception occur at defer expire time, cause: " + t.getMessage(), t);
}
}, expirePeriod / 2, expirePeriod / 2, TimeUnit.MILLISECONDS);
}