Documentation ¶
Index ¶
- Constants
- Variables
- func IsTempError(err error) bool
- type ICompleteHandler
- type INodeUser
- type NodeHost
- func (nh *NodeHost) GetNodeUser(groupID uint64) (INodeUser, error)
- func (nh *NodeHost) HasNodeInfo(groupID uint64, nodeID uint64) bool
- func (nh *NodeHost) NodeHostConfig() config.NodeHostConfig
- func (nh *NodeHost) PaxosAddress() string
- func (nh *NodeHost) Propose(grouID uint64, cmd []byte, timeout time.Duration) (*RequestState, error)
- func (nh *NodeHost) ReadLocalNode(groupID uint64, query []byte) ([]byte, error)
- func (nh *NodeHost) StartGroup(nodes map[uint64]string, join bool, ...) error
- func (nh *NodeHost) Stop()
- func (nh *NodeHost) StopGroup(groupID uint64) error
- func (nh *NodeHost) StopNode(groupID uint64, nodeID uint64) error
- func (nh *NodeHost) SyncPropose(ctx context.Context, groupID uint64, cmd []byte) (uint64, error)
- type RequestResult
- type RequestResultCode
- type RequestState
Examples ¶
Constants ¶
const ( //PaxosMajor ... PaxosMajor = 0 //PaxosMinor ... PaxosMinor = 0 //PaxosPatch ... PaxosPatch = 1 // DEVVersion is a boolean value to indicate whether this is a dev version DEVVersion = true )
Variables ¶
var ( ErrGroupNotFound = errors.New("group not found") ErrGroupAlreadyExist = errors.New("group already exist") ErrInvalidGroupSettings = errors.New("group settings are invalid") ErrDeadlineNotSet = errors.New("deadline not set") ErrInvalidDeadline = errors.New("invalid deadline") )
var ( // ErrInvalidSession indicates that the specified client session is invalid. ErrInvalidSession = errors.New("invalid session") // ErrTimeoutTooSmall indicates that the specified timeout value is too small. ErrTimeoutTooSmall = errors.New("specified timeout value is too small") // ErrPayloadTooBig indicates that the payload is too big. ErrPayloadTooBig = errors.New("payload is too big") // ErrSystemBusy indicates that the system is too busy to handle the request. ErrSystemBusy = errors.New("system is too busy try again later") // ErrGroupClosed indicates that the requested cluster is being shut down. ErrGroupClosed = errors.New("paxos group already closed") // ErrBadKey indicates that the key is bad, retry the request is recommended. ErrBadKey = errors.New("bad key try again later") // ErrPendingConfigChangeExist indicates that there is already a pending // membership change exist in the system. ErrPendingConfigChangeExist = errors.New("pending config change request exist") // ErrTimeout indicates that the operation timed out. ErrTimeout = errors.New("timeout") // ErrSystemStopped indicates that the system is being shut down. ErrSystemStopped = errors.New("system stopped") // ErrCanceled indicates that the request has been canceled. ErrCanceled = errors.New("request canceled") // ErrRejected indicates that the request has been rejected. ErrRejected = errors.New("request rejected") )
Functions ¶
func IsTempError ¶
IsTempError returns a boolean value indicating whether the specified error is a temporary error that worth to be retried later with the exact same input, potentially on a more suitable NodeHost instance.
Types ¶
type ICompleteHandler ¶
type ICompleteHandler interface { Notify(RequestResult) Release() }
ICompleteHandler is a handler interface that will be invoked when the request in completed. This interface is used by the language bindings, applications are not expected to directly use this interface.
type INodeUser ¶
type INodeUser interface { Propose(groupID uint64, cmd []byte, timeout time.Duration) (*RequestState, error) }
INodeUser is the interface implemented by a Paxos node user type. A Paxos node user can be used to directly initiate proposals operations without locating the Paxos node in NodeHost's node list first. It is useful when doing bulk load operations on selected groups.
type NodeHost ¶
type NodeHost struct {
// contains filtered or unexported fields
}
NodeHost ...
func NewNodeHost ¶
func NewNodeHost(nhConfig config.NodeHostConfig) *NodeHost
NewNodeHost ...
Example ¶
nhc := config.NodeHostConfig{ WALDir: "wal", NodeHostDir: "go-paxos", RTTMillisecond: 200, PaxosAddress: "myhostname:5012", } nh := NewNodeHost(nhc) log.Printf("nodehost created, running on %s", nh.PaxosAddress())
Output:
func (*NodeHost) GetNodeUser ¶
GetNodeUser returns an INodeUser instance ready to be used to directly make proposals.
func (*NodeHost) HasNodeInfo ¶
HasNodeInfo returns a boolean value indicating whether the specified node has been bootstrapped on the current NodeHost instance.
func (*NodeHost) NodeHostConfig ¶
func (nh *NodeHost) NodeHostConfig() config.NodeHostConfig
NodeHostConfig ...
func (*NodeHost) Propose ¶
func (nh *NodeHost) Propose(grouID uint64, cmd []byte, timeout time.Duration) (*RequestState, error)
Propose ...
func (*NodeHost) ReadLocalNode ¶
ReadLocalNode queries the paxos node identified by the input RequestState instance.
func (*NodeHost) StartGroup ¶
func (nh *NodeHost) StartGroup(nodes map[uint64]string, join bool, createStateMachine func(uint64, uint64) statemachine.IStateMachine, config config.Config) error
StartGroup ...
Example ¶
nhc := config.NodeHostConfig{ WALDir: "wal", NodeHostDir: "go-paxos", RTTMillisecond: 200, PaxosAddress: "myhostname:5012", } // Creates a nodehost instance using the above NodeHostConfig instnace. nh := NewNodeHost(nhc) // config for paxos rc := config.Config{ NodeID: 1, GroupID: 1, AskForLearnRTT: 10, } peers := make(map[uint64]string) peers[100] = "myhostname1:5012" peers[200] = "myhostname2:5012" peers[300] = "myhostname3:5012" // Use this NO-OP data store in this example NewStateMachine := func(clusterID uint64, nodeID uint64) statemachine.IStateMachine { return &tests.NoOP{} } if err := nh.StartGroup(peers, false, NewStateMachine, rc); err != nil { log.Fatalf("failed to add group, %v\n", err) }
Output:
type RequestResult ¶
type RequestResult struct {
// contains filtered or unexported fields
}
RequestResult is the result struct returned for the request.
func (*RequestResult) Completed ¶
func (rr *RequestResult) Completed() bool
Completed returns a boolean value indicating the request request completed successfully. For proposals, it means the proposal has been committed by the Raft cluster and applied on the local node. For ReadIndex operation, it means the cluster is now ready for a local read.
func (*RequestResult) GetResult ¶
func (rr *RequestResult) GetResult() uint64
GetResult returns the result value of the request. When making a proposal, the returned result is the value returned by the Update method of the IStateMachine instance.
func (*RequestResult) Rejected ¶
func (rr *RequestResult) Rejected() bool
Rejected returns a boolean value indicating the request is rejected. For a proposal, it means that the used client session instance is not registered or it has been evicted on the server side. When requesting a client session to be registered, Rejected means the another client session with the same client ID has already been registered. When requesting a client session to be unregistered, Rejected means the specified client session is not found on the server side. For a membership change request, it means the request is out of order and thus ignored. Note that the out-of-order check when making membership changes is only imposed when IMasterClient is used in NodeHost.
func (*RequestResult) Terminated ¶
func (rr *RequestResult) Terminated() bool
Terminated returns a boolean value indicating the request terminated due to the requested Raft cluster is being shut down.
func (*RequestResult) Timeout ¶
func (rr *RequestResult) Timeout() bool
Timeout returns a boolean value indicating whether the Request timed out.
type RequestResultCode ¶
type RequestResultCode int
RequestResultCode is the result code returned to the client to indicate the outcome of the request.
func (RequestResultCode) String ¶
func (c RequestResultCode) String() string
type RequestState ¶
type RequestState struct { // CompleteC is a channel for delivering request result to users. CompletedC chan RequestResult // contains filtered or unexported fields }
RequestState is the object used to provide request result to users.
func (*RequestState) Release ¶
func (r *RequestState) Release()
Release puts the RequestState object back to the sync.Pool pool.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
example
|
|
internal
|
|
logdb/gorocksdb
Package gorocksdb provides the ability to create and access RocksDB databases.
|
Package gorocksdb provides the ability to create and access RocksDB databases. |
logdb/levigo
Package levigo provides the ability to create and access LevelDB databases.
|
Package levigo provides the ability to create and access LevelDB databases. |
utils/netutil/cenk/backoff
Package backoff implements backoff algorithms for retrying operations.
|
Package backoff implements backoff algorithms for retrying operations. |
utils/netutil/rubyist/circuitbreaker
Package circuit implements the Circuit Breaker pattern.
|
Package circuit implements the Circuit Breaker pattern. |
Package logger manages loggers used in dragonboat.
|
Package logger manages loggers used in dragonboat. |
Package statemachine contains the definition of the IStateMachine interface required to be implemented by dragonboat based applications.
|
Package statemachine contains the definition of the IStateMachine interface required to be implemented by dragonboat based applications. |
tools
|
|