// Clusters returns an implementation of Clusters for CloudStack.
485618
func (cs *CSCloud) Clusters() (cloudprovider.Clusters, bool) {
	if cs.client == nil {
		return nil, false
	}

	return nil, false
}
656595
func (c *client) clusterEndpoints(ctx context.Context, dbname string) (clusterEndpointsResponse, error) {
	var url string
	if dbname == "" {
		url = "_api/cluster/endpoints"
	} else {
		url = path.Join("_db", pathEscape(dbname), "_api/cluster/endpoints")
	}
	req, err := c.conn.NewRequest("GET", url)
	if err != nil {
		return clusterEndpointsResponse{}, WithStack(err)
	}
	applyContextSettings(ctx, req)
	resp, err := c.conn.Do(ctx, req)
	if err != nil {
		return clusterEndpointsResponse{}, WithStack(err)
	}
	if err := resp.CheckStatus(200); err != nil {
		return clusterEndpointsResponse{}, WithStack(err)
	}
	var data clusterEndpointsResponse
	if err := resp.ParseBody("", &data); err != nil {
		return clusterEndpointsResponse{}, WithStack(err)
	}
	return data, nil
}
747768
func NewCluster() *Cluster {
	return &Cluster{
		stores:  make(map[uint64]*Store),
		regions: make(map[uint64]*Region),
	}
}
625101
func ClusterPointers(pointers []geo.Pointer, distancer ClusterDistancer, threshold float64) []*Cluster {
	clusters := make([]*Cluster, 0, len(pointers))
	for _, p := range pointers {
		clusters = append(clusters, NewCluster(p))
	}

	return cluster(clusters, distancer, threshold)
}
937447
func (s *ClusterService) AddCluster(p *AddClusterParams) (*AddClusterResponse, error) {
	resp, err := s.cs.newRequest("addCluster", p.toURLValues())
	if err != nil {
		return nil, err
	}

	var r AddClusterResponse
	if err := json.Unmarshal(resp, &r); err != nil {
		return nil, err
	}

	return &r, nil
}
405967
func (s *EnvoyApi) EnvoyClustersFromState() []*EnvoyCluster {
	clusters := make([]*EnvoyCluster, 0)

	s.state.RLock()
	defer s.state.RUnlock()

	svcs := s.state.ByService()
	for svcName, endpoints := range svcs {
		if len(endpoints) < 1 {
			continue
		}

		var svc *service.Service
		for _, endpoint := range endpoints {
			if endpoint.IsAlive() {
				svc = endpoint
				break
			}
		}

		if svc == nil {
			continue
		}

		for _, port := range svc.Ports {
			if port.ServicePort < 1 {
				continue
			}

			clusters = append(clusters, &EnvoyCluster{
				Name:             SvcName(svcName, port.ServicePort),
				Type:             "sds", // use Sidecar's SDS endpoint for the hosts
				ConnectTimeoutMs: 500,
				LBType:           "round_robin", // TODO figure this out!
				ServiceName:      SvcName(svcName, port.ServicePort),
			})
		}
	}

	return clusters
}
328034
func (t *Topic) Partitions() (PartitionList, error) {
	value, _, err := t.kz.conn.Get(t.metadataPath())
	if err != nil {
		return nil, err
	}

	return t.parsePartitions(value)
}
55366
func (c *clusters) Update(cluster *v1alpha2.Cluster) (result *v1alpha2.Cluster, err error) {
	result = &v1alpha2.Cluster{}
	err = c.client.Put().
		Namespace(c.ns).
		Resource("clusters").
		Name(cluster.Name).
		Body(cluster).
		Do().
		Into(result)
	return
}
925489
func clusterToData(c *appv1.Cluster) map[string][]byte {
	data := make(map[string][]byte)
	data["server"] = []byte(c.Server)
	if c.Name == "" {
		data["name"] = []byte(c.Server)
	} else {
		data["name"] = []byte(c.Name)
	}
	configBytes, err := json.Marshal(c.Config)
	if err != nil {
		panic(err)
	}
	data["config"] = configBytes
	return data
}
66550
func ListResources(cloud openstack.OpenstackCloud, clusterName string) (map[string]*resources.Resource, error) {
	resources := make(map[string]*resources.Resource)

	os := &clusterDiscoveryOS{
		cloud:       cloud,
		osCloud:     cloud,
		clusterName: clusterName,
	}

	listFunctions := []openstackListFn{
		os.ListKeypairs,
		os.ListInstances,
		os.ListServerGroups,
		os.ListVolumes,
		os.ListLBListener,
		os.ListLBPools,
		os.ListLB,
		os.ListPorts,
		os.ListSecurityGroups,
		os.ListNetwork,
		os.ListDNSRecordsets,
	}
	for _, fn := range listFunctions {
		resourceTrackers, err := fn()
		if err != nil {
			return nil, err
		}
		for _, t := range resourceTrackers {
			resources[t.Type+":"+t.ID] = t
		}
	}
	return resources, nil
}
1292656
func (g *Cloud) ListClusters(ctx context.Context) ([]string, error) {
	allClusters := []string{}

	for _, zone := range g.managedZones {
		clusters, err := g.listClustersInZone(zone)
		if err != nil {
			return nil, err
		}
		// TODO: Scoping?  Do we need to qualify the cluster name?
		allClusters = append(allClusters, clusters...)
	}

	return allClusters, nil
}
461408
func (proxy *ProxyClient) currentCluster() (*services.Site, error) {
	sites, err := proxy.GetSites()
	if err != nil {
		return nil, trace.Wrap(err)
	}
	if len(sites) == 0 {
		return nil, trace.NotFound("no clusters registered")
	}
	if proxy.siteName == "" {
		return &sites[0], nil
	}
	for _, site := range sites {
		if site.Name == proxy.siteName {
			return &site, nil
		}
	}
	return nil, trace.NotFound("cluster %v not found", proxy.siteName)
}
755314
func (n *BuilderNode) Partitions() []int {
	n.builder.ring.FillReplicaToNodeToPartitions()
	var partitions holdme.OrderedIntsNoDups
	for _, nodeToPartitions := range n.builder.ring.ReplicaToNodeToPartitions {
		for _, partition := range nodeToPartitions[n.index] {
			partitions.Add(int(partition))
		}
	}
	return partitions
}
376495
func (a *Api) clusterMetrics(request *restful.Request, response *restful.Response) {
	a.processMetricRequest(core.ClusterKey(), request, response)
}
519105
func (c *Client) Clouds() (map[names.CloudTag]jujucloud.Cloud, error) {
	var result params.CloudsResult
	if err := c.facade.FacadeCall("Clouds", nil, &result); err != nil {
		return nil, errors.Trace(err)
	}
	clouds := make(map[names.CloudTag]jujucloud.Cloud)
	for tagString, cloud := range result.Clouds {
		tag, err := names.ParseCloudTag(tagString)
		if err != nil {
			return nil, errors.Trace(err)
		}
		clouds[tag] = common.CloudFromParams(tag.Id(), cloud)
	}
	return clouds, nil
}
431634
func NewCluster() *Cluster {
	// TODO(abronan): generate Cluster ID for federation

	return &Cluster{
		members:        make(map[uint64]*Member),
		removed:        make(map[uint64]bool),
		PeersBroadcast: watch.NewQueue(),
	}
}
235665
func (clstr *Cluster) GetSeeds() []Host {
	res, _ := clstr.seeds.GetSyncedVia(func(val interface{}) (interface{}, error) {
		seeds := val.([]*Host)
		res := make([]Host, 0, len(seeds))
		for _, seed := range seeds {
			res = append(res, *seed)
		}

		return res, nil
	})

	return res.([]Host)
}