// MovingAssignmentCount returns the number of assignments that are currently
// "in motion". If you were to call IsMoving for every replica of every
// partition and count the true responses, that would equal the
// MovingAssignmentCount.
434937
func (b *Builder) MovingAssignmentCount() int {
	replicaCount := len(b.ring.ReplicaToPartitionToNode)
	partitionCount := len(b.ring.ReplicaToPartitionToNode[0])
	moving := 0
	for replica := 0; replica < replicaCount; replica++ {
		partitionToWait := b.ring.ReplicaToPartitionToWait[replica]
		for partition := 0; partition < partitionCount; partition++ {
			if partitionToWait[partition] > 0 {
				moving++
			}
		}
	}
	return moving
}
1226240
func diskCount(disks []StorageAPI) int {
	diskCount := 0
	for _, disk := range disks {
		if disk == nil {
			continue
		}
		diskCount++
	}
	return diskCount
}
838696
func (r *PCPRegistry) MetricCount() int {
	r.metricslock.RLock()
	defer r.metricslock.RUnlock()

	return len(r.metrics)
}
803681
func (c *Client) Assignment() (map[string][]int32, error) {
	request := &clientRequest{
		Key: RequestKeyAssignments,
	}

	assignments := make(map[string][]int32)
	err := c.handleRequest(request, &assignments)
	return assignments, err
}
605027
func (t *Topic) validatePartitionAssignments(brokers []int32, assignment PartitionList) error {
	if len(assignment) == 0 {
		return ErrInvalidPartitionCount
	}

	// get the first replica count to compare against. Every partition should have the same.
	var replicaCount int
	for _, part := range assignment {
		replicaCount = len(part.Replicas)
		break
	}
	if replicaCount == 0 {
		return ErrInvalidReplicationFactor
	}

	// ensure all ids are unique and sequential
	maxPartitionID := int32(-1)
	partitionIDmap := make(map[int32]struct{}, len(assignment))

	for _, part := range assignment {
		if part == nil {
			continue
		}
		if maxPartitionID < part.ID {
			maxPartitionID = part.ID
		}
		partitionIDmap[part.ID] = struct{}{}

		// all partitions require the same replica count
		if len(part.Replicas) != replicaCount {
			return ErrInvalidReplicaCount
		}

		rset := make(map[int32]struct{}, replicaCount)
		for _, r := range part.Replicas {
			// replica must be assigned to a valid broker
			found := false
			for _, b := range brokers {
				if r == b {
					found = true
					break
				}
			}
			if !found {
				return ErrInvalidBroker
			}
			rset[r] = struct{}{}
		}
		// broker assignments for a partition must be unique
		if len(rset) != replicaCount {
			return ErrReplicaBrokerOverlap
		}
	}

	// ensure all partitions accounted for
	if int(maxPartitionID) != len(assignment)-1 {
		return ErrMissingPartitionID
	}

	// ensure no duplicate ids
	if len(partitionIDmap) != len(assignment) {
		return ErrDuplicatePartitionID
	}

	return nil
}
614870
func (s *ListBonusPaymentsInput) SetAssignmentId(v string) *ListBonusPaymentsInput {
	s.AssignmentId = &v
	return s
}
309028
func (s *LoadBalancerService) NewAssignCertToLoadBalancerParams(certid string, lbruleid string) *AssignCertToLoadBalancerParams {
	p := &AssignCertToLoadBalancerParams{}
	p.p = make(map[string]interface{})
	p.p["certid"] = certid
	p.p["lbruleid"] = lbruleid
	return p
}
578704
func (u *UpdateJob) InstanceCount(inst int32) *UpdateJob {
	u.req.InstanceCount = inst
	return u
}
596984
func (s *GetAssignmentOutput) SetAssignment(v *Assignment) *GetAssignmentOutput {
	s.Assignment = v
	return s
}
655751
func NewMoveToArgs(nodeID NodeID, targetNodeID NodeID) *MoveToArgs {
	args := new(MoveToArgs)
	args.NodeID = nodeID
	args.TargetNodeID = targetNodeID
	return args
}
573700
func MoveMouseSmooth(x, y int, args ...interface{}) bool {
	return MoveSmooth(x, y, args...)
}
15550
func moveInfoSchemaToFront(dbs []string) {
	if len(dbs) > 0 && strings.EqualFold(dbs[0], "INFORMATION_SCHEMA") {
		return
	}

	i := sort.SearchStrings(dbs, "INFORMATION_SCHEMA")
	if i < len(dbs) && strings.EqualFold(dbs[i], "INFORMATION_SCHEMA") {
		copy(dbs[1:i+1], dbs[0:i])
		dbs[0] = "INFORMATION_SCHEMA"
	}
}
1362388
func (se *ServiceEndpoint) SetAssignment(aa addressassignment.AddressAssignment) error {
	if se.AddressConfig.Port == 0 {
		return errors.New("cannot assign address to endpoint without AddressResourceConfig")
	}
	se.AddressAssignment = aa
	return nil
}
1287052
func (s *ListAssignmentsForHITOutput) SetAssignments(v []*Assignment) *ListAssignmentsForHITOutput {
	s.Assignments = v
	return s
}
1056206
func (p *propertySet) populateExisting() {
	// Retrieve all previously placed allocations
	ws := memdb.NewWatchSet()
	allocs, err := p.ctx.State().AllocsByJob(ws, p.namespace, p.jobID, false)
	if err != nil {
		p.errorBuilding = fmt.Errorf("failed to get job's allocations: %v", err)
		p.logger.Error("failed to get job's allocations", "job", p.jobID, "namespace", p.namespace, "error", err)
		return
	}

	// Filter to the correct set of allocs
	allocs = p.filterAllocs(allocs, true)

	// Get all the nodes that have been used by the allocs
	nodes, err := p.buildNodeMap(allocs)
	if err != nil {
		p.errorBuilding = err
		p.logger.Error("failed to build node map", "error", err)
		return
	}

	// Build existing properties map
	p.populateProperties(allocs, nodes, p.existingValues)
}
1298091
func (s *CreateAdditionalAssignmentsForHITInput) SetNumberOfAdditionalAssignments(v int64) *CreateAdditionalAssignmentsForHITInput {
	s.NumberOfAdditionalAssignments = &v
	return s
}
810125
func NewRelocationBatchArg(Entries []*RelocationPath) *RelocationBatchArg {
	s := new(RelocationBatchArg)
	s.Entries = Entries
	s.Autorename = false
	s.AllowSharedFolder = false
	s.AllowOwnershipTransfer = false
	return s
}