coordinator

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2013 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const NUMBER_OF_RING_LOCATIONS = 10000

Variables

This section is empty.

Functions

This section is empty.

Types

type AddPotentialServerCommand added in v0.0.5

type AddPotentialServerCommand struct {
	Server *ClusterServer
}

func NewAddPotentialServerCommand added in v0.0.5

func NewAddPotentialServerCommand(s *ClusterServer) *AddPotentialServerCommand

func (*AddPotentialServerCommand) Apply added in v0.0.5

func (c *AddPotentialServerCommand) Apply(server raft.Server) (interface{}, error)

func (*AddPotentialServerCommand) CommandName added in v0.0.5

func (c *AddPotentialServerCommand) CommandName() string

type ClusterConfiguration

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

func NewClusterConfiguration

func NewClusterConfiguration() *ClusterConfiguration

func (*ClusterConfiguration) AddPotentialServer added in v0.0.2

func (self *ClusterConfiguration) AddPotentialServer(server *ClusterServer)

func (*ClusterConfiguration) CreateDatabase

func (self *ClusterConfiguration) CreateDatabase(name string) error

func (*ClusterConfiguration) DropDatabase added in v0.0.2

func (self *ClusterConfiguration) DropDatabase(name string) error

func (*ClusterConfiguration) GetClusterAdmin added in v0.0.2

func (self *ClusterConfiguration) GetClusterAdmin(username string) *clusterAdmin

func (*ClusterConfiguration) GetClusterAdmins added in v0.0.2

func (self *ClusterConfiguration) GetClusterAdmins() (names []string)

func (*ClusterConfiguration) GetDatabases

func (self *ClusterConfiguration) GetDatabases() []string

func (*ClusterConfiguration) GetDbUser added in v0.0.2

func (self *ClusterConfiguration) GetDbUser(db, username string) *dbUser

func (*ClusterConfiguration) GetDbUsers added in v0.0.2

func (self *ClusterConfiguration) GetDbUsers(db string) (names []string)

func (*ClusterConfiguration) GetServerByRaftName added in v0.0.5

func (self *ClusterConfiguration) GetServerByRaftName(name string) *ClusterServer

func (*ClusterConfiguration) IsActive added in v0.0.5

func (self *ClusterConfiguration) IsActive() bool

func (*ClusterConfiguration) SaveClusterAdmin

func (self *ClusterConfiguration) SaveClusterAdmin(u *clusterAdmin)

func (*ClusterConfiguration) SaveDbUser

func (self *ClusterConfiguration) SaveDbUser(u *dbUser)

func (*ClusterConfiguration) UpdateServerState added in v0.0.5

func (self *ClusterConfiguration) UpdateServerState(serverId uint32, state ServerState) error

type ClusterConsensus added in v0.0.6

type ClusterConsensus interface {
	CreateDatabase(name string) error
	DropDatabase(name string) error
	SaveClusterAdminUser(u *clusterAdmin) error
	SaveDbUser(user *dbUser) error

	// an insert index of -1 will append to the end of the ring
	AddServer(server *ClusterServer, insertIndex int) error
	// only servers that are in a Potential state can be moved around in the ring
	MovePotentialServer(server *ClusterServer, insertIndex int) error
	/*
		Activate tells the cluster to start sending writes to this node.
		The node will also make requests to the other servers to backfill any
		  data they should have
		Once the new node updates it state to "Running" the other servers will
		  delete all of the data that they no longer have to keep from the ring
	*/
	ActivateServer(server *ClusterServer) error
	// Efficient method to have a potential server take the place of a running (or downed)
	// server. The replacement must have a state of "Potential" for this to work.
	ReplaceServer(oldServer *ClusterServer, replacement *ClusterServer) error

	// When a cluster is turned on for the first time.
	CreateRootUser() error
}

type ClusterServer added in v0.0.2

type ClusterServer struct {
	Id                   uint32
	RaftName             string
	State                ServerState
	RaftConnectionString string
}

type CommonUser

type CommonUser struct {
	Name          string `json:"name"`
	Hash          string `json:"hash"`
	IsUserDeleted bool   `json:"is_deleted"`
}

func (*CommonUser) GetDb

func (self *CommonUser) GetDb() string

func (*CommonUser) GetName

func (self *CommonUser) GetName() string

func (*CommonUser) HasReadAccess

func (self *CommonUser) HasReadAccess(name string) bool

func (*CommonUser) HasWriteAccess

func (self *CommonUser) HasWriteAccess(name string) bool

func (*CommonUser) IsClusterAdmin

func (self *CommonUser) IsClusterAdmin() bool

func (*CommonUser) IsDbAdmin

func (self *CommonUser) IsDbAdmin(db string) bool

func (*CommonUser) IsDeleted

func (self *CommonUser) IsDeleted() bool

type Coordinator

type Coordinator interface {
	// Assumption about the returned data:
	//   1. For any given time series, the points returned are in order
	//   2. If the query involves more than one time series, there is no
	//      guarantee on the order in whic they are returned
	//   3. Data is filtered, i.e. where clause should be assumed to hold true
	//      for all the data points that are returned
	//   4. The end of a time series is signaled by returning a series with no data points
	//   5. TODO: Aggregation on the nodes
	DistributeQuery(user common.User, db string, query *parser.Query, yield func(*protocol.Series) error) error
	WriteSeriesData(user common.User, db string, series *protocol.Series) error
	DropDatabase(user common.User, db string) error
	CreateDatabase(user common.User, db string) error
	ListDatabases(user common.User) ([]string, error)
}

type CoordinatorImpl

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

func NewCoordinatorImpl

func NewCoordinatorImpl(datastore datastore.Datastore, raftServer ClusterConsensus, clusterConfiguration *ClusterConfiguration) *CoordinatorImpl

func (*CoordinatorImpl) AuthenticateClusterAdmin

func (self *CoordinatorImpl) AuthenticateClusterAdmin(username, password string) (common.User, error)

func (*CoordinatorImpl) AuthenticateDbUser

func (self *CoordinatorImpl) AuthenticateDbUser(db, username, password string) (common.User, error)

func (*CoordinatorImpl) ChangeClusterAdminPassword

func (self *CoordinatorImpl) ChangeClusterAdminPassword(requester common.User, username, password string) error

func (*CoordinatorImpl) ChangeDbUserPassword

func (self *CoordinatorImpl) ChangeDbUserPassword(requester common.User, db, username, password string) error

func (*CoordinatorImpl) CreateClusterAdminUser

func (self *CoordinatorImpl) CreateClusterAdminUser(requester common.User, username string) error

func (*CoordinatorImpl) CreateDatabase

func (self *CoordinatorImpl) CreateDatabase(user common.User, db string) error

func (*CoordinatorImpl) CreateDbUser

func (self *CoordinatorImpl) CreateDbUser(requester common.User, db, username string) error

func (*CoordinatorImpl) DeleteClusterAdminUser

func (self *CoordinatorImpl) DeleteClusterAdminUser(requester common.User, username string) error

func (*CoordinatorImpl) DeleteDbUser

func (self *CoordinatorImpl) DeleteDbUser(requester common.User, db, username string) error

func (*CoordinatorImpl) DistributeQuery

func (self *CoordinatorImpl) DistributeQuery(user common.User, db string, query *parser.Query, yield func(*protocol.Series) error) error

func (*CoordinatorImpl) DropDatabase added in v0.0.2

func (self *CoordinatorImpl) DropDatabase(user common.User, db string) error

func (*CoordinatorImpl) ListClusterAdmins added in v0.0.2

func (self *CoordinatorImpl) ListClusterAdmins(requester common.User) ([]string, error)

func (*CoordinatorImpl) ListDatabases added in v0.0.2

func (self *CoordinatorImpl) ListDatabases(user common.User) ([]string, error)

func (*CoordinatorImpl) ListDbUsers added in v0.0.2

func (self *CoordinatorImpl) ListDbUsers(requester common.User, db string) ([]string, error)

func (*CoordinatorImpl) SetDbAdmin

func (self *CoordinatorImpl) SetDbAdmin(requester common.User, db, username string, isAdmin bool) error

func (*CoordinatorImpl) WriteSeriesData

func (self *CoordinatorImpl) WriteSeriesData(user common.User, db string, series *protocol.Series) error

type CreateDatabaseCommand

type CreateDatabaseCommand struct {
	Name string `json:"name"`
}

func NewCreateDatabaseCommand

func NewCreateDatabaseCommand(name string) *CreateDatabaseCommand

func (*CreateDatabaseCommand) Apply

func (c *CreateDatabaseCommand) Apply(server raft.Server) (interface{}, error)

func (*CreateDatabaseCommand) CommandName

func (c *CreateDatabaseCommand) CommandName() string

type DropDatabaseCommand added in v0.0.2

type DropDatabaseCommand struct {
	Name string `json:"name"`
}

func NewDropDatabaseCommand added in v0.0.2

func NewDropDatabaseCommand(name string) *DropDatabaseCommand

func (*DropDatabaseCommand) Apply added in v0.0.2

func (c *DropDatabaseCommand) Apply(server raft.Server) (interface{}, error)

func (*DropDatabaseCommand) CommandName added in v0.0.2

func (c *DropDatabaseCommand) CommandName() string

type Matcher

type Matcher struct {
	IsRegex bool
	Name    string
}

func (*Matcher) Matches

func (self *Matcher) Matches(name string) bool

type RaftServer

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

The raftd server is a combination of the Raft server and an HTTP server which acts as the transport.

func NewRaftServer

func NewRaftServer(path string, host string, port int, clusterConfig *ClusterConfiguration) *RaftServer

Creates a new server.

func (*RaftServer) ActivateServer added in v0.0.6

func (s *RaftServer) ActivateServer(server *ClusterServer) error

func (*RaftServer) AddServer added in v0.0.6

func (s *RaftServer) AddServer(server *ClusterServer, insertIndex int) error

func (*RaftServer) Close

func (self *RaftServer) Close()

func (*RaftServer) ClusterServer added in v0.0.5

func (s *RaftServer) ClusterServer() *ClusterServer

func (*RaftServer) CreateDatabase

func (s *RaftServer) CreateDatabase(name string) error

func (*RaftServer) CreateRootUser

func (s *RaftServer) CreateRootUser() error

func (*RaftServer) DropDatabase added in v0.0.2

func (s *RaftServer) DropDatabase(name string) error

func (*RaftServer) HandleFunc

func (s *RaftServer) HandleFunc(pattern string, handler func(http.ResponseWriter, *http.Request))

This is a hack around Gorilla mux not providing the correct net/http HandleFunc() interface.

func (*RaftServer) Join

func (s *RaftServer) Join(leader string) error

Joins to the leader of an existing cluster.

func (*RaftServer) ListenAndServe

func (s *RaftServer) ListenAndServe(potentialLeaders []string, retryUntilJoin bool) error

func (*RaftServer) MovePotentialServer added in v0.0.6

func (s *RaftServer) MovePotentialServer(server *ClusterServer, insertIndex int) error

func (*RaftServer) ReplaceServer added in v0.0.6

func (s *RaftServer) ReplaceServer(oldServer *ClusterServer, replacement *ClusterServer) error

func (*RaftServer) SaveClusterAdminUser

func (s *RaftServer) SaveClusterAdminUser(u *clusterAdmin) error

func (*RaftServer) SaveDbUser

func (s *RaftServer) SaveDbUser(u *dbUser) error

func (*RaftServer) Serve added in v0.0.5

func (s *RaftServer) Serve(l net.Listener, potentialLeaders []string, retryUntilJoin bool) error

type SaveClusterAdminCommand

type SaveClusterAdminCommand struct {
	User *clusterAdmin `json:"user"`
}

func NewSaveClusterAdminCommand

func NewSaveClusterAdminCommand(u *clusterAdmin) *SaveClusterAdminCommand

func (*SaveClusterAdminCommand) Apply

func (c *SaveClusterAdminCommand) Apply(server raft.Server) (interface{}, error)

func (*SaveClusterAdminCommand) CommandName

func (c *SaveClusterAdminCommand) CommandName() string

type SaveDbUserCommand

type SaveDbUserCommand struct {
	User *dbUser `json:"user"`
}

func NewSaveDbUserCommand

func NewSaveDbUserCommand(u *dbUser) *SaveDbUserCommand

func (*SaveDbUserCommand) Apply

func (c *SaveDbUserCommand) Apply(server raft.Server) (interface{}, error)

func (*SaveDbUserCommand) CommandName

func (c *SaveDbUserCommand) CommandName() string

type ServerState added in v0.0.2

type ServerState int
const (
	LoadingRingData ServerState = iota
	SendingRingData
	DeletingOldData
	Running
	Potential
)

type UpdateServerStateCommand added in v0.0.5

type UpdateServerStateCommand struct {
	ServerId uint32
	State    ServerState
}

func NewUpdateServerStateCommand added in v0.0.5

func NewUpdateServerStateCommand(serverId uint32, state ServerState) *UpdateServerStateCommand

func (*UpdateServerStateCommand) Apply added in v0.0.5

func (c *UpdateServerStateCommand) Apply(server raft.Server) (interface{}, error)

func (*UpdateServerStateCommand) CommandName added in v0.0.5

func (c *UpdateServerStateCommand) CommandName() string

type UserManager

type UserManager interface {
	// Returns the user for the given db and that has the given
	// credentials, falling back to cluster admins
	AuthenticateDbUser(db, username, password string) (common.User, error)
	// Returns the cluster admin with the given credentials
	AuthenticateClusterAdmin(username, password string) (common.User, error)
	// Create a cluster admin user, it's an error if requester isn't a cluster admin
	CreateClusterAdminUser(request common.User, username string) error
	// Delete a cluster admin. Same restricutions as CreateClusterAdminUser
	DeleteClusterAdminUser(requester common.User, username string) error
	// Change cluster admin's password. It's an error if requester isn't a cluster admin
	ChangeClusterAdminPassword(requester common.User, username, password string) error
	// list cluster admins. only a cluster admin can list the other cluster admins
	ListClusterAdmins(requester common.User) ([]string, error)
	// Create a db user, it's an error if requester isn't a db admin or cluster admin
	CreateDbUser(request common.User, db, username string) error
	// Delete a db user. Same restrictions apply as in CreateDbUser
	DeleteDbUser(requester common.User, db, username string) error
	// Change db user's password. It's an error if requester isn't a cluster admin or db admin
	ChangeDbUserPassword(requester common.User, db, username, password string) error
	// list cluster admins. only a cluster admin or the db admin can list the db users
	ListDbUsers(requester common.User, db string) ([]string, error)
	// make user a db admin for 'db'. It's an error if the requester
	// isn't a db admin or cluster admin or if user isn't a db user
	// for the given db
	SetDbAdmin(requester common.User, db, username string, isAdmin bool) error
}

Jump to

Keyboard shortcuts

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