framework: occupy

@fengjingchao This works. need some refactoring. 
How I even know which task to try to occupy?
Xiaoyun
2014年11月24日 下午2:23于 "Xiang Li" <notifications@github.com>写道：

> In framework.go:
>
> > @@ -368,3 +369,26 @@ func (f *framework) GetLogger() log.Logger {
> >  func (f *framework) GetTaskID() uint64 {
> >  	return f.taskID
> >  }
> > +
> > +func (f *framework) occupyTask(taskPath string) uint64 {
> > +	slots, err := f.etcdClient.Get(taskPath, true, true)
> > +	if err != nil {
> > +		// TODO: handle err
> > +		log.Panic(err)
> > +	}
> > +	for _, s := range slots.Node.Nodes {
> > +		_, err := f.etcdClient.CompareAndSwap(s.Key+"/master", f.ln.Addr().String(), 0, "empty", 0)
>
>  I send in another pr which change master/slave to 0,1..., that we way,
> it is easy to handle them uniformly. Can you provide some feedback.
>
> Ack. Agreed.
>
> It is still unclear to me as to how each node knows which task/replica it
> should take on from this pr. Can you clarify?
>
> Instead of panic at line 392, for loop again with s.key + "/slave"
> ("replica" -> 1,2,3....)
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/go-distributed/meritop/pull/52/files#r20774233>.
>