blob: 677652ee48cda2c0e96e8220b49da9e7e7fe2bce [file] [log] [blame]
<!doctype html>
<html class="docs-version-current" lang="zh-CN" dir="ltr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="generator" content="Docusaurus v2.0.0-beta.14">
<link rel="alternate" type="application/rss+xml" href="/zh-CN/blog/rss.xml" title="Apache Linkis Blog RSS Feed">
<link rel="alternate" type="application/atom+xml" href="/zh-CN/blog/atom.xml" title="Apache Linkis Blog Atom Feed">
<link rel="search" type="application/opensearchdescription+xml" title="Apache Linkis" href="/zh-CN/opensearch.xml"><title data-react-helmet="true">ResourceManager 架构 | Apache Linkis</title><meta data-react-helmet="true" name="twitter:card" content="summary_large_image"><meta data-react-helmet="true" property="og:url" content="https://linkis.incubator.apache.org/zh-CN/docs/1.1.3/architecture/computation_governance_services/linkis_manager/resource_manager"><meta data-react-helmet="true" name="docsearch:language" content="zh-CN"><meta data-react-helmet="true" name="docsearch:version" content="current"><meta data-react-helmet="true" name="docsearch:docusaurus_tag" content="docs-default-current"><meta data-react-helmet="true" property="og:title" content="ResourceManager 架构 | Apache Linkis"><meta data-react-helmet="true" name="description" content="ResourceManager(简称RM),是Linkis的计算资源管理模块,所有的EngineConn(简称EC)、EngineConnManager(简称ECM),甚至包括Yarn在内的外部资源,都由RM负责统筹管理。RM能够基于用户、ECM或其它通过复杂标签定义的粒度对资源进行管控。"><meta data-react-helmet="true" property="og:description" content="ResourceManager(简称RM),是Linkis的计算资源管理模块,所有的EngineConn(简称EC)、EngineConnManager(简称ECM),甚至包括Yarn在内的外部资源,都由RM负责统筹管理。RM能够基于用户、ECM或其它通过复杂标签定义的粒度对资源进行管控。"><link data-react-helmet="true" rel="shortcut icon" href="/zh-CN/img/favicon.ico"><link data-react-helmet="true" rel="canonical" href="https://linkis.incubator.apache.org/zh-CN/docs/1.1.3/architecture/computation_governance_services/linkis_manager/resource_manager"><link data-react-helmet="true" rel="alternate" href="https://linkis.incubator.apache.org/docs/1.1.3/architecture/computation_governance_services/linkis_manager/resource_manager" hreflang="en"><link data-react-helmet="true" rel="alternate" href="https://linkis.incubator.apache.org/zh-CN/docs/1.1.3/architecture/computation_governance_services/linkis_manager/resource_manager" hreflang="zh-CN"><link data-react-helmet="true" rel="alternate" href="https://linkis.incubator.apache.org/docs/1.1.3/architecture/computation_governance_services/linkis_manager/resource_manager" hreflang="x-default"><link data-react-helmet="true" rel="preconnect" href="https://AE29KQB3IA-dsn.algolia.net" crossorigin="anonymous"><link rel="stylesheet" href="/zh-CN/assets/css/styles.e9faf9bb.css">
<link rel="preload" href="/zh-CN/assets/js/runtime~main.14d5df0c.js" as="script">
<link rel="preload" href="/zh-CN/assets/js/main.5a9c4743.js" as="script">
</head>
<body>
<script>!function(){function t(t){document.documentElement.setAttribute("data-theme",t)}var e=function(){var t=null;try{t=localStorage.getItem("theme")}catch(t){}return t}();t(null!==e?e:"light")}()</script><div id="__docusaurus">
<div><a href="#" class="skipToContent_OuoZ">Skip to main content</a></div><nav class="navbar navbar--fixed-top"><div class="navbar__inner"><div class="navbar__items"><button aria-label="Navigation bar toggle" class="navbar__toggle clean-btn" type="button" tabindex="0"><svg width="30" height="30" viewBox="0 0 30 30" aria-hidden="true"><path stroke="currentColor" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2" d="M4 7h22M4 15h22M4 23h22"></path></svg></button><a class="navbar__brand" href="/zh-CN/"><img src="/zh-CN/img/logo.png" alt="Apache Linkis Logo" class="themedImage_TMUO themedImage--light_4Vu1 navbar__logo"><img src="/zh-CN/img/logo.png" alt="Apache Linkis Logo" class="themedImage_TMUO themedImage--dark_uzRr navbar__logo"><b class="navbar__title">Apache Linkis(Incubating)</b></a><a class="navbar__item navbar__link" href="/zh-CN/">首页</a><a class="navbar__item navbar__link" href="/zh-CN/faq/main">FAQ</a><a class="navbar__item navbar__link" href="/zh-CN/download/main">下载</a><a class="navbar__item navbar__link" href="/zh-CN/community/how-to-subscribe">社区</a><a class="navbar__item navbar__link" href="/zh-CN/blog">博客</a><a class="navbar__item navbar__link" href="/zh-CN/team">团队</a><a class="navbar__item navbar__link" href="/zh-CN/user">用户</a><div class="navbar__item dropdown dropdown--hoverable"><a class="navbar__link">Apache</a><ul class="dropdown__menu"><li><a href="https://www.apache.org/" target="_blank" rel="noopener noreferrer" class="dropdown__link">基金会</a></li><li><a href="https://www.apache.org/licenses/" target="_blank" rel="noopener noreferrer" class="dropdown__link">证书</a></li><li><a href="https://www.apache.org/events/current-event" target="_blank" rel="noopener noreferrer" class="dropdown__link">事件</a></li><li><a href="https://www.apache.org/security/" target="_blank" rel="noopener noreferrer" class="dropdown__link">安全</a></li><li><a href="https://www.apache.org/foundation/sponsorship.html" target="_blank" rel="noopener noreferrer" class="dropdown__link">赞助</a></li><li><a href="https://www.apache.org/foundation/policies/privacy.html" target="_blank" rel="noopener noreferrer" class="dropdown__link">Privacy</a></li><li><a href="https://www.apache.org/foundation/thanks.html" target="_blank" rel="noopener noreferrer" class="dropdown__link">致谢</a></li></ul></div></div><div class="navbar__items navbar__items--right"><div class="navbar__item dropdown dropdown--hoverable dropdown--right"><a class="navbar__link">文档</a><ul class="dropdown__menu"><li><a class="dropdown__link" href="/zh-CN/docs/1.1.3/introduction">Next(1.1.3)</a></li><li><a class="dropdown__link" href="/zh-CN/docs/latest/introduction">1.1.2</a></li><li><a class="dropdown__link" href="/zh-CN/docs/1.1.1/introduction">1.1.1</a></li><li><a class="dropdown__link" href="/zh-CN/docs/1.1.0/introduction">1.1.0</a></li><li><a class="dropdown__link" href="/zh-CN/docs/1.0.3/introduction">1.0.3</a></li><li><a class="dropdown__link" href="/zh-CN/docs/1.0.2/introduction">1.0.2</a></li><li><a class="dropdown__link" href="/zh-CN/docs/0.11.0/introduction">0.11.0</a></li><li><a class="dropdown__link" href="/zh-CN/versions">All Version</a></li></ul></div><a href="https://github.com/apache/incubator-linkis" target="_blank" rel="noopener noreferrer" class="navbar__item navbar__link header-github-link" aria-label="GitHub"></a><div class="navbar__item dropdown dropdown--hoverable dropdown--right"><a href="#" class="navbar__link"><span><svg t="1631348384596" class="iconLanguage_EbrZ" viewBox="0 0 1024 1024" version="1.1" p-id="557" width="20" height="20"><path d="M547.797333 638.208l-104.405333-103.168 1.237333-1.28a720.170667 720.170667 0 0 0 152.490667-268.373333h120.448V183.082667h-287.744V100.906667H347.605333v82.218666H59.818667V265.386667h459.178666a648.234667 648.234667 0 0 1-130.304 219.946666 643.242667 643.242667 0 0 1-94.976-137.728H211.541333a722.048 722.048 0 0 0 122.453334 187.434667l-209.194667 206.378667 58.368 58.368 205.525333-205.525334 127.872 127.829334 31.232-83.84m231.424-208.426667h-82.218666l-184.96 493.312h82.218666l46.037334-123.306667h195.242666l46.464 123.306667h82.218667l-185.002667-493.312m-107.690666 287.744l66.56-178.005333 66.602666 178.005333z" fill="currentColor" p-id="558"></path></svg><span>简体中文</span></span></a><ul class="dropdown__menu"><li><a href="/docs/1.1.3/architecture/computation_governance_services/linkis_manager/resource_manager" target="_self" rel="noopener noreferrer" class="dropdown__link" style="text-transform:capitalize">English</a></li><li><a href="/zh-CN/docs/1.1.3/architecture/computation_governance_services/linkis_manager/resource_manager" target="_self" rel="noopener noreferrer" class="dropdown__link dropdown__link--active" style="text-transform:capitalize">简体中文</a></li></ul></div><div class="searchBox_Bc3W"><button type="button" class="DocSearch DocSearch-Button" aria-label="Search"><span class="DocSearch-Button-Container"><svg width="20" height="20" class="DocSearch-Search-Icon" viewBox="0 0 20 20"><path d="M14.386 14.386l4.0877 4.0877-4.0877-4.0877c-2.9418 2.9419-7.7115 2.9419-10.6533 0-2.9419-2.9418-2.9419-7.7115 0-10.6533 2.9418-2.9419 7.7115-2.9419 10.6533 0 2.9419 2.9418 2.9419 7.7115 0 10.6533z" stroke="currentColor" fill="none" fill-rule="evenodd" stroke-linecap="round" stroke-linejoin="round"></path></svg><span class="DocSearch-Button-Placeholder">Search</span></span><span class="DocSearch-Button-Keys"></span></button></div></div></div><div role="presentation" class="navbar-sidebar__backdrop"></div></nav><div class="main-wrapper docs-wrapper docs-doc-page"><div class="docPage_lDyR"><button class="clean-btn backToTopButton_i9tI" type="button"><svg viewBox="0 0 24 24" width="28"><path d="M7.41 15.41L12 10.83l4.59 4.58L18 14l-6-6-6 6z" fill="currentColor"></path></svg></button><aside class="docSidebarContainer_0YBq"><div class="sidebar_a3j0"><nav class="menu thin-scrollbar menu_cyFh menuWithAnnouncementBar_+O1J"><ul class="theme-doc-sidebar-menu menu__list"><li class="theme-doc-sidebar-item-link menu__list-item"><a class="menu__link" href="/zh-CN/docs/1.1.3/introduction">Linkis 简述</a></li><li class="theme-doc-sidebar-item-link menu__list-item"><a class="menu__link" href="/zh-CN/docs/1.1.3/release">版本总览</a></li><li class="theme-doc-sidebar-item-link menu__list-item"><a class="menu__link" href="/zh-CN/docs/1.1.3/release-notes-1.1.3">Release Notes 1.1.3-RC1</a></li><li class="theme-doc-sidebar-item-category menu__list-item menu__list-item--collapsed"><a class="menu__link menu__link--sublist" href="#">安装部署</a></li><li class="theme-doc-sidebar-item-category menu__list-item menu__list-item--collapsed"><a class="menu__link menu__link--sublist" href="#">用户手册</a></li><li class="theme-doc-sidebar-item-category menu__list-item menu__list-item--collapsed"><a class="menu__link menu__link--sublist" href="#">引擎使用</a></li><li class="theme-doc-sidebar-item-category menu__list-item menu__list-item--collapsed"><a class="menu__link menu__link--sublist" href="#">API文档</a></li><li class="theme-doc-sidebar-item-category menu__list-item menu__list-item--collapsed"><a class="menu__link menu__link--sublist" href="#">表结构</a></li><li class="theme-doc-sidebar-item-category menu__list-item"><a class="menu__link menu__link--sublist menu__link--active" href="#">技术架构</a><ul style="display:block;overflow:visible;height:auto" class="menu__list"><li class="theme-doc-sidebar-item-link menu__list-item"><a class="menu__link" tabindex="0" href="/zh-CN/docs/1.1.3/architecture/overview">总览</a></li><li class="theme-doc-sidebar-item-link menu__list-item"><a class="menu__link" tabindex="0" href="/zh-CN/docs/1.1.3/architecture/difference_between_1.0_and_0.x">Linkis1.0 与 Linkis0.X 的区别简述</a></li><li class="theme-doc-sidebar-item-category menu__list-item menu__list-item--collapsed"><a class="menu__link menu__link--sublist" href="#" tabindex="0">公共模块</a></li><li class="theme-doc-sidebar-item-category menu__list-item"><a class="menu__link menu__link--sublist menu__link--active" href="#" tabindex="0">计算治理服务架构</a><ul style="display:block;overflow:visible;height:auto" class="menu__list"><li class="theme-doc-sidebar-item-link menu__list-item"><a class="menu__link" tabindex="0" href="/zh-CN/docs/1.1.3/architecture/computation_governance_services/overview">总览</a></li><li class="theme-doc-sidebar-item-link menu__list-item"><a class="menu__link" tabindex="0" href="/zh-CN/docs/1.1.3/architecture/computation_governance_services/job_submission_preparation_and_execution_process">Linkis任务执行流程</a></li><li class="theme-doc-sidebar-item-category menu__list-item"><a class="menu__link menu__link--sublist menu__link--active" href="#" tabindex="0">Manager架构</a><ul style="display:block;overflow:visible;height:auto" class="menu__list"><li class="theme-doc-sidebar-item-link menu__list-item"><a class="menu__link" tabindex="0" href="/zh-CN/docs/1.1.3/architecture/computation_governance_services/linkis_manager/overview">总览</a></li><li class="theme-doc-sidebar-item-link menu__list-item"><a class="menu__link" tabindex="0" href="/zh-CN/docs/1.1.3/architecture/computation_governance_services/linkis_manager/app_manager">AppManager 架构</a></li><li class="theme-doc-sidebar-item-link menu__list-item"><a class="menu__link" tabindex="0" href="/zh-CN/docs/1.1.3/architecture/computation_governance_services/linkis_manager/label_manager">LabelManager 架构</a></li><li class="theme-doc-sidebar-item-link menu__list-item"><a class="menu__link menu__link--active" aria-current="page" tabindex="0" href="/zh-CN/docs/1.1.3/architecture/computation_governance_services/linkis_manager/resource_manager">ResourceManager 架构</a></li></ul></li><li class="theme-doc-sidebar-item-category menu__list-item menu__list-item--collapsed"><a class="menu__link menu__link--sublist" href="#" tabindex="0">引擎服务</a></li><li class="theme-doc-sidebar-item-link menu__list-item"><a class="menu__link" tabindex="0" href="/zh-CN/docs/1.1.3/architecture/computation_governance_services/proxy_user">Linkis支持代理用户提交架构涉及</a></li><li class="theme-doc-sidebar-item-link menu__list-item"><a class="menu__link" tabindex="0" href="/zh-CN/docs/1.1.3/architecture/computation_governance_services/entrance">Entrance 架构设计</a></li><li class="theme-doc-sidebar-item-link menu__list-item"><a class="menu__link" tabindex="0" href="/zh-CN/docs/1.1.3/architecture/computation_governance_services/linkis-cli">Linkis Client 架构设计</a></li></ul></li><li class="theme-doc-sidebar-item-category menu__list-item menu__list-item--collapsed"><a class="menu__link menu__link--sublist" href="#" tabindex="0">公共增强服务</a></li><li class="theme-doc-sidebar-item-category menu__list-item menu__list-item--collapsed"><a class="menu__link menu__link--sublist" href="#" tabindex="0">微服务治理架构</a></li></ul></li><li class="theme-doc-sidebar-item-category menu__list-item menu__list-item--collapsed"><a class="menu__link menu__link--sublist" href="#">开发文档</a></li><li class="theme-doc-sidebar-item-category menu__list-item menu__list-item--collapsed"><a class="menu__link menu__link--sublist" href="#">版本升级</a></li><li class="theme-doc-sidebar-item-category menu__list-item menu__list-item--collapsed"><a class="menu__link menu__link--sublist" href="#">调优排障</a></li></ul></nav></div></aside><main class="docMainContainer_r8cw"><div class="container padding-top--md padding-bottom--lg"><div class="row"><div class="col docItemCol_zHA2"><div class="theme-doc-version-banner alert alert--warning margin-bottom--md" role="alert"><div>此版本是还未发布的文档版本<!-- -->Apache Linkis<!-- --> <b>Next(1.1.3)</b>(1.1.3)</div><div class="margin-top--md">有关最新文档,请参阅最新稳定版本<b><a href="/zh-CN/docs/latest/architecture/computation_governance_services/linkis_manager/resource_manager">latest version</a></b> (<!-- -->1.1.2<!-- -->).</div></div><div class="docItemContainer_oiyr"><article><span class="theme-doc-version-badge badge badge--secondary">Version: <!-- -->Next(1.1.3)</span><div class="tocCollapsible_aw-L theme-doc-toc-mobile tocMobile_Tx6Y"><button type="button" class="clean-btn tocCollapsibleButton_zr6a">On this page</button></div><div class="theme-doc-markdown markdown"><header><h1>ResourceManager 架构</h1></header><p>ResourceManager(简称RM),是Linkis的计算资源管理模块,所有的EngineConn(简称EC)、EngineConnManager(简称ECM),甚至包括Yarn在内的外部资源,都由RM负责统筹管理。RM能够基于用户、ECM或其它通过复杂标签定义的粒度对资源进行管控。</p><h3><a aria-hidden="true" tabindex="-1" class="anchor anchor__h3 anchorWithStickyNavbar_y2LR" id="rm在linkis中的作用"></a>RM在Linkis中的作用<a class="hash-link" href="#rm在linkis中的作用" title="Direct link to heading">#</a></h3><p><img alt="01" src="/zh-CN/assets/images/rm-01-2fb943aa9216c45fdbbfdfae8e4d6ab2.png">
<img alt="02" src="/zh-CN/assets/images/rm-02-4d64a8e6aa03fd99bb46fcc9dba1dd8b.png"></p><p>RM作为Linkis Manager的一部分,主要作用为:维护ECM上报的可用资源信息,处理ECM提出的资源申请,记录成功申请后,EC在生命周期内实时上报的实际资源使用信息,并提供查询当前资源使用情况的相关接口。</p><p>Linkis中,与RM产生交互的其它服务主要有:</p><ul><li><p><strong>引擎管理器,简称ECM</strong>:处理启动引擎连接器请求的微服务。ECM作为资源的提供者,负责向RM注册资源(register)和下线资源(unregister)。同时,ECM作为引擎的管理者,负责代替准备启动的新引擎连接器向RM申请资源。每一个ECM实例,均在RM中有一条对应的资源记录,包含它提供的总资源、保护资源等信息,并动态更新已使用资源。
<img alt="03" src="/zh-CN/assets/images/rm-03-729d9f223ac0f5111b0dcb0e0d26792a.png"></p></li><li><p><strong>引擎连接器,简称EC</strong>,是用户作业的实际执行单元。同时,EC作为资源的实际使用者,负责向RM上报实际使用资源。每一个EC,均在RM中有一条对应的资源记录:在启动过程中,体现为锁定资源;在运行过程中,体现为已使用资源;在被结束之后,该资源记录随之被删除。
<img alt="04" src="/zh-CN/assets/images/rm-04-1d3bc2058d477c1c3498b8f6076c851b.png"></p></li></ul><h3><a aria-hidden="true" tabindex="-1" class="anchor anchor__h3 anchorWithStickyNavbar_y2LR" id="资源的类型与格式"></a>资源的类型与格式<a class="hash-link" href="#资源的类型与格式" title="Direct link to heading">#</a></h3><p><img alt="05" src="/zh-CN/assets/images/rm-05-fcca9073b4eba3afa8e7bf22c7b096b5.png"></p><p>如上图所示,所有的资源类均实现一个顶层的Resource接口,该接口定义了所有资源类均需要支持的计算和比较的方法,并进行相应的数学运算符的重载,使得资源之间能够像数字一样直接被计算和比较。</p><table><thead><tr><th>运算符</th><th>对应方法</th><th>运算符</th><th>对应方法</th></tr></thead><tbody><tr><td>+</td><td>add</td><td>&gt;</td><td>moreThan</td></tr><tr><td>-</td><td>minus</td><td>\&lt;</td><td>lessThan</td></tr><tr><td>*</td><td>multiply</td><td>=</td><td>equals</td></tr><tr><td>/</td><td>divide</td><td>&gt;<!-- -->=</td><td>notLessThan</td></tr><tr><td>\&lt;=</td><td>notMoreThan</td><td></td><td></td></tr></tbody></table><p>当前支持的资源类型如下表所示,所有的资源都有对应的json序列化与反序列化方法,能够通过json格式进行存储和在网络间传递:</p><table><thead><tr><th>资源类型</th><th>描述</th></tr></thead><tbody><tr><td>MemoryResource</td><td>内存资源</td></tr><tr><td>CPUResource</td><td>CPU资源</td></tr><tr><td>LoadResource</td><td>同时具备内存与CPU的资源</td></tr><tr><td>YarnResource</td><td>Yarn队列资源(队列,队列内存,队列CPU,队列实例数)</td></tr><tr><td>LoadInstanceResource</td><td>服务器资源(内存,CPU,实例数)</td></tr><tr><td>DriverAndYarnResource</td><td>驱动器与执行器资源(同时具备服务器资源,Yarn队列资源)</td></tr><tr><td>SpecialResource</td><td>其它自定义资源</td></tr></tbody></table><h3><a aria-hidden="true" tabindex="-1" class="anchor anchor__h3 anchorWithStickyNavbar_y2LR" id="可用资源管理"></a>可用资源管理<a class="hash-link" href="#可用资源管理" title="Direct link to heading">#</a></h3><p>RM中的可用资源,主要有两个来源:ECM上报的可用资源,以及Configuration模块中根据标签配置的资源限制。<br>
<strong>ECM资源上报</strong></p><ol><li>ECM启动时,会广播ECM注册的消息,RM接收到消息后,根据消息中包含的内容进行资源注册,资源相关的内容包括:</li></ol><ul><li>总资源:该ECM能够提供的资源总数。</li><li>保护资源:当剩余资源小于该资源时,不再允许继续分配资源。</li><li>资源类型:如LoadResource,DriverAndYarnResource等类型名称。</li><li>实例信息:机器名加端口名。</li></ul><ol start="2"><li><p>RM在收到资源注册请求后,在资源表中新增一条记录,内容与接口的参数信息一致,并通过实例信息找到代表该ECM的标签,在资源、标签关联表中新增一条关联记录。</p></li><li><p>ECM在关闭时,会广播ECM关闭的消息,RM接收到消息后,根据消息中的ECM实例信息来进行资源的下线,即删除该ECM实例标签对应的资源和关联记录。</p></li></ol><p><strong>Configuration模块标签资源配置</strong></p><p>用户能够在Configuration模块中,根据不同的标签组合进行资源数量限制的配置,如限制User/Creator/EngineType组合的最大可用资源。</p><p>RM通过RPC消息,以组合标签为查询条件,向Configuration模块查询资源信息,并转换成Resource对象参与后续的比较和记录。</p><h3><a aria-hidden="true" tabindex="-1" class="anchor anchor__h3 anchorWithStickyNavbar_y2LR" id="资源使用管理"></a>资源使用管理<a class="hash-link" href="#资源使用管理" title="Direct link to heading">#</a></h3><p><strong>接收用户的资源申请</strong></p><ol><li>LinkisManager在收到启动EngineConn的请求时,会调用RM的资源申请接口,进行资源申请。资源申请接口接受一个可选的时间参数,当申请资源的等待时间超出该时间参数的限制时,该资源申请将自动作为失败处理。</li></ol><p><strong>判断是否有足够的资源</strong></p><p>即为判断剩余可用资源是否大于申请资源,如果大于或等于,则资源充足;否则资源不充足。</p><ol><li><p>RM预处理资源申请中附带的标签信息,根据规则将原始的标签进行过滤、组合和转换等操作(如将User/Creator标签和EngineType标签进行组合),这使得后续的资源判断的粒度更加灵活多变。</p></li><li><p>在每个转换后的标签上逐一加锁,使得它们所对应的资源记录在资源申请的处理期间保持不变。</p></li><li><p>根据每个标签:</p><ol><li><p>通过Persistence模块从数据库中查询对应的资源记录,如果该记录包含剩余可用资源,则直接用来比较。</p></li><li><p>如果没有直接的剩余可用资源记录,则通过<!-- -->[剩余可用资源=最大可用资源-已用资源-已锁定资源-保护资源]<!-- -->公式进行计算得出。</p></li><li><p>如果没有最大可用资源记录,则请求Configuration模块,看是否有配置的资源信息,如果有则使用到公式中进行计算,如果没有则跳过针对这个标签的资源判断。</p></li><li><p>如果没有任何资源记录,则跳过针对这个标签的资源判断。</p></li></ol></li><li><p>只要有一个标签被判断为资源不充足,则资源申请失败,对每个标签逐一解锁。</p></li><li><p>只有所有标签都判断为资源充足的情况下,才成功通过资源申请,进入下一步。</p></li></ol><p><strong>锁定申请通过的资源</strong></p><ol><li><p>根据申请通过的资源数量,在资源表中生成一条新的记录,并与每个标签进行关联。</p></li><li><p>如果对应的标签有剩余可用资源记录,则扣减对应的数量。</p></li><li><p>生成一个定时任务,在一定时间后检查这批锁定的资源是否被实际使用,如果超时未使用,则强制回收。</p></li><li><p>对每个标签进行解锁。</p></li></ol><p><strong>上报实际使用资源</strong></p><ol><li><p>EngineConn启动后,广播资源使用消息。RM收到消息后,检查该EngineConn对应的标签是否有锁定资源记录,如果没有,则报错。</p></li><li><p>如果有锁定资源,则对该EngineConn有关联的所有标签进行加锁。</p></li><li><p>对每个标签,将对应的锁定资源记录转换为已使用资源记录。</p></li><li><p>解锁所有标签。</p></li></ol><p><strong>释放实际使用资源</strong></p><ol><li><p>EngineConn结束生命周期后,广播资源回收消息。RM收到消息后,检查该EngineConn对应的标签是否有已使用资源记录。</p></li><li><p>如果有,则对该EngineConn有关联的所有标签进行加锁。</p></li><li><p>对每个标签,在已使用资源记录中减去对应的数量。</p></li><li><p>如果对应的标签有剩余可用资源记录,则增加对应的数量。</p></li><li><p>对每个标签解锁</p></li></ol><h3><a aria-hidden="true" tabindex="-1" class="anchor anchor__h3 anchorWithStickyNavbar_y2LR" id="外部资源管理"></a>外部资源管理<a class="hash-link" href="#外部资源管理" title="Direct link to heading">#</a></h3><p>在RM中,为了更加灵活并有拓展性对资源进行分类,支持多集群的资源管控的同时,使得接入新的外部资源更加便利,在设计上进行了以下几点的考虑:</p><ol><li><p>通过标签来对资源进行统一管理。资源注册后,与标签进行关联,使得资源的属性能够无限拓展。同时,资源申请也都带上标签,实现灵活的匹配。</p></li><li><p>将集群抽象成一个或多个标签,并在外部资源管理模块中维护每个集群标签对应的环境信息,实现动态的对接。</p></li><li><p>抽象出通用的外部资源管理模块,如需接入新的外部资源类型,只要实现固定的接口,即可将不同类型的资源信息转换为RM中的Resource实体,实现统一管理。</p></li></ol><p><img alt="06" src="/zh-CN/assets/images/rm-06-20c8ef614561c8c23052d6e59ec4360a.png"></p><p>RM的其它模块,通过ExternalResourceService提供的接口来进行外部资源信息的获取。</p><p>而ExternalResourceService通过资源类型和标签来获取外部资源的信息:</p><ol><li><p>所有外部资源的类型、标签、配置等属性(如集群名称、Yarn的web
url、Hadoop版本等信息),都维护在linkis<!-- -->_<!-- -->external<!-- -->_<!-- -->resource<!-- -->_<!-- -->provider表中。</p></li><li><p>针对每种资源类型,均有一个ExternalResourceProviderParser接口的实现,将外部资源的属性进行解析,将能够匹配到Label的信息转换成对应的Label,将能够作为参数去请求资源接口的都转换成params。最后构建成一个能够作为外部资源信息查询依据的ExternalResourceProvider实例。</p></li><li><p>根据ExternalResourceService方法的参数中的资源类型和标签信息,找到匹配的ExternalResourceProvider,根据其中的信息生成ExternalResourceRequest,正式调用外部资源提供的API,发起资源信息请求。</p></li></ol></div><footer class="theme-doc-footer docusaurus-mt-lg"><div class="theme-doc-footer-edit-meta-row row"><div class="col"><a href="https://github.com/apache/incubator-linkis-website/edit/dev/i18n/zh-CN/docusaurus-plugin-content-docs/current/architecture/computation_governance_services/linkis_manager/resource_manager.md" target="_blank" rel="noreferrer noopener" class="theme-edit-this-page"><svg fill="currentColor" height="20" width="20" viewBox="0 0 40 40" class="iconEdit_mS5F" aria-hidden="true"><g><path d="m34.5 11.7l-3 3.1-6.3-6.3 3.1-3q0.5-0.5 1.2-0.5t1.1 0.5l3.9 3.9q0.5 0.4 0.5 1.1t-0.5 1.2z m-29.5 17.1l18.4-18.5 6.3 6.3-18.4 18.4h-6.3v-6.2z"></path></g></svg>编辑</a></div><div class="col lastUpdated_mt2f"></div></div></footer></article><nav class="pagination-nav docusaurus-mt-lg" aria-label="Docs pages navigation"><div class="pagination-nav__item"><a class="pagination-nav__link" href="/zh-CN/docs/1.1.3/architecture/computation_governance_services/linkis_manager/label_manager"><div class="pagination-nav__sublabel">上一篇</div><div class="pagination-nav__label">« <!-- -->LabelManager 架构</div></a></div><div class="pagination-nav__item pagination-nav__item--next"><a class="pagination-nav__link" href="/zh-CN/docs/1.1.3/architecture/computation_governance_services/engine/engine_conn"><div class="pagination-nav__sublabel">下一篇</div><div class="pagination-nav__label">EngineConn架构<!-- --> »</div></a></div></nav></div></div><div class="col col--3"><div class="tableOfContents_vrFS thin-scrollbar"><ul class="table-of-contents table-of-contents__left-border"><li><a href="#rm在linkis中的作用" class="table-of-contents__link">RM在Linkis中的作用</a></li><li><a href="#资源的类型与格式" class="table-of-contents__link">资源的类型与格式</a></li><li><a href="#可用资源管理" class="table-of-contents__link">可用资源管理</a></li><li><a href="#资源使用管理" class="table-of-contents__link">资源使用管理</a></li><li><a href="#外部资源管理" class="table-of-contents__link">外部资源管理</a></li></ul></div></div></div></div></main></div></div><footer class="footer"><div class="container"><div class="row footer__links"><div class="col footer__col"><div class="footer__title">Linkis</div><ul class="footer__items"><li class="footer__item"><a class="footer__link-item" href="/zh-CN/docs/latest/introduction">文档</a></li><li class="footer__item"><a class="footer__link-item" href="/zh-CN/faq/main">FAQ</a></li><li class="footer__item"><a href="https://github.com/apache/incubator-linkis/releases" target="_blank" rel="noopener noreferrer" class="footer__link-item"><span>版本<svg width="13.5" height="13.5" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_wgqa"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></span></a></li></ul></div><div class="col footer__col"><div class="footer__title">社区</div><ul class="footer__items"><li class="footer__item"><a href="https://github.com/apache/incubator-linkis" target="_blank" rel="noopener noreferrer" class="footer__link-item"><span>GitHub<svg width="13.5" height="13.5" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_wgqa"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></span></a></li><li class="footer__item"><a href="https://github.com/apache/incubator-linkis/issues" target="_blank" rel="noopener noreferrer" class="footer__link-item"><span>Issue Tracker<svg width="13.5" height="13.5" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_wgqa"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></span></a></li><li class="footer__item"><a href="https://github.com/apache/incubator-linkis/pulls" target="_blank" rel="noopener noreferrer" class="footer__link-item"><span>Pull Requests<svg width="13.5" height="13.5" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_wgqa"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></span></a></li></ul></div><div class="col footer__col"><div class="footer__title">订阅邮件组</div><ul class="footer__items"><li class="footer__item"><a class="footer__link-item" href="/zh-CN/community/how-to-subscribe">如何订阅</a></li><li class="footer__item"><a href="mailto:dev-subscribe@linkis.apache.org" target="_blank" rel="noopener noreferrer" class="footer__link-item"><span>订阅邮件<svg width="13.5" height="13.5" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_wgqa"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></span></a></li><li class="footer__item"><a href="https://lists.apache.org/list.html?dev@linkis.apache.org" target="_blank" rel="noopener noreferrer" class="footer__link-item"><span>邮件归档<svg width="13.5" height="13.5" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_wgqa"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></span></a></li></ul></div></div><div class="footer__bottom text--center"><div class="footer__copyright"><div style="text-align: left;">
<div>
<p style="font-family: Avenir-Medium;font-size: 14px;color: #999;line-height: 20px;">Apache Linkis (incubating) is an effort undergoing incubation at The Apache Software Foundation (ASF), sponsored by Incubator. Incubation is required of all newly accepted projects until a further review indicates that the infrastructure, communications, and decision making process have stabilized in a manner consistent with other successful ASF projects. While incubation status is not necessarily a reflection of the completeness or stability of the code, it does indicate that the project has yet to be fully endorsed by the ASF.</p>
</div>
<div style="border-top: 1px solid #ccc;min-height: 60px;line-height: 20px;text-align: center;font-family: Avenir-Medium;font-size: 14px;color: #999;display: flex;align-items: center;"><span>Copyright © 2019-2020 The Apache Software Foundation. Apache Linkis, Linkis, and its feather logo are trademarks of The Apache Software Foundation.</span></div>
</div></div></div></div></footer></div>
<script src="/zh-CN/assets/js/runtime~main.14d5df0c.js"></script>
<script src="/zh-CN/assets/js/main.5a9c4743.js"></script>
</body>
</html>