com.hazelcast.util.scheduler

## Class SecondsBasedEntryTaskScheduler<K,V>

- java.lang.Object
- - com.hazelcast.util.scheduler.SecondsBasedEntryTaskScheduler<K,V>

- Type Parameters:
    `K` - entry key type
    `V` - entry value type
  All Implemented Interfaces:
    EntryTaskScheduler<K,V>

      public final class SecondsBasedEntryTaskScheduler<K,V>
      extends Object
      implements EntryTaskScheduler<K,V>

  Schedule execution of an entry for seconds later. This is similar to a scheduled executor service, but instead of scheduling a execution for a specific millisecond, this service will schedule it with second proximity. For example, if delayMillis is 600 ms, then the entry will be scheduled to execute in 1 second. If delayMillis is 2400, then the entry will be scheduled to execute in 3 seconds. Therefore, delayMillis is ceil-ed to the next second. It gives up exact time scheduling to gain the power of: a) bulk execution of all operations within the same second or b) being able to reschedule (postpone) execution.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static double` | `FACTOR`
    `static int` | `INITIAL_CAPACITY` hash-map initial capacity

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `ScheduledEntry<K,V>` | `cancel(K key)` Cancel all scheduled executions with the given key.
    `void` | `cancelAll()` Cancel all scheduled executions
    `int` | `cancelIfExists(K key, V value)` Cancels the scheduled executions for the given key and value if present.
    `ScheduledEntry<K,V>` | `get(K key)` Return the entry for the scheduled key or null if there is none
    `ScheduledEntry<K,V>` | `getByCompositeKey(K key)` Returns one scheduled entry for the given `key` with no guaranteed ordering
    `boolean` | `schedule(long delayMillis, K key, V value)` Schedules (or reschedules) the execution of given entry.
    `int` | `size()`
    `String` | `toString()`

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

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

- - ### Field Detail

    - #### INITIAL_CAPACITY

          public static final int INITIAL_CAPACITY

      hash-map initial capacity
      See Also:
        Constant Field Values

    - #### FACTOR

          public static final double FACTOR

      See Also:
        `ceilToSecond(long)`, Constant Field Values

  - ### Method Detail

    - #### schedule

          public boolean schedule(long delayMillis,
                                  K key,
                                  V value)

      Description copied from interface: `EntryTaskScheduler`
      Schedules (or reschedules) the execution of given entry. Key parameter is used to check whether there is an existing scheduling for this entry.
      Specified by:
        `schedule` in interface `EntryTaskScheduler<K,V>`
      Parameters:
        `delayMillis` - milliseconds to delay the execution.
        `key` - key of this scheduling.
        `value` - user object to pass back when it is time to execute.
      Returns:
        returns true if this call resulted in a new scheduling, false otherwise.

    - #### cancel

          public ScheduledEntry<K,V> cancel(K key)

      Description copied from interface: `EntryTaskScheduler`
      Cancel all scheduled executions with the given key.
      Specified by:
        `cancel` in interface `EntryTaskScheduler<K,V>`
      Parameters:
        `key` - the scheduled key
      Returns:
        the cancelled scheduled execution

    - #### cancelIfExists

          public int cancelIfExists(K key,
                                    V value)

      Description copied from interface: `EntryTaskScheduler`
      Cancels the scheduled executions for the given key and value if present. The method returns the number of cancelled scheduled entries.
      Specified by:
        `cancelIfExists` in interface `EntryTaskScheduler<K,V>`
      Parameters:
        `key` - the scheduled key
        `value` - the scheduled value
      Returns:
        the number of cancelled scheduled entries.

    - #### get

          public ScheduledEntry<K,V> get(K key)

      Description copied from interface: `EntryTaskScheduler`
      Return the entry for the scheduled key or null if there is none
      Specified by:
        `get` in interface `EntryTaskScheduler<K,V>`

    - #### getByCompositeKey

          public ScheduledEntry<K,V> getByCompositeKey(K key)

      Returns one scheduled entry for the given `key` with no guaranteed ordering

    - #### cancelAll

          public void cancelAll()

      Description copied from interface: `EntryTaskScheduler`
      Cancel all scheduled executions
      Specified by:
        `cancelAll` in interface `EntryTaskScheduler<K,V>`

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### size

          public int size()

Copyright © 2018. All rights reserved.