MCPcopy Index your code
hub / github.com/CodisLabs/codis / handleConfigRestore

Method handleConfigRestore

cmd/admin/admin.go:354–399  ·  view source on GitHub ↗
(d map[string]interface{})

Source from the content-addressed store, hash-verified

352}
353
354func (t *cmdAdmin) handleConfigRestore(d map[string]interface{}) {
355 store := t.newTopomStore(d)
356 defer store.Close()
357
358 config := t.loadJsonConfigV3(utils.ArgumentMust(d, "--config-restore"))
359
360 if !d["--confirm"].(bool) {
361 b, err := json.MarshalIndent(config, "", " ")
362 if err != nil {
363 log.PanicErrorf(err, "json marshal failed")
364 }
365 fmt.Println(string(b))
366 return
367 }
368
369 proxy, err := store.ListProxy()
370 if err != nil {
371 log.PanicErrorf(err, "list proxy failed")
372 }
373 group, err := store.ListGroup()
374 if err != nil {
375 log.PanicErrorf(err, "list group failed")
376 }
377
378 if len(group) != 0 || len(proxy) != 0 {
379 log.Panicf("product %s is not empty", t.product)
380 }
381
382 for _, s := range config.Slots {
383 if err := store.UpdateSlotMapping(s); err != nil {
384 log.PanicErrorf(err, "restore slot-%04d failed", s.Id)
385 }
386 }
387
388 for _, g := range config.Group {
389 if err := store.UpdateGroup(g); err != nil {
390 log.PanicErrorf(err, "restore group-%04d failed", g.Id)
391 }
392 }
393
394 for _, p := range config.Proxy {
395 if err := store.UpdateProxy(p); err != nil {
396 log.PanicErrorf(err, "restore proxy-%s failed", p.Token)
397 }
398 }
399}
400
401func (t *cmdAdmin) handleDashboardList(d map[string]interface{}) {
402 client := t.newTopomClient(d)

Callers 1

MainMethod · 0.95

Calls 11

newTopomStoreMethod · 0.95
loadJsonConfigV3Method · 0.95
PanicErrorfMethod · 0.80
PrintlnMethod · 0.80
ListProxyMethod · 0.80
ListGroupMethod · 0.80
PanicfMethod · 0.80
UpdateSlotMappingMethod · 0.80
UpdateGroupMethod · 0.80
UpdateProxyMethod · 0.80
CloseMethod · 0.65

Tested by

no test coverage detected