Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
02697ca725 | |||
bd693c7069 | |||
52c90cdcfb | |||
a88b22ac0a | |||
e93f8b8a12 |
@ -26,6 +26,7 @@ func NewImportSnapCommand() cli.Command {
|
|||||||
Usage: "import a snapshot to a cluster",
|
Usage: "import a snapshot to a cluster",
|
||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
cli.StringFlag{Name: "snap", Value: "", Usage: "Path to the vaild etcd 0.4.x snapshot."},
|
cli.StringFlag{Name: "snap", Value: "", Usage: "Path to the vaild etcd 0.4.x snapshot."},
|
||||||
|
cli.StringSliceFlag{Name: "hidden", Value: new(cli.StringSlice), Usage: "Hidden key spaces to import from snapshot"},
|
||||||
cli.IntFlag{Name: "c", Value: 10, Usage: "Number of concurrent clients to import the data"},
|
cli.IntFlag{Name: "c", Value: 10, Usage: "Number of concurrent clients to import the data"},
|
||||||
},
|
},
|
||||||
Action: handleImportSnap,
|
Action: handleImportSnap,
|
||||||
@ -36,7 +37,7 @@ func handleImportSnap(c *cli.Context) {
|
|||||||
d, err := ioutil.ReadFile(c.String("snap"))
|
d, err := ioutil.ReadFile(c.String("snap"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if c.String("snap") == "" {
|
if c.String("snap") == "" {
|
||||||
fmt.Printf("no snapshot file provided (use --snap)")
|
fmt.Printf("no snapshot file provided (use --snap)\n")
|
||||||
} else {
|
} else {
|
||||||
fmt.Printf("cannot read snapshot file %s\n", c.String("snap"))
|
fmt.Printf("cannot read snapshot file %s\n", c.String("snap"))
|
||||||
}
|
}
|
||||||
@ -83,6 +84,15 @@ func handleImportSnap(c *cli.Context) {
|
|||||||
handleError(ErrorFromEtcd, err)
|
handleError(ErrorFromEtcd, err)
|
||||||
}
|
}
|
||||||
n := copyKeys(all.Node, setc)
|
n := copyKeys(all.Node, setc)
|
||||||
|
|
||||||
|
hiddens := c.StringSlice("hidden")
|
||||||
|
for _, h := range hiddens {
|
||||||
|
allh, err := st.Get(h, true, true)
|
||||||
|
if err != nil {
|
||||||
|
handleError(ErrorFromEtcd, err)
|
||||||
|
}
|
||||||
|
n += copyKeys(allh.Node, setc)
|
||||||
|
}
|
||||||
close(setc)
|
close(setc)
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
fmt.Printf("finished importing %d keys\n", n)
|
fmt.Printf("finished importing %d keys\n", n)
|
||||||
|
@ -119,7 +119,6 @@ func (h *keysHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
writeError(w, err)
|
writeError(w, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
case resp.Event != nil:
|
case resp.Event != nil:
|
||||||
if err := writeKeyEvent(w, resp.Event, h.timer); err != nil {
|
if err := writeKeyEvent(w, resp.Event, h.timer); err != nil {
|
||||||
|
@ -84,7 +84,6 @@ func (wh *watcherHub) watch(key string, recursive, stream bool, index, storeInde
|
|||||||
|
|
||||||
if ok { // add the new watcher to the back of the list
|
if ok { // add the new watcher to the back of the list
|
||||||
elem = l.PushBack(w)
|
elem = l.PushBack(w)
|
||||||
|
|
||||||
} else { // create a new list and add the new watcher
|
} else { // create a new list and add the new watcher
|
||||||
l = list.New()
|
l = list.New()
|
||||||
elem = l.PushBack(w)
|
elem = l.PushBack(w)
|
||||||
@ -146,6 +145,7 @@ func (wh *watcherHub) notifyWatchers(e *Event, nodePath string, deleted bool) {
|
|||||||
// if we successfully notify a watcher
|
// if we successfully notify a watcher
|
||||||
// we need to remove the watcher from the list
|
// we need to remove the watcher from the list
|
||||||
// and decrease the counter
|
// and decrease the counter
|
||||||
|
w.removed = true
|
||||||
l.Remove(curr)
|
l.Remove(curr)
|
||||||
atomic.AddInt64(&wh.count, -1)
|
atomic.AddInt64(&wh.count, -1)
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
Version = "2.0.8"
|
Version = "2.0.9"
|
||||||
)
|
)
|
||||||
|
|
||||||
// WalVersion is an enum for versions of etcd logs.
|
// WalVersion is an enum for versions of etcd logs.
|
||||||
|
Reference in New Issue
Block a user