framework: occupy

@fengjingchao This works. need some refactoring. 
How do we get host and port?
Xiaoyub
2014年11月24日 下午2:33于 "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)
>
> @xiaoyunwu <https://github.com/xiaoyunwu> so it is a O(n^2) (1+2+3...+n
> )approach. We can improve it by adding hints(if a framework occupies a
> task, it will create hints for other slow frameworks) when necessary.
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/go-distributed/meritop/pull/52/files#r20774420>.
>