X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/da13bb400f87fdd4157146e2d0b171b730fa3208..436f5c768dbc97135490b6477efd1ff0482a9dda:/services/keepstore/volume.go diff --git a/services/keepstore/volume.go b/services/keepstore/volume.go index 01bb6e28ca..778f27fcde 100644 --- a/services/keepstore/volume.go +++ b/services/keepstore/volume.go @@ -7,6 +7,18 @@ import ( "time" ) +type BlockWriter interface { + // WriteBlock reads all data from r, writes it to a backing + // store as "loc", and returns the number of bytes written. + WriteBlock(ctx context.Context, loc string, r io.Reader) error +} + +type BlockReader interface { + // ReadBlock retrieves data previously stored as "loc" and + // writes it to w. + ReadBlock(ctx context.Context, loc string, w io.Writer) error +} + // A Volume is an interface representing a Keep back-end storage unit: // for example, a single mounted disk, a RAID array, an Amazon S3 volume, // etc. @@ -55,7 +67,7 @@ type Volume interface { // CollisionError or DiskHashError (depending on whether the // data on disk matches the expected hash), or whatever error // was encountered opening/reading the stored data. - Compare(loc string, data []byte) error + Compare(ctx context.Context, loc string, data []byte) error // Put writes a block to an underlying storage device. // @@ -243,6 +255,10 @@ type VolumeManager interface { // with more free space, etc. NextWritable() Volume + // VolumeStats returns the ioStats used for tracking stats for + // the given Volume. + VolumeStats(Volume) *ioStats + // Close shuts down the volume manager cleanly. Close() } @@ -254,12 +270,16 @@ type RRVolumeManager struct { readables []Volume writables []Volume counter uint32 + iostats map[Volume]*ioStats } // MakeRRVolumeManager initializes RRVolumeManager func MakeRRVolumeManager(volumes []Volume) *RRVolumeManager { - vm := &RRVolumeManager{} + vm := &RRVolumeManager{ + iostats: make(map[Volume]*ioStats), + } for _, v := range volumes { + vm.iostats[v] = &ioStats{} vm.readables = append(vm.readables, v) if v.Writable() { vm.writables = append(vm.writables, v) @@ -287,18 +307,35 @@ func (vm *RRVolumeManager) NextWritable() Volume { return vm.writables[i%uint32(len(vm.writables))] } +// VolumeStats returns an ioStats for the given volume. +func (vm *RRVolumeManager) VolumeStats(v Volume) *ioStats { + return vm.iostats[v] +} + // Close the RRVolumeManager func (vm *RRVolumeManager) Close() { } -// VolumeStatus provides status information of the volume consisting of: -// * mount_point -// * device_num (an integer identifying the underlying storage system) -// * bytes_free -// * bytes_used +// VolumeStatus describes the current condition of a volume type VolumeStatus struct { - MountPoint string `json:"mount_point"` - DeviceNum uint64 `json:"device_num"` - BytesFree uint64 `json:"bytes_free"` - BytesUsed uint64 `json:"bytes_used"` + MountPoint string + DeviceNum uint64 + BytesFree uint64 + BytesUsed uint64 +} + +// ioStats tracks I/O statistics for a volume or server +type ioStats struct { + Errors uint64 + Ops uint64 + CompareOps uint64 + GetOps uint64 + PutOps uint64 + TouchOps uint64 + InBytes uint64 + OutBytes uint64 +} + +type InternalStatser interface { + InternalStats() interface{} }