华为社招机考考什么_牛客网-华为-2020届校园招聘上机考试-软件类机考-3

题目描述:

Apache Hadoop YARN是一种新的Hadoop资源管理器,主要部件为resource manager和node manager。resource manager使用有限状态机维护有状态对象的生命周期。

RmAppAttempt是resource manager中用于维护一个 Application运行尝试的生命周期的数据结构,当某个事件发生时RmAppAttempt会根据当前状态进行状态迁移,同时触发一个其他行为。RmAppAttempt相关状态和事件简述如下:

RmApp发送start事件创建RmAppAttempt,初始化后,状态迁移为submitted。

RmAppAttempt在submitted状态下收到资源调度器(ResourceScheduler)发来的app_accepted事件,状态迁移为scheduled。

RmAppAttempt在scheduled状态下收到RmContainer发来的container_allocated事件,状态迁移为allocated。

RmAppAttempt在scheduled状态下收到ApplicationMasterLauncher发来的launched事件,状态迁移为running。

RmAppAttempt在running状态下收到ResourceScheduler发来的finished事件,状态迁移为finished。

在RmAppAttempt运行过程中(不含finished状态),当收到来自客户端的杀死应用程序的命令,RmApp向RmAppAttempt发送kill事件,RmAppAttempt收到后,状态迁移到killed状态。

请编写一段程序模拟实现RmAppAttempt状态机,接受一段连续事件输入,输出每个事件处理后yarn中对应RmAppAttempt对象的状态。

输入描述:

模拟RmAppAttempt状态机,接收一段连续事件输入

输入接口:(事件间用空格分隔)

事件源|RmAppAttempt对象|事件

事件源:RmApp、ResourceScheduler、ApplicationMasterLauncher、RmContainer

事件:start、app_accepted、container_allocated、launched、finished、kill

输出描述:

输出接口:(输出结果用分毫;分隔)

RmAppAttempt对象|状态

状态:submitted、scheduled、allocated、running、finished、killed

无效输入通过状态机过滤,不需要任何输出

示例1

输入:

mApp|RmAppAttempt_001|start RmApp|RmAppAttempt_002|start RmApp|RmAppAttempt_001|kill

输出:

RmAppAttempt_001|submitted;RmAppAttempt_002|submitted;RmAppAttempt_001|killed;

----------------2019.03.20-------------------

上机考试的时候,因为只剩下20min左右时间做这道题,来不及写完,只写了一部分代码。待之后完善了再来更新。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值