framework: occupy

@fengjingchao This works. need some refactoring. 
@xiang90 , 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. 

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?