Class DynamoDbPersistenceProvider<V extends DigitalTwinBase>
- java.lang.Object
-
- com.scaleoutsoftware.digitaltwin.persistentstorage.PersistentStorage<V>
-
- com.scaleoutsoftware.digitaltwin.persistentstorage.DynamoDbPersistenceProvider<V>
-
- 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.
-
-
Field Summary
-
Fields inherited from class com.scaleoutsoftware.digitaltwin.persistentstorage.PersistentStorage
_connection
-
-
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 voidclose()java.lang.StringgetInstance(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.bytegetPersistencePolicy()<T> TgetProperty(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.PersistenceProviderTypegetProviderType()Retrieves this persistence providers type.<T> TgetRtdtProperty(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.StringgetTableName()voidinitialize(java.util.HashMap<java.lang.String,java.lang.String> conf)voidinitializeDynamoDbConnection()booleanisActive()Returns true if this PersistenceProvider is active, false otherwise.Vload(java.lang.String id)voidonSignal(com.scaleout.client.ighosting.InvocationGridSignal invocationGridSignal, java.lang.Object o)voidstore(V instance)java.lang.StringtoString()voidupdateProperty(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.voidupdateRtdtProperty(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.
-
-
-
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()
-
isActive
public boolean isActive()
Description copied from interface:PersistenceProviderReturns true if this PersistenceProvider is active, false otherwise.- Specified by:
isActivein interfacePersistenceProvider- Specified by:
isActivein classPersistentStorage<V extends DigitalTwinBase>- Returns:
- true if this PersistenceProvider is active, false otherwise.
-
store
public void store(V instance)
- Specified by:
storein classPersistentStorage<V extends DigitalTwinBase>
-
load
public V load(java.lang.String id)
- Specified by:
loadin classPersistentStorage<V extends DigitalTwinBase>
-
getPersistencePolicy
public byte getPersistencePolicy()
- Specified by:
getPersistencePolicyin classPersistentStorage<V extends DigitalTwinBase>
-
initialize
public void initialize(java.util.HashMap<java.lang.String,java.lang.String> conf)
- Specified by:
initializein classPersistentStorage<V extends DigitalTwinBase>
-
initializeDynamoDbConnection
public void initializeDynamoDbConnection()
-
getProviderType
public PersistenceProviderType getProviderType()
Description copied from interface:PersistenceProviderRetrieves this persistence providers type. Currently supported provider types: AzureDigitalTwins.- Specified by:
getProviderTypein interfacePersistenceProvider- Returns:
- the persistence provider type.
-
getInstanceIdsAsync
public java.util.concurrent.CompletableFuture<java.util.List<java.lang.String>> getInstanceIdsAsync(java.lang.String modelName)
Description copied from interface:PersistenceProviderRetrieves a future that when complete will return the instance IDs stored in a container, or an empty list if no instances exist.- Specified by:
getInstanceIdsAsyncin interfacePersistenceProvider- 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:PersistenceProviderRetrieves the instance IDs stored in a container, or an empty list if no instances exist.- Specified by:
getInstanceIdsin interfacePersistenceProvider- 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:PersistenceProviderRetrieves a future that when complete will return an instance or null if it doesn't exist.- Specified by:
getInstanceAsyncin interfacePersistenceProvider- 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:PersistenceProviderRetrieves an instance or null if it doesn't exist.- Specified by:
getInstancein interfacePersistenceProvider- Parameters:
modelName- the container nameinstanceId- 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:PersistenceProviderRetrieves a future that will return a map of property names to property, or an empty map.- Specified by:
getPropertyMapAsyncin interfacePersistenceProvider- 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:PersistenceProviderRetrieves a map of property names to property types, or an empty map.- Specified by:
getPropertyMapin interfacePersistenceProvider- 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:PersistenceProviderRetrieves 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:
updatePropertyAsyncin interfacePersistenceProvider- 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:PersistenceProviderUpdates a property for the provided instance id in the provided container specified by the property name and property value.- Specified by:
updatePropertyin interfacePersistenceProvider- 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:PersistenceProviderRetrieves a future that will return a property or null if the property does not exist.- Specified by:
getPropertyAsyncin interfacePersistenceProvider- 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:PersistenceProviderRetrieves a property or null if the property does not exist.- Specified by:
getPropertyin interfacePersistenceProvider- Type Parameters:
T- the type of the property to return.- Parameters:
modelName- the container name.instanceId- the instance id.propertyName- the property nameaClass- 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:PersistenceProviderRetrieves 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:
updateRtdtPropertyAsyncin interfacePersistenceProvider- 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:PersistenceProviderUpdates a RTDT property for the provided instance id specified by the property name and property value.- Specified by:
updateRtdtPropertyin interfacePersistenceProvider- 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:PersistenceProviderRetrieves a future that will return a property value for a RTDT instance or null if the property doesn't exist.- Specified by:
getRtdtPropertyAsyncin interfacePersistenceProvider- 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:PersistenceProviderRetrieves a property for a RTDT instance or null if the property does not exist.- Specified by:
getRtdtPropertyin interfacePersistenceProvider- 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:
closein interfacejava.lang.AutoCloseable- Throws:
java.lang.Exception
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
onSignal
public void onSignal(com.scaleout.client.ighosting.InvocationGridSignal invocationGridSignal, java.lang.Object o)- Specified by:
onSignalin interfacecom.scaleout.client.ighosting.InvocationGridSignalHandler
-
-