Examples of ThreadPoolManager


Examples of com.l2jfrozen.gameserver.thread.ThreadPoolManager

      _notInitialized = false;
      //*
//      _history = new FastList<Race>();
      _managers = new FastList<L2RaceManagerInstance>();

      ThreadPoolManager s = ThreadPoolManager.getInstance();
      s.scheduleGeneralAtFixedRate(new Announcement(SystemMessageId.MONSRACE_TICKETS_AVAILABLE_FOR_S1_RACE), 0, 10 * MINUTE);
      s.scheduleGeneralAtFixedRate(new Announcement(SystemMessageId.MONSRACE_TICKETS_NOW_AVAILABLE_FOR_S1_RACE), 30 * SECOND, 10 * MINUTE);
      s.scheduleGeneralAtFixedRate(new Announcement(SystemMessageId.MONSRACE_TICKETS_AVAILABLE_FOR_S1_RACE), MINUTE, 10 * MINUTE);
      s.scheduleGeneralAtFixedRate(new Announcement(SystemMessageId.MONSRACE_TICKETS_NOW_AVAILABLE_FOR_S1_RACE), MINUTE + 30 * SECOND, 10 * MINUTE);
      s.scheduleGeneralAtFixedRate(new Announcement(SystemMessageId.MONSRACE_TICKETS_STOP_IN_S1_MINUTES), 2 * MINUTE, 10 * MINUTE);
      s.scheduleGeneralAtFixedRate(new Announcement(SystemMessageId.MONSRACE_TICKETS_STOP_IN_S1_MINUTES), 3 * MINUTE, 10 * MINUTE);
      s.scheduleGeneralAtFixedRate(new Announcement(SystemMessageId.MONSRACE_TICKETS_STOP_IN_S1_MINUTES), 4 * MINUTE, 10 * MINUTE);
      s.scheduleGeneralAtFixedRate(new Announcement(SystemMessageId.MONSRACE_TICKETS_STOP_IN_S1_MINUTES), 5 * MINUTE, 10 * MINUTE);
      s.scheduleGeneralAtFixedRate(new Announcement(SystemMessageId.MONSRACE_TICKETS_STOP_IN_S1_MINUTES), 6 * MINUTE, 10 * MINUTE);
      s.scheduleGeneralAtFixedRate(new Announcement(SystemMessageId.MONSRACE_TICKET_SALES_CLOSED), 7 * MINUTE, 10 * MINUTE);
      s.scheduleGeneralAtFixedRate(new Announcement(SystemMessageId.MONSRACE_BEGINS_IN_S1_MINUTES), 7 * MINUTE, 10 * MINUTE);
      s.scheduleGeneralAtFixedRate(new Announcement(SystemMessageId.MONSRACE_BEGINS_IN_S1_MINUTES), 8 * MINUTE, 10 * MINUTE);
      s.scheduleGeneralAtFixedRate(new Announcement(SystemMessageId.MONSRACE_BEGINS_IN_30_SECONDS), 8 * MINUTE + 30 * SECOND, 10 * MINUTE);
      s.scheduleGeneralAtFixedRate(new Announcement(SystemMessageId.MONSRACE_COUNTDOWN_IN_FIVE_SECONDS), 8 * MINUTE + 50 * SECOND, 10 * MINUTE);
      s.scheduleGeneralAtFixedRate(new Announcement(SystemMessageId.MONSRACE_BEGINS_IN_S1_SECONDS), 8 * MINUTE + 55 * SECOND, 10 * MINUTE);
      s.scheduleGeneralAtFixedRate(new Announcement(SystemMessageId.MONSRACE_BEGINS_IN_S1_SECONDS), 8 * MINUTE + 56 * SECOND, 10 * MINUTE);
      s.scheduleGeneralAtFixedRate(new Announcement(SystemMessageId.MONSRACE_BEGINS_IN_S1_SECONDS), 8 * MINUTE + 57 * SECOND, 10 * MINUTE);
      s.scheduleGeneralAtFixedRate(new Announcement(SystemMessageId.MONSRACE_BEGINS_IN_S1_SECONDS), 8 * MINUTE + 58 * SECOND, 10 * MINUTE);
      s.scheduleGeneralAtFixedRate(new Announcement(SystemMessageId.MONSRACE_BEGINS_IN_S1_SECONDS), 8 * MINUTE + 59 * SECOND, 10 * MINUTE);
      s.scheduleGeneralAtFixedRate(new Announcement(SystemMessageId.MONSRACE_RACE_START), 9 * MINUTE, 10 * MINUTE);
      //*/
    }
    _managers.add(this);
  }
 
View Full Code Here

Examples of com.l2jfrozen.gameserver.thread.ThreadPoolManager

    }
  }

  private boolean launchTask(ExecutedTask task)
  {
    final ThreadPoolManager scheduler = ThreadPoolManager.getInstance();
    final TaskTypes type = task.getType();

    if(type == TYPE_STARTUP)
    {
      task.run();
      return false;
    }
    else if(type == TYPE_SHEDULED)
    {
      long delay = Long.valueOf(task.getParams()[0]);
      task.scheduled = scheduler.scheduleGeneral(task, delay);
      return true;
    }
    else if(type == TYPE_FIXED_SHEDULED)
    {
      long delay = Long.valueOf(task.getParams()[0]);
      long interval = Long.valueOf(task.getParams()[1]);

      task.scheduled = scheduler.scheduleGeneralAtFixedRate(task, delay, interval);
      return true;
    }
    else if(type == TYPE_TIME)
    {
      try
      {
        Date desired = DateFormat.getInstance().parse(task.getParams()[0]);
        long diff = desired.getTime() - System.currentTimeMillis();
        if(diff >= 0)
        {
          task.scheduled = scheduler.scheduleGeneral(task, diff);
          return true;
        }
        _log.info("Task " + task.getId() + " is obsoleted.");
      }
      catch(Exception e)
      {
        if(Config.ENABLE_ALL_EXCEPTIONS)
          e.printStackTrace();
      }
    }
    else if(type == TYPE_SPECIAL)
    {
      ScheduledFuture<?> result = task.getTask().launchSpecial(task);
      if(result != null)
      {
        task.scheduled = result;
        return true;
      }
    }
    else if(type == TYPE_GLOBAL_TASK)
    {
      long interval = Long.valueOf(task.getParams()[0]) * 86400000L;
      String[] hour = task.getParams()[1].split(":");

      if(hour.length != 3)
      {
        _log.warning("Task " + task.getId() + " has incorrect parameters");
        return false;
      }

      Calendar check = Calendar.getInstance();
      check.setTimeInMillis(task.getLastActivation() + interval);

      Calendar min = Calendar.getInstance();
      try
      {
        min.set(Calendar.HOUR_OF_DAY, Integer.valueOf(hour[0]));
        min.set(Calendar.MINUTE, Integer.valueOf(hour[1]));
        min.set(Calendar.SECOND, Integer.valueOf(hour[2]));
      }
      catch(Exception e)
      {
        if(Config.ENABLE_ALL_EXCEPTIONS)
          e.printStackTrace();
        _log.warning("Bad parameter on task " + task.getId() + ": " + e.getMessage());
        return false;
      }

      long delay = min.getTimeInMillis() - System.currentTimeMillis();

      if(check.after(min) || delay < 0)
      {
        delay += interval;
      }

      task.scheduled = scheduler.scheduleGeneralAtFixedRate(task, delay, interval);

      return true;
    }

    return false;
View Full Code Here

Examples of com.sun.corba.ee.spi.orbutil.threadpool.ThreadPoolManager

    public void scheduleWork(ClassLoader classLoader, Runnable target) {
        ThreadPoolWork work = new ThreadPoolWork(classLoader, target);

        try {
            ThreadPoolManager threadpoolMgr =
                S1ASThreadPoolManager.getThreadPoolManager();
            ThreadPool threadpool = threadpoolMgr.getDefaultThreadPool();
            threadpool.getAnyWorkQueue().addWork(work);
        } catch (Throwable th) {
            String errMsg =  "Error while adding work to orb threadpool. "
                + "Hence doing it in current thread";
            _ejbLogger.log(Level.WARNING, errMsg, th);
View Full Code Here

Examples of com.sun.corba.ee.spi.orbutil.threadpool.ThreadPoolManager

                       "for Ejb " + ejbDescriptor.getName());
        }


  if (threadPoolName != null) {
      ThreadPoolManager threadPoolManager
    = S1ASThreadPoolManager.getThreadPoolManager();
      try {
    threadPoolNumericID = threadPoolManager.getThreadPoolNumericId(
        threadPoolName);
    policies.add(new RequestPartitioningPolicy(threadPoolNumericID));
      } catch (Exception ex) {
                logger.log(Level.WARNING, "Not using threadpool-request-partitioning...", ex);
      }
View Full Code Here

Examples of com.sun.corba.ee.spi.orbutil.threadpool.ThreadPoolManager

    public static void addFirst(Work work) {
        addLast(work);
    }

    public static void addLast(Work work) {
        ThreadPoolManager threadpoolMgr =
            S1ASThreadPoolManager.getThreadPoolManager();
        ThreadPool threadpool = threadpoolMgr.getDefaultThreadPool();
        threadpool.getAnyWorkQueue().addWork(work);
    }
View Full Code Here

Examples of com.sun.corba.ee.spi.orbutil.threadpool.ThreadPoolManager

              orb.setThreadPoolManager(threadpoolMgr);
            }

            // Do the stats for the threadpool
           
            ThreadPoolManager tpool =  orb.getThreadPoolManager();
            // ORB creates its own threadpool if threadpoolMgr was null above
            ThreadPool thpool=tpool.getDefaultThreadPool();
            String ThreadPoolName = thpool.getName();
            ThreadPoolStats tpStats = new ThreadPoolStatsImpl(
                thpool.getWorkQueue(0).getThreadPool());
            StatsProviderManager.register("orb", PluginPoint.SERVER,
                "thread-pool/orb/threadpool/"+ThreadPoolName, tpStats);
View Full Code Here

Examples of com.sun.corba.ee.spi.threadpool.ThreadPoolManager

      if (usePassByReference) {
          policies.add(new CopyObjectPolicy(PASS_BY_REFERENCE_ID));
      }

      if (threadPoolName != null) {
          ThreadPoolManager threadPoolManager
            = S1ASThreadPoolManager.getThreadPoolManager();
          try {
            threadPoolNumericID = threadPoolManager.getThreadPoolNumericId(
            threadPoolName);
            policies.add(new RequestPartitioningPolicy(threadPoolNumericID));
          } catch (Exception ex) {
                logger.log(Level.WARNING, "Not using threadpool-request-partitioning...", ex);
          }
View Full Code Here

Examples of com.sun.corba.ee.spi.threadpool.ThreadPoolManager

              orb.setThreadPoolManager(threadpoolMgr);
            }

            // Do the stats for the threadpool
           
            ThreadPoolManager tpool =  orb.getThreadPoolManager();
            // ORB creates its own threadpool if threadpoolMgr was null above
            ThreadPool thpool=tpool.getDefaultThreadPool();
            String ThreadPoolName = thpool.getName();
            ThreadPoolStats tpStats = new ThreadPoolStatsImpl(
                thpool.getWorkQueue(0).getThreadPool());
            StatsProviderManager.register("orb", PluginPoint.SERVER,
                "thread-pool/orb/threadpool/"+ThreadPoolName, tpStats);
View Full Code Here

Examples of l2p.common.ThreadPoolManager

    {
      notInitialized = false;
      _raceNumber = ServerVariables.getInt("monster_race", 1);
      history = new GArray<Race>();
      managers = new GArray<L2RaceManagerInstance>();
      ThreadPoolManager s = ThreadPoolManager.getInstance();
      s.scheduleGeneralAtFixedRate(new Announcement(SystemMessage.TICKETS_ARE_NOW_AVAILABLE_FOR_THE_S1TH_MONSTER_RACE), 0, 10 * MINUTE);
      s.scheduleGeneralAtFixedRate(new Announcement(SystemMessage.WE_ARE_NOW_SELLING_TICKETS_FOR_THE_S1TH_MONSTER_RACE), 30 * SECOND, 10 * MINUTE);
      s.scheduleGeneralAtFixedRate(new Announcement(SystemMessage.TICKETS_ARE_NOW_AVAILABLE_FOR_THE_S1TH_MONSTER_RACE), MINUTE, 10 * MINUTE);
      s.scheduleGeneralAtFixedRate(new Announcement(SystemMessage.WE_ARE_NOW_SELLING_TICKETS_FOR_THE_S1TH_MONSTER_RACE), MINUTE + 30 * SECOND, 10 * MINUTE);
      s.scheduleGeneralAtFixedRate(new Announcement(SystemMessage.TICKET_SALES_FOR_THE_MONSTER_RACE_WILL_CEASE_IN_S1_MINUTE_S), 2 * MINUTE, 10 * MINUTE);
      s.scheduleGeneralAtFixedRate(new Announcement(SystemMessage.TICKET_SALES_FOR_THE_MONSTER_RACE_WILL_CEASE_IN_S1_MINUTE_S), 3 * MINUTE, 10 * MINUTE);
      s.scheduleGeneralAtFixedRate(new Announcement(SystemMessage.TICKET_SALES_FOR_THE_MONSTER_RACE_WILL_CEASE_IN_S1_MINUTE_S), 4 * MINUTE, 10 * MINUTE);
      s.scheduleGeneralAtFixedRate(new Announcement(SystemMessage.TICKET_SALES_FOR_THE_MONSTER_RACE_WILL_CEASE_IN_S1_MINUTE_S), 5 * MINUTE, 10 * MINUTE);
      s.scheduleGeneralAtFixedRate(new Announcement(SystemMessage.TICKETS_SALES_ARE_CLOSED_FOR_THE_S1TH_MONSTER_RACE_ODDS_ARE_POSTED), 6 * MINUTE, 10 * MINUTE);
      s.scheduleGeneralAtFixedRate(new Announcement(SystemMessage.TICKETS_SALES_ARE_CLOSED_FOR_THE_S1TH_MONSTER_RACE_ODDS_ARE_POSTED), 7 * MINUTE, 10 * MINUTE);
      s.scheduleGeneralAtFixedRate(new Announcement(SystemMessage.THE_S2TH_MONSTER_RACE_WILL_BEGIN_IN_S1_MINUTES), 7 * MINUTE, 10 * MINUTE);
      s.scheduleGeneralAtFixedRate(new Announcement(SystemMessage.THE_S2TH_MONSTER_RACE_WILL_BEGIN_IN_S1_MINUTES), 8 * MINUTE, 10 * MINUTE);
      s.scheduleGeneralAtFixedRate(new Announcement(SystemMessage.THE_S1TH_MONSTER_RACE_WILL_BEGIN_IN_30_SECONDS), 8 * MINUTE + 30 * SECOND, 10 * MINUTE);
      s.scheduleGeneralAtFixedRate(new Announcement(SystemMessage.THE_S1TH_MONSTER_RACE_IS_ABOUT_TO_BEGIN_COUNTDOWN_IN_FIVE_SECONDS), 8 * MINUTE + 50 * SECOND, 10 * MINUTE);
      s.scheduleGeneralAtFixedRate(new Announcement(SystemMessage.THE_RACE_WILL_BEGIN_IN_S1_SECONDS), 8 * MINUTE + 55 * SECOND, 10 * MINUTE);
      s.scheduleGeneralAtFixedRate(new Announcement(SystemMessage.THE_RACE_WILL_BEGIN_IN_S1_SECONDS), 8 * MINUTE + 56 * SECOND, 10 * MINUTE);
      s.scheduleGeneralAtFixedRate(new Announcement(SystemMessage.THE_RACE_WILL_BEGIN_IN_S1_SECONDS), 8 * MINUTE + 57 * SECOND, 10 * MINUTE);
      s.scheduleGeneralAtFixedRate(new Announcement(SystemMessage.THE_RACE_WILL_BEGIN_IN_S1_SECONDS), 8 * MINUTE + 58 * SECOND, 10 * MINUTE);
      s.scheduleGeneralAtFixedRate(new Announcement(SystemMessage.THE_RACE_WILL_BEGIN_IN_S1_SECONDS), 8 * MINUTE + 59 * SECOND, 10 * MINUTE);
      s.scheduleGeneralAtFixedRate(new Announcement(SystemMessage.THEYRE_OFF), 9 * MINUTE, 10 * MINUTE);
    }
    managers.add(this);
  }
 
View Full Code Here

Examples of l2p.common.ThreadPoolManager

    }
  }

  private boolean launchTask(ExecutedTask task)
  {
    final ThreadPoolManager scheduler = ThreadPoolManager.getInstance();
    final TaskTypes type = task.getType();
    if(type == TYPE_STARTUP)
    {
      task.run();
      return false;
    }
    else if(type == TYPE_SHEDULED)
    {
      long delay = Long.valueOf(task.getParams()[0]);
      task._scheduled = scheduler.scheduleGeneral(task, delay);
      return true;
    }
    else if(type == TYPE_FIXED_SHEDULED)
    {
      long delay = Long.valueOf(task.getParams()[0]);
      long interval = Long.valueOf(task.getParams()[1]);
      task._scheduled = scheduler.scheduleGeneralAtFixedRate(task, delay, interval);
      return true;
    }
    else if(type == TYPE_TIME)
    {
      try
      {
        Date desired = DateFormat.getInstance().parse(task.getParams()[0]);
        long diff = desired.getTime() - System.currentTimeMillis();
        if(diff >= 0)
        {
          task._scheduled = scheduler.scheduleGeneral(task, diff);
          return true;
        }
        _log.info("Task " + task.getId() + " is obsoleted.");
      }
      catch(Exception e)
      {
      }
    }
    else if(type == TYPE_SPECIAL)
    {
      ScheduledFuture<?> result = task.getTask().launchSpecial(task);
      if(result != null)
      {
        task._scheduled = result;
        return true;
      }
    }
    else if(type == TYPE_GLOBAL_TASK)
    {
      long interval = Long.valueOf(task.getParams()[0]) * 86400000L;
      String[] hour = task.getParams()[1].split(":");
      if(hour.length != 3)
      {
        _log.warning("Task " + task.getId() + " has incorrect parameters");
        return false;
      }
      Calendar check = Calendar.getInstance();
      check.setTimeInMillis(task.getLastActivation() + interval);
      Calendar min = Calendar.getInstance();
      try
      {
        min.set(Calendar.HOUR_OF_DAY, Integer.valueOf(hour[0]));
        min.set(Calendar.MINUTE, Integer.valueOf(hour[1]));
        min.set(Calendar.SECOND, Integer.valueOf(hour[2]));
      }
      catch(Exception e)
      {
        _log.warning("Bad parameter on task " + task.getId() + ": " + e.getMessage());
        return false;
      }
      long delay = min.getTimeInMillis() - System.currentTimeMillis();
      if(check.after(min) || delay < 0)
      {
        delay += interval;
      }
      task._scheduled = scheduler.scheduleGeneralAtFixedRate(task, delay, interval);
      return true;
    }
    return false;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.