Documentation ¶
Overview ¶
Package rados contains a set of wrappers around Ceph's librados API.
Index ¶
- Constants
- Variables
- func Version() (int, int, int)
- type AllocHintFlags
- type ClusterRef
- type ClusterStat
- type Conn
- func (c *Conn) Cluster() ClusterRef
- func (c *Conn) Connect() error
- func (c *Conn) DeletePool(name string) error
- func (c *Conn) GetClusterStats() (stat ClusterStat, err error)
- func (c *Conn) GetConfigOption(name string) (value string, err error)
- func (c *Conn) GetFSID() (fsid string, err error)
- func (c *Conn) GetInstanceID() uint64
- func (c *Conn) GetPoolByID(id int64) (string, error)
- func (c *Conn) GetPoolByName(name string) (int64, error)
- func (c *Conn) ListPools() (names []string, err error)
- func (c *Conn) MakePool(name string) error
- func (c *Conn) MgrCommand(args [][]byte) ([]byte, string, error)
- func (c *Conn) MgrCommandWithInputBuffer(args [][]byte, inputBuffer []byte) ([]byte, string, error)
- func (c *Conn) MonCommand(args []byte) ([]byte, string, error)
- func (c *Conn) MonCommandTarget(name string, args [][]byte) ([]byte, string, error)
- func (c *Conn) MonCommandTargetWithInputBuffer(name string, args [][]byte, inputBuffer []byte) ([]byte, string, error)
- func (c *Conn) MonCommandWithInputBuffer(args, inputBuffer []byte) ([]byte, string, error)
- func (c *Conn) OpenIOContext(pool string) (*IOContext, error)
- func (c *Conn) OsdCommand(osd int, args [][]byte) ([]byte, string, error)
- func (c *Conn) OsdCommandWithInputBuffer(osd int, args [][]byte, inputBuffer []byte) ([]byte, string, error)
- func (c *Conn) PGCommand(pgid []byte, args [][]byte) ([]byte, string, error)
- func (c *Conn) PGCommandWithInputBuffer(pgid []byte, args [][]byte, inputBuffer []byte) ([]byte, string, error)
- func (c *Conn) ParseCmdLineArgs(args []string) error
- func (c *Conn) ParseConfigArgv(argv []string) error
- func (c *Conn) ParseDefaultConfigEnv() error
- func (c *Conn) PingMonitor(id string) (string, error)
- func (c *Conn) ReadConfigFile(path string) error
- func (c *Conn) ReadDefaultConfigFile() error
- func (c *Conn) SetConfigOption(option, value string) error
- func (c *Conn) Shutdown()
- func (c *Conn) WaitForLatestOSDMap() error
- func (c *Conn) WatcherFlush() error
- type CreateOption
- type GetOmapStep
- type IOContext
- func (ioctx *IOContext) Alignment() (uint64, error)
- func (ioctx *IOContext) Append(oid string, data []byte) error
- func (ioctx *IOContext) BreakLock(oid, name, client, cookie string) (int, error)
- func (ioctx *IOContext) CleanOmap(oid string) error
- func (ioctx *IOContext) Create(oid string, exclusive CreateOption) error
- func (ioctx *IOContext) CreateSnap(snapName string) error
- func (ioctx *IOContext) Delete(oid string) error
- func (ioctx *IOContext) Destroy()
- func (ioctx *IOContext) GetAllOmapValues(oid string, startAfter string, filterPrefix string, iteratorSize int64) (map[string][]byte, error)
- func (ioctx *IOContext) GetLastVersion() (uint64, error)
- func (ioctx *IOContext) GetNamespace() (string, error)
- func (ioctx *IOContext) GetOmapValues(oid string, startAfter string, filterPrefix string, maxReturn int64) (map[string][]byte, error)
- func (ioctx *IOContext) GetPoolID() int64
- func (ioctx *IOContext) GetPoolName() (name string, err error)
- func (ioctx *IOContext) GetPoolStats() (stat PoolStat, err error)
- func (ioctx *IOContext) GetSnapName(snapID SnapID) (string, error)
- func (ioctx *IOContext) GetSnapStamp(snapID SnapID) (time.Time, error)
- func (ioctx *IOContext) GetXattr(object string, name string, data []byte) (int, error)
- func (ioctx *IOContext) Iter() (*Iter, error)
- func (ioctx *IOContext) ListLockers(oid, name string) (*LockInfo, error)
- func (ioctx *IOContext) ListObjects(listFn ObjectListFunc) error
- func (ioctx *IOContext) ListOmapValues(oid string, startAfter string, filterPrefix string, maxReturn int64, ...) error
- func (ioctx *IOContext) ListSnaps() ([]SnapID, error)
- func (ioctx *IOContext) ListXattrs(oid string) (map[string][]byte, error)
- func (ioctx *IOContext) LockExclusive(oid, name, cookie, desc string, duration time.Duration, flags *byte) (int, error)
- func (ioctx *IOContext) LockShared(oid, name, cookie, tag, desc string, duration time.Duration, flags *byte) (int, error)
- func (ioctx *IOContext) LookupSnap(snapName string) (SnapID, error)
- func (ioctx *IOContext) Notify(obj string, data []byte) ([]NotifyAck, []NotifyTimeout, error)
- func (ioctx *IOContext) NotifyWithTimeout(obj string, data []byte, timeout time.Duration) ([]NotifyAck, []NotifyTimeout, error)
- func (ioctx *IOContext) Pointer() unsafe.Pointer
- func (ioctx *IOContext) Read(oid string, data []byte, offset uint64) (int, error)
- func (ioctx *IOContext) RemoveSnap(snapName string) error
- func (ioctx *IOContext) RequiresAlignment() (bool, error)
- func (ioctx *IOContext) RmOmapKeys(oid string, keys []string) error
- func (ioctx *IOContext) RmXattr(oid string, name string) error
- func (ioctx *IOContext) RollbackSnap(oid, snapName string) error
- func (ioctx *IOContext) SetAllocationHint(oid string, expectedObjectSize uint64, expectedWriteSize uint64, ...) error
- func (ioctx *IOContext) SetLocator(locator string)
- func (ioctx *IOContext) SetNamespace(namespace string)
- func (ioctx *IOContext) SetOmap(oid string, pairs map[string][]byte) error
- func (ioctx *IOContext) SetPoolFullTry() error
- func (ioctx *IOContext) SetReadSnap(snapID SnapID) error
- func (ioctx *IOContext) SetXattr(object string, name string, data []byte) error
- func (ioctx *IOContext) Stat(object string) (stat ObjectStat, err error)
- func (ioctx *IOContext) Truncate(oid string, size uint64) error
- func (ioctx *IOContext) Unlock(oid, name, cookie string) (int, error)
- func (ioctx *IOContext) UnsetPoolFullTry() error
- func (ioctx *IOContext) Watch(obj string) (*Watcher, error)
- func (ioctx *IOContext) WatchWithTimeout(oid string, timeout time.Duration) (*Watcher, error)
- func (ioctx *IOContext) Write(oid string, data []byte, offset uint64) error
- func (ioctx *IOContext) WriteFull(oid string, data []byte) error
- type Iter
- type IterToken
- type LockInfo
- type NotifierID
- type NotifyAck
- type NotifyEvent
- type NotifyID
- type NotifyTimeout
- type ObjectListFunc
- type ObjectStat
- type OmapKeyValue
- type OmapListFunc
- type OpFlags
- type OperationError
- type OperationFlags
- type PoolStat
- type ReadOp
- func (r *ReadOp) AssertExists()
- func (r *ReadOp) AssertVersion(ver uint64)
- func (r *ReadOp) GetOmapValues(startAfter, filterPrefix string, maxReturn uint64) *GetOmapStep
- func (r *ReadOp) GetOmapValuesByKeys(keys []string) *ReadOpOmapGetValsByKeysStep
- func (r *ReadOp) Operate(ioctx *IOContext, oid string, flags OperationFlags) error
- func (r *ReadOp) Read(offset uint64, buffer []byte) *ReadOpReadStep
- func (r *ReadOp) Release()
- type ReadOpOmapGetValsByKeysStep
- type ReadOpReadStep
- type SnapID
- type Timespec
- type Watcher
- type WatcherID
- type WriteOp
- func (w *WriteOp) AssertExists()
- func (w *WriteOp) AssertVersion(ver uint64)
- func (w *WriteOp) CleanOmap()
- func (w *WriteOp) CmpExt(b []byte, offset uint64) *WriteOpCmpExtStep
- func (w *WriteOp) Create(exclusive CreateOption)
- func (w *WriteOp) Operate(ioctx *IOContext, oid string, flags OperationFlags) error
- func (w *WriteOp) OperateWithMtime(ioctx *IOContext, oid string, mtime Timespec, flags OperationFlags) error
- func (w *WriteOp) Release()
- func (w *WriteOp) Remove()
- func (w *WriteOp) RmOmapKeys(keys []string)
- func (w *WriteOp) SetAllocationHint(expectedObjectSize uint64, expectedWriteSize uint64, flags AllocHintFlags)
- func (w *WriteOp) SetOmap(pairs map[string][]byte)
- func (w *WriteOp) SetXattr(name string, value []byte)
- func (w *WriteOp) Write(b []byte, offset uint64)
- func (w *WriteOp) WriteFull(b []byte)
- func (w *WriteOp) WriteSame(b []byte, writeLen, offset uint64)
- type WriteOpCmpExtStep
Constants ¶
const ( // AllocHintNoHint indicates no predefined behavior AllocHintNoHint = AllocHintFlags(0) // AllocHintSequentialWrite TODO AllocHintSequentialWrite = AllocHintFlags(C.LIBRADOS_ALLOC_HINT_FLAG_SEQUENTIAL_WRITE) // AllocHintRandomWrite TODO AllocHintRandomWrite = AllocHintFlags(C.LIBRADOS_ALLOC_HINT_FLAG_RANDOM_WRITE) // AllocHintSequentialRead TODO AllocHintSequentialRead = AllocHintFlags(C.LIBRADOS_ALLOC_HINT_FLAG_SEQUENTIAL_READ) // AllocHintRandomRead TODO AllocHintRandomRead = AllocHintFlags(C.LIBRADOS_ALLOC_HINT_FLAG_RANDOM_READ) // AllocHintAppendOnly TODO AllocHintAppendOnly = AllocHintFlags(C.LIBRADOS_ALLOC_HINT_FLAG_APPEND_ONLY) // AllocHintImmutable TODO AllocHintImmutable = AllocHintFlags(C.LIBRADOS_ALLOC_HINT_FLAG_IMMUTABLE) // AllocHintShortlived TODO AllocHintShortlived = AllocHintFlags(C.LIBRADOS_ALLOC_HINT_FLAG_SHORTLIVED) // AllocHintLonglived TODO AllocHintLonglived = AllocHintFlags(C.LIBRADOS_ALLOC_HINT_FLAG_LONGLIVED) // AllocHintCompressible TODO AllocHintCompressible = AllocHintFlags(C.LIBRADOS_ALLOC_HINT_FLAG_COMPRESSIBLE) // AllocHintIncompressible TODO AllocHintIncompressible = AllocHintFlags(C.LIBRADOS_ALLOC_HINT_FLAG_INCOMPRESSIBLE) )
const ( // ErrNotFound indicates a missing resource. ErrNotFound = radosError(-C.ENOENT) // ErrPermissionDenied indicates a permissions issue. ErrPermissionDenied = radosError(-C.EPERM) // ErrObjectExists indicates that an exclusive object creation failed. ErrObjectExists = radosError(-C.EEXIST) // RadosErrorNotFound indicates a missing resource. // // Deprecated: use ErrNotFound instead RadosErrorNotFound = ErrNotFound // RadosErrorPermissionDenied indicates a permissions issue. // // Deprecated: use ErrPermissionDenied instead RadosErrorPermissionDenied = ErrPermissionDenied )
const ( // CreateExclusive if used with IOContext.Create() and the object // already exists, the function will return an error. CreateExclusive = C.LIBRADOS_CREATE_EXCLUSIVE // CreateIdempotent if used with IOContext.Create() and the object // already exists, the function will not return an error. CreateIdempotent = C.LIBRADOS_CREATE_IDEMPOTENT )
const ( // OperationNoFlag indicates no special behavior is requested. OperationNoFlag = OperationFlags(C.LIBRADOS_OPERATION_NOFLAG) // OperationBalanceReads TODO OperationBalanceReads = OperationFlags(C.LIBRADOS_OPERATION_BALANCE_READS) // OperationLocalizeReads TODO OperationLocalizeReads = OperationFlags(C.LIBRADOS_OPERATION_LOCALIZE_READS) // OperationOrderReadsWrites TODO OperationOrderReadsWrites = OperationFlags(C.LIBRADOS_OPERATION_ORDER_READS_WRITES) // OperationIgnoreCache TODO OperationIgnoreCache = OperationFlags(C.LIBRADOS_OPERATION_IGNORE_CACHE) // OperationSkipRWLocks TODO OperationSkipRWLocks = OperationFlags(C.LIBRADOS_OPERATION_SKIPRWLOCKS) // OperationIgnoreOverlay TODO OperationIgnoreOverlay = OperationFlags(C.LIBRADOS_OPERATION_IGNORE_OVERLAY) // OperationFullTry send request to a full cluster or pool, ops such as delete // can succeed while other ops will return out-of-space errors. OperationFullTry = OperationFlags(C.LIBRADOS_OPERATION_FULL_TRY) // OperationFullForce TODO OperationFullForce = OperationFlags(C.LIBRADOS_OPERATION_FULL_FORCE) // OperationIgnoreRedirect TODO OperationIgnoreRedirect = OperationFlags(C.LIBRADOS_OPERATION_IGNORE_REDIRECT) // OperationOrderSnap TODO OperationOrderSnap = OperationFlags(C.LIBRADOS_OPERATION_ORDERSNAP) )
const ( // AllNamespaces is used to reset a selected namespace to all // namespaces. See the IOContext SetNamespace function. AllNamespaces = C.LIBRADOS_ALL_NSPACES // RadosAllNamespaces is used to reset a selected namespace to all // namespaces. See the IOContext SetNamespace function. // // Deprecated: use AllNamespaces instead RadosAllNamespaces = AllNamespaces )
const ( // OpFlagNone can be use to not set any flags. OpFlagNone = OpFlags(0) // OpFlagExcl marks an op to fail a create operation if the object // already exists. OpFlagExcl = OpFlags(C.LIBRADOS_OP_FLAG_EXCL) // OpFlagFailOk allows the transaction to succeed even if the flagged // op fails. OpFlagFailOk = OpFlags(C.LIBRADOS_OP_FLAG_FAILOK) // OpFlagFAdviseRandom indicates read/write op random. OpFlagFAdviseRandom = OpFlags(C.LIBRADOS_OP_FLAG_FADVISE_RANDOM) // OpFlagFAdviseSequential indicates read/write op sequential. OpFlagFAdviseSequential = OpFlags(C.LIBRADOS_OP_FLAG_FADVISE_SEQUENTIAL) // OpFlagFAdviseWillNeed indicates read/write data will be accessed in // the near future (by someone). OpFlagFAdviseWillNeed = OpFlags(C.LIBRADOS_OP_FLAG_FADVISE_WILLNEED) // OpFlagFAdviseDontNeed indicates read/write data will not accessed in // the near future (by anyone). OpFlagFAdviseDontNeed = OpFlags(C.LIBRADOS_OP_FLAG_FADVISE_DONTNEED) // OpFlagFAdviseNoCache indicates read/write data will not accessed // again (by *this* client). OpFlagFAdviseNoCache = OpFlags(C.LIBRADOS_OP_FLAG_FADVISE_NOCACHE) )
const ( // OpFlagFAdviseFUA optionally support FUA (force unit access) on write // requests. OpFlagFAdviseFUA = OpFlags(C.LIBRADOS_OP_FLAG_FADVISE_FUA) )
const SnapHead = SnapID(C.LIBRADOS_SNAP_HEAD)
SnapHead is the representation of LIBRADOS_SNAP_HEAD from librados. SnapHead can be used to reset the IOContext to stop reading from a snapshot.
Variables ¶
var ( // ErrNotConnected is returned when functions are called // without a RADOS connection. ErrNotConnected = errors.New("RADOS not connected") // ErrEmptyArgument may be returned if a function argument is passed // a zero-length slice or map. ErrEmptyArgument = errors.New("Argument must contain at least one item") // ErrInvalidIOContext may be returned if an api call requires an IOContext // but IOContext is not ready for use. ErrInvalidIOContext = errors.New("IOContext is not ready for use") // ErrOperationIncomplete is returned from write op or read op steps for // which the operation has not been performed yet. ErrOperationIncomplete = errors.New("Operation has not been performed yet") )
Functions ¶
Types ¶
type AllocHintFlags ¶
type AllocHintFlags uint32
AllocHintFlags control the behavior of read and write operations.
type ClusterRef ¶
ClusterRef represents a fundamental RADOS cluster connection.
type ClusterStat ¶
ClusterStat represents Ceph cluster statistics.
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
Conn is a connection handle to a Ceph cluster.
func NewConn ¶
NewConn creates a new connection object. It returns the connection and an error, if any.
func NewConnWithClusterAndUser ¶
NewConnWithClusterAndUser creates a new connection object for a specific cluster and username. It returns the connection and an error, if any.
func NewConnWithUser ¶
NewConnWithUser creates a new connection object with a custom username. It returns the connection and an error, if any.
func (*Conn) Cluster ¶
func (c *Conn) Cluster() ClusterRef
Cluster returns the underlying RADOS cluster reference for this Conn.
func (*Conn) Connect ¶
Connect establishes a connection to a RADOS cluster. It returns an error, if any.
func (*Conn) DeletePool ¶
DeletePool deletes a pool and all the data inside the pool.
func (*Conn) GetClusterStats ¶
func (c *Conn) GetClusterStats() (stat ClusterStat, err error)
GetClusterStats returns statistics about the cluster associated with the connection.
func (*Conn) GetConfigOption ¶
GetConfigOption returns the value of the Ceph configuration option identified by the given name.
func (*Conn) GetFSID ¶
GetFSID returns the fsid of the cluster as a hexadecimal string. The fsid is a unique identifier of an entire Ceph cluster.
func (*Conn) GetInstanceID ¶
GetInstanceID returns a globally unique identifier for the cluster connection instance.
func (*Conn) GetPoolByID ¶
GetPoolByID returns the name of a pool by a given ID.
func (*Conn) GetPoolByName ¶
GetPoolByName returns the ID of the pool with a given name.
func (*Conn) MgrCommand ¶
MgrCommand sends a command to a ceph-mgr.
func (*Conn) MgrCommandWithInputBuffer ¶
MgrCommandWithInputBuffer sends a command, with an input buffer, to a ceph-mgr.
Implements:
int rados_mgr_command(rados_t cluster, const char **cmd, size_t cmdlen, const char *inbuf, size_t inbuflen, char **outbuf, size_t *outbuflen, char **outs, size_t *outslen);
func (*Conn) MonCommand ¶
MonCommand sends a command to one of the monitors
func (*Conn) MonCommandTarget ¶
MonCommandTarget sends a command to a specified monitor.
func (*Conn) MonCommandTargetWithInputBuffer ¶
func (c *Conn) MonCommandTargetWithInputBuffer( name string, args [][]byte, inputBuffer []byte) ([]byte, string, error)
MonCommandTargetWithInputBuffer sends a command, with an input buffer, to a specified monitor.
Implements:
int rados_mon_command_target(rados_t cluster, const char *name, const char **cmd, size_t cmdlen, const char *inbuf, size_t inbuflen, char **outbuf, size_t *outbuflen, char **outs, size_t *outslen);
func (*Conn) MonCommandWithInputBuffer ¶
MonCommandWithInputBuffer sends a command to one of the monitors, with an input buffer
func (*Conn) OpenIOContext ¶
OpenIOContext creates and returns a new IOContext for the given pool.
Implements:
int rados_ioctx_create(rados_t cluster, const char *pool_name, rados_ioctx_t *ioctx);
func (*Conn) OsdCommand ¶
OsdCommand sends a command to the specified ceph OSD.
func (*Conn) OsdCommandWithInputBuffer ¶
func (c *Conn) OsdCommandWithInputBuffer( osd int, args [][]byte, inputBuffer []byte) ([]byte, string, error)
OsdCommandWithInputBuffer sends a command, with an input buffer, to the specified ceph OSD.
Implements:
int rados_osd_command(rados_t cluster, int osdid, const char **cmd, size_t cmdlen, const char *inbuf, size_t inbuflen, char **outbuf, size_t *outbuflen, char **outs, size_t *outslen);
func (*Conn) PGCommand ¶
PGCommand sends a command to one of the PGs
Implements:
int rados_pg_command(rados_t cluster, const char *pgstr, const char **cmd, size_t cmdlen, const char *inbuf, size_t inbuflen, char **outbuf, size_t *outbuflen, char **outs, size_t *outslen);
func (*Conn) PGCommandWithInputBuffer ¶
func (c *Conn) PGCommandWithInputBuffer(pgid []byte, args [][]byte, inputBuffer []byte) ([]byte, string, error)
PGCommandWithInputBuffer sends a command to one of the PGs, with an input buffer
Implements:
int rados_pg_command(rados_t cluster, const char *pgstr, const char **cmd, size_t cmdlen, const char *inbuf, size_t inbuflen, char **outbuf, size_t *outbuflen, char **outs, size_t *outslen);
func (*Conn) ParseCmdLineArgs ¶
ParseCmdLineArgs configures the connection from command line arguments.
This function passes a placeholder value to Ceph as argv[0], see ParseConfigArgv for a version of this function that allows the caller to specify argv[0].
func (*Conn) ParseConfigArgv ¶
ParseConfigArgv configures the connection using a unix style command line argument vector.
Implements:
int rados_conf_parse_argv(rados_t cluster, int argc, const char **argv);
func (*Conn) ParseDefaultConfigEnv ¶
ParseDefaultConfigEnv configures the connection from the default Ceph environment variable CEPH_ARGS.
func (*Conn) PingMonitor ¶
PingMonitor sends a ping to a monitor and returns the reply.
func (*Conn) ReadConfigFile ¶
ReadConfigFile configures the connection using a Ceph configuration file.
func (*Conn) ReadDefaultConfigFile ¶
ReadDefaultConfigFile configures the connection using a Ceph configuration file located at default locations.
func (*Conn) SetConfigOption ¶
SetConfigOption sets the value of the configuration option identified by the given name.
func (*Conn) WaitForLatestOSDMap ¶
WaitForLatestOSDMap blocks the caller until the latest OSD map has been retrieved.
func (*Conn) WatcherFlush ¶
WatcherFlush flushes all pending notifications of the cluster.
Implements:
int rados_watch_flush(rados_t cluster)
type CreateOption ¶
type CreateOption int
CreateOption is passed to IOContext.Create() and should be one of CreateExclusive or CreateIdempotent.
type GetOmapStep ¶
type GetOmapStep struct {
// contains filtered or unexported fields
}
GetOmapStep values are used to get the results of an GetOmapValues call on a WriteOp. Until the Operate method of the WriteOp is called the Next call will return an error. After Operate is called, the Next call will return valid results.
The life cycle of the GetOmapStep is bound to the ReadOp, if the ReadOp Release method is called the public methods of the step must no longer be used and may return errors.
func (*GetOmapStep) More ¶
func (gos *GetOmapStep) More() bool
More returns true if there are more matching keys available.
func (*GetOmapStep) Next ¶
func (gos *GetOmapStep) Next() (*OmapKeyValue, error)
Next returns the next key value pair or nil if iteration is exhausted.
type IOContext ¶
type IOContext struct {
// contains filtered or unexported fields
}
IOContext represents a context for performing I/O within a pool.
func (*IOContext) Alignment ¶
Alignment returns the required stripe size in bytes for pools supporting/requiring it, or an error if unsuccessful. For an EC pool, a buffer size multiple of its stripe size is required to call Append. To know if the pool requires alignment or not, use RequiresAlignment.
Implements:
int rados_ioctx_pool_required_alignment2(rados_ioctx_t io, uint64_t *alignment)
func (*IOContext) Append ¶
Append appends len(data) bytes to the object with key oid. The object is appended with the provided data. If the object exists, it is atomically appended to. It returns an error, if any.
func (*IOContext) BreakLock ¶
BreakLock releases a shared or exclusive lock on an object, which was taken by the specified client.
func (*IOContext) Create ¶
func (ioctx *IOContext) Create(oid string, exclusive CreateOption) error
Create a new object with key oid.
Implements:
void rados_write_op_create(rados_write_op_t write_op, int exclusive, const char* category)
func (*IOContext) CreateSnap ¶
CreateSnap creates a pool-wide snapshot.
Implements: int rados_ioctx_snap_create(rados_ioctx_t io, const char *snapname)
func (*IOContext) Destroy ¶
func (ioctx *IOContext) Destroy()
Destroy informs librados that the I/O context is no longer in use. Resources associated with the context may not be freed immediately, and the context should not be used again after calling this method.
func (*IOContext) GetAllOmapValues ¶
func (ioctx *IOContext) GetAllOmapValues(oid string, startAfter string, filterPrefix string, iteratorSize int64) (map[string][]byte, error)
GetAllOmapValues fetches all the keys and their values from an omap and returns then as a map `startAfter`: retrieve only the keys after this specified one `filterPrefix`: retrieve only the keys beginning with this prefix `iteratorSize`: internal number of keys to fetch during a read operation
func (*IOContext) GetLastVersion ¶
GetLastVersion will return the version number of the last object read or written to.
Implements:
uint64_t rados_get_last_version(rados_ioctx_t io);
func (*IOContext) GetNamespace ¶
GetNamespace gets the namespace used for objects within this IO context.
Implements:
int rados_ioctx_get_namespace(rados_ioctx_t io, char *buf, unsigned maxlen);
func (*IOContext) GetOmapValues ¶
func (ioctx *IOContext) GetOmapValues(oid string, startAfter string, filterPrefix string, maxReturn int64) (map[string][]byte, error)
GetOmapValues fetches a set of keys and their values from an omap and returns then as a map `startAfter`: retrieve only the keys after this specified one `filterPrefix`: retrieve only the keys beginning with this prefix `maxReturn`: retrieve no more than `maxReturn` key/value pairs
func (*IOContext) GetPoolID ¶
GetPoolID returns the pool ID associated with the I/O context.
Implements:
int64_t rados_ioctx_get_id(rados_ioctx_t io)
func (*IOContext) GetPoolName ¶
GetPoolName returns the name of the pool associated with the I/O context.
func (*IOContext) GetPoolStats ¶
GetPoolStats returns a set of statistics about the pool associated with this I/O context.
Implements:
int rados_ioctx_pool_stat(rados_ioctx_t io, struct rados_pool_stat_t *stats);
func (*IOContext) GetSnapName ¶
GetSnapName returns the name of a pool snapshot with the given snapshot ID.
Implements:
int rados_ioctx_snap_get_name(rados_ioctx_t io, rados_snap_t id, char *name, int maxlen)
func (*IOContext) GetSnapStamp ¶
GetSnapStamp returns the time of the pool snapshot creation.
Implements:
int rados_ioctx_snap_get_stamp(rados_ioctx_t io, rados_snap_t id, time_t *t)
func (*IOContext) GetXattr ¶
GetXattr gets an xattr with key `name`, it returns the length of the key read or an error if not successful
func (*IOContext) Iter ¶
Iter returns a Iterator object that can be used to list the object names in the current pool
func (*IOContext) ListLockers ¶
ListLockers lists clients that have locked the named object lock and information about the lock. The number of bytes required in each buffer is put in the corresponding size out parameter. If any of the provided buffers are too short, -ERANGE is returned after these sizes are filled in.
func (*IOContext) ListObjects ¶
func (ioctx *IOContext) ListObjects(listFn ObjectListFunc) error
ListObjects lists all of the objects in the pool associated with the I/O context, and called the provided listFn function for each object, passing to the function the name of the object. Call SetNamespace with RadosAllNamespaces before calling this function to return objects from all namespaces
func (*IOContext) ListOmapValues ¶
func (ioctx *IOContext) ListOmapValues(oid string, startAfter string, filterPrefix string, maxReturn int64, listFn OmapListFunc) error
ListOmapValues iterates over the keys and values in an omap by way of a callback function.
`startAfter`: iterate only on the keys after this specified one `filterPrefix`: iterate only on the keys beginning with this prefix `maxReturn`: iterate no more than `maxReturn` key/value pairs `listFn`: the function called at each iteration
func (*IOContext) ListSnaps ¶
ListSnaps returns a slice containing the SnapIDs of existing pool snapshots.
Implements:
int rados_ioctx_snap_list(rados_ioctx_t io, rados_snap_t *snaps, int maxlen)
func (*IOContext) ListXattrs ¶
ListXattrs lists all the xattrs for an object. The xattrs are returned as a mapping of string keys and byte-slice values.
func (*IOContext) LockExclusive ¶
func (ioctx *IOContext) LockExclusive(oid, name, cookie, desc string, duration time.Duration, flags *byte) (int, error)
LockExclusive takes an exclusive lock on an object.
func (*IOContext) LockShared ¶
func (ioctx *IOContext) LockShared(oid, name, cookie, tag, desc string, duration time.Duration, flags *byte) (int, error)
LockShared takes a shared lock on an object.
func (*IOContext) LookupSnap ¶
LookupSnap returns the ID of a pool snapshot.
Implements:
int rados_ioctx_snap_lookup(rados_ioctx_t io, const char *name, rados_snap_t *id)
func (*IOContext) Notify ¶
Notify sends a notification with the provided data to all Watchers of the specified object.
CAUTION: even if the error is not nil. the returned slices might still contain data.
func (*IOContext) NotifyWithTimeout ¶
func (ioctx *IOContext) NotifyWithTimeout(obj string, data []byte, timeout time.Duration) ([]NotifyAck, []NotifyTimeout, error)
NotifyWithTimeout is like Notify() but with a different timeout than the default.
Implements:
int rados_notify2(rados_ioctx_t io, const char* o, const char* buf, int buf_len, uint64_t timeout_ms, char** reply_buffer, size_t* reply_buffer_len)
func (*IOContext) Pointer ¶
Pointer returns a pointer reference to an internal structure. This function should NOT be used outside of go-ceph itself.
func (*IOContext) Read ¶
Read reads up to len(data) bytes from the object with key oid starting at byte offset offset. It returns the number of bytes read and an error, if any.
func (*IOContext) RemoveSnap ¶
RemoveSnap deletes the pool snapshot.
Implements:
int rados_ioctx_snap_remove(rados_ioctx_t io, const char *snapname)
func (*IOContext) RequiresAlignment ¶
RequiresAlignment returns true if the pool supports/requires alignment or an error if not successful. For an EC pool, a buffer size multiple of its stripe size is required to call Append. See Alignment to know how to get the stripe size for pools requiring it.
Implements:
int rados_ioctx_pool_requires_alignment2(rados_ioctx_t io, int *req)
func (*IOContext) RmOmapKeys ¶
RmOmapKeys removes the specified `keys` from the omap `oid`
func (*IOContext) RollbackSnap ¶
RollbackSnap rollbacks the object with key oID to the pool snapshot. The contents of the object will be the same as when the snapshot was taken.
Implements:
int rados_ioctx_snap_rollback(rados_ioctx_t io, const char *oid, const char *snapname);
func (*IOContext) SetAllocationHint ¶
func (ioctx *IOContext) SetAllocationHint(oid string, expectedObjectSize uint64, expectedWriteSize uint64, flags AllocHintFlags) error
SetAllocationHint sets allocation hint for an object. This is an advisory operation, it will always succeed (as if it was submitted with a LIBRADOS_OP_FLAG_FAILOK flag set) and is not guaranteed to do anything on the backend.
Implements:
int rados_set_alloc_hint2(rados_ioctx_t io, const char *o, uint64_t expected_object_size, uint64_t expected_write_size, uint32_t flags);
func (*IOContext) SetLocator ¶
SetLocator sets the key for mapping objects to pgs within an io context. Until a different locator key is set, all objects in this io context will be placed in the same pg. To reset the locator, an empty string must be set.
Implements:
void rados_ioctx_locator_set_key(rados_ioctx_t io, const char *key);
func (*IOContext) SetNamespace ¶
SetNamespace sets the namespace for objects within this IO context (pool). Setting namespace to a empty or zero length string sets the pool to the default namespace.
Implements:
void rados_ioctx_set_namespace(rados_ioctx_t io, const char *nspace);
func (*IOContext) SetPoolFullTry ¶
SetPoolFullTry makes sure to send requests to the cluster despite the cluster or pool being marked full; ops will either succeed(e.g., delete) or return EDQUOT or ENOSPC.
Implements:
void rados_set_pool_full_try(rados_ioctx_t io);
func (*IOContext) SetReadSnap ¶
SetReadSnap sets the snapshot from which reads are performed. Subsequent reads will return data as it was at the time of that snapshot. Pass SnapHead for no snapshot (i.e. normal operation).
Implements:
void rados_ioctx_snap_set_read(rados_ioctx_t io, rados_snap_t snap);
func (*IOContext) SetXattr ¶
SetXattr sets an xattr for an object with key `name` with value as `data`
func (*IOContext) Stat ¶
func (ioctx *IOContext) Stat(object string) (stat ObjectStat, err error)
Stat returns the size of the object and its last modification time
func (*IOContext) Truncate ¶
Truncate resizes the object with key oid to size size. If the operation enlarges the object, the new area is logically filled with zeroes. If the operation shrinks the object, the excess data is removed. It returns an error, if any.
func (*IOContext) UnsetPoolFullTry ¶
UnsetPoolFullTry unsets the flag set by SetPoolFullTry()
Implements:
void rados_unset_pool_full_try(rados_ioctx_t io);
func (*IOContext) Watch ¶
Watch creates a Watcher for the specified object.
A Watcher receives all notifications that are sent to the object on which it has been created. It exposes two read-only channels: Events() receives all the NotifyEvents and Errors() receives all occuring errors. A typical code creating a Watcher could look like this:
watcher, err := ioctx.Watch(oid) go func() { // event handler for ne := range watcher.Events() { ... ne.Ack([]byte("response data...")) ... } }() go func() { // error handler for err := range watcher.Errors() { ... handle err ... } }()
CAUTION: the Watcher references the IOContext in which it has been created. Therefore all watchers must be deleted with the Delete() method before the IOContext is being destroyed.
Implements:
int rados_watch2(rados_ioctx_t io, const char* o, uint64_t* cookie, rados_watchcb2_t watchcb, rados_watcherrcb_t watcherrcb, void* arg)
func (*IOContext) WatchWithTimeout ¶
WatchWithTimeout creates a watcher on an object. Same as Watcher(), but different timeout than the default can be specified.
Implements:
int rados_watch3(rados_ioctx_t io, const char *o, uint64_t *cookie, rados_watchcb2_t watchcb, rados_watcherrcb_t watcherrcb, uint32_t timeout, void *arg);
type Iter ¶
type Iter struct {
// contains filtered or unexported fields
}
Iter supports iterating over objects in the ioctx.
func (*Iter) Close ¶
func (iter *Iter) Close()
Close the iterator cursor on the server. Be aware that iterators are not closed automatically at the end of iteration.
func (*Iter) Namespace ¶
Namespace returns the namespace associated with the current value of the iterator (object name), after a successful call to Next.
func (*Iter) Next ¶
Next retrieves the next object name in the pool/namespace iterator. Upon a successful invocation (return value of true), the Value method should be used to obtain the name of the retrieved object name. When the iterator is exhausted, Next returns false. The Err method should used to verify whether the end of the iterator was reached, or the iterator received an error.
Example:
iter := pool.Iter() defer iter.Close() for iter.Next() { fmt.Printf("%v\n", iter.Value()) } return iter.Err()
type IterToken ¶
type IterToken uint32
IterToken supports reporting on and seeking to different positions.
type LockInfo ¶
type LockInfo struct { NumLockers int Exclusive bool Tag string Clients []string Cookies []string Addrs []string }
LockInfo represents information on a current Ceph lock
type NotifyAck ¶
type NotifyAck struct { WatcherID WatcherID NotifierID NotifierID Response []byte }
NotifyAck represents an acknowleged notification.
type NotifyEvent ¶
type NotifyEvent struct { ID NotifyID WatcherID WatcherID NotifierID NotifierID Data []byte }
NotifyEvent is received by a watcher for each notification.
func (*NotifyEvent) Ack ¶
func (ne *NotifyEvent) Ack(response []byte) error
Ack sends an acknowledgement with the specified response data to the notfier of the NotifyEvent. If a notify is not ack'ed, the originating Notify() call blocks and eventiually times out.
Implements:
int rados_notify_ack(rados_ioctx_t io, const char *o, uint64_t notify_id, uint64_t cookie, const char *buf, int buf_len)
type NotifyTimeout ¶
type NotifyTimeout struct { WatcherID WatcherID NotifierID NotifierID }
NotifyTimeout represents an unacknowleged notification.
type ObjectListFunc ¶
type ObjectListFunc func(oid string)
ObjectListFunc is the type of the function called for each object visited by ListObjects.
type ObjectStat ¶
type ObjectStat struct { // current length in bytes Size uint64 // last modification time ModTime time.Time }
ObjectStat represents an object stat information
type OmapKeyValue ¶
OmapKeyValue items are returned by the GetOmapStep's Next call.
type OmapListFunc ¶
OmapListFunc is the type of the function called for each omap key visited by ListOmapValues
type OperationError ¶
type OperationError struct { OpError error StepErrors map[int]error // contains filtered or unexported fields }
OperationError is an error type that may be returned by an Operate call. It captures the error from the operate call itself and any errors from steps that can return an error.
func (OperationError) Error ¶
func (e OperationError) Error() string
type OperationFlags ¶
type OperationFlags int
OperationFlags control the behavior of read and write operations.
type PoolStat ¶
type PoolStat struct { // space used in bytes Num_bytes uint64 // space used in KB Num_kb uint64 // number of objects in the pool Num_objects uint64 // number of clones of objects Num_object_clones uint64 // num_objects * num_replicas Num_object_copies uint64 Num_objects_missing_on_primary uint64 // number of objects found on no OSDs Num_objects_unfound uint64 // number of objects replicated fewer times than they should be // (but found on at least one OSD) Num_objects_degraded uint64 Num_rd uint64 Num_rd_kb uint64 Num_wr uint64 Num_wr_kb uint64 }
PoolStat represents Ceph pool statistics.
type ReadOp ¶
type ReadOp struct {
// contains filtered or unexported fields
}
ReadOp manages a set of discrete object read actions that will be performed together atomically.
func CreateReadOp ¶
func CreateReadOp() *ReadOp
CreateReadOp returns a newly constructed read operation.
func (*ReadOp) AssertExists ¶
func (r *ReadOp) AssertExists()
AssertExists assures the object targeted by the read op exists.
Implements:
void rados_read_op_assert_exists(rados_read_op_t read_op);
func (*ReadOp) AssertVersion ¶
AssertVersion ensures that the object exists and that its internal version number is equal to "ver" before reading. "ver" should be a version number previously obtained with IOContext.GetLastVersion().
Implements:
void rados_read_op_assert_version(rados_read_op_t read_op, uint64_t ver)
func (*ReadOp) GetOmapValues ¶
func (r *ReadOp) GetOmapValues(startAfter, filterPrefix string, maxReturn uint64) *GetOmapStep
GetOmapValues is used to iterate over a set, or sub-set, of omap keys as part of a read operation. An GetOmapStep is returned from this function. The GetOmapStep may be used to iterate over the key-value pairs after the Operate call has been performed.
func (*ReadOp) GetOmapValuesByKeys ¶
func (r *ReadOp) GetOmapValuesByKeys(keys []string) *ReadOpOmapGetValsByKeysStep
GetOmapValuesByKeys starts iterating over specific key/value pairs.
Implements:
void rados_read_op_omap_get_vals_by_keys2(rados_read_op_t read_op, char const * const * keys, size_t num_keys, const size_t * key_lens, rados_omap_iter_t * iter, int * prval)
func (*ReadOp) Operate ¶
func (r *ReadOp) Operate(ioctx *IOContext, oid string, flags OperationFlags) error
Operate will perform the operation(s).
func (*ReadOp) Read ¶
func (r *ReadOp) Read(offset uint64, buffer []byte) *ReadOpReadStep
Read bytes from offset into buffer. len(buffer) is the maximum number of bytes read from the object. buffer[:ReadOpReadStep.BytesRead] then contains object data.
Implements:
void rados_read_op_read(rados_read_op_t read_op, uint64_t offset, size_t len, char * buffer, size_t * bytes_read, int * prval)
type ReadOpOmapGetValsByKeysStep ¶
type ReadOpOmapGetValsByKeysStep struct {
// contains filtered or unexported fields
}
ReadOpOmapGetValsByKeysStep holds the result of the GetOmapValuesByKeys read operation. Result is valid only after Operate() was called.
func (*ReadOpOmapGetValsByKeysStep) Next ¶
func (s *ReadOpOmapGetValsByKeysStep) Next() (*OmapKeyValue, error)
Next gets the next omap key/value pair referenced by ReadOpOmapGetValsByKeysStep's internal iterator. If there are no more elements to retrieve, (nil, nil) is returned. May be called only after Operate() finished.
type ReadOpReadStep ¶
type ReadOpReadStep struct { BytesRead int64 // Bytes read by this action. Result int // Result of this action. // contains filtered or unexported fields }
ReadOpReadStep holds the result of the Read read operation. Result is valid only after Operate() was called.
type Watcher ¶
type Watcher struct {
// contains filtered or unexported fields
}
Watcher receives all notifications for certain object.
func (*Watcher) Check ¶
Check on the status of a Watcher.
Returns the time since it was last confirmed. If there is an error, the Watcher is no longer valid, and should be destroyed with the Delete() method.
Implements:
int rados_watch_check(rados_ioctx_t io, uint64_t cookie)
func (*Watcher) Delete ¶
Delete the watcher. This closes both the event and error channel.
Implements:
int rados_unwatch2(rados_ioctx_t io, uint64_t cookie)
func (*Watcher) Errors ¶
Errors returns a read-only channel, that receives all errors for the Watcher.
func (*Watcher) Events ¶
func (w *Watcher) Events() <-chan NotifyEvent
Events returns a read-only channel, that receives all notifications that are sent to the object of the Watcher.
type WriteOp ¶
type WriteOp struct {
// contains filtered or unexported fields
}
WriteOp manages a set of discrete actions that will be performed together atomically.
func CreateWriteOp ¶
func CreateWriteOp() *WriteOp
CreateWriteOp returns a newly constructed write operation.
func (*WriteOp) AssertExists ¶
func (w *WriteOp) AssertExists()
AssertExists assures the object targeted by the write op exists.
Implements:
void rados_write_op_assert_exists(rados_write_op_t write_op);
func (*WriteOp) AssertVersion ¶
AssertVersion ensures that the object exists and that its internal version number is equal to "ver" before writing. "ver" should be a version number previously obtained with IOContext.GetLastVersion().
Implements:
void rados_read_op_assert_version(rados_read_op_t read_op, uint64_t ver)
func (*WriteOp) CmpExt ¶
func (w *WriteOp) CmpExt(b []byte, offset uint64) *WriteOpCmpExtStep
CmpExt ensures that given object range (extent) satisfies comparison.
Implements:
void rados_write_op_cmpext(rados_write_op_t write_op, const char * cmp_buf, size_t cmp_len, uint64_t off, int * prval);
func (*WriteOp) Operate ¶
func (w *WriteOp) Operate(ioctx *IOContext, oid string, flags OperationFlags) error
Operate will perform the operation(s).
func (*WriteOp) OperateWithMtime ¶
func (w *WriteOp) OperateWithMtime( ioctx *IOContext, oid string, mtime Timespec, flags OperationFlags) error
OperateWithMtime will perform the operation while setting the modification time stamp to the supplied value.
func (*WriteOp) Release ¶
func (w *WriteOp) Release()
Release the resources associated with this write operation.
func (*WriteOp) Remove ¶
func (w *WriteOp) Remove()
Remove object.
Implements:
void rados_write_op_remove(rados_write_op_t write_op)
func (*WriteOp) RmOmapKeys ¶
RmOmapKeys removes the specified `keys` from the omap `oid`.
func (*WriteOp) SetAllocationHint ¶
func (w *WriteOp) SetAllocationHint(expectedObjectSize uint64, expectedWriteSize uint64, flags AllocHintFlags)
SetAllocationHint sets allocation hint for an object. This is an advisory operation, it will always succeed (as if it was submitted with a LIBRADOS_OP_FLAG_FAILOK flag set) and is not guaranteed to do anything on the backend.
Implements:
void rados_write_op_set_alloc_hint2(rados_write_op_t write_op, uint64_t expected_object_size, uint64_t expected_write_size, uint32_t flags);
func (*WriteOp) SetXattr ¶
SetXattr sets an xattr.
Implements:
void rados_write_op_setxattr(rados_write_op_t write_op, const char * name, const char * value, size_t value_len)
func (*WriteOp) Write ¶
Write a given byte slice at the supplied offset.
Implements:
void rados_write_op_write(rados_write_op_t write_op, const char *buffer, size_t len, uint64_t offset);
func (*WriteOp) WriteFull ¶
WriteFull writes a given byte slice as the whole object, atomically replacing it.
Implements:
void rados_write_op_write_full(rados_write_op_t write_op, const char *buffer, size_t len);
type WriteOpCmpExtStep ¶
type WriteOpCmpExtStep struct { // Result of the CmpExt write operation. Result int // contains filtered or unexported fields }
WriteOpCmpExtStep holds result of the CmpExt write operation. Result is valid only after Operate() was called.
Source Files ¶
- alloc_hint_flags.go
- command.go
- conn.go
- doc.go
- errors.go
- ioctx.go
- ioctx_octopus.go
- ioctx_pool_alignment.go
- ioctx_pool_requires_alignment.go
- ioctx_set_alloc_hint.go
- object_iter.go
- omap.go
- operation.go
- operation_flags.go
- rados.go
- rados_nautilus.go
- rados_read_op_assert_version.go
- rados_set_locator.go
- rados_write_op_assert_version.go
- rados_write_op_remove.go
- rados_write_op_setxattr.go
- read_op.go
- read_op_omap_get_vals_by_keys.go
- read_op_read.go
- read_step.go
- snapshot.go
- watcher.go
- write_op.go
- write_op_cmpext.go
- write_op_set_alloc_hint.go
- write_step.go