Documentation ¶
Overview ¶
Package hexaring is a generated protocol buffer package.
It is generated from these files:
structs.proto
It has these top-level messages:
Location LookupRequest LookupResponse
Index ¶
- func BuildReplicaHashes(key []byte, count int64, h hash.Hash) [][]byte
- func CalculateRingVertexBytes(hash []byte, count int64) [][]byte
- func CalculateRingVertexes(hash []byte, count int64) []*big.Int
- func DefaultConfig(hostname string) *chord.Config
- func RegisterLookupRPCServer(s *grpc.Server, srv LookupRPCServer)
- type InMemPeerStore
- type Location
- func (*Location) Descriptor() ([]byte, []int)
- func (m *Location) GetID() []byte
- func (m *Location) GetIndex() int32
- func (m *Location) GetPriority() int32
- func (m *Location) GetVnode() *chord.Vnode
- func (loc *Location) Host() string
- func (loc Location) MarshalJSON() ([]byte, error)
- func (*Location) ProtoMessage()
- func (m *Location) Reset()
- func (m *Location) String() string
- type LocationSet
- func (locs LocationSet) EndRange(locID []byte) (end []byte, err error)
- func (locs LocationSet) GetByHost(host string) (*Location, error)
- func (locs LocationSet) GetNext(host string) (*Location, error)
- func (locs LocationSet) NaturalRange() (start []byte, end []byte)
- func (locs LocationSet) String() string
- type LookupRPCClient
- type LookupRPCServer
- type LookupRequest
- type LookupResponse
- type NetClient
- func (client *NetClient) Lookup(host string, n int32, key []byte) ([]*chord.Vnode, error)
- func (client *NetClient) LookupHash(host string, n int32, hash []byte) ([]*chord.Vnode, error)
- func (client *NetClient) LookupReplicated(host string, key []byte, n int32) ([]*Location, error)
- func (client *NetClient) LookupReplicatedHash(host string, hash []byte, n int32) ([]*Location, error)
- func (client *NetClient) Shutdown()
- type NetTransport
- func (trans *NetTransport) LookupHashRPC(ctx context.Context, req *LookupRequest) (*LookupResponse, error)
- func (trans *NetTransport) LookupRPC(ctx context.Context, req *LookupRequest) (*LookupResponse, error)
- func (trans *NetTransport) LookupReplicatedHashRPC(ctx context.Context, req *LookupRequest) (*LookupResponse, error)
- func (trans *NetTransport) LookupReplicatedRPC(ctx context.Context, req *LookupRequest) (*LookupResponse, error)
- func (trans *NetTransport) RegisterServer(server *grpc.Server)
- type Peer
- type PeerJSONStore
- type PeerStore
- type Ring
- func (r *Ring) Create() error
- func (r *Ring) Hostname() string
- func (r *Ring) Join() error
- func (r *Ring) LookupReplicated(key []byte, n int) (LocationSet, error)
- func (r *Ring) LookupReplicatedHash(hash []byte, n int) (LocationSet, error)
- func (r *Ring) LookupReplicatedHashSerial(hash []byte, n int) (LocationSet, error)
- func (r *Ring) NumSuccessors() int
- func (r *Ring) RegisterServer(server *grpc.Server)
- func (r *Ring) RetryJoin() error
- func (r *Ring) Scour(locs LocationSet, cb func(*chord.Vnode) error) (int, error)
- func (r *Ring) ScourReplica(locID []byte, cb func(*chord.Vnode) error) (int, error)
- func (r *Ring) ScourReplicatedKey(key []byte, replicas int, cb func(*chord.Vnode) error) (int, error)
- func (r *Ring) ScourSector(start, end []byte, cb func(*chord.Vnode) error) (int, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildReplicaHashes ¶
BuildReplicaHashes hashes the given key and build the required additional hashes returning the requested count of hashes.
func CalculateRingVertexBytes ¶
CalculateRingVertexBytes returns the a slice of bytes one for each vertex
func CalculateRingVertexes ¶
CalculateRingVertexes returns the requested number of vertexes around the ring equi-distant from each other except for potentially the last one which may be larger
func DefaultConfig ¶
DefaultConfig returns a sane config
func RegisterLookupRPCServer ¶
func RegisterLookupRPCServer(s *grpc.Server, srv LookupRPCServer)
Types ¶
type InMemPeerStore ¶
type InMemPeerStore struct {
// contains filtered or unexported fields
}
InMemPeerStore implements an in-memory PeerStore interface
func NewInMemPeerStore ¶
func NewInMemPeerStore() *InMemPeerStore
NewInMemPeerStore instantiates a new in-memory peer store
func (*InMemPeerStore) AddPeer ¶
func (ps *InMemPeerStore) AddPeer(peer string) bool
AddPeer adds the given peer to the store. If it exists then the last seen time is updated and false is returned
func (*InMemPeerStore) Peers ¶
func (ps *InMemPeerStore) Peers() []string
Peers returns a slice of all known peers
func (*InMemPeerStore) RemovePeer ¶
func (ps *InMemPeerStore) RemovePeer(peer string)
RemovePeer removes a peer from the store.
type Location ¶
type Location struct { ID []byte `protobuf:"bytes,1,opt,name=ID,json=iD,proto3" json:"ID,omitempty"` // Priority among locations in a set Priority int32 `protobuf:"varint,2,opt,name=Priority,json=priority" json:"Priority,omitempty"` // Index within location group Index int32 `protobuf:"varint,3,opt,name=Index,json=index" json:"Index,omitempty"` // Vnode for location id Vnode *chord.Vnode `protobuf:"bytes,4,opt,name=Vnode,json=vnode" json:"Vnode,omitempty"` }
func (*Location) Descriptor ¶
func (*Location) GetPriority ¶
func (Location) MarshalJSON ¶
MarshalJSON is a custom Location json marshaller
func (*Location) ProtoMessage ¶
func (*Location) ProtoMessage()
type LocationSet ¶
type LocationSet []*Location
LocationSet is a set of locations responsible for a key.
func (LocationSet) EndRange ¶
func (locs LocationSet) EndRange(locID []byte) (end []byte, err error)
EndRange returns the ending range for the given starting location id. It returns an error if the location is not in the set
func (LocationSet) GetByHost ¶
func (locs LocationSet) GetByHost(host string) (*Location, error)
GetByHost returns a location by the given host or a not found error otherwise
func (LocationSet) GetNext ¶
func (locs LocationSet) GetNext(host string) (*Location, error)
GetNext returns the next location after the given host
func (LocationSet) NaturalRange ¶
func (locs LocationSet) NaturalRange() (start []byte, end []byte)
NaturalRange returns the hash range for the natural key hash
func (LocationSet) String ¶
func (locs LocationSet) String() string
type LookupRPCClient ¶
type LookupRPCClient interface { LookupRPC(ctx context.Context, in *LookupRequest, opts ...grpc.CallOption) (*LookupResponse, error) LookupHashRPC(ctx context.Context, in *LookupRequest, opts ...grpc.CallOption) (*LookupResponse, error) LookupReplicatedRPC(ctx context.Context, in *LookupRequest, opts ...grpc.CallOption) (*LookupResponse, error) LookupReplicatedHashRPC(ctx context.Context, in *LookupRequest, opts ...grpc.CallOption) (*LookupResponse, error) }
func NewLookupRPCClient ¶
func NewLookupRPCClient(cc *grpc.ClientConn) LookupRPCClient
type LookupRPCServer ¶
type LookupRPCServer interface { LookupRPC(context.Context, *LookupRequest) (*LookupResponse, error) LookupHashRPC(context.Context, *LookupRequest) (*LookupResponse, error) LookupReplicatedRPC(context.Context, *LookupRequest) (*LookupResponse, error) LookupReplicatedHashRPC(context.Context, *LookupRequest) (*LookupResponse, error) }
type LookupRequest ¶
type LookupRequest struct { Key []byte `protobuf:"bytes,1,opt,name=Key,json=key,proto3" json:"Key,omitempty"` N int32 `protobuf:"varint,2,opt,name=N,json=n" json:"N,omitempty"` }
func (*LookupRequest) Descriptor ¶
func (*LookupRequest) Descriptor() ([]byte, []int)
func (*LookupRequest) GetKey ¶
func (m *LookupRequest) GetKey() []byte
func (*LookupRequest) GetN ¶
func (m *LookupRequest) GetN() int32
func (*LookupRequest) ProtoMessage ¶
func (*LookupRequest) ProtoMessage()
func (*LookupRequest) Reset ¶
func (m *LookupRequest) Reset()
func (*LookupRequest) String ¶
func (m *LookupRequest) String() string
type LookupResponse ¶
type LookupResponse struct { Locations []*Location `protobuf:"bytes,1,rep,name=Locations,json=locations" json:"Locations,omitempty"` Vnodes []*chord.Vnode `protobuf:"bytes,2,rep,name=Vnodes,json=vnodes" json:"Vnodes,omitempty"` }
func (*LookupResponse) Descriptor ¶
func (*LookupResponse) Descriptor() ([]byte, []int)
func (*LookupResponse) GetLocations ¶
func (m *LookupResponse) GetLocations() []*Location
func (*LookupResponse) GetVnodes ¶
func (m *LookupResponse) GetVnodes() []*chord.Vnode
func (*LookupResponse) ProtoMessage ¶
func (*LookupResponse) ProtoMessage()
func (*LookupResponse) Reset ¶
func (m *LookupResponse) Reset()
func (*LookupResponse) String ¶
func (m *LookupResponse) String() string
type NetClient ¶
type NetClient struct {
// contains filtered or unexported fields
}
NetClient provides RPC calls to the ring
func NewNetClient ¶
NewNetClient instantiates a new NetClient. It takes the max connection idle time as an argument
func (*NetClient) LookupHash ¶
LookupHash performs a LookupHash on a host
func (*NetClient) LookupReplicated ¶
LookupReplicated performs LookupReplicated request on a host
type NetTransport ¶
type NetTransport struct {
// contains filtered or unexported fields
}
NetTransport implements the server side lookup interface
func NewNetTransport ¶
func NewNetTransport(r *Ring) *NetTransport
NewNetTransport instantiates a new network transport to serve client ring requests
func (*NetTransport) LookupHashRPC ¶
func (trans *NetTransport) LookupHashRPC(ctx context.Context, req *LookupRequest) (*LookupResponse, error)
LookupHashRPC serves a LookupHash request
func (*NetTransport) LookupRPC ¶
func (trans *NetTransport) LookupRPC(ctx context.Context, req *LookupRequest) (*LookupResponse, error)
LookupRPC serves a Lookup request
func (*NetTransport) LookupReplicatedHashRPC ¶
func (trans *NetTransport) LookupReplicatedHashRPC(ctx context.Context, req *LookupRequest) (*LookupResponse, error)
LookupReplicatedHashRPC serves a LookupReplicatedHash request
func (*NetTransport) LookupReplicatedRPC ¶
func (trans *NetTransport) LookupReplicatedRPC(ctx context.Context, req *LookupRequest) (*LookupResponse, error)
LookupReplicatedRPC serves a LookupReplicated request
func (*NetTransport) RegisterServer ¶
func (trans *NetTransport) RegisterServer(server *grpc.Server)
type PeerJSONStore ¶
type PeerJSONStore struct { *InMemPeerStore // contains filtered or unexported fields }
PeerJSONStore implements a json file based PeerStore interface it inherits the in-memory interface for caching
func NewPeerJSONStore ¶
func NewPeerJSONStore(filename string) (*PeerJSONStore, error)
NewPeerJSONStore implements a JSON PeerStore with an in-memory store for caching
func (*PeerJSONStore) AddPeer ¶
func (ps *PeerJSONStore) AddPeer(peer string) bool
AddPeer adds a peer to the json store
func (*PeerJSONStore) Commit ¶
func (ps *PeerJSONStore) Commit() error
Commit writes the in-memory peer list to the stable store.
type Ring ¶
Ring is a node part of the chord ring allowing to perform ring operations. This is used on peers participating in the ring.
func New ¶
New instantiates a new ring func New(conf *Config, peers PeerStore, rpcTimeout, maxConnIdle time.Duration) *Ring {
func (*Ring) LookupReplicated ¶
func (r *Ring) LookupReplicated(key []byte, n int) (LocationSet, error)
LookupReplicated returns vnodes where a key and n replicas are located.
func (*Ring) LookupReplicatedHash ¶
func (r *Ring) LookupReplicatedHash(hash []byte, n int) (LocationSet, error)
LookupReplicatedHash returns vnodes where a key and n replicas are located. Each replica call is performed in its own go-routine. Each replica returned is a unique node. It returns a n error if the lookup fails or enough unique nodes are not found.
func (*Ring) LookupReplicatedHashSerial ¶
func (r *Ring) LookupReplicatedHashSerial(hash []byte, n int) (LocationSet, error)
LookupReplicatedHashSerial returns vnodes where a key and n replicas are located. Each replica returned is a unique node. It returns a n error if the lookup fails or enough unique nodes are not found.
func (*Ring) NumSuccessors ¶
NumSuccessors returns the num of succesors per the config.
func (*Ring) RegisterServer ¶
RegisterServer registers the underlying transport to the grpc server
func (*Ring) RetryJoin ¶
RetryJoin keeps looping through the available peers to join. It implements a backoff for each retry
func (*Ring) Scour ¶
Scour traverses each location up to the allowed number of succesors, issueing the callback for each node. It skips nodes that have already been visited. If the callback returns an error, it is immediately exits. It returns the number of nodes visited and/or an error either from the lookup or callback.
func (*Ring) ScourReplica ¶
ScourReplica scours a replica location id upto the allowable number of vnodes.