Documentation ¶
Overview ¶
Package kinetic is golang kinetic client implementation.
For details about kinetic protocol, please refer to https://github.com/Kinetic/kinetic-protocol
Index ¶
- func SetLogLevel(l LogLevel)
- func SetLogOutput(out io.Writer)
- func UpdateFirmware(conn *BlockConnection, file string) error
- type ACL
- type ACLAlgorithm
- type ACLPermission
- type ACLScope
- type Algorithm
- type BatchEndCallback
- type BatchStatus
- type BlockConnection
- func (conn *BlockConnection) BatchAbort() (Status, error)
- func (conn *BlockConnection) BatchDelete(entry *Record) error
- func (conn *BlockConnection) BatchEnd() (*BatchStatus, Status, error)
- func (conn *BlockConnection) BatchPut(entry *Record) error
- func (conn *BlockConnection) BatchStart() (Status, error)
- func (conn *BlockConnection) Close()
- func (conn *BlockConnection) Delete(entry *Record) (Status, error)
- func (conn *BlockConnection) Flush() (Status, error)
- func (conn *BlockConnection) Get(key []byte) (*Record, Status, error)
- func (conn *BlockConnection) GetKeyRange(r *KeyRange) ([][]byte, Status, error)
- func (conn *BlockConnection) GetLog(logs []LogType) (*Log, Status, error)
- func (conn *BlockConnection) GetNext(key []byte) (*Record, Status, error)
- func (conn *BlockConnection) GetPrevious(key []byte) (*Record, Status, error)
- func (conn *BlockConnection) GetVersion(key []byte) ([]byte, Status, error)
- func (conn *BlockConnection) InstantErase(pin []byte) (Status, error)
- func (conn *BlockConnection) LockDevice(pin []byte) (Status, error)
- func (conn *BlockConnection) MediaOptimize(op *MediaOperation, pri Priority) (Status, error)
- func (conn *BlockConnection) MediaScan(op *MediaOperation, pri Priority) (Status, error)
- func (conn *BlockConnection) NoOp() (Status, error)
- func (conn *BlockConnection) P2PPush(request *P2PPushRequest) (*P2PPushStatus, Status, error)
- func (conn *BlockConnection) Put(entry *Record) (Status, error)
- func (conn *BlockConnection) SecureErase(pin []byte) (Status, error)
- func (conn *BlockConnection) SetACL(acls []ACL) (Status, error)
- func (conn *BlockConnection) SetClientClusterVersion(version int64)
- func (conn *BlockConnection) SetClusterVersion(version int64) (Status, error)
- func (conn *BlockConnection) SetErasePin(currentPin []byte, newPin []byte) (Status, error)
- func (conn *BlockConnection) SetLockPin(currentPin []byte, newPin []byte) (Status, error)
- func (conn *BlockConnection) SetPowerLevel(p PowerLevel) (Status, error)
- func (conn *BlockConnection) UnlockDevice(pin []byte) (Status, error)
- func (conn *BlockConnection) UpdateFirmware(code []byte) (Status, error)
- type Callback
- type CapacityLog
- type ClientOptions
- type ConfigurationInterface
- type ConfigurationLog
- type DeviceLog
- type GenericCallback
- type GetCallback
- type GetKeyRangeCallback
- type GetLogCallback
- type GetVersionCallback
- type KeyRange
- type LimitsLog
- type Log
- type LogLevel
- type LogType
- type MediaOperation
- type MessageType
- type NonBlockConnection
- func (conn *NonBlockConnection) BatchAbort(h *ResponseHandler) error
- func (conn *NonBlockConnection) BatchDelete(entry *Record) error
- func (conn *NonBlockConnection) BatchEnd(h *ResponseHandler) error
- func (conn *NonBlockConnection) BatchPut(entry *Record) error
- func (conn *NonBlockConnection) BatchStart(h *ResponseHandler) error
- func (conn *NonBlockConnection) Close()
- func (conn *NonBlockConnection) Delete(entry *Record, h *ResponseHandler) error
- func (conn *NonBlockConnection) Flush(h *ResponseHandler) error
- func (conn *NonBlockConnection) Get(key []byte, h *ResponseHandler) error
- func (conn *NonBlockConnection) GetKeyRange(r *KeyRange, h *ResponseHandler) error
- func (conn *NonBlockConnection) GetLog(logs []LogType, h *ResponseHandler) error
- func (conn *NonBlockConnection) GetNext(key []byte, h *ResponseHandler) error
- func (conn *NonBlockConnection) GetPrevious(key []byte, h *ResponseHandler) error
- func (conn *NonBlockConnection) GetVersion(key []byte, h *ResponseHandler) error
- func (conn *NonBlockConnection) InstantErase(pin []byte, h *ResponseHandler) error
- func (conn *NonBlockConnection) Listen(h *ResponseHandler) error
- func (conn *NonBlockConnection) LockDevice(pin []byte, h *ResponseHandler) error
- func (conn *NonBlockConnection) MediaOptimize(op *MediaOperation, pri Priority, h *ResponseHandler) error
- func (conn *NonBlockConnection) MediaScan(op *MediaOperation, pri Priority, h *ResponseHandler) error
- func (conn *NonBlockConnection) NoOp(h *ResponseHandler) error
- func (conn *NonBlockConnection) P2PPush(request *P2PPushRequest, h *ResponseHandler) error
- func (conn *NonBlockConnection) Put(entry *Record, h *ResponseHandler) error
- func (conn *NonBlockConnection) SecureErase(pin []byte, h *ResponseHandler) error
- func (conn *NonBlockConnection) SetACL(acls []ACL, h *ResponseHandler) error
- func (conn *NonBlockConnection) SetClientClusterVersion(version int64)
- func (conn *NonBlockConnection) SetClusterVersion(version int64, h *ResponseHandler) error
- func (conn *NonBlockConnection) SetErasePin(currentPin []byte, newPin []byte, h *ResponseHandler) error
- func (conn *NonBlockConnection) SetLockPin(currentPin []byte, newPin []byte, h *ResponseHandler) error
- func (conn *NonBlockConnection) SetPowerLevel(p PowerLevel, h *ResponseHandler) error
- func (conn *NonBlockConnection) UnlockDevice(pin []byte, h *ResponseHandler) error
- func (conn *NonBlockConnection) UpdateFirmware(code []byte, h *ResponseHandler) error
- type P2PPushCallback
- type P2PPushOperation
- type P2PPushRequest
- type P2PPushStatus
- type PowerLevel
- type Priority
- type Record
- type ResponseHandler
- type StatisticsLog
- type Status
- type StatusCode
- type Synchronization
- type TemperatureLog
- type UtilizationLog
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func UpdateFirmware ¶
func UpdateFirmware(conn *BlockConnection, file string) error
UpdateFirmware is the utility function to update drive firmware. conn is BlockConnection to drive, and file is the full path to the firmware file.
Example ¶
// Set the log leverl to debug SetLogLevel(LogLevelDebug) // Client options var option = ClientOptions{ Host: "127.0.0.1", Port: 8123, User: 1, Hmac: []byte("asdfasdf")} conn, err := NewBlockConnection(option) if err != nil { panic(err) } defer conn.Close() file := "not/exist/firmare/unknown-version.slod" err = UpdateFirmware(conn, file) if err != nil { fmt.Println("Firmware update fail: ", file, err) }
Output:
Types ¶
type ACL ¶
type ACL struct { Identity int64 Key []byte Algo ACLAlgorithm Scopes []ACLScope MaxPriority Priority }
ACL structure for SetACL call. Defines permission for identity.
type ACLAlgorithm ¶
type ACLAlgorithm int32
ACLAlgorithm defines the HMAC algorithm.
const (
ACLAlgorithmHMACSHA1 ACLAlgorithm = iota
)
ACLAlgorithm values.
func (ACLAlgorithm) String ¶
func (p ACLAlgorithm) String() string
type ACLPermission ¶
type ACLPermission int32
ACLPermission defines what operations a user identity can perform.
const ( ACLPermissionRead ACLPermission = iota // Can read key/values ACLPermissionWrite ACLPermission = iota // Can write key/values ACLPermissionDelete ACLPermission = iota // Can delete key/values ACLPermissionRange ACLPermission = iota // Can do a range ACLPermissionSetup ACLPermission = iota // Can setup a device ACLPermissionP2POP ACLPermission = iota // Can do a peer to peer operation ACLPermissionGetLog ACLPermission = iota // Can get log ACLPermissionSecurity ACLPermission = iota // Can set up the security of device ACLPermissionPowerManagement ACLPermission = iota // Can set power level )
ACLPermission for various type of operation.
func (ACLPermission) String ¶
func (p ACLPermission) String() string
type ACLScope ¶
type ACLScope struct { Offset int64 Value []byte Permissions []ACLPermission TLSRequired bool }
ACLScope defines scope of ACL.
type Algorithm ¶
type Algorithm int32
Algorithm defines the which algorithm used to protect data.
type BatchEndCallback ¶
type BatchEndCallback struct { GenericCallback BatchStatus BatchStatus }
BatchEndCallback is the Callback for Command_END_BATCH
type BatchStatus ¶
type BatchStatus struct { DoneSequence []int64 // All sequence Ids of those commands (PUT/DELETE) performed successfully in the batch FailedSequence int64 // Non 0 value means the first failed operation sequence in the batch, 0 means no failure }
BatchStatus indicates status of all operations in a batch commit.
type BlockConnection ¶
type BlockConnection struct {
// contains filtered or unexported fields
}
BlockConnection sends kinetic message to devices and wait for response message from device. For all API functions, it will only return after response from kinetic device handled. If no data required from kinetic device, API function will return Status and error. If any data required from kinetic device, the data will be one of the return values.
Example (PutGetDelete) ¶
// Set the log leverl to debug SetLogLevel(LogLevelDebug) // Client options var option = ClientOptions{ Host: "127.0.0.1", Port: 8123, User: 1, Hmac: []byte("asdfasdf")} conn, err := NewBlockConnection(option) if err != nil { panic(err) } defer conn.Close() // PUT pentry := Record{ Key: []byte("Test Object"), Value: []byte("Test Object Data"), Sync: SyncWriteThrough, Algo: AlgorithmSHA1, Tag: []byte(""), Force: true, } status, err := conn.Put(&pentry) if err != nil || status.Code != OK { fmt.Println("Blocking Put Failure") } // GET back the object gentry, status, err := conn.Get(pentry.Key) if err != nil || status.Code != OK { fmt.Println("Blocking Get Failure") } // Verify the object Key and Value if !bytes.Equal(pentry.Key, gentry.Key) { fmt.Printf("Key Mismatch: [%s] vs [%s]\n", pentry.Key, gentry.Key) } if !bytes.Equal(pentry.Value, gentry.Value) { fmt.Printf("Value Mismatch: [%s] vs [%s]\n", pentry.Value, gentry.Value) } // DELETE the object dentry := Record{ Key: pentry.Key, Sync: pentry.Sync, Force: true, } status, err = conn.Delete(&dentry) if err != nil || status.Code != OK { fmt.Println("Blocking Delete Failure") }
Output:
Example (Ssl) ¶
// Set the log leverl to debug SetLogLevel(LogLevelDebug) // Client options, use SSL connection var option = ClientOptions{ Host: "127.0.0.1", Port: 8443, User: 1, Hmac: []byte("asdfasdf"), UseSSL: true, } conn, err := NewBlockConnection(option) if err != nil { panic(err) } defer conn.Close()
Output:
func NewBlockConnection ¶
func NewBlockConnection(op ClientOptions) (*BlockConnection, error)
NewBlockConnection is helper function to establish block connection to device.
func (*BlockConnection) BatchAbort ¶
func (conn *BlockConnection) BatchAbort() (Status, error)
BatchAbort aborts jobs in current batch operation.
func (*BlockConnection) BatchDelete ¶
func (conn *BlockConnection) BatchDelete(entry *Record) error
BatchDelete delete object from kinetic drive, as a batch job. Batch PUT / DELETE won't expect acknowledgement from kinetic device. Status for batch PUT / DELETE will only available in response message for BatchEnd.
func (*BlockConnection) BatchEnd ¶
func (conn *BlockConnection) BatchEnd() (*BatchStatus, Status, error)
BatchEnd commits all batch jobs. Response from kinetic device will indicate succeeded jobs sequence number, or the first failed job sequence number if there is a failure.
func (*BlockConnection) BatchPut ¶
func (conn *BlockConnection) BatchPut(entry *Record) error
BatchPut puts objects to kinetic drive, as a batch job. Batch PUT / DELETE won't expect acknowledgement from kinetic device. Status for batch PUT / DELETE will only available in response message for BatchEnd.
func (*BlockConnection) BatchStart ¶
func (conn *BlockConnection) BatchStart() (Status, error)
BatchStart starts new batch operation, all following batch PUT / DELETE share same batch ID until BatchEnd or BatchAbort is called.
func (*BlockConnection) Close ¶
func (conn *BlockConnection) Close()
Close the connection to kientic device
func (*BlockConnection) Delete ¶
func (conn *BlockConnection) Delete(entry *Record) (Status, error)
Delete deletes object from kinetic device. On success, Status.Code = OK
func (*BlockConnection) Flush ¶
func (conn *BlockConnection) Flush() (Status, error)
Flush requests kinetic device to write all cached data to persistent media. On success, Status.Code = OK
func (*BlockConnection) Get ¶
func (conn *BlockConnection) Get(key []byte) (*Record, Status, error)
Get gets the object from kinetic drive with key. On success, object Record will return and Status.Code = OK
func (*BlockConnection) GetKeyRange ¶
func (conn *BlockConnection) GetKeyRange(r *KeyRange) ([][]byte, Status, error)
GetKeyRange gets list of objects' keys, which meet the criteria defined by KeyRange. On success, list of objects's keys returned, and Status.Code = OK
func (*BlockConnection) GetLog ¶
func (conn *BlockConnection) GetLog(logs []LogType) (*Log, Status, error)
GetLog gets kinetic device Log information. Can request single LogType or multiple LogType. On success, device Log information will return, and Status.Code = OK
func (*BlockConnection) GetNext ¶
func (conn *BlockConnection) GetNext(key []byte) (*Record, Status, error)
GetNext gets the next object with key after the passed in key. On success, object Record will return and Status.Code = OK
func (*BlockConnection) GetPrevious ¶
func (conn *BlockConnection) GetPrevious(key []byte) (*Record, Status, error)
GetPrevious gets the previous object with key before the passed in key. On success, object Record will return and Status.Code = OK
func (*BlockConnection) GetVersion ¶
func (conn *BlockConnection) GetVersion(key []byte) ([]byte, Status, error)
GetVersion gets object DB version information. On success, version information will return and Status.Code = OK
func (*BlockConnection) InstantErase ¶
func (conn *BlockConnection) InstantErase(pin []byte) (Status, error)
InstantErase request kinetic device to perform instant erase. SSL connection is requested to perform this operation, and the erase pin is needed. On success, Status.Code = OK
func (*BlockConnection) LockDevice ¶
func (conn *BlockConnection) LockDevice(pin []byte) (Status, error)
LockDevice locks the kinetic device. SSL connection is requested to perform this operation, and the lock pin is needed. On success, Status.Code = OK
func (*BlockConnection) MediaOptimize ¶
func (conn *BlockConnection) MediaOptimize(op *MediaOperation, pri Priority) (Status, error)
MediaOptimize performs optimizations of the media. Things like defragmentation, compaction, garbage collection, compression could be things accomplished using the media optimize command.
func (*BlockConnection) MediaScan ¶
func (conn *BlockConnection) MediaScan(op *MediaOperation, pri Priority) (Status, error)
MediaScan is to check that the user data is readable, and if the end to end integrity is known to the device, if the end to end integrity field is correct.
func (*BlockConnection) NoOp ¶
func (conn *BlockConnection) NoOp() (Status, error)
NoOp does nothing but wait for drive to return response. On success, Status.Code will be OK
func (*BlockConnection) P2PPush ¶
func (conn *BlockConnection) P2PPush(request *P2PPushRequest) (*P2PPushStatus, Status, error)
P2PPush performs peer to peer push operation
func (*BlockConnection) Put ¶
func (conn *BlockConnection) Put(entry *Record) (Status, error)
Put store object to kinetic device. On success, Status.Code = OK
func (*BlockConnection) SecureErase ¶
func (conn *BlockConnection) SecureErase(pin []byte) (Status, error)
SecureErase request kinetic device to perform secure erase. SSL connection is requested to perform this operation, and the erase pin is needed. On success, Status.Code = OK
func (*BlockConnection) SetACL ¶
func (conn *BlockConnection) SetACL(acls []ACL) (Status, error)
SetACL sets Permission for particular user Identity. On success, Status.Code = OK.
Example ¶
// Set the log leverl to debug SetLogLevel(LogLevelDebug) // Client options var option = ClientOptions{ Host: "127.0.0.1", Port: 8443, // Must be SSL connection here User: 1, Hmac: []byte("asdfasdf"), UseSSL: true, // Set ACL must use SSL connection } conn, err := NewBlockConnection(option) if err != nil { panic(err) } perms := []ACLPermission{ ACLPermissionGetLog, } scope := []ACLScope{ ACLScope{ Permissions: perms, }, } acls := []ACL{ ACL{ Identity: 100, Key: []byte("asdfasdf"), Algo: ACLAlgorithmHMACSHA1, Scopes: scope, }, } status, err := conn.SetACL(acls) if err != nil || status.Code != OK { fmt.Println("SetACL failure: ", err, status) } // Close the SET ACL connection conn.Close() // Next, do the verifiation on the SET ACL // Client options option = ClientOptions{ Host: "127.0.0.1", Port: 8123, User: 100, Hmac: []byte("asdfasdf")} conn, err = NewBlockConnection(option) if err != nil { panic(err) } logs := []LogType{ LogTypeUtilizations, LogTypeTemperatures, LogTypeCapacities, LogTypeConfiguration, LogTypeStatistics, LogTypeMessages, LogTypeLimits, } _, status, err = conn.GetLog(logs) if err != nil || status.Code != OK { fmt.Println("GetLog Failure: ", err, status) } _, status, err = conn.Get([]byte("object000")) if err != nil { fmt.Println("Get Failure: ", err) } if status.Code != RemoteNotAuthorized { fmt.Println("SET ACL not effective, ", status) } // Close the verify connection conn.Close()
Output:
func (*BlockConnection) SetClientClusterVersion ¶
func (conn *BlockConnection) SetClientClusterVersion(version int64)
SetClientClusterVersion sets the cluster version for all following message to kinetic device.
func (*BlockConnection) SetClusterVersion ¶
func (conn *BlockConnection) SetClusterVersion(version int64) (Status, error)
SetClusterVersion sets the cluster version on kinetic drive. On success, Status.Code = OK.
func (*BlockConnection) SetErasePin ¶
func (conn *BlockConnection) SetErasePin(currentPin []byte, newPin []byte) (Status, error)
SetErasePin changes kinetic device erase pin. Both current pin and new pin needed. SSL connection is required to perform this operation. On success, Status.Code = OK.
func (*BlockConnection) SetLockPin ¶
func (conn *BlockConnection) SetLockPin(currentPin []byte, newPin []byte) (Status, error)
SetLockPin changes kinetic device lock pin. Both current pin and new pin needed. SSL connection is required to perform this operation. On success, Status.Code = OK.
func (*BlockConnection) SetPowerLevel ¶
func (conn *BlockConnection) SetPowerLevel(p PowerLevel) (Status, error)
SetPowerLevel sets device power level
func (*BlockConnection) UnlockDevice ¶
func (conn *BlockConnection) UnlockDevice(pin []byte) (Status, error)
UnlockDevice unlocks the kinetic device. SSL connection is requested to perform this operation, and the lock pin is needed. On success, Status.Code = OK
func (*BlockConnection) UpdateFirmware ¶
func (conn *BlockConnection) UpdateFirmware(code []byte) (Status, error)
UpdateFirmware requests to update kientic device firmware. Status.OK will return if firmware data received by kinetic device. Then drive will reboot and perform the firmware update process.
type Callback ¶
type Callback interface { Success(resp *kproto.Command, value []byte) Failure(resp *kproto.Command, status Status) Status() Status }
Callback is the interface define actions for MessageType. Success is called when XXXXX_RESPONSE message received from drive without problem. Failure is called when XXXXX_RESPONSE message status code is not OK, or any other kind of failure. Done return true if either Success or Failure is called to indicate XXXXX_RESPONSE received and processed. Status return the MessateType operation status.
type CapacityLog ¶
type CapacityLog struct { CapacityInBytes uint64 // total capacity of hard disk, in bytes PortionFull float32 // remaining capacity of hard disk }
CapacityLog for kinetic device capacity information.
type ClientOptions ¶
type ClientOptions struct { Host string // Kinetic device IP address Port int // Network port to connect, if UseSSL is true, this port should be the TlsPort User int64 // User Id Hmac []byte UseSSL bool // Use SSL connection, or plain connection Timeout int64 // Network timeout in millisecond RequestTimeout int64 // Operation request timeout in millisecond }
ClientOptions specify connection options to kinetic device.
type ConfigurationInterface ¶
type ConfigurationInterface struct { Name string // network device name MAC []byte // network device mac address Ipv4Addr []byte // network device ipv4 address Ipv6Addr []byte // network device ipv6 address }
ConfigurationInterface for kinetic device network interfaces information.
type ConfigurationLog ¶
type ConfigurationLog struct { Vendor string // Vendor name Model string // Device model SerialNumber []byte // Device serial number WorldWideName []byte // Device world wide name Version string // Device version CompilationDate string // Device service code compilation date SourceHash string // Device service source code repository hash value ProtocolVersion string // Device supported protocol version ProtocolCompilationDate string // Device supported protocol compilation date ProtocolSourceHash string // Device supported protocol source code repository hash value Interface []ConfigurationInterface // Device interfaces as list Port int32 // Service port TLSPort int32 // TLS service port CurrentPowerLevel PowerLevel // Device current power level, valid value only POWER_HIBERNATE or POWER_OPERATIONAL }
ConfigurationLog for kinetic device configuration information.
type DeviceLog ¶
type DeviceLog struct {
Name []byte
}
DeviceLog is to ask the device to send back the log of a certain name in the value field. The limit of each log is 1m byte.
Proprietary names should be prefaced by the vendor name so that name collisions do not happen in the future. An example could be names that start with “com.WD” would be for Western Digital devices.
If the name is not found, the get log returns NOT_FOUND.
There can be only one Device in the list of logs that can be retrieved.!
type GenericCallback ¶
type GenericCallback struct {
// contains filtered or unexported fields
}
GenericCallback can be used for all MessageType which doesn't require data from Kinetic drive. And for MessageType that require data from drive, a new struct need to be defined GenericCallback
func (*GenericCallback) Failure ¶
func (c *GenericCallback) Failure(resp *kproto.Command, status Status)
Failure is called ResponseHandler when response message received from kinetic device with status code other than OK.
func (*GenericCallback) Status ¶
func (c *GenericCallback) Status() Status
Status returns the status after ResponseHandler processed response message from kinetic device.
type GetCallback ¶
type GetCallback struct { GenericCallback Entry Record // Entity information }
GetCallback is the Callback for Command_GET Message
type GetKeyRangeCallback ¶
type GetKeyRangeCallback struct { GenericCallback Keys [][]byte // List of objects' keys within range, get from device }
GetKeyRangeCallback is the Callback for Command_GETKEYRANGE Message
type GetLogCallback ¶
type GetLogCallback struct { GenericCallback Logs Log // Device log information }
GetLogCallback is the Callback for Command_GETLOG Message
type GetVersionCallback ¶
type GetVersionCallback struct { GenericCallback Version []byte // Version of the object on device }
GetVersionCallback is the Callback for Command_GETVERSION Message
type KeyRange ¶
type KeyRange struct { StartKey []byte EndKey []byte StartKeyInclusive bool EndKeyInclusive bool Reverse bool Max int32 }
KeyRange structure defines the range for GetRange operation.
type LimitsLog ¶
type LimitsLog struct { MaxKeySize uint32 // max key size MaxValueSize uint32 // max value size MaxVersionSize uint32 // max version size MaxTagSize uint32 // max tag size MaxConnections uint32 // max connection MaxOutstandingReadRequests uint32 // max out standing read request MaxOutstandingWriteRequests uint32 // max out standing write request MaxMessageSize uint32 // max message size MaxKeyRangeCount uint32 // max key range count MaxIdentityCount uint32 // max identity count MaxPinSize uint32 // MaxOperationCountPerBatch uint32 // MaxBatchCountPerDevice uint32 // }
LimitsLog defines max values.
type Log ¶
type Log struct { Utilizations []UtilizationLog // List of utilization information of the drive Temperatures []TemperatureLog // List of tempeture inforamtion of the drive Capacity *CapacityLog // Capacity information of the drive Configuration *ConfigurationLog // Configuration information of the drive Statistics []StatisticsLog // List of statistic information from the drive Messages []byte // Kinetic log messages from the drive Limits *LimitsLog // Limits information from the drive Device *DeviceLog }
Log is the top level structure that groups all the log information
type LogLevel ¶
LogLevel defines the logging level for kinetic Go library. Default is LogLevelInfo.
const ( // LogLevelPanic level. Panic. LogLevelPanic LogLevel = LogLevel(logrus.PanicLevel) // LogLevelFatal level. Logs and then calls `os.Exit(1)`. It will exit even if the // logging level is set to Panic. LogLevelFatal LogLevel = LogLevel(logrus.FatalLevel) // LogLevelError level. Logs. Used for errors that should definitely be noted. // Commonly used for hooks to send errors to an error tracking service. LogLevelError LogLevel = LogLevel(logrus.ErrorLevel) // LogLevelWarn level. Non-critical entries that deserve eyes. LogLevelWarn LogLevel = LogLevel(logrus.WarnLevel) // LogLevelInfo level. General operational entries about what's going on inside the // application. LogLevelInfo LogLevel = LogLevel(logrus.InfoLevel) // LogLevelDebug level. Usually only enabled when debugging. Very verbose logging. LogLevelDebug LogLevel = LogLevel(logrus.DebugLevel) )
type LogType ¶
type LogType int32
LogType defines what type of information to retrieve by GetLog.
type MediaOperation ¶
type MediaOperation struct { StartKey []byte EndKey []byte StartKeyInclusive bool EndKeyInclusive bool }
MediaOperation structure defines media operation information for MediaScan and MediaOptimize.
type MessageType ¶
type MessageType int32
MessageType defines the top level kinetic command message type.
const ( MessageGet MessageType = iota MessageGetResponse MessageType = iota MessagePut MessageType = iota MessagePutResponse MessageType = iota MessageDelete MessageType = iota MessageDeleteResponse MessageType = iota MessageGetNext MessageType = iota MessageGetNextResponse MessageType = iota MessageGetPrevious MessageType = iota MessageGetPreviousResponse MessageType = iota MessageGetKeyRange MessageType = iota MessageGetKeyRangeResponse MessageType = iota MessageGetVersion MessageType = iota MessageGetVersionResponse MessageType = iota MessageSetup MessageType = iota MessageSetupResponse MessageType = iota MessageGetLog MessageType = iota MessageGetLogResponse MessageType = iota MessageSecurity MessageType = iota MessageSecurityResponse MessageType = iota MessagePeer2PeerPush MessageType = iota MessagePeer2PeerPushResponse MessageType = iota MessageNoop MessageType = iota MessageNoopResponse MessageType = iota MessageFlushAllData MessageType = iota MessageFlushAllDataResponse MessageType = iota MessagePinOp MessageType = iota MessagePinOpResponse MessageType = iota MessageMediaScan MessageType = iota MessageMediaScanResponse MessageType = iota MessageMediaOptimize MessageType = iota MessageMediaOptimizeResponse MessageType = iota MessageStartBatch MessageType = iota MessageStartBatchResponse MessageType = iota MessageEndBatch MessageType = iota MessageEndBatchResponse MessageType = iota MessageAbortBatch MessageType = iota MessageAbortBatchResponse MessageType = iota MessageSetPowerLevel MessageType = iota MessageSetPowerLevelResponse MessageType = iota )
MessageType for each message exchanged between kinetic device and client
func (MessageType) String ¶
func (m MessageType) String() string
type NonBlockConnection ¶
type NonBlockConnection struct {
// contains filtered or unexported fields
}
NonBlockConnection send kinetic message to devices and doesn't wait for response message from device.
Example (MultiplePut) ¶
// Set the log leverl to debug SetLogLevel(LogLevelDebug) // Client options var option = ClientOptions{ Host: "127.0.0.1", Port: 8123, User: 1, Hmac: []byte("asdfasdf")} conn, err := NewNonBlockConnection(option) if err != nil { panic(err) } defer conn.Close() done := make(chan bool) prefix := []byte("TestObject") // PUT // 1st round: main routin PUT object, start new go routine to wait for operation done for id := 1; id <= 100; id++ { key := []byte(fmt.Sprintf("%s-%05d", prefix, id)) v := bytes.Repeat(key, id) if len(v) > 1024*1024 { v = v[:1024*1024] } pentry := Record{ Key: key, Value: v, Sync: SyncWriteThrough, Algo: AlgorithmSHA1, Tag: []byte(""), Force: true, } pcallback := &GenericCallback{} ph := NewResponseHandler(pcallback) err = conn.Put(&pentry, ph) if err != nil { fmt.Println("NonBlocking Put Failure") } go func() { conn.Listen(ph) done <- true }() } // PUT // 2nd round, start new go routin for each PUT object and wait for operation done for id := 101; id <= 200; id++ { go func(id int, done chan bool) { key := []byte(fmt.Sprintf("%s-%05d", prefix, id)) v := bytes.Repeat(key, id) if len(v) > 1024*1024 { v = v[:1024*1024] } pentry := Record{ Key: key, Value: v, Sync: SyncWriteThrough, Algo: AlgorithmSHA1, Tag: []byte(""), Force: true, } pcallback := &GenericCallback{} ph := NewResponseHandler(pcallback) err = conn.Put(&pentry, ph) if err != nil { fmt.Println("NonBlocking Put Failure") } conn.Listen(ph) done <- true }(id, done) } // Total 200 go routine started, wait for all to finish for id := 1; id <= 200; id++ { <-done }
Output:
Example (PutGetDelete) ¶
// Set the log leverl to debug SetLogLevel(LogLevelDebug) // Client options var option = ClientOptions{ Host: "127.0.0.1", Port: 8123, User: 1, Hmac: []byte("asdfasdf")} conn, err := NewNonBlockConnection(option) if err != nil { panic(err) } defer conn.Close() // PUT pentry := Record{ Key: []byte("Test Object"), Value: []byte("Test Object Data"), Sync: SyncWriteThrough, Algo: AlgorithmSHA1, Tag: []byte(""), Force: true, } // Each Nonblock operation require specific Callback and ResponseHandler // For operation doesn't require data from Kinetic drive, GenericCallback will enough. pcallback := &GenericCallback{} ph := NewResponseHandler(pcallback) err = conn.Put(&pentry, ph) if err != nil { fmt.Println("NonBlocking Put Failure") } conn.Listen(ph) // GET back the object, GET operation need to process data from drive, so use GetCallBack gcallback := &GetCallback{} gh := NewResponseHandler(gcallback) err = conn.Get(pentry.Key, gh) if err != nil { fmt.Println("NonBlocking Get Failure") } conn.Listen(gh) gentry := gcallback.Entry // Verify the object Key and Value if !bytes.Equal(pentry.Key, gentry.Key) { fmt.Printf("Key Mismatch: [%s] vs [%s]\n", pentry.Key, gentry.Key) } if !bytes.Equal(pentry.Value, gentry.Value) { fmt.Printf("Value Mismatch: [%s] vs [%s]\n", pentry.Value, gentry.Value) } // DELETE the object, DELETE doesn't require data from drive, use GenericCallback dcallback := &GenericCallback{} dh := NewResponseHandler(dcallback) dentry := Record{ Key: pentry.Key, Sync: pentry.Sync, Force: true, } err = conn.Delete(&dentry, dh) if err != nil { fmt.Println("NonBlocking Delete Failure") } conn.Listen(dh)
Output:
func NewNonBlockConnection ¶
func NewNonBlockConnection(op ClientOptions) (*NonBlockConnection, error)
NewNonBlockConnection is helper function to establish non-block connection to device.
func (*NonBlockConnection) BatchAbort ¶
func (conn *NonBlockConnection) BatchAbort(h *ResponseHandler) error
BatchAbort aborts jobs in current batch operation.
func (*NonBlockConnection) BatchDelete ¶
func (conn *NonBlockConnection) BatchDelete(entry *Record) error
BatchDelete delete object from kinetic drive, as a batch job. Batch PUT / DELETE won't expect acknowledgement from kinetic device. Status for batch PUT / DELETE will only available in response message for BatchEnd.
func (*NonBlockConnection) BatchEnd ¶
func (conn *NonBlockConnection) BatchEnd(h *ResponseHandler) error
BatchEnd commits all batch jobs. Response from kinetic device will indicate succeeded jobs sequence number, or the first failed job sequence number if there is a failure.
func (*NonBlockConnection) BatchPut ¶
func (conn *NonBlockConnection) BatchPut(entry *Record) error
BatchPut puts objects to kinetic drive, as a batch job. Batch PUT / DELETE won't expect acknowledgement from kinetic device. Status for batch PUT / DELETE will only available in response message for BatchEnd.
func (*NonBlockConnection) BatchStart ¶
func (conn *NonBlockConnection) BatchStart(h *ResponseHandler) error
BatchStart starts new batch operation, all following batch PUT / DELETE share same batch ID until BatchEnd or BatchAbort is called.
func (*NonBlockConnection) Close ¶
func (conn *NonBlockConnection) Close()
Close the connection to kientic device
func (*NonBlockConnection) Delete ¶
func (conn *NonBlockConnection) Delete(entry *Record, h *ResponseHandler) error
Delete deletes object from kinetic device.
func (*NonBlockConnection) Flush ¶
func (conn *NonBlockConnection) Flush(h *ResponseHandler) error
Flush requests kinetic device to write all cached data to persistent media.
func (*NonBlockConnection) Get ¶
func (conn *NonBlockConnection) Get(key []byte, h *ResponseHandler) error
Get gets the object from kinetic drive with key.
func (*NonBlockConnection) GetKeyRange ¶
func (conn *NonBlockConnection) GetKeyRange(r *KeyRange, h *ResponseHandler) error
GetKeyRange gets list of objects' keys, which meet the criteria defined by KeyRange.
func (*NonBlockConnection) GetLog ¶
func (conn *NonBlockConnection) GetLog(logs []LogType, h *ResponseHandler) error
GetLog gets kinetic device Log information. Can request single LogType or multiple LogType.
func (*NonBlockConnection) GetNext ¶
func (conn *NonBlockConnection) GetNext(key []byte, h *ResponseHandler) error
GetNext gets the next object with key after the passed in key.
func (*NonBlockConnection) GetPrevious ¶
func (conn *NonBlockConnection) GetPrevious(key []byte, h *ResponseHandler) error
GetPrevious gets the previous object with key before the passed in key.
func (*NonBlockConnection) GetVersion ¶
func (conn *NonBlockConnection) GetVersion(key []byte, h *ResponseHandler) error
GetVersion gets object DB version information.
func (*NonBlockConnection) InstantErase ¶
func (conn *NonBlockConnection) InstantErase(pin []byte, h *ResponseHandler) error
InstantErase request kinetic device to perform instant erase. SSL connection is requested to perform this operation, and the erase pin is needed.
func (*NonBlockConnection) Listen ¶
func (conn *NonBlockConnection) Listen(h *ResponseHandler) error
Listen waits and read response message from device, then call ResponseHandler in queue to process received message.
func (*NonBlockConnection) LockDevice ¶
func (conn *NonBlockConnection) LockDevice(pin []byte, h *ResponseHandler) error
LockDevice locks the kinetic device. SSL connection is requested to perform this operation, and the lock pin is needed.
func (*NonBlockConnection) MediaOptimize ¶
func (conn *NonBlockConnection) MediaOptimize(op *MediaOperation, pri Priority, h *ResponseHandler) error
MediaOptimize performs optimizations of the media. Things like defragmentation, compaction, garbage collection, compression could be things accomplished using the media optimize command.
func (*NonBlockConnection) MediaScan ¶
func (conn *NonBlockConnection) MediaScan(op *MediaOperation, pri Priority, h *ResponseHandler) error
MediaScan is to check that the user data is readable, and if the end to end integrity is known to the device, if the end to end integrity field is correct.
func (*NonBlockConnection) NoOp ¶
func (conn *NonBlockConnection) NoOp(h *ResponseHandler) error
NoOp does nothing but wait for drive to return response.
func (*NonBlockConnection) P2PPush ¶
func (conn *NonBlockConnection) P2PPush(request *P2PPushRequest, h *ResponseHandler) error
P2PPush performs peer to peer push operation
func (*NonBlockConnection) Put ¶
func (conn *NonBlockConnection) Put(entry *Record, h *ResponseHandler) error
Put store object to kinetic device.
func (*NonBlockConnection) SecureErase ¶
func (conn *NonBlockConnection) SecureErase(pin []byte, h *ResponseHandler) error
SecureErase request kinetic device to perform secure erase. SSL connection is requested to perform this operation, and the erase pin is needed.
func (*NonBlockConnection) SetACL ¶
func (conn *NonBlockConnection) SetACL(acls []ACL, h *ResponseHandler) error
SetACL sets Permission for particular user Identity.
func (*NonBlockConnection) SetClientClusterVersion ¶
func (conn *NonBlockConnection) SetClientClusterVersion(version int64)
SetClientClusterVersion sets the cluster version for all following message to kinetic device.
func (*NonBlockConnection) SetClusterVersion ¶
func (conn *NonBlockConnection) SetClusterVersion(version int64, h *ResponseHandler) error
SetClusterVersion sets the cluster version on kinetic drive.
func (*NonBlockConnection) SetErasePin ¶
func (conn *NonBlockConnection) SetErasePin(currentPin []byte, newPin []byte, h *ResponseHandler) error
SetErasePin changes kinetic device erase pin. Both current pin and new pin needed. SSL connection is required to perform this operation.
func (*NonBlockConnection) SetLockPin ¶
func (conn *NonBlockConnection) SetLockPin(currentPin []byte, newPin []byte, h *ResponseHandler) error
SetLockPin changes kinetic device lock pin. Both current pin and new pin needed. SSL connection is required to perform this operation.
func (*NonBlockConnection) SetPowerLevel ¶
func (conn *NonBlockConnection) SetPowerLevel(p PowerLevel, h *ResponseHandler) error
SetPowerLevel sets device power level
func (*NonBlockConnection) UnlockDevice ¶
func (conn *NonBlockConnection) UnlockDevice(pin []byte, h *ResponseHandler) error
UnlockDevice unlocks the kinetic device. SSL connection is requested to perform this operation, and the lock pin is needed.
func (*NonBlockConnection) UpdateFirmware ¶
func (conn *NonBlockConnection) UpdateFirmware(code []byte, h *ResponseHandler) error
UpdateFirmware requests to update kientic device firmware. Then drive will reboot and perform the firmware update process.
type P2PPushCallback ¶
type P2PPushCallback struct { GenericCallback P2PStatus P2PPushStatus }
P2PPushCallback is the Callback for Command_PEER2PEERPUSH
type P2PPushOperation ¶
type P2PPushOperation struct { Key []byte // Key for the object to push to peer kinetic device Version []byte NewKey []byte // NewKey to be used for the object on peer kinetic device, if not specify, will be same as Key Force bool Request *P2PPushRequest // Chain P2PPushRequest, which will perform on peer kinetic device }
P2PPushOperation structure for P2PPush operation.
type P2PPushRequest ¶
type P2PPushRequest struct { HostName string // Peer kinetic device IP / hostname Port int32 // Peer kinetic drvice port TLS bool Operations []P2PPushOperation // List of operations to perform on peer kinetic device }
P2PPushRequest structure for P2PPush operation
type P2PPushStatus ¶
type P2PPushStatus struct { AllOperationsSucceeded bool // Overall status for all child operations PushStatus []Status // individual operation status }
P2PPushStatus holds the status for P2PPushOperations. AllOperationsSucceeded indicates whether all operations have Status SUCCESS When false, clients should traverse operation status codes to discover error cases. When true, no further error checking should be required.
type PowerLevel ¶
type PowerLevel int32
PowerLevel defines the power level of kinetic device.
const ( PowerLevelOperational PowerLevel = iota PowerLevelHibernate PowerLevel = iota PowerLevelShutdown PowerLevel = iota PowerLevelFail PowerLevel = iota )
PowerLevel values.
func (PowerLevel) String ¶
func (p PowerLevel) String() string
type Priority ¶
type Priority int32
Priority is a simple integer that determines the priority of this request. All activity at a higher priority will execute before that of lower priority traffic. A higher number is higher priority.
type Record ¶
type Record struct { Key []byte Value []byte Version []byte Tag []byte Algo Algorithm Sync Synchronization Force bool MetaOnly bool }
Record structure defines information for an object stored on kinetic device.
type ResponseHandler ¶
type ResponseHandler struct {
// contains filtered or unexported fields
}
ResponseHandler is the handler for XXXXX_RESPONSE message from drive. For each operation, a unique ResponseHandler is required
func NewResponseHandler ¶
func NewResponseHandler(call Callback) *ResponseHandler
NewResponseHandler is helper function to build a ResponseHandler with call as the Callback. For each operation, a unique ResponseHandler is required
type StatisticsLog ¶
type StatisticsLog struct { // TODO: Would it better just use the protocol Command_MessageType? Type MessageType Count uint64 Bytes uint64 }
StatisticsLog information for each type of MessageType. Count is total number of Type message processed. Bytes is the sum of the data that is in the data portion. This does not include the command description. For P2P operations, this is the amount of data moved between drives
type Status ¶
type Status struct { Code StatusCode ErrorMsg string ExpectedClusterVersion int64 }
Status for each kinetic message. Code is the status code and ErrorMsg is the detail message
func UploadFile ¶
func UploadFile(conn *BlockConnection, file string, keys [][]byte, chunkSize int32) ([]Status, error)
UploadFile is the utility function to upload file to drive. conn is BlockConnection to drive, file is the full path to the file. The file may be stored into multiple object files depends on its size and input chunkSize. Input number of keys should equal to total number of object files on drive. If any chunk PUT fail, upload will stop and return status.
type StatusCode ¶
type StatusCode int32
StatusCode for kinetic message. Including status code get from device, or client internal error code.
const ( RemoteNotAttempted StatusCode = iota OK StatusCode = iota ClientIOError StatusCode = iota ClientShutdown StatusCode = iota ClientInternalError StatusCode = iota ClientResponseHMACError StatusCode = iota RemoteHMACError StatusCode = iota RemoteNotAuthorized StatusCode = iota RemoteClusterVersionMismatch StatusCode = iota RemoteInvalidRequest StatusCode = iota RemoteInternalError StatusCode = iota RemoteHeaderRequired StatusCode = iota RemoteNotFound StatusCode = iota RemoteVersionMismatch StatusCode = iota RemoteServiceBusy StatusCode = iota RemoteExpired StatusCode = iota RemoteDataError StatusCode = iota RemotePermDataError StatusCode = iota RemoteConnectionError StatusCode = iota RemoteNoSpace StatusCode = iota RemoteNoSuchHMACAlgorithm StatusCode = iota RemoteOtherError StatusCode = iota ProtocolErrorResponseNoAckSequence StatusCode = iota RemoteNestedOperationErrors StatusCode = iota RemoteDeviceLocked StatusCode = iota RemoteDeviceAlreadyUnlocked StatusCode = iota RemoteConnectionTerminated StatusCode = iota RemoteInvalidBatch StatusCode = iota RemoteInvalidExecute StatusCode = iota RemoteExecuteComplete StatusCode = iota RemoteHibernate StatusCode = iota RemoteShutdown StatusCode = iota )
StatusCode code value
func (StatusCode) String ¶
func (c StatusCode) String() string
String returns string value of StatusCode.
type Synchronization ¶
type Synchronization int32
Synchronization allows the puts and deletes to determine how to make data persistent.
const ( SyncWriteThrough Synchronization = iota SyncWriteBack Synchronization = iota SyncFlush Synchronization = iota )
Syncchronization types SyncWriteThrough: This request is made persistent before returning. This does not effect any other pending operations. SyncWriteBack: They can be made persistent when the device chooses, or when a subsequent FLUSH is give to the device. SyncFlush: All pending information that has not been written is pushed to the disk and the command that specifies FLUSH is written last and then returned. All WRITEBACK writes that have received ending status will be guaranteed to be written before the FLUSH operation is returned completed.
func (Synchronization) String ¶
func (sync Synchronization) String() string
type TemperatureLog ¶
type TemperatureLog struct { Name string // Name of the device Current float32 // Current Temperature Minimum float32 // Minimum Temperature for drive Maximum float32 // Maximum Tempture for drive Target float32 // Target Temperature for drive }
TemperatureLog for kinetic device tempture.
type UtilizationLog ¶
type UtilizationLog struct { Name string // Name of the device utlity Value float32 // Value of device utility }
UtilizationLog for kinetic device utilization information.