Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ### Eclipse Workspace Patch 1.0
- #P L2JHellasC
- Index: config/Network/LoginServer.ini
- ===================================================================
- --- config/Network/LoginServer.ini (revision 462)
- +++ config/Network/LoginServer.ini (working copy)
- @@ -19,18 +19,13 @@
- # It is highly recommended for Account Security to leave this option as default (True)
- ShowLicence = True
- -# ============= #
- -# Database info #
- -# ============= #
- -Driver=com.mysql.jdbc.Driver
- -# Driver=org.hsqldb.jdbcDriver
- -# Driver=com.microsoft.sqlserver.jdbc.SQLServerDriver
- -URL=jdbc:mysql://localhost/l2jhellas
- +# ========================== #
- +# Database Information #
- +# ========================== #
- +DatabaseName = l2jhellas
- +DatabaseUsername = root
- +DatabasePassword =
- -Login = root
- -Password =
- -MaximumDbConnections = 10
- -
- # Useable values: "True" - "False", use this option to choose whether accounts will be created
- # automatically or not.
- # Retail : False
- Index: .classpath
- ===================================================================
- --- .classpath (revision 462)
- +++ .classpath (working copy)
- @@ -15,10 +13,9 @@
- <classpathentry exported="true" kind="lib" path="libs/jython.jar"/>
- <classpathentry exported="true" kind="lib" path="libs/mail.jar"/>
- <classpathentry exported="true" kind="lib" path="libs/mmocore.jar"/>
- <classpathentry exported="true" kind="lib" path="libs/Subnet-1.0.jar"/>
- <classpathentry exported="true" kind="lib" path="libs/worldwind.jar"/>
- + <classpathentry exported="true" kind="lib" path="libs/mysql-connector-java-5.1.33-bin.jar"/>
- + <classpathentry exported="true" kind="lib" path="libs/HikariCP-java6-2.1.0.jar"/>
- <classpathentry kind="output" path="bin"/>
- </classpath>
- Index: config/Network/GameServer.ini
- ===================================================================
- --- config/Network/GameServer.ini (revision 462)
- +++ config/Network/GameServer.ini (working copy)
- @@ -40,28 +40,17 @@
- # This is the server id that the gameserver will request (i.e. 1 is Bartz)
- RequestServerID = 1
- -# If set to True, the login will give an other id to the server if the requested id is allready reserved
- +# If set to True, the login will give an other id to the server if the requested id is already reserved
- AcceptAlternateID = True
- # ========================== #
- # Database Information #
- # ========================== #
- -# Drivers: org.hsqldb.jdbcDriver
- -# or com.mysql.jdbc.Driver
- -# or com.microsoft.sqlserver.jdbc.SQLServerDriver
- -# Default:
- -Driver = com.mysql.jdbc.Driver
- +DatabaseName = l2jhellas
- +DatabaseUsername = root
- +DatabasePassword =
- Index: java/com/l2jhellas/Config.java
- ===================================================================
- --- java/com/l2jhellas/Config.java (revision 462)
- +++ java/com/l2jhellas/Config.java (working copy)
- @@ -1128,11 +1128,9 @@
- public static boolean PURGE_ERROR_LOG;
- public static int REQUEST_ID;
- public static boolean ACCEPT_ALTERNATE_ID;
- - public static String DATABASE_DRIVER;
- - public static String DATABASE_URL;
- - public static String DATABASE_LOGIN;
- + public static String DATABASE_NAME;
- + public static String DATABASE_USERNAME;
- public static String DATABASE_PASSWORD;
- - public static int DATABASE_MAX_CONNECTIONS;
- public static String CNAME_TEMPLATE;
- public static String PET_NAME_TEMPLATE;
- public static int MAX_CHARACTERS_NUMBER_PER_ACCOUNT;
- @@ -3143,11 +3141,9 @@
- PURGE_ERROR_LOG = Boolean.parseBoolean(serverSettings.getProperty("PurgeErrorLog", "False"));
- REQUEST_ID = Integer.parseInt(serverSettings.getProperty("RequestServerID", "0"));
- ACCEPT_ALTERNATE_ID = Boolean.parseBoolean(serverSettings.getProperty("AcceptAlternateID", "True"));
- - DATABASE_DRIVER = serverSettings.getProperty("Driver", "com.mysql.jdbc.Driver");
- - DATABASE_URL = serverSettings.getProperty("URL", "jdbc:mysql://localhost/l2jdb");
- - DATABASE_LOGIN = serverSettings.getProperty("Login", "root");
- - DATABASE_PASSWORD = serverSettings.getProperty("Password", "");
- - DATABASE_MAX_CONNECTIONS = Integer.parseInt(serverSettings.getProperty("MaximumDbConnections", "10"));
- + DATABASE_NAME = serverSettings.getProperty("DatabaseName", "l2jhellas");
- + DATABASE_USERNAME = serverSettings.getProperty("DatabaseUsername", "root");
- + DATABASE_PASSWORD = serverSettings.getProperty("DatabasePassword", "");
- CNAME_TEMPLATE = serverSettings.getProperty("CnameTemplate", ".*");
- PET_NAME_TEMPLATE = serverSettings.getProperty("PetNameTemplate", ".*");
- MAX_CHARACTERS_NUMBER_PER_ACCOUNT = Integer.parseInt(serverSettings.getProperty("CharMaxNumber", "0"));
- @@ -3264,11 +3260,9 @@
- ACCEPT_ALTERNATE_ID = Boolean.parseBoolean(serverSettings.getProperty("AcceptAlternateID", "True"));
- LOGIN_TRY_BEFORE_BAN = Integer.parseInt(serverSettings.getProperty("LoginTryBeforeBan", "10"));
- LOGIN_BLOCK_AFTER_BAN = Integer.parseInt(serverSettings.getProperty("LoginBlockAfterBan", "600"));
- - DATABASE_DRIVER = serverSettings.getProperty("Driver", "com.mysql.jdbc.Driver");
- - DATABASE_URL = serverSettings.getProperty("URL", "jdbc:mysql://localhost/l2jdb");
- - DATABASE_LOGIN = serverSettings.getProperty("Login", "root");
- - DATABASE_PASSWORD = serverSettings.getProperty("Password", "");
- - DATABASE_MAX_CONNECTIONS = Integer.parseInt(serverSettings.getProperty("MaximumDbConnections", "10"));
- + DATABASE_NAME = serverSettings.getProperty("DatabaseName", "l2jhellas");
- + DATABASE_USERNAME = serverSettings.getProperty("DatabaseUsername", "root");
- + DATABASE_PASSWORD = serverSettings.getProperty("DatabasePassword", "");
- SHOW_LICENCE = Boolean.parseBoolean(serverSettings.getProperty("ShowLicence", "True"));
- IP_UPDATE_TIME = Integer.parseInt(serverSettings.getProperty("IpUpdateTime", "15"));
- FORCE_GGAUTH = Boolean.parseBoolean(serverSettings.getProperty("ForceGGAuth", "False"));
- Index: java/com/l2jhellas/util/database/L2DatabaseFactory.java
- ===================================================================
- --- java/com/l2jhellas/util/database/L2DatabaseFactory.java (revision 462)
- +++ java/com/l2jhellas/util/database/L2DatabaseFactory.java (working copy)
- @@ -11,6 +11,12 @@
- *
- * You should have received a copy of the GNU General Public License along with
- * this program. If not, see <http://www.gnu.org/licenses/>.
- + *
- + * links
- + * http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.zaxxer%22%20AND%20a%3A%22HikariCP%22
- + * http://brettwooldridge.github.io/HikariCP/
- + * https://github.com/brettwooldridge/HikariCP
- + * auti einai i version se java 1.6 se java 1.8 tha mporei na mpei to neotero jar
- */
- package com.l2jhellas.util.database;
- @@ -19,73 +25,50 @@
- import java.util.logging.Level;
- import java.util.logging.Logger;
- -import com.jolbox.bonecp.BoneCPDataSource;
- import com.l2jhellas.Config;
- import com.l2jhellas.Server;
- import com.l2jhellas.gameserver.ThreadPoolManager;
- +import com.zaxxer.hikari.HikariDataSource;
- public class L2DatabaseFactory
- {
- private static final Logger _log = Logger.getLogger(L2DatabaseFactory.class.getName());
- private static L2DatabaseFactory _instance;
- - private BoneCPDataSource _source;
- - private int database_partition_count = 3;
- - private int database_timeout = 0;
- + private HikariDataSource _source;
- + private int connection_timeout = 30000;
- public L2DatabaseFactory()
- {
- try
- {
- - if (Config.DATABASE_MAX_CONNECTIONS < 10)
- - {
- - Config.DATABASE_MAX_CONNECTIONS = 10;
- - _log.warning("at least " + Config.DATABASE_MAX_CONNECTIONS + " db connections are required.");
- - }
- + final long serverLoadStart = System.currentTimeMillis();
- + _source = new HikariDataSource();
- - if (database_partition_count > 4)
- - {
- - database_partition_count = 4;
- - _log.warning("max {} db connections partitions. " + database_partition_count);
- - }
- -
- - if (Config.DATABASE_MAX_CONNECTIONS * database_partition_count > 200)
- - {
- - _log.warning("Max Connections number is higher then 60.. Using Partition 2 and Connection 30");
- - Config.DATABASE_MAX_CONNECTIONS = 50;
- - database_partition_count = 4;
- - }
- - _source = new BoneCPDataSource();
- + _source.setDriverClassName("com.mysql.jdbc.Driver");
- + _source.setJdbcUrl("jdbc:mysql://localhost/"+Config.DATABASE_NAME);
- + _source.setUsername(Config.DATABASE_USERNAME);
- + _source.setPassword(Config.DATABASE_PASSWORD);
- - _source.getConfig().setDefaultAutoCommit(true);
- - _source.getConfig().setPoolAvailabilityThreshold(10);
- - _source.getConfig().setMinConnectionsPerPartition(10);
- - _source.getConfig().setMaxConnectionsPerPartition(Config.DATABASE_MAX_CONNECTIONS);
- - _source.getConfig().setPartitionCount(database_partition_count);
- -
- - _source.setAcquireRetryAttempts(0);
- - _source.setAcquireRetryDelayInMs(500);
- - _source.setAcquireIncrement(5);
- -
- - _source.setConnectionTimeoutInMs(database_timeout);
- -
- - _source.setIdleConnectionTestPeriodInMinutes(1);
- -
- - _source.setIdleMaxAgeInSeconds(1800);
- -
- - _source.setTransactionRecoveryEnabled(true);
- - _source.setDriverClass(Config.DATABASE_DRIVER);
- - _source.setJdbcUrl(Config.DATABASE_URL);
- - _source.setUsername(Config.DATABASE_LOGIN);
- - _source.setPassword(Config.DATABASE_PASSWORD);
- -
- + _source.setAutoCommit(true);
- + _source.setReadOnly(false);
- + _source.setConnectionTimeout(connection_timeout);
- + _source.setIdleTimeout(600000);//10min
- + _source.setMaxLifetime(0);
- + _source.setLeakDetectionThreshold(0);
- + _source.setInitializationFailFast(true);
- + _source.setMaximumPoolSize(20);
- + _source.setPoolName("");
- + if (Config.DEBUG)
- + _source.setJdbc4ConnectionTest(true);
- +
- _source.getConnection().close();
- -
- - _log.log(Level.INFO, "Database loaded.");
- + final long serverLoadEnd = System.currentTimeMillis();
- + _log.log(Level.INFO, "Database loaded in " + ((serverLoadEnd - serverLoadStart) / 1000) + " seconds.");
- }
- catch (Exception e)
- {
- - throw new Error("L2DatabaseFactory: Failed to init database connections: " + e, e);
- + _log.log(Level.WARNING, getClass().getSimpleName() + ": Failed to init database connections: ", e);
- }
- }
- Index: libs/BoneCP-0.7.1.jar
- ===================================================================
- Cannot display: file marked as a binary type.
- svn:mime-type = application/octet-stream
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement