Ejemplo n.º 1
0
Archivo: ids.go Proyecto: zbs4ms/ids
func InitProgram() {
	global.CoordinateCenter = coordinate.NewCenterPoolAgent(global.Get("center", "zookeeperAddr"), global.Get("center", "redisAddr"))
	if nil == global.CoordinateCenter {
		fmt.Println("Can not access to coordintor")
		os.Exit(1)
	}
	global.ServeAddr = global.Get("uuidCluster", "serveAddr")

	machineCode := global.Get("uuidCluster", "machineCode")
	global.MachineCode = machineCode

	global.QueCounter = count.NewQueCounter(1, 8191, 1)

	services.InitAuthority(global.CoordinateCenter)
}
Ejemplo n.º 2
0
func TestQueCounter(t *testing.T) {

	queCounter := count.NewQueCounter(1, 100000000, 2)

	chs := make([]chan [1000]string, 100)
	for i := 0; i < 100; i++ {
		chs[i] = make(chan [1000]string)
		go calc(chs[i], queCounter)
	}

	var all map[string]string = make(map[string]string)
	for _, ch := range chs {
		orders := <-ch
		for i := 0; i < 1000; i++ {
			value, ok := all[orders[i]]
			if ok {
				t.Errorf("Failed for create same id: %s", value)
			} else {
				all[orders[i]] = "1"
			}
		}
	}
}