Beispiel #1
0
//Will create and save a new router table.
func (this *Services) NewRouterTable(service string, totalshards int, repFactor int) error {

	_, ok := this.RouterTable(service)
	if ok {
		//already exists
		return fmt.Errorf("Router Table %s already exists!", service)
	}

	rt := shards.NewRouterTable(service)
	rt.TotalPartitions = totalshards
	rt.ReplicationFactor = repFactor
	this.SetRouterTable(rt)
	return nil
}
Beispiel #2
0
func main() {
	flag.Parse()
	bootstrap := cheshire.NewBootstrapFile(*configFilename)

	//Setup our cache.  this uses the local cache
	cache := gocache.New(10, 10)
	bootstrap.AddFilters(cheshire.NewSession(cache, 3600))

	balancer.Servs.DataDir = *dataDir
	balancer.Servs.Load()

	testrt := shards.NewRouterTable("Test")
	balancer.Servs.SetRouterTable(testrt)

	//try creating entry
	entry := &shards.RouterEntry{
		Address:    "localhost",
		JsonPort:   8009,
		HttpPort:   8010,
		Partitions: make([]int, 0),
	}

	log.Println("********************* ADD ENTRY")
	testrt.AddEntries(entry)

	//
	log.Println("Starting")
	// go func() {
	//     c := time.Tick(5 * time.Second)
	//     for now := range c {
	//         str := fmt.Sprintf("%v %s\n", now, "Something something")
	//         balancer.Servs.Logger.Emit("test", str)
	//         balancer.Servs.Logger.Println("TESTING LOG")
	//     }
	// }()

	//starts listening on all configured interfaces
	bootstrap.Start()

}