Documentation
¶
Overview ¶
This package is used to provide an implementation of the Chord network protocol.
Index ¶
- Constants
- Variables
- func CreateNewTCPTransport(localOnly bool) (int, Transport, *Config)
- func CreateNewTCPTransportWithConfig(localOnly bool, configGen func(string) *Config) (int, Transport, *Config)
- func GetLocalExternalAddresses() (localAddr string, externalAddr string)
- type BlackholeTransport
- func (*BlackholeTransport) AbortWLock(v *Vnode, key string, version uint, nodeID string, opsLogEntry *OpsLogEntry) (uint64, error)
- func (*BlackholeTransport) BulkSet(v *Vnode, key string, valLst []KVStoreValue) error
- func (*BlackholeTransport) ClearPredecessor(target, self *Vnode) error
- func (*BlackholeTransport) CommitWLock(v *Vnode, key string, version uint, nodeID string, opsLogEntry *OpsLogEntry) (uint64, error)
- func (*BlackholeTransport) FindSuccessors(vn *Vnode, n int, key []byte) ([]*Vnode, error)
- func (*BlackholeTransport) Get(v *Vnode, key string, version uint) ([]byte, error)
- func (*BlackholeTransport) GetPredecessor(vn *Vnode) (*Vnode, error)
- func (*BlackholeTransport) GetPredecessorList(vn *Vnode) ([]*Vnode, error)
- func (*BlackholeTransport) List(v *Vnode) ([]string, error)
- func (*BlackholeTransport) ListVnodes(host string) ([]*Vnode, error)
- func (*BlackholeTransport) MissingKeys(v *Vnode, replVn *Vnode, key string, ver []uint) error
- func (*BlackholeTransport) Notify(vn, self *Vnode) ([]*Vnode, error)
- func (*BlackholeTransport) Ping(vn *Vnode) (bool, error)
- func (*BlackholeTransport) PurgeVersions(v *Vnode, key string, maxVersion uint) error
- func (*BlackholeTransport) RLock(v *Vnode, key string, nodeID string, opsLogEntry *OpsLogEntry) (string, uint, uint64, error)
- func (*BlackholeTransport) Register(v *Vnode, o VnodeRPC)
- func (*BlackholeTransport) Set(v *Vnode, key string, version uint, value []byte) error
- func (*BlackholeTransport) SkipSuccessor(target, self *Vnode) error
- func (*BlackholeTransport) SyncKeys(v *Vnode, ownerVn *Vnode, key string, ver []uint) error
- func (*BlackholeTransport) WLock(v *Vnode, key string, version uint, timeout uint, nodeID string, ...) (string, uint, uint, uint64, error)
- type BuddyStore
- type BuddyStoreConfig
- type BuddyStoreError
- type ClockIface
- type Config
- type Delegate
- type KVStore
- type KVStoreClient
- type KVStoreClientImpl
- func (kv KVStoreClientImpl) Get(key string, retry bool) ([]byte, error)
- func (kv KVStoreClientImpl) GetForSet(key string, retry bool) ([]byte, uint, error)
- func (kv *KVStoreClientImpl) Set(key string, value []byte) error
- func (kv *KVStoreClientImpl) SetVersion(key string, version uint, value []byte) error
- type KVStoreIntf
- type KVStoreValue
- type LMClientIntf
- type LManager
- type LManagerClient
- func (lm *LManagerClient) AbortWLock(key string, version uint) error
- func (lm *LManagerClient) CommitWLock(key string, version uint) error
- func (lm *LManagerClient) InvalidateRLock(lockID string) error
- func (lm *LManagerClient) RLock(key string, forceNoCache bool) (version uint, err error)
- func (lm *LManagerClient) WLock(key string, version uint, timeout uint) (uint, error)
- type LManagerIntf
- type LocalTransport
- func (lt *LocalTransport) AbortWLock(targetLm *Vnode, key string, version uint, nodeID string, ...) (uint64, error)
- func (lt *LocalTransport) BulkSet(target *Vnode, key string, valLst []KVStoreValue) error
- func (lt *LocalTransport) ClearPredecessor(target, self *Vnode) error
- func (lt *LocalTransport) CommitWLock(targetLm *Vnode, key string, version uint, nodeID string, ...) (uint64, error)
- func (lt *LocalTransport) Deregister(v *Vnode)
- func (lt *LocalTransport) FindSuccessors(vn *Vnode, n int, key []byte) ([]*Vnode, error)
- func (lt *LocalTransport) Get(target *Vnode, key string, version uint) ([]byte, error)
- func (lt *LocalTransport) GetPredecessor(vn *Vnode) (*Vnode, error)
- func (lt *LocalTransport) GetPredecessorList(vn *Vnode) ([]*Vnode, error)
- func (lt *LocalTransport) InvalidateRLock(targetClient *Vnode, lockID string) error
- func (lt *LocalTransport) IsLocalVnode(target *Vnode) bool
- func (lt *LocalTransport) JoinRing(target *Vnode, ringId string, self *Vnode) ([]*Vnode, error)
- func (lt *LocalTransport) List(target *Vnode) ([]string, error)
- func (lt *LocalTransport) ListVnodes(host string) ([]*Vnode, error)
- func (lt *LocalTransport) MissingKeys(target *Vnode, ownerVn *Vnode, key string, ver []uint) error
- func (lt *LocalTransport) Notify(vn, self *Vnode) ([]*Vnode, error)
- func (lt *LocalTransport) Ping(vn *Vnode) (bool, error)
- func (lt *LocalTransport) PurgeVersions(target *Vnode, key string, maxVersion uint) error
- func (lt *LocalTransport) RLock(targetLm *Vnode, key string, nodeID string, opsLogEntry *OpsLogEntry) (string, uint, uint64, error)
- func (lt *LocalTransport) Register(v *Vnode, o VnodeRPC)
- func (lt *LocalTransport) Set(target *Vnode, key string, version uint, value []byte) error
- func (lt *LocalTransport) SkipSuccessor(target, self *Vnode) error
- func (lt *LocalTransport) SyncKeys(target *Vnode, ownerVn *Vnode, key string, ver []uint) error
- func (lt *LocalTransport) WLock(targetLm *Vnode, key string, version uint, timeout uint, nodeID string, ...) (string, uint, uint, uint64, error)
- type MockClock
- type OpsLogEntry
- type RLockEntry
- type RLockVal
- type RealClock
- type Ring
- func (r *Ring) GetConfig() *Config
- func (r *Ring) GetHashFunc() func() hash.Hash
- func (r *Ring) GetLocalLocalVnode() *localVnode
- func (r *Ring) GetLocalVnode() *Vnode
- func (r *Ring) GetNumSuccessors() int
- func (r *Ring) GetRingId() string
- func (r *Ring) Leave() error
- func (r *Ring) Len() int
- func (r *Ring) Less(i, j int) bool
- func (r *Ring) Lookup(n int, key []byte) ([]*Vnode, error)
- func (r *Ring) Shutdown()
- func (r *Ring) Swap(i, j int)
- func (r *Ring) Transport() Transport
- type RingIntf
- type TCPResponse
- type TCPResponseBody
- type TCPResponseImpl
- type TCPTransport
- func (t *TCPTransport) AbortWLock(target *Vnode, key string, version uint, nodeID string, ...) (uint64, error)
- func (t *TCPTransport) BulkSet(target *Vnode, key string, valLst []KVStoreValue) error
- func (t *TCPTransport) ClearPredecessor(target, self *Vnode) error
- func (t *TCPTransport) CommitWLock(target *Vnode, key string, version uint, nodeID string, ...) (uint64, error)
- func (t *TCPTransport) FindSuccessors(vn *Vnode, n int, k []byte) ([]*Vnode, error)
- func (t *TCPTransport) Get(target *Vnode, key string, version uint) ([]byte, error)
- func (t *TCPTransport) GetPredecessor(vn *Vnode) (*Vnode, error)
- func (t *TCPTransport) GetPredecessorList(vn *Vnode) ([]*Vnode, error)
- func (t *TCPTransport) InvalidateRLock(target *Vnode, lockID string) error
- func (t *TCPTransport) JoinRing(target *Vnode, ringId string, joiner *Vnode) ([]*Vnode, error)
- func (t *TCPTransport) List(target *Vnode) ([]string, error)
- func (t *TCPTransport) ListVnodes(host string) ([]*Vnode, error)
- func (t *TCPTransport) MissingKeys(target *Vnode, replVn *Vnode, key string, ver []uint) error
- func (t *TCPTransport) Notify(target, self *Vnode) ([]*Vnode, error)
- func (t *TCPTransport) Ping(vn *Vnode) (bool, error)
- func (t *TCPTransport) PurgeVersions(target *Vnode, key string, maxVersion uint) error
- func (t *TCPTransport) RLock(target *Vnode, key string, nodeID string, opsLogEntry *OpsLogEntry) (string, uint, uint64, error)
- func (t *TCPTransport) Register(v *Vnode, o VnodeRPC)
- func (t *TCPTransport) Set(target *Vnode, key string, version uint, value []byte) error
- func (t *TCPTransport) Shutdown()
- func (t *TCPTransport) SkipSuccessor(target, self *Vnode) error
- func (t *TCPTransport) SyncKeys(target *Vnode, ownerVn *Vnode, key string, ver []uint) error
- func (t *TCPTransport) WLock(target *Vnode, key string, version uint, timeout uint, nodeID string, ...) (string, uint, uint, uint64, error)
- type TimeoutItem
- type TimeoutQueue
- type Tracker
- type TrackerClient
- type TrackerClientImpl
- type TrackerImpl
- type Transport
- type Vnode
- type VnodeRPC
- type WLockEntry
- type WLockVal
Constants ¶
const ( MaxIncSyncParallelism = 8 MaxReplParallelism = 12 )
const BUDDYSTORE_INFOHASH_BASE = "BuddyStore"
const ENOTINITIALIZED = -1
const JOIN_STABILIZE_WAIT = 5
const LISTEN_TIMEOUT = 30 * time.Second
const NUM_TRACKER_REPLICAS = 2
const OK = 0
const PEERLEN = 6
const RETRY_WAIT = 1 * time.Millisecond
const TRACKER_TIMEOUT_SECS = 600 * time.Second
const TRACKER_URL = "udp://tracker.openbittorrent.com:80/announce"
Variables ¶
var NUM_LM_REPLICA = 2
Functions ¶
Types ¶
type BlackholeTransport ¶
type BlackholeTransport struct { // Implements: Transport }
BlackholeTransport is used to provide an implemenation of the Transport that does not actually do anything. Any operation will result in an error.
func (*BlackholeTransport) AbortWLock ¶
func (*BlackholeTransport) AbortWLock(v *Vnode, key string, version uint, nodeID string, opsLogEntry *OpsLogEntry) (uint64, error)
func (*BlackholeTransport) BulkSet ¶
func (*BlackholeTransport) BulkSet(v *Vnode, key string, valLst []KVStoreValue) error
func (*BlackholeTransport) ClearPredecessor ¶
func (*BlackholeTransport) ClearPredecessor(target, self *Vnode) error
func (*BlackholeTransport) CommitWLock ¶
func (*BlackholeTransport) CommitWLock(v *Vnode, key string, version uint, nodeID string, opsLogEntry *OpsLogEntry) (uint64, error)
func (*BlackholeTransport) FindSuccessors ¶
func (*BlackholeTransport) GetPredecessor ¶
func (*BlackholeTransport) GetPredecessor(vn *Vnode) (*Vnode, error)
func (*BlackholeTransport) GetPredecessorList ¶
func (*BlackholeTransport) GetPredecessorList(vn *Vnode) ([]*Vnode, error)
func (*BlackholeTransport) ListVnodes ¶
func (*BlackholeTransport) ListVnodes(host string) ([]*Vnode, error)
func (*BlackholeTransport) MissingKeys ¶
func (*BlackholeTransport) Notify ¶
func (*BlackholeTransport) Notify(vn, self *Vnode) ([]*Vnode, error)
func (*BlackholeTransport) PurgeVersions ¶
func (*BlackholeTransport) PurgeVersions(v *Vnode, key string, maxVersion uint) error
func (*BlackholeTransport) RLock ¶
func (*BlackholeTransport) RLock(v *Vnode, key string, nodeID string, opsLogEntry *OpsLogEntry) (string, uint, uint64, error)
func (*BlackholeTransport) Register ¶
func (*BlackholeTransport) Register(v *Vnode, o VnodeRPC)
func (*BlackholeTransport) SkipSuccessor ¶
func (*BlackholeTransport) SkipSuccessor(target, self *Vnode) error
type BuddyStore ¶
type BuddyStore struct { Config *BuddyStoreConfig GlobalRing RingIntf SubRings map[string]RingIntf Tracker TrackerClient // contains filtered or unexported fields }
func NewBuddyStore ¶
func NewBuddyStore(bsConfig *BuddyStoreConfig) *BuddyStore
func (BuddyStore) GetKVClient ¶
func (bs BuddyStore) GetKVClient(ringId string) (KVStoreClient, int)
func (BuddyStore) GetMyKVClient ¶
func (bs BuddyStore) GetMyKVClient() (KVStoreClient, int)
type BuddyStoreConfig ¶
type BuddyStoreError ¶
func PermanentError ¶
func PermanentError(str string, args ...interface{}) BuddyStoreError
func TransientError ¶
func TransientError(str string, args ...interface{}) BuddyStoreError
func (BuddyStoreError) Error ¶
func (bse BuddyStoreError) Error() string
func (BuddyStoreError) Temporary ¶
func (bse BuddyStoreError) Temporary() bool
func (BuddyStoreError) Timeout ¶
func (bse BuddyStoreError) Timeout() bool
type ClockIface ¶
type Config ¶
type Config struct { Hostname string // Local host name NumVnodes int // Number of vnodes per physical node HashFunc func() hash.Hash // Hash function to use StabilizeMin time.Duration // Minimum stabilization time StabilizeMax time.Duration // Maximum stabilization time NumSuccessors int // Number of successors to maintain Delegate Delegate // Invoked to handle ring events RingId string // contains filtered or unexported fields }
Configuration for Chord nodes
func DefaultConfig ¶
Returns the default Ring configuration
type Delegate ¶
type Delegate interface { NewPredecessor(local, remoteNew, remotePrev *Vnode) Leaving(local, pred, succ *Vnode) PredecessorLeaving(local, remote *Vnode) SuccessorLeaving(local, remote *Vnode) Shutdown() }
Delegate to notify on ring events
type KVStore ¶
type KVStore struct { // Implements: KVStoreIntf // contains filtered or unexported fields }
type KVStoreClient ¶
type KVStoreClientImpl ¶
type KVStoreClientImpl struct {
// contains filtered or unexported fields
}
func NewKVStoreClient ¶
func NewKVStoreClient(ring *Ring) *KVStoreClientImpl
func NewKVStoreClientWithLM ¶
func NewKVStoreClientWithLM(ringIntf RingIntf, lm LMClientIntf) *KVStoreClientImpl
func (KVStoreClientImpl) Get ¶
func (kv KVStoreClientImpl) Get(key string, retry bool) ([]byte, error)
Inform the lock manager we're interested in reading the value for key. Expected return value:
Current version number associated with key
Expected error conditions:
Network failure => Retryable failure Key does not exist => Fail immediately
Once current version number has been successfully read, contact nodes KV Store to read value at expected version. Expected error conditions:
Key/version does not exist => Retry with another node All nodes returned error => Fail
Optimization:
Prioritize reading from local vnode if one of them may contain this data.
func (KVStoreClientImpl) GetForSet ¶
Similar to KVStore.Get, but useful for transactional read-update-write operations along with KVStore.SetVersion.
First, get a write lease from the lock manager. This prevents any further write operations on the same key. Proceed to read the latest version of the key and get its data, which is returned.
func (*KVStoreClientImpl) Set ¶
func (kv *KVStoreClientImpl) Set(key string, value []byte) error
Inform the lock manager we're interested in setting the value for key. Expected return value:
Next available version number to write value to
Expected error conditions:
Network failure => Retryable failure Key does not exist => Fail immediately Access permissions? => Fail immediately
Once next version number has been successfully read, contact master KV Store to write value at new version. Expected error conditions:
Key/version too old => TODO: Inform lock manager Transient error => TODO: Retry
If write operation succeeded without errors, send a commit message to the lock manager to finalize the operation. Until the commit returns successfully, the new version of this value will not be advertised. Expected error conditions:
Lock not found => TODO: Return Transient error => TODO: Retry
If write operation failed, send an abort message to the lock manager to cancel the operation. This is simply to speed up the lock release operation instead of waiting for a timeout to happen. Expected error conditions:
Lock not found => TODO: Return Transient error => TODO: Retry
func (*KVStoreClientImpl) SetVersion ¶
func (kv *KVStoreClientImpl) SetVersion(key string, version uint, value []byte) error
Similar to KVStore.Set, but useful for transactional read-update-write operations along with KVStore.GetForSet.
Use the version number from the write lease acquired in KVStore.GetForSet. Perform regular Set operation with commit/abort.
type KVStoreIntf ¶
type KVStoreIntf interface {
// contains filtered or unexported methods
}
type KVStoreValue ¶
type LMClientIntf ¶
type LManager ¶
type LManager struct { // Local state managed by the LockManager Ring *Ring // This is to get the Ring's transport when the server has to send invalidations to lm_client cache Vn *Vnode // The Vnode this LockManager is associated with CurrentLM bool // Boolean flag which says if the node is the current Lock Manager. VersionMap map[string]uint // key-version mappings. A map of key to the corresponding version RLocks map[string]*RLockEntry // Will have the CopySets for whom the RLocks have been provided for a key WLocks map[string]*WLockEntry // Will have mapping from key to the metadata to be maintained TimeoutTicker *time.Ticker // Ticker that will periodically check WLocks for invalidation LMCheckTicker *time.Ticker // Ticker that will periodically checks if LM has changed OpsLog []*OpsLogEntry // Actual log used for write-ahead logging each operation // HARP Replication CommitPoint uint64 // Current Commit point of LManager. CommitIndex int // contains filtered or unexported fields }
In-memory implementation of LockManager that implements LManagerIntf
func (*LManager) CheckStatus ¶
func (lm *LManager) CheckStatus()
This method is called after JOIN_STABILIZE_WAIT time.
1. Check if this lm is the CurrentLM, if yes, you should have received the current set of Locks from the original LockManager. In that case, we are ready to go. Set CurrentLM to true. Set block to false. 2. If not the current LM, then just set block to false so that you can start acting as the secondary
func (*LManager) ScheduleLMCheckTicker ¶
func (lm *LManager) ScheduleLMCheckTicker()
Logic is moved to stabilize operation in vnode.go
func (*LManager) SyncWithSuccessor ¶
TODO : What if I have no log? Two possibilities
1. I just joined. Go and ask the successor for the opsLog and replay it. 2. Its genesis, there was no LM before this. Go and ask the successor to confirm it. Well, just ask the successor and execute whatever you have to.. Return true, if the successor has state, else return false (birth)
func (*LManager) UpdateVersionMap ¶
Called by the old LM on the new LM to update it with the Locks
type LManagerClient ¶
type LManagerClient struct { Vnode *Vnode // Vnode associated with this LMClient Ring RingIntf // Ring with whom the client is associated with RLocks map[string]*RLockVal // Map of <keys, ReadLock Values> WLocks map[string]*WLockVal // Map of <keys, WriteLock Values> // Implements: LMClientIntf // contains filtered or unexported fields }
func (*LManagerClient) AbortWLock ¶
func (lm *LManagerClient) AbortWLock(key string, version uint) error
func (*LManagerClient) CommitWLock ¶
func (lm *LManagerClient) CommitWLock(key string, version uint) error
func (*LManagerClient) InvalidateRLock ¶
func (lm *LManagerClient) InvalidateRLock(lockID string) error
type LManagerIntf ¶
type LManagerIntf interface {
// contains filtered or unexported methods
}
Should be extensible to be used by any underlying storage implementation
type LocalTransport ¶
type LocalTransport struct { // Implements: Transport // contains filtered or unexported fields }
LocalTransport is used to provides fast routing to Vnodes running locally using direct method calls. For any non-local vnodes, the request is passed on to another transport.
func (*LocalTransport) AbortWLock ¶
func (lt *LocalTransport) AbortWLock(targetLm *Vnode, key string, version uint, nodeID string, opsLogEntry *OpsLogEntry) (uint64, error)
func (*LocalTransport) BulkSet ¶
func (lt *LocalTransport) BulkSet(target *Vnode, key string, valLst []KVStoreValue) error
func (*LocalTransport) ClearPredecessor ¶
func (lt *LocalTransport) ClearPredecessor(target, self *Vnode) error
func (*LocalTransport) CommitWLock ¶
func (lt *LocalTransport) CommitWLock(targetLm *Vnode, key string, version uint, nodeID string, opsLogEntry *OpsLogEntry) (uint64, error)
func (*LocalTransport) Deregister ¶
func (lt *LocalTransport) Deregister(v *Vnode)
func (*LocalTransport) FindSuccessors ¶
func (*LocalTransport) GetPredecessor ¶
func (lt *LocalTransport) GetPredecessor(vn *Vnode) (*Vnode, error)
func (*LocalTransport) GetPredecessorList ¶
func (lt *LocalTransport) GetPredecessorList(vn *Vnode) ([]*Vnode, error)
func (*LocalTransport) InvalidateRLock ¶
func (lt *LocalTransport) InvalidateRLock(targetClient *Vnode, lockID string) error
func (*LocalTransport) IsLocalVnode ¶
func (lt *LocalTransport) IsLocalVnode(target *Vnode) bool
func (*LocalTransport) ListVnodes ¶
func (lt *LocalTransport) ListVnodes(host string) ([]*Vnode, error)
func (*LocalTransport) MissingKeys ¶
func (*LocalTransport) PurgeVersions ¶
func (lt *LocalTransport) PurgeVersions(target *Vnode, key string, maxVersion uint) error
func (*LocalTransport) RLock ¶
func (lt *LocalTransport) RLock(targetLm *Vnode, key string, nodeID string, opsLogEntry *OpsLogEntry) (string, uint, uint64, error)
func (*LocalTransport) Register ¶
func (lt *LocalTransport) Register(v *Vnode, o VnodeRPC)
func (*LocalTransport) SkipSuccessor ¶
func (lt *LocalTransport) SkipSuccessor(target, self *Vnode) error
type MockClock ¶
func NewFrozenClock ¶
func NewFrozenClock() *MockClock
type OpsLogEntry ¶
type OpsLogEntry struct { OpNum uint64 // Operation Number Op string // Operation that was performed Key string // Key on which the operation was performed Version uint // Version number of the Key Timeout *time.Time // Timeout setting if any. For instance, WLocks have timeouts associated with them. When the primary fails, the second should know when to invalidate that entry // For handling replication. Nodes should be able to reconstruct the state using this log CopySet *RLockEntry // 2D array. Maps nodeID and remote address. Used for RLock calls to maintain copysets LockId string // For RLocks and WLocks, the LockID which the primary LM used should be replicated to the secondaries. Do not generate new LockIDs in the secondary CommitPoint uint64 // Operation number of the last committed operation Vn *Vnode // Identity of the VNode, can be extended to be used for sending out of band signals to the primary. }
Struct for the Log used for Lock state replication
type RLockEntry ¶
type Ring ¶
type Ring struct { // Implements: RingIntf // contains filtered or unexported fields }
Stores the state required for a Chord ring
func BlockingJoin ¶
BlockingJoin. Called by the buddynode that wants to block all operations until the network is healed.
Reason : All its operations should happen in its namespace. And its namespace i.e. the ring, specicifically the bootstrap members are present in the original ring
func (*Ring) GetHashFunc ¶
func (*Ring) GetLocalLocalVnode ¶
func (r *Ring) GetLocalLocalVnode() *localVnode
func (*Ring) GetLocalVnode ¶
func (*Ring) GetNumSuccessors ¶
func (*Ring) Less ¶
Less returns whether the vnode with index i should sort before the vnode with index j.
type TCPResponse ¶
type TCPResponseBody ¶
type TCPResponseBody interface { }
type TCPResponseImpl ¶
type TCPResponseImpl struct { Err string `json:"err,string,omitempty"` // Implements: TCPResponse `json:"-"` }
func (*TCPResponseImpl) Error ¶
func (t *TCPResponseImpl) Error() error
func (*TCPResponseImpl) SetError ¶
func (t *TCPResponseImpl) SetError(err error)
type TCPTransport ¶
type TCPTransport struct { // Implements: Transport // contains filtered or unexported fields }
TCPTransport provides a TCP based Chord transport layer. This allows Chord to be implemented over a network, instead of only using the LocalTransport. It is meant to be a simple implementation, optimizing for simplicity instead of performance. Messages are sent with a header frame, followed by a body frame. All data is encoded using the GOB format for simplicity.
Internally, there is 1 Goroutine listening for inbound connections, 1 Goroutine PER inbound connection.
func InitTCPTransport ¶
func InitTCPTransport(listen string, timeout time.Duration) (*TCPTransport, error)
Creates a new TCP transport on the given listen address with the configured timeout duration.
func (*TCPTransport) AbortWLock ¶
func (t *TCPTransport) AbortWLock(target *Vnode, key string, version uint, nodeID string, opsLogEntry *OpsLogEntry) (uint64, error)
AbortWLock transport layer implementation Param Vnode : The destination Vnode i.e. the Lock Manager Param key : The key for which the read lock should be obtained
func (*TCPTransport) BulkSet ¶
func (t *TCPTransport) BulkSet(target *Vnode, key string, valLst []KVStoreValue) error
func (*TCPTransport) ClearPredecessor ¶
func (t *TCPTransport) ClearPredecessor(target, self *Vnode) error
Clears a predecessor if it matches a given vnode. Used to leave.
func (*TCPTransport) CommitWLock ¶
func (t *TCPTransport) CommitWLock(target *Vnode, key string, version uint, nodeID string, opsLogEntry *OpsLogEntry) (uint64, error)
CommitWLock transport layer implementation Param Vnode : The destination Vnode i.e. the Lock Manager Param key : The key for which the read lock should be obtained Param version : The version of the key to be committed
func (*TCPTransport) FindSuccessors ¶
Find a successor
func (*TCPTransport) GetPredecessor ¶
func (t *TCPTransport) GetPredecessor(vn *Vnode) (*Vnode, error)
Request a nodes predecessor
func (*TCPTransport) GetPredecessorList ¶
func (t *TCPTransport) GetPredecessorList(vn *Vnode) ([]*Vnode, error)
Request a nodes predecessor list
func (*TCPTransport) InvalidateRLock ¶
func (t *TCPTransport) InvalidateRLock(target *Vnode, lockID string) error
InvalidateRLock transport layer implementation Param Vnode : The destination Vnode i.e. the Client where the RLock should be invalidated Param lockID : The exact lock to be invalidated
func (*TCPTransport) ListVnodes ¶
func (t *TCPTransport) ListVnodes(host string) ([]*Vnode, error)
Gets a list of the vnodes on the box
func (*TCPTransport) MissingKeys ¶
func (*TCPTransport) Notify ¶
func (t *TCPTransport) Notify(target, self *Vnode) ([]*Vnode, error)
Notify our successor of ourselves
func (*TCPTransport) Ping ¶
func (t *TCPTransport) Ping(vn *Vnode) (bool, error)
Ping a Vnode, check for liveness
func (*TCPTransport) PurgeVersions ¶
func (t *TCPTransport) PurgeVersions(target *Vnode, key string, maxVersion uint) error
func (*TCPTransport) RLock ¶
func (t *TCPTransport) RLock(target *Vnode, key string, nodeID string, opsLogEntry *OpsLogEntry) (string, uint, uint64, error)
RLock tranasport layer implementation Param Vnode : The destination Vnode i.e. the Lock Manager Param key : The key for which the read lock should be obtained
func (*TCPTransport) Register ¶
func (t *TCPTransport) Register(v *Vnode, o VnodeRPC)
Register for an RPC callbacks
func (*TCPTransport) SkipSuccessor ¶
func (t *TCPTransport) SkipSuccessor(target, self *Vnode) error
Instructs a node to skip a given successor. Used to leave.
func (*TCPTransport) WLock ¶
func (t *TCPTransport) WLock(target *Vnode, key string, version uint, timeout uint, nodeID string, opsLogEntry *OpsLogEntry) (string, uint, uint, uint64, error)
WLock transport layer implementation Param Vnode : The destination Vnode i.e. the Vnode with the Lock Manager Param key : The key for which the write lock should be obtained Param version : The version of the key Param timeout : Requested Timeout value. Param NodeID : NodeID of the requesting node
type TimeoutItem ¶
type TimeoutItem struct {
// contains filtered or unexported fields
}
TimeoutQueue based on PriorityQueue from http://golang.org/pkg/container/heap/
type TimeoutQueue ¶
type TimeoutQueue []*TimeoutItem
A TimeoutQueue implements heap.Interface and holds TimeoutItems.
func (*TimeoutQueue) Get ¶
func (pq *TimeoutQueue) Get(i int) *TimeoutItem
func (TimeoutQueue) Len ¶
func (pq TimeoutQueue) Len() int
func (TimeoutQueue) Less ¶
func (pq TimeoutQueue) Less(i, j int) bool
func (*TimeoutQueue) Peek ¶
func (pq *TimeoutQueue) Peek() *TimeoutItem
func (*TimeoutQueue) Pop ¶
func (pq *TimeoutQueue) Pop() interface{}
func (*TimeoutQueue) Push ¶
func (pq *TimeoutQueue) Push(x interface{})
func (TimeoutQueue) Swap ¶
func (pq TimeoutQueue) Swap(i, j int)
type Tracker ¶
type Tracker interface {
// contains filtered or unexported methods
}
func NewTracker ¶
func NewTracker() Tracker
func NewTrackerWithClock ¶
func NewTrackerWithClock(clock ClockIface) Tracker
func NewTrackerWithClockAndStore ¶
func NewTrackerWithClockAndStore(clock ClockIface, kvClient KVStoreClient) Tracker
func NewTrackerWithStore ¶
func NewTrackerWithStore(store KVStoreClient) Tracker
type TrackerClient ¶
func NewTrackerClient ¶
func NewTrackerClient(ring RingIntf) TrackerClient
type TrackerClientImpl ¶
type TrackerClientImpl struct {
// contains filtered or unexported fields
}
func (*TrackerClientImpl) JoinRing ¶
func (tr *TrackerClientImpl) JoinRing(ringId string, localOnly bool) (*Ring, error)
func (*TrackerClientImpl) LeaveRing ¶
func (tr *TrackerClientImpl) LeaveRing(ringId string) error
type TrackerImpl ¶
type TrackerImpl struct { // Implements: Tracker // contains filtered or unexported fields }
type Transport ¶
type Transport interface { // Gets a list of the vnodes on the box ListVnodes(string) ([]*Vnode, error) // Ping a Vnode, check for liveness Ping(*Vnode) (bool, error) // Request a nodes predecessor GetPredecessor(*Vnode) (*Vnode, error) // Notify our successor of ourselves Notify(target, self *Vnode) ([]*Vnode, error) // Find a successor FindSuccessors(*Vnode, int, []byte) ([]*Vnode, error) // Clears a predecessor if it matches a given vnode. Used to leave. ClearPredecessor(target, self *Vnode) error // Instructs a node to skip a given successor. Used to leave. SkipSuccessor(target, self *Vnode) error // Get the list of predecessors GetPredecessorList(*Vnode) ([]*Vnode, error) // Register for an RPC callbacks Register(*Vnode, VnodeRPC) // Lock Manager operations RLock(*Vnode, string, string, *OpsLogEntry) (string, uint, uint64, error) WLock(*Vnode, string, uint, uint, string, *OpsLogEntry) (string, uint, uint, uint64, error) CommitWLock(*Vnode, string, uint, string, *OpsLogEntry) (uint64, error) AbortWLock(*Vnode, string, uint, string, *OpsLogEntry) (uint64, error) InvalidateRLock(*Vnode, string) error // KV Store operations Get(target *Vnode, key string, version uint) ([]byte, error) Set(target *Vnode, key string, version uint, value []byte) error List(target *Vnode) ([]string, error) BulkSet(target *Vnode, key string, valLst []KVStoreValue) error SyncKeys(target *Vnode, ownerVn *Vnode, key string, ver []uint) error MissingKeys(target *Vnode, replVn *Vnode, key string, ver []uint) error PurgeVersions(target *Vnode, key string, maxVersion uint) error // Tracker operations JoinRing(target *Vnode, ringId string, self *Vnode) ([]*Vnode, error) LeaveRing(target *Vnode, ringId string) error // TODO: Is this the right place? IsLocalVnode(vn *Vnode) bool }
Implements the methods needed for a Chord ring
func InitLocalTransport ¶
Creates a local transport to wrap a remote transport
type Vnode ¶
type Vnode struct { Id []byte // Virtual ID Host string // Host identifier // contains filtered or unexported fields }
Represents an Vnode, local or remote
type VnodeRPC ¶
type VnodeRPC interface { GetPredecessor() (*Vnode, error) Notify(*Vnode) ([]*Vnode, error) FindSuccessors(int, []byte) ([]*Vnode, error) ClearPredecessor(*Vnode) error SkipSuccessor(*Vnode) error GetPredecessorList() ([]*Vnode, error) GetId() (string, error) // KV Store operations Get(key string, version uint) ([]byte, error) Set(key string, version uint, value []byte) error List() ([]string, error) BulkSet(key string, valLst []KVStoreValue) error SyncKeys(ownerVn *Vnode, key string, ver []uint) error MissingKeys(replVn *Vnode, key string, ver []uint) error PurgeVersions(key string, maxVersion uint) error // Lock Manager operations RLock(key string, nodeID string, remoteAddr string, opsLogEntry *OpsLogEntry) (string, uint, uint64, error) WLock(key string, version uint, timeout uint, nodeID string, opsLogEntry *OpsLogEntry) (string, uint, uint, uint64, error) CommitWLock(key string, version uint, nodeID string, opsLogEntry *OpsLogEntry) (uint64, error) AbortWLock(key string, version uint, nodeID string, opsLogEntry *OpsLogEntry) (uint64, error) InvalidateRLock(lockID string) error CheckWLock(key string) (bool, uint, error) UpdateVersionMap(versionMap *map[string]uint) // Tracker operations JoinRing(ringId string, self *Vnode) ([]*Vnode, error) LeaveRing(ringId string) error }
These are the methods to invoke on the registered vnodes
type WLockEntry ¶
type WLockEntry struct { LockID string // contains filtered or unexported fields }
TODO : Discuss : LockID is currently 160 bits long. Is that good enough?