RrdNioBackendFactory
Keywords: org.jrobin.core.RrdNioBackendFactory class

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.jrobin.core
Class RrdNioBackendFactory

    java.lang.Object
      org.jrobin.core.RrdBackendFactory
          org.jrobin.core.RrdFileBackendFactory
              org.jrobin.core.RrdNioBackendFactory

public class RrdNioBackendFactory
extends RrdFileBackendFactory

Factory class which creates actual `RrdNioBackend` objects. This is the default factory since 1.4.0 version

Field Summary
`static int` | `DEFAULT_SYNC_PERIOD` Period in seconds between consecutive synchronizations when sync-mode is set to SYNC_BACKGROUND.
`static java.lang.String` | `NAME` factory name, "NIO"
`static int` | `SYNC_AFTERFETCH` See `setSyncMode(int)` for explanation
`static int` | `SYNC_AFTERUPDATE` See `setSyncMode(int)` for explanation
`static int` | `SYNC_BACKGROUND` See `setSyncMode(int)` for explanation
`static int` | `SYNC_BEFOREFETCH` See `setSyncMode(int)` for explanation
`static int` | `SYNC_BEFOREUPDATE` See `setSyncMode(int)` for explanation
`static int` | `SYNC_ONCLOSE` See `setSyncMode(int)` for explanation

Constructor Summary
`RrdNioBackendFactory()`

Method Summary
`java.lang.String` | `getFactoryName()` Returns the name of this factory.
`static int` | `getSyncMode()` Returns the current synchronization mode between backend data in memory and data in the persistent storage (disk file).
`static int` | `getSyncPeriod()` Returns time between two consecutive background synchronizations.
`protected RrdBackend` | `open(java.lang.String path, boolean readOnly, int lockMode)` Creates RrdNioBackend object for the given file path.
`static void` | `setSyncMode(int syncMode)` Sets the current synchronization mode between backend data in memory (backend cache) and RRD data in the persistant storage (disk file).
`static void` | `setSyncPeriod(int syncPeriod)` Sets time between consecutive background synchronizations.

Methods inherited from class org.jrobin.core.RrdFileBackendFactory
`exists`

Methods inherited from class org.jrobin.core.RrdBackendFactory
`getDefaultFactory, getFactory, registerAndSetAsDefaultFactory, registerFactory, setDefaultFactory`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### NAME

    public static final java.lang.String NAME

  factory name, "NIO"

  See Also:
    Constant Field Values

### SYNC_ONCLOSE

    public static final int SYNC_ONCLOSE

  See `setSyncMode(int)` for explanation

  See Also:
    Constant Field Values

### SYNC_BEFOREUPDATE

    public static final int SYNC_BEFOREUPDATE

  See `setSyncMode(int)` for explanation

  See Also:
    Constant Field Values

### SYNC_AFTERUPDATE

    public static final int SYNC_AFTERUPDATE

  See `setSyncMode(int)` for explanation

  See Also:
    Constant Field Values

### SYNC_BEFOREFETCH

    public static final int SYNC_BEFOREFETCH

  See `setSyncMode(int)` for explanation

  See Also:
    Constant Field Values

### SYNC_AFTERFETCH

    public static final int SYNC_AFTERFETCH

  See `setSyncMode(int)` for explanation

  See Also:
    Constant Field Values

### SYNC_BACKGROUND

    public static final int SYNC_BACKGROUND

  See `setSyncMode(int)` for explanation

  See Also:
    Constant Field Values

### DEFAULT_SYNC_PERIOD

    public static final int DEFAULT_SYNC_PERIOD

  Period in seconds between consecutive synchronizations when sync-mode is set to SYNC_BACKGROUND. By default in-memory cache will be transferred to the disc every 300 seconds (5 minutes). Default value can be changed via `setSyncPeriod(int)` method.

  See Also:
    Constant Field Values

Constructor Detail

### RrdNioBackendFactory

    public RrdNioBackendFactory()

Method Detail

### getSyncMode

    public static int getSyncMode()

  Returns the current synchronization mode between backend data in memory and data in the persistent storage (disk file).

  Returns:
    Integer representing current synchronization mode (SYNC_ONCLOSE, SYNC_BEFOREUPDATE, SYNC_AFTERUPDATE, SYNC_BEFOREFETCH, SYNC_AFTERFETCH or SYNC_BACKGROUND). See `setSyncMode(int)` for full explanation of these return values.

### setSyncMode

    public static void setSyncMode(int syncMode)

  Sets the current synchronization mode between backend data in memory (backend cache) and RRD data in the persistant storage (disk file).

  Parameters:
    `syncMode` - Desired synchronization mode. Possible values are:

    - SYNC_ONCLOSE: synchronization will be performed only when `RrdDb.close()` is called (RRD file is closed) or when `RrdDb.sync()` method is called.
    - SYNC_BEFOREUPDATE: synchronization will be performed before each `Sample.update()` call (right before RRD file is about to be updated).
    - SYNC_AFTERUPDATE: synchronization will be performed after each `Sample.update()` call (right after RRD file is updated).
    - SYNC_BEFOREFETCH: synchronization will be performed before each `FetchRequest.fetchData()` call (right before data is about to be fetched from a RRD file, for example for graph creation)
    - SYNC_AFTERFETCH: synchronization will be performed after each `FetchRequest.fetchData()` call (right after data is fetched from a RRD file)
    - SYNC_BACKGROUND (default): synchronization will be performed automatically from a separate thread on a regular basis. Period of time between the two consecutive synchronizations can be controlled with `setSyncPeriod(int)`.

### getSyncPeriod

    public static int getSyncPeriod()

  Returns time between two consecutive background synchronizations. If not changed via `setSyncPeriod(int)` method call, defaults to `DEFAULT_SYNC_PERIOD`. See `setSyncPeriod(int)` for more information.

  Returns:
    Time in seconds between consecutive background synchronizations.

### setSyncPeriod

    public static void setSyncPeriod(int syncPeriod)

  Sets time between consecutive background synchronizations. Method is effective only if synchronization mode is set to SYNC_BACKGROUND.

  Parameters:
    `syncPeriod` - Time in seconds between consecutive background synchronizations.

### open

    protected RrdBackend open(java.lang.String path,
                              boolean readOnly,
                              int lockMode)
                       throws java.io.IOException

  Creates RrdNioBackend object for the given file path.

  Overrides:
    `open` in class `RrdFileBackendFactory`
  Parameters:
    `path` - File path
    `readOnly` - True, if the file should be accessed in read/only mode. False otherwise.
    `lockMode` - One of the following constants: `RrdDb.NO_LOCKS`, `RrdDb.EXCEPTION_IF_LOCKED` or `RrdDb.WAIT_IF_LOCKED`.
  Returns:
    RrdNioBackend object which handles all I/O operations for the given file path
  Throws:
    `java.io.IOException` - Thrown in case of I/O error.

### getFactoryName

    public java.lang.String getFactoryName()

  Returns the name of this factory.

  Overrides:
    `getFactoryName` in class `RrdFileBackendFactory`
  Returns:
    Factory name (equals to string "NIO")

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD