DataPolicy (Apache Geode 1.9.1)
Date: 2019-08-30

org.apache.geode.cache

## Class DataPolicy

- java.lang.Object
- - org.apache.geode.cache.DataPolicy

- All Implemented Interfaces:
    Serializable

      @Immutable
      public class DataPolicy
      extends Object
      implements Serializable

  Enumerated type for region data policy. The data policy specifies how this local cache will handle the data for a region.
  1. `EMPTY` causes data to never be stored in local memory. The region will always appear empty. It can be used to for zero footprint producers that only want to distribute their data to others and for zero footprint consumers that only want to see events.
  2. `NORMAL` causes data that this region is interested in to be stored in local memory. It allows the contents in this cache to differ from other caches.
  3. `PARTITION` causes data that this region holds to be spread across processes. The amount of data held in this cache is configured in `PartitionAttributes` with a `PartitionAttributesFactory`.
  4. `PERSISTENT_PARTITION` in addition to `PARTITION` also causes data to be stored to disk. The region initialization uses the data stored on disk.
  5. `REPLICATE` causes data that this region is interested in to be stored in local memory. A distributed region will be initialized with the data from other caches. On distributed region operations that would cause the contents to differ with other caches are not allowed. This policy is allowed on local scope region but it behaves the same as `NORMAL`.
  6. `PERSISTENT_REPLICATE` in addition to `REPLICATE` also causes data to be stored to disk. The region initialization uses the data stored on disk. Note that the persistence applies to both local scope and distributed scope.
  Since:
    GemFire 5.0
  See Also:
    `AttributesFactory.setDataPolicy(org.apache.geode.cache.DataPolicy)`, `RegionAttributes.getDataPolicy()`, Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static DataPolicy` | `DEFAULT` The data policy used by default; it is `NORMAL`.
    `static DataPolicy` | `EMPTY` Data is never stored in local memory.
    `static DataPolicy` | `NORMAL` Allows the contents in this cache to differ from other caches.
    `byte` | `ordinal` used as ordinal to represent this DataPolicy
    `static DataPolicy` | `PARTITION` Data in this region may be spread across a number of processes.
    `static DataPolicy` | `PERSISTENT_PARTITION` In addition to `PARTITION` also causes data to be stored to disk.
    `static DataPolicy` | `PERSISTENT_REPLICATE` In addition to `REPLICATE` also causes data to be stored to disk.
    `static DataPolicy` | `PRELOADED` In addition to `NORMAL`, contents inside of this cache are (partially) initialized with data from other caches, if available.
    `static DataPolicy` | `REPLICATE` The region will be initialized with the data from other caches and accepts any new entries created in other caches.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `static DataPolicy` | `fromOrdinal(byte ordinal)` Return the DataPolicy represented by specified ordinal
    `static DataPolicy` | `fromString(String s)`
    `boolean` | `isDefault()` Deprecated. from version 6.5 forward please use an identity comparison instead of this method
    `boolean` | `isEmpty()` Deprecated. from version 6.5 forward please use withStorage()
    `boolean` | `isNormal()` Deprecated. from version 6.5 forward please use an identity comparison instead of this method
    `boolean` | `isPartition()` Deprecated. from version 6.5 forward please use withPartitioning()
    `boolean` | `isPersistentReplicate()` Deprecated. from version 6.5 forward please use withPersistence() and withReplication()
    `boolean` | `isPreloaded()` Deprecated. from version 6.5 forward please use withPreloaded()
    `boolean` | `isReplicate()` Deprecated. from version 6.5 forward please use withReplication()
    `String` | `toString()` Returns a string representation for this data policy.
    `boolean` | `withPartitioning()` Return whether this policy does partitioning.
    `boolean` | `withPersistence()` Return whether this policy does persistence.
    `boolean` | `withPreloaded()` Return whether this policy does preloaded.
    `boolean` | `withReplication()` Return whether this policy does replication.
    `boolean` | `withStorage()` Return true if regions with this policy store data locally.

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

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

- - ### Field Detail

    - #### EMPTY

          @Immutable
          public static final DataPolicy EMPTY

      Data is never stored in local memory. The region will always be empty locally. It can be used to for zero footprint producers that only want to distribute their data to others and for zero footprint consumers that only want to see events.

    - #### NORMAL

          @Immutable
          public static final DataPolicy NORMAL

      Allows the contents in this cache to differ from other caches.

      Data that this region is interested in is stored in local memory.

    - #### REPLICATE

          @Immutable
          public static final DataPolicy REPLICATE

      The region will be initialized with the data from other caches and accepts any new entries created in other caches.

      Operations that would cause the contents to differ with other caches are not allowed.

      Data that this region is interested in is stored in local memory.

    - #### PERSISTENT_REPLICATE

          @Immutable
          public static final DataPolicy PERSISTENT_REPLICATE

      In addition to `REPLICATE` also causes data to be stored to disk. The region initialization may use the data stored on disk.

    - #### PARTITION

          @Immutable
          public static final DataPolicy PARTITION

      Data in this region may be spread across a number of processes. This is further configured with `partitioning attributes`

    - #### PRELOADED

          @Immutable
          public static final DataPolicy PRELOADED

      In addition to `NORMAL`, contents inside of this cache are (partially) initialized with data from other caches, if available.

    - #### PERSISTENT_PARTITION

          @Immutable
          public static final DataPolicy PERSISTENT_PARTITION

      In addition to `PARTITION` also causes data to be stored to disk. The region initialization may use the data stored on disk.
      Since:
        GemFire 6.5

    - #### DEFAULT

          @Immutable
          public static final DataPolicy DEFAULT

      The data policy used by default; it is `NORMAL`.

    - #### ordinal

          public final byte ordinal

      used as ordinal to represent this DataPolicy

  - ### Method Detail

    - #### fromOrdinal

          public static DataPolicy fromOrdinal(byte ordinal)

      Return the DataPolicy represented by specified ordinal

    - #### withStorage

          public boolean withStorage()

      Return true if regions with this policy store data locally.

      Although DataPolicy `PARTITION` will return true to this query, it is possible to turn off local storage with `PartitionAttributesFactory.setLocalMaxMemory(int)` by setting localMaxMemory to zero.

      Returns:
        true if regions with this policy store data locally.
      See Also:
        `NORMAL`, `PRELOADED`, `REPLICATE`, `PERSISTENT_REPLICATE`, `PARTITION`, `PERSISTENT_PARTITION`

    - #### withReplication

          public boolean withReplication()

      Return whether this policy does replication.
      Returns:
        true if this policy does replication.
      See Also:
        `REPLICATE`, `PERSISTENT_REPLICATE`

    - #### withPersistence

          public boolean withPersistence()

      Return whether this policy does persistence.
      Returns:
        true if this policy does persistence.
      Since:
        GemFire 6.5
      See Also:
        `PERSISTENT_PARTITION`, `PERSISTENT_REPLICATE`

    - #### withPartitioning

          public boolean withPartitioning()

      Return whether this policy does partitioning.
      Returns:
        true if this policy does partitioning
      Since:
        GemFire 6.5
      See Also:
        `PARTITION`, `PERSISTENT_PARTITION`

    - #### withPreloaded

          public boolean withPreloaded()

      Return whether this policy does preloaded.
      Returns:
        true if this policy does preloaded.
      Since:
        GemFire 6.5
      See Also:
        `PRELOADED`

    - #### isEmpty

          public boolean isEmpty()

      Deprecated. from version 6.5 forward please use withStorage()
      Return true if this policy is `EMPTY`.
      Returns:
        true if this policy is `EMPTY`.

    - #### isNormal

          public boolean isNormal()

      Deprecated. from version 6.5 forward please use an identity comparison instead of this method
      Return true if this policy is `NORMAL`.
      Returns:
        true if this policy is `NORMAL`.

    - #### isPreloaded

          public boolean isPreloaded()

      Deprecated. from version 6.5 forward please use withPreloaded()
      Return true if this policy is `PRELOADED`.
      Returns:
        true if this policy is `PRELOADED`

    - #### isDefault

          public boolean isDefault()

      Deprecated. from version 6.5 forward please use an identity comparison instead of this method
      Return true if this policy is the default.
      Returns:
        true if this policy is the default.

    - #### isReplicate

          public boolean isReplicate()

      Deprecated. from version 6.5 forward please use withReplication()
      Return true if this policy is `REPLICATE`.
      Returns:
        true if this policy is `REPLICATE`.

    - #### isPersistentReplicate

          public boolean isPersistentReplicate()

      Deprecated. from version 6.5 forward please use withPersistence() and withReplication()
      Return true if this policy is `PERSISTENT_REPLICATE`.
      Returns:
        true if this policy is `PERSISTENT_REPLICATE`.

    - #### isPartition

          public boolean isPartition()

      Deprecated. from version 6.5 forward please use withPartitioning()
      Return true if this policy is `PARTITION`.
      Returns:
        true if this policy is `PARTITION`

    - #### toString

          public String toString()

      Returns a string representation for this data policy.
      Overrides:
        `toString` in class `Object`
      Returns:
        the name of this data policy.

    - #### fromString

          public static DataPolicy fromString(String s)