Class DynamoDbPersistenceProvider<V extends DigitalTwinBase>

  • Type Parameters:
    V - the type of the digital twin
    All Implemented Interfaces:
    com.scaleout.client.ighosting.InvocationGridSignalHandler, PersistenceProvider, java.lang.AutoCloseable

    public class DynamoDbPersistenceProvider<V extends DigitalTwinBase>
    extends PersistentStorage<V>
    implements PersistenceProvider, java.lang.AutoCloseable
    DynamoDB persistent storage - transparently store and load digital twins to and from a DynamoDB deployment.
    • Constructor Summary

      Constructors 
      Constructor Description
      DynamoDbPersistenceProvider​(com.scaleout.client.GridConnection connection, java.lang.String model, java.lang.Class<V> clazz)  
    • Method Summary

      Modifier and Type Method Description
      void close()  
      java.lang.String getInstance​(java.lang.String modelName, java.lang.String instanceId)
      Retrieves an instance or null if it doesn't exist.
      java.util.concurrent.CompletableFuture<java.lang.String> getInstanceAsync​(java.lang.String modelName, java.lang.String instanceId)
      Retrieves a future that when complete will return an instance or null if it doesn't exist.
      java.util.List<java.lang.String> getInstanceIds​(java.lang.String modelName)
      Retrieves the instance IDs stored in a container, or an empty list if no instances exist.
      java.util.concurrent.CompletableFuture<java.util.List<java.lang.String>> getInstanceIdsAsync​(java.lang.String modelName)
      Retrieves a future that when complete will return the instance IDs stored in a container, or an empty list if no instances exist.
      byte getPersistencePolicy()  
      <T> T getProperty​(java.lang.String modelName, java.lang.String instanceId, java.lang.String propertyName, java.lang.Class<T> aClass)
      Retrieves a property or null if the property does not exist.
      <T> java.util.concurrent.CompletableFuture<T> getPropertyAsync​(java.lang.String modelName, java.lang.String instanceId, java.lang.String propertyName, java.lang.Class<T> aClass)
      Retrieves a future that will return a property or null if the property does not exist.
      java.util.Map<java.lang.String,​java.lang.String> getPropertyMap​(java.lang.String s)
      Retrieves a map of property names to property types, or an empty map.
      java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,​java.lang.String>> getPropertyMapAsync​(java.lang.String s)
      Retrieves a future that will return a map of property names to property, or an empty map.
      PersistenceProviderType getProviderType()
      Retrieves this persistence providers type.
      <T> T getRtdtProperty​(java.lang.String instanceId, java.lang.String propertyName, java.lang.Class<T> aClass)
      Retrieves a property for a RTDT instance or null if the property does not exist.
      <T> java.util.concurrent.CompletableFuture<T> getRtdtPropertyAsync​(java.lang.String instanceId, java.lang.String propertyName, java.lang.Class<T> aClass)
      Retrieves a future that will return a property value for a RTDT instance or null if the property doesn't exist.
      java.lang.String getTableName()  
      void initialize​(java.util.HashMap<java.lang.String,​java.lang.String> conf)  
      void initializeDynamoDbConnection()  
      boolean isActive()
      Returns true if this PersistenceProvider is active, false otherwise.
      V load​(java.lang.String id)  
      void onSignal​(com.scaleout.client.ighosting.InvocationGridSignal invocationGridSignal, java.lang.Object o)  
      void store​(V instance)  
      java.lang.String toString()  
      void updateProperty​(java.lang.String modelName, java.lang.String instanceId, java.lang.String propertyName, java.lang.Object propertyValue)
      Updates a property for the provided instance id in the provided container specified by the property name and property value.
      java.util.concurrent.CompletableFuture<java.lang.Void> updatePropertyAsync​(java.lang.String modelName, java.lang.String instanceId, java.lang.String propertyName, java.lang.Object propertyValue)
      Retrieves a future that will complete exceptionally or return void if the instance's property was successfully updated.
      void updateRtdtProperty​(java.lang.String instanceId, java.lang.String propertyName, java.lang.Object propertyValue)
      Updates a RTDT property for the provided instance id specified by the property name and property value.
      java.util.concurrent.CompletableFuture<java.lang.Void> updateRtdtPropertyAsync​(java.lang.String instanceId, java.lang.String propertyName, java.lang.Object propertyValue)
      Retrieves a future that will complete exceptionally or return void if the RTDT's property was successfully updated.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • DynamoDbPersistenceProvider

        public DynamoDbPersistenceProvider​(com.scaleout.client.GridConnection connection,
                                           java.lang.String model,
                                           java.lang.Class<V> clazz)
    • Method Detail

      • getTableName

        public java.lang.String getTableName()
      • initializeDynamoDbConnection

        public void initializeDynamoDbConnection()
      • getInstanceIdsAsync

        public java.util.concurrent.CompletableFuture<java.util.List<java.lang.String>> getInstanceIdsAsync​(java.lang.String modelName)
        Description copied from interface: PersistenceProvider
        Retrieves a future that when complete will return the instance IDs stored in a container, or an empty list if no instances exist.
        Specified by:
        getInstanceIdsAsync in interface PersistenceProvider
        Parameters:
        modelName - the container name.
        Returns:
        a future that will return a list of instances.
      • getInstanceIds

        public java.util.List<java.lang.String> getInstanceIds​(java.lang.String modelName)
        Description copied from interface: PersistenceProvider
        Retrieves the instance IDs stored in a container, or an empty list if no instances exist.
        Specified by:
        getInstanceIds in interface PersistenceProvider
        Parameters:
        modelName - the container name.
        Returns:
        a list of instances.
      • getInstanceAsync

        public java.util.concurrent.CompletableFuture<java.lang.String> getInstanceAsync​(java.lang.String modelName,
                                                                                         java.lang.String instanceId)
        Description copied from interface: PersistenceProvider
        Retrieves a future that when complete will return an instance or null if it doesn't exist.
        Specified by:
        getInstanceAsync in interface PersistenceProvider
        Parameters:
        modelName - the container name.
        instanceId - the instance identifier.
        Returns:
        a future that will return an instance or null.
      • getInstance

        public java.lang.String getInstance​(java.lang.String modelName,
                                            java.lang.String instanceId)
        Description copied from interface: PersistenceProvider
        Retrieves an instance or null if it doesn't exist.
        Specified by:
        getInstance in interface PersistenceProvider
        Parameters:
        modelName - the container name
        instanceId - the instance identifier
        Returns:
        the instance or null.
      • getPropertyMapAsync

        public java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,​java.lang.String>> getPropertyMapAsync​(java.lang.String s)
        Description copied from interface: PersistenceProvider
        Retrieves a future that will return a map of property names to property, or an empty map.
        Specified by:
        getPropertyMapAsync in interface PersistenceProvider
        Parameters:
        s - the container name.
        Returns:
        a future that will return a map of property names to property types.
      • getPropertyMap

        public java.util.Map<java.lang.String,​java.lang.String> getPropertyMap​(java.lang.String s)
        Description copied from interface: PersistenceProvider
        Retrieves a map of property names to property types, or an empty map.
        Specified by:
        getPropertyMap in interface PersistenceProvider
        Parameters:
        s - the container name.
        Returns:
        a map of property names to property types.
      • updatePropertyAsync

        public java.util.concurrent.CompletableFuture<java.lang.Void> updatePropertyAsync​(java.lang.String modelName,
                                                                                          java.lang.String instanceId,
                                                                                          java.lang.String propertyName,
                                                                                          java.lang.Object propertyValue)
        Description copied from interface: PersistenceProvider
        Retrieves a future that will complete exceptionally or return void if the instance's property was successfully updated. Updates a property for the provided instance id in the provided container specified by the property name and property value.
        Specified by:
        updatePropertyAsync in interface PersistenceProvider
        Parameters:
        modelName - the container name.
        instanceId - the instance id.
        propertyName - the property name.
        propertyValue - the property value.
        Returns:
        a future that will complete exceptionally or return void.
      • updateProperty

        public void updateProperty​(java.lang.String modelName,
                                   java.lang.String instanceId,
                                   java.lang.String propertyName,
                                   java.lang.Object propertyValue)
        Description copied from interface: PersistenceProvider
        Updates a property for the provided instance id in the provided container specified by the property name and property value.
        Specified by:
        updateProperty in interface PersistenceProvider
        Parameters:
        modelName - the container name.
        instanceId - the instance id.
        propertyName - the property name.
        propertyValue - the property value.
      • getPropertyAsync

        public <T> java.util.concurrent.CompletableFuture<T> getPropertyAsync​(java.lang.String modelName,
                                                                              java.lang.String instanceId,
                                                                              java.lang.String propertyName,
                                                                              java.lang.Class<T> aClass)
        Description copied from interface: PersistenceProvider
        Retrieves a future that will return a property or null if the property does not exist.
        Specified by:
        getPropertyAsync in interface PersistenceProvider
        Type Parameters:
        T - the type of the property to return
        Parameters:
        modelName - the container name.
        instanceId - the instance id.
        propertyName - the property name.
        aClass - the class representing the property.
        Returns:
        the property or null if the property does not exist.
      • getProperty

        public <T> T getProperty​(java.lang.String modelName,
                                 java.lang.String instanceId,
                                 java.lang.String propertyName,
                                 java.lang.Class<T> aClass)
        Description copied from interface: PersistenceProvider
        Retrieves a property or null if the property does not exist.
        Specified by:
        getProperty in interface PersistenceProvider
        Type Parameters:
        T - the type of the property to return.
        Parameters:
        modelName - the container name.
        instanceId - the instance id.
        propertyName - the property name
        aClass - the class representing the property.
        Returns:
        the property or null if the property does not exist.
      • updateRtdtPropertyAsync

        public java.util.concurrent.CompletableFuture<java.lang.Void> updateRtdtPropertyAsync​(java.lang.String instanceId,
                                                                                              java.lang.String propertyName,
                                                                                              java.lang.Object propertyValue)
        Description copied from interface: PersistenceProvider
        Retrieves a future that will complete exceptionally or return void if the RTDT's property was successfully updated. Updates a RTDT property for the provided instance id specified by the property name and property value.
        Specified by:
        updateRtdtPropertyAsync in interface PersistenceProvider
        Parameters:
        instanceId - the instance id.
        propertyName - the property name.
        propertyValue - the property value.
        Returns:
        a future that will complete exceptionally or return void.
      • updateRtdtProperty

        public void updateRtdtProperty​(java.lang.String instanceId,
                                       java.lang.String propertyName,
                                       java.lang.Object propertyValue)
        Description copied from interface: PersistenceProvider
        Updates a RTDT property for the provided instance id specified by the property name and property value.
        Specified by:
        updateRtdtProperty in interface PersistenceProvider
        Parameters:
        instanceId - the instance id.
        propertyName - the property name.
        propertyValue - the property value.
      • getRtdtPropertyAsync

        public <T> java.util.concurrent.CompletableFuture<T> getRtdtPropertyAsync​(java.lang.String instanceId,
                                                                                  java.lang.String propertyName,
                                                                                  java.lang.Class<T> aClass)
        Description copied from interface: PersistenceProvider
        Retrieves a future that will return a property value for a RTDT instance or null if the property doesn't exist.
        Specified by:
        getRtdtPropertyAsync in interface PersistenceProvider
        Type Parameters:
        T - the type of the property to return.
        Parameters:
        instanceId - the instance id.
        propertyName - the property name.
        aClass - the class of the property type
        Returns:
        a future that will return a property value for a RTDT instance.
      • getRtdtProperty

        public <T> T getRtdtProperty​(java.lang.String instanceId,
                                     java.lang.String propertyName,
                                     java.lang.Class<T> aClass)
        Description copied from interface: PersistenceProvider
        Retrieves a property for a RTDT instance or null if the property does not exist.
        Specified by:
        getRtdtProperty in interface PersistenceProvider
        Type Parameters:
        T - the type of the property to return.
        Parameters:
        instanceId - the instance id.
        propertyName - the property name.
        aClass - the class of the property type.
        Returns:
        the property value.
      • close

        public void close()
                   throws java.lang.Exception
        Specified by:
        close in interface java.lang.AutoCloseable
        Throws:
        java.lang.Exception
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • onSignal

        public void onSignal​(com.scaleout.client.ighosting.InvocationGridSignal invocationGridSignal,
                             java.lang.Object o)
        Specified by:
        onSignal in interface com.scaleout.client.ighosting.InvocationGridSignalHandler