mirror of
https://github.com/PikaMug/Quests.git
synced 2024-11-25 03:55:35 +01:00
Add keepalive property to config, part 1
This commit is contained in:
parent
613ba96e34
commit
731d21deb7
@ -12,7 +12,6 @@
|
|||||||
|
|
||||||
package me.blackvein.quests.storage;
|
package me.blackvein.quests.storage;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
|
||||||
import me.blackvein.quests.Quests;
|
import me.blackvein.quests.Quests;
|
||||||
import me.blackvein.quests.storage.implementation.StorageImplementation;
|
import me.blackvein.quests.storage.implementation.StorageImplementation;
|
||||||
import me.blackvein.quests.storage.implementation.custom.CustomStorageProviders;
|
import me.blackvein.quests.storage.implementation.custom.CustomStorageProviders;
|
||||||
@ -23,8 +22,8 @@ import me.blackvein.quests.storage.misc.StorageCredentials;
|
|||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Collections;
|
import java.util.HashMap;
|
||||||
import java.util.Set;
|
import java.util.Map;
|
||||||
|
|
||||||
public class StorageFactory {
|
public class StorageFactory {
|
||||||
private final Quests plugin;
|
private final Quests plugin;
|
||||||
@ -33,11 +32,6 @@ public class StorageFactory {
|
|||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<StorageType> getRequiredTypes() {
|
|
||||||
return ImmutableSet.of(StorageType.parse(plugin.getConfig().getString("storage-method.player-data", "yaml"),
|
|
||||||
StorageType.YAML));
|
|
||||||
}
|
|
||||||
|
|
||||||
public Storage getInstance() {
|
public Storage getInstance() {
|
||||||
final Storage storage;
|
final Storage storage;
|
||||||
final StorageType type = StorageType.parse(plugin.getConfig().getString("storage-method.player-data", "yaml"),
|
final StorageType type = StorageType.parse(plugin.getConfig().getString("storage-method.player-data", "yaml"),
|
||||||
@ -71,14 +65,20 @@ public class StorageFactory {
|
|||||||
fc.getInt("storage-data.pool-size", 10));
|
fc.getInt("storage-data.pool-size", 10));
|
||||||
final int minIdle = fc.getInt("storage-data.pool-settings.min-idle", maxPoolSize);
|
final int minIdle = fc.getInt("storage-data.pool-settings.min-idle", maxPoolSize);
|
||||||
final int maxLifetime = fc.getInt("storage-data.pool-settings.max-lifetime", 1800000);
|
final int maxLifetime = fc.getInt("storage-data.pool-settings.max-lifetime", 1800000);
|
||||||
|
final int keepAliveTime = fc.getInt("storage-data.pool-settings.keepalive-time", 0);
|
||||||
final int connectionTimeout = fc.getInt("storage-data.pool-settings.connection-timeout", 5000);
|
final int connectionTimeout = fc.getInt("storage-data.pool-settings.connection-timeout", 5000);
|
||||||
|
final boolean useUnicode = fc.getBoolean("storage-data.pool-settings.properties.useUnicode", true);
|
||||||
|
final String characterEncoding = fc.getString("storage-data.pool-settings.properties.characterEncoding", "utf8");
|
||||||
|
Map<String, String> props = new HashMap<>();
|
||||||
|
props.put("useUnicode", String.valueOf(useUnicode));
|
||||||
|
props.put("characterEncoding", characterEncoding);
|
||||||
|
|
||||||
return new StorageCredentials(
|
return new StorageCredentials(
|
||||||
fc.getString("storage-data.address", null),
|
fc.getString("storage-data.address", null),
|
||||||
fc.getString("storage-data.database", null),
|
fc.getString("storage-data.database", null),
|
||||||
fc.getString("storage-data.username", null),
|
fc.getString("storage-data.username", null),
|
||||||
fc.getString("storage-data.password", null),
|
fc.getString("storage-data.password", null),
|
||||||
maxPoolSize, minIdle, maxLifetime, connectionTimeout, Collections.singletonMap("true", "utf8")
|
maxPoolSize, minIdle, maxLifetime, keepAliveTime, connectionTimeout, props
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -101,6 +101,7 @@ public abstract class HikariConnectionFactory implements ConnectionFactory {
|
|||||||
config.setMaximumPoolSize(this.configuration.getMaxPoolSize());
|
config.setMaximumPoolSize(this.configuration.getMaxPoolSize());
|
||||||
config.setMinimumIdle(this.configuration.getMinIdleConnections());
|
config.setMinimumIdle(this.configuration.getMinIdleConnections());
|
||||||
config.setMaxLifetime(this.configuration.getMaxLifetime());
|
config.setMaxLifetime(this.configuration.getMaxLifetime());
|
||||||
|
//config.setKeepaliveTime(this.configuration.getKeepAliveTime());
|
||||||
config.setConnectionTimeout(this.configuration.getConnectionTimeout());
|
config.setConnectionTimeout(this.configuration.getConnectionTimeout());
|
||||||
|
|
||||||
hikari = new HikariDataSource(config);
|
hikari = new HikariDataSource(config);
|
||||||
|
@ -24,12 +24,13 @@ public class StorageCredentials {
|
|||||||
private final int maxPoolSize;
|
private final int maxPoolSize;
|
||||||
private final int minIdleConnections;
|
private final int minIdleConnections;
|
||||||
private final int maxLifetime;
|
private final int maxLifetime;
|
||||||
|
private final int keepAliveTime;
|
||||||
private final int connectionTimeout;
|
private final int connectionTimeout;
|
||||||
private final Map<String, String> properties;
|
private final Map<String, String> properties;
|
||||||
|
|
||||||
public StorageCredentials(final String address, final String database, final String username, final String password,
|
public StorageCredentials(final String address, final String database, final String username, final String password,
|
||||||
final int maxPoolSize, final int minIdleConnections, final int maxLifetime, final int connectionTimeout,
|
final int maxPoolSize, final int minIdleConnections, final int maxLifetime, final int keepAliveTime,
|
||||||
final Map<String, String> properties) {
|
final int connectionTimeout, final Map<String, String> properties) {
|
||||||
this.address = address;
|
this.address = address;
|
||||||
this.database = database;
|
this.database = database;
|
||||||
this.username = username;
|
this.username = username;
|
||||||
@ -37,6 +38,7 @@ public class StorageCredentials {
|
|||||||
this.maxPoolSize = maxPoolSize;
|
this.maxPoolSize = maxPoolSize;
|
||||||
this.minIdleConnections = minIdleConnections;
|
this.minIdleConnections = minIdleConnections;
|
||||||
this.maxLifetime = maxLifetime;
|
this.maxLifetime = maxLifetime;
|
||||||
|
this.keepAliveTime = keepAliveTime;
|
||||||
this.connectionTimeout = connectionTimeout;
|
this.connectionTimeout = connectionTimeout;
|
||||||
this.properties = properties;
|
this.properties = properties;
|
||||||
}
|
}
|
||||||
@ -69,6 +71,10 @@ public class StorageCredentials {
|
|||||||
return maxLifetime;
|
return maxLifetime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getKeepAliveTime() {
|
||||||
|
return keepAliveTime;
|
||||||
|
}
|
||||||
|
|
||||||
public int getConnectionTimeout() {
|
public int getConnectionTimeout() {
|
||||||
return connectionTimeout;
|
return connectionTimeout;
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,11 @@ storage-data:
|
|||||||
max-pool-size: 10
|
max-pool-size: 10
|
||||||
min-idle: 10
|
min-idle: 10
|
||||||
max-lifetime: 1800000
|
max-lifetime: 1800000
|
||||||
|
keepalive-time: 0
|
||||||
connection-timeout: 5000
|
connection-timeout: 5000
|
||||||
|
properties:
|
||||||
|
useUnicode: true
|
||||||
|
characterEncoding: utf8
|
||||||
storage-method:
|
storage-method:
|
||||||
player-data: yaml
|
player-data: yaml
|
||||||
trial-save: false
|
trial-save: false
|
||||||
|
Loading…
Reference in New Issue
Block a user