github.com/iqoqo/nomad@v0.11.3-0.20200911112621-d7021c74d101/client/state/interface.go (about)

     1  package state
     2  
     3  import (
     4  	"github.com/hashicorp/nomad/client/allocrunner/taskrunner/state"
     5  	dmstate "github.com/hashicorp/nomad/client/devicemanager/state"
     6  	"github.com/hashicorp/nomad/client/dynamicplugins"
     7  	driverstate "github.com/hashicorp/nomad/client/pluginmanager/drivermanager/state"
     8  	"github.com/hashicorp/nomad/nomad/structs"
     9  )
    10  
    11  // StateDB implementations store and load Nomad client state.
    12  type StateDB interface {
    13  	// Name of implementation.
    14  	Name() string
    15  
    16  	// Upgrade ensures the layout of the database is at the latest version
    17  	// or returns an error. Corrupt data will be dropped when possible.
    18  	// Errors should be considered critical and unrecoverable.
    19  	Upgrade() error
    20  
    21  	// GetAllAllocations returns all valid allocations and a map of
    22  	// allocation IDs to retrieval errors.
    23  	//
    24  	// If a single error is returned then both allocations and the map will be nil.
    25  	GetAllAllocations() ([]*structs.Allocation, map[string]error, error)
    26  
    27  	// PulAllocation stores an allocation or returns an error if it could
    28  	// not be stored.
    29  	PutAllocation(*structs.Allocation) error
    30  
    31  	// Get/Put DeploymentStatus get and put the allocation's deployment
    32  	// status. It may be nil.
    33  	GetDeploymentStatus(allocID string) (*structs.AllocDeploymentStatus, error)
    34  	PutDeploymentStatus(allocID string, ds *structs.AllocDeploymentStatus) error
    35  
    36  	// GetTaskRunnerState returns the LocalState and TaskState for a
    37  	// TaskRunner. Either state may be nil if it is not found, but if an
    38  	// error is encountered only the error will be non-nil.
    39  	GetTaskRunnerState(allocID, taskName string) (*state.LocalState, *structs.TaskState, error)
    40  
    41  	// PutTaskRunnerLocalTask stores the LocalState for a TaskRunner or
    42  	// returns an error.
    43  	PutTaskRunnerLocalState(allocID, taskName string, val *state.LocalState) error
    44  
    45  	// PutTaskState stores the TaskState for a TaskRunner or returns an
    46  	// error.
    47  	PutTaskState(allocID, taskName string, state *structs.TaskState) error
    48  
    49  	// DeleteTaskBucket deletes a task's state bucket if it exists. No
    50  	// error is returned if it does not exist.
    51  	DeleteTaskBucket(allocID, taskName string) error
    52  
    53  	// DeleteAllocationBucket deletes an allocation's state bucket if it
    54  	// exists. No error is returned if it does not exist.
    55  	DeleteAllocationBucket(allocID string) error
    56  
    57  	// GetDevicePluginState is used to retrieve the device manager's plugin
    58  	// state.
    59  	GetDevicePluginState() (*dmstate.PluginState, error)
    60  
    61  	// PutDevicePluginState is used to store the device manager's plugin
    62  	// state.
    63  	PutDevicePluginState(state *dmstate.PluginState) error
    64  
    65  	// GetDriverPluginState is used to retrieve the driver manager's plugin
    66  	// state.
    67  	GetDriverPluginState() (*driverstate.PluginState, error)
    68  
    69  	// PutDriverPluginState is used to store the driver manager's plugin
    70  	// state.
    71  	PutDriverPluginState(state *driverstate.PluginState) error
    72  
    73  	// GetDynamicPluginRegistryState is used to retrieve a dynamic plugin manager's state.
    74  	GetDynamicPluginRegistryState() (*dynamicplugins.RegistryState, error)
    75  
    76  	// PutDynamicPluginRegistryState is used to store the dynamic plugin managers's state.
    77  	PutDynamicPluginRegistryState(state *dynamicplugins.RegistryState) error
    78  
    79  	// Close the database. Unsafe for further use after calling regardless
    80  	// of return value.
    81  	Close() error
    82  }