Documentation ¶
Overview ¶
* Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. *
* Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. *
* Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. *
* Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. *
* Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. *
* Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. *
Index ¶
- Constants
- Variables
- type Cluster
- func (cluster *Cluster) AddNode(shardIndex int, addr, role, password string) error
- func (cluster *Cluster) GetNodes() []Node
- func (cluster *Cluster) GetShard(shardIndex int) (*Shard, error)
- func (cluster *Cluster) MigrateSlot(ctx context.Context, slot int, targetShardIdx int, slotOnly bool) error
- func (cluster *Cluster) PromoteNewMaster(ctx context.Context, shardIdx int, masterNodeID, preferredNodeID string) (string, error)
- func (cluster *Cluster) RemoveNode(shardIndex int, nodeID string) error
- func (cluster *Cluster) Reset(ctx context.Context) error
- func (cluster *Cluster) SetPassword(password string)
- func (cluster *Cluster) SetSlot(ctx context.Context, slot int, targetNodeID string) error
- func (cluster *Cluster) SyncToNodes(ctx context.Context) error
- func (cluster *Cluster) ToSlotString() (string, error)
- type ClusterInfo
- type ClusterMockNode
- func (mock *ClusterMockNode) GetClusterInfo(ctx context.Context) (*ClusterInfo, error)
- func (mock *ClusterMockNode) GetClusterNodeInfo(ctx context.Context) (*ClusterNodeInfo, error)
- func (mock *ClusterMockNode) Reset(ctx context.Context) error
- func (mock *ClusterMockNode) SyncClusterInfo(ctx context.Context, cluster *Cluster) error
- type ClusterNode
- func (n *ClusterNode) Addr() string
- func (n *ClusterNode) CheckClusterMode(ctx context.Context) (int64, error)
- func (n *ClusterNode) GetClient() *redis.Client
- func (n *ClusterNode) GetClusterInfo(ctx context.Context) (*ClusterInfo, error)
- func (n *ClusterNode) GetClusterNodeInfo(ctx context.Context) (*ClusterNodeInfo, error)
- func (n *ClusterNode) GetClusterNodesString(ctx context.Context) (string, error)
- func (n *ClusterNode) ID() string
- func (n *ClusterNode) IsMaster() bool
- func (n *ClusterNode) MarshalJSON() ([]byte, error)
- func (n *ClusterNode) MigrateSlot(ctx context.Context, slot int, targetNodeID string) error
- func (n *ClusterNode) Password() string
- func (n *ClusterNode) Reset(ctx context.Context) error
- func (n *ClusterNode) SetPassword(password string)
- func (n *ClusterNode) SetRole(role string)
- func (n *ClusterNode) SyncClusterInfo(ctx context.Context, cluster *Cluster) error
- func (n *ClusterNode) UnmarshalJSON(bytes []byte) error
- func (n *ClusterNode) Validate() error
- type ClusterNodeInfo
- type ClusterStore
- func (s *ClusterStore) CheckNewNodes(ctx context.Context, nodes []string) error
- func (s *ClusterStore) Close() error
- func (s *ClusterStore) CreateCluster(ctx context.Context, ns string, clusterInfo *Cluster) error
- func (s *ClusterStore) CreateNamespace(ctx context.Context, ns string) error
- func (s *ClusterStore) EmitEvent(event EventPayload)
- func (s *ClusterStore) ExistsNamespace(ctx context.Context, ns string) (bool, error)
- func (s *ClusterStore) GetCluster(ctx context.Context, ns, cluster string) (*Cluster, error)
- func (s *ClusterStore) ID() string
- func (s *ClusterStore) IsLeader() bool
- func (s *ClusterStore) IsReady(ctx context.Context) bool
- func (s *ClusterStore) Leader() string
- func (s *ClusterStore) LeaderChange() <-chan bool
- func (s *ClusterStore) ListCluster(ctx context.Context, ns string) ([]string, error)
- func (s *ClusterStore) ListNamespace(ctx context.Context) ([]string, error)
- func (s *ClusterStore) Notify() <-chan EventPayload
- func (s *ClusterStore) RemoveCluster(ctx context.Context, ns, cluster string) error
- func (s *ClusterStore) RemoveNamespace(ctx context.Context, ns string) error
- func (s *ClusterStore) SetCluster(ctx context.Context, ns string, clusterInfo *Cluster) error
- func (s *ClusterStore) Stop() error
- func (s *ClusterStore) UpdateCluster(ctx context.Context, ns string, clusterInfo *Cluster) error
- type Command
- type EventPayload
- type EventType
- type Node
- type Shard
- func (shard *Shard) ClearMigrateState()
- func (shard *Shard) GetMasterNode() Node
- func (shard *Shard) HasOverlap(slotRange *SlotRange) bool
- func (shard *Shard) IsMigrating() bool
- func (shard *Shard) IsServicing() bool
- func (shard *Shard) ToSlotsString() (string, error)
- func (shard *Shard) UnmarshalJSON(bytes []byte) error
- type Shards
- type SlotRange
- type SlotRanges
- type Store
Constants ¶
const ( RoleMaster = "master" RoleSlave = "slave" NodeIDLen = 40 )
const ( CommandCreate = iota + 1 CommandUpdate = iota + 1 CommandRemove )
const ( MinSlotID = 0 MaxSlotID = 16383 )
Variables ¶
var ErrSlotOutOfRange = errors.New("slot id was out of range, should be between 0 and 16383")
Functions ¶
This section is empty.
Types ¶
type Cluster ¶
type Cluster struct { Name string `json:"name"` Version atomic.Int64 `json:"version"` Shards []*Shard `json:"shards"` }
func ParseCluster ¶
ParseCluster will parse the cluster string into cluster topology.
func (*Cluster) MigrateSlot ¶
func (*Cluster) PromoteNewMaster ¶
func (*Cluster) RemoveNode ¶
func (*Cluster) SetPassword ¶
SetPassword will set the password for all nodes in the cluster.
func (*Cluster) ToSlotString ¶
type ClusterInfo ¶
type ClusterMockNode ¶
type ClusterMockNode struct { *ClusterNode Sequence uint64 }
ClusterMockNode is a mock implementation of the Node interface, it is used for testing purposes.
func NewClusterMockNode ¶
func NewClusterMockNode() *ClusterMockNode
func (*ClusterMockNode) GetClusterInfo ¶
func (mock *ClusterMockNode) GetClusterInfo(ctx context.Context) (*ClusterInfo, error)
func (*ClusterMockNode) GetClusterNodeInfo ¶
func (mock *ClusterMockNode) GetClusterNodeInfo(ctx context.Context) (*ClusterNodeInfo, error)
func (*ClusterMockNode) SyncClusterInfo ¶
func (mock *ClusterMockNode) SyncClusterInfo(ctx context.Context, cluster *Cluster) error
type ClusterNode ¶
type ClusterNode struct {
// contains filtered or unexported fields
}
func NewClusterNode ¶
func NewClusterNode(addr, password string) *ClusterNode
func (*ClusterNode) Addr ¶
func (n *ClusterNode) Addr() string
func (*ClusterNode) CheckClusterMode ¶
func (n *ClusterNode) CheckClusterMode(ctx context.Context) (int64, error)
func (*ClusterNode) GetClient ¶
func (n *ClusterNode) GetClient() *redis.Client
func (*ClusterNode) GetClusterInfo ¶
func (n *ClusterNode) GetClusterInfo(ctx context.Context) (*ClusterInfo, error)
func (*ClusterNode) GetClusterNodeInfo ¶
func (n *ClusterNode) GetClusterNodeInfo(ctx context.Context) (*ClusterNodeInfo, error)
func (*ClusterNode) GetClusterNodesString ¶
func (n *ClusterNode) GetClusterNodesString(ctx context.Context) (string, error)
func (*ClusterNode) ID ¶
func (n *ClusterNode) ID() string
func (*ClusterNode) IsMaster ¶
func (n *ClusterNode) IsMaster() bool
func (*ClusterNode) MarshalJSON ¶
func (n *ClusterNode) MarshalJSON() ([]byte, error)
func (*ClusterNode) MigrateSlot ¶
func (*ClusterNode) Password ¶
func (n *ClusterNode) Password() string
func (*ClusterNode) SetPassword ¶
func (n *ClusterNode) SetPassword(password string)
func (*ClusterNode) SetRole ¶
func (n *ClusterNode) SetRole(role string)
func (*ClusterNode) SyncClusterInfo ¶
func (n *ClusterNode) SyncClusterInfo(ctx context.Context, cluster *Cluster) error
func (*ClusterNode) UnmarshalJSON ¶
func (n *ClusterNode) UnmarshalJSON(bytes []byte) error
func (*ClusterNode) Validate ¶
func (n *ClusterNode) Validate() error
type ClusterNodeInfo ¶
type ClusterStore ¶
type ClusterStore struct {
// contains filtered or unexported fields
}
func NewClusterStore ¶
func NewClusterStore(e engine.Engine) *ClusterStore
func (*ClusterStore) CheckNewNodes ¶
func (s *ClusterStore) CheckNewNodes(ctx context.Context, nodes []string) error
func (*ClusterStore) Close ¶
func (s *ClusterStore) Close() error
func (*ClusterStore) CreateCluster ¶
func (*ClusterStore) CreateNamespace ¶
func (s *ClusterStore) CreateNamespace(ctx context.Context, ns string) error
CreateNamespace will create a namespace for clusters
func (*ClusterStore) EmitEvent ¶
func (s *ClusterStore) EmitEvent(event EventPayload)
func (*ClusterStore) ExistsNamespace ¶
ExistsNamespace return an indicator whether the specified namespace exists
func (*ClusterStore) GetCluster ¶
func (*ClusterStore) ID ¶
func (s *ClusterStore) ID() string
func (*ClusterStore) IsLeader ¶
func (s *ClusterStore) IsLeader() bool
func (*ClusterStore) Leader ¶
func (s *ClusterStore) Leader() string
func (*ClusterStore) LeaderChange ¶
func (s *ClusterStore) LeaderChange() <-chan bool
func (*ClusterStore) ListCluster ¶
ListCluster return the list of name of cluster under the specified namespace
func (*ClusterStore) ListNamespace ¶
func (s *ClusterStore) ListNamespace(ctx context.Context) ([]string, error)
ListNamespace return the list of name of all namespaces
func (*ClusterStore) Notify ¶
func (s *ClusterStore) Notify() <-chan EventPayload
func (*ClusterStore) RemoveCluster ¶
func (s *ClusterStore) RemoveCluster(ctx context.Context, ns, cluster string) error
func (*ClusterStore) RemoveNamespace ¶
func (s *ClusterStore) RemoveNamespace(ctx context.Context, ns string) error
RemoveNamespace delete the specified namespace from store
func (*ClusterStore) SetCluster ¶
func (*ClusterStore) Stop ¶
func (s *ClusterStore) Stop() error
func (*ClusterStore) UpdateCluster ¶
UpdateCluster update the Name to store under the specified namespace
type EventPayload ¶
type Node ¶
type Node interface { ID() string Password() string Addr() string IsMaster() bool SetRole(string) SetPassword(string) Reset(ctx context.Context) error GetClusterNodeInfo(ctx context.Context) (*ClusterNodeInfo, error) GetClusterInfo(ctx context.Context) (*ClusterInfo, error) SyncClusterInfo(ctx context.Context, cluster *Cluster) error CheckClusterMode(ctx context.Context) (int64, error) MigrateSlot(ctx context.Context, slot int, NodeID string) error MarshalJSON() ([]byte, error) UnmarshalJSON(data []byte) error }
type Shard ¶
type Shard struct { Nodes []Node `json:"nodes"` SlotRanges []SlotRange `json:"slot_ranges"` TargetShardIndex int `json:"target_shard_index"` MigratingSlot int `json:"migrating_slot"` }
func (*Shard) ClearMigrateState ¶
func (shard *Shard) ClearMigrateState()
func (*Shard) GetMasterNode ¶
func (*Shard) HasOverlap ¶
func (*Shard) IsMigrating ¶
func (*Shard) IsServicing ¶
func (*Shard) ToSlotsString ¶
func (*Shard) UnmarshalJSON ¶
UnmarshalJSON unmarshal a Shard from JSON bytes, it's required since Shard.Nodes is an interface slice. So we need to take into a concrete type.
type SlotRange ¶
func NewSlotRange ¶
func ParseSlotRange ¶
func (*SlotRange) HasOverlap ¶
func (*SlotRange) MarshalJSON ¶
func (*SlotRange) UnmarshalJSON ¶
type SlotRanges ¶
type SlotRanges []SlotRange
func AddSlotToSlotRanges ¶
func AddSlotToSlotRanges(source SlotRanges, slot int) SlotRanges
func CalculateSlotRanges ¶
func CalculateSlotRanges(n int) SlotRanges
func RemoveSlotFromSlotRanges ¶
func RemoveSlotFromSlotRanges(source SlotRanges, slot int) SlotRanges
func (*SlotRanges) Contains ¶
func (SlotRanges *SlotRanges) Contains(slot int) bool
type Store ¶
type Store interface { IsReady(ctx context.Context) bool ListNamespace(ctx context.Context) ([]string, error) CreateNamespace(ctx context.Context, ns string) error ExistsNamespace(ctx context.Context, ns string) (bool, error) RemoveNamespace(ctx context.Context, ns string) error ListCluster(ctx context.Context, ns string) ([]string, error) GetCluster(ctx context.Context, ns, cluster string) (*Cluster, error) RemoveCluster(ctx context.Context, ns, cluster string) error CreateCluster(ctx context.Context, ns string, cluster *Cluster) error UpdateCluster(ctx context.Context, ns string, cluster *Cluster) error SetCluster(ctx context.Context, ns string, clusterInfo *Cluster) error CheckNewNodes(ctx context.Context, nodes []string) error }
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
* Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements.
|
* Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. |
etcd
* Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements.
|
* Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. |
zookeeper
* Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements.
|
* Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. |