예제 #1
0
func (z *zkCluster) GetQueryNodes() ([]clustering.QueryNode, errors.Error) {
	impl, ok := getConfigStoreImplementation(z)
	if !ok {
		return nil, errors.NewAdminConnectionError(nil, z.ConfigurationStoreId())
	}
	qryNodes := []clustering.QueryNode{}
	nodes, _, err := impl.conn.Children("/" + z.Name())
	if err != nil {
		return nil, errors.NewAdminGetClusterError(err, z.Name())
	}
	for _, name := range nodes {
		nodePath := "/" + z.Name() + "/" + name
		data, _, err := impl.conn.Get(nodePath)
		if err != nil {
			return nil, errors.NewAdminGetNodeError(err, nodePath)
		}
		queryNode := &zkQueryNodeConfig{}
		err = json.Unmarshal(data, queryNode)
		if err != nil {
			return nil, errors.NewAdminDecodingError(err)
		}
		qryNodes = append(qryNodes, queryNode)
	}
	return qryNodes, nil
}
예제 #2
0
func (z *zkCluster) QueryNodeByName(name string) (clustering.QueryNode, errors.Error) {
	impl, ok := getConfigStoreImplementation(z)
	if !ok {
		return nil, errors.NewAdminConnectionError(nil, z.ConfigurationStoreId())
	}
	nodePath := "/" + z.ClusterName + "/" + name
	data, _, err := impl.conn.Get(nodePath)
	if err != nil {
		return nil, errors.NewAdminGetNodeError(err, nodePath)
	}
	var queryNode zkQueryNodeConfig
	err = json.Unmarshal(data, &queryNode)
	if err != nil {
		return nil, errors.NewAdminDecodingError(err)
	}
	return &queryNode, nil
}