Package me.ahoo.cosid.machine
Class InMemoryMachineStateStorage
java.lang.Object
me.ahoo.cosid.machine.InMemoryMachineStateStorage
- All Implemented Interfaces:
MachineStateStorage
In-memory implementation of
MachineStateStorage.
Stores machine states in a ConcurrentHashMap for fast access.
This implementation is not persistent and should only be used for testing
or single-instance deployments.
-
Field Summary
Fields inherited from interface me.ahoo.cosid.machine.MachineStateStorage
IN_MEMORY, LOCAL -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidClears all machine states for a given namespace.booleanexists(String namespace, InstanceId instanceId) Checks if a machine state exists for a given namespace and instance.@NonNull MachineStateget(String namespace, InstanceId instanceId) Gets the machine state for a given namespace and instance.voidremove(String namespace, InstanceId instanceId) Removes the machine state for a given namespace and instance.voidset(String namespace, int machineId, InstanceId instanceId) Sets the machine state for a given namespace and instance.intGets the number of machine states in a namespace.
-
Constructor Details
-
InMemoryMachineStateStorage
public InMemoryMachineStateStorage()
-
-
Method Details
-
get
Description copied from interface:MachineStateStorageGets the machine state for a given namespace and instance.- Specified by:
getin interfaceMachineStateStorage- Parameters:
namespace- the namespaceinstanceId- the instance ID- Returns:
- the machine state, or NOT_FOUND if not found
-
set
Description copied from interface:MachineStateStorageSets the machine state for a given namespace and instance.- Specified by:
setin interfaceMachineStateStorage- Parameters:
namespace- the namespacemachineId- the machine IDinstanceId- the instance ID
-
remove
Description copied from interface:MachineStateStorageRemoves the machine state for a given namespace and instance.- Specified by:
removein interfaceMachineStateStorage- Parameters:
namespace- the namespaceinstanceId- the instance ID
-
clear
Description copied from interface:MachineStateStorageClears all machine states for a given namespace.- Specified by:
clearin interfaceMachineStateStorage- Parameters:
namespace- the namespace
-
size
Description copied from interface:MachineStateStorageGets the number of machine states in a namespace.- Specified by:
sizein interfaceMachineStateStorage- Parameters:
namespace- the namespace- Returns:
- the number of machine states
-
exists
Description copied from interface:MachineStateStorageChecks if a machine state exists for a given namespace and instance.- Specified by:
existsin interfaceMachineStateStorage- Parameters:
namespace- the namespaceinstanceId- the instance ID- Returns:
- true if the state exists
-