Remove unneeded threadpool (testing has shown for it to be unneeded)
This commit is contained in:
parent
afab303292
commit
8244cf4974
@ -39,8 +39,11 @@ public class RedisManager extends BinaryJedisPubSub implements Runnable {
|
||||
this.plugin = plugin;
|
||||
Configuration config = this.plugin.getConfig();
|
||||
JedisPoolConfig JConfig = new JedisPoolConfig();
|
||||
JConfig.setMaxTotal(config.getInt("Redis.MaxConnections"));
|
||||
JConfig.setMaxIdle(config.getInt("Redis.MaxConnections"));
|
||||
int maxConnections = config.getInt("Redis.MaxConnections");
|
||||
if (maxConnections < 2) { maxConnections = 2; }
|
||||
|
||||
JConfig.setMaxTotal(maxConnections);
|
||||
JConfig.setMaxIdle(maxConnections);
|
||||
JConfig.setMinIdle(1);
|
||||
JConfig.setBlockWhenExhausted(true);
|
||||
this.jedisPool = new JedisPool(JConfig,
|
||||
@ -49,7 +52,7 @@ public class RedisManager extends BinaryJedisPubSub implements Runnable {
|
||||
config.getInt("Redis.TimeOut"),
|
||||
config.getString("Redis.Password"),
|
||||
config.getBoolean("Redis.useTLS"));
|
||||
RedisService = Executors.newFixedThreadPool(config.getInt("Redis.Threads"));
|
||||
RedisService = Executors.newSingleThreadExecutor();
|
||||
try {
|
||||
this.subscribeJedis = this.jedisPool.getResource();
|
||||
} catch (Exception ignored) {
|
||||
@ -73,7 +76,6 @@ public class RedisManager extends BinaryJedisPubSub implements Runnable {
|
||||
int byteArr2dSize = 1;
|
||||
byte[][] channelsInByte = new byte[channels.size()][byteArr2dSize];
|
||||
boolean reInitializeByteArray;
|
||||
|
||||
// Loop that reInitialize array IF array size is not enough
|
||||
do {
|
||||
reInitializeByteArray = false;
|
||||
@ -91,6 +93,7 @@ public class RedisManager extends BinaryJedisPubSub implements Runnable {
|
||||
} while (reInitializeByteArray);
|
||||
this.subscribeJedis.subscribe(this, channelsInByte);
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
plugin.getLogger().warning(ChatColor.translateAlternateColorCodes('&', "&2[&aRediSkript&a] &cConnection to redis has failed! &ereconnecting..."));
|
||||
if (this.subscribeJedis != null) {
|
||||
@ -157,10 +160,6 @@ public class RedisManager extends BinaryJedisPubSub implements Runnable {
|
||||
return jedisPool;
|
||||
}
|
||||
|
||||
public ExecutorService getRedisService() {
|
||||
return RedisService;
|
||||
}
|
||||
|
||||
public Encryption getEncryption() {
|
||||
return encryption;
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ import java.nio.charset.StandardCharsets;
|
||||
|
||||
public class EffSendMessage extends Effect {
|
||||
static {
|
||||
Skript.registerEffect(EffSendMessage.class, "send redis message to channel %string% with [message] %string%", "send redis message %string% to [channel] %string%");
|
||||
Skript.registerEffect(EffSendMessage.class, "send redis message %string% to [channel] %string%");
|
||||
}
|
||||
|
||||
|
||||
@ -43,7 +43,7 @@ public class EffSendMessage extends Effect {
|
||||
}
|
||||
assert plugin != null;
|
||||
RedisManager manager = plugin.getRm();
|
||||
manager.getRedisService().execute(() -> {
|
||||
//manager.getRedisService().execute(() -> {
|
||||
BinaryJedis j = manager.getJedisPool().getResource();
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("Message", message);
|
||||
@ -57,7 +57,7 @@ public class EffSendMessage extends Effect {
|
||||
}
|
||||
j.publish(channel.getBytes(StandardCharsets.UTF_8), msg);
|
||||
j.close();
|
||||
});
|
||||
//});
|
||||
|
||||
}
|
||||
|
||||
@ -69,13 +69,8 @@ public class EffSendMessage extends Effect {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public boolean init(Expression<?>[] expressions, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parser) {
|
||||
if (matchedPattern == 0) {
|
||||
this.channel = (Expression<String>) expressions[0];
|
||||
this.message = (Expression<String>) expressions[1];
|
||||
} else {
|
||||
this.channel = (Expression<String>) expressions[1];
|
||||
this.message = (Expression<String>) expressions[0];
|
||||
}
|
||||
this.channel = (Expression<String>) expressions[1];
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -3,8 +3,8 @@ Redis:
|
||||
#it is also recommended to firewall your redis server with iptables so it can only be accessed by specific IP addresses
|
||||
Password: "yHy0d2zdBlRmaSPj3CiBwEv5V3XxBTLTrCsGW7ntBnzhfxPxXJS6Q1aTtR6DSfAtCZr2VxWnsungXHTcF94a4bsWEpGAvjL9XMU"
|
||||
Host: "127.0.0.1"
|
||||
MaxConnections: 20
|
||||
Threads: 10
|
||||
#must be 2 or higher, if you set to lower, the addon will automatically use 2 as a minimum
|
||||
MaxConnections: 2
|
||||
#the default Redis port
|
||||
Port: 6379
|
||||
#time out in milliseconds, how long it should take before it decides that it is unable to connect when sending a message
|
||||
|
Loading…
Reference in New Issue
Block a user