Exemple #1
0
func NewStatus(allocator *Allocator, defaultSubnet address.CIDR) *Status {
	if allocator == nil {
		return nil
	}

	var paxosStatus *paxos.Status
	if allocator.awaitingConsensus && allocator.paxos != nil {
		if allocator.paxos.IsElector() {
			if node, ok := allocator.paxos.(*paxos.Node); ok {
				paxosStatus = paxos.NewStatus(node)
			}
		} else {
			paxosStatus = &paxos.Status{Elector: false}
		}
	}

	resultChan := make(chan *Status)
	allocator.actionChan <- func() {
		resultChan <- &Status{
			paxosStatus,
			allocator.universe.String(),
			int(allocator.universe.Size()),
			defaultSubnet.String(),
			newEntryStatusSlice(allocator),
			newClaimStatusSlice(allocator),
			newAllocateIdentSlice(allocator)}
	}

	return <-resultChan
}
Exemple #2
0
func NewStatus(allocator *Allocator, defaultSubnet address.CIDR) *Status {
	if allocator == nil {
		return nil
	}

	var paxosStatus *paxos.Status
	if allocator.paxosTicker != nil {
		paxosStatus = paxos.NewStatus(allocator.paxos)
	}

	resultChan := make(chan *Status)
	allocator.actionChan <- func() {
		resultChan <- &Status{
			paxosStatus,
			allocator.universe.String(),
			defaultSubnet.String(),
			newEntryStatusSlice(allocator),
			newClaimStatusSlice(allocator),
			newAllocateIdentSlice(allocator)}
	}

	return <-resultChan
}