Class CosmosDbPersistenceProvider<V extends DigitalTwinBase>
- java.lang.Object
-
- com.scaleoutsoftware.digitaltwin.persistentstorage.PersistentStorage<V>
-
- com.scaleoutsoftware.digitaltwin.persistentstorage.CosmosDbPersistenceProvider<V>
-
- Type Parameters:
V
- the type of the digital twin
- All Implemented Interfaces:
com.scaleout.client.ighosting.InvocationGridSignalHandler
,PersistenceProvider
,java.lang.AutoCloseable
public class CosmosDbPersistenceProvider<V extends DigitalTwinBase> extends PersistentStorage<V> implements PersistenceProvider, java.lang.AutoCloseable
CosmosDB persistent storage - transparently store and load digital twins to and from an Azure CosmosDB deployment.
-
-
Field Summary
-
Fields inherited from class com.scaleoutsoftware.digitaltwin.persistentstorage.PersistentStorage
_connection
-
-
Constructor Summary
Constructors Constructor Description CosmosDbPersistenceProvider(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
initializeCosmosDbConnection()
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.
-
-
-
Constructor Detail
-
CosmosDbPersistenceProvider
public CosmosDbPersistenceProvider(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:PersistenceProvider
Returns true if this PersistenceProvider is active, false otherwise.- Specified by:
isActive
in interfacePersistenceProvider
- Specified by:
isActive
in classPersistentStorage<V extends DigitalTwinBase>
- Returns:
- true if this PersistenceProvider is active, false otherwise.
-
store
public void store(V instance)
- Specified by:
store
in classPersistentStorage<V extends DigitalTwinBase>
-
load
public V load(java.lang.String id)
- Specified by:
load
in classPersistentStorage<V extends DigitalTwinBase>
-
getPersistencePolicy
public byte getPersistencePolicy()
- Specified by:
getPersistencePolicy
in classPersistentStorage<V extends DigitalTwinBase>
-
initialize
public void initialize(java.util.HashMap<java.lang.String,java.lang.String> conf)
- Specified by:
initialize
in classPersistentStorage<V extends DigitalTwinBase>
-
initializeCosmosDbConnection
public void initializeCosmosDbConnection()
-
getProviderType
public PersistenceProviderType getProviderType()
Description copied from interface:PersistenceProvider
Retrieves this persistence providers type. Currently supported provider types: AzureDigitalTwins.- Specified by:
getProviderType
in 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: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 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:PersistenceProvider
Retrieves the instance IDs stored in a container, or an empty list if no instances exist.- Specified by:
getInstanceIds
in 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:PersistenceProvider
Retrieves a future that when complete will return an instance or null if it doesn't exist.- Specified by:
getInstanceAsync
in 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:PersistenceProvider
Retrieves an instance or null if it doesn't exist.- Specified by:
getInstance
in 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:PersistenceProvider
Retrieves a future that will return a map of property names to property, or an empty map.- Specified by:
getPropertyMapAsync
in 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:PersistenceProvider
Retrieves a map of property names to property types, or an empty map.- Specified by:
getPropertyMap
in 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: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 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: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 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:PersistenceProvider
Retrieves a future that will return a property or null if the property does not exist.- Specified by:
getPropertyAsync
in 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:PersistenceProvider
Retrieves a property or null if the property does not exist.- Specified by:
getProperty
in 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: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 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:PersistenceProvider
Updates a RTDT property for the provided instance id specified by the property name and property value.- Specified by:
updateRtdtProperty
in 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: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 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:PersistenceProvider
Retrieves a property for a RTDT instance or null if the property does not exist.- Specified by:
getRtdtProperty
in 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:
close
in interfacejava.lang.AutoCloseable
- Throws:
java.lang.Exception
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
onSignal
public void onSignal(com.scaleout.client.ighosting.InvocationGridSignal invocationGridSignal, java.lang.Object o)
- Specified by:
onSignal
in interfacecom.scaleout.client.ighosting.InvocationGridSignalHandler
-
-