ru.bitel.bgbilling.modules.inet.access.sa

## Class ServiceActivatorDeviceWorker

- java.lang.Object
- - ru.bitel.common.worker.WorkerTask<EventListenerContext>
  - - ru.bitel.bgbilling.kernel.event.EventWorker
    - - ru.bitel.bgbilling.kernel.event.AsyncEventWorker<Event>
      - - ru.bitel.bgbilling.modules.inet.access.sa.ServiceActivatorDeviceWorker

- All Implemented Interfaces:
    java.lang.Runnable, EventListener<Event>

      public class ServiceActivatorDeviceWorker
      extends AsyncEventWorker<Event>

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class ru.bitel.common.worker.WorkerTask

      `ru.bitel.common.worker.WorkerTask.BlockingExecutionHandler`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected long` | `connectErrorCount`
    `protected long` | `errorAlarmCount`
    `protected long` | `errorRedeliveryCount`
    `protected long` | `errorRedeliveryTimeout`

    - ### Fields inherited from class ru.bitel.bgbilling.kernel.event.AsyncEventWorker

      `batchPause, batchSize, errorCount, needAcknowledge, waitNextTask`

    - ### Fields inherited from class ru.bitel.bgbilling.kernel.event.EventWorker

      `batchWait, consumer, errorPause, moduleId, working`

    - ### Fields inherited from class ru.bitel.common.worker.WorkerTask

      `context`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ServiceActivatorDeviceWorker(ru.bitel.bgbilling.modules.inet.access.Access access, java.util.concurrent.ScheduledExecutorService scheduledExecutorService, int deviceId, long fetchDelay, long fetchTimeout)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.lang.Object` | `doTask(java.lang.Object task)` Выполнение отдельной задачи.
    `void` | `execute()`
    `int` | `getDeviceId()`
    `ru.bitel.bgbilling.modules.inet.runtime.device.InetDeviceRuntime` | `getDeviceRuntime()`
    `protected void` | `processDoTaskException(java.lang.Object task, boolean inDoTask, boolean putFirstIfInDoTask, ru.bitel.bgbilling.common.BGException ex, boolean throwException)`
    `void` | `putLast(java.lang.Object task)`
    `protected void` | `runImpl()`
    `protected boolean` | `runWorker()` Вызывается, когда появляются задачи.
    `void` | `skipEvent()`
    `void` | `start()`
    `protected void` | `taskDone(java.lang.Object task, java.lang.Object result)`
    `protected void` | `taskTimeout(java.lang.Object task)`
    `java.lang.String` | `toString()`

    - ### Methods inherited from class ru.bitel.bgbilling.kernel.event.AsyncEventWorker

      `doTasks, internalDoTask, notify, poll, putFirst`

    - ### Methods inherited from class ru.bitel.bgbilling.kernel.event.EventWorker

      `internalRunWorker, pollFirstTask, setConsumer, shutdown`

    - ### Methods inherited from class ru.bitel.common.worker.WorkerTask

      `newBlockingFixedThreadPool, newFixedThreadPool, newFixedThreadPool, newScheduledThreadPool, run, runSync, runSync, setContext`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### errorAlarmCount

          protected long errorAlarmCount

    - #### errorRedeliveryCount

          protected long errorRedeliveryCount

    - #### errorRedeliveryTimeout

          protected long errorRedeliveryTimeout

    - #### connectErrorCount

          protected long connectErrorCount

  - ### Constructor Detail

    - #### ServiceActivatorDeviceWorker

          public ServiceActivatorDeviceWorker(ru.bitel.bgbilling.modules.inet.access.Access access,
                                              java.util.concurrent.ScheduledExecutorService scheduledExecutorService,
                                              int deviceId,
                                              long fetchDelay,
                                              long fetchTimeout)
                                       throws ru.bitel.bgbilling.common.BGException

      Throws:
        `ru.bitel.bgbilling.common.BGException`

  - ### Method Detail

    - #### getDeviceId

          public int getDeviceId()

    - #### getDeviceRuntime

          public ru.bitel.bgbilling.modules.inet.runtime.device.InetDeviceRuntime getDeviceRuntime()

    - #### start

          public void start()

    - #### runImpl

          protected void runImpl()
                          throws java.lang.Exception

      Overrides:
        `runImpl` in class `EventWorker`
      Throws:
        `java.lang.Exception`

    - #### execute

          public void execute()

    - #### runWorker

          protected boolean runWorker()
                               throws ru.bitel.bgbilling.common.BGException

      Description copied from class: `EventWorker`
      Вызывается, когда появляются задачи. Внутри данного метода нужно вызвать `EventWorker.doTasks()`, который выполняет последовательно появившиеся задачи. А перед и после вызова `EventWorker.doTasks()` можно инициализировать и освободить DAO.
      Specified by:
        `runWorker` in class `EventWorker`
      Returns:
      Throws:
        `ru.bitel.bgbilling.common.BGException`

    - #### putLast

          public final void putLast(java.lang.Object task)
                             throws java.lang.InterruptedException

      Overrides:
        `putLast` in class `AsyncEventWorker<Event>`
      Throws:
        `java.lang.InterruptedException`

    - #### doTask

          public java.lang.Object doTask(java.lang.Object task)
                                  throws ru.bitel.bgbilling.common.BGException

      Выполнение отдельной задачи. Очень важная часть - правильная реакция на события.
      Specified by:
        `doTask` in class `EventWorker`
      Returns:
        обычно null.
      Throws:
        `ru.bitel.bgbilling.common.BGException`

    - #### taskDone

          protected void taskDone(java.lang.Object task,
                                  java.lang.Object result)
                           throws ru.bitel.bgbilling.common.BGException

      Specified by:
        `taskDone` in class `AsyncEventWorker<Event>`
      Throws:
        `ru.bitel.bgbilling.common.BGException`

    - #### toString

          public java.lang.String toString()

      Overrides:
        `toString` in class `java.lang.Object`

    - #### skipEvent

          public void skipEvent()

    - #### processDoTaskException

          protected void processDoTaskException(java.lang.Object task,
                                                boolean inDoTask,
                                                boolean putFirstIfInDoTask,
                                                ru.bitel.bgbilling.common.BGException ex,
                                                boolean throwException)
                                         throws ru.bitel.bgbilling.common.BGException

      Overrides:
        `processDoTaskException` in class `AsyncEventWorker<Event>`
        `inDoTask` - ошибка произошла в doTask или позже
      Throws:
        `ru.bitel.bgbilling.common.BGException`

    - #### taskTimeout

          protected void taskTimeout(java.lang.Object task)

      Overrides:
        `taskTimeout` in class `AsyncEventWorker<Event>`