zoukankan      html  css  js  c++  java
  • 牛客网-华为-2020届校园招聘上机考试-软件类机考-3

    题目描述:
    Apache Hadoop YARN是一种新的Hadoop资源管理器,主要部件为resource manager和node manager。resource manager使用有限状态机维护有状态对象的生命周期。
    RmAppAttempt是resource manager中用于维护一个 Application运行尝试的生命周期的数据结构,当某个事件发生时RmAppAttempt会根据当前状态进行状态迁移,同时触发一个其他行为。RmAppAttempt相关状态和事件简述如下:

    1. RmApp发送start事件创建RmAppAttempt,初始化后,状态迁移为submitted。
    2. RmAppAttempt在submitted状态下收到资源调度器(ResourceScheduler)发来的app_accepted事件,状态迁移为scheduled。
    3. RmAppAttempt在scheduled状态下收到RmContainer发来的container_allocated事件,状态迁移为allocated。
    4. RmAppAttempt在scheduled状态下收到ApplicationMasterLauncher发来的launched事件,状态迁移为running。
    5. RmAppAttempt在running状态下收到ResourceScheduler发来的finished事件,状态迁移为finished。
    6. 在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左右时间做这道题,来不及写完,只写了一部分代码。待之后完善了再来更新。

  • 相关阅读:
    多项式插值取模哈希标记法
    AC自助机
    [OIBH] 糖果盒(Candy Box)——又一个最大子矩形
    windows phone 之ListBox数据绑定
    WP学习笔记
    为TextArea添加maxlength属性
    让整个网页(LOGO图片)色调全部变灰的方法(CSS写法)
    JS调试加断点
    Container.ItemIndex 获取到行的序号
    c# Invoke 与 BeginInvoke
  • 原文地址:https://www.cnblogs.com/xuyy-isee/p/10568949.html
Copyright © 2011-2022 走看看