Example #1
0
func main() {
	if len(os.Args) < 2 {
		fmt.Println("usage: %s hfileserver")
		os.Exit(1)
	}

	url := os.Args[1]

	if !strings.Contains(url, "/") {
		url = url + "/rpc/HFileService"
	}
	if !strings.HasPrefix(url, "http") {
		url = "http://" + url
	}

	recv, send := thriftrpc.NewClientProts(url, false)
	client := gen.NewHFileServiceClientProtocol(nil, recv, send)

	r := &gen.InfoRequest{nil, nil}
	if resp, err := client.GetInfo(r); err != nil {
		fmt.Println("Error getting info:", err)
		os.Exit(1)
	} else {
		for _, v := range resp {
			fmt.Printf("%s:\n", v.GetName())
			fmt.Printf("\tpath:\t%s\n", removeWebhdfs(v.GetPath()))
			fmt.Printf("\tkeys:\t%d\n", v.GetNumElements())
			fmt.Printf("\tstart:\t%s\n", hex.EncodeToString(v.GetFirstKey()))
			fmt.Printf("\tend:\t%s\n", hex.EncodeToString(v.GetLastKey()))
		}
	}
}
Example #2
0
func DummyClient(url string, compact bool) *gen.HFileServiceClient {
	recv, send := thriftrpc.NewClientProts(url, compact)
	return gen.NewHFileServiceClientProtocol(nil, recv, send)
}