hadoop 2-state machine-(1)

1.what  

  in many scenarios,we see some figures like this:some state node,some events triggered state changes,and certain directed-arcs.it look likes a running-machine with misc commands ,say like events.so it is called "State Machine".

  yep,through these elements,we know a clear flow of running,so it's simple and easily-understandable.

 

2.why

  bases on it's concept above,we know 'State machine' is targeted to simplify logics,decrease couples,and facilitate to tune programs.

 

3.how

  in hadoop yarn,there are many state machines in different modules,eg. RMAppImpl,RMAppAtttemptImpl,RMContainerImpl,RMNodeImpl etc.from the construction of it,there are at least certain items exists in it:

  prestate/current state--current status before any event comes in to be handled.

  post state--in contrast with prestate,this is the next state after triggering certain events

  event--that is the cuase to trigger to state to be moved on

  handler--what to do if any event comes in .in hadoop this is called by 'callback'

  here is a simple outline below:

prestate1-------event1---------->post state1  
 - - - - event2 - - - -> post state1  
 - - - - event 3 - - - ->post state2  
prestate2-------event2--------> post state2  
 -------event2--------> post state1  
........... 

  so  the relationship between event and post state may be N:M

  e.g.in RMAppImpl,there is a 'stateMachine' class varibale defined to render all flows from old to new states,of course ,related handlers are registered when starting up StateMachineFactory#installTopology()

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值