Пример #1
0
	"log"
	"net"
	"os"
	"strconv"
	"strings"
	"time"
)

const (
	alpha     = 50
	maxUDPLen = 3000
)

const calDir = "/ctl/cal"

var calGlob = store.MustCompileGlob(calDir + "/*")

type proposer struct {
	seqns chan int64
	props chan *consensus.Prop
	st    *store.Store
}

func (p *proposer) Propose(v []byte) (e store.Event) {
	for e.Mut != string(v) {
		n := <-p.seqns
		w, err := p.st.Wait(store.Any, n)
		if err != nil {
			panic(err) // can't happen
		}
		p.props <- &consensus.Prop{n, v}
Пример #2
0
package member

import (
	"github.com/coreos/doozerd/consensus"
	"github.com/coreos/doozerd/store"
	"log"
)

var (
	calGlob = store.MustCompileGlob("/ctl/cal/*")
)

func Clean(c chan string, st *store.Store, p consensus.Proposer) {
	for addr := range c {
		_, g := st.Snap()
		name := getName(addr, g)
		if name != "" {
			go func() {
				clearSlot(p, g, name)
				removeInfo(p, g, name)
			}()
		}
	}
}

func getName(addr string, g store.Getter) string {
	for _, name := range store.Getdir(g, "/ctl/node") {
		if store.GetString(g, "/ctl/node/"+name+"/addr") == addr {
			return name
		}
	}