mirror of
https://github.com/proxiodev/RedisBungee.git
synced 2024-12-23 02:28:01 +00:00
fix mess up in API
This commit is contained in:
parent
8f602407b5
commit
6910c96f67
@ -5,11 +5,13 @@ import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.imaginarycode.minecraft.redisbungee.api.RedisBungeePlugin;
|
||||
import com.imaginarycode.minecraft.redisbungee.api.summoners.JedisClusterSummoner;
|
||||
import com.imaginarycode.minecraft.redisbungee.api.summoners.JedisSummoner;
|
||||
import com.imaginarycode.minecraft.redisbungee.api.summoners.Summoner;
|
||||
import com.imaginarycode.minecraft.redisbungee.api.RedisBungeeMode;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import redis.clients.jedis.Jedis;
|
||||
import redis.clients.jedis.JedisCluster;
|
||||
import redis.clients.jedis.JedisPool;
|
||||
|
||||
import java.net.InetAddress;
|
||||
@ -389,14 +391,15 @@ public class RedisBungeeAPI {
|
||||
|
||||
/**
|
||||
* This gives you instance of Jedis Cluster
|
||||
* WARNING DO NOT USE {@link JedisCluster#close()} it will break the functionally
|
||||
*
|
||||
* @return {@link redis.clients.jedis.JedisCluster}
|
||||
* @since 0.8.0
|
||||
* @throws IllegalStateException if the {@link #getMode()} is not equal to {@link RedisBungeeMode#CLUSTER}
|
||||
*/
|
||||
public Jedis requestClusterJedis() {
|
||||
public JedisCluster requestClusterJedis() {
|
||||
if (getMode() == RedisBungeeMode.CLUSTER) {
|
||||
return ((JedisSummoner) this.plugin.getSummoner()).obtainResource();
|
||||
return ((JedisClusterSummoner) this.plugin.getSummoner()).obtainResource();
|
||||
} else {
|
||||
throw new IllegalStateException("Mode is not " + RedisBungeeMode.CLUSTER);
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ package com.imaginarycode.minecraft.redisbungee.api.config;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import com.imaginarycode.minecraft.redisbungee.api.RedisBungeeMode;
|
||||
import com.imaginarycode.minecraft.redisbungee.api.RedisBungeePlugin;
|
||||
import com.imaginarycode.minecraft.redisbungee.api.summoners.ClusterJedisSummoner;
|
||||
import com.imaginarycode.minecraft.redisbungee.api.summoners.JedisClusterSummoner;
|
||||
import com.imaginarycode.minecraft.redisbungee.api.summoners.JedisSummoner;
|
||||
import com.imaginarycode.minecraft.redisbungee.api.summoners.Summoner;
|
||||
import ninja.leaping.configurate.ConfigurationNode;
|
||||
@ -88,10 +88,10 @@ public interface ConfigLoader {
|
||||
throw new RuntimeException("No redis cluster servers specified");
|
||||
}
|
||||
if (redisPassword != null) {
|
||||
summoner = new ClusterJedisSummoner(new JedisCluster(hostAndPortSet, 5000, 5000, 60, proxyId, redisPassword, poolConfig, useSSL));
|
||||
summoner = new JedisClusterSummoner(new JedisCluster(hostAndPortSet, 5000, 5000, 60, proxyId, redisPassword, poolConfig, useSSL));
|
||||
} else {
|
||||
plugin.logWarn("SSL option is ignored in Cluster mode if no PASSWORD is set");
|
||||
summoner = new ClusterJedisSummoner(new JedisCluster(hostAndPortSet, 5000, 5000, 60, poolConfig));
|
||||
summoner = new JedisClusterSummoner(new JedisCluster(hostAndPortSet, 5000, 5000, 60, poolConfig));
|
||||
}
|
||||
redisBungeeMode = RedisBungeeMode.CLUSTER;
|
||||
} else {
|
||||
|
@ -4,11 +4,11 @@ import redis.clients.jedis.JedisCluster;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class ClusterJedisSummoner implements Summoner<JedisCluster> {
|
||||
public class JedisClusterSummoner implements Summoner<JedisCluster> {
|
||||
public final JedisCluster jedisCluster;
|
||||
private boolean closed = false;
|
||||
|
||||
public ClusterJedisSummoner(JedisCluster jedisCluster) {
|
||||
public JedisClusterSummoner(JedisCluster jedisCluster) {
|
||||
this.jedisCluster = jedisCluster;
|
||||
// test the connection
|
||||
jedisCluster.set("random_data", "0");
|
@ -2,7 +2,7 @@ package com.imaginarycode.minecraft.redisbungee.api.tasks;
|
||||
|
||||
import com.imaginarycode.minecraft.redisbungee.RedisBungeeAPI;
|
||||
import com.imaginarycode.minecraft.redisbungee.api.RedisBungeePlugin;
|
||||
import com.imaginarycode.minecraft.redisbungee.api.summoners.ClusterJedisSummoner;
|
||||
import com.imaginarycode.minecraft.redisbungee.api.summoners.JedisClusterSummoner;
|
||||
import com.imaginarycode.minecraft.redisbungee.api.summoners.JedisSummoner;
|
||||
import com.imaginarycode.minecraft.redisbungee.api.summoners.Summoner;
|
||||
import com.imaginarycode.minecraft.redisbungee.api.RedisBungeeMode;
|
||||
@ -71,8 +71,8 @@ public abstract class RedisTask<V> implements Runnable, Callable<V> {
|
||||
|
||||
} else if (api.getMode() == RedisBungeeMode.CLUSTER) {
|
||||
// Jedis cluster does not need new instance since its single instance anyways.
|
||||
ClusterJedisSummoner clusterJedisSummoner = (ClusterJedisSummoner) summoner;
|
||||
return this.clusterJedisTask(clusterJedisSummoner.obtainResource());
|
||||
JedisClusterSummoner jedisClusterSummoner = (JedisClusterSummoner) summoner;
|
||||
return this.clusterJedisTask(jedisClusterSummoner.obtainResource());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -6,12 +6,9 @@ import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMultimap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import com.google.inject.Inject;
|
||||
import com.imaginarycode.minecraft.redisbungee.api.*;
|
||||
import com.imaginarycode.minecraft.redisbungee.api.config.RedisBungeeConfiguration;
|
||||
import com.imaginarycode.minecraft.redisbungee.api.summoners.ClusterJedisSummoner;
|
||||
import com.imaginarycode.minecraft.redisbungee.api.summoners.JedisSummoner;
|
||||
import com.imaginarycode.minecraft.redisbungee.api.summoners.Summoner;
|
||||
import com.imaginarycode.minecraft.redisbungee.api.tasks.HeartbeatTask;
|
||||
import com.imaginarycode.minecraft.redisbungee.api.tasks.RedisTask;
|
||||
@ -40,10 +37,6 @@ import com.velocitypowered.api.proxy.messages.ChannelIdentifier;
|
||||
import com.velocitypowered.api.proxy.messages.LegacyChannelIdentifier;
|
||||
import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier;
|
||||
import com.velocitypowered.api.scheduler.ScheduledTask;
|
||||
import ninja.leaping.configurate.ConfigurationNode;
|
||||
import ninja.leaping.configurate.objectmapping.ObjectMappingException;
|
||||
import ninja.leaping.configurate.yaml.YAMLConfigurationLoader;
|
||||
import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
|
||||
import org.slf4j.Logger;
|
||||
import redis.clients.jedis.*;
|
||||
import redis.clients.jedis.exceptions.JedisConnectionException;
|
||||
|
Loading…
Reference in New Issue
Block a user