7121: Log all errors (except the everyday "not found") encountered during CompareAndT...
[arvados.git] / services / keepstore / volume.go
index 0f9fcffe52327435540df00692d0c587dd2981b6..d17af446a6b2674f9e86330ace0fea457d023e2a 100644 (file)
@@ -5,16 +5,26 @@
 package main
 
 import (
+       "io"
        "sync/atomic"
        "time"
 )
 
 type Volume interface {
+       // Get a block. IFF the returned error is nil, the caller must
+       // put the returned slice back into the buffer pool when it's
+       // finished with it.
        Get(loc string) ([]byte, error)
-       Put(loc string, block []byte) error
+       // Confirm Get() would return a buffer with exactly the same
+       // content as buf. If so, return nil. If not, return
+       // CollisionError or DiskHashError (depending on whether the
+       // data on disk matches the expected hash), or whatever error
+       // was encountered opening/reading the file.
+       Compare(loc string, data []byte) error
+       Put(loc string, data []byte) error
        Touch(loc string) error
        Mtime(loc string) (time.Time, error)
-       Index(prefix string) string
+       IndexTo(prefix string, writer io.Writer) error
        Delete(loc string) error
        Status() *VolumeStatus
        String() string
@@ -69,7 +79,7 @@ func (vm *RRVolumeManager) NextWritable() Volume {
                return nil
        }
        i := atomic.AddUint32(&vm.counter, 1)
-       return vm.writables[i % uint32(len(vm.writables))]
+       return vm.writables[i%uint32(len(vm.writables))]
 }
 
 func (vm *RRVolumeManager) Close() {