Package com.rpl.rama

Interface PState

All Superinterfaces:
PartitionedObject

public interface PState extends PartitionedObject
Interface for thread-safe PState clients. These are also known as "foreign PStates". A PState client is retrieved using a RamaClusterManager on a real cluster or InProcessCluster in a test environment.

Static methods on this class implement schemas for use when declaring a PState in a module with pstate.
See Also:
  • Method Details

    • migrated

      static PState.MigratedSchema migrated(Object schema, String migrationId, RamaFunction1<?,?> migrationFunction)
      Declares a migration at a location in a PState schema. This can only be used at positions within a PState that are serialized as a whole, e.g. the value of a subindexed map or the value of a top level map. Migrations are instantaneous in that after a module update all reads will return fully migrated results. The supplied migration function is applied on reads while Rama migrates the values on disk in the background.
      Parameters:
      schema - The new schema for this location in the PState
      migrationId - Used to determine if a migration should be restarted or continue where it left off when the module is updated mid-migration. If this remains the same, it continues where it left off. Otherwise, it restarts from the beginning of the PState.
      migrationFunction - A function that converts values at that position from the old schema to the new schema. It must be idempotent, as it may be called on either a migrated or unmigrated value.
      Returns:
      Object for declaring options for the migrated schema
      See Also:
    • mapSchema

      static PState.Schema mapSchema(Class keyClass, Class valueSchema)
      Declare a map schema
      Parameters:
      keyClass - Type of keys in map
      valueSchema - Type of values in map
    • mapSchema

      static PState.Schema mapSchema(Class keyClass, PState.Schema valueSchema)
      Declare a map schema
      Parameters:
      keyClass - Type of keys in map
      valueSchema - Schema for nested data structures for map values
    • setSchema

      static PState.Schema setSchema(Class valClass)
      Declare a set schema
      Parameters:
      valClass - Type of values in set
    • listSchema

      static PState.Schema listSchema(Class valClass)
      Declare a list schema
      Parameters:
      valClass - Type of values in list
    • listSchema

      static PState.Schema listSchema(PState.Schema valueSchema)
      Declare a list schema
      Parameters:
      valueSchema - Schema for values in list
    • fixedKeysSchema

      static PState.Schema fixedKeysSchema(Object... keyAndSchemas)
      Declare schema for map with different schema for each key. Specified keys are the only ones allowed when writing, but they're all optional. Example: PState.fixedKeysSchema("a", Long.class, "b", PState.setSchema(String.class)
      Parameters:
      keyAndSchemas - Alternating declarations of keys and the Class or PState.Schema schema for that key
    • select

      <T> List<T> select(Path path)
      Queries PState with Path. If PState has more than one partition, Path must start with key navigator and query will extract that key as partitioning key. Select is allowed to yield during execution, and the query is done on a stable view of the PState at its value when the query begins. Blocking operation.
      Type Parameters:
      T - Type of navigated values
      Parameters:
      path - Query path
      Returns:
      List of navigated values
      See Also:
    • select

      <T> List<T> select(Object partitioningKey, Path path)
      Queries PState with Path using explicit partitioning key. Select is allowed to yield during execution, and the query is done on a stable view of the PState at its value when the query begins.Blocking operation.
      Type Parameters:
      T - Type of navigated value
      Parameters:
      partitioningKey - Explicit partitioning key
      path - Query path
      Returns:
      List of navigated values
      See Also:
    • selectOne

      <T> T selectOne(Path path)
      Queries PState with Path that must navigate to exactly one value. If PState has more than one partition, Path must start with key navigator and query will extract that key as partitioning key. Select is allowed to yield during execution, and the query is done on a stable view of the PState at its value when the query begins. Blocking operation.
      Type Parameters:
      T - Type of navigated value
      Parameters:
      path - Query path
      Returns:
      Navigated value
      See Also:
    • selectOne

      <T> T selectOne(Object partitioningKey, Path path)
      Queries PState using explicit partitioning key with Path that must navigate to exactly one value. Select is allowed to yield during execution, and the query is done on a stable view of the PState at its value when the query begins. Blocking operation.
      Type Parameters:
      T - Type of navigated value
      Parameters:
      partitioningKey - Explicit partitioning key
      path - Query path
      Returns:
      Navigated value
      See Also:
    • selectAsync

      <T> CompletableFuture<List<T>> selectAsync(Path path)
      Queries PState with Path. If PState has more than one partition, Path must start with key navigator and query will extract that key as partitioning key. Select is allowed to yield during execution, and the query is done on a stable view of the PState at its value when the query begins. Non-blocking operation.
      Type Parameters:
      T - Type of navigated values
      Parameters:
      path - Query path
      Returns:
      Future for list of navigated values
      See Also:
    • selectAsync

      <T> CompletableFuture<List<T>> selectAsync(Object partitioningKey, Path path)
      Queries PState with Path using explicit partitioning key. Select is allowed to yield during execution, and the query is done on a stable view of he PState at its value when the query begins. Non-blocking operation.
      Type Parameters:
      T - Type of navigated values
      Parameters:
      partitioningKey - Explicit partitioning key
      path - Query path
      Returns:
      Future for list of navigated values
      See Also:
    • selectOneAsync

      <T> CompletableFuture<T> selectOneAsync(Path path)
      Queries PState with Path that must navigate to exactly one value. If PState has more than one partition, Path must start with key navigator and query will extract that key as partitioning key. Select is allowed to yield during execution, and the query is done on a stable view of the PState at its value when the query begins. Non-blocking operation.
      Type Parameters:
      T - Type of navigated value
      Parameters:
      path - Query path
      Returns:
      Future for navigated value
      See Also:
    • selectOneAsync

      <T> CompletableFuture<T> selectOneAsync(Object partitioningKey, Path path)
      Queries PState using explicit partitioning key with Path that must navigate to exactly one value. Select is allowed to yield during execution, and the query is done on a stable view of the PState at its value when the query begins. Non-blocking operation.
      Type Parameters:
      T - Type of navigated value
      Parameters:
      partitioningKey - Explicit partitioning key
      path - Query path
      Returns:
      Future for navigated value
      See Also:
    • proxy

      <T> ProxyState<T> proxy(Path path)
      Reactive query of PState with Path that must navigate to exactly one value. If PState has more than one partition, Path must start with key navigator and query will extract that key as partitioning key. Blocks until initial query finishes, then receives fine-grained updates to returned ProxyState in background.
      Type Parameters:
      T - Type of navigated value
      Parameters:
      path - Query path
      Returns:
      Reactive value
      See Also:
    • proxy

      <T> ProxyState<T> proxy(Object partitioningKey, Path path)
      Reactive query of PState using explicit partitioning key with Path that must navigate to exactly one value. Blocks until initial query finishes, then receives fine-grained updates to returned ProxyState in background.
      Type Parameters:
      T - Type of navigated value
      Parameters:
      partitioningKey - Explicit partitioning key
      path - Query path
      Returns:
      Reactive value
      See Also:
    • proxy

      <T> ProxyState<T> proxy(Path path, ProxyState.Callback<T> callback)
      Reactive query of PState with Path that must navigate to exactly one value. Receives fine-grained information about changes to value via provided callback. If PState has more than one partition, Path must start with key navigator and query will extract that key as partitioning key. Blocks until initial query finishes, then receives fine-grained updates in background.
      Type Parameters:
      T - Type of navigated value
      Parameters:
      path - Query path
      callback - Function that receives fine-grained information about changes. Callbacks run on a separate dedicated thread.
      Returns:
      Reactive value
      See Also:
    • proxy

      <T> ProxyState<T> proxy(Object partitioningKey, Path path, ProxyState.Callback<T> callback)
      Reactive query of PState using explicit partitioning key with Path that must navigate to exactly one value. Receives fine-grained information about changes to value via provided callback. Blocks until initial query finishes, then receives fine-grained updates in background.
      Type Parameters:
      T - Type of navigated value
      Parameters:
      partitioningKey - Explicit partitioning key
      path - Query path
      callback - Function that receives fine-grained information about changes. Callbacks run on a separate dedicated thread.
      Returns:
      Reactive value
      See Also:
    • proxyAsync

      <T> CompletableFuture<ProxyState<T>> proxyAsync(Path path)
      Reactive query of PState with Path that must navigate to exactly one value. If PState has more than one partition, Path must start with key navigator and query will extract that key as partitioning key. Non-blocking. Once ProxyState is delivered to returned future, the ProxyState receives fine-grained updates in background.
      Type Parameters:
      T - Type of navigated value
      Parameters:
      path - Query path
      Returns:
      Future for reactive value
      See Also:
    • proxyAsync

      <T> CompletableFuture<ProxyState<T>> proxyAsync(Object partitioningKey, Path path)
      Reactive query of PState using explicit partitioning key with Path that must navigate to exactly one value. Non-blocking. Once ProxyState is delivered to returned future, the ProxyState receives fine-grained updates in background.
      Type Parameters:
      T - Type of navigated value
      Parameters:
      partitioningKey - Explicit partitioning key
      path - Query path
      Returns:
      Future for reactive value
      See Also:
    • proxyAsync

      <T> CompletableFuture<ProxyState<T>> proxyAsync(Path path, ProxyState.Callback<T> callback)
      Reactive query of PState with Path that must navigate to exactly one value. Receives fine-grained information about changes to value via provided callback. If PState has more than one partition, Path must start with key navigator and query will extract that key as partitioning key. Non-blocking. Once ProxyState is delivered to returned future, the ProxyState receives fine-grained updates in background.
      Type Parameters:
      T - Type of navigated value
      Parameters:
      path - Query path
      callback - Function that receives fine-grained information about changes. Callbacks run on a separate dedicated thread.
      Returns:
      Future for reactive value
      See Also:
    • proxyAsync

      <T> CompletableFuture<ProxyState<T>> proxyAsync(Object partitioningKey, Path path, ProxyState.Callback<T> callback)
      Reactive query of PState using explicit partitioning key with Path that must navigate to exactly one value. Receives fine-grained information about changes to value via provided callback. Non-blocking. Once ProxyState is delivered to returned future, the ProxyState receives fine-grained updates in background.
      Type Parameters:
      T - Type of navigated value
      Parameters:
      partitioningKey - Explicit partitioning key
      path - Query path
      callback - Function that receives fine-grained information about changes. Callbacks run on a separate dedicated thread.
      Returns:
      Future for reactive value
      See Also: