Exemple #1
0
// NewClient creates a new HBase client.
func NewClient(zkquorum string, options ...Option) *Client {
	log.WithFields(log.Fields{
		"Host": zkquorum,
	}).Debug("Creating new client.")
	c := &Client{
		clientType: StandardClient,
		regions:    keyRegionCache{regions: b.TreeNew(regioninfo.CompareGeneric)},
		clients: regionClientCache{
			clients:        make(map[*regioninfo.Info]*region.Client),
			clientsToInfos: make(map[*region.Client][]*regioninfo.Info),
		},
		zkquorum:      zkquorum,
		rpcQueueSize:  100,
		flushInterval: 20 * time.Millisecond,
		metaRegionInfo: &regioninfo.Info{
			Table:      []byte("hbase:meta"),
			RegionName: []byte("hbase:meta,,1"),
			StopKey:    []byte{},
		},
		adminRegionInfo: &regioninfo.Info{},
	}
	for _, option := range options {
		option(c)
	}
	if c.master == (zk.ResourceName)("") {
		c.master = zk.ResourceName("/hbase/master")
	}
	if c.meta == (zk.ResourceName)("") {
		c.meta = zk.ResourceName("/hbase/meta-region-server")
	}
	return c
}
Exemple #2
0
func newClient(zkquorum string, options ...Option) *client {
	log.WithFields(log.Fields{
		"Host": zkquorum,
	}).Debug("Creating new client.")
	c := &client{
		clientType: standardClient,
		regions:    keyRegionCache{regions: b.TreeNew(region.CompareGeneric)},
		clients: clientRegionCache{
			regions: make(map[hrpc.RegionClient][]hrpc.RegionInfo),
		},
		zkquorum:      zkquorum,
		rpcQueueSize:  100,
		flushInterval: 20 * time.Millisecond,
		metaRegionInfo: region.NewInfo(
			[]byte("hbase:meta"),
			[]byte("hbase:meta,,1"),
			nil,
			nil),
		adminRegionInfo: region.NewInfo(
			nil,
			nil,
			nil,
			nil),
		zkClient: zk.NewClient(zkquorum),
	}
	for _, option := range options {
		option(c)
	}
	if c.master == (zk.ResourceName)("") {
		c.master = zk.ResourceName("/hbase/master")
	}
	if c.meta == (zk.ResourceName)("") {
		c.meta = zk.ResourceName("/hbase/meta-region-server")
	}
	return c
}