Ejemplo n.º 1
0
func NewPlanner(spec *DeploymentSpec, chs chan interface{}) *Planner {

	size, err := strconv.Atoi(os.Getenv(cStepSize))

	if err != nil {
		size = defaultStepSize
	}

	deployment := NewDeployment(spec.CountOfRoles())

	//	chs := make(chan interface{}, capacity)

	return &Planner{
		//		TargetSize:     spec.GetTargetSize(),
		DeploymentSpec:      spec,
		Sender:              msg.NewQueue(spec.GetTargetSize()),
		ProvisionerObserver: nil,
		Deployment:          deployment,
		//		wait:                wait,
		FinishReport: chs,
		stepSize:     size,
	}
}
Ejemplo n.º 2
0
		}
	})

	Context("#Planner", func() {
		It("Monitoring Provision work and add to the deployment plan", func() {
			//			Expect(roles[3].Name).To(Equal("registry"))
			//			Expect(spec.GetTargetSize()).To(BeEquivalentTo(8))
			//			Expect(spec.GetLeastDeployableSize()).To(BeEquivalentTo(8))

			//			var waitgroup sync.WaitGroup

			//			waitgroup.Add(1)

			planReport := make(chan interface{}, 1)

			queue := msg.NewQueue(num)

			defer queue.Close()

			planner = NewPlanner(spec, planReport)

			fmt.Println("spec.groupMap:", spec.ReuseGroup)

			planner.RegisterOberserver(queue)

			go planner.Run()

			for i := 0; i < num; i++ {
				go func(n int) {
					fmt.Fprintf(os.Stdout, "call %d\n", n)
					queue.Send(hosts[n])