Use ThreadPool with login server.
This commit is contained in:
parent
43f1707098
commit
14cb1e0cff
@ -67,11 +67,33 @@ MySqlBinLocation = C:/xampp/mysql/bin/
|
|||||||
BackupPath = ../backup/
|
BackupPath = ../backup/
|
||||||
|
|
||||||
# Maximum number of days that backups will be kept.
|
# Maximum number of days that backups will be kept.
|
||||||
# Old backups will be deleted.
|
# Old files in backup folder will be deleted.
|
||||||
# Set to 0 to disable.
|
# Set to 0 to disable.
|
||||||
BackupDays = 30
|
BackupDays = 30
|
||||||
|
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
# Thread Configuration
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# Determines the amount of scheduled thread pools. If set to -1, the server will decide the amount depending on the available processors.
|
||||||
|
ScheduledThreadPoolCount = 2
|
||||||
|
|
||||||
|
# Specifies how many threads will be in a single scheduled pool.
|
||||||
|
ThreadsPerScheduledThreadPool = 2
|
||||||
|
|
||||||
|
# Determines the amount of instant thread pools. If set to -1, the server will decide the amount depending on the available processors.
|
||||||
|
InstantThreadPoolCount = 2
|
||||||
|
|
||||||
|
# Specifies how many threads will be in a single instant pool.
|
||||||
|
ThreadsPerInstantThreadPool = 4
|
||||||
|
|
||||||
|
# Use threads to run client packets individually.
|
||||||
|
# Less lag when using threads, but more CPU consumption.
|
||||||
|
# Default: True
|
||||||
|
ThreadsForClientPackets = True
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# Security
|
# Security
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
@ -3573,6 +3573,19 @@ public class Config
|
|||||||
MYSQL_BIN_PATH = loginConfig.getString("MySqlBinLocation", "C:/xampp/mysql/bin/");
|
MYSQL_BIN_PATH = loginConfig.getString("MySqlBinLocation", "C:/xampp/mysql/bin/");
|
||||||
BACKUP_PATH = loginConfig.getString("BackupPath", "../backup/");
|
BACKUP_PATH = loginConfig.getString("BackupPath", "../backup/");
|
||||||
BACKUP_DAYS = loginConfig.getInt("BackupDays", 30);
|
BACKUP_DAYS = loginConfig.getInt("BackupDays", 30);
|
||||||
|
SCHEDULED_THREAD_POOL_COUNT = loginConfig.getInt("ScheduledThreadPoolCount", 2);
|
||||||
|
if (SCHEDULED_THREAD_POOL_COUNT == -1)
|
||||||
|
{
|
||||||
|
SCHEDULED_THREAD_POOL_COUNT = Math.max(2, Runtime.getRuntime().availableProcessors() / 2);
|
||||||
|
}
|
||||||
|
THREADS_PER_SCHEDULED_THREAD_POOL = loginConfig.getInt("ThreadsPerScheduledThreadPool", 2);
|
||||||
|
INSTANT_THREAD_POOL_COUNT = loginConfig.getInt("InstantThreadPoolCount", 2);
|
||||||
|
if (INSTANT_THREAD_POOL_COUNT == -1)
|
||||||
|
{
|
||||||
|
INSTANT_THREAD_POOL_COUNT = Math.max(2, Runtime.getRuntime().availableProcessors() / 2);
|
||||||
|
}
|
||||||
|
THREADS_PER_INSTANT_THREAD_POOL = loginConfig.getInt("ThreadsPerInstantThreadPool", 4);
|
||||||
|
THREADS_FOR_CLIENT_PACKETS = loginConfig.getBoolean("ThreadsForClientPackets", true);
|
||||||
SHOW_LICENCE = loginConfig.getBoolean("ShowLicence", true);
|
SHOW_LICENCE = loginConfig.getBoolean("ShowLicence", true);
|
||||||
SHOW_PI_AGREEMENT = loginConfig.getBoolean("ShowPIAgreement", false);
|
SHOW_PI_AGREEMENT = loginConfig.getBoolean("ShowPIAgreement", false);
|
||||||
AUTO_CREATE_ACCOUNTS = loginConfig.getBoolean("AutoCreateAccounts", true);
|
AUTO_CREATE_ACCOUNTS = loginConfig.getBoolean("AutoCreateAccounts", true);
|
||||||
|
@ -33,6 +33,7 @@ import org.l2jmobius.commons.database.DatabaseBackup;
|
|||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||||
import org.l2jmobius.commons.enums.ServerMode;
|
import org.l2jmobius.commons.enums.ServerMode;
|
||||||
import org.l2jmobius.commons.network.NetServer;
|
import org.l2jmobius.commons.network.NetServer;
|
||||||
|
import org.l2jmobius.commons.threads.ThreadPool;
|
||||||
import org.l2jmobius.commons.util.PropertiesParser;
|
import org.l2jmobius.commons.util.PropertiesParser;
|
||||||
import org.l2jmobius.gameserver.network.loginserverpackets.game.ServerStatus;
|
import org.l2jmobius.gameserver.network.loginserverpackets.game.ServerStatus;
|
||||||
import org.l2jmobius.loginserver.network.LoginClient;
|
import org.l2jmobius.loginserver.network.LoginClient;
|
||||||
@ -95,6 +96,9 @@ public class LoginServer
|
|||||||
// Prepare Database
|
// Prepare Database
|
||||||
DatabaseFactory.init();
|
DatabaseFactory.init();
|
||||||
|
|
||||||
|
// Initialize ThreadPool.
|
||||||
|
ThreadPool.init();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
LoginController.load();
|
LoginController.load();
|
||||||
|
@ -18,10 +18,11 @@ package org.l2jmobius.loginserver.network;
|
|||||||
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import org.l2jmobius.Config;
|
||||||
import org.l2jmobius.commons.network.PacketHandlerInterface;
|
import org.l2jmobius.commons.network.PacketHandlerInterface;
|
||||||
import org.l2jmobius.commons.network.ReadablePacket;
|
import org.l2jmobius.commons.network.ReadablePacket;
|
||||||
|
import org.l2jmobius.commons.threads.ThreadPool;
|
||||||
import org.l2jmobius.commons.util.CommonUtil;
|
import org.l2jmobius.commons.util.CommonUtil;
|
||||||
import org.l2jmobius.gameserver.network.PacketLogger;
|
|
||||||
import org.l2jmobius.loginserver.network.clientpackets.LoginClientPacket;
|
import org.l2jmobius.loginserver.network.clientpackets.LoginClientPacket;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -42,8 +43,8 @@ public class LoginPacketHandler implements PacketHandlerInterface<LoginClient>
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
PacketLogger.warning("LoginPacketHandler: Problem receiving packet id from " + client);
|
LOGGER.warning("LoginPacketHandler: Problem receiving packet id from " + client);
|
||||||
PacketLogger.warning(CommonUtil.getStackTrace(e));
|
LOGGER.warning(CommonUtil.getStackTrace(e));
|
||||||
client.disconnect();
|
client.disconnect();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -75,10 +76,23 @@ public class LoginPacketHandler implements PacketHandlerInterface<LoginClient>
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Continue on another thread.
|
// Continue on another thread.
|
||||||
final Thread thread = new Thread(new ExecuteTask(client, packet, newPacket, packetId), getClass().getName());
|
if (Config.THREADS_FOR_CLIENT_PACKETS)
|
||||||
thread.setPriority(Thread.NORM_PRIORITY);
|
{
|
||||||
thread.setDaemon(false);
|
ThreadPool.execute(new ExecuteTask(client, packet, newPacket, packetId));
|
||||||
thread.start();
|
}
|
||||||
|
else // Wait for execution.
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
newPacket.read(packet);
|
||||||
|
newPacket.run(client);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
LOGGER.warning("LoginPacketHandler: Problem with " + client + " [Packet: 0x" + Integer.toHexString(packetId).toUpperCase() + "]");
|
||||||
|
LOGGER.warning(CommonUtil.getStackTrace(e));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ExecuteTask implements Runnable
|
private class ExecuteTask implements Runnable
|
||||||
|
@ -67,11 +67,33 @@ MySqlBinLocation = C:/xampp/mysql/bin/
|
|||||||
BackupPath = ../backup/
|
BackupPath = ../backup/
|
||||||
|
|
||||||
# Maximum number of days that backups will be kept.
|
# Maximum number of days that backups will be kept.
|
||||||
# Old backups will be deleted.
|
# Old files in backup folder will be deleted.
|
||||||
# Set to 0 to disable.
|
# Set to 0 to disable.
|
||||||
BackupDays = 30
|
BackupDays = 30
|
||||||
|
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
# Thread Configuration
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# Determines the amount of scheduled thread pools. If set to -1, the server will decide the amount depending on the available processors.
|
||||||
|
ScheduledThreadPoolCount = 2
|
||||||
|
|
||||||
|
# Specifies how many threads will be in a single scheduled pool.
|
||||||
|
ThreadsPerScheduledThreadPool = 2
|
||||||
|
|
||||||
|
# Determines the amount of instant thread pools. If set to -1, the server will decide the amount depending on the available processors.
|
||||||
|
InstantThreadPoolCount = 2
|
||||||
|
|
||||||
|
# Specifies how many threads will be in a single instant pool.
|
||||||
|
ThreadsPerInstantThreadPool = 4
|
||||||
|
|
||||||
|
# Use threads to run client packets individually.
|
||||||
|
# Less lag when using threads, but more CPU consumption.
|
||||||
|
# Default: True
|
||||||
|
ThreadsForClientPackets = True
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# Security
|
# Security
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
@ -3599,6 +3599,19 @@ public class Config
|
|||||||
MYSQL_BIN_PATH = loginConfig.getString("MySqlBinLocation", "C:/xampp/mysql/bin/");
|
MYSQL_BIN_PATH = loginConfig.getString("MySqlBinLocation", "C:/xampp/mysql/bin/");
|
||||||
BACKUP_PATH = loginConfig.getString("BackupPath", "../backup/");
|
BACKUP_PATH = loginConfig.getString("BackupPath", "../backup/");
|
||||||
BACKUP_DAYS = loginConfig.getInt("BackupDays", 30);
|
BACKUP_DAYS = loginConfig.getInt("BackupDays", 30);
|
||||||
|
SCHEDULED_THREAD_POOL_COUNT = loginConfig.getInt("ScheduledThreadPoolCount", 2);
|
||||||
|
if (SCHEDULED_THREAD_POOL_COUNT == -1)
|
||||||
|
{
|
||||||
|
SCHEDULED_THREAD_POOL_COUNT = Math.max(2, Runtime.getRuntime().availableProcessors() / 2);
|
||||||
|
}
|
||||||
|
THREADS_PER_SCHEDULED_THREAD_POOL = loginConfig.getInt("ThreadsPerScheduledThreadPool", 2);
|
||||||
|
INSTANT_THREAD_POOL_COUNT = loginConfig.getInt("InstantThreadPoolCount", 2);
|
||||||
|
if (INSTANT_THREAD_POOL_COUNT == -1)
|
||||||
|
{
|
||||||
|
INSTANT_THREAD_POOL_COUNT = Math.max(2, Runtime.getRuntime().availableProcessors() / 2);
|
||||||
|
}
|
||||||
|
THREADS_PER_INSTANT_THREAD_POOL = loginConfig.getInt("ThreadsPerInstantThreadPool", 4);
|
||||||
|
THREADS_FOR_CLIENT_PACKETS = loginConfig.getBoolean("ThreadsForClientPackets", true);
|
||||||
SHOW_LICENCE = loginConfig.getBoolean("ShowLicence", true);
|
SHOW_LICENCE = loginConfig.getBoolean("ShowLicence", true);
|
||||||
SHOW_PI_AGREEMENT = loginConfig.getBoolean("ShowPIAgreement", false);
|
SHOW_PI_AGREEMENT = loginConfig.getBoolean("ShowPIAgreement", false);
|
||||||
AUTO_CREATE_ACCOUNTS = loginConfig.getBoolean("AutoCreateAccounts", true);
|
AUTO_CREATE_ACCOUNTS = loginConfig.getBoolean("AutoCreateAccounts", true);
|
||||||
|
@ -33,6 +33,7 @@ import org.l2jmobius.commons.database.DatabaseBackup;
|
|||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||||
import org.l2jmobius.commons.enums.ServerMode;
|
import org.l2jmobius.commons.enums.ServerMode;
|
||||||
import org.l2jmobius.commons.network.NetServer;
|
import org.l2jmobius.commons.network.NetServer;
|
||||||
|
import org.l2jmobius.commons.threads.ThreadPool;
|
||||||
import org.l2jmobius.commons.util.PropertiesParser;
|
import org.l2jmobius.commons.util.PropertiesParser;
|
||||||
import org.l2jmobius.gameserver.network.loginserverpackets.game.ServerStatus;
|
import org.l2jmobius.gameserver.network.loginserverpackets.game.ServerStatus;
|
||||||
import org.l2jmobius.loginserver.network.LoginClient;
|
import org.l2jmobius.loginserver.network.LoginClient;
|
||||||
@ -95,6 +96,9 @@ public class LoginServer
|
|||||||
// Prepare Database
|
// Prepare Database
|
||||||
DatabaseFactory.init();
|
DatabaseFactory.init();
|
||||||
|
|
||||||
|
// Initialize ThreadPool.
|
||||||
|
ThreadPool.init();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
LoginController.load();
|
LoginController.load();
|
||||||
|
@ -18,10 +18,11 @@ package org.l2jmobius.loginserver.network;
|
|||||||
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import org.l2jmobius.Config;
|
||||||
import org.l2jmobius.commons.network.PacketHandlerInterface;
|
import org.l2jmobius.commons.network.PacketHandlerInterface;
|
||||||
import org.l2jmobius.commons.network.ReadablePacket;
|
import org.l2jmobius.commons.network.ReadablePacket;
|
||||||
|
import org.l2jmobius.commons.threads.ThreadPool;
|
||||||
import org.l2jmobius.commons.util.CommonUtil;
|
import org.l2jmobius.commons.util.CommonUtil;
|
||||||
import org.l2jmobius.gameserver.network.PacketLogger;
|
|
||||||
import org.l2jmobius.loginserver.network.clientpackets.LoginClientPacket;
|
import org.l2jmobius.loginserver.network.clientpackets.LoginClientPacket;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -42,8 +43,8 @@ public class LoginPacketHandler implements PacketHandlerInterface<LoginClient>
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
PacketLogger.warning("LoginPacketHandler: Problem receiving packet id from " + client);
|
LOGGER.warning("LoginPacketHandler: Problem receiving packet id from " + client);
|
||||||
PacketLogger.warning(CommonUtil.getStackTrace(e));
|
LOGGER.warning(CommonUtil.getStackTrace(e));
|
||||||
client.disconnect();
|
client.disconnect();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -75,10 +76,23 @@ public class LoginPacketHandler implements PacketHandlerInterface<LoginClient>
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Continue on another thread.
|
// Continue on another thread.
|
||||||
final Thread thread = new Thread(new ExecuteTask(client, packet, newPacket, packetId), getClass().getName());
|
if (Config.THREADS_FOR_CLIENT_PACKETS)
|
||||||
thread.setPriority(Thread.NORM_PRIORITY);
|
{
|
||||||
thread.setDaemon(false);
|
ThreadPool.execute(new ExecuteTask(client, packet, newPacket, packetId));
|
||||||
thread.start();
|
}
|
||||||
|
else // Wait for execution.
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
newPacket.read(packet);
|
||||||
|
newPacket.run(client);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
LOGGER.warning("LoginPacketHandler: Problem with " + client + " [Packet: 0x" + Integer.toHexString(packetId).toUpperCase() + "]");
|
||||||
|
LOGGER.warning(CommonUtil.getStackTrace(e));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ExecuteTask implements Runnable
|
private class ExecuteTask implements Runnable
|
||||||
|
@ -67,11 +67,33 @@ MySqlBinLocation = C:/xampp/mysql/bin/
|
|||||||
BackupPath = ../backup/
|
BackupPath = ../backup/
|
||||||
|
|
||||||
# Maximum number of days that backups will be kept.
|
# Maximum number of days that backups will be kept.
|
||||||
# Old backups will be deleted.
|
# Old files in backup folder will be deleted.
|
||||||
# Set to 0 to disable.
|
# Set to 0 to disable.
|
||||||
BackupDays = 30
|
BackupDays = 30
|
||||||
|
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
# Thread Configuration
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# Determines the amount of scheduled thread pools. If set to -1, the server will decide the amount depending on the available processors.
|
||||||
|
ScheduledThreadPoolCount = 2
|
||||||
|
|
||||||
|
# Specifies how many threads will be in a single scheduled pool.
|
||||||
|
ThreadsPerScheduledThreadPool = 2
|
||||||
|
|
||||||
|
# Determines the amount of instant thread pools. If set to -1, the server will decide the amount depending on the available processors.
|
||||||
|
InstantThreadPoolCount = 2
|
||||||
|
|
||||||
|
# Specifies how many threads will be in a single instant pool.
|
||||||
|
ThreadsPerInstantThreadPool = 4
|
||||||
|
|
||||||
|
# Use threads to run client packets individually.
|
||||||
|
# Less lag when using threads, but more CPU consumption.
|
||||||
|
# Default: True
|
||||||
|
ThreadsForClientPackets = True
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# Security
|
# Security
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
@ -3621,6 +3621,19 @@ public class Config
|
|||||||
MYSQL_BIN_PATH = loginConfig.getString("MySqlBinLocation", "C:/xampp/mysql/bin/");
|
MYSQL_BIN_PATH = loginConfig.getString("MySqlBinLocation", "C:/xampp/mysql/bin/");
|
||||||
BACKUP_PATH = loginConfig.getString("BackupPath", "../backup/");
|
BACKUP_PATH = loginConfig.getString("BackupPath", "../backup/");
|
||||||
BACKUP_DAYS = loginConfig.getInt("BackupDays", 30);
|
BACKUP_DAYS = loginConfig.getInt("BackupDays", 30);
|
||||||
|
SCHEDULED_THREAD_POOL_COUNT = loginConfig.getInt("ScheduledThreadPoolCount", 2);
|
||||||
|
if (SCHEDULED_THREAD_POOL_COUNT == -1)
|
||||||
|
{
|
||||||
|
SCHEDULED_THREAD_POOL_COUNT = Math.max(2, Runtime.getRuntime().availableProcessors() / 2);
|
||||||
|
}
|
||||||
|
THREADS_PER_SCHEDULED_THREAD_POOL = loginConfig.getInt("ThreadsPerScheduledThreadPool", 2);
|
||||||
|
INSTANT_THREAD_POOL_COUNT = loginConfig.getInt("InstantThreadPoolCount", 2);
|
||||||
|
if (INSTANT_THREAD_POOL_COUNT == -1)
|
||||||
|
{
|
||||||
|
INSTANT_THREAD_POOL_COUNT = Math.max(2, Runtime.getRuntime().availableProcessors() / 2);
|
||||||
|
}
|
||||||
|
THREADS_PER_INSTANT_THREAD_POOL = loginConfig.getInt("ThreadsPerInstantThreadPool", 4);
|
||||||
|
THREADS_FOR_CLIENT_PACKETS = loginConfig.getBoolean("ThreadsForClientPackets", true);
|
||||||
SHOW_LICENCE = loginConfig.getBoolean("ShowLicence", true);
|
SHOW_LICENCE = loginConfig.getBoolean("ShowLicence", true);
|
||||||
SHOW_PI_AGREEMENT = loginConfig.getBoolean("ShowPIAgreement", false);
|
SHOW_PI_AGREEMENT = loginConfig.getBoolean("ShowPIAgreement", false);
|
||||||
AUTO_CREATE_ACCOUNTS = loginConfig.getBoolean("AutoCreateAccounts", true);
|
AUTO_CREATE_ACCOUNTS = loginConfig.getBoolean("AutoCreateAccounts", true);
|
||||||
|
@ -33,6 +33,7 @@ import org.l2jmobius.commons.database.DatabaseBackup;
|
|||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||||
import org.l2jmobius.commons.enums.ServerMode;
|
import org.l2jmobius.commons.enums.ServerMode;
|
||||||
import org.l2jmobius.commons.network.NetServer;
|
import org.l2jmobius.commons.network.NetServer;
|
||||||
|
import org.l2jmobius.commons.threads.ThreadPool;
|
||||||
import org.l2jmobius.commons.util.PropertiesParser;
|
import org.l2jmobius.commons.util.PropertiesParser;
|
||||||
import org.l2jmobius.gameserver.network.loginserverpackets.game.ServerStatus;
|
import org.l2jmobius.gameserver.network.loginserverpackets.game.ServerStatus;
|
||||||
import org.l2jmobius.loginserver.network.LoginClient;
|
import org.l2jmobius.loginserver.network.LoginClient;
|
||||||
@ -95,6 +96,9 @@ public class LoginServer
|
|||||||
// Prepare Database
|
// Prepare Database
|
||||||
DatabaseFactory.init();
|
DatabaseFactory.init();
|
||||||
|
|
||||||
|
// Initialize ThreadPool.
|
||||||
|
ThreadPool.init();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
LoginController.load();
|
LoginController.load();
|
||||||
|
@ -18,10 +18,11 @@ package org.l2jmobius.loginserver.network;
|
|||||||
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import org.l2jmobius.Config;
|
||||||
import org.l2jmobius.commons.network.PacketHandlerInterface;
|
import org.l2jmobius.commons.network.PacketHandlerInterface;
|
||||||
import org.l2jmobius.commons.network.ReadablePacket;
|
import org.l2jmobius.commons.network.ReadablePacket;
|
||||||
|
import org.l2jmobius.commons.threads.ThreadPool;
|
||||||
import org.l2jmobius.commons.util.CommonUtil;
|
import org.l2jmobius.commons.util.CommonUtil;
|
||||||
import org.l2jmobius.gameserver.network.PacketLogger;
|
|
||||||
import org.l2jmobius.loginserver.network.clientpackets.LoginClientPacket;
|
import org.l2jmobius.loginserver.network.clientpackets.LoginClientPacket;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -42,8 +43,8 @@ public class LoginPacketHandler implements PacketHandlerInterface<LoginClient>
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
PacketLogger.warning("LoginPacketHandler: Problem receiving packet id from " + client);
|
LOGGER.warning("LoginPacketHandler: Problem receiving packet id from " + client);
|
||||||
PacketLogger.warning(CommonUtil.getStackTrace(e));
|
LOGGER.warning(CommonUtil.getStackTrace(e));
|
||||||
client.disconnect();
|
client.disconnect();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -75,10 +76,23 @@ public class LoginPacketHandler implements PacketHandlerInterface<LoginClient>
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Continue on another thread.
|
// Continue on another thread.
|
||||||
final Thread thread = new Thread(new ExecuteTask(client, packet, newPacket, packetId), getClass().getName());
|
if (Config.THREADS_FOR_CLIENT_PACKETS)
|
||||||
thread.setPriority(Thread.NORM_PRIORITY);
|
{
|
||||||
thread.setDaemon(false);
|
ThreadPool.execute(new ExecuteTask(client, packet, newPacket, packetId));
|
||||||
thread.start();
|
}
|
||||||
|
else // Wait for execution.
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
newPacket.read(packet);
|
||||||
|
newPacket.run(client);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
LOGGER.warning("LoginPacketHandler: Problem with " + client + " [Packet: 0x" + Integer.toHexString(packetId).toUpperCase() + "]");
|
||||||
|
LOGGER.warning(CommonUtil.getStackTrace(e));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ExecuteTask implements Runnable
|
private class ExecuteTask implements Runnable
|
||||||
|
@ -67,11 +67,33 @@ MySqlBinLocation = C:/xampp/mysql/bin/
|
|||||||
BackupPath = ../backup/
|
BackupPath = ../backup/
|
||||||
|
|
||||||
# Maximum number of days that backups will be kept.
|
# Maximum number of days that backups will be kept.
|
||||||
# Old backups will be deleted.
|
# Old files in backup folder will be deleted.
|
||||||
# Set to 0 to disable.
|
# Set to 0 to disable.
|
||||||
BackupDays = 30
|
BackupDays = 30
|
||||||
|
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
# Thread Configuration
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# Determines the amount of scheduled thread pools. If set to -1, the server will decide the amount depending on the available processors.
|
||||||
|
ScheduledThreadPoolCount = 2
|
||||||
|
|
||||||
|
# Specifies how many threads will be in a single scheduled pool.
|
||||||
|
ThreadsPerScheduledThreadPool = 2
|
||||||
|
|
||||||
|
# Determines the amount of instant thread pools. If set to -1, the server will decide the amount depending on the available processors.
|
||||||
|
InstantThreadPoolCount = 2
|
||||||
|
|
||||||
|
# Specifies how many threads will be in a single instant pool.
|
||||||
|
ThreadsPerInstantThreadPool = 4
|
||||||
|
|
||||||
|
# Use threads to run client packets individually.
|
||||||
|
# Less lag when using threads, but more CPU consumption.
|
||||||
|
# Default: True
|
||||||
|
ThreadsForClientPackets = True
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# Security
|
# Security
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
@ -3595,6 +3595,19 @@ public class Config
|
|||||||
MYSQL_BIN_PATH = loginConfig.getString("MySqlBinLocation", "C:/xampp/mysql/bin/");
|
MYSQL_BIN_PATH = loginConfig.getString("MySqlBinLocation", "C:/xampp/mysql/bin/");
|
||||||
BACKUP_PATH = loginConfig.getString("BackupPath", "../backup/");
|
BACKUP_PATH = loginConfig.getString("BackupPath", "../backup/");
|
||||||
BACKUP_DAYS = loginConfig.getInt("BackupDays", 30);
|
BACKUP_DAYS = loginConfig.getInt("BackupDays", 30);
|
||||||
|
SCHEDULED_THREAD_POOL_COUNT = loginConfig.getInt("ScheduledThreadPoolCount", 2);
|
||||||
|
if (SCHEDULED_THREAD_POOL_COUNT == -1)
|
||||||
|
{
|
||||||
|
SCHEDULED_THREAD_POOL_COUNT = Math.max(2, Runtime.getRuntime().availableProcessors() / 2);
|
||||||
|
}
|
||||||
|
THREADS_PER_SCHEDULED_THREAD_POOL = loginConfig.getInt("ThreadsPerScheduledThreadPool", 2);
|
||||||
|
INSTANT_THREAD_POOL_COUNT = loginConfig.getInt("InstantThreadPoolCount", 2);
|
||||||
|
if (INSTANT_THREAD_POOL_COUNT == -1)
|
||||||
|
{
|
||||||
|
INSTANT_THREAD_POOL_COUNT = Math.max(2, Runtime.getRuntime().availableProcessors() / 2);
|
||||||
|
}
|
||||||
|
THREADS_PER_INSTANT_THREAD_POOL = loginConfig.getInt("ThreadsPerInstantThreadPool", 4);
|
||||||
|
THREADS_FOR_CLIENT_PACKETS = loginConfig.getBoolean("ThreadsForClientPackets", true);
|
||||||
SHOW_LICENCE = loginConfig.getBoolean("ShowLicence", true);
|
SHOW_LICENCE = loginConfig.getBoolean("ShowLicence", true);
|
||||||
SHOW_PI_AGREEMENT = loginConfig.getBoolean("ShowPIAgreement", false);
|
SHOW_PI_AGREEMENT = loginConfig.getBoolean("ShowPIAgreement", false);
|
||||||
AUTO_CREATE_ACCOUNTS = loginConfig.getBoolean("AutoCreateAccounts", true);
|
AUTO_CREATE_ACCOUNTS = loginConfig.getBoolean("AutoCreateAccounts", true);
|
||||||
|
@ -33,6 +33,7 @@ import org.l2jmobius.commons.database.DatabaseBackup;
|
|||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||||
import org.l2jmobius.commons.enums.ServerMode;
|
import org.l2jmobius.commons.enums.ServerMode;
|
||||||
import org.l2jmobius.commons.network.NetServer;
|
import org.l2jmobius.commons.network.NetServer;
|
||||||
|
import org.l2jmobius.commons.threads.ThreadPool;
|
||||||
import org.l2jmobius.commons.util.PropertiesParser;
|
import org.l2jmobius.commons.util.PropertiesParser;
|
||||||
import org.l2jmobius.gameserver.network.loginserverpackets.game.ServerStatus;
|
import org.l2jmobius.gameserver.network.loginserverpackets.game.ServerStatus;
|
||||||
import org.l2jmobius.loginserver.network.LoginClient;
|
import org.l2jmobius.loginserver.network.LoginClient;
|
||||||
@ -95,6 +96,9 @@ public class LoginServer
|
|||||||
// Prepare Database
|
// Prepare Database
|
||||||
DatabaseFactory.init();
|
DatabaseFactory.init();
|
||||||
|
|
||||||
|
// Initialize ThreadPool.
|
||||||
|
ThreadPool.init();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
LoginController.load();
|
LoginController.load();
|
||||||
|
@ -18,10 +18,11 @@ package org.l2jmobius.loginserver.network;
|
|||||||
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import org.l2jmobius.Config;
|
||||||
import org.l2jmobius.commons.network.PacketHandlerInterface;
|
import org.l2jmobius.commons.network.PacketHandlerInterface;
|
||||||
import org.l2jmobius.commons.network.ReadablePacket;
|
import org.l2jmobius.commons.network.ReadablePacket;
|
||||||
|
import org.l2jmobius.commons.threads.ThreadPool;
|
||||||
import org.l2jmobius.commons.util.CommonUtil;
|
import org.l2jmobius.commons.util.CommonUtil;
|
||||||
import org.l2jmobius.gameserver.network.PacketLogger;
|
|
||||||
import org.l2jmobius.loginserver.network.clientpackets.LoginClientPacket;
|
import org.l2jmobius.loginserver.network.clientpackets.LoginClientPacket;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -42,8 +43,8 @@ public class LoginPacketHandler implements PacketHandlerInterface<LoginClient>
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
PacketLogger.warning("LoginPacketHandler: Problem receiving packet id from " + client);
|
LOGGER.warning("LoginPacketHandler: Problem receiving packet id from " + client);
|
||||||
PacketLogger.warning(CommonUtil.getStackTrace(e));
|
LOGGER.warning(CommonUtil.getStackTrace(e));
|
||||||
client.disconnect();
|
client.disconnect();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -75,10 +76,23 @@ public class LoginPacketHandler implements PacketHandlerInterface<LoginClient>
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Continue on another thread.
|
// Continue on another thread.
|
||||||
final Thread thread = new Thread(new ExecuteTask(client, packet, newPacket, packetId), getClass().getName());
|
if (Config.THREADS_FOR_CLIENT_PACKETS)
|
||||||
thread.setPriority(Thread.NORM_PRIORITY);
|
{
|
||||||
thread.setDaemon(false);
|
ThreadPool.execute(new ExecuteTask(client, packet, newPacket, packetId));
|
||||||
thread.start();
|
}
|
||||||
|
else // Wait for execution.
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
newPacket.read(packet);
|
||||||
|
newPacket.run(client);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
LOGGER.warning("LoginPacketHandler: Problem with " + client + " [Packet: 0x" + Integer.toHexString(packetId).toUpperCase() + "]");
|
||||||
|
LOGGER.warning(CommonUtil.getStackTrace(e));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ExecuteTask implements Runnable
|
private class ExecuteTask implements Runnable
|
||||||
|
@ -67,11 +67,33 @@ MySqlBinLocation = C:/xampp/mysql/bin/
|
|||||||
BackupPath = ../backup/
|
BackupPath = ../backup/
|
||||||
|
|
||||||
# Maximum number of days that backups will be kept.
|
# Maximum number of days that backups will be kept.
|
||||||
# Old backups will be deleted.
|
# Old files in backup folder will be deleted.
|
||||||
# Set to 0 to disable.
|
# Set to 0 to disable.
|
||||||
BackupDays = 30
|
BackupDays = 30
|
||||||
|
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
# Thread Configuration
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# Determines the amount of scheduled thread pools. If set to -1, the server will decide the amount depending on the available processors.
|
||||||
|
ScheduledThreadPoolCount = 2
|
||||||
|
|
||||||
|
# Specifies how many threads will be in a single scheduled pool.
|
||||||
|
ThreadsPerScheduledThreadPool = 2
|
||||||
|
|
||||||
|
# Determines the amount of instant thread pools. If set to -1, the server will decide the amount depending on the available processors.
|
||||||
|
InstantThreadPoolCount = 2
|
||||||
|
|
||||||
|
# Specifies how many threads will be in a single instant pool.
|
||||||
|
ThreadsPerInstantThreadPool = 4
|
||||||
|
|
||||||
|
# Use threads to run client packets individually.
|
||||||
|
# Less lag when using threads, but more CPU consumption.
|
||||||
|
# Default: True
|
||||||
|
ThreadsForClientPackets = True
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# Security
|
# Security
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
@ -3604,6 +3604,19 @@ public class Config
|
|||||||
MYSQL_BIN_PATH = loginConfig.getString("MySqlBinLocation", "C:/xampp/mysql/bin/");
|
MYSQL_BIN_PATH = loginConfig.getString("MySqlBinLocation", "C:/xampp/mysql/bin/");
|
||||||
BACKUP_PATH = loginConfig.getString("BackupPath", "../backup/");
|
BACKUP_PATH = loginConfig.getString("BackupPath", "../backup/");
|
||||||
BACKUP_DAYS = loginConfig.getInt("BackupDays", 30);
|
BACKUP_DAYS = loginConfig.getInt("BackupDays", 30);
|
||||||
|
SCHEDULED_THREAD_POOL_COUNT = loginConfig.getInt("ScheduledThreadPoolCount", 2);
|
||||||
|
if (SCHEDULED_THREAD_POOL_COUNT == -1)
|
||||||
|
{
|
||||||
|
SCHEDULED_THREAD_POOL_COUNT = Math.max(2, Runtime.getRuntime().availableProcessors() / 2);
|
||||||
|
}
|
||||||
|
THREADS_PER_SCHEDULED_THREAD_POOL = loginConfig.getInt("ThreadsPerScheduledThreadPool", 2);
|
||||||
|
INSTANT_THREAD_POOL_COUNT = loginConfig.getInt("InstantThreadPoolCount", 2);
|
||||||
|
if (INSTANT_THREAD_POOL_COUNT == -1)
|
||||||
|
{
|
||||||
|
INSTANT_THREAD_POOL_COUNT = Math.max(2, Runtime.getRuntime().availableProcessors() / 2);
|
||||||
|
}
|
||||||
|
THREADS_PER_INSTANT_THREAD_POOL = loginConfig.getInt("ThreadsPerInstantThreadPool", 4);
|
||||||
|
THREADS_FOR_CLIENT_PACKETS = loginConfig.getBoolean("ThreadsForClientPackets", true);
|
||||||
SHOW_LICENCE = loginConfig.getBoolean("ShowLicence", true);
|
SHOW_LICENCE = loginConfig.getBoolean("ShowLicence", true);
|
||||||
SHOW_PI_AGREEMENT = loginConfig.getBoolean("ShowPIAgreement", false);
|
SHOW_PI_AGREEMENT = loginConfig.getBoolean("ShowPIAgreement", false);
|
||||||
AUTO_CREATE_ACCOUNTS = loginConfig.getBoolean("AutoCreateAccounts", true);
|
AUTO_CREATE_ACCOUNTS = loginConfig.getBoolean("AutoCreateAccounts", true);
|
||||||
|
@ -33,6 +33,7 @@ import org.l2jmobius.commons.database.DatabaseBackup;
|
|||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||||
import org.l2jmobius.commons.enums.ServerMode;
|
import org.l2jmobius.commons.enums.ServerMode;
|
||||||
import org.l2jmobius.commons.network.NetServer;
|
import org.l2jmobius.commons.network.NetServer;
|
||||||
|
import org.l2jmobius.commons.threads.ThreadPool;
|
||||||
import org.l2jmobius.commons.util.PropertiesParser;
|
import org.l2jmobius.commons.util.PropertiesParser;
|
||||||
import org.l2jmobius.gameserver.network.loginserverpackets.game.ServerStatus;
|
import org.l2jmobius.gameserver.network.loginserverpackets.game.ServerStatus;
|
||||||
import org.l2jmobius.loginserver.network.LoginClient;
|
import org.l2jmobius.loginserver.network.LoginClient;
|
||||||
@ -95,6 +96,9 @@ public class LoginServer
|
|||||||
// Prepare Database
|
// Prepare Database
|
||||||
DatabaseFactory.init();
|
DatabaseFactory.init();
|
||||||
|
|
||||||
|
// Initialize ThreadPool.
|
||||||
|
ThreadPool.init();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
LoginController.load();
|
LoginController.load();
|
||||||
|
@ -18,10 +18,11 @@ package org.l2jmobius.loginserver.network;
|
|||||||
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import org.l2jmobius.Config;
|
||||||
import org.l2jmobius.commons.network.PacketHandlerInterface;
|
import org.l2jmobius.commons.network.PacketHandlerInterface;
|
||||||
import org.l2jmobius.commons.network.ReadablePacket;
|
import org.l2jmobius.commons.network.ReadablePacket;
|
||||||
|
import org.l2jmobius.commons.threads.ThreadPool;
|
||||||
import org.l2jmobius.commons.util.CommonUtil;
|
import org.l2jmobius.commons.util.CommonUtil;
|
||||||
import org.l2jmobius.gameserver.network.PacketLogger;
|
|
||||||
import org.l2jmobius.loginserver.network.clientpackets.LoginClientPacket;
|
import org.l2jmobius.loginserver.network.clientpackets.LoginClientPacket;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -42,8 +43,8 @@ public class LoginPacketHandler implements PacketHandlerInterface<LoginClient>
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
PacketLogger.warning("LoginPacketHandler: Problem receiving packet id from " + client);
|
LOGGER.warning("LoginPacketHandler: Problem receiving packet id from " + client);
|
||||||
PacketLogger.warning(CommonUtil.getStackTrace(e));
|
LOGGER.warning(CommonUtil.getStackTrace(e));
|
||||||
client.disconnect();
|
client.disconnect();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -75,10 +76,23 @@ public class LoginPacketHandler implements PacketHandlerInterface<LoginClient>
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Continue on another thread.
|
// Continue on another thread.
|
||||||
final Thread thread = new Thread(new ExecuteTask(client, packet, newPacket, packetId), getClass().getName());
|
if (Config.THREADS_FOR_CLIENT_PACKETS)
|
||||||
thread.setPriority(Thread.NORM_PRIORITY);
|
{
|
||||||
thread.setDaemon(false);
|
ThreadPool.execute(new ExecuteTask(client, packet, newPacket, packetId));
|
||||||
thread.start();
|
}
|
||||||
|
else // Wait for execution.
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
newPacket.read(packet);
|
||||||
|
newPacket.run(client);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
LOGGER.warning("LoginPacketHandler: Problem with " + client + " [Packet: 0x" + Integer.toHexString(packetId).toUpperCase() + "]");
|
||||||
|
LOGGER.warning(CommonUtil.getStackTrace(e));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ExecuteTask implements Runnable
|
private class ExecuteTask implements Runnable
|
||||||
|
@ -67,11 +67,33 @@ MySqlBinLocation = C:/xampp/mysql/bin/
|
|||||||
BackupPath = ../backup/
|
BackupPath = ../backup/
|
||||||
|
|
||||||
# Maximum number of days that backups will be kept.
|
# Maximum number of days that backups will be kept.
|
||||||
# Old backups will be deleted.
|
# Old files in backup folder will be deleted.
|
||||||
# Set to 0 to disable.
|
# Set to 0 to disable.
|
||||||
BackupDays = 30
|
BackupDays = 30
|
||||||
|
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
# Thread Configuration
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# Determines the amount of scheduled thread pools. If set to -1, the server will decide the amount depending on the available processors.
|
||||||
|
ScheduledThreadPoolCount = 2
|
||||||
|
|
||||||
|
# Specifies how many threads will be in a single scheduled pool.
|
||||||
|
ThreadsPerScheduledThreadPool = 2
|
||||||
|
|
||||||
|
# Determines the amount of instant thread pools. If set to -1, the server will decide the amount depending on the available processors.
|
||||||
|
InstantThreadPoolCount = 2
|
||||||
|
|
||||||
|
# Specifies how many threads will be in a single instant pool.
|
||||||
|
ThreadsPerInstantThreadPool = 4
|
||||||
|
|
||||||
|
# Use threads to run client packets individually.
|
||||||
|
# Less lag when using threads, but more CPU consumption.
|
||||||
|
# Default: True
|
||||||
|
ThreadsForClientPackets = True
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# Security
|
# Security
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
@ -3616,6 +3616,19 @@ public class Config
|
|||||||
MYSQL_BIN_PATH = loginConfig.getString("MySqlBinLocation", "C:/xampp/mysql/bin/");
|
MYSQL_BIN_PATH = loginConfig.getString("MySqlBinLocation", "C:/xampp/mysql/bin/");
|
||||||
BACKUP_PATH = loginConfig.getString("BackupPath", "../backup/");
|
BACKUP_PATH = loginConfig.getString("BackupPath", "../backup/");
|
||||||
BACKUP_DAYS = loginConfig.getInt("BackupDays", 30);
|
BACKUP_DAYS = loginConfig.getInt("BackupDays", 30);
|
||||||
|
SCHEDULED_THREAD_POOL_COUNT = loginConfig.getInt("ScheduledThreadPoolCount", 2);
|
||||||
|
if (SCHEDULED_THREAD_POOL_COUNT == -1)
|
||||||
|
{
|
||||||
|
SCHEDULED_THREAD_POOL_COUNT = Math.max(2, Runtime.getRuntime().availableProcessors() / 2);
|
||||||
|
}
|
||||||
|
THREADS_PER_SCHEDULED_THREAD_POOL = loginConfig.getInt("ThreadsPerScheduledThreadPool", 2);
|
||||||
|
INSTANT_THREAD_POOL_COUNT = loginConfig.getInt("InstantThreadPoolCount", 2);
|
||||||
|
if (INSTANT_THREAD_POOL_COUNT == -1)
|
||||||
|
{
|
||||||
|
INSTANT_THREAD_POOL_COUNT = Math.max(2, Runtime.getRuntime().availableProcessors() / 2);
|
||||||
|
}
|
||||||
|
THREADS_PER_INSTANT_THREAD_POOL = loginConfig.getInt("ThreadsPerInstantThreadPool", 4);
|
||||||
|
THREADS_FOR_CLIENT_PACKETS = loginConfig.getBoolean("ThreadsForClientPackets", true);
|
||||||
SHOW_LICENCE = loginConfig.getBoolean("ShowLicence", true);
|
SHOW_LICENCE = loginConfig.getBoolean("ShowLicence", true);
|
||||||
SHOW_PI_AGREEMENT = loginConfig.getBoolean("ShowPIAgreement", false);
|
SHOW_PI_AGREEMENT = loginConfig.getBoolean("ShowPIAgreement", false);
|
||||||
AUTO_CREATE_ACCOUNTS = loginConfig.getBoolean("AutoCreateAccounts", true);
|
AUTO_CREATE_ACCOUNTS = loginConfig.getBoolean("AutoCreateAccounts", true);
|
||||||
|
@ -33,6 +33,7 @@ import org.l2jmobius.commons.database.DatabaseBackup;
|
|||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||||
import org.l2jmobius.commons.enums.ServerMode;
|
import org.l2jmobius.commons.enums.ServerMode;
|
||||||
import org.l2jmobius.commons.network.NetServer;
|
import org.l2jmobius.commons.network.NetServer;
|
||||||
|
import org.l2jmobius.commons.threads.ThreadPool;
|
||||||
import org.l2jmobius.commons.util.PropertiesParser;
|
import org.l2jmobius.commons.util.PropertiesParser;
|
||||||
import org.l2jmobius.gameserver.network.loginserverpackets.game.ServerStatus;
|
import org.l2jmobius.gameserver.network.loginserverpackets.game.ServerStatus;
|
||||||
import org.l2jmobius.loginserver.network.LoginClient;
|
import org.l2jmobius.loginserver.network.LoginClient;
|
||||||
@ -95,6 +96,9 @@ public class LoginServer
|
|||||||
// Prepare Database
|
// Prepare Database
|
||||||
DatabaseFactory.init();
|
DatabaseFactory.init();
|
||||||
|
|
||||||
|
// Initialize ThreadPool.
|
||||||
|
ThreadPool.init();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
LoginController.load();
|
LoginController.load();
|
||||||
|
@ -18,10 +18,11 @@ package org.l2jmobius.loginserver.network;
|
|||||||
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import org.l2jmobius.Config;
|
||||||
import org.l2jmobius.commons.network.PacketHandlerInterface;
|
import org.l2jmobius.commons.network.PacketHandlerInterface;
|
||||||
import org.l2jmobius.commons.network.ReadablePacket;
|
import org.l2jmobius.commons.network.ReadablePacket;
|
||||||
|
import org.l2jmobius.commons.threads.ThreadPool;
|
||||||
import org.l2jmobius.commons.util.CommonUtil;
|
import org.l2jmobius.commons.util.CommonUtil;
|
||||||
import org.l2jmobius.gameserver.network.PacketLogger;
|
|
||||||
import org.l2jmobius.loginserver.network.clientpackets.LoginClientPacket;
|
import org.l2jmobius.loginserver.network.clientpackets.LoginClientPacket;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -42,8 +43,8 @@ public class LoginPacketHandler implements PacketHandlerInterface<LoginClient>
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
PacketLogger.warning("LoginPacketHandler: Problem receiving packet id from " + client);
|
LOGGER.warning("LoginPacketHandler: Problem receiving packet id from " + client);
|
||||||
PacketLogger.warning(CommonUtil.getStackTrace(e));
|
LOGGER.warning(CommonUtil.getStackTrace(e));
|
||||||
client.disconnect();
|
client.disconnect();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -75,10 +76,23 @@ public class LoginPacketHandler implements PacketHandlerInterface<LoginClient>
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Continue on another thread.
|
// Continue on another thread.
|
||||||
final Thread thread = new Thread(new ExecuteTask(client, packet, newPacket, packetId), getClass().getName());
|
if (Config.THREADS_FOR_CLIENT_PACKETS)
|
||||||
thread.setPriority(Thread.NORM_PRIORITY);
|
{
|
||||||
thread.setDaemon(false);
|
ThreadPool.execute(new ExecuteTask(client, packet, newPacket, packetId));
|
||||||
thread.start();
|
}
|
||||||
|
else // Wait for execution.
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
newPacket.read(packet);
|
||||||
|
newPacket.run(client);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
LOGGER.warning("LoginPacketHandler: Problem with " + client + " [Packet: 0x" + Integer.toHexString(packetId).toUpperCase() + "]");
|
||||||
|
LOGGER.warning(CommonUtil.getStackTrace(e));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ExecuteTask implements Runnable
|
private class ExecuteTask implements Runnable
|
||||||
|
@ -67,11 +67,33 @@ MySqlBinLocation = C:/xampp/mysql/bin/
|
|||||||
BackupPath = ../backup/
|
BackupPath = ../backup/
|
||||||
|
|
||||||
# Maximum number of days that backups will be kept.
|
# Maximum number of days that backups will be kept.
|
||||||
# Old backups will be deleted.
|
# Old files in backup folder will be deleted.
|
||||||
# Set to 0 to disable.
|
# Set to 0 to disable.
|
||||||
BackupDays = 30
|
BackupDays = 30
|
||||||
|
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
# Thread Configuration
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# Determines the amount of scheduled thread pools. If set to -1, the server will decide the amount depending on the available processors.
|
||||||
|
ScheduledThreadPoolCount = 2
|
||||||
|
|
||||||
|
# Specifies how many threads will be in a single scheduled pool.
|
||||||
|
ThreadsPerScheduledThreadPool = 2
|
||||||
|
|
||||||
|
# Determines the amount of instant thread pools. If set to -1, the server will decide the amount depending on the available processors.
|
||||||
|
InstantThreadPoolCount = 2
|
||||||
|
|
||||||
|
# Specifies how many threads will be in a single instant pool.
|
||||||
|
ThreadsPerInstantThreadPool = 4
|
||||||
|
|
||||||
|
# Use threads to run client packets individually.
|
||||||
|
# Less lag when using threads, but more CPU consumption.
|
||||||
|
# Default: True
|
||||||
|
ThreadsForClientPackets = True
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# Security
|
# Security
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
@ -3659,6 +3659,19 @@ public class Config
|
|||||||
MYSQL_BIN_PATH = loginConfig.getString("MySqlBinLocation", "C:/xampp/mysql/bin/");
|
MYSQL_BIN_PATH = loginConfig.getString("MySqlBinLocation", "C:/xampp/mysql/bin/");
|
||||||
BACKUP_PATH = loginConfig.getString("BackupPath", "../backup/");
|
BACKUP_PATH = loginConfig.getString("BackupPath", "../backup/");
|
||||||
BACKUP_DAYS = loginConfig.getInt("BackupDays", 30);
|
BACKUP_DAYS = loginConfig.getInt("BackupDays", 30);
|
||||||
|
SCHEDULED_THREAD_POOL_COUNT = loginConfig.getInt("ScheduledThreadPoolCount", 2);
|
||||||
|
if (SCHEDULED_THREAD_POOL_COUNT == -1)
|
||||||
|
{
|
||||||
|
SCHEDULED_THREAD_POOL_COUNT = Math.max(2, Runtime.getRuntime().availableProcessors() / 2);
|
||||||
|
}
|
||||||
|
THREADS_PER_SCHEDULED_THREAD_POOL = loginConfig.getInt("ThreadsPerScheduledThreadPool", 2);
|
||||||
|
INSTANT_THREAD_POOL_COUNT = loginConfig.getInt("InstantThreadPoolCount", 2);
|
||||||
|
if (INSTANT_THREAD_POOL_COUNT == -1)
|
||||||
|
{
|
||||||
|
INSTANT_THREAD_POOL_COUNT = Math.max(2, Runtime.getRuntime().availableProcessors() / 2);
|
||||||
|
}
|
||||||
|
THREADS_PER_INSTANT_THREAD_POOL = loginConfig.getInt("ThreadsPerInstantThreadPool", 4);
|
||||||
|
THREADS_FOR_CLIENT_PACKETS = loginConfig.getBoolean("ThreadsForClientPackets", true);
|
||||||
SHOW_LICENCE = loginConfig.getBoolean("ShowLicence", true);
|
SHOW_LICENCE = loginConfig.getBoolean("ShowLicence", true);
|
||||||
SHOW_PI_AGREEMENT = loginConfig.getBoolean("ShowPIAgreement", false);
|
SHOW_PI_AGREEMENT = loginConfig.getBoolean("ShowPIAgreement", false);
|
||||||
AUTO_CREATE_ACCOUNTS = loginConfig.getBoolean("AutoCreateAccounts", true);
|
AUTO_CREATE_ACCOUNTS = loginConfig.getBoolean("AutoCreateAccounts", true);
|
||||||
|
@ -33,6 +33,7 @@ import org.l2jmobius.commons.database.DatabaseBackup;
|
|||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||||
import org.l2jmobius.commons.enums.ServerMode;
|
import org.l2jmobius.commons.enums.ServerMode;
|
||||||
import org.l2jmobius.commons.network.NetServer;
|
import org.l2jmobius.commons.network.NetServer;
|
||||||
|
import org.l2jmobius.commons.threads.ThreadPool;
|
||||||
import org.l2jmobius.commons.util.PropertiesParser;
|
import org.l2jmobius.commons.util.PropertiesParser;
|
||||||
import org.l2jmobius.gameserver.network.loginserverpackets.game.ServerStatus;
|
import org.l2jmobius.gameserver.network.loginserverpackets.game.ServerStatus;
|
||||||
import org.l2jmobius.loginserver.network.LoginClient;
|
import org.l2jmobius.loginserver.network.LoginClient;
|
||||||
@ -95,6 +96,9 @@ public class LoginServer
|
|||||||
// Prepare Database
|
// Prepare Database
|
||||||
DatabaseFactory.init();
|
DatabaseFactory.init();
|
||||||
|
|
||||||
|
// Initialize ThreadPool.
|
||||||
|
ThreadPool.init();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
LoginController.load();
|
LoginController.load();
|
||||||
|
@ -18,10 +18,11 @@ package org.l2jmobius.loginserver.network;
|
|||||||
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import org.l2jmobius.Config;
|
||||||
import org.l2jmobius.commons.network.PacketHandlerInterface;
|
import org.l2jmobius.commons.network.PacketHandlerInterface;
|
||||||
import org.l2jmobius.commons.network.ReadablePacket;
|
import org.l2jmobius.commons.network.ReadablePacket;
|
||||||
|
import org.l2jmobius.commons.threads.ThreadPool;
|
||||||
import org.l2jmobius.commons.util.CommonUtil;
|
import org.l2jmobius.commons.util.CommonUtil;
|
||||||
import org.l2jmobius.gameserver.network.PacketLogger;
|
|
||||||
import org.l2jmobius.loginserver.network.clientpackets.LoginClientPacket;
|
import org.l2jmobius.loginserver.network.clientpackets.LoginClientPacket;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -42,8 +43,8 @@ public class LoginPacketHandler implements PacketHandlerInterface<LoginClient>
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
PacketLogger.warning("LoginPacketHandler: Problem receiving packet id from " + client);
|
LOGGER.warning("LoginPacketHandler: Problem receiving packet id from " + client);
|
||||||
PacketLogger.warning(CommonUtil.getStackTrace(e));
|
LOGGER.warning(CommonUtil.getStackTrace(e));
|
||||||
client.disconnect();
|
client.disconnect();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -75,10 +76,23 @@ public class LoginPacketHandler implements PacketHandlerInterface<LoginClient>
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Continue on another thread.
|
// Continue on another thread.
|
||||||
final Thread thread = new Thread(new ExecuteTask(client, packet, newPacket, packetId), getClass().getName());
|
if (Config.THREADS_FOR_CLIENT_PACKETS)
|
||||||
thread.setPriority(Thread.NORM_PRIORITY);
|
{
|
||||||
thread.setDaemon(false);
|
ThreadPool.execute(new ExecuteTask(client, packet, newPacket, packetId));
|
||||||
thread.start();
|
}
|
||||||
|
else // Wait for execution.
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
newPacket.read(packet);
|
||||||
|
newPacket.run(client);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
LOGGER.warning("LoginPacketHandler: Problem with " + client + " [Packet: 0x" + Integer.toHexString(packetId).toUpperCase() + "]");
|
||||||
|
LOGGER.warning(CommonUtil.getStackTrace(e));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ExecuteTask implements Runnable
|
private class ExecuteTask implements Runnable
|
||||||
|
@ -67,11 +67,33 @@ MySqlBinLocation = C:/xampp/mysql/bin/
|
|||||||
BackupPath = ../backup/
|
BackupPath = ../backup/
|
||||||
|
|
||||||
# Maximum number of days that backups will be kept.
|
# Maximum number of days that backups will be kept.
|
||||||
# Old backups will be deleted.
|
# Old files in backup folder will be deleted.
|
||||||
# Set to 0 to disable.
|
# Set to 0 to disable.
|
||||||
BackupDays = 30
|
BackupDays = 30
|
||||||
|
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
# Thread Configuration
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# Determines the amount of scheduled thread pools. If set to -1, the server will decide the amount depending on the available processors.
|
||||||
|
ScheduledThreadPoolCount = 2
|
||||||
|
|
||||||
|
# Specifies how many threads will be in a single scheduled pool.
|
||||||
|
ThreadsPerScheduledThreadPool = 2
|
||||||
|
|
||||||
|
# Determines the amount of instant thread pools. If set to -1, the server will decide the amount depending on the available processors.
|
||||||
|
InstantThreadPoolCount = 2
|
||||||
|
|
||||||
|
# Specifies how many threads will be in a single instant pool.
|
||||||
|
ThreadsPerInstantThreadPool = 4
|
||||||
|
|
||||||
|
# Use threads to run client packets individually.
|
||||||
|
# Less lag when using threads, but more CPU consumption.
|
||||||
|
# Default: True
|
||||||
|
ThreadsForClientPackets = True
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# Security
|
# Security
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
@ -3675,6 +3675,19 @@ public class Config
|
|||||||
MYSQL_BIN_PATH = loginConfig.getString("MySqlBinLocation", "C:/xampp/mysql/bin/");
|
MYSQL_BIN_PATH = loginConfig.getString("MySqlBinLocation", "C:/xampp/mysql/bin/");
|
||||||
BACKUP_PATH = loginConfig.getString("BackupPath", "../backup/");
|
BACKUP_PATH = loginConfig.getString("BackupPath", "../backup/");
|
||||||
BACKUP_DAYS = loginConfig.getInt("BackupDays", 30);
|
BACKUP_DAYS = loginConfig.getInt("BackupDays", 30);
|
||||||
|
SCHEDULED_THREAD_POOL_COUNT = loginConfig.getInt("ScheduledThreadPoolCount", 2);
|
||||||
|
if (SCHEDULED_THREAD_POOL_COUNT == -1)
|
||||||
|
{
|
||||||
|
SCHEDULED_THREAD_POOL_COUNT = Math.max(2, Runtime.getRuntime().availableProcessors() / 2);
|
||||||
|
}
|
||||||
|
THREADS_PER_SCHEDULED_THREAD_POOL = loginConfig.getInt("ThreadsPerScheduledThreadPool", 2);
|
||||||
|
INSTANT_THREAD_POOL_COUNT = loginConfig.getInt("InstantThreadPoolCount", 2);
|
||||||
|
if (INSTANT_THREAD_POOL_COUNT == -1)
|
||||||
|
{
|
||||||
|
INSTANT_THREAD_POOL_COUNT = Math.max(2, Runtime.getRuntime().availableProcessors() / 2);
|
||||||
|
}
|
||||||
|
THREADS_PER_INSTANT_THREAD_POOL = loginConfig.getInt("ThreadsPerInstantThreadPool", 4);
|
||||||
|
THREADS_FOR_CLIENT_PACKETS = loginConfig.getBoolean("ThreadsForClientPackets", true);
|
||||||
SHOW_LICENCE = loginConfig.getBoolean("ShowLicence", true);
|
SHOW_LICENCE = loginConfig.getBoolean("ShowLicence", true);
|
||||||
SHOW_PI_AGREEMENT = loginConfig.getBoolean("ShowPIAgreement", false);
|
SHOW_PI_AGREEMENT = loginConfig.getBoolean("ShowPIAgreement", false);
|
||||||
AUTO_CREATE_ACCOUNTS = loginConfig.getBoolean("AutoCreateAccounts", true);
|
AUTO_CREATE_ACCOUNTS = loginConfig.getBoolean("AutoCreateAccounts", true);
|
||||||
|
@ -33,6 +33,7 @@ import org.l2jmobius.commons.database.DatabaseBackup;
|
|||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||||
import org.l2jmobius.commons.enums.ServerMode;
|
import org.l2jmobius.commons.enums.ServerMode;
|
||||||
import org.l2jmobius.commons.network.NetServer;
|
import org.l2jmobius.commons.network.NetServer;
|
||||||
|
import org.l2jmobius.commons.threads.ThreadPool;
|
||||||
import org.l2jmobius.commons.util.PropertiesParser;
|
import org.l2jmobius.commons.util.PropertiesParser;
|
||||||
import org.l2jmobius.gameserver.network.loginserverpackets.game.ServerStatus;
|
import org.l2jmobius.gameserver.network.loginserverpackets.game.ServerStatus;
|
||||||
import org.l2jmobius.loginserver.network.LoginClient;
|
import org.l2jmobius.loginserver.network.LoginClient;
|
||||||
@ -95,6 +96,9 @@ public class LoginServer
|
|||||||
// Prepare Database
|
// Prepare Database
|
||||||
DatabaseFactory.init();
|
DatabaseFactory.init();
|
||||||
|
|
||||||
|
// Initialize ThreadPool.
|
||||||
|
ThreadPool.init();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
LoginController.load();
|
LoginController.load();
|
||||||
|
@ -18,10 +18,11 @@ package org.l2jmobius.loginserver.network;
|
|||||||
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import org.l2jmobius.Config;
|
||||||
import org.l2jmobius.commons.network.PacketHandlerInterface;
|
import org.l2jmobius.commons.network.PacketHandlerInterface;
|
||||||
import org.l2jmobius.commons.network.ReadablePacket;
|
import org.l2jmobius.commons.network.ReadablePacket;
|
||||||
|
import org.l2jmobius.commons.threads.ThreadPool;
|
||||||
import org.l2jmobius.commons.util.CommonUtil;
|
import org.l2jmobius.commons.util.CommonUtil;
|
||||||
import org.l2jmobius.gameserver.network.PacketLogger;
|
|
||||||
import org.l2jmobius.loginserver.network.clientpackets.LoginClientPacket;
|
import org.l2jmobius.loginserver.network.clientpackets.LoginClientPacket;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -42,8 +43,8 @@ public class LoginPacketHandler implements PacketHandlerInterface<LoginClient>
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
PacketLogger.warning("LoginPacketHandler: Problem receiving packet id from " + client);
|
LOGGER.warning("LoginPacketHandler: Problem receiving packet id from " + client);
|
||||||
PacketLogger.warning(CommonUtil.getStackTrace(e));
|
LOGGER.warning(CommonUtil.getStackTrace(e));
|
||||||
client.disconnect();
|
client.disconnect();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -75,10 +76,23 @@ public class LoginPacketHandler implements PacketHandlerInterface<LoginClient>
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Continue on another thread.
|
// Continue on another thread.
|
||||||
final Thread thread = new Thread(new ExecuteTask(client, packet, newPacket, packetId), getClass().getName());
|
if (Config.THREADS_FOR_CLIENT_PACKETS)
|
||||||
thread.setPriority(Thread.NORM_PRIORITY);
|
{
|
||||||
thread.setDaemon(false);
|
ThreadPool.execute(new ExecuteTask(client, packet, newPacket, packetId));
|
||||||
thread.start();
|
}
|
||||||
|
else // Wait for execution.
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
newPacket.read(packet);
|
||||||
|
newPacket.run(client);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
LOGGER.warning("LoginPacketHandler: Problem with " + client + " [Packet: 0x" + Integer.toHexString(packetId).toUpperCase() + "]");
|
||||||
|
LOGGER.warning(CommonUtil.getStackTrace(e));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ExecuteTask implements Runnable
|
private class ExecuteTask implements Runnable
|
||||||
|
@ -67,11 +67,33 @@ MySqlBinLocation = C:/xampp/mysql/bin/
|
|||||||
BackupPath = ../backup/
|
BackupPath = ../backup/
|
||||||
|
|
||||||
# Maximum number of days that backups will be kept.
|
# Maximum number of days that backups will be kept.
|
||||||
# Old backups will be deleted.
|
# Old files in backup folder will be deleted.
|
||||||
# Set to 0 to disable.
|
# Set to 0 to disable.
|
||||||
BackupDays = 30
|
BackupDays = 30
|
||||||
|
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
# Thread Configuration
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# Determines the amount of scheduled thread pools. If set to -1, the server will decide the amount depending on the available processors.
|
||||||
|
ScheduledThreadPoolCount = 2
|
||||||
|
|
||||||
|
# Specifies how many threads will be in a single scheduled pool.
|
||||||
|
ThreadsPerScheduledThreadPool = 2
|
||||||
|
|
||||||
|
# Determines the amount of instant thread pools. If set to -1, the server will decide the amount depending on the available processors.
|
||||||
|
InstantThreadPoolCount = 2
|
||||||
|
|
||||||
|
# Specifies how many threads will be in a single instant pool.
|
||||||
|
ThreadsPerInstantThreadPool = 4
|
||||||
|
|
||||||
|
# Use threads to run client packets individually.
|
||||||
|
# Less lag when using threads, but more CPU consumption.
|
||||||
|
# Default: True
|
||||||
|
ThreadsForClientPackets = True
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# Security
|
# Security
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
@ -3650,6 +3650,19 @@ public class Config
|
|||||||
MYSQL_BIN_PATH = loginConfig.getString("MySqlBinLocation", "C:/xampp/mysql/bin/");
|
MYSQL_BIN_PATH = loginConfig.getString("MySqlBinLocation", "C:/xampp/mysql/bin/");
|
||||||
BACKUP_PATH = loginConfig.getString("BackupPath", "../backup/");
|
BACKUP_PATH = loginConfig.getString("BackupPath", "../backup/");
|
||||||
BACKUP_DAYS = loginConfig.getInt("BackupDays", 30);
|
BACKUP_DAYS = loginConfig.getInt("BackupDays", 30);
|
||||||
|
SCHEDULED_THREAD_POOL_COUNT = loginConfig.getInt("ScheduledThreadPoolCount", 2);
|
||||||
|
if (SCHEDULED_THREAD_POOL_COUNT == -1)
|
||||||
|
{
|
||||||
|
SCHEDULED_THREAD_POOL_COUNT = Math.max(2, Runtime.getRuntime().availableProcessors() / 2);
|
||||||
|
}
|
||||||
|
THREADS_PER_SCHEDULED_THREAD_POOL = loginConfig.getInt("ThreadsPerScheduledThreadPool", 2);
|
||||||
|
INSTANT_THREAD_POOL_COUNT = loginConfig.getInt("InstantThreadPoolCount", 2);
|
||||||
|
if (INSTANT_THREAD_POOL_COUNT == -1)
|
||||||
|
{
|
||||||
|
INSTANT_THREAD_POOL_COUNT = Math.max(2, Runtime.getRuntime().availableProcessors() / 2);
|
||||||
|
}
|
||||||
|
THREADS_PER_INSTANT_THREAD_POOL = loginConfig.getInt("ThreadsPerInstantThreadPool", 4);
|
||||||
|
THREADS_FOR_CLIENT_PACKETS = loginConfig.getBoolean("ThreadsForClientPackets", true);
|
||||||
SHOW_LICENCE = loginConfig.getBoolean("ShowLicence", true);
|
SHOW_LICENCE = loginConfig.getBoolean("ShowLicence", true);
|
||||||
SHOW_PI_AGREEMENT = loginConfig.getBoolean("ShowPIAgreement", false);
|
SHOW_PI_AGREEMENT = loginConfig.getBoolean("ShowPIAgreement", false);
|
||||||
AUTO_CREATE_ACCOUNTS = loginConfig.getBoolean("AutoCreateAccounts", true);
|
AUTO_CREATE_ACCOUNTS = loginConfig.getBoolean("AutoCreateAccounts", true);
|
||||||
|
@ -33,6 +33,7 @@ import org.l2jmobius.commons.database.DatabaseBackup;
|
|||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||||
import org.l2jmobius.commons.enums.ServerMode;
|
import org.l2jmobius.commons.enums.ServerMode;
|
||||||
import org.l2jmobius.commons.network.NetServer;
|
import org.l2jmobius.commons.network.NetServer;
|
||||||
|
import org.l2jmobius.commons.threads.ThreadPool;
|
||||||
import org.l2jmobius.commons.util.PropertiesParser;
|
import org.l2jmobius.commons.util.PropertiesParser;
|
||||||
import org.l2jmobius.gameserver.network.loginserverpackets.game.ServerStatus;
|
import org.l2jmobius.gameserver.network.loginserverpackets.game.ServerStatus;
|
||||||
import org.l2jmobius.loginserver.network.LoginClient;
|
import org.l2jmobius.loginserver.network.LoginClient;
|
||||||
@ -95,6 +96,9 @@ public class LoginServer
|
|||||||
// Prepare Database
|
// Prepare Database
|
||||||
DatabaseFactory.init();
|
DatabaseFactory.init();
|
||||||
|
|
||||||
|
// Initialize ThreadPool.
|
||||||
|
ThreadPool.init();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
LoginController.load();
|
LoginController.load();
|
||||||
|
@ -18,10 +18,11 @@ package org.l2jmobius.loginserver.network;
|
|||||||
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import org.l2jmobius.Config;
|
||||||
import org.l2jmobius.commons.network.PacketHandlerInterface;
|
import org.l2jmobius.commons.network.PacketHandlerInterface;
|
||||||
import org.l2jmobius.commons.network.ReadablePacket;
|
import org.l2jmobius.commons.network.ReadablePacket;
|
||||||
|
import org.l2jmobius.commons.threads.ThreadPool;
|
||||||
import org.l2jmobius.commons.util.CommonUtil;
|
import org.l2jmobius.commons.util.CommonUtil;
|
||||||
import org.l2jmobius.gameserver.network.PacketLogger;
|
|
||||||
import org.l2jmobius.loginserver.network.clientpackets.LoginClientPacket;
|
import org.l2jmobius.loginserver.network.clientpackets.LoginClientPacket;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -42,8 +43,8 @@ public class LoginPacketHandler implements PacketHandlerInterface<LoginClient>
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
PacketLogger.warning("LoginPacketHandler: Problem receiving packet id from " + client);
|
LOGGER.warning("LoginPacketHandler: Problem receiving packet id from " + client);
|
||||||
PacketLogger.warning(CommonUtil.getStackTrace(e));
|
LOGGER.warning(CommonUtil.getStackTrace(e));
|
||||||
client.disconnect();
|
client.disconnect();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -75,10 +76,23 @@ public class LoginPacketHandler implements PacketHandlerInterface<LoginClient>
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Continue on another thread.
|
// Continue on another thread.
|
||||||
final Thread thread = new Thread(new ExecuteTask(client, packet, newPacket, packetId), getClass().getName());
|
if (Config.THREADS_FOR_CLIENT_PACKETS)
|
||||||
thread.setPriority(Thread.NORM_PRIORITY);
|
{
|
||||||
thread.setDaemon(false);
|
ThreadPool.execute(new ExecuteTask(client, packet, newPacket, packetId));
|
||||||
thread.start();
|
}
|
||||||
|
else // Wait for execution.
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
newPacket.read(packet);
|
||||||
|
newPacket.run(client);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
LOGGER.warning("LoginPacketHandler: Problem with " + client + " [Packet: 0x" + Integer.toHexString(packetId).toUpperCase() + "]");
|
||||||
|
LOGGER.warning(CommonUtil.getStackTrace(e));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ExecuteTask implements Runnable
|
private class ExecuteTask implements Runnable
|
||||||
|
@ -67,11 +67,33 @@ MySqlBinLocation = C:/xampp/mysql/bin/
|
|||||||
BackupPath = ../backup/
|
BackupPath = ../backup/
|
||||||
|
|
||||||
# Maximum number of days that backups will be kept.
|
# Maximum number of days that backups will be kept.
|
||||||
# Old backups will be deleted.
|
# Old files in backup folder will be deleted.
|
||||||
# Set to 0 to disable.
|
# Set to 0 to disable.
|
||||||
BackupDays = 30
|
BackupDays = 30
|
||||||
|
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
# Thread Configuration
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# Determines the amount of scheduled thread pools. If set to -1, the server will decide the amount depending on the available processors.
|
||||||
|
ScheduledThreadPoolCount = 2
|
||||||
|
|
||||||
|
# Specifies how many threads will be in a single scheduled pool.
|
||||||
|
ThreadsPerScheduledThreadPool = 2
|
||||||
|
|
||||||
|
# Determines the amount of instant thread pools. If set to -1, the server will decide the amount depending on the available processors.
|
||||||
|
InstantThreadPoolCount = 2
|
||||||
|
|
||||||
|
# Specifies how many threads will be in a single instant pool.
|
||||||
|
ThreadsPerInstantThreadPool = 4
|
||||||
|
|
||||||
|
# Use threads to run client packets individually.
|
||||||
|
# Less lag when using threads, but more CPU consumption.
|
||||||
|
# Default: True
|
||||||
|
ThreadsForClientPackets = True
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# Security
|
# Security
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
@ -3654,6 +3654,19 @@ public class Config
|
|||||||
MYSQL_BIN_PATH = loginConfig.getString("MySqlBinLocation", "C:/xampp/mysql/bin/");
|
MYSQL_BIN_PATH = loginConfig.getString("MySqlBinLocation", "C:/xampp/mysql/bin/");
|
||||||
BACKUP_PATH = loginConfig.getString("BackupPath", "../backup/");
|
BACKUP_PATH = loginConfig.getString("BackupPath", "../backup/");
|
||||||
BACKUP_DAYS = loginConfig.getInt("BackupDays", 30);
|
BACKUP_DAYS = loginConfig.getInt("BackupDays", 30);
|
||||||
|
SCHEDULED_THREAD_POOL_COUNT = loginConfig.getInt("ScheduledThreadPoolCount", 2);
|
||||||
|
if (SCHEDULED_THREAD_POOL_COUNT == -1)
|
||||||
|
{
|
||||||
|
SCHEDULED_THREAD_POOL_COUNT = Math.max(2, Runtime.getRuntime().availableProcessors() / 2);
|
||||||
|
}
|
||||||
|
THREADS_PER_SCHEDULED_THREAD_POOL = loginConfig.getInt("ThreadsPerScheduledThreadPool", 2);
|
||||||
|
INSTANT_THREAD_POOL_COUNT = loginConfig.getInt("InstantThreadPoolCount", 2);
|
||||||
|
if (INSTANT_THREAD_POOL_COUNT == -1)
|
||||||
|
{
|
||||||
|
INSTANT_THREAD_POOL_COUNT = Math.max(2, Runtime.getRuntime().availableProcessors() / 2);
|
||||||
|
}
|
||||||
|
THREADS_PER_INSTANT_THREAD_POOL = loginConfig.getInt("ThreadsPerInstantThreadPool", 4);
|
||||||
|
THREADS_FOR_CLIENT_PACKETS = loginConfig.getBoolean("ThreadsForClientPackets", true);
|
||||||
SHOW_LICENCE = loginConfig.getBoolean("ShowLicence", true);
|
SHOW_LICENCE = loginConfig.getBoolean("ShowLicence", true);
|
||||||
SHOW_PI_AGREEMENT = loginConfig.getBoolean("ShowPIAgreement", false);
|
SHOW_PI_AGREEMENT = loginConfig.getBoolean("ShowPIAgreement", false);
|
||||||
AUTO_CREATE_ACCOUNTS = loginConfig.getBoolean("AutoCreateAccounts", true);
|
AUTO_CREATE_ACCOUNTS = loginConfig.getBoolean("AutoCreateAccounts", true);
|
||||||
|
@ -33,6 +33,7 @@ import org.l2jmobius.commons.database.DatabaseBackup;
|
|||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||||
import org.l2jmobius.commons.enums.ServerMode;
|
import org.l2jmobius.commons.enums.ServerMode;
|
||||||
import org.l2jmobius.commons.network.NetServer;
|
import org.l2jmobius.commons.network.NetServer;
|
||||||
|
import org.l2jmobius.commons.threads.ThreadPool;
|
||||||
import org.l2jmobius.commons.util.PropertiesParser;
|
import org.l2jmobius.commons.util.PropertiesParser;
|
||||||
import org.l2jmobius.gameserver.network.loginserverpackets.game.ServerStatus;
|
import org.l2jmobius.gameserver.network.loginserverpackets.game.ServerStatus;
|
||||||
import org.l2jmobius.loginserver.network.LoginClient;
|
import org.l2jmobius.loginserver.network.LoginClient;
|
||||||
@ -95,6 +96,9 @@ public class LoginServer
|
|||||||
// Prepare Database
|
// Prepare Database
|
||||||
DatabaseFactory.init();
|
DatabaseFactory.init();
|
||||||
|
|
||||||
|
// Initialize ThreadPool.
|
||||||
|
ThreadPool.init();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
LoginController.load();
|
LoginController.load();
|
||||||
|
@ -18,10 +18,11 @@ package org.l2jmobius.loginserver.network;
|
|||||||
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import org.l2jmobius.Config;
|
||||||
import org.l2jmobius.commons.network.PacketHandlerInterface;
|
import org.l2jmobius.commons.network.PacketHandlerInterface;
|
||||||
import org.l2jmobius.commons.network.ReadablePacket;
|
import org.l2jmobius.commons.network.ReadablePacket;
|
||||||
|
import org.l2jmobius.commons.threads.ThreadPool;
|
||||||
import org.l2jmobius.commons.util.CommonUtil;
|
import org.l2jmobius.commons.util.CommonUtil;
|
||||||
import org.l2jmobius.gameserver.network.PacketLogger;
|
|
||||||
import org.l2jmobius.loginserver.network.clientpackets.LoginClientPacket;
|
import org.l2jmobius.loginserver.network.clientpackets.LoginClientPacket;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -42,8 +43,8 @@ public class LoginPacketHandler implements PacketHandlerInterface<LoginClient>
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
PacketLogger.warning("LoginPacketHandler: Problem receiving packet id from " + client);
|
LOGGER.warning("LoginPacketHandler: Problem receiving packet id from " + client);
|
||||||
PacketLogger.warning(CommonUtil.getStackTrace(e));
|
LOGGER.warning(CommonUtil.getStackTrace(e));
|
||||||
client.disconnect();
|
client.disconnect();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -75,10 +76,23 @@ public class LoginPacketHandler implements PacketHandlerInterface<LoginClient>
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Continue on another thread.
|
// Continue on another thread.
|
||||||
final Thread thread = new Thread(new ExecuteTask(client, packet, newPacket, packetId), getClass().getName());
|
if (Config.THREADS_FOR_CLIENT_PACKETS)
|
||||||
thread.setPriority(Thread.NORM_PRIORITY);
|
{
|
||||||
thread.setDaemon(false);
|
ThreadPool.execute(new ExecuteTask(client, packet, newPacket, packetId));
|
||||||
thread.start();
|
}
|
||||||
|
else // Wait for execution.
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
newPacket.read(packet);
|
||||||
|
newPacket.run(client);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
LOGGER.warning("LoginPacketHandler: Problem with " + client + " [Packet: 0x" + Integer.toHexString(packetId).toUpperCase() + "]");
|
||||||
|
LOGGER.warning(CommonUtil.getStackTrace(e));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ExecuteTask implements Runnable
|
private class ExecuteTask implements Runnable
|
||||||
|
@ -67,11 +67,33 @@ MySqlBinLocation = C:/xampp/mysql/bin/
|
|||||||
BackupPath = ../backup/
|
BackupPath = ../backup/
|
||||||
|
|
||||||
# Maximum number of days that backups will be kept.
|
# Maximum number of days that backups will be kept.
|
||||||
# Old backups will be deleted.
|
# Old files in backup folder will be deleted.
|
||||||
# Set to 0 to disable.
|
# Set to 0 to disable.
|
||||||
BackupDays = 30
|
BackupDays = 30
|
||||||
|
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
# Thread Configuration
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# Determines the amount of scheduled thread pools. If set to -1, the server will decide the amount depending on the available processors.
|
||||||
|
ScheduledThreadPoolCount = 2
|
||||||
|
|
||||||
|
# Specifies how many threads will be in a single scheduled pool.
|
||||||
|
ThreadsPerScheduledThreadPool = 2
|
||||||
|
|
||||||
|
# Determines the amount of instant thread pools. If set to -1, the server will decide the amount depending on the available processors.
|
||||||
|
InstantThreadPoolCount = 2
|
||||||
|
|
||||||
|
# Specifies how many threads will be in a single instant pool.
|
||||||
|
ThreadsPerInstantThreadPool = 4
|
||||||
|
|
||||||
|
# Use threads to run client packets individually.
|
||||||
|
# Less lag when using threads, but more CPU consumption.
|
||||||
|
# Default: True
|
||||||
|
ThreadsForClientPackets = True
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# Security
|
# Security
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
@ -3656,6 +3656,19 @@ public class Config
|
|||||||
MYSQL_BIN_PATH = loginConfig.getString("MySqlBinLocation", "C:/xampp/mysql/bin/");
|
MYSQL_BIN_PATH = loginConfig.getString("MySqlBinLocation", "C:/xampp/mysql/bin/");
|
||||||
BACKUP_PATH = loginConfig.getString("BackupPath", "../backup/");
|
BACKUP_PATH = loginConfig.getString("BackupPath", "../backup/");
|
||||||
BACKUP_DAYS = loginConfig.getInt("BackupDays", 30);
|
BACKUP_DAYS = loginConfig.getInt("BackupDays", 30);
|
||||||
|
SCHEDULED_THREAD_POOL_COUNT = loginConfig.getInt("ScheduledThreadPoolCount", 2);
|
||||||
|
if (SCHEDULED_THREAD_POOL_COUNT == -1)
|
||||||
|
{
|
||||||
|
SCHEDULED_THREAD_POOL_COUNT = Math.max(2, Runtime.getRuntime().availableProcessors() / 2);
|
||||||
|
}
|
||||||
|
THREADS_PER_SCHEDULED_THREAD_POOL = loginConfig.getInt("ThreadsPerScheduledThreadPool", 2);
|
||||||
|
INSTANT_THREAD_POOL_COUNT = loginConfig.getInt("InstantThreadPoolCount", 2);
|
||||||
|
if (INSTANT_THREAD_POOL_COUNT == -1)
|
||||||
|
{
|
||||||
|
INSTANT_THREAD_POOL_COUNT = Math.max(2, Runtime.getRuntime().availableProcessors() / 2);
|
||||||
|
}
|
||||||
|
THREADS_PER_INSTANT_THREAD_POOL = loginConfig.getInt("ThreadsPerInstantThreadPool", 4);
|
||||||
|
THREADS_FOR_CLIENT_PACKETS = loginConfig.getBoolean("ThreadsForClientPackets", true);
|
||||||
SHOW_LICENCE = loginConfig.getBoolean("ShowLicence", true);
|
SHOW_LICENCE = loginConfig.getBoolean("ShowLicence", true);
|
||||||
SHOW_PI_AGREEMENT = loginConfig.getBoolean("ShowPIAgreement", false);
|
SHOW_PI_AGREEMENT = loginConfig.getBoolean("ShowPIAgreement", false);
|
||||||
AUTO_CREATE_ACCOUNTS = loginConfig.getBoolean("AutoCreateAccounts", true);
|
AUTO_CREATE_ACCOUNTS = loginConfig.getBoolean("AutoCreateAccounts", true);
|
||||||
|
@ -33,6 +33,7 @@ import org.l2jmobius.commons.database.DatabaseBackup;
|
|||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||||
import org.l2jmobius.commons.enums.ServerMode;
|
import org.l2jmobius.commons.enums.ServerMode;
|
||||||
import org.l2jmobius.commons.network.NetServer;
|
import org.l2jmobius.commons.network.NetServer;
|
||||||
|
import org.l2jmobius.commons.threads.ThreadPool;
|
||||||
import org.l2jmobius.commons.util.PropertiesParser;
|
import org.l2jmobius.commons.util.PropertiesParser;
|
||||||
import org.l2jmobius.gameserver.network.loginserverpackets.game.ServerStatus;
|
import org.l2jmobius.gameserver.network.loginserverpackets.game.ServerStatus;
|
||||||
import org.l2jmobius.loginserver.network.LoginClient;
|
import org.l2jmobius.loginserver.network.LoginClient;
|
||||||
@ -95,6 +96,9 @@ public class LoginServer
|
|||||||
// Prepare Database
|
// Prepare Database
|
||||||
DatabaseFactory.init();
|
DatabaseFactory.init();
|
||||||
|
|
||||||
|
// Initialize ThreadPool.
|
||||||
|
ThreadPool.init();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
LoginController.load();
|
LoginController.load();
|
||||||
|
@ -18,10 +18,11 @@ package org.l2jmobius.loginserver.network;
|
|||||||
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import org.l2jmobius.Config;
|
||||||
import org.l2jmobius.commons.network.PacketHandlerInterface;
|
import org.l2jmobius.commons.network.PacketHandlerInterface;
|
||||||
import org.l2jmobius.commons.network.ReadablePacket;
|
import org.l2jmobius.commons.network.ReadablePacket;
|
||||||
|
import org.l2jmobius.commons.threads.ThreadPool;
|
||||||
import org.l2jmobius.commons.util.CommonUtil;
|
import org.l2jmobius.commons.util.CommonUtil;
|
||||||
import org.l2jmobius.gameserver.network.PacketLogger;
|
|
||||||
import org.l2jmobius.loginserver.network.clientpackets.LoginClientPacket;
|
import org.l2jmobius.loginserver.network.clientpackets.LoginClientPacket;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -42,8 +43,8 @@ public class LoginPacketHandler implements PacketHandlerInterface<LoginClient>
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
PacketLogger.warning("LoginPacketHandler: Problem receiving packet id from " + client);
|
LOGGER.warning("LoginPacketHandler: Problem receiving packet id from " + client);
|
||||||
PacketLogger.warning(CommonUtil.getStackTrace(e));
|
LOGGER.warning(CommonUtil.getStackTrace(e));
|
||||||
client.disconnect();
|
client.disconnect();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -75,10 +76,23 @@ public class LoginPacketHandler implements PacketHandlerInterface<LoginClient>
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Continue on another thread.
|
// Continue on another thread.
|
||||||
final Thread thread = new Thread(new ExecuteTask(client, packet, newPacket, packetId), getClass().getName());
|
if (Config.THREADS_FOR_CLIENT_PACKETS)
|
||||||
thread.setPriority(Thread.NORM_PRIORITY);
|
{
|
||||||
thread.setDaemon(false);
|
ThreadPool.execute(new ExecuteTask(client, packet, newPacket, packetId));
|
||||||
thread.start();
|
}
|
||||||
|
else // Wait for execution.
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
newPacket.read(packet);
|
||||||
|
newPacket.run(client);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
LOGGER.warning("LoginPacketHandler: Problem with " + client + " [Packet: 0x" + Integer.toHexString(packetId).toUpperCase() + "]");
|
||||||
|
LOGGER.warning(CommonUtil.getStackTrace(e));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ExecuteTask implements Runnable
|
private class ExecuteTask implements Runnable
|
||||||
|
@ -67,11 +67,33 @@ MySqlBinLocation = C:/xampp/mysql/bin/
|
|||||||
BackupPath = ../backup/
|
BackupPath = ../backup/
|
||||||
|
|
||||||
# Maximum number of days that backups will be kept.
|
# Maximum number of days that backups will be kept.
|
||||||
# Old backups will be deleted.
|
# Old files in backup folder will be deleted.
|
||||||
# Set to 0 to disable.
|
# Set to 0 to disable.
|
||||||
BackupDays = 30
|
BackupDays = 30
|
||||||
|
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
# Thread Configuration
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# Determines the amount of scheduled thread pools. If set to -1, the server will decide the amount depending on the available processors.
|
||||||
|
ScheduledThreadPoolCount = 2
|
||||||
|
|
||||||
|
# Specifies how many threads will be in a single scheduled pool.
|
||||||
|
ThreadsPerScheduledThreadPool = 2
|
||||||
|
|
||||||
|
# Determines the amount of instant thread pools. If set to -1, the server will decide the amount depending on the available processors.
|
||||||
|
InstantThreadPoolCount = 2
|
||||||
|
|
||||||
|
# Specifies how many threads will be in a single instant pool.
|
||||||
|
ThreadsPerInstantThreadPool = 4
|
||||||
|
|
||||||
|
# Use threads to run client packets individually.
|
||||||
|
# Less lag when using threads, but more CPU consumption.
|
||||||
|
# Default: True
|
||||||
|
ThreadsForClientPackets = True
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# Security
|
# Security
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
@ -3698,6 +3698,19 @@ public class Config
|
|||||||
MYSQL_BIN_PATH = loginConfig.getString("MySqlBinLocation", "C:/xampp/mysql/bin/");
|
MYSQL_BIN_PATH = loginConfig.getString("MySqlBinLocation", "C:/xampp/mysql/bin/");
|
||||||
BACKUP_PATH = loginConfig.getString("BackupPath", "../backup/");
|
BACKUP_PATH = loginConfig.getString("BackupPath", "../backup/");
|
||||||
BACKUP_DAYS = loginConfig.getInt("BackupDays", 30);
|
BACKUP_DAYS = loginConfig.getInt("BackupDays", 30);
|
||||||
|
SCHEDULED_THREAD_POOL_COUNT = loginConfig.getInt("ScheduledThreadPoolCount", 2);
|
||||||
|
if (SCHEDULED_THREAD_POOL_COUNT == -1)
|
||||||
|
{
|
||||||
|
SCHEDULED_THREAD_POOL_COUNT = Math.max(2, Runtime.getRuntime().availableProcessors() / 2);
|
||||||
|
}
|
||||||
|
THREADS_PER_SCHEDULED_THREAD_POOL = loginConfig.getInt("ThreadsPerScheduledThreadPool", 2);
|
||||||
|
INSTANT_THREAD_POOL_COUNT = loginConfig.getInt("InstantThreadPoolCount", 2);
|
||||||
|
if (INSTANT_THREAD_POOL_COUNT == -1)
|
||||||
|
{
|
||||||
|
INSTANT_THREAD_POOL_COUNT = Math.max(2, Runtime.getRuntime().availableProcessors() / 2);
|
||||||
|
}
|
||||||
|
THREADS_PER_INSTANT_THREAD_POOL = loginConfig.getInt("ThreadsPerInstantThreadPool", 4);
|
||||||
|
THREADS_FOR_CLIENT_PACKETS = loginConfig.getBoolean("ThreadsForClientPackets", true);
|
||||||
SHOW_LICENCE = loginConfig.getBoolean("ShowLicence", true);
|
SHOW_LICENCE = loginConfig.getBoolean("ShowLicence", true);
|
||||||
SHOW_PI_AGREEMENT = loginConfig.getBoolean("ShowPIAgreement", false);
|
SHOW_PI_AGREEMENT = loginConfig.getBoolean("ShowPIAgreement", false);
|
||||||
AUTO_CREATE_ACCOUNTS = loginConfig.getBoolean("AutoCreateAccounts", true);
|
AUTO_CREATE_ACCOUNTS = loginConfig.getBoolean("AutoCreateAccounts", true);
|
||||||
|
@ -33,6 +33,7 @@ import org.l2jmobius.commons.database.DatabaseBackup;
|
|||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||||
import org.l2jmobius.commons.enums.ServerMode;
|
import org.l2jmobius.commons.enums.ServerMode;
|
||||||
import org.l2jmobius.commons.network.NetServer;
|
import org.l2jmobius.commons.network.NetServer;
|
||||||
|
import org.l2jmobius.commons.threads.ThreadPool;
|
||||||
import org.l2jmobius.commons.util.PropertiesParser;
|
import org.l2jmobius.commons.util.PropertiesParser;
|
||||||
import org.l2jmobius.gameserver.network.loginserverpackets.game.ServerStatus;
|
import org.l2jmobius.gameserver.network.loginserverpackets.game.ServerStatus;
|
||||||
import org.l2jmobius.loginserver.network.LoginClient;
|
import org.l2jmobius.loginserver.network.LoginClient;
|
||||||
@ -95,6 +96,9 @@ public class LoginServer
|
|||||||
// Prepare Database
|
// Prepare Database
|
||||||
DatabaseFactory.init();
|
DatabaseFactory.init();
|
||||||
|
|
||||||
|
// Initialize ThreadPool.
|
||||||
|
ThreadPool.init();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
LoginController.load();
|
LoginController.load();
|
||||||
|
@ -18,10 +18,11 @@ package org.l2jmobius.loginserver.network;
|
|||||||
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import org.l2jmobius.Config;
|
||||||
import org.l2jmobius.commons.network.PacketHandlerInterface;
|
import org.l2jmobius.commons.network.PacketHandlerInterface;
|
||||||
import org.l2jmobius.commons.network.ReadablePacket;
|
import org.l2jmobius.commons.network.ReadablePacket;
|
||||||
|
import org.l2jmobius.commons.threads.ThreadPool;
|
||||||
import org.l2jmobius.commons.util.CommonUtil;
|
import org.l2jmobius.commons.util.CommonUtil;
|
||||||
import org.l2jmobius.gameserver.network.PacketLogger;
|
|
||||||
import org.l2jmobius.loginserver.network.clientpackets.LoginClientPacket;
|
import org.l2jmobius.loginserver.network.clientpackets.LoginClientPacket;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -42,8 +43,8 @@ public class LoginPacketHandler implements PacketHandlerInterface<LoginClient>
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
PacketLogger.warning("LoginPacketHandler: Problem receiving packet id from " + client);
|
LOGGER.warning("LoginPacketHandler: Problem receiving packet id from " + client);
|
||||||
PacketLogger.warning(CommonUtil.getStackTrace(e));
|
LOGGER.warning(CommonUtil.getStackTrace(e));
|
||||||
client.disconnect();
|
client.disconnect();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -75,10 +76,23 @@ public class LoginPacketHandler implements PacketHandlerInterface<LoginClient>
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Continue on another thread.
|
// Continue on another thread.
|
||||||
final Thread thread = new Thread(new ExecuteTask(client, packet, newPacket, packetId), getClass().getName());
|
if (Config.THREADS_FOR_CLIENT_PACKETS)
|
||||||
thread.setPriority(Thread.NORM_PRIORITY);
|
{
|
||||||
thread.setDaemon(false);
|
ThreadPool.execute(new ExecuteTask(client, packet, newPacket, packetId));
|
||||||
thread.start();
|
}
|
||||||
|
else // Wait for execution.
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
newPacket.read(packet);
|
||||||
|
newPacket.run(client);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
LOGGER.warning("LoginPacketHandler: Problem with " + client + " [Packet: 0x" + Integer.toHexString(packetId).toUpperCase() + "]");
|
||||||
|
LOGGER.warning(CommonUtil.getStackTrace(e));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ExecuteTask implements Runnable
|
private class ExecuteTask implements Runnable
|
||||||
|
@ -67,11 +67,33 @@ MySqlBinLocation = C:/xampp/mysql/bin/
|
|||||||
BackupPath = ../backup/
|
BackupPath = ../backup/
|
||||||
|
|
||||||
# Maximum number of days that backups will be kept.
|
# Maximum number of days that backups will be kept.
|
||||||
# Old backups will be deleted.
|
# Old files in backup folder will be deleted.
|
||||||
# Set to 0 to disable.
|
# Set to 0 to disable.
|
||||||
BackupDays = 30
|
BackupDays = 30
|
||||||
|
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
# Thread Configuration
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# Determines the amount of scheduled thread pools. If set to -1, the server will decide the amount depending on the available processors.
|
||||||
|
ScheduledThreadPoolCount = 2
|
||||||
|
|
||||||
|
# Specifies how many threads will be in a single scheduled pool.
|
||||||
|
ThreadsPerScheduledThreadPool = 2
|
||||||
|
|
||||||
|
# Determines the amount of instant thread pools. If set to -1, the server will decide the amount depending on the available processors.
|
||||||
|
InstantThreadPoolCount = 2
|
||||||
|
|
||||||
|
# Specifies how many threads will be in a single instant pool.
|
||||||
|
ThreadsPerInstantThreadPool = 4
|
||||||
|
|
||||||
|
# Use threads to run client packets individually.
|
||||||
|
# Less lag when using threads, but more CPU consumption.
|
||||||
|
# Default: True
|
||||||
|
ThreadsForClientPackets = True
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# Security
|
# Security
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
@ -2897,6 +2897,19 @@ public class Config
|
|||||||
MYSQL_BIN_PATH = serverSettings.getString("MySqlBinLocation", "C:/xampp/mysql/bin/");
|
MYSQL_BIN_PATH = serverSettings.getString("MySqlBinLocation", "C:/xampp/mysql/bin/");
|
||||||
BACKUP_PATH = serverSettings.getString("BackupPath", "../backup/");
|
BACKUP_PATH = serverSettings.getString("BackupPath", "../backup/");
|
||||||
BACKUP_DAYS = serverSettings.getInt("BackupDays", 30);
|
BACKUP_DAYS = serverSettings.getInt("BackupDays", 30);
|
||||||
|
SCHEDULED_THREAD_POOL_COUNT = serverSettings.getInt("ScheduledThreadPoolCount", 2);
|
||||||
|
if (SCHEDULED_THREAD_POOL_COUNT == -1)
|
||||||
|
{
|
||||||
|
SCHEDULED_THREAD_POOL_COUNT = Math.max(2, Runtime.getRuntime().availableProcessors() / 2);
|
||||||
|
}
|
||||||
|
THREADS_PER_SCHEDULED_THREAD_POOL = serverSettings.getInt("ThreadsPerScheduledThreadPool", 2);
|
||||||
|
INSTANT_THREAD_POOL_COUNT = serverSettings.getInt("InstantThreadPoolCount", 2);
|
||||||
|
if (INSTANT_THREAD_POOL_COUNT == -1)
|
||||||
|
{
|
||||||
|
INSTANT_THREAD_POOL_COUNT = Math.max(2, Runtime.getRuntime().availableProcessors() / 2);
|
||||||
|
}
|
||||||
|
THREADS_PER_INSTANT_THREAD_POOL = serverSettings.getInt("ThreadsPerInstantThreadPool", 4);
|
||||||
|
THREADS_FOR_CLIENT_PACKETS = serverSettings.getBoolean("ThreadsForClientPackets", true);
|
||||||
SHOW_LICENCE = serverSettings.getBoolean("ShowLicence", false);
|
SHOW_LICENCE = serverSettings.getBoolean("ShowLicence", false);
|
||||||
AUTO_CREATE_ACCOUNTS = serverSettings.getBoolean("AutoCreateAccounts", true);
|
AUTO_CREATE_ACCOUNTS = serverSettings.getBoolean("AutoCreateAccounts", true);
|
||||||
FLOOD_PROTECTION = serverSettings.getBoolean("EnableFloodProtection", true);
|
FLOOD_PROTECTION = serverSettings.getBoolean("EnableFloodProtection", true);
|
||||||
|
@ -33,6 +33,7 @@ import org.l2jmobius.commons.database.DatabaseBackup;
|
|||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||||
import org.l2jmobius.commons.enums.ServerMode;
|
import org.l2jmobius.commons.enums.ServerMode;
|
||||||
import org.l2jmobius.commons.network.NetServer;
|
import org.l2jmobius.commons.network.NetServer;
|
||||||
|
import org.l2jmobius.commons.threads.ThreadPool;
|
||||||
import org.l2jmobius.commons.util.PropertiesParser;
|
import org.l2jmobius.commons.util.PropertiesParser;
|
||||||
import org.l2jmobius.gameserver.network.loginserverpackets.game.ServerStatus;
|
import org.l2jmobius.gameserver.network.loginserverpackets.game.ServerStatus;
|
||||||
import org.l2jmobius.loginserver.network.LoginClient;
|
import org.l2jmobius.loginserver.network.LoginClient;
|
||||||
@ -95,6 +96,9 @@ public class LoginServer
|
|||||||
// Prepare Database
|
// Prepare Database
|
||||||
DatabaseFactory.init();
|
DatabaseFactory.init();
|
||||||
|
|
||||||
|
// Initialize ThreadPool.
|
||||||
|
ThreadPool.init();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
LoginController.load();
|
LoginController.load();
|
||||||
|
@ -18,10 +18,11 @@ package org.l2jmobius.loginserver.network;
|
|||||||
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import org.l2jmobius.Config;
|
||||||
import org.l2jmobius.commons.network.PacketHandlerInterface;
|
import org.l2jmobius.commons.network.PacketHandlerInterface;
|
||||||
import org.l2jmobius.commons.network.ReadablePacket;
|
import org.l2jmobius.commons.network.ReadablePacket;
|
||||||
|
import org.l2jmobius.commons.threads.ThreadPool;
|
||||||
import org.l2jmobius.commons.util.CommonUtil;
|
import org.l2jmobius.commons.util.CommonUtil;
|
||||||
import org.l2jmobius.gameserver.network.PacketLogger;
|
|
||||||
import org.l2jmobius.loginserver.network.clientpackets.LoginClientPacket;
|
import org.l2jmobius.loginserver.network.clientpackets.LoginClientPacket;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -42,8 +43,8 @@ public class LoginPacketHandler implements PacketHandlerInterface<LoginClient>
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
PacketLogger.warning("LoginPacketHandler: Problem receiving packet id from " + client);
|
LOGGER.warning("LoginPacketHandler: Problem receiving packet id from " + client);
|
||||||
PacketLogger.warning(CommonUtil.getStackTrace(e));
|
LOGGER.warning(CommonUtil.getStackTrace(e));
|
||||||
client.disconnect();
|
client.disconnect();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -75,10 +76,23 @@ public class LoginPacketHandler implements PacketHandlerInterface<LoginClient>
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Continue on another thread.
|
// Continue on another thread.
|
||||||
final Thread thread = new Thread(new ExecuteTask(client, packet, newPacket, packetId), getClass().getName());
|
if (Config.THREADS_FOR_CLIENT_PACKETS)
|
||||||
thread.setPriority(Thread.NORM_PRIORITY);
|
{
|
||||||
thread.setDaemon(false);
|
ThreadPool.execute(new ExecuteTask(client, packet, newPacket, packetId));
|
||||||
thread.start();
|
}
|
||||||
|
else // Wait for execution.
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
newPacket.read(packet);
|
||||||
|
newPacket.run(client);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
LOGGER.warning("LoginPacketHandler: Problem with " + client + " [Packet: 0x" + Integer.toHexString(packetId).toUpperCase() + "]");
|
||||||
|
LOGGER.warning(CommonUtil.getStackTrace(e));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ExecuteTask implements Runnable
|
private class ExecuteTask implements Runnable
|
||||||
|
@ -67,11 +67,33 @@ MySqlBinLocation = C:/xampp/mysql/bin/
|
|||||||
BackupPath = ../backup/
|
BackupPath = ../backup/
|
||||||
|
|
||||||
# Maximum number of days that backups will be kept.
|
# Maximum number of days that backups will be kept.
|
||||||
# Old backups will be deleted.
|
# Old files in backup folder will be deleted.
|
||||||
# Set to 0 to disable.
|
# Set to 0 to disable.
|
||||||
BackupDays = 30
|
BackupDays = 30
|
||||||
|
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
# Thread Configuration
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# Determines the amount of scheduled thread pools. If set to -1, the server will decide the amount depending on the available processors.
|
||||||
|
ScheduledThreadPoolCount = 2
|
||||||
|
|
||||||
|
# Specifies how many threads will be in a single scheduled pool.
|
||||||
|
ThreadsPerScheduledThreadPool = 2
|
||||||
|
|
||||||
|
# Determines the amount of instant thread pools. If set to -1, the server will decide the amount depending on the available processors.
|
||||||
|
InstantThreadPoolCount = 2
|
||||||
|
|
||||||
|
# Specifies how many threads will be in a single instant pool.
|
||||||
|
ThreadsPerInstantThreadPool = 4
|
||||||
|
|
||||||
|
# Use threads to run client packets individually.
|
||||||
|
# Less lag when using threads, but more CPU consumption.
|
||||||
|
# Default: True
|
||||||
|
ThreadsForClientPackets = True
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# Security
|
# Security
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
@ -3056,6 +3056,19 @@ public class Config
|
|||||||
MYSQL_BIN_PATH = loginConfig.getString("MySqlBinLocation", "C:/xampp/mysql/bin/");
|
MYSQL_BIN_PATH = loginConfig.getString("MySqlBinLocation", "C:/xampp/mysql/bin/");
|
||||||
BACKUP_PATH = loginConfig.getString("BackupPath", "../backup/");
|
BACKUP_PATH = loginConfig.getString("BackupPath", "../backup/");
|
||||||
BACKUP_DAYS = loginConfig.getInt("BackupDays", 30);
|
BACKUP_DAYS = loginConfig.getInt("BackupDays", 30);
|
||||||
|
SCHEDULED_THREAD_POOL_COUNT = loginConfig.getInt("ScheduledThreadPoolCount", 2);
|
||||||
|
if (SCHEDULED_THREAD_POOL_COUNT == -1)
|
||||||
|
{
|
||||||
|
SCHEDULED_THREAD_POOL_COUNT = Math.max(2, Runtime.getRuntime().availableProcessors() / 2);
|
||||||
|
}
|
||||||
|
THREADS_PER_SCHEDULED_THREAD_POOL = loginConfig.getInt("ThreadsPerScheduledThreadPool", 2);
|
||||||
|
INSTANT_THREAD_POOL_COUNT = loginConfig.getInt("InstantThreadPoolCount", 2);
|
||||||
|
if (INSTANT_THREAD_POOL_COUNT == -1)
|
||||||
|
{
|
||||||
|
INSTANT_THREAD_POOL_COUNT = Math.max(2, Runtime.getRuntime().availableProcessors() / 2);
|
||||||
|
}
|
||||||
|
THREADS_PER_INSTANT_THREAD_POOL = loginConfig.getInt("ThreadsPerInstantThreadPool", 4);
|
||||||
|
THREADS_FOR_CLIENT_PACKETS = loginConfig.getBoolean("ThreadsForClientPackets", true);
|
||||||
SHOW_LICENCE = loginConfig.getBoolean("ShowLicence", true);
|
SHOW_LICENCE = loginConfig.getBoolean("ShowLicence", true);
|
||||||
AUTO_CREATE_ACCOUNTS = loginConfig.getBoolean("AutoCreateAccounts", true);
|
AUTO_CREATE_ACCOUNTS = loginConfig.getBoolean("AutoCreateAccounts", true);
|
||||||
FLOOD_PROTECTION = loginConfig.getBoolean("EnableFloodProtection", true);
|
FLOOD_PROTECTION = loginConfig.getBoolean("EnableFloodProtection", true);
|
||||||
|
@ -33,6 +33,7 @@ import org.l2jmobius.commons.database.DatabaseBackup;
|
|||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||||
import org.l2jmobius.commons.enums.ServerMode;
|
import org.l2jmobius.commons.enums.ServerMode;
|
||||||
import org.l2jmobius.commons.network.NetServer;
|
import org.l2jmobius.commons.network.NetServer;
|
||||||
|
import org.l2jmobius.commons.threads.ThreadPool;
|
||||||
import org.l2jmobius.commons.util.PropertiesParser;
|
import org.l2jmobius.commons.util.PropertiesParser;
|
||||||
import org.l2jmobius.gameserver.network.loginserverpackets.game.ServerStatus;
|
import org.l2jmobius.gameserver.network.loginserverpackets.game.ServerStatus;
|
||||||
import org.l2jmobius.loginserver.network.LoginClient;
|
import org.l2jmobius.loginserver.network.LoginClient;
|
||||||
@ -95,6 +96,9 @@ public class LoginServer
|
|||||||
// Prepare Database
|
// Prepare Database
|
||||||
DatabaseFactory.init();
|
DatabaseFactory.init();
|
||||||
|
|
||||||
|
// Initialize ThreadPool.
|
||||||
|
ThreadPool.init();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
LoginController.load();
|
LoginController.load();
|
||||||
|
@ -18,10 +18,11 @@ package org.l2jmobius.loginserver.network;
|
|||||||
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import org.l2jmobius.Config;
|
||||||
import org.l2jmobius.commons.network.PacketHandlerInterface;
|
import org.l2jmobius.commons.network.PacketHandlerInterface;
|
||||||
import org.l2jmobius.commons.network.ReadablePacket;
|
import org.l2jmobius.commons.network.ReadablePacket;
|
||||||
|
import org.l2jmobius.commons.threads.ThreadPool;
|
||||||
import org.l2jmobius.commons.util.CommonUtil;
|
import org.l2jmobius.commons.util.CommonUtil;
|
||||||
import org.l2jmobius.gameserver.network.PacketLogger;
|
|
||||||
import org.l2jmobius.loginserver.network.clientpackets.LoginClientPacket;
|
import org.l2jmobius.loginserver.network.clientpackets.LoginClientPacket;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -42,8 +43,8 @@ public class LoginPacketHandler implements PacketHandlerInterface<LoginClient>
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
PacketLogger.warning("LoginPacketHandler: Problem receiving packet id from " + client);
|
LOGGER.warning("LoginPacketHandler: Problem receiving packet id from " + client);
|
||||||
PacketLogger.warning(CommonUtil.getStackTrace(e));
|
LOGGER.warning(CommonUtil.getStackTrace(e));
|
||||||
client.disconnect();
|
client.disconnect();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -75,10 +76,23 @@ public class LoginPacketHandler implements PacketHandlerInterface<LoginClient>
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Continue on another thread.
|
// Continue on another thread.
|
||||||
final Thread thread = new Thread(new ExecuteTask(client, packet, newPacket, packetId), getClass().getName());
|
if (Config.THREADS_FOR_CLIENT_PACKETS)
|
||||||
thread.setPriority(Thread.NORM_PRIORITY);
|
{
|
||||||
thread.setDaemon(false);
|
ThreadPool.execute(new ExecuteTask(client, packet, newPacket, packetId));
|
||||||
thread.start();
|
}
|
||||||
|
else // Wait for execution.
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
newPacket.read(packet);
|
||||||
|
newPacket.run(client);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
LOGGER.warning("LoginPacketHandler: Problem with " + client + " [Packet: 0x" + Integer.toHexString(packetId).toUpperCase() + "]");
|
||||||
|
LOGGER.warning(CommonUtil.getStackTrace(e));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ExecuteTask implements Runnable
|
private class ExecuteTask implements Runnable
|
||||||
|
@ -67,11 +67,33 @@ MySqlBinLocation = C:/xampp/mysql/bin/
|
|||||||
BackupPath = ../backup/
|
BackupPath = ../backup/
|
||||||
|
|
||||||
# Maximum number of days that backups will be kept.
|
# Maximum number of days that backups will be kept.
|
||||||
# Old backups will be deleted.
|
# Old files in backup folder will be deleted.
|
||||||
# Set to 0 to disable.
|
# Set to 0 to disable.
|
||||||
BackupDays = 30
|
BackupDays = 30
|
||||||
|
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
# Thread Configuration
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# Determines the amount of scheduled thread pools. If set to -1, the server will decide the amount depending on the available processors.
|
||||||
|
ScheduledThreadPoolCount = 2
|
||||||
|
|
||||||
|
# Specifies how many threads will be in a single scheduled pool.
|
||||||
|
ThreadsPerScheduledThreadPool = 2
|
||||||
|
|
||||||
|
# Determines the amount of instant thread pools. If set to -1, the server will decide the amount depending on the available processors.
|
||||||
|
InstantThreadPoolCount = 2
|
||||||
|
|
||||||
|
# Specifies how many threads will be in a single instant pool.
|
||||||
|
ThreadsPerInstantThreadPool = 4
|
||||||
|
|
||||||
|
# Use threads to run client packets individually.
|
||||||
|
# Less lag when using threads, but more CPU consumption.
|
||||||
|
# Default: True
|
||||||
|
ThreadsForClientPackets = True
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# Security
|
# Security
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
@ -3174,6 +3174,19 @@ public class Config
|
|||||||
MYSQL_BIN_PATH = loginConfig.getString("MySqlBinLocation", "C:/xampp/mysql/bin/");
|
MYSQL_BIN_PATH = loginConfig.getString("MySqlBinLocation", "C:/xampp/mysql/bin/");
|
||||||
BACKUP_PATH = loginConfig.getString("BackupPath", "../backup/");
|
BACKUP_PATH = loginConfig.getString("BackupPath", "../backup/");
|
||||||
BACKUP_DAYS = loginConfig.getInt("BackupDays", 30);
|
BACKUP_DAYS = loginConfig.getInt("BackupDays", 30);
|
||||||
|
SCHEDULED_THREAD_POOL_COUNT = loginConfig.getInt("ScheduledThreadPoolCount", 2);
|
||||||
|
if (SCHEDULED_THREAD_POOL_COUNT == -1)
|
||||||
|
{
|
||||||
|
SCHEDULED_THREAD_POOL_COUNT = Math.max(2, Runtime.getRuntime().availableProcessors() / 2);
|
||||||
|
}
|
||||||
|
THREADS_PER_SCHEDULED_THREAD_POOL = loginConfig.getInt("ThreadsPerScheduledThreadPool", 2);
|
||||||
|
INSTANT_THREAD_POOL_COUNT = loginConfig.getInt("InstantThreadPoolCount", 2);
|
||||||
|
if (INSTANT_THREAD_POOL_COUNT == -1)
|
||||||
|
{
|
||||||
|
INSTANT_THREAD_POOL_COUNT = Math.max(2, Runtime.getRuntime().availableProcessors() / 2);
|
||||||
|
}
|
||||||
|
THREADS_PER_INSTANT_THREAD_POOL = loginConfig.getInt("ThreadsPerInstantThreadPool", 4);
|
||||||
|
THREADS_FOR_CLIENT_PACKETS = loginConfig.getBoolean("ThreadsForClientPackets", true);
|
||||||
SHOW_LICENCE = loginConfig.getBoolean("ShowLicence", true);
|
SHOW_LICENCE = loginConfig.getBoolean("ShowLicence", true);
|
||||||
AUTO_CREATE_ACCOUNTS = loginConfig.getBoolean("AutoCreateAccounts", true);
|
AUTO_CREATE_ACCOUNTS = loginConfig.getBoolean("AutoCreateAccounts", true);
|
||||||
FLOOD_PROTECTION = loginConfig.getBoolean("EnableFloodProtection", true);
|
FLOOD_PROTECTION = loginConfig.getBoolean("EnableFloodProtection", true);
|
||||||
|
@ -33,6 +33,7 @@ import org.l2jmobius.commons.database.DatabaseBackup;
|
|||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||||
import org.l2jmobius.commons.enums.ServerMode;
|
import org.l2jmobius.commons.enums.ServerMode;
|
||||||
import org.l2jmobius.commons.network.NetServer;
|
import org.l2jmobius.commons.network.NetServer;
|
||||||
|
import org.l2jmobius.commons.threads.ThreadPool;
|
||||||
import org.l2jmobius.commons.util.PropertiesParser;
|
import org.l2jmobius.commons.util.PropertiesParser;
|
||||||
import org.l2jmobius.gameserver.network.loginserverpackets.game.ServerStatus;
|
import org.l2jmobius.gameserver.network.loginserverpackets.game.ServerStatus;
|
||||||
import org.l2jmobius.loginserver.network.LoginClient;
|
import org.l2jmobius.loginserver.network.LoginClient;
|
||||||
@ -95,6 +96,9 @@ public class LoginServer
|
|||||||
// Prepare Database
|
// Prepare Database
|
||||||
DatabaseFactory.init();
|
DatabaseFactory.init();
|
||||||
|
|
||||||
|
// Initialize ThreadPool.
|
||||||
|
ThreadPool.init();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
LoginController.load();
|
LoginController.load();
|
||||||
|
@ -18,10 +18,11 @@ package org.l2jmobius.loginserver.network;
|
|||||||
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import org.l2jmobius.Config;
|
||||||
import org.l2jmobius.commons.network.PacketHandlerInterface;
|
import org.l2jmobius.commons.network.PacketHandlerInterface;
|
||||||
import org.l2jmobius.commons.network.ReadablePacket;
|
import org.l2jmobius.commons.network.ReadablePacket;
|
||||||
|
import org.l2jmobius.commons.threads.ThreadPool;
|
||||||
import org.l2jmobius.commons.util.CommonUtil;
|
import org.l2jmobius.commons.util.CommonUtil;
|
||||||
import org.l2jmobius.gameserver.network.PacketLogger;
|
|
||||||
import org.l2jmobius.loginserver.network.clientpackets.LoginClientPacket;
|
import org.l2jmobius.loginserver.network.clientpackets.LoginClientPacket;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -42,8 +43,8 @@ public class LoginPacketHandler implements PacketHandlerInterface<LoginClient>
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
PacketLogger.warning("LoginPacketHandler: Problem receiving packet id from " + client);
|
LOGGER.warning("LoginPacketHandler: Problem receiving packet id from " + client);
|
||||||
PacketLogger.warning(CommonUtil.getStackTrace(e));
|
LOGGER.warning(CommonUtil.getStackTrace(e));
|
||||||
client.disconnect();
|
client.disconnect();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -75,10 +76,23 @@ public class LoginPacketHandler implements PacketHandlerInterface<LoginClient>
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Continue on another thread.
|
// Continue on another thread.
|
||||||
final Thread thread = new Thread(new ExecuteTask(client, packet, newPacket, packetId), getClass().getName());
|
if (Config.THREADS_FOR_CLIENT_PACKETS)
|
||||||
thread.setPriority(Thread.NORM_PRIORITY);
|
{
|
||||||
thread.setDaemon(false);
|
ThreadPool.execute(new ExecuteTask(client, packet, newPacket, packetId));
|
||||||
thread.start();
|
}
|
||||||
|
else // Wait for execution.
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
newPacket.read(packet);
|
||||||
|
newPacket.run(client);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
LOGGER.warning("LoginPacketHandler: Problem with " + client + " [Packet: 0x" + Integer.toHexString(packetId).toUpperCase() + "]");
|
||||||
|
LOGGER.warning(CommonUtil.getStackTrace(e));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ExecuteTask implements Runnable
|
private class ExecuteTask implements Runnable
|
||||||
|
@ -67,11 +67,33 @@ MySqlBinLocation = C:/xampp/mysql/bin/
|
|||||||
BackupPath = ../backup/
|
BackupPath = ../backup/
|
||||||
|
|
||||||
# Maximum number of days that backups will be kept.
|
# Maximum number of days that backups will be kept.
|
||||||
# Old backups will be deleted.
|
# Old files in backup folder will be deleted.
|
||||||
# Set to 0 to disable.
|
# Set to 0 to disable.
|
||||||
BackupDays = 30
|
BackupDays = 30
|
||||||
|
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
# Thread Configuration
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# Determines the amount of scheduled thread pools. If set to -1, the server will decide the amount depending on the available processors.
|
||||||
|
ScheduledThreadPoolCount = 2
|
||||||
|
|
||||||
|
# Specifies how many threads will be in a single scheduled pool.
|
||||||
|
ThreadsPerScheduledThreadPool = 2
|
||||||
|
|
||||||
|
# Determines the amount of instant thread pools. If set to -1, the server will decide the amount depending on the available processors.
|
||||||
|
InstantThreadPoolCount = 2
|
||||||
|
|
||||||
|
# Specifies how many threads will be in a single instant pool.
|
||||||
|
ThreadsPerInstantThreadPool = 4
|
||||||
|
|
||||||
|
# Use threads to run client packets individually.
|
||||||
|
# Less lag when using threads, but more CPU consumption.
|
||||||
|
# Default: True
|
||||||
|
ThreadsForClientPackets = True
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# Security
|
# Security
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
@ -3181,6 +3181,19 @@ public class Config
|
|||||||
MYSQL_BIN_PATH = loginConfig.getString("MySqlBinLocation", "C:/xampp/mysql/bin/");
|
MYSQL_BIN_PATH = loginConfig.getString("MySqlBinLocation", "C:/xampp/mysql/bin/");
|
||||||
BACKUP_PATH = loginConfig.getString("BackupPath", "../backup/");
|
BACKUP_PATH = loginConfig.getString("BackupPath", "../backup/");
|
||||||
BACKUP_DAYS = loginConfig.getInt("BackupDays", 30);
|
BACKUP_DAYS = loginConfig.getInt("BackupDays", 30);
|
||||||
|
SCHEDULED_THREAD_POOL_COUNT = loginConfig.getInt("ScheduledThreadPoolCount", 2);
|
||||||
|
if (SCHEDULED_THREAD_POOL_COUNT == -1)
|
||||||
|
{
|
||||||
|
SCHEDULED_THREAD_POOL_COUNT = Math.max(2, Runtime.getRuntime().availableProcessors() / 2);
|
||||||
|
}
|
||||||
|
THREADS_PER_SCHEDULED_THREAD_POOL = loginConfig.getInt("ThreadsPerScheduledThreadPool", 2);
|
||||||
|
INSTANT_THREAD_POOL_COUNT = loginConfig.getInt("InstantThreadPoolCount", 2);
|
||||||
|
if (INSTANT_THREAD_POOL_COUNT == -1)
|
||||||
|
{
|
||||||
|
INSTANT_THREAD_POOL_COUNT = Math.max(2, Runtime.getRuntime().availableProcessors() / 2);
|
||||||
|
}
|
||||||
|
THREADS_PER_INSTANT_THREAD_POOL = loginConfig.getInt("ThreadsPerInstantThreadPool", 4);
|
||||||
|
THREADS_FOR_CLIENT_PACKETS = loginConfig.getBoolean("ThreadsForClientPackets", true);
|
||||||
SHOW_LICENCE = loginConfig.getBoolean("ShowLicence", true);
|
SHOW_LICENCE = loginConfig.getBoolean("ShowLicence", true);
|
||||||
AUTO_CREATE_ACCOUNTS = loginConfig.getBoolean("AutoCreateAccounts", true);
|
AUTO_CREATE_ACCOUNTS = loginConfig.getBoolean("AutoCreateAccounts", true);
|
||||||
FLOOD_PROTECTION = loginConfig.getBoolean("EnableFloodProtection", true);
|
FLOOD_PROTECTION = loginConfig.getBoolean("EnableFloodProtection", true);
|
||||||
|
@ -33,6 +33,7 @@ import org.l2jmobius.commons.database.DatabaseBackup;
|
|||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||||
import org.l2jmobius.commons.enums.ServerMode;
|
import org.l2jmobius.commons.enums.ServerMode;
|
||||||
import org.l2jmobius.commons.network.NetServer;
|
import org.l2jmobius.commons.network.NetServer;
|
||||||
|
import org.l2jmobius.commons.threads.ThreadPool;
|
||||||
import org.l2jmobius.commons.util.PropertiesParser;
|
import org.l2jmobius.commons.util.PropertiesParser;
|
||||||
import org.l2jmobius.gameserver.network.loginserverpackets.game.ServerStatus;
|
import org.l2jmobius.gameserver.network.loginserverpackets.game.ServerStatus;
|
||||||
import org.l2jmobius.loginserver.network.LoginClient;
|
import org.l2jmobius.loginserver.network.LoginClient;
|
||||||
@ -95,6 +96,9 @@ public class LoginServer
|
|||||||
// Prepare Database
|
// Prepare Database
|
||||||
DatabaseFactory.init();
|
DatabaseFactory.init();
|
||||||
|
|
||||||
|
// Initialize ThreadPool.
|
||||||
|
ThreadPool.init();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
LoginController.load();
|
LoginController.load();
|
||||||
|
@ -18,10 +18,11 @@ package org.l2jmobius.loginserver.network;
|
|||||||
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import org.l2jmobius.Config;
|
||||||
import org.l2jmobius.commons.network.PacketHandlerInterface;
|
import org.l2jmobius.commons.network.PacketHandlerInterface;
|
||||||
import org.l2jmobius.commons.network.ReadablePacket;
|
import org.l2jmobius.commons.network.ReadablePacket;
|
||||||
|
import org.l2jmobius.commons.threads.ThreadPool;
|
||||||
import org.l2jmobius.commons.util.CommonUtil;
|
import org.l2jmobius.commons.util.CommonUtil;
|
||||||
import org.l2jmobius.gameserver.network.PacketLogger;
|
|
||||||
import org.l2jmobius.loginserver.network.clientpackets.LoginClientPacket;
|
import org.l2jmobius.loginserver.network.clientpackets.LoginClientPacket;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -42,8 +43,8 @@ public class LoginPacketHandler implements PacketHandlerInterface<LoginClient>
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
PacketLogger.warning("LoginPacketHandler: Problem receiving packet id from " + client);
|
LOGGER.warning("LoginPacketHandler: Problem receiving packet id from " + client);
|
||||||
PacketLogger.warning(CommonUtil.getStackTrace(e));
|
LOGGER.warning(CommonUtil.getStackTrace(e));
|
||||||
client.disconnect();
|
client.disconnect();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -75,10 +76,23 @@ public class LoginPacketHandler implements PacketHandlerInterface<LoginClient>
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Continue on another thread.
|
// Continue on another thread.
|
||||||
final Thread thread = new Thread(new ExecuteTask(client, packet, newPacket, packetId), getClass().getName());
|
if (Config.THREADS_FOR_CLIENT_PACKETS)
|
||||||
thread.setPriority(Thread.NORM_PRIORITY);
|
{
|
||||||
thread.setDaemon(false);
|
ThreadPool.execute(new ExecuteTask(client, packet, newPacket, packetId));
|
||||||
thread.start();
|
}
|
||||||
|
else // Wait for execution.
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
newPacket.read(packet);
|
||||||
|
newPacket.run(client);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
LOGGER.warning("LoginPacketHandler: Problem with " + client + " [Packet: 0x" + Integer.toHexString(packetId).toUpperCase() + "]");
|
||||||
|
LOGGER.warning(CommonUtil.getStackTrace(e));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ExecuteTask implements Runnable
|
private class ExecuteTask implements Runnable
|
||||||
|
@ -67,11 +67,33 @@ MySqlBinLocation = C:/xampp/mysql/bin/
|
|||||||
BackupPath = ../backup/
|
BackupPath = ../backup/
|
||||||
|
|
||||||
# Maximum number of days that backups will be kept.
|
# Maximum number of days that backups will be kept.
|
||||||
# Old backups will be deleted.
|
# Old files in backup folder will be deleted.
|
||||||
# Set to 0 to disable.
|
# Set to 0 to disable.
|
||||||
BackupDays = 30
|
BackupDays = 30
|
||||||
|
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
# Thread Configuration
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# Determines the amount of scheduled thread pools. If set to -1, the server will decide the amount depending on the available processors.
|
||||||
|
ScheduledThreadPoolCount = 2
|
||||||
|
|
||||||
|
# Specifies how many threads will be in a single scheduled pool.
|
||||||
|
ThreadsPerScheduledThreadPool = 2
|
||||||
|
|
||||||
|
# Determines the amount of instant thread pools. If set to -1, the server will decide the amount depending on the available processors.
|
||||||
|
InstantThreadPoolCount = 2
|
||||||
|
|
||||||
|
# Specifies how many threads will be in a single instant pool.
|
||||||
|
ThreadsPerInstantThreadPool = 4
|
||||||
|
|
||||||
|
# Use threads to run client packets individually.
|
||||||
|
# Less lag when using threads, but more CPU consumption.
|
||||||
|
# Default: True
|
||||||
|
ThreadsForClientPackets = True
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# Security
|
# Security
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
@ -3464,6 +3464,19 @@ public class Config
|
|||||||
MYSQL_BIN_PATH = loginConfig.getString("MySqlBinLocation", "C:/xampp/mysql/bin/");
|
MYSQL_BIN_PATH = loginConfig.getString("MySqlBinLocation", "C:/xampp/mysql/bin/");
|
||||||
BACKUP_PATH = loginConfig.getString("BackupPath", "../backup/");
|
BACKUP_PATH = loginConfig.getString("BackupPath", "../backup/");
|
||||||
BACKUP_DAYS = loginConfig.getInt("BackupDays", 30);
|
BACKUP_DAYS = loginConfig.getInt("BackupDays", 30);
|
||||||
|
SCHEDULED_THREAD_POOL_COUNT = loginConfig.getInt("ScheduledThreadPoolCount", 2);
|
||||||
|
if (SCHEDULED_THREAD_POOL_COUNT == -1)
|
||||||
|
{
|
||||||
|
SCHEDULED_THREAD_POOL_COUNT = Math.max(2, Runtime.getRuntime().availableProcessors() / 2);
|
||||||
|
}
|
||||||
|
THREADS_PER_SCHEDULED_THREAD_POOL = loginConfig.getInt("ThreadsPerScheduledThreadPool", 2);
|
||||||
|
INSTANT_THREAD_POOL_COUNT = loginConfig.getInt("InstantThreadPoolCount", 2);
|
||||||
|
if (INSTANT_THREAD_POOL_COUNT == -1)
|
||||||
|
{
|
||||||
|
INSTANT_THREAD_POOL_COUNT = Math.max(2, Runtime.getRuntime().availableProcessors() / 2);
|
||||||
|
}
|
||||||
|
THREADS_PER_INSTANT_THREAD_POOL = loginConfig.getInt("ThreadsPerInstantThreadPool", 4);
|
||||||
|
THREADS_FOR_CLIENT_PACKETS = loginConfig.getBoolean("ThreadsForClientPackets", true);
|
||||||
SHOW_LICENCE = loginConfig.getBoolean("ShowLicence", true);
|
SHOW_LICENCE = loginConfig.getBoolean("ShowLicence", true);
|
||||||
SHOW_PI_AGREEMENT = loginConfig.getBoolean("ShowPIAgreement", false);
|
SHOW_PI_AGREEMENT = loginConfig.getBoolean("ShowPIAgreement", false);
|
||||||
AUTO_CREATE_ACCOUNTS = loginConfig.getBoolean("AutoCreateAccounts", true);
|
AUTO_CREATE_ACCOUNTS = loginConfig.getBoolean("AutoCreateAccounts", true);
|
||||||
|
@ -33,6 +33,7 @@ import org.l2jmobius.commons.database.DatabaseBackup;
|
|||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||||
import org.l2jmobius.commons.enums.ServerMode;
|
import org.l2jmobius.commons.enums.ServerMode;
|
||||||
import org.l2jmobius.commons.network.NetServer;
|
import org.l2jmobius.commons.network.NetServer;
|
||||||
|
import org.l2jmobius.commons.threads.ThreadPool;
|
||||||
import org.l2jmobius.commons.util.PropertiesParser;
|
import org.l2jmobius.commons.util.PropertiesParser;
|
||||||
import org.l2jmobius.gameserver.network.loginserverpackets.game.ServerStatus;
|
import org.l2jmobius.gameserver.network.loginserverpackets.game.ServerStatus;
|
||||||
import org.l2jmobius.loginserver.network.LoginClient;
|
import org.l2jmobius.loginserver.network.LoginClient;
|
||||||
@ -95,6 +96,9 @@ public class LoginServer
|
|||||||
// Prepare Database
|
// Prepare Database
|
||||||
DatabaseFactory.init();
|
DatabaseFactory.init();
|
||||||
|
|
||||||
|
// Initialize ThreadPool.
|
||||||
|
ThreadPool.init();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
LoginController.load();
|
LoginController.load();
|
||||||
|
@ -18,10 +18,11 @@ package org.l2jmobius.loginserver.network;
|
|||||||
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import org.l2jmobius.Config;
|
||||||
import org.l2jmobius.commons.network.PacketHandlerInterface;
|
import org.l2jmobius.commons.network.PacketHandlerInterface;
|
||||||
import org.l2jmobius.commons.network.ReadablePacket;
|
import org.l2jmobius.commons.network.ReadablePacket;
|
||||||
|
import org.l2jmobius.commons.threads.ThreadPool;
|
||||||
import org.l2jmobius.commons.util.CommonUtil;
|
import org.l2jmobius.commons.util.CommonUtil;
|
||||||
import org.l2jmobius.gameserver.network.PacketLogger;
|
|
||||||
import org.l2jmobius.loginserver.network.clientpackets.LoginClientPacket;
|
import org.l2jmobius.loginserver.network.clientpackets.LoginClientPacket;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -42,8 +43,8 @@ public class LoginPacketHandler implements PacketHandlerInterface<LoginClient>
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
PacketLogger.warning("LoginPacketHandler: Problem receiving packet id from " + client);
|
LOGGER.warning("LoginPacketHandler: Problem receiving packet id from " + client);
|
||||||
PacketLogger.warning(CommonUtil.getStackTrace(e));
|
LOGGER.warning(CommonUtil.getStackTrace(e));
|
||||||
client.disconnect();
|
client.disconnect();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -75,10 +76,23 @@ public class LoginPacketHandler implements PacketHandlerInterface<LoginClient>
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Continue on another thread.
|
// Continue on another thread.
|
||||||
final Thread thread = new Thread(new ExecuteTask(client, packet, newPacket, packetId), getClass().getName());
|
if (Config.THREADS_FOR_CLIENT_PACKETS)
|
||||||
thread.setPriority(Thread.NORM_PRIORITY);
|
{
|
||||||
thread.setDaemon(false);
|
ThreadPool.execute(new ExecuteTask(client, packet, newPacket, packetId));
|
||||||
thread.start();
|
}
|
||||||
|
else // Wait for execution.
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
newPacket.read(packet);
|
||||||
|
newPacket.run(client);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
LOGGER.warning("LoginPacketHandler: Problem with " + client + " [Packet: 0x" + Integer.toHexString(packetId).toUpperCase() + "]");
|
||||||
|
LOGGER.warning(CommonUtil.getStackTrace(e));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ExecuteTask implements Runnable
|
private class ExecuteTask implements Runnable
|
||||||
|
@ -67,11 +67,33 @@ MySqlBinLocation = C:/xampp/mysql/bin/
|
|||||||
BackupPath = ../backup/
|
BackupPath = ../backup/
|
||||||
|
|
||||||
# Maximum number of days that backups will be kept.
|
# Maximum number of days that backups will be kept.
|
||||||
# Old backups will be deleted.
|
# Old files in backup folder will be deleted.
|
||||||
# Set to 0 to disable.
|
# Set to 0 to disable.
|
||||||
BackupDays = 30
|
BackupDays = 30
|
||||||
|
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
# Thread Configuration
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# Determines the amount of scheduled thread pools. If set to -1, the server will decide the amount depending on the available processors.
|
||||||
|
ScheduledThreadPoolCount = 2
|
||||||
|
|
||||||
|
# Specifies how many threads will be in a single scheduled pool.
|
||||||
|
ThreadsPerScheduledThreadPool = 2
|
||||||
|
|
||||||
|
# Determines the amount of instant thread pools. If set to -1, the server will decide the amount depending on the available processors.
|
||||||
|
InstantThreadPoolCount = 2
|
||||||
|
|
||||||
|
# Specifies how many threads will be in a single instant pool.
|
||||||
|
ThreadsPerInstantThreadPool = 4
|
||||||
|
|
||||||
|
# Use threads to run client packets individually.
|
||||||
|
# Less lag when using threads, but more CPU consumption.
|
||||||
|
# Default: True
|
||||||
|
ThreadsForClientPackets = True
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# Security
|
# Security
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
@ -3510,6 +3510,19 @@ public class Config
|
|||||||
MYSQL_BIN_PATH = loginConfig.getString("MySqlBinLocation", "C:/xampp/mysql/bin/");
|
MYSQL_BIN_PATH = loginConfig.getString("MySqlBinLocation", "C:/xampp/mysql/bin/");
|
||||||
BACKUP_PATH = loginConfig.getString("BackupPath", "../backup/");
|
BACKUP_PATH = loginConfig.getString("BackupPath", "../backup/");
|
||||||
BACKUP_DAYS = loginConfig.getInt("BackupDays", 30);
|
BACKUP_DAYS = loginConfig.getInt("BackupDays", 30);
|
||||||
|
SCHEDULED_THREAD_POOL_COUNT = loginConfig.getInt("ScheduledThreadPoolCount", 2);
|
||||||
|
if (SCHEDULED_THREAD_POOL_COUNT == -1)
|
||||||
|
{
|
||||||
|
SCHEDULED_THREAD_POOL_COUNT = Math.max(2, Runtime.getRuntime().availableProcessors() / 2);
|
||||||
|
}
|
||||||
|
THREADS_PER_SCHEDULED_THREAD_POOL = loginConfig.getInt("ThreadsPerScheduledThreadPool", 2);
|
||||||
|
INSTANT_THREAD_POOL_COUNT = loginConfig.getInt("InstantThreadPoolCount", 2);
|
||||||
|
if (INSTANT_THREAD_POOL_COUNT == -1)
|
||||||
|
{
|
||||||
|
INSTANT_THREAD_POOL_COUNT = Math.max(2, Runtime.getRuntime().availableProcessors() / 2);
|
||||||
|
}
|
||||||
|
THREADS_PER_INSTANT_THREAD_POOL = loginConfig.getInt("ThreadsPerInstantThreadPool", 4);
|
||||||
|
THREADS_FOR_CLIENT_PACKETS = loginConfig.getBoolean("ThreadsForClientPackets", true);
|
||||||
SHOW_LICENCE = loginConfig.getBoolean("ShowLicence", true);
|
SHOW_LICENCE = loginConfig.getBoolean("ShowLicence", true);
|
||||||
SHOW_PI_AGREEMENT = loginConfig.getBoolean("ShowPIAgreement", false);
|
SHOW_PI_AGREEMENT = loginConfig.getBoolean("ShowPIAgreement", false);
|
||||||
AUTO_CREATE_ACCOUNTS = loginConfig.getBoolean("AutoCreateAccounts", true);
|
AUTO_CREATE_ACCOUNTS = loginConfig.getBoolean("AutoCreateAccounts", true);
|
||||||
|
@ -33,6 +33,7 @@ import org.l2jmobius.commons.database.DatabaseBackup;
|
|||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||||
import org.l2jmobius.commons.enums.ServerMode;
|
import org.l2jmobius.commons.enums.ServerMode;
|
||||||
import org.l2jmobius.commons.network.NetServer;
|
import org.l2jmobius.commons.network.NetServer;
|
||||||
|
import org.l2jmobius.commons.threads.ThreadPool;
|
||||||
import org.l2jmobius.commons.util.PropertiesParser;
|
import org.l2jmobius.commons.util.PropertiesParser;
|
||||||
import org.l2jmobius.gameserver.network.loginserverpackets.game.ServerStatus;
|
import org.l2jmobius.gameserver.network.loginserverpackets.game.ServerStatus;
|
||||||
import org.l2jmobius.loginserver.network.LoginClient;
|
import org.l2jmobius.loginserver.network.LoginClient;
|
||||||
@ -95,6 +96,9 @@ public class LoginServer
|
|||||||
// Prepare Database
|
// Prepare Database
|
||||||
DatabaseFactory.init();
|
DatabaseFactory.init();
|
||||||
|
|
||||||
|
// Initialize ThreadPool.
|
||||||
|
ThreadPool.init();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
LoginController.load();
|
LoginController.load();
|
||||||
|
@ -18,10 +18,11 @@ package org.l2jmobius.loginserver.network;
|
|||||||
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import org.l2jmobius.Config;
|
||||||
import org.l2jmobius.commons.network.PacketHandlerInterface;
|
import org.l2jmobius.commons.network.PacketHandlerInterface;
|
||||||
import org.l2jmobius.commons.network.ReadablePacket;
|
import org.l2jmobius.commons.network.ReadablePacket;
|
||||||
|
import org.l2jmobius.commons.threads.ThreadPool;
|
||||||
import org.l2jmobius.commons.util.CommonUtil;
|
import org.l2jmobius.commons.util.CommonUtil;
|
||||||
import org.l2jmobius.gameserver.network.PacketLogger;
|
|
||||||
import org.l2jmobius.loginserver.network.clientpackets.LoginClientPacket;
|
import org.l2jmobius.loginserver.network.clientpackets.LoginClientPacket;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -42,8 +43,8 @@ public class LoginPacketHandler implements PacketHandlerInterface<LoginClient>
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
PacketLogger.warning("LoginPacketHandler: Problem receiving packet id from " + client);
|
LOGGER.warning("LoginPacketHandler: Problem receiving packet id from " + client);
|
||||||
PacketLogger.warning(CommonUtil.getStackTrace(e));
|
LOGGER.warning(CommonUtil.getStackTrace(e));
|
||||||
client.disconnect();
|
client.disconnect();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -75,10 +76,23 @@ public class LoginPacketHandler implements PacketHandlerInterface<LoginClient>
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Continue on another thread.
|
// Continue on another thread.
|
||||||
final Thread thread = new Thread(new ExecuteTask(client, packet, newPacket, packetId), getClass().getName());
|
if (Config.THREADS_FOR_CLIENT_PACKETS)
|
||||||
thread.setPriority(Thread.NORM_PRIORITY);
|
{
|
||||||
thread.setDaemon(false);
|
ThreadPool.execute(new ExecuteTask(client, packet, newPacket, packetId));
|
||||||
thread.start();
|
}
|
||||||
|
else // Wait for execution.
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
newPacket.read(packet);
|
||||||
|
newPacket.run(client);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
LOGGER.warning("LoginPacketHandler: Problem with " + client + " [Packet: 0x" + Integer.toHexString(packetId).toUpperCase() + "]");
|
||||||
|
LOGGER.warning(CommonUtil.getStackTrace(e));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ExecuteTask implements Runnable
|
private class ExecuteTask implements Runnable
|
||||||
|
@ -67,11 +67,33 @@ MySqlBinLocation = C:/xampp/mysql/bin/
|
|||||||
BackupPath = ../backup/
|
BackupPath = ../backup/
|
||||||
|
|
||||||
# Maximum number of days that backups will be kept.
|
# Maximum number of days that backups will be kept.
|
||||||
# Old backups will be deleted.
|
# Old files in backup folder will be deleted.
|
||||||
# Set to 0 to disable.
|
# Set to 0 to disable.
|
||||||
BackupDays = 30
|
BackupDays = 30
|
||||||
|
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
# Thread Configuration
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# Determines the amount of scheduled thread pools. If set to -1, the server will decide the amount depending on the available processors.
|
||||||
|
ScheduledThreadPoolCount = 2
|
||||||
|
|
||||||
|
# Specifies how many threads will be in a single scheduled pool.
|
||||||
|
ThreadsPerScheduledThreadPool = 2
|
||||||
|
|
||||||
|
# Determines the amount of instant thread pools. If set to -1, the server will decide the amount depending on the available processors.
|
||||||
|
InstantThreadPoolCount = 2
|
||||||
|
|
||||||
|
# Specifies how many threads will be in a single instant pool.
|
||||||
|
ThreadsPerInstantThreadPool = 4
|
||||||
|
|
||||||
|
# Use threads to run client packets individually.
|
||||||
|
# Less lag when using threads, but more CPU consumption.
|
||||||
|
# Default: True
|
||||||
|
ThreadsForClientPackets = True
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# Security
|
# Security
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
@ -3516,6 +3516,19 @@ public class Config
|
|||||||
MYSQL_BIN_PATH = loginConfig.getString("MySqlBinLocation", "C:/xampp/mysql/bin/");
|
MYSQL_BIN_PATH = loginConfig.getString("MySqlBinLocation", "C:/xampp/mysql/bin/");
|
||||||
BACKUP_PATH = loginConfig.getString("BackupPath", "../backup/");
|
BACKUP_PATH = loginConfig.getString("BackupPath", "../backup/");
|
||||||
BACKUP_DAYS = loginConfig.getInt("BackupDays", 30);
|
BACKUP_DAYS = loginConfig.getInt("BackupDays", 30);
|
||||||
|
SCHEDULED_THREAD_POOL_COUNT = loginConfig.getInt("ScheduledThreadPoolCount", 2);
|
||||||
|
if (SCHEDULED_THREAD_POOL_COUNT == -1)
|
||||||
|
{
|
||||||
|
SCHEDULED_THREAD_POOL_COUNT = Math.max(2, Runtime.getRuntime().availableProcessors() / 2);
|
||||||
|
}
|
||||||
|
THREADS_PER_SCHEDULED_THREAD_POOL = loginConfig.getInt("ThreadsPerScheduledThreadPool", 2);
|
||||||
|
INSTANT_THREAD_POOL_COUNT = loginConfig.getInt("InstantThreadPoolCount", 2);
|
||||||
|
if (INSTANT_THREAD_POOL_COUNT == -1)
|
||||||
|
{
|
||||||
|
INSTANT_THREAD_POOL_COUNT = Math.max(2, Runtime.getRuntime().availableProcessors() / 2);
|
||||||
|
}
|
||||||
|
THREADS_PER_INSTANT_THREAD_POOL = loginConfig.getInt("ThreadsPerInstantThreadPool", 4);
|
||||||
|
THREADS_FOR_CLIENT_PACKETS = loginConfig.getBoolean("ThreadsForClientPackets", true);
|
||||||
SHOW_LICENCE = loginConfig.getBoolean("ShowLicence", true);
|
SHOW_LICENCE = loginConfig.getBoolean("ShowLicence", true);
|
||||||
SHOW_PI_AGREEMENT = loginConfig.getBoolean("ShowPIAgreement", false);
|
SHOW_PI_AGREEMENT = loginConfig.getBoolean("ShowPIAgreement", false);
|
||||||
AUTO_CREATE_ACCOUNTS = loginConfig.getBoolean("AutoCreateAccounts", true);
|
AUTO_CREATE_ACCOUNTS = loginConfig.getBoolean("AutoCreateAccounts", true);
|
||||||
|
@ -33,6 +33,7 @@ import org.l2jmobius.commons.database.DatabaseBackup;
|
|||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||||
import org.l2jmobius.commons.enums.ServerMode;
|
import org.l2jmobius.commons.enums.ServerMode;
|
||||||
import org.l2jmobius.commons.network.NetServer;
|
import org.l2jmobius.commons.network.NetServer;
|
||||||
|
import org.l2jmobius.commons.threads.ThreadPool;
|
||||||
import org.l2jmobius.commons.util.PropertiesParser;
|
import org.l2jmobius.commons.util.PropertiesParser;
|
||||||
import org.l2jmobius.gameserver.network.loginserverpackets.game.ServerStatus;
|
import org.l2jmobius.gameserver.network.loginserverpackets.game.ServerStatus;
|
||||||
import org.l2jmobius.loginserver.network.LoginClient;
|
import org.l2jmobius.loginserver.network.LoginClient;
|
||||||
@ -95,6 +96,9 @@ public class LoginServer
|
|||||||
// Prepare Database
|
// Prepare Database
|
||||||
DatabaseFactory.init();
|
DatabaseFactory.init();
|
||||||
|
|
||||||
|
// Initialize ThreadPool.
|
||||||
|
ThreadPool.init();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
LoginController.load();
|
LoginController.load();
|
||||||
|
@ -18,10 +18,11 @@ package org.l2jmobius.loginserver.network;
|
|||||||
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import org.l2jmobius.Config;
|
||||||
import org.l2jmobius.commons.network.PacketHandlerInterface;
|
import org.l2jmobius.commons.network.PacketHandlerInterface;
|
||||||
import org.l2jmobius.commons.network.ReadablePacket;
|
import org.l2jmobius.commons.network.ReadablePacket;
|
||||||
|
import org.l2jmobius.commons.threads.ThreadPool;
|
||||||
import org.l2jmobius.commons.util.CommonUtil;
|
import org.l2jmobius.commons.util.CommonUtil;
|
||||||
import org.l2jmobius.gameserver.network.PacketLogger;
|
|
||||||
import org.l2jmobius.loginserver.network.clientpackets.LoginClientPacket;
|
import org.l2jmobius.loginserver.network.clientpackets.LoginClientPacket;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -42,8 +43,8 @@ public class LoginPacketHandler implements PacketHandlerInterface<LoginClient>
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
PacketLogger.warning("LoginPacketHandler: Problem receiving packet id from " + client);
|
LOGGER.warning("LoginPacketHandler: Problem receiving packet id from " + client);
|
||||||
PacketLogger.warning(CommonUtil.getStackTrace(e));
|
LOGGER.warning(CommonUtil.getStackTrace(e));
|
||||||
client.disconnect();
|
client.disconnect();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -75,10 +76,23 @@ public class LoginPacketHandler implements PacketHandlerInterface<LoginClient>
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Continue on another thread.
|
// Continue on another thread.
|
||||||
final Thread thread = new Thread(new ExecuteTask(client, packet, newPacket, packetId), getClass().getName());
|
if (Config.THREADS_FOR_CLIENT_PACKETS)
|
||||||
thread.setPriority(Thread.NORM_PRIORITY);
|
{
|
||||||
thread.setDaemon(false);
|
ThreadPool.execute(new ExecuteTask(client, packet, newPacket, packetId));
|
||||||
thread.start();
|
}
|
||||||
|
else // Wait for execution.
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
newPacket.read(packet);
|
||||||
|
newPacket.run(client);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
LOGGER.warning("LoginPacketHandler: Problem with " + client + " [Packet: 0x" + Integer.toHexString(packetId).toUpperCase() + "]");
|
||||||
|
LOGGER.warning(CommonUtil.getStackTrace(e));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ExecuteTask implements Runnable
|
private class ExecuteTask implements Runnable
|
||||||
|
@ -67,11 +67,33 @@ MySqlBinLocation = C:/xampp/mysql/bin/
|
|||||||
BackupPath = ../backup/
|
BackupPath = ../backup/
|
||||||
|
|
||||||
# Maximum number of days that backups will be kept.
|
# Maximum number of days that backups will be kept.
|
||||||
# Old backups will be deleted.
|
# Old files in backup folder will be deleted.
|
||||||
# Set to 0 to disable.
|
# Set to 0 to disable.
|
||||||
BackupDays = 30
|
BackupDays = 30
|
||||||
|
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
# Thread Configuration
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# Determines the amount of scheduled thread pools. If set to -1, the server will decide the amount depending on the available processors.
|
||||||
|
ScheduledThreadPoolCount = 2
|
||||||
|
|
||||||
|
# Specifies how many threads will be in a single scheduled pool.
|
||||||
|
ThreadsPerScheduledThreadPool = 2
|
||||||
|
|
||||||
|
# Determines the amount of instant thread pools. If set to -1, the server will decide the amount depending on the available processors.
|
||||||
|
InstantThreadPoolCount = 2
|
||||||
|
|
||||||
|
# Specifies how many threads will be in a single instant pool.
|
||||||
|
ThreadsPerInstantThreadPool = 4
|
||||||
|
|
||||||
|
# Use threads to run client packets individually.
|
||||||
|
# Less lag when using threads, but more CPU consumption.
|
||||||
|
# Default: True
|
||||||
|
ThreadsForClientPackets = True
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# Security
|
# Security
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
@ -3522,6 +3522,19 @@ public class Config
|
|||||||
MYSQL_BIN_PATH = loginConfig.getString("MySqlBinLocation", "C:/xampp/mysql/bin/");
|
MYSQL_BIN_PATH = loginConfig.getString("MySqlBinLocation", "C:/xampp/mysql/bin/");
|
||||||
BACKUP_PATH = loginConfig.getString("BackupPath", "../backup/");
|
BACKUP_PATH = loginConfig.getString("BackupPath", "../backup/");
|
||||||
BACKUP_DAYS = loginConfig.getInt("BackupDays", 30);
|
BACKUP_DAYS = loginConfig.getInt("BackupDays", 30);
|
||||||
|
SCHEDULED_THREAD_POOL_COUNT = loginConfig.getInt("ScheduledThreadPoolCount", 2);
|
||||||
|
if (SCHEDULED_THREAD_POOL_COUNT == -1)
|
||||||
|
{
|
||||||
|
SCHEDULED_THREAD_POOL_COUNT = Math.max(2, Runtime.getRuntime().availableProcessors() / 2);
|
||||||
|
}
|
||||||
|
THREADS_PER_SCHEDULED_THREAD_POOL = loginConfig.getInt("ThreadsPerScheduledThreadPool", 2);
|
||||||
|
INSTANT_THREAD_POOL_COUNT = loginConfig.getInt("InstantThreadPoolCount", 2);
|
||||||
|
if (INSTANT_THREAD_POOL_COUNT == -1)
|
||||||
|
{
|
||||||
|
INSTANT_THREAD_POOL_COUNT = Math.max(2, Runtime.getRuntime().availableProcessors() / 2);
|
||||||
|
}
|
||||||
|
THREADS_PER_INSTANT_THREAD_POOL = loginConfig.getInt("ThreadsPerInstantThreadPool", 4);
|
||||||
|
THREADS_FOR_CLIENT_PACKETS = loginConfig.getBoolean("ThreadsForClientPackets", true);
|
||||||
SHOW_LICENCE = loginConfig.getBoolean("ShowLicence", true);
|
SHOW_LICENCE = loginConfig.getBoolean("ShowLicence", true);
|
||||||
SHOW_PI_AGREEMENT = loginConfig.getBoolean("ShowPIAgreement", false);
|
SHOW_PI_AGREEMENT = loginConfig.getBoolean("ShowPIAgreement", false);
|
||||||
AUTO_CREATE_ACCOUNTS = loginConfig.getBoolean("AutoCreateAccounts", true);
|
AUTO_CREATE_ACCOUNTS = loginConfig.getBoolean("AutoCreateAccounts", true);
|
||||||
|
@ -33,6 +33,7 @@ import org.l2jmobius.commons.database.DatabaseBackup;
|
|||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||||
import org.l2jmobius.commons.enums.ServerMode;
|
import org.l2jmobius.commons.enums.ServerMode;
|
||||||
import org.l2jmobius.commons.network.NetServer;
|
import org.l2jmobius.commons.network.NetServer;
|
||||||
|
import org.l2jmobius.commons.threads.ThreadPool;
|
||||||
import org.l2jmobius.commons.util.PropertiesParser;
|
import org.l2jmobius.commons.util.PropertiesParser;
|
||||||
import org.l2jmobius.gameserver.network.loginserverpackets.game.ServerStatus;
|
import org.l2jmobius.gameserver.network.loginserverpackets.game.ServerStatus;
|
||||||
import org.l2jmobius.loginserver.network.LoginClient;
|
import org.l2jmobius.loginserver.network.LoginClient;
|
||||||
@ -95,6 +96,9 @@ public class LoginServer
|
|||||||
// Prepare Database
|
// Prepare Database
|
||||||
DatabaseFactory.init();
|
DatabaseFactory.init();
|
||||||
|
|
||||||
|
// Initialize ThreadPool.
|
||||||
|
ThreadPool.init();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
LoginController.load();
|
LoginController.load();
|
||||||
|
@ -18,10 +18,11 @@ package org.l2jmobius.loginserver.network;
|
|||||||
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import org.l2jmobius.Config;
|
||||||
import org.l2jmobius.commons.network.PacketHandlerInterface;
|
import org.l2jmobius.commons.network.PacketHandlerInterface;
|
||||||
import org.l2jmobius.commons.network.ReadablePacket;
|
import org.l2jmobius.commons.network.ReadablePacket;
|
||||||
|
import org.l2jmobius.commons.threads.ThreadPool;
|
||||||
import org.l2jmobius.commons.util.CommonUtil;
|
import org.l2jmobius.commons.util.CommonUtil;
|
||||||
import org.l2jmobius.gameserver.network.PacketLogger;
|
|
||||||
import org.l2jmobius.loginserver.network.clientpackets.LoginClientPacket;
|
import org.l2jmobius.loginserver.network.clientpackets.LoginClientPacket;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -42,8 +43,8 @@ public class LoginPacketHandler implements PacketHandlerInterface<LoginClient>
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
PacketLogger.warning("LoginPacketHandler: Problem receiving packet id from " + client);
|
LOGGER.warning("LoginPacketHandler: Problem receiving packet id from " + client);
|
||||||
PacketLogger.warning(CommonUtil.getStackTrace(e));
|
LOGGER.warning(CommonUtil.getStackTrace(e));
|
||||||
client.disconnect();
|
client.disconnect();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -75,10 +76,23 @@ public class LoginPacketHandler implements PacketHandlerInterface<LoginClient>
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Continue on another thread.
|
// Continue on another thread.
|
||||||
final Thread thread = new Thread(new ExecuteTask(client, packet, newPacket, packetId), getClass().getName());
|
if (Config.THREADS_FOR_CLIENT_PACKETS)
|
||||||
thread.setPriority(Thread.NORM_PRIORITY);
|
{
|
||||||
thread.setDaemon(false);
|
ThreadPool.execute(new ExecuteTask(client, packet, newPacket, packetId));
|
||||||
thread.start();
|
}
|
||||||
|
else // Wait for execution.
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
newPacket.read(packet);
|
||||||
|
newPacket.run(client);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
LOGGER.warning("LoginPacketHandler: Problem with " + client + " [Packet: 0x" + Integer.toHexString(packetId).toUpperCase() + "]");
|
||||||
|
LOGGER.warning(CommonUtil.getStackTrace(e));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ExecuteTask implements Runnable
|
private class ExecuteTask implements Runnable
|
||||||
|
@ -67,11 +67,33 @@ MySqlBinLocation = C:/xampp/mysql/bin/
|
|||||||
BackupPath = ../backup/
|
BackupPath = ../backup/
|
||||||
|
|
||||||
# Maximum number of days that backups will be kept.
|
# Maximum number of days that backups will be kept.
|
||||||
# Old backups will be deleted.
|
# Old files in backup folder will be deleted.
|
||||||
# Set to 0 to disable.
|
# Set to 0 to disable.
|
||||||
BackupDays = 30
|
BackupDays = 30
|
||||||
|
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
# Thread Configuration
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# Determines the amount of scheduled thread pools. If set to -1, the server will decide the amount depending on the available processors.
|
||||||
|
ScheduledThreadPoolCount = 2
|
||||||
|
|
||||||
|
# Specifies how many threads will be in a single scheduled pool.
|
||||||
|
ThreadsPerScheduledThreadPool = 2
|
||||||
|
|
||||||
|
# Determines the amount of instant thread pools. If set to -1, the server will decide the amount depending on the available processors.
|
||||||
|
InstantThreadPoolCount = 2
|
||||||
|
|
||||||
|
# Specifies how many threads will be in a single instant pool.
|
||||||
|
ThreadsPerInstantThreadPool = 4
|
||||||
|
|
||||||
|
# Use threads to run client packets individually.
|
||||||
|
# Less lag when using threads, but more CPU consumption.
|
||||||
|
# Default: True
|
||||||
|
ThreadsForClientPackets = True
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# Security
|
# Security
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
@ -3522,6 +3522,19 @@ public class Config
|
|||||||
MYSQL_BIN_PATH = loginConfig.getString("MySqlBinLocation", "C:/xampp/mysql/bin/");
|
MYSQL_BIN_PATH = loginConfig.getString("MySqlBinLocation", "C:/xampp/mysql/bin/");
|
||||||
BACKUP_PATH = loginConfig.getString("BackupPath", "../backup/");
|
BACKUP_PATH = loginConfig.getString("BackupPath", "../backup/");
|
||||||
BACKUP_DAYS = loginConfig.getInt("BackupDays", 30);
|
BACKUP_DAYS = loginConfig.getInt("BackupDays", 30);
|
||||||
|
SCHEDULED_THREAD_POOL_COUNT = loginConfig.getInt("ScheduledThreadPoolCount", 2);
|
||||||
|
if (SCHEDULED_THREAD_POOL_COUNT == -1)
|
||||||
|
{
|
||||||
|
SCHEDULED_THREAD_POOL_COUNT = Math.max(2, Runtime.getRuntime().availableProcessors() / 2);
|
||||||
|
}
|
||||||
|
THREADS_PER_SCHEDULED_THREAD_POOL = loginConfig.getInt("ThreadsPerScheduledThreadPool", 2);
|
||||||
|
INSTANT_THREAD_POOL_COUNT = loginConfig.getInt("InstantThreadPoolCount", 2);
|
||||||
|
if (INSTANT_THREAD_POOL_COUNT == -1)
|
||||||
|
{
|
||||||
|
INSTANT_THREAD_POOL_COUNT = Math.max(2, Runtime.getRuntime().availableProcessors() / 2);
|
||||||
|
}
|
||||||
|
THREADS_PER_INSTANT_THREAD_POOL = loginConfig.getInt("ThreadsPerInstantThreadPool", 4);
|
||||||
|
THREADS_FOR_CLIENT_PACKETS = loginConfig.getBoolean("ThreadsForClientPackets", true);
|
||||||
SHOW_LICENCE = loginConfig.getBoolean("ShowLicence", true);
|
SHOW_LICENCE = loginConfig.getBoolean("ShowLicence", true);
|
||||||
SHOW_PI_AGREEMENT = loginConfig.getBoolean("ShowPIAgreement", false);
|
SHOW_PI_AGREEMENT = loginConfig.getBoolean("ShowPIAgreement", false);
|
||||||
AUTO_CREATE_ACCOUNTS = loginConfig.getBoolean("AutoCreateAccounts", true);
|
AUTO_CREATE_ACCOUNTS = loginConfig.getBoolean("AutoCreateAccounts", true);
|
||||||
|
@ -33,6 +33,7 @@ import org.l2jmobius.commons.database.DatabaseBackup;
|
|||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||||
import org.l2jmobius.commons.enums.ServerMode;
|
import org.l2jmobius.commons.enums.ServerMode;
|
||||||
import org.l2jmobius.commons.network.NetServer;
|
import org.l2jmobius.commons.network.NetServer;
|
||||||
|
import org.l2jmobius.commons.threads.ThreadPool;
|
||||||
import org.l2jmobius.commons.util.PropertiesParser;
|
import org.l2jmobius.commons.util.PropertiesParser;
|
||||||
import org.l2jmobius.gameserver.network.loginserverpackets.game.ServerStatus;
|
import org.l2jmobius.gameserver.network.loginserverpackets.game.ServerStatus;
|
||||||
import org.l2jmobius.loginserver.network.LoginClient;
|
import org.l2jmobius.loginserver.network.LoginClient;
|
||||||
@ -95,6 +96,9 @@ public class LoginServer
|
|||||||
// Prepare Database
|
// Prepare Database
|
||||||
DatabaseFactory.init();
|
DatabaseFactory.init();
|
||||||
|
|
||||||
|
// Initialize ThreadPool.
|
||||||
|
ThreadPool.init();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
LoginController.load();
|
LoginController.load();
|
||||||
|
@ -18,10 +18,11 @@ package org.l2jmobius.loginserver.network;
|
|||||||
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import org.l2jmobius.Config;
|
||||||
import org.l2jmobius.commons.network.PacketHandlerInterface;
|
import org.l2jmobius.commons.network.PacketHandlerInterface;
|
||||||
import org.l2jmobius.commons.network.ReadablePacket;
|
import org.l2jmobius.commons.network.ReadablePacket;
|
||||||
|
import org.l2jmobius.commons.threads.ThreadPool;
|
||||||
import org.l2jmobius.commons.util.CommonUtil;
|
import org.l2jmobius.commons.util.CommonUtil;
|
||||||
import org.l2jmobius.gameserver.network.PacketLogger;
|
|
||||||
import org.l2jmobius.loginserver.network.clientpackets.LoginClientPacket;
|
import org.l2jmobius.loginserver.network.clientpackets.LoginClientPacket;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -42,8 +43,8 @@ public class LoginPacketHandler implements PacketHandlerInterface<LoginClient>
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
PacketLogger.warning("LoginPacketHandler: Problem receiving packet id from " + client);
|
LOGGER.warning("LoginPacketHandler: Problem receiving packet id from " + client);
|
||||||
PacketLogger.warning(CommonUtil.getStackTrace(e));
|
LOGGER.warning(CommonUtil.getStackTrace(e));
|
||||||
client.disconnect();
|
client.disconnect();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -75,10 +76,23 @@ public class LoginPacketHandler implements PacketHandlerInterface<LoginClient>
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Continue on another thread.
|
// Continue on another thread.
|
||||||
final Thread thread = new Thread(new ExecuteTask(client, packet, newPacket, packetId), getClass().getName());
|
if (Config.THREADS_FOR_CLIENT_PACKETS)
|
||||||
thread.setPriority(Thread.NORM_PRIORITY);
|
{
|
||||||
thread.setDaemon(false);
|
ThreadPool.execute(new ExecuteTask(client, packet, newPacket, packetId));
|
||||||
thread.start();
|
}
|
||||||
|
else // Wait for execution.
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
newPacket.read(packet);
|
||||||
|
newPacket.run(client);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
LOGGER.warning("LoginPacketHandler: Problem with " + client + " [Packet: 0x" + Integer.toHexString(packetId).toUpperCase() + "]");
|
||||||
|
LOGGER.warning(CommonUtil.getStackTrace(e));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ExecuteTask implements Runnable
|
private class ExecuteTask implements Runnable
|
||||||
|
@ -67,11 +67,33 @@ MySqlBinLocation = C:/xampp/mysql/bin/
|
|||||||
BackupPath = ../backup/
|
BackupPath = ../backup/
|
||||||
|
|
||||||
# Maximum number of days that backups will be kept.
|
# Maximum number of days that backups will be kept.
|
||||||
# Old backups will be deleted.
|
# Old files in backup folder will be deleted.
|
||||||
# Set to 0 to disable.
|
# Set to 0 to disable.
|
||||||
BackupDays = 30
|
BackupDays = 30
|
||||||
|
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
# Thread Configuration
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# Determines the amount of scheduled thread pools. If set to -1, the server will decide the amount depending on the available processors.
|
||||||
|
ScheduledThreadPoolCount = 2
|
||||||
|
|
||||||
|
# Specifies how many threads will be in a single scheduled pool.
|
||||||
|
ThreadsPerScheduledThreadPool = 2
|
||||||
|
|
||||||
|
# Determines the amount of instant thread pools. If set to -1, the server will decide the amount depending on the available processors.
|
||||||
|
InstantThreadPoolCount = 2
|
||||||
|
|
||||||
|
# Specifies how many threads will be in a single instant pool.
|
||||||
|
ThreadsPerInstantThreadPool = 4
|
||||||
|
|
||||||
|
# Use threads to run client packets individually.
|
||||||
|
# Less lag when using threads, but more CPU consumption.
|
||||||
|
# Default: True
|
||||||
|
ThreadsForClientPackets = True
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# Security
|
# Security
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
@ -3522,6 +3522,19 @@ public class Config
|
|||||||
MYSQL_BIN_PATH = loginConfig.getString("MySqlBinLocation", "C:/xampp/mysql/bin/");
|
MYSQL_BIN_PATH = loginConfig.getString("MySqlBinLocation", "C:/xampp/mysql/bin/");
|
||||||
BACKUP_PATH = loginConfig.getString("BackupPath", "../backup/");
|
BACKUP_PATH = loginConfig.getString("BackupPath", "../backup/");
|
||||||
BACKUP_DAYS = loginConfig.getInt("BackupDays", 30);
|
BACKUP_DAYS = loginConfig.getInt("BackupDays", 30);
|
||||||
|
SCHEDULED_THREAD_POOL_COUNT = loginConfig.getInt("ScheduledThreadPoolCount", 2);
|
||||||
|
if (SCHEDULED_THREAD_POOL_COUNT == -1)
|
||||||
|
{
|
||||||
|
SCHEDULED_THREAD_POOL_COUNT = Math.max(2, Runtime.getRuntime().availableProcessors() / 2);
|
||||||
|
}
|
||||||
|
THREADS_PER_SCHEDULED_THREAD_POOL = loginConfig.getInt("ThreadsPerScheduledThreadPool", 2);
|
||||||
|
INSTANT_THREAD_POOL_COUNT = loginConfig.getInt("InstantThreadPoolCount", 2);
|
||||||
|
if (INSTANT_THREAD_POOL_COUNT == -1)
|
||||||
|
{
|
||||||
|
INSTANT_THREAD_POOL_COUNT = Math.max(2, Runtime.getRuntime().availableProcessors() / 2);
|
||||||
|
}
|
||||||
|
THREADS_PER_INSTANT_THREAD_POOL = loginConfig.getInt("ThreadsPerInstantThreadPool", 4);
|
||||||
|
THREADS_FOR_CLIENT_PACKETS = loginConfig.getBoolean("ThreadsForClientPackets", true);
|
||||||
SHOW_LICENCE = loginConfig.getBoolean("ShowLicence", true);
|
SHOW_LICENCE = loginConfig.getBoolean("ShowLicence", true);
|
||||||
SHOW_PI_AGREEMENT = loginConfig.getBoolean("ShowPIAgreement", false);
|
SHOW_PI_AGREEMENT = loginConfig.getBoolean("ShowPIAgreement", false);
|
||||||
AUTO_CREATE_ACCOUNTS = loginConfig.getBoolean("AutoCreateAccounts", true);
|
AUTO_CREATE_ACCOUNTS = loginConfig.getBoolean("AutoCreateAccounts", true);
|
||||||
|
@ -33,6 +33,7 @@ import org.l2jmobius.commons.database.DatabaseBackup;
|
|||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||||
import org.l2jmobius.commons.enums.ServerMode;
|
import org.l2jmobius.commons.enums.ServerMode;
|
||||||
import org.l2jmobius.commons.network.NetServer;
|
import org.l2jmobius.commons.network.NetServer;
|
||||||
|
import org.l2jmobius.commons.threads.ThreadPool;
|
||||||
import org.l2jmobius.commons.util.PropertiesParser;
|
import org.l2jmobius.commons.util.PropertiesParser;
|
||||||
import org.l2jmobius.gameserver.network.loginserverpackets.game.ServerStatus;
|
import org.l2jmobius.gameserver.network.loginserverpackets.game.ServerStatus;
|
||||||
import org.l2jmobius.loginserver.network.LoginClient;
|
import org.l2jmobius.loginserver.network.LoginClient;
|
||||||
@ -95,6 +96,9 @@ public class LoginServer
|
|||||||
// Prepare Database
|
// Prepare Database
|
||||||
DatabaseFactory.init();
|
DatabaseFactory.init();
|
||||||
|
|
||||||
|
// Initialize ThreadPool.
|
||||||
|
ThreadPool.init();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
LoginController.load();
|
LoginController.load();
|
||||||
|
@ -18,10 +18,11 @@ package org.l2jmobius.loginserver.network;
|
|||||||
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import org.l2jmobius.Config;
|
||||||
import org.l2jmobius.commons.network.PacketHandlerInterface;
|
import org.l2jmobius.commons.network.PacketHandlerInterface;
|
||||||
import org.l2jmobius.commons.network.ReadablePacket;
|
import org.l2jmobius.commons.network.ReadablePacket;
|
||||||
|
import org.l2jmobius.commons.threads.ThreadPool;
|
||||||
import org.l2jmobius.commons.util.CommonUtil;
|
import org.l2jmobius.commons.util.CommonUtil;
|
||||||
import org.l2jmobius.gameserver.network.PacketLogger;
|
|
||||||
import org.l2jmobius.loginserver.network.clientpackets.LoginClientPacket;
|
import org.l2jmobius.loginserver.network.clientpackets.LoginClientPacket;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -42,8 +43,8 @@ public class LoginPacketHandler implements PacketHandlerInterface<LoginClient>
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
PacketLogger.warning("LoginPacketHandler: Problem receiving packet id from " + client);
|
LOGGER.warning("LoginPacketHandler: Problem receiving packet id from " + client);
|
||||||
PacketLogger.warning(CommonUtil.getStackTrace(e));
|
LOGGER.warning(CommonUtil.getStackTrace(e));
|
||||||
client.disconnect();
|
client.disconnect();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -75,10 +76,23 @@ public class LoginPacketHandler implements PacketHandlerInterface<LoginClient>
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Continue on another thread.
|
// Continue on another thread.
|
||||||
final Thread thread = new Thread(new ExecuteTask(client, packet, newPacket, packetId), getClass().getName());
|
if (Config.THREADS_FOR_CLIENT_PACKETS)
|
||||||
thread.setPriority(Thread.NORM_PRIORITY);
|
{
|
||||||
thread.setDaemon(false);
|
ThreadPool.execute(new ExecuteTask(client, packet, newPacket, packetId));
|
||||||
thread.start();
|
}
|
||||||
|
else // Wait for execution.
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
newPacket.read(packet);
|
||||||
|
newPacket.run(client);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
LOGGER.warning("LoginPacketHandler: Problem with " + client + " [Packet: 0x" + Integer.toHexString(packetId).toUpperCase() + "]");
|
||||||
|
LOGGER.warning(CommonUtil.getStackTrace(e));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ExecuteTask implements Runnable
|
private class ExecuteTask implements Runnable
|
||||||
|
@ -67,11 +67,33 @@ MySqlBinLocation = C:/xampp/mysql/bin/
|
|||||||
BackupPath = ../backup/
|
BackupPath = ../backup/
|
||||||
|
|
||||||
# Maximum number of days that backups will be kept.
|
# Maximum number of days that backups will be kept.
|
||||||
# Old backups will be deleted.
|
# Old files in backup folder will be deleted.
|
||||||
# Set to 0 to disable.
|
# Set to 0 to disable.
|
||||||
BackupDays = 30
|
BackupDays = 30
|
||||||
|
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
# Thread Configuration
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# Determines the amount of scheduled thread pools. If set to -1, the server will decide the amount depending on the available processors.
|
||||||
|
ScheduledThreadPoolCount = 2
|
||||||
|
|
||||||
|
# Specifies how many threads will be in a single scheduled pool.
|
||||||
|
ThreadsPerScheduledThreadPool = 2
|
||||||
|
|
||||||
|
# Determines the amount of instant thread pools. If set to -1, the server will decide the amount depending on the available processors.
|
||||||
|
InstantThreadPoolCount = 2
|
||||||
|
|
||||||
|
# Specifies how many threads will be in a single instant pool.
|
||||||
|
ThreadsPerInstantThreadPool = 4
|
||||||
|
|
||||||
|
# Use threads to run client packets individually.
|
||||||
|
# Less lag when using threads, but more CPU consumption.
|
||||||
|
# Default: True
|
||||||
|
ThreadsForClientPackets = True
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# Security
|
# Security
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
@ -3545,6 +3545,19 @@ public class Config
|
|||||||
MYSQL_BIN_PATH = loginConfig.getString("MySqlBinLocation", "C:/xampp/mysql/bin/");
|
MYSQL_BIN_PATH = loginConfig.getString("MySqlBinLocation", "C:/xampp/mysql/bin/");
|
||||||
BACKUP_PATH = loginConfig.getString("BackupPath", "../backup/");
|
BACKUP_PATH = loginConfig.getString("BackupPath", "../backup/");
|
||||||
BACKUP_DAYS = loginConfig.getInt("BackupDays", 30);
|
BACKUP_DAYS = loginConfig.getInt("BackupDays", 30);
|
||||||
|
SCHEDULED_THREAD_POOL_COUNT = loginConfig.getInt("ScheduledThreadPoolCount", 2);
|
||||||
|
if (SCHEDULED_THREAD_POOL_COUNT == -1)
|
||||||
|
{
|
||||||
|
SCHEDULED_THREAD_POOL_COUNT = Math.max(2, Runtime.getRuntime().availableProcessors() / 2);
|
||||||
|
}
|
||||||
|
THREADS_PER_SCHEDULED_THREAD_POOL = loginConfig.getInt("ThreadsPerScheduledThreadPool", 2);
|
||||||
|
INSTANT_THREAD_POOL_COUNT = loginConfig.getInt("InstantThreadPoolCount", 2);
|
||||||
|
if (INSTANT_THREAD_POOL_COUNT == -1)
|
||||||
|
{
|
||||||
|
INSTANT_THREAD_POOL_COUNT = Math.max(2, Runtime.getRuntime().availableProcessors() / 2);
|
||||||
|
}
|
||||||
|
THREADS_PER_INSTANT_THREAD_POOL = loginConfig.getInt("ThreadsPerInstantThreadPool", 4);
|
||||||
|
THREADS_FOR_CLIENT_PACKETS = loginConfig.getBoolean("ThreadsForClientPackets", true);
|
||||||
SHOW_LICENCE = loginConfig.getBoolean("ShowLicence", true);
|
SHOW_LICENCE = loginConfig.getBoolean("ShowLicence", true);
|
||||||
SHOW_PI_AGREEMENT = loginConfig.getBoolean("ShowPIAgreement", false);
|
SHOW_PI_AGREEMENT = loginConfig.getBoolean("ShowPIAgreement", false);
|
||||||
AUTO_CREATE_ACCOUNTS = loginConfig.getBoolean("AutoCreateAccounts", true);
|
AUTO_CREATE_ACCOUNTS = loginConfig.getBoolean("AutoCreateAccounts", true);
|
||||||
|
@ -33,6 +33,7 @@ import org.l2jmobius.commons.database.DatabaseBackup;
|
|||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||||
import org.l2jmobius.commons.enums.ServerMode;
|
import org.l2jmobius.commons.enums.ServerMode;
|
||||||
import org.l2jmobius.commons.network.NetServer;
|
import org.l2jmobius.commons.network.NetServer;
|
||||||
|
import org.l2jmobius.commons.threads.ThreadPool;
|
||||||
import org.l2jmobius.commons.util.PropertiesParser;
|
import org.l2jmobius.commons.util.PropertiesParser;
|
||||||
import org.l2jmobius.gameserver.network.loginserverpackets.game.ServerStatus;
|
import org.l2jmobius.gameserver.network.loginserverpackets.game.ServerStatus;
|
||||||
import org.l2jmobius.loginserver.network.LoginClient;
|
import org.l2jmobius.loginserver.network.LoginClient;
|
||||||
@ -95,6 +96,9 @@ public class LoginServer
|
|||||||
// Prepare Database
|
// Prepare Database
|
||||||
DatabaseFactory.init();
|
DatabaseFactory.init();
|
||||||
|
|
||||||
|
// Initialize ThreadPool.
|
||||||
|
ThreadPool.init();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
LoginController.load();
|
LoginController.load();
|
||||||
|
@ -18,10 +18,11 @@ package org.l2jmobius.loginserver.network;
|
|||||||
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import org.l2jmobius.Config;
|
||||||
import org.l2jmobius.commons.network.PacketHandlerInterface;
|
import org.l2jmobius.commons.network.PacketHandlerInterface;
|
||||||
import org.l2jmobius.commons.network.ReadablePacket;
|
import org.l2jmobius.commons.network.ReadablePacket;
|
||||||
|
import org.l2jmobius.commons.threads.ThreadPool;
|
||||||
import org.l2jmobius.commons.util.CommonUtil;
|
import org.l2jmobius.commons.util.CommonUtil;
|
||||||
import org.l2jmobius.gameserver.network.PacketLogger;
|
|
||||||
import org.l2jmobius.loginserver.network.clientpackets.LoginClientPacket;
|
import org.l2jmobius.loginserver.network.clientpackets.LoginClientPacket;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -42,8 +43,8 @@ public class LoginPacketHandler implements PacketHandlerInterface<LoginClient>
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
PacketLogger.warning("LoginPacketHandler: Problem receiving packet id from " + client);
|
LOGGER.warning("LoginPacketHandler: Problem receiving packet id from " + client);
|
||||||
PacketLogger.warning(CommonUtil.getStackTrace(e));
|
LOGGER.warning(CommonUtil.getStackTrace(e));
|
||||||
client.disconnect();
|
client.disconnect();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -75,10 +76,23 @@ public class LoginPacketHandler implements PacketHandlerInterface<LoginClient>
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Continue on another thread.
|
// Continue on another thread.
|
||||||
final Thread thread = new Thread(new ExecuteTask(client, packet, newPacket, packetId), getClass().getName());
|
if (Config.THREADS_FOR_CLIENT_PACKETS)
|
||||||
thread.setPriority(Thread.NORM_PRIORITY);
|
{
|
||||||
thread.setDaemon(false);
|
ThreadPool.execute(new ExecuteTask(client, packet, newPacket, packetId));
|
||||||
thread.start();
|
}
|
||||||
|
else // Wait for execution.
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
newPacket.read(packet);
|
||||||
|
newPacket.run(client);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
LOGGER.warning("LoginPacketHandler: Problem with " + client + " [Packet: 0x" + Integer.toHexString(packetId).toUpperCase() + "]");
|
||||||
|
LOGGER.warning(CommonUtil.getStackTrace(e));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ExecuteTask implements Runnable
|
private class ExecuteTask implements Runnable
|
||||||
|
@ -67,11 +67,33 @@ MySqlBinLocation = C:/xampp/mysql/bin/
|
|||||||
BackupPath = ../backup/
|
BackupPath = ../backup/
|
||||||
|
|
||||||
# Maximum number of days that backups will be kept.
|
# Maximum number of days that backups will be kept.
|
||||||
# Old backups will be deleted.
|
# Old files in backup folder will be deleted.
|
||||||
# Set to 0 to disable.
|
# Set to 0 to disable.
|
||||||
BackupDays = 30
|
BackupDays = 30
|
||||||
|
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
# Thread Configuration
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# Determines the amount of scheduled thread pools. If set to -1, the server will decide the amount depending on the available processors.
|
||||||
|
ScheduledThreadPoolCount = 2
|
||||||
|
|
||||||
|
# Specifies how many threads will be in a single scheduled pool.
|
||||||
|
ThreadsPerScheduledThreadPool = 2
|
||||||
|
|
||||||
|
# Determines the amount of instant thread pools. If set to -1, the server will decide the amount depending on the available processors.
|
||||||
|
InstantThreadPoolCount = 2
|
||||||
|
|
||||||
|
# Specifies how many threads will be in a single instant pool.
|
||||||
|
ThreadsPerInstantThreadPool = 4
|
||||||
|
|
||||||
|
# Use threads to run client packets individually.
|
||||||
|
# Less lag when using threads, but more CPU consumption.
|
||||||
|
# Default: True
|
||||||
|
ThreadsForClientPackets = True
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# Security
|
# Security
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
@ -3531,6 +3531,19 @@ public class Config
|
|||||||
MYSQL_BIN_PATH = loginConfig.getString("MySqlBinLocation", "C:/xampp/mysql/bin/");
|
MYSQL_BIN_PATH = loginConfig.getString("MySqlBinLocation", "C:/xampp/mysql/bin/");
|
||||||
BACKUP_PATH = loginConfig.getString("BackupPath", "../backup/");
|
BACKUP_PATH = loginConfig.getString("BackupPath", "../backup/");
|
||||||
BACKUP_DAYS = loginConfig.getInt("BackupDays", 30);
|
BACKUP_DAYS = loginConfig.getInt("BackupDays", 30);
|
||||||
|
SCHEDULED_THREAD_POOL_COUNT = loginConfig.getInt("ScheduledThreadPoolCount", 2);
|
||||||
|
if (SCHEDULED_THREAD_POOL_COUNT == -1)
|
||||||
|
{
|
||||||
|
SCHEDULED_THREAD_POOL_COUNT = Math.max(2, Runtime.getRuntime().availableProcessors() / 2);
|
||||||
|
}
|
||||||
|
THREADS_PER_SCHEDULED_THREAD_POOL = loginConfig.getInt("ThreadsPerScheduledThreadPool", 2);
|
||||||
|
INSTANT_THREAD_POOL_COUNT = loginConfig.getInt("InstantThreadPoolCount", 2);
|
||||||
|
if (INSTANT_THREAD_POOL_COUNT == -1)
|
||||||
|
{
|
||||||
|
INSTANT_THREAD_POOL_COUNT = Math.max(2, Runtime.getRuntime().availableProcessors() / 2);
|
||||||
|
}
|
||||||
|
THREADS_PER_INSTANT_THREAD_POOL = loginConfig.getInt("ThreadsPerInstantThreadPool", 4);
|
||||||
|
THREADS_FOR_CLIENT_PACKETS = loginConfig.getBoolean("ThreadsForClientPackets", true);
|
||||||
SHOW_LICENCE = loginConfig.getBoolean("ShowLicence", true);
|
SHOW_LICENCE = loginConfig.getBoolean("ShowLicence", true);
|
||||||
SHOW_PI_AGREEMENT = loginConfig.getBoolean("ShowPIAgreement", false);
|
SHOW_PI_AGREEMENT = loginConfig.getBoolean("ShowPIAgreement", false);
|
||||||
AUTO_CREATE_ACCOUNTS = loginConfig.getBoolean("AutoCreateAccounts", true);
|
AUTO_CREATE_ACCOUNTS = loginConfig.getBoolean("AutoCreateAccounts", true);
|
||||||
|
@ -33,6 +33,7 @@ import org.l2jmobius.commons.database.DatabaseBackup;
|
|||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||||
import org.l2jmobius.commons.enums.ServerMode;
|
import org.l2jmobius.commons.enums.ServerMode;
|
||||||
import org.l2jmobius.commons.network.NetServer;
|
import org.l2jmobius.commons.network.NetServer;
|
||||||
|
import org.l2jmobius.commons.threads.ThreadPool;
|
||||||
import org.l2jmobius.commons.util.PropertiesParser;
|
import org.l2jmobius.commons.util.PropertiesParser;
|
||||||
import org.l2jmobius.gameserver.network.loginserverpackets.game.ServerStatus;
|
import org.l2jmobius.gameserver.network.loginserverpackets.game.ServerStatus;
|
||||||
import org.l2jmobius.loginserver.network.LoginClient;
|
import org.l2jmobius.loginserver.network.LoginClient;
|
||||||
@ -95,6 +96,9 @@ public class LoginServer
|
|||||||
// Prepare Database
|
// Prepare Database
|
||||||
DatabaseFactory.init();
|
DatabaseFactory.init();
|
||||||
|
|
||||||
|
// Initialize ThreadPool.
|
||||||
|
ThreadPool.init();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
LoginController.load();
|
LoginController.load();
|
||||||
|
@ -18,10 +18,11 @@ package org.l2jmobius.loginserver.network;
|
|||||||
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import org.l2jmobius.Config;
|
||||||
import org.l2jmobius.commons.network.PacketHandlerInterface;
|
import org.l2jmobius.commons.network.PacketHandlerInterface;
|
||||||
import org.l2jmobius.commons.network.ReadablePacket;
|
import org.l2jmobius.commons.network.ReadablePacket;
|
||||||
|
import org.l2jmobius.commons.threads.ThreadPool;
|
||||||
import org.l2jmobius.commons.util.CommonUtil;
|
import org.l2jmobius.commons.util.CommonUtil;
|
||||||
import org.l2jmobius.gameserver.network.PacketLogger;
|
|
||||||
import org.l2jmobius.loginserver.network.clientpackets.LoginClientPacket;
|
import org.l2jmobius.loginserver.network.clientpackets.LoginClientPacket;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -42,8 +43,8 @@ public class LoginPacketHandler implements PacketHandlerInterface<LoginClient>
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
PacketLogger.warning("LoginPacketHandler: Problem receiving packet id from " + client);
|
LOGGER.warning("LoginPacketHandler: Problem receiving packet id from " + client);
|
||||||
PacketLogger.warning(CommonUtil.getStackTrace(e));
|
LOGGER.warning(CommonUtil.getStackTrace(e));
|
||||||
client.disconnect();
|
client.disconnect();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -75,10 +76,23 @@ public class LoginPacketHandler implements PacketHandlerInterface<LoginClient>
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Continue on another thread.
|
// Continue on another thread.
|
||||||
final Thread thread = new Thread(new ExecuteTask(client, packet, newPacket, packetId), getClass().getName());
|
if (Config.THREADS_FOR_CLIENT_PACKETS)
|
||||||
thread.setPriority(Thread.NORM_PRIORITY);
|
{
|
||||||
thread.setDaemon(false);
|
ThreadPool.execute(new ExecuteTask(client, packet, newPacket, packetId));
|
||||||
thread.start();
|
}
|
||||||
|
else // Wait for execution.
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
newPacket.read(packet);
|
||||||
|
newPacket.run(client);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
LOGGER.warning("LoginPacketHandler: Problem with " + client + " [Packet: 0x" + Integer.toHexString(packetId).toUpperCase() + "]");
|
||||||
|
LOGGER.warning(CommonUtil.getStackTrace(e));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ExecuteTask implements Runnable
|
private class ExecuteTask implements Runnable
|
||||||
|
@ -67,11 +67,33 @@ MySqlBinLocation = C:/xampp/mysql/bin/
|
|||||||
BackupPath = ../backup/
|
BackupPath = ../backup/
|
||||||
|
|
||||||
# Maximum number of days that backups will be kept.
|
# Maximum number of days that backups will be kept.
|
||||||
# Old backups will be deleted.
|
# Old files in backup folder will be deleted.
|
||||||
# Set to 0 to disable.
|
# Set to 0 to disable.
|
||||||
BackupDays = 30
|
BackupDays = 30
|
||||||
|
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
# Thread Configuration
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# Determines the amount of scheduled thread pools. If set to -1, the server will decide the amount depending on the available processors.
|
||||||
|
ScheduledThreadPoolCount = 2
|
||||||
|
|
||||||
|
# Specifies how many threads will be in a single scheduled pool.
|
||||||
|
ThreadsPerScheduledThreadPool = 2
|
||||||
|
|
||||||
|
# Determines the amount of instant thread pools. If set to -1, the server will decide the amount depending on the available processors.
|
||||||
|
InstantThreadPoolCount = 2
|
||||||
|
|
||||||
|
# Specifies how many threads will be in a single instant pool.
|
||||||
|
ThreadsPerInstantThreadPool = 4
|
||||||
|
|
||||||
|
# Use threads to run client packets individually.
|
||||||
|
# Less lag when using threads, but more CPU consumption.
|
||||||
|
# Default: True
|
||||||
|
ThreadsForClientPackets = True
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# Security
|
# Security
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
@ -3545,6 +3545,19 @@ public class Config
|
|||||||
MYSQL_BIN_PATH = loginConfig.getString("MySqlBinLocation", "C:/xampp/mysql/bin/");
|
MYSQL_BIN_PATH = loginConfig.getString("MySqlBinLocation", "C:/xampp/mysql/bin/");
|
||||||
BACKUP_PATH = loginConfig.getString("BackupPath", "../backup/");
|
BACKUP_PATH = loginConfig.getString("BackupPath", "../backup/");
|
||||||
BACKUP_DAYS = loginConfig.getInt("BackupDays", 30);
|
BACKUP_DAYS = loginConfig.getInt("BackupDays", 30);
|
||||||
|
SCHEDULED_THREAD_POOL_COUNT = loginConfig.getInt("ScheduledThreadPoolCount", 2);
|
||||||
|
if (SCHEDULED_THREAD_POOL_COUNT == -1)
|
||||||
|
{
|
||||||
|
SCHEDULED_THREAD_POOL_COUNT = Math.max(2, Runtime.getRuntime().availableProcessors() / 2);
|
||||||
|
}
|
||||||
|
THREADS_PER_SCHEDULED_THREAD_POOL = loginConfig.getInt("ThreadsPerScheduledThreadPool", 2);
|
||||||
|
INSTANT_THREAD_POOL_COUNT = loginConfig.getInt("InstantThreadPoolCount", 2);
|
||||||
|
if (INSTANT_THREAD_POOL_COUNT == -1)
|
||||||
|
{
|
||||||
|
INSTANT_THREAD_POOL_COUNT = Math.max(2, Runtime.getRuntime().availableProcessors() / 2);
|
||||||
|
}
|
||||||
|
THREADS_PER_INSTANT_THREAD_POOL = loginConfig.getInt("ThreadsPerInstantThreadPool", 4);
|
||||||
|
THREADS_FOR_CLIENT_PACKETS = loginConfig.getBoolean("ThreadsForClientPackets", true);
|
||||||
SHOW_LICENCE = loginConfig.getBoolean("ShowLicence", true);
|
SHOW_LICENCE = loginConfig.getBoolean("ShowLicence", true);
|
||||||
SHOW_PI_AGREEMENT = loginConfig.getBoolean("ShowPIAgreement", false);
|
SHOW_PI_AGREEMENT = loginConfig.getBoolean("ShowPIAgreement", false);
|
||||||
AUTO_CREATE_ACCOUNTS = loginConfig.getBoolean("AutoCreateAccounts", true);
|
AUTO_CREATE_ACCOUNTS = loginConfig.getBoolean("AutoCreateAccounts", true);
|
||||||
|
@ -33,6 +33,7 @@ import org.l2jmobius.commons.database.DatabaseBackup;
|
|||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||||
import org.l2jmobius.commons.enums.ServerMode;
|
import org.l2jmobius.commons.enums.ServerMode;
|
||||||
import org.l2jmobius.commons.network.NetServer;
|
import org.l2jmobius.commons.network.NetServer;
|
||||||
|
import org.l2jmobius.commons.threads.ThreadPool;
|
||||||
import org.l2jmobius.commons.util.PropertiesParser;
|
import org.l2jmobius.commons.util.PropertiesParser;
|
||||||
import org.l2jmobius.gameserver.network.loginserverpackets.game.ServerStatus;
|
import org.l2jmobius.gameserver.network.loginserverpackets.game.ServerStatus;
|
||||||
import org.l2jmobius.loginserver.network.LoginClient;
|
import org.l2jmobius.loginserver.network.LoginClient;
|
||||||
@ -95,6 +96,9 @@ public class LoginServer
|
|||||||
// Prepare Database
|
// Prepare Database
|
||||||
DatabaseFactory.init();
|
DatabaseFactory.init();
|
||||||
|
|
||||||
|
// Initialize ThreadPool.
|
||||||
|
ThreadPool.init();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
LoginController.load();
|
LoginController.load();
|
||||||
|
@ -18,10 +18,11 @@ package org.l2jmobius.loginserver.network;
|
|||||||
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import org.l2jmobius.Config;
|
||||||
import org.l2jmobius.commons.network.PacketHandlerInterface;
|
import org.l2jmobius.commons.network.PacketHandlerInterface;
|
||||||
import org.l2jmobius.commons.network.ReadablePacket;
|
import org.l2jmobius.commons.network.ReadablePacket;
|
||||||
|
import org.l2jmobius.commons.threads.ThreadPool;
|
||||||
import org.l2jmobius.commons.util.CommonUtil;
|
import org.l2jmobius.commons.util.CommonUtil;
|
||||||
import org.l2jmobius.gameserver.network.PacketLogger;
|
|
||||||
import org.l2jmobius.loginserver.network.clientpackets.LoginClientPacket;
|
import org.l2jmobius.loginserver.network.clientpackets.LoginClientPacket;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -42,8 +43,8 @@ public class LoginPacketHandler implements PacketHandlerInterface<LoginClient>
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
PacketLogger.warning("LoginPacketHandler: Problem receiving packet id from " + client);
|
LOGGER.warning("LoginPacketHandler: Problem receiving packet id from " + client);
|
||||||
PacketLogger.warning(CommonUtil.getStackTrace(e));
|
LOGGER.warning(CommonUtil.getStackTrace(e));
|
||||||
client.disconnect();
|
client.disconnect();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -75,10 +76,23 @@ public class LoginPacketHandler implements PacketHandlerInterface<LoginClient>
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Continue on another thread.
|
// Continue on another thread.
|
||||||
final Thread thread = new Thread(new ExecuteTask(client, packet, newPacket, packetId), getClass().getName());
|
if (Config.THREADS_FOR_CLIENT_PACKETS)
|
||||||
thread.setPriority(Thread.NORM_PRIORITY);
|
{
|
||||||
thread.setDaemon(false);
|
ThreadPool.execute(new ExecuteTask(client, packet, newPacket, packetId));
|
||||||
thread.start();
|
}
|
||||||
|
else // Wait for execution.
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
newPacket.read(packet);
|
||||||
|
newPacket.run(client);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
LOGGER.warning("LoginPacketHandler: Problem with " + client + " [Packet: 0x" + Integer.toHexString(packetId).toUpperCase() + "]");
|
||||||
|
LOGGER.warning(CommonUtil.getStackTrace(e));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ExecuteTask implements Runnable
|
private class ExecuteTask implements Runnable
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user