/**
  * This is invoked on every iteration of the daemons while() loop.
  *
  * @param integer $timeout The timeout before the daemon wakes up
  *
  * @return void
  */
 public function iterate($timeout)
 {
     // call parent method and sleep for the default timeout
     parent::iterate($timeout);
     // collect the SFSBs that timed out
     $this->collectGarbage();
 }
Esempio n. 2
0
 /**
  * This is invoked on every iteration of the daemons while() loop.
  *
  * @param integer $timeout The timeout before the daemon wakes up
  *
  * @return void
  */
 public function iterate($timeout)
 {
     // call parent method and sleep for the default timeout
     parent::iterate($timeout);
     // create the requested timer instance
     $this->synchronized(function ($self) {
         // create the timer, only if we're NOT dispatched
         if ($self->dispatched === false) {
             $self->timer = Timer::builder()->setNewTimer(true)->setId(Uuid::uuid4()->__toString())->setInitialDate($self->initialExpiration)->setRepeatInterval($self->intervalDuration)->setInfo($self->info)->setPersistent($self->persistent)->setTimerState(TimerState::CREATED)->setTimedObjectId($self->timerService->getTimedObjectInvoker()->getTimedObjectId())->build($self->timerService);
             // we're dispatched now
             $self->dispatched = true;
         }
     }, $this);
     // profile the size of the sessions
     if ($this->profileLogger) {
         $this->profileLogger->debug(sprintf('Size of session pool is: %d', sizeof($this->sessionPool)));
     }
 }
 /**
  * This is invoked on every iteration of the daemons while() loop.
  *
  * @param integer $timeout The timeout before the daemon wakes up
  *
  * @return void
  */
 public function iterate($timeout)
 {
     // call parent method and sleep for the default timeout
     parent::iterate($timeout);
     // collect the session garbage
     $this->collectGarbage();
     // profile the size of the sessions
     if ($this->profileLogger) {
         $this->profileLogger->debug(sprintf('Collect garbage for session pool with size: %d', sizeof($this->getSessions())));
     }
 }
 /**
  * This is invoked on every iteration of the daemons while() loop.
  *
  * @param integer $timeout The timeout before the daemon wakes up
  *
  * @return void
  */
 public function iterate($timeout)
 {
     // call parent method and sleep for the default timeout
     parent::iterate($timeout);
     // collect the session garbage
     $this->collectGarbage();
     // profile the size of the sessions
     if ($profileLogger = $this->getProfileLogger()) {
         $profileLogger->info('Successfull collect garbage for the servlet engine\'s session manager');
     }
 }
Esempio n. 5
0
 /**
  * This is invoked on every iteration of the daemons while() loop.
  *
  * @param integer $timeout The timeout before the daemon wakes up
  *
  * @return void
  */
 public function iterate($timeout)
 {
     // call parent method and sleep for the default timeout
     parent::iterate($timeout);
     // create sessions and add them to the pool
     $this->synchronized(function ($self) {
         // check the method we want to invoke
         switch ($self->action) {
             // we want to create a new session instance
             case SessionFactory::ACTION_NEXT_FROM_POOL:
                 $self->uniqueId = uniqid();
                 $self->sessionPool->set($self->uniqueId, Session::emptyInstance());
                 $self->sessionAvailable = true;
                 // send a notification that method invocation has been processed
                 $self->notify();
                 break;
                 // we want to remove a session instance from the pool
             // we want to remove a session instance from the pool
             case SessionFactory::ACTION_REMOVE_BY_SESSION_ID:
                 foreach ($self->sessionPool as $uniqueId => $session) {
                     if ($session instanceof ServletSessionInterface && $session->getId() === $self->sessionId) {
                         $self->sessionPool->remove($uniqueId);
                     }
                 }
                 break;
                 // do nothing, because we've an unknown action
             // do nothing, because we've an unknown action
             default:
                 break;
         }
         // reset the action
         $self->action = null;
     }, $this);
     // profile the size of the sessions
     if ($this->profileLogger) {
         $this->profileLogger->debug(sprintf('Size of session pool is: %d', sizeof($this->sessionPool)));
     }
 }
 /**
  * This is invoked on every iteration of the daemons while() loop.
  *
  * @param integer $timeout The timeout before the daemon wakes up
  *
  * @return void
  */
 public function iterate($timeout)
 {
     // call parent method and sleep for the default timeout
     parent::iterate($timeout);
     // create the requested timer instance
     $this->synchronized(function ($self) {
         // create the calendar timer, only if we're NOT dispatched
         if ($self->dispatched === false) {
             $self->timer = CalendarTimer::builder()->setAutoTimer($self->timeoutMethod != null)->setScheduleExprSecond($self->schedule->getSecond())->setScheduleExprMinute($self->schedule->getMinute())->setScheduleExprHour($self->schedule->getHour())->setScheduleExprDayOfWeek($self->schedule->getDayOfWeek())->setScheduleExprDayOfMonth($self->schedule->getDayOfMonth())->setScheduleExprMonth($self->schedule->getMonth())->setScheduleExprYear($self->schedule->getYear())->setScheduleExprStartDate($self->schedule->getStart())->setScheduleExprEndDate($self->schedule->getEnd())->setScheduleExprTimezone($self->schedule->getTimezone())->setTimeoutMethod($self->timeoutMethod)->setTimerState(TimerState::CREATED)->setId(Uuid::uuid4()->__toString())->setPersistent($self->persistent)->setTimedObjectId($self->timerService->getTimedObjectInvoker()->getTimedObjectId())->setInfo($self->info)->setNewTimer(true)->build($self->timerService);
             // we're dispatched now
             $self->dispatched = true;
         }
     }, $this);
     // profile the size of the sessions
     if ($this->profileLogger) {
         $this->profileLogger->debug(sprintf('Size of session pool is: %d', sizeof($this->sessionPool)));
     }
 }
 /**
  * This is invoked on every iteration of the daemons while() loop.
  *
  * @param integer $timeout The timeout before the daemon wakes up
  *
  * @return void
  */
 public function iterate($timeout)
 {
     // call parent method and sleep for the default timeout
     parent::iterate($timeout);
     // create the instance and stack it
     $this->synchronized(function ($self) {
         // create the instance only if we're NOT dispatched and a class name is available
         if ($self->dispatched === false && $self->className) {
             // create the instance
             $instance = $self->getApplication()->search('ProviderInterface')->newInstance($self->className, $self->sessionId, $self->args);
             // stack the instance
             $self->instances[] = $instance;
             // we're dispatched now
             $self->dispatched = true;
         }
     }, $this);
 }
 /**
  * This is invoked on every iteration of the daemons while() loop.
  *
  * @param integer $timeout The timeout before the daemon wakes up
  *
  * @return void
  */
 public function iterate($timeout)
 {
     // call parent method and sleep for the default timeout
     parent::iterate($timeout);
     // now persist inactive sessions
     $this->persist();
     // profile the size of the sessions
     if ($this->profileLogger) {
         $this->profileLogger->debug(sprintf('Persisted sessions to filesystem for sessions size: %d', sizeof($this->getSessions())));
     }
 }
 /**
  * This is invoked on every iteration of the daemons while() loop.
  *
  * @param integer $timeout The timeout before the daemon wakes up
  *
  * @return void
  */
 public function iterate($timeout)
 {
     // call parent method and sleep for the default timeout
     parent::iterate($timeout);
     // iterate over the timer tasks that has to be executed
     foreach ($this->tasksToExecute as $taskId => $timerTaskWrapper) {
         // this should never happen
         if (!$timerTaskWrapper instanceof \stdClass) {
             // log an error message because we task wrapper has wrong type
             $this->getApplication()->getInitialContext()->getSystemLogger()->error(sprintf('Timer-Task-Wrapper %s has wrong type %s', $taskId, get_class($timerTaskWrapper)));
             // we didn't foud a timer task ignore this
             continue;
         }
         // query if the task has to be executed now
         if ($timerTaskWrapper->executeAt < microtime(true)) {
             // load the timer task wrapper we want to execute
             if ($pk = $this->scheduledTimers[$timerId = $timerTaskWrapper->timerId]) {
                 // load the timer service registry
                 $timerServiceRegistry = $this->getApplication()->search('TimerServiceContextInterface');
                 // lookup the timer from the timer service
                 $timer = $timerServiceRegistry->lookup($pk)->getTimers()->get($timerId);
                 // create the timer task to be executed
                 $timer->getTimerTask($this->getApplication());
                 // remove the key from the list of tasks to be executed
                 unset($this->tasksToExecute[$taskId]);
             } else {
                 // log an error message because we can't find the timer instance
                 $this->getApplication()->getInitialContext()->getSystemLogger()->error(sprintf('Can\'t find timer %s to create timer task %s', $timerTaskWrapper->timerId, $taskId));
             }
         }
     }
     // profile the size of the timer tasks to be executed
     if ($this->profileLogger) {
         $this->profileLogger->debug(sprintf('Processed timer service executor, executing %d timer tasks', sizeof($this->tasksToExecute)));
     }
 }
 /**
  * This is invoked on every iteration of the daemons while() loop.
  *
  * @param integer $timeout The timeout before the daemon wakes up
  *
  * @return void
  */
 public function iterate($timeout)
 {
     // call parent method and sleep for the default timeout
     parent::iterate($timeout);
     // check the method we want to invoke
     switch ($this->action) {
         // we want to create a new session instance
         case StatefulSessionBeanMapFactory::ACTION_NEW_INSTANCE:
             $this->sessionPool->set($this->sessionId, new StatefulSessionBeanMap());
             break;
             // we want to remove a session instance from the pool
         // we want to remove a session instance from the pool
         case StatefulSessionBeanMapFactory::ACTION_REMOVE_BY_SESSION_ID:
             foreach ($this->sessionPool as $sessionId => $session) {
                 if ($session instanceof MapInterface && $sessionId === $this->sessionId) {
                     $this->sessionPool->remove($sessionId);
                 }
             }
             break;
             // do nothing, because we've an unknown action
         // do nothing, because we've an unknown action
         default:
             break;
     }
     // reset the action and session-ID
     $this->action = null;
     $this->sessionId = null;
     // profile the size of the session pool
     if ($this->profileLogger) {
         $this->profileLogger->debug(sprintf('Size of session pool is: %d', sizeof($this->sessionPool)));
     }
 }