Advertisement
Guest User

testing on hikari cp for l2jhellas

a guest
Nov 26th, 2018
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 10.27 KB | None | 0 0
  1. ### Eclipse Workspace Patch 1.0
  2. #P L2JHellasC
  3. Index: config/Network/LoginServer.ini
  4. ===================================================================
  5. --- config/Network/LoginServer.ini  (revision 462)
  6. +++ config/Network/LoginServer.ini  (working copy)
  7. @@ -19,18 +19,13 @@
  8.  # It is highly recommended for Account Security to leave this option as default (True)
  9.  ShowLicence = True
  10.  
  11. -# ============= #
  12. -# Database info #
  13. -# ============= #
  14. -Driver=com.mysql.jdbc.Driver
  15. -# Driver=org.hsqldb.jdbcDriver
  16. -# Driver=com.microsoft.sqlserver.jdbc.SQLServerDriver
  17. -URL=jdbc:mysql://localhost/l2jhellas
  18. +# ========================== #
  19. +#  Database Information      #
  20. +# ========================== #
  21. +DatabaseName = l2jhellas
  22. +DatabaseUsername = root
  23. +DatabasePassword =
  24.  
  25. -Login = root
  26. -Password =
  27. -MaximumDbConnections = 10
  28. -
  29.  # Useable values: "True" - "False", use this option to choose whether accounts will be created
  30.  # automatically or not.
  31.  # Retail : False
  32. Index: .classpath
  33. ===================================================================
  34. --- .classpath  (revision 462)
  35. +++ .classpath  (working copy)
  36. @@ -15,10 +13,9 @@
  37.     <classpathentry exported="true" kind="lib" path="libs/jython.jar"/>
  38.     <classpathentry exported="true" kind="lib" path="libs/mail.jar"/>
  39.     <classpathentry exported="true" kind="lib" path="libs/mmocore.jar"/>
  40.     <classpathentry exported="true" kind="lib" path="libs/Subnet-1.0.jar"/>
  41.     <classpathentry exported="true" kind="lib" path="libs/worldwind.jar"/>
  42. +   <classpathentry exported="true" kind="lib" path="libs/mysql-connector-java-5.1.33-bin.jar"/>
  43. +   <classpathentry exported="true" kind="lib" path="libs/HikariCP-java6-2.1.0.jar"/>
  44.     <classpathentry kind="output" path="bin"/>
  45.  </classpath>
  46. Index: config/Network/GameServer.ini
  47. ===================================================================
  48. --- config/Network/GameServer.ini   (revision 462)
  49. +++ config/Network/GameServer.ini   (working copy)
  50. @@ -40,28 +40,17 @@
  51.  
  52.  # This is the server id that the gameserver will request (i.e. 1 is Bartz)
  53.  RequestServerID = 1
  54. -# If set to True, the login will give an other id to the server  if the requested id is allready reserved
  55. +# If set to True, the login will give an other id to the server  if the requested id is already reserved
  56.  AcceptAlternateID = True
  57.  
  58.  # ========================== #
  59.  #  Database Information      #
  60.  # ========================== #
  61. -# Drivers: org.hsqldb.jdbcDriver
  62. -# or com.mysql.jdbc.Driver
  63. -# or com.microsoft.sqlserver.jdbc.SQLServerDriver
  64. -# Default:
  65. -Driver = com.mysql.jdbc.Driver
  66. +DatabaseName = l2jhellas
  67. +DatabaseUsername = root
  68. +DatabasePassword =
  69.  
  70. Index: java/com/l2jhellas/Config.java
  71. ===================================================================
  72. --- java/com/l2jhellas/Config.java  (revision 462)
  73. +++ java/com/l2jhellas/Config.java  (working copy)
  74. @@ -1128,11 +1128,9 @@
  75.     public static boolean PURGE_ERROR_LOG;
  76.     public static int REQUEST_ID;
  77.     public static boolean ACCEPT_ALTERNATE_ID;
  78. -   public static String DATABASE_DRIVER;
  79. -   public static String DATABASE_URL;
  80. -   public static String DATABASE_LOGIN;
  81. +   public static String DATABASE_NAME;
  82. +   public static String DATABASE_USERNAME;
  83.     public static String DATABASE_PASSWORD;
  84. -   public static int DATABASE_MAX_CONNECTIONS;
  85.     public static String CNAME_TEMPLATE;
  86.     public static String PET_NAME_TEMPLATE;
  87.     public static int MAX_CHARACTERS_NUMBER_PER_ACCOUNT;
  88. @@ -3143,11 +3141,9 @@
  89.             PURGE_ERROR_LOG = Boolean.parseBoolean(serverSettings.getProperty("PurgeErrorLog", "False"));
  90.             REQUEST_ID = Integer.parseInt(serverSettings.getProperty("RequestServerID", "0"));
  91.             ACCEPT_ALTERNATE_ID = Boolean.parseBoolean(serverSettings.getProperty("AcceptAlternateID", "True"));
  92. -           DATABASE_DRIVER = serverSettings.getProperty("Driver", "com.mysql.jdbc.Driver");
  93. -           DATABASE_URL = serverSettings.getProperty("URL", "jdbc:mysql://localhost/l2jdb");
  94. -           DATABASE_LOGIN = serverSettings.getProperty("Login", "root");
  95. -           DATABASE_PASSWORD = serverSettings.getProperty("Password", "");
  96. -           DATABASE_MAX_CONNECTIONS = Integer.parseInt(serverSettings.getProperty("MaximumDbConnections", "10"));
  97. +           DATABASE_NAME = serverSettings.getProperty("DatabaseName", "l2jhellas");
  98. +           DATABASE_USERNAME = serverSettings.getProperty("DatabaseUsername", "root");
  99. +           DATABASE_PASSWORD = serverSettings.getProperty("DatabasePassword", "");
  100.             CNAME_TEMPLATE = serverSettings.getProperty("CnameTemplate", ".*");
  101.             PET_NAME_TEMPLATE = serverSettings.getProperty("PetNameTemplate", ".*");
  102.             MAX_CHARACTERS_NUMBER_PER_ACCOUNT = Integer.parseInt(serverSettings.getProperty("CharMaxNumber", "0"));
  103. @@ -3264,11 +3260,9 @@
  104.             ACCEPT_ALTERNATE_ID = Boolean.parseBoolean(serverSettings.getProperty("AcceptAlternateID", "True"));
  105.             LOGIN_TRY_BEFORE_BAN = Integer.parseInt(serverSettings.getProperty("LoginTryBeforeBan", "10"));
  106.             LOGIN_BLOCK_AFTER_BAN = Integer.parseInt(serverSettings.getProperty("LoginBlockAfterBan", "600"));
  107. -           DATABASE_DRIVER = serverSettings.getProperty("Driver", "com.mysql.jdbc.Driver");
  108. -           DATABASE_URL = serverSettings.getProperty("URL", "jdbc:mysql://localhost/l2jdb");
  109. -           DATABASE_LOGIN = serverSettings.getProperty("Login", "root");
  110. -           DATABASE_PASSWORD = serverSettings.getProperty("Password", "");
  111. -           DATABASE_MAX_CONNECTIONS = Integer.parseInt(serverSettings.getProperty("MaximumDbConnections", "10"));
  112. +           DATABASE_NAME = serverSettings.getProperty("DatabaseName", "l2jhellas");
  113. +           DATABASE_USERNAME = serverSettings.getProperty("DatabaseUsername", "root");
  114. +           DATABASE_PASSWORD = serverSettings.getProperty("DatabasePassword", "");
  115.             SHOW_LICENCE = Boolean.parseBoolean(serverSettings.getProperty("ShowLicence", "True"));
  116.             IP_UPDATE_TIME = Integer.parseInt(serverSettings.getProperty("IpUpdateTime", "15"));
  117.             FORCE_GGAUTH = Boolean.parseBoolean(serverSettings.getProperty("ForceGGAuth", "False"));
  118. Index: java/com/l2jhellas/util/database/L2DatabaseFactory.java
  119. ===================================================================
  120. --- java/com/l2jhellas/util/database/L2DatabaseFactory.java (revision 462)
  121. +++ java/com/l2jhellas/util/database/L2DatabaseFactory.java (working copy)
  122. @@ -11,6 +11,12 @@
  123.   *
  124.   * You should have received a copy of the GNU General Public License along with
  125.   * this program. If not, see <http://www.gnu.org/licenses/>.
  126. + *
  127. + * links
  128. + * http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.zaxxer%22%20AND%20a%3A%22HikariCP%22
  129. + * http://brettwooldridge.github.io/HikariCP/
  130. + * https://github.com/brettwooldridge/HikariCP
  131. + * auti einai i version se java 1.6 se java 1.8 tha mporei na mpei to neotero jar
  132.   */
  133.  package com.l2jhellas.util.database;
  134.  
  135. @@ -19,73 +25,50 @@
  136.  import java.util.logging.Level;
  137.  import java.util.logging.Logger;
  138.  
  139. -import com.jolbox.bonecp.BoneCPDataSource;
  140.  import com.l2jhellas.Config;
  141.  import com.l2jhellas.Server;
  142.  import com.l2jhellas.gameserver.ThreadPoolManager;
  143. +import com.zaxxer.hikari.HikariDataSource;
  144.  
  145.  public class L2DatabaseFactory
  146.  {
  147.     private static final Logger _log = Logger.getLogger(L2DatabaseFactory.class.getName());
  148.  
  149.     private static L2DatabaseFactory _instance;
  150. -   private BoneCPDataSource _source;
  151. -   private int database_partition_count = 3;
  152. -   private int database_timeout = 0;
  153. +   private HikariDataSource _source;
  154. +   private int connection_timeout = 30000;
  155.  
  156.     public L2DatabaseFactory()
  157.     {
  158.         try
  159.         {
  160. -           if (Config.DATABASE_MAX_CONNECTIONS < 10)
  161. -           {
  162. -               Config.DATABASE_MAX_CONNECTIONS = 10;
  163. -               _log.warning("at least " + Config.DATABASE_MAX_CONNECTIONS + " db connections are required.");
  164. -           }
  165. +           final long serverLoadStart = System.currentTimeMillis();
  166. +           _source = new HikariDataSource();
  167.  
  168. -           if (database_partition_count > 4)
  169. -           {
  170. -               database_partition_count = 4;
  171. -               _log.warning("max {} db connections partitions. " + database_partition_count);
  172. -           }
  173. -
  174. -           if (Config.DATABASE_MAX_CONNECTIONS * database_partition_count > 200)
  175. -           {
  176. -               _log.warning("Max Connections number is higher then 60.. Using Partition 2 and Connection 30");
  177. -               Config.DATABASE_MAX_CONNECTIONS = 50;
  178. -               database_partition_count = 4;
  179. -           }
  180. -           _source = new BoneCPDataSource();
  181. +           _source.setDriverClassName("com.mysql.jdbc.Driver");
  182. +           _source.setJdbcUrl("jdbc:mysql://localhost/"+Config.DATABASE_NAME);
  183. +           _source.setUsername(Config.DATABASE_USERNAME);
  184. +           _source.setPassword(Config.DATABASE_PASSWORD);
  185.            
  186. -           _source.getConfig().setDefaultAutoCommit(true);
  187. -           _source.getConfig().setPoolAvailabilityThreshold(10);
  188. -           _source.getConfig().setMinConnectionsPerPartition(10);
  189. -           _source.getConfig().setMaxConnectionsPerPartition(Config.DATABASE_MAX_CONNECTIONS);
  190. -           _source.getConfig().setPartitionCount(database_partition_count);
  191. -
  192. -           _source.setAcquireRetryAttempts(0);
  193. -           _source.setAcquireRetryDelayInMs(500);
  194. -           _source.setAcquireIncrement(5);
  195. -
  196. -           _source.setConnectionTimeoutInMs(database_timeout);
  197. -
  198. -           _source.setIdleConnectionTestPeriodInMinutes(1);
  199. -
  200. -           _source.setIdleMaxAgeInSeconds(1800);
  201. -
  202. -           _source.setTransactionRecoveryEnabled(true);
  203. -           _source.setDriverClass(Config.DATABASE_DRIVER);
  204. -           _source.setJdbcUrl(Config.DATABASE_URL);
  205. -           _source.setUsername(Config.DATABASE_LOGIN);
  206. -           _source.setPassword(Config.DATABASE_PASSWORD);
  207. -
  208. +           _source.setAutoCommit(true);
  209. +           _source.setReadOnly(false);
  210. +           _source.setConnectionTimeout(connection_timeout);
  211. +           _source.setIdleTimeout(600000);//10min
  212. +           _source.setMaxLifetime(0);
  213. +           _source.setLeakDetectionThreshold(0);
  214. +           _source.setInitializationFailFast(true);
  215. +           _source.setMaximumPoolSize(20);
  216. +           _source.setPoolName("");
  217. +           if (Config.DEBUG)
  218. +               _source.setJdbc4ConnectionTest(true);
  219. +          
  220.             _source.getConnection().close();
  221. -          
  222. -           _log.log(Level.INFO, "Database loaded.");
  223. +           final long serverLoadEnd = System.currentTimeMillis();
  224. +           _log.log(Level.INFO, "Database loaded in " + ((serverLoadEnd - serverLoadStart) / 1000) + " seconds.");
  225.         }
  226.         catch (Exception e)
  227.         {
  228. -           throw new Error("L2DatabaseFactory: Failed to init database connections: " + e, e);
  229. +           _log.log(Level.WARNING, getClass().getSimpleName() + ": Failed to init database connections: ", e);
  230.         }
  231.     }
  232.  
  233. Index: libs/BoneCP-0.7.1.jar
  234. ===================================================================
  235. Cannot display: file marked as a binary type.
  236. svn:mime-type = application/octet-stream
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement