func main() { flag.Parse() rand.Seed(time.Now().UnixNano()) if *quiet { log.SetOutput(ioutil.Discard) } if *cpuprofile != "" { f, err := os.Create(*cpuprofile) if err != nil { glog.Fatal(err) } pprof.StartCPUProfile(f) defer pprof.StopCPUProfile() } opts := []bh.AppOption{bh.Persistent(*replFactor)} if *random { rp := bh.RandomPlacement{ Rand: rand.New(rand.NewSource(time.Now().UnixNano())), } opts = append(opts, bh.Placement(rp)) } a := bh.NewApp("kvstore", opts...) kv := &store.KVStore{ Hive: bh.DefaultHive, Buckets: uint64(*buckets), } a.Handle(store.Put{}, kv) a.Handle(store.Get(""), kv) a.Handle(store.Del(""), kv) a.HandleHTTP("/{key}", kv) bh.Start() }
func (m testNonLocalPlacementMethod) Place(cells MappedCells, thisHive Hive, liveHives []HiveInfo) HiveInfo { for _, h := range liveHives { if h.ID != thisHive.ID() { return h } } glog.Fatal("cannot find a non-local hive") return HiveInfo{} }
func (r *registry) lockCell(l lockMappedCell) (Colony, error) { if l.Colony.Leader == 0 { return Colony{}, ErrInvalidParam } locked := false openk := make(MappedCells, 0, 10) for _, k := range l.Cells { c, ok := r.Store.colony(l.App, k) if !ok { if locked { r.Store.assign(l.App, k, l.Colony) } else { openk = append(openk, k) } continue } if locked && !c.Equals(l.Colony) { // FIXME(soheil): Fix this bug after refactoring the code. glog.Fatal("TODO registery conflict between colonies") } locked = true l.Colony = c } if locked { for _, k := range openk { r.Store.assign(l.App, k, l.Colony) } return l.Colony, nil } for _, k := range l.Cells { r.Store.assign(l.App, k, l.Colony) } return l.Colony, nil }
func main() { flag.Parse() if *cpuprofile != "" { f, err := os.Create(*cpuprofile) if err != nil { glog.Fatal(err) } pprof.StartCPUProfile(f) defer pprof.StopCPUProfile() } h := bh.NewHive() openflow.StartOpenFlow(h) controller.RegisterNOMController(h) discovery.RegisterDiscovery(h) // Register a switch: // switching.RegisterSwitch(h, bh.Persistent(1)) // or a hub: // switching.RegisterHub(h, bh.NonTransactional()) h.Start() }