Skip to content

Commit

Permalink
fix: create cluster with password
Browse files Browse the repository at this point in the history
  • Loading branch information
PoplarYang committed Sep 12, 2020
1 parent b57f66e commit 89485bd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 17 deletions.
28 changes: 12 additions & 16 deletions clusternode.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"os"

"github.com/Sirupsen/logrus"
"github.com/codegangsta/cli"
"github.com/garyburd/redigo/redis"
)

Expand Down Expand Up @@ -41,12 +40,6 @@ type NodeInfo struct {
importing map[int]string
}

func (ni *NodeInfo) SetPassword(context *cli.Context) {
if context.String("password") != "" {
ni.password = context.String("password")
}
}

func (ni *NodeInfo) HasFlag(flag string) bool {
for _, f := range ni.flags {
if strings.Contains(f, flag) {
Expand All @@ -66,8 +59,8 @@ type ClusterNode struct {
r redis.Conn
info *NodeInfo
dirty bool
friends [](*NodeInfo)
replicasNodes [](*ClusterNode)
friends []*NodeInfo
replicasNodes []*ClusterNode
verbose bool
}

Expand Down Expand Up @@ -427,23 +420,26 @@ func (cn *ClusterNode) FlushNodeConfig() {
return
}
} else {
// TODO: run addslots cmd
var array []int
for s, value := range cn.Slots() {
for slot, value := range cn.Slots() {
if value == NewHashSlot {
array = append(array, s)
cn.info.slots[s] = AssignedHashSlot
array = append(array, slot)
cn.info.slots[slot] = AssignedHashSlot
_, err := cn.ClusterAddSlots(slot)
if err != nil {
logrus.Printf("ClusterAddSlots slot: %s with error %s", slot, err)
return
}
}
cn.ClusterAddSlots(array)
}
}

}
cn.dirty = false
}

// XXX: check the error for call CLUSTER addslots
func (cn *ClusterNode) ClusterAddSlots(args ...interface{}) (ret string, err error) {
return redis.String(cn.Call("CLUSTER", "addslots", args))
return redis.String(cn.Call("CLUSTER", "addslots", args[0]))
}

// XXX: check the error for call CLUSTER delslots
Expand Down
2 changes: 1 addition & 1 deletion create.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ func (rt *RedisTrib) AllocSlots() {

// Select master instances
logrus.Printf("Using %d masters:", mastersNum)
var interleaved [](*ClusterNode)
var interleaved []*ClusterNode
stop := false
for !stop {
// Take one node from each IP until we run out of nodes
Expand Down

0 comments on commit 89485bd

Please sign in to comment.