Package me.ahoo.cosid.machine
Class LocalMachineStateStorage
java.lang.Object
me.ahoo.cosid.machine.LocalMachineStateStorage
- All Implemented Interfaces:
MachineStateStorage
File-based machine state storage.
Stores machine state in local files, using base64-encoded filenames for namespace/instance encoding.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringDefault state location in user home directory.final StringThe state location path.Fields inherited from interface me.ahoo.cosid.machine.MachineStateStorage
IN_MEMORY, LOCAL -
Constructor Summary
ConstructorsConstructorDescriptionCreates storage with default location.LocalMachineStateStorage(String stateLocation) Creates storage with specified location. -
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.
-
Field Details
-
DEFAULT_STATE_LOCATION_PATH
Default state location in user home directory. -
stateLocation
The state location path.
-
-
Constructor Details
-
LocalMachineStateStorage
Creates storage with specified location.- Parameters:
stateLocation- the directory path for state files
-
LocalMachineStateStorage
public LocalMachineStateStorage()Creates storage with default location.
-
-
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
-