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