rados

package
v0.0.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 4, 2021 License: Apache-2.0 Imports: 5 Imported by: 2

README

go-rados - Go bindings for RADOS distributed object store

Installation

go get github.com/noahdesu/go-rados

The native RADOS library and development headers are expected to be installed.

Documentation

Detailed documentation is available at http://godoc.org/github.com/noahdesu/go-rados.

Connecting to a cluster

Connect to a Ceph cluster using a configuration file located in the default search paths.

conn, _ := rados.NewConn()
conn.ReadDefaultConfigFile()
conn.Connect()

A connection can be shutdown by calling the Shutdown method on the connection object (e.g. conn.Shutdown()). There are also other methods for configuring the connection. Specific configuration options can be set:

conn.SetConfigOption("log_file", "/dev/null")

and command line options can also be used using the ParseCmdLineArgs method.

args := []string{ "--mon-host", "1.1.1.1" }
err := conn.ParseCmdLineArgs(args)

For other configuration options see the full documentation.

Pool maintenance

The list of pools in a cluster can be retreived using the ListPools method on the connection object. On a new cluster the following code snippet:

pools, _ := conn.ListPools()
fmt.Println(pools)

will produce the output [data metadata rbd], along with any other pools that might exist in your cluster. Pools can also be created and destroyed. The following creates a new, empty pool with default settings.

conn.MakePool("new_pool")

Deleting a pool is also easy. Call DeletePool(name string) on a connection object to delete a pool with the given name. The following will delete the pool named new_pool and remove all of the pool's data.

conn.DeletePool("new_pool")

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Version

func Version() (int, int, int)

Version returns the major, minor, and patch components of the version of the RADOS library linked against.

Types

type AioCompletion

type AioCompletion struct {
	// contains filtered or unexported fields
}

func (*AioCompletion) Create

func (c *AioCompletion) Create() error

func (*AioCompletion) GetReturnValue

func (c *AioCompletion) GetReturnValue() int

func (*AioCompletion) IsComplete

func (c *AioCompletion) IsComplete() int

func (*AioCompletion) Release

func (c *AioCompletion) Release()

func (*AioCompletion) WaitForComplete

func (c *AioCompletion) WaitForComplete()

type CephDetail

type CephDetail struct {
	Stats struct {
		TotalBytes        int64   `json:"total_bytes"`
		TotalAvailBytes   int64   `json:"total_avail_bytes"`
		TotalUsedBytes    int64   `json:"total_used_bytes"`
		TotalUsedRawBytes int64   `json:"total_used_raw_bytes"`
		TotalUsedRawRatio float64 `json:"total_used_raw_ratio"`
		NumOsds           int     `json:"num_osds"`
		NumPerPoolOsds    int     `json:"num_per_pool_osds"`
	} `json:"stats"`
	StatsByClass struct {
		Hdd struct {
			TotalBytes        int64   `json:"total_bytes"`
			TotalAvailBytes   int64   `json:"total_avail_bytes"`
			TotalUsedBytes    int64   `json:"total_used_bytes"`
			TotalUsedRawBytes int64   `json:"total_used_raw_bytes"`
			TotalUsedRawRatio float64 `json:"total_used_raw_ratio"`
		} `json:"hdd"`
		Ssd struct {
			TotalBytes        int64   `json:"total_bytes"`
			TotalAvailBytes   int64   `json:"total_avail_bytes"`
			TotalUsedBytes    int64   `json:"total_used_bytes"`
			TotalUsedRawBytes int64   `json:"total_used_raw_bytes"`
			TotalUsedRawRatio float64 `json:"total_used_raw_ratio"`
		} `json:"ssd"`
	} `json:"stats_by_class"`
	Pools []struct {
		Name  string `json:"name"`
		ID    int    `json:"id"`
		Stats struct {
			Stored      int64   `json:"stored"`
			Objects     int     `json:"objects"`
			KbUsed      int64   `json:"kb_used"`
			BytesUsed   int64   `json:"bytes_used"`
			PercentUsed float64 `json:"percent_used"`
			MaxAvail    int64   `json:"max_avail"`
		} `json:"stats"`
	} `json:"pools"`
}

type ClusterStat

type ClusterStat struct {
	Kb          uint64
	Kb_used     uint64
	Kb_avail    uint64
	Num_objects uint64
}

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

func NewConn(id string) (*Conn, error)

NewConn creates a new connection object. It returns the connection and an error, if any.

func (*Conn) Connect

func (c *Conn) Connect() error

Connect establishes a connection to a RADOS cluster. It returns an error, if any.

func (*Conn) DeletePool

func (c *Conn) DeletePool(name string) error

DeletePool deletes a pool and all the data inside the pool.

func (*Conn) GetCephDf

func (c *Conn) GetCephDf() (response string, status string, err error)

func (*Conn) GetClusterStats

func (c *Conn) GetClusterStats() (stat ClusterStat, err error)

GetClusterStat returns statistics about the cluster associated with the connection.

func (*Conn) GetConfigOption

func (c *Conn) GetConfigOption(name string) (value string, err error)

GetConfigOption returns the value of the Ceph configuration option identified by the given name.

func (*Conn) GetFSID

func (c *Conn) GetFSID() (fsid string, err error)

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

func (c *Conn) GetInstanceID() uint64

GetInstanceID returns a globally unique identifier for the cluster connection instance.

func (*Conn) ListPools

func (c *Conn) ListPools() (names []string, err error)

ListPools returns the names of all existing pools.

func (*Conn) MakePool

func (c *Conn) MakePool(name string) error

MakePool creates a new pool with default settings.

func (*Conn) OpenPool

func (c *Conn) OpenPool(pool string) (*Pool, error)

func (*Conn) ParseCmdLineArgs

func (c *Conn) ParseCmdLineArgs(args []string) error

ParseCmdLineArgs configures the connection from command line arguments.

func (*Conn) ParseDefaultConfigEnv

func (c *Conn) ParseDefaultConfigEnv() error

ParseDefaultConfigEnv configures the connection from the default Ceph environment variable(s).

func (*Conn) PingMonitor

func (c *Conn) PingMonitor(id string) (string, error)

PingMonitor sends a ping to a monitor and returns the reply.

func (*Conn) ReadConfigFile

func (c *Conn) ReadConfigFile(path string) error

ReadConfigFile configures the connection using a Ceph configuration file.

func (*Conn) ReadDefaultConfigFile

func (c *Conn) ReadDefaultConfigFile() error

ReadDefaultConfigFile configures the connection using a Ceph configuration file located at default locations.

func (*Conn) SetConfigOption

func (c *Conn) SetConfigOption(option, value string) error

SetConfigOption sets the value of the configuration option identified by the given name.

func (*Conn) Shutdown

func (c *Conn) Shutdown()

Shutdown disconnects from the cluster.

func (*Conn) Status

func (c *Conn) Status() (string, error)

func (*Conn) WaitForLatestOSDMap

func (c *Conn) WaitForLatestOSDMap() error

WaitForLatestOSDMap blocks the caller until the latest OSD map has been retrieved.

type Pool

type Pool struct {
	// contains filtered or unexported fields
}

Pool represents a context for performing I/O within a pool.

func (*Pool) CreateStriper

func (p *Pool) CreateStriper() (StriperPool, error)

func (*Pool) Delete

func (p *Pool) Delete(oid string) error

Delete deletes the object with key oid. It returns an error, if any.

func (*Pool) Destroy

func (p *Pool) Destroy()

func (*Pool) Read

func (p *Pool) Read(oid string, data []byte, offset uint64) (int, error)

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 (*Pool) Stat added in v0.0.7

func (p *Pool) Stat(oid string) (uint64, uint64, error)

Stat object and get size and update time

func (*Pool) Truncate

func (p *Pool) Truncate(oid string, size uint64) error

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 (*Pool) Write

func (p *Pool) Write(oid string, data []byte, offset uint64) error

Write writes len(data) bytes to the object with key oid starting at byte offset offset. It returns an error, if any.

func (*Pool) WriteSmallObject

func (p *Pool) WriteSmallObject(oid string, data []byte) error

add a new flag

type PoolStat

type PoolStat struct {
	Byte_used   uint64
	Kb_used     uint64
	Pecent_used float32
	Max_avail   uint64
}

type PoolsStatMap

type PoolsStatMap struct {
	StatMap map[string]PoolStat
}

type RadosError

type RadosError int

func (RadosError) Error

func (e RadosError) Error() string

type StriperPool

type StriperPool struct {
	// contains filtered or unexported fields
}

func (*StriperPool) Delete

func (sp *StriperPool) Delete(oid string) error

func (*StriperPool) Destroy

func (sp *StriperPool) Destroy()

func (*StriperPool) Flush

func (sp *StriperPool) Flush()

func (*StriperPool) Read

func (sp *StriperPool) Read(oid string, data []byte, offset uint64) (int, error)

func (*StriperPool) SetLayoutObjectSize

func (sp *StriperPool) SetLayoutObjectSize(object_size uint) int

func (*StriperPool) SetLayoutStripeCount

func (sp *StriperPool) SetLayoutStripeCount(stripe_count uint) int

func (*StriperPool) SetLayoutStripeUnit

func (sp *StriperPool) SetLayoutStripeUnit(stripe_unit uint) int

func (*StriperPool) State

func (sp *StriperPool) State(oid string) (uint64, uint64, error)

func (*StriperPool) Truncate

func (sp *StriperPool) Truncate(oid string, offset uint64) error

func (*StriperPool) Write

func (sp *StriperPool) Write(oid string, data []byte, offset uint64) (int, error)

func (*StriperPool) WriteAIO

func (sp *StriperPool) WriteAIO(c *AioCompletion, oid string, data []byte, offset uint64) (int, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL