ThreadHandler.java 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * This program is free software: you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation, either version 3 of the License, or (at your option) any later
  5. * version.
  6. *
  7. * This program is distributed in the hope that it will be useful, but WITHOUT
  8. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  10. * details.
  11. *
  12. * You should have received a copy of the GNU General Public License along with
  13. * this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. package handlers.telnethandlers;
  16. import java.io.PrintWriter;
  17. import java.net.Socket;
  18. import com.l2jserver.gameserver.ThreadPoolManager;
  19. import com.l2jserver.gameserver.handler.ITelnetHandler;
  20. /**
  21. * @author UnAfraid
  22. */
  23. public class ThreadHandler implements ITelnetHandler
  24. {
  25. private final String[] _commands =
  26. {
  27. "purge",
  28. "performance"
  29. };
  30. @Override
  31. public boolean useCommand(String command, PrintWriter _print, Socket _cSocket, int _uptime)
  32. {
  33. if (command.equals("performance"))
  34. {
  35. for (String line : ThreadPoolManager.getInstance().getStats())
  36. {
  37. _print.println(line);
  38. }
  39. _print.flush();
  40. }
  41. else if (command.equals("purge"))
  42. {
  43. ThreadPoolManager.getInstance().purge();
  44. _print.println("STATUS OF THREAD POOLS AFTER PURGE COMMAND:");
  45. _print.println("");
  46. for (String line : ThreadPoolManager.getInstance().getStats())
  47. {
  48. _print.println(line);
  49. }
  50. _print.flush();
  51. }
  52. return false;
  53. }
  54. @Override
  55. public String[] getCommandList()
  56. {
  57. return _commands;
  58. }
  59. }