예제 #1
0
func getSrvKeyspace(rpcClient *rpcplus.Client, cell, keyspace string, verbose bool) {
	req := &topo.GetSrvKeyspaceArgs{
		Cell:     cell,
		Keyspace: keyspace,
	}
	reply := &topo.SrvKeyspace{}
	if err := rpcClient.Call(context.TODO(), "TopoReader.GetSrvKeyspace", req, reply); err != nil {
		log.Fatalf("TopoReader.GetSrvKeyspace error: %v", err)
	}
	if verbose {
		tabletTypes := make([]string, 0, len(reply.Partitions))
		for t, _ := range reply.Partitions {
			tabletTypes = append(tabletTypes, string(t))
		}
		sort.Strings(tabletTypes)
		for _, t := range tabletTypes {
			println(fmt.Sprintf("Partitions[%v] =", t))
			for i, s := range reply.Partitions[topo.TabletType(t)].Shards {
				println(fmt.Sprintf("  Shards[%v]=%v", i, s.KeyRange.String()))
			}
		}
		for i, s := range reply.Shards {
			println(fmt.Sprintf("Shards[%v]=%v", i, s.KeyRange.String()))
		}
		for i, t := range reply.TabletTypes {
			println(fmt.Sprintf("TabletTypes[%v] = %v", i, t))
		}
	}
}
예제 #2
0
func get(rpcClient *rpcplus.Client, path string, verbose bool) {
	// it's a get
	zkPath := &zk.ZkPath{Path: path}
	zkNode := &zk.ZkNode{}
	if err := rpcClient.Call(context.TODO(), "ZkReader.Get", zkPath, zkNode); err != nil {
		log.Fatalf("ZkReader.Get error: %v", err)
	}
	if verbose {
		println(fmt.Sprintf("%v = %v (NumChildren=%v, Version=%v, Cached=%v, Stale=%v)", zkNode.Path, zkNode.Data, zkNode.Stat.NumChildren(), zkNode.Stat.Version(), zkNode.Cached, zkNode.Stale))
	}

}
예제 #3
0
func getSrvKeyspaceNames(rpcClient *rpcplus.Client, cell string, verbose bool) {
	req := &topo.GetSrvKeyspaceNamesArgs{
		Cell: cell,
	}
	reply := &topo.SrvKeyspaceNames{}
	if err := rpcClient.Call(context.TODO(), "TopoReader.GetSrvKeyspaceNames", req, reply); err != nil {
		log.Fatalf("TopoReader.GetSrvKeyspaceNames error: %v", err)
	}
	if verbose {
		for i, entry := range reply.Entries {
			println(fmt.Sprintf("KeyspaceNames[%v] = %v", i, entry))
		}
	}
}
예제 #4
0
func getv(rpcClient *rpcplus.Client, paths []string, verbose bool) {
	zkPathV := &zk.ZkPathV{Paths: make([]string, len(paths))}
	for i, v := range paths {
		zkPathV.Paths[i] = v
	}
	zkNodeV := &zk.ZkNodeV{}
	if err := rpcClient.Call(context.TODO(), "ZkReader.GetV", zkPathV, zkNodeV); err != nil {
		log.Fatalf("ZkReader.GetV error: %v", err)
	}
	if verbose {
		for i, zkNode := range zkNodeV.Nodes {
			println(fmt.Sprintf("[%v] %v = %v (NumChildren=%v, Version=%v, Cached=%v, Stale=%v)", i, zkNode.Path, zkNode.Data, zkNode.Stat.NumChildren(), zkNode.Stat.Version(), zkNode.Cached, zkNode.Stale))
		}
	}
}
예제 #5
0
func getEndPoints(rpcClient *rpcplus.Client, cell, keyspace, shard, tabletType string, verbose bool) {
	req := &topo.GetEndPointsArgs{
		Cell:       cell,
		Keyspace:   keyspace,
		Shard:      shard,
		TabletType: topo.TabletType(tabletType),
	}
	reply := &topo.EndPoints{}
	if err := rpcClient.Call(context.TODO(), "TopoReader.GetEndPoints", req, reply); err != nil {
		log.Fatalf("TopoReader.GetEndPoints error: %v", err)
	}
	if verbose {
		for i, e := range reply.Entries {
			println(fmt.Sprintf("Entries[%v] = %v %v", i, e.Uid, e.Host))
		}
	}
}
예제 #6
0
func children(rpcClient *rpcplus.Client, paths []string, verbose bool) {
	for _, v := range paths {
		zkPath := &zk.ZkPath{Path: v}
		zkNode := &zk.ZkNode{}
		if err := rpcClient.Call(context.TODO(), "ZkReader.Children", zkPath, zkNode); err != nil {
			log.Fatalf("ZkReader.Children error: %v", err)
		}
		if verbose {
			println(fmt.Sprintf("Path = %v", zkNode.Path))
			for i, child := range zkNode.Children {
				println(fmt.Sprintf("Child[%v] = %v", i, child))
			}
			println(fmt.Sprintf("NumChildren = %v", zkNode.Stat.NumChildren()))
			println(fmt.Sprintf("CVersion = %v", zkNode.Stat.CVersion()))
			println(fmt.Sprintf("Cached = %v", zkNode.Cached))
			println(fmt.Sprintf("Stale = %v", zkNode.Stale))
		}
	}
}