accountserver

package
v0.0.0-...-6bbe1e0 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2017 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrorNoSuchAccount is returned when a requested account doesn't exist.
	ErrorNoSuchAccount = fmt.Errorf("No such account.")
	// ErrorInvalidMetadata is returned for errors that violate the API metadata constraints.
	ErrorInvalidMetadata = fmt.Errorf("Invalid metadata value")
)
View Source
var GetHashPrefixAndSuffix = conf.GetHashPrefixAndSuffix

GetHashPrefixAndSuffix is a pointer to hummingbird's function of the same name, for overriding in tests.

View Source
var (

	// GetRing is a local pointer to the hummingbird function, for overriding in tests.
	GetRing = ring.GetRing
)

Functions

func GetReplicator

func GetReplicator(serverconf conf.Config, flags *flag.FlagSet) (srv.Daemon, srv.LowLevelLogger, error)

GetReplicator uses the config settings and command-line flags to configure and return a replicator daemon struct.

func GetServer

func GetServer(serverconf conf.Config, flags *flag.FlagSet) (bindIP string, bindPort int, serv srv.Server, logger srv.LowLevelLogger, err error)

GetServer parses configs and command-line flags, returning a configured server object and the ip and port it should bind on.

Types

type Account

type Account interface {
	// GetInfo returns the AccountInfo struct for the account.
	GetInfo() (*AccountInfo, error)
	// PolicyStats returns the metrics for various policies in use by the account.
	PolicyStats() ([]*PolicyStat, error)
	// IsDeleted returns true if the account has been deleted.
	IsDeleted() (bool, error)
	// Delete deletes the account.
	Delete(timestamp string) error
	// ListContainers lists the account's container entries.
	ListContainers(limit int, marker string, endMarker string, prefix string, delimiter string, reverse bool) ([]interface{}, error)
	// GetMetadata returns the account's current metadata.
	GetMetadata() (map[string]string, error)
	// UpdateMetadata applies updates to the account's metadata.
	UpdateMetadata(updates map[string][]string) error
	// PutContainer adds a new container to the account.
	PutContainer(name string, putTimestamp string, deleteTimestamp string, objectCount int64, bytesUsed int64, storagePolicyIndex int) error
	// ID returns a unique identifier for the account.
	ID() string
	// Close frees any resources associated with the account.
	Close() error
}

Account is the interface implemented by an account

type AccountEngine

type AccountEngine interface {
	// Get returns an Account, given a vars mapping.
	Get(vars map[string]string) (c Account, err error)
	// Return returns a Account to the engine, where it can close or retain them as it sees fit.
	Return(c Account)
	// Create creates a new account.  Returns true if the accoun t was created and a pointer to the account.
	Create(vars map[string]string, putTimestamp string, metadata map[string][]string) (bool, Account, error)
	// Close releases all cached accounts and any other retained resources.
	Close()

	// GetByHash returns a replicable database given its hash.  This will probably move from this interface once we
	// have replicator->replicator communication.
	GetByHash(device, hash, partition string) (c ReplicableAccount, err error)
	// Invalidate removes an account from the cache entirely.  This will probably also move, since it's only used by replication.
	Invalidate(c Account)
}

AccountEngine is the interface of an object that creates and returns accounts.

type AccountInfo

type AccountInfo struct {
	Account         string              `json:"account"`
	CreatedAt       string              `json:"created_at"`
	PutTimestamp    string              `json:"put_timestamp"`
	DeleteTimestamp string              `json:"delete_timestamp"`
	StatusChangedAt string              `json:"status_changed_at"`
	ObjectCount     int64               `json:"count"`
	BytesUsed       int64               `json:"bytes_used"`
	ContainerCount  int64               `json:"container_count"`
	Hash            string              `json:"hash"`
	ID              string              `json:"id"`
	RawMetadata     string              `json:"metadata"`
	Metadata        map[string][]string `json:"-"`
	MaxRow          int64               `json:"max_row"`

	// This row isn't populated by GetInfo, it only exists for the times this is
	// serialized during replication.
	Point int64 `json:"point"`
	// contains filtered or unexported fields
}

AccountInfo represents the container_info database record - basic information about the container.

type AccountServer

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

AccountServer contains all of the information for a running account server.

func (*AccountServer) AccountDeleteHandler

func (server *AccountServer) AccountDeleteHandler(writer http.ResponseWriter, request *http.Request)

AccountDeleteHandler handles DELETE requests for an account.

func (*AccountServer) AccountGetHandler

func (server *AccountServer) AccountGetHandler(writer http.ResponseWriter, request *http.Request)

AccountGetHandler handles GET and HEAD requests for an account.

func (*AccountServer) AccountPostHandler

func (server *AccountServer) AccountPostHandler(writer http.ResponseWriter, request *http.Request)

AccountPostHandler handles POST requests for an account.

func (*AccountServer) AccountPutHandler

func (server *AccountServer) AccountPutHandler(writer http.ResponseWriter, request *http.Request)

AccountPutHandler handles PUT requests for an account.

func (*AccountServer) AccountReplicateHandler

func (server *AccountServer) AccountReplicateHandler(writer http.ResponseWriter, request *http.Request)

AccountReplicateHandler handles the REPLICATE call for accounts.

func (*AccountServer) AcquireDevice

func (server *AccountServer) AcquireDevice(next http.Handler) http.Handler

AcquireDevice is a middleware that makes sure the device is available - mounted and not beyond its max concurrency.

func (*AccountServer) ContainerPutHandler

func (server *AccountServer) ContainerPutHandler(writer http.ResponseWriter, request *http.Request)

ContainerPutHandler handles the PUT of container records to an account.

func (*AccountServer) DiskUsageHandler

func (server *AccountServer) DiskUsageHandler(writer http.ResponseWriter, request *http.Request)

DiskUsageHandler returns information on the current outstanding HTTP requests per-disk.

func (*AccountServer) Finalize

func (server *AccountServer) Finalize()

func (*AccountServer) GetHandler

func (server *AccountServer) GetHandler(config conf.Config) http.Handler

GetHandler returns the server's http handler - it sets up routes and instantiates middleware.

func (*AccountServer) HealthcheckHandler

func (server *AccountServer) HealthcheckHandler(writer http.ResponseWriter, request *http.Request)

HealthcheckHandler implements a basic health check, that just returns "OK".

func (*AccountServer) LogRequest

func (server *AccountServer) LogRequest(next http.Handler) http.Handler

LogRequest is a middleware that logs requests and also sets up a logger in the request context.

func (*AccountServer) ReconHandler

func (server *AccountServer) ReconHandler(writer http.ResponseWriter, request *http.Request)

ReconHandler delegates incoming /recon calls to the common recon handler.

func (*AccountServer) TmpUploadHandler

func (server *AccountServer) TmpUploadHandler(writer http.ResponseWriter, request *http.Request)

TmpUploadHandler handles uploading account files to the tmp directory for various replication strategies. This replaces the swift replicator's use of rsync.

type ContainerListingRecord

type ContainerListingRecord struct {
	XMLName      xml.Name `xml:"container" json:"-"`
	Name         string   `xml:"name" json:"name"`
	Bytes        int64    `xml:"bytes" json:"bytes"`
	Count        int64    `xml:"count" json:"count"`
	LastModified string   `xml:"last_modified" json:"last_modified"`
}

ContainerListingRecord is the struct used for serializing objects in json and xml account listings.

type ContainerRecord

type ContainerRecord struct {
	Rowid              int64  `json:"ROWID"`
	Name               string `json:"name"`
	PutTimestamp       string `json:"put_timestamp"`
	DeleteTimestamp    string `json:"delete_timestamp"`
	ObjectCount        int64  `json:"object_count"`
	BytesUsed          int64  `json:"bytes_used"`
	Deleted            int    `json:"deleted"`
	StoragePolicyIndex int    `json:"storage_policy_index"`
}

ContainerRecord represents the object's data in-databaee, it is used by replication.

type PolicyStat

type PolicyStat struct {
	StoragePolicyIndex int
	ContainerCount     int64
	ObjectCount        int64
	BytesUsed          int64
}

type ReplicableAccount

type ReplicableAccount interface {
	Account
	// MergeItems merges object records into the account, with an optional remoteId.
	MergeItems(records []*ContainerRecord, remoteID string) error
	// ItemsSince returns count object records with a ROWID greater than start.
	ItemsSince(start int64, count int) ([]*ContainerRecord, error)
	// MergeSyncTable updates the account's incoming sync tables with new data.
	MergeSyncTable(records []*SyncRecord) error
	// SyncTable returns the account's current sync table.
	SyncTable() ([]*SyncRecord, error)
	// SyncRemoteData accepts a remote account's current status information and updates local records accordingly.
	SyncRemoteData(maxRow int64, hash, id, createdAt, putTimestamp, deleteTimestamp, metadata string) (*AccountInfo, error)
	// NewID gives the database a new unique identifier, which is used for incoming_sync entries.
	NewID() error
	// OpenDatabaseFile returns a consistent reader for the underlying database file.
	OpenDatabaseFile() (*os.File, func(), error)
	// CleanupTombstones removes any metadata and object tombstones older than reclaimAge seconds.
	CleanupTombstones(reclaimAge int64) error
	// RingHash returns the account's ring hash.
	RingHash() string
}

ReplicableAccount is an account that also implements the replication API.

type Replicator

type Replicator struct {
	Ring ring.Ring
	// contains filtered or unexported fields
}

Replicator is the account replicator daemon object

func (*Replicator) Run

func (r *Replicator) Run()

Run runs a pass of the replicator once.

func (*Replicator) RunForever

func (r *Replicator) RunForever()

RunForever runs the replicator in a forever-loop.

type SubdirListingRecord

type SubdirListingRecord struct {
	XMLName xml.Name `xml:"subdir" json:"-"`
	Name2   string   `xml:"name,attr" json:"-"`
	Name    string   `xml:"name" json:"subdir"`
}

SubdirListingRecord is the struct used for serializing subdirs in json and xml account listings.

type SyncRecord

type SyncRecord struct {
	SyncPoint int64  `json:"sync_point"`
	RemoteID  string `json:"remote_id"`
}

SyncRecord represents a row in the incoming_sync table. It is used by replication.

Jump to

Keyboard shortcuts

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