예제 #1
0
func NewZkReader(resolveLocal bool, preload []string) *ZkReader {
	zkr := &ZkReader{zcell: make(map[string]*zkCell), resolveLocal: resolveLocal}
	if resolveLocal {
		zkr.localCell = zk.GuessLocalCell()
	}

	stats.PublishFunc("ZkReader", func() string { return zkr.statsJSON() })

	// start some cells
	for _, cellName := range preload {
		_, path, err := zkr.getCell("/zk/" + cellName)
		if err != nil {
			log.Errorf("Cell " + cellName + " could not be preloaded: " + err.Error())
		} else {
			log.Infof("Cell " + cellName + " preloaded for: " + path)
		}
	}
	return zkr
}
예제 #2
0
파일: rpc.go 프로젝트: CERN-Stage-3/vitess
func NewZkReader(resolveLocal bool, preload []string) *ZkReader {
	zkr := &ZkReader{zcell: make(map[string]*zkCell), resolveLocal: resolveLocal}
	if resolveLocal {
		zkr.localCell = zk.GuessLocalCell()
	}
	zkr.rpcCalls = stats.NewInt("ZkReaderRpcCalls")
	zkr.unknownCellErrors = stats.NewInt("ZkReaderUnknownCellErrors")
	zkr.zkrStats = newZkrStats()

	stats.PublishJSONFunc("ZkReader", zkr.statsJSON)

	// start some cells
	for _, cellName := range preload {
		_, path, err := zkr.getCell("/zk/" + cellName)
		if err != nil {
			log.Errorf("Cell " + cellName + " could not be preloaded: " + err.Error())
		} else {
			log.Infof("Cell " + cellName + " preloaded for: " + path)
		}
	}
	return zkr
}