Пример #1
0
// Helper method to retrieve Couchbase services data (/pools/default/nodeServices)
// and Couchbase pool (cluster) data (/pools/default)
//
func (this *cbConfigStore) getPoolServices(name string) (*couchbase.Pool, *couchbase.PoolServices, errors.Error) {
	nodeServices, err := this.cbConn.GetPoolServices(name)
	if err != nil {
		return nil, nil, errors.NewAdminGetClusterError(err, name)
	}

	pool, err := this.cbConn.GetPool(name)
	if err != nil {
		return nil, nil, errors.NewAdminGetClusterError(err, name)
	}

	return &pool, &nodeServices, nil
}
Пример #2
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
}
Пример #3
0
func (z *zkConfigStore) ClusterNames() ([]string, errors.Error) {
	clusterIds := []string{}
	nodes, _, err := z.conn.Children("/")
	if err != nil {
		return nil, errors.NewAdminGetClusterError(err, "/")
	}
	for _, name := range nodes {
		clusterIds = append(clusterIds, name)
	}
	return clusterIds, nil
}
Пример #4
0
func (this *cbConfigStore) ClusterByName(name string) (clustering.Cluster, errors.Error) {
	_, err := this.cbConn.GetPool(name)
	if err != nil {
		return nil, errors.NewAdminGetClusterError(err, name)
	}
	return &cbCluster{
		configStore:    this,
		ClusterName:    name,
		ConfigstoreURI: this.URL(),
		DatastoreURI:   this.URL(),
	}, nil
}
Пример #5
0
func (z *zkConfigStore) ClusterByName(name string) (clustering.Cluster, errors.Error) {
	data, _, err := z.conn.Get("/" + name)
	if err != nil {
		return nil, errors.NewAdminGetClusterError(err, name)
	}
	var clusterConfig zkCluster
	err = json.Unmarshal(data, &clusterConfig)
	if err != nil {
		return nil, errors.NewAdminDecodingError(err)
	}
	clusterConfig.configStore = z
	return &clusterConfig, nil
}
Пример #6
0
func (z *zkConfigStore) GetClusters() ([]clustering.Cluster, errors.Error) {
	clusters := []clustering.Cluster{}
	nodes, _, err := z.conn.Children("/")
	if err != nil {
		return nil, errors.NewAdminGetClusterError(err, "/")
	}
	for _, name := range nodes {
		if name == _RESERVED_NAME {
			continue
		}
		data, _, err := z.conn.Get("/" + name)
		if err != nil {
			return nil, errors.NewAdminGetClusterError(err, name)
		}
		cluster := &zkCluster{}
		err = json.Unmarshal(data, cluster)
		if err != nil {
			return nil, errors.NewAdminDecodingError(err)
		}
		clusters = append(clusters, cluster)
	}
	return clusters, nil
}
Пример #7
0
func (z *zkCluster) QueryNodeNames() ([]string, errors.Error) {
	queryNodeNames := []string{}
	impl, ok := getConfigStoreImplementation(z)
	if !ok {
		return nil, errors.NewAdminConnectionError(nil, z.ConfigurationStoreId())
	}
	nodes, _, err := impl.conn.Children("/" + z.ClusterName)
	if err != nil {
		return nil, errors.NewAdminGetClusterError(err, z.ClusterName)
	}
	for _, name := range nodes {
		queryNodeNames = append(queryNodeNames, name)
	}
	return queryNodeNames, nil
}