1 frameworks开发指南
这个文档中,我们称Mesos的应用为”framworks”。
In this document we refer to Mesos applications as “frameworks”.
Mesos支持java,python,c++。可以从MESOS_HOME/src/examples/找对应的例子,搞明白framework的scheduler和executor的开发。
2 第一步创建Framework调度器
Framework的scheduler可以是C/c++/java/Scala或者Python,你的Framework调度器必须继承scheduler类。scheduler必须创建一个SchedulerDriver(负责中转你的掉的钱和Mesos master的通讯)的实例,然后调用SchedulerDriver.run().
2.1 Scheduler API
声明在 MESOS_HOME/include/mesos/scheduler.hpp
/** * Empty virtual destructor (necessary to instantiate subclasses). */ virtual ~Scheduler() {} /** * Invoked when the scheduler successfully registers with a Mesos * master. A unique ID (generated by the master) used for * distinguishing this framework from others and MasterInfo * with the ip and port of the current master are provided as arguments. */ virtual void registered(SchedulerDriver* driver, const FrameworkID& frameworkId, const MasterInfo& masterInfo) = 0; /** * Invoked when the scheduler re-registers with a newly elected Mesos master. * This is only called when the scheduler has previously been registered. * MasterInfo containing the updated information about the elected master * is provided as an argument. */ virtual void reregistered(SchedulerDriver* driver, const MasterInfo& masterInfo) = 0; /** * Invoked when the scheduler becomes "disconnected" from the master * (e.g., the master fails and another is taking over). */ virtual void disconnected(SchedulerDriver* driver) = 0; /** * Invoked when resources have been offered to this framework. A * single offer will only contain resources from a single slave. * Resources associated with an offer will not be re-offered to * _this_ framework until either (a) this framework has rejected * those resources (see SchedulerDriver::launchTasks) or (b) those * resources have been rescinded (see Scheduler::offerRescinded). * Note that resources may be concurrently offered to more than one * framework at a time (depending on the allocator being used). In * that case, the first framework to launch tasks using those * resources will be able to use them while the other frameworks * will have those resources rescinded (or if a framework has * already launched tasks with those resources then those tasks will * fail with a TASK_LOST status and a message saying as much). */ virtual void resourceOffers(SchedulerDriver* driver, const std::vector<Offer>& offers) = 0; /** * Invoked when an offer is no longer valid (e.g., the slave was * lost or another framework used resources in the offer). If for * whatever reason an offer is never rescinded (e.g., dropped * message, failing over framework, etc.), a framwork that attempts * to launch tasks using an invalid offer will receive TASK_LOST * status updats for those tasks (see Scheduler::resourceOffers). */ virtual void offerRescinded(SchedulerDriver* driver, const OfferID& offerId) = 0; /** * Invoked when the status of a task has changed (e.g., a slave is * lost and so the task is lost, a task finishes and an executor * sends a status update saying so, etc). Note that returning from * this callback _acknowledges_ receipt of this status update! If * for whatever reason the scheduler aborts during this callback (or * the process exits) another status update will be delivered (note, * however, that this is currently not true if the slave sending the * status update is lost/fails during that time). */ virtual void statusUpdate(SchedulerDriver* driver, const TaskStatus& status) = 0; /** * Invoked when an executor sends a message. These messages are best * effort; do not expect a framework message to be retransmitted in * any reliable fashion. */ virtual void frameworkMessage(SchedulerDriver* driver, const ExecutorID& executorId, const SlaveID& slaveId, const std::string& data) = 0; /** * Invoked when a slave has been determined unreachable (e.g., * machine failure, network partition). Most frameworks will need to * reschedule any tasks launched on this slave on a new slave. */ virtual void slaveLost(SchedulerDriver* driver, const SlaveID& slaveId) = 0; /** * Invoked when an executor has exited/terminated. Note that any * tasks running will have TASK_LOST status updates automagically * generated. */ virtual void executorLost(SchedulerDriver* driver, const ExecutorID& executorId, const SlaveID& slaveId, int status) = 0; /** * Invoked when there is an unrecoverable error in the scheduler or * scheduler driver. The driver will be aborted BEFORE invoking this * callback. */ virtual void error(SchedulerDriver* driver, const std::string& message) = 0;
3 第二步创建Framework Executor
Your framework executor must inherit from the Executor class. It must override the launchTask() method. You can use the $MESOS_HOME environment variable inside of your executor to determine where Mesos is running from.
Framework executor必须继承Executor类,并且重写launchTask()方法。可以通过设置executor环境变量$MESOS_HOME配置Mesos运行环境。
3.1 Executor API
声明在 MESOS_HOME/include/mesos/executor.hpp
/** * Invoked once the executor driver has been able to successfully * connect with Mesos. In particular, a scheduler can pass some * data to it's executors through the FrameworkInfo.ExecutorInfo's * data field. */ virtual void registered(ExecutorDriver* driver, const ExecutorInfo& executorInfo, const FrameworkInfo& frameworkInfo, const SlaveInfo& slaveInfo) = 0; /** * Invoked when the executor re-registers with a restarted slave. */ virtual void reregistered(ExecutorDriver* driver, const SlaveInfo& slaveInfo) = 0; /** * Invoked when the executor becomes "disconnected" from the slave * (e.g., the slave is being restarted due to an upgrade). */ virtual void disconnected(ExecutorDriver* driver) = 0; /** * Invoked when a task has been launched on this executor (initiated * via Scheduler::launchTasks). Note that this task can be realized * with a thread, a process, or some simple computation, however, no * other callbacks will be invoked on this executor until this * callback has returned. */ virtual void launchTask(ExecutorDriver* driver, const TaskInfo& task) = 0; /** * Invoked when a task running within this executor has been killed * (via SchedulerDriver::killTask). Note that no status update will * be sent on behalf of the executor, the executor is responsible * for creating a new TaskStatus (i.e., with TASK_KILLED) and * invoking ExecutorDriver::sendStatusUpdate. */ virtual void killTask(ExecutorDriver* driver, const TaskID& taskId) = 0; /** * Invoked when a framework message has arrived for this * executor. These messages are best effort; do not expect a * framework message to be retransmitted in any reliable fashion. */ virtual void frameworkMessage(ExecutorDriver* driver, const std::string& data) = 0; /** * Invoked when the executor should terminate all of it's currently * running tasks. Note that after a Mesos has determined that an * executor has terminated any tasks that the executor did not send * terminal status updates for (e.g., TASK_KILLED, TASK_FINISHED, * TASK_FAILED, etc) a TASK_LOST status update will be created. */ virtual void shutdown(ExecutorDriver* driver) = 0; /** * Invoked when a fatal error has occured with the executor and/or * executor driver. The driver will be aborted BEFORE invoking this * callback. */ virtual void error(ExecutorDriver* driver, const std::string& message) = 0;
4 安装Framework
你必须把framework放在集群中所有的slave可以获得地方。比如运行在HDFS上,可以把executor放在HDFS上。然后通过MesosSchedulerDriver构造器的ExecutorInfo参数传递。ExecutorInfo是一个Protocol Buffer Message类。(定义在include/mesos/mesos.proto),配置URL字段类似为HDFS://path/to/executor/。当能也可以在启动framework slave时通过frameworks_home这个参数选型传递给mesos-slave指明executors存储在哪里。然后配置ExecutorInfo为相对路径。Slave会预先拼接frameworks_home和相对路径。
一旦你确认executors可以被mesos-slaves调用时,就可以执行scheduler,scheduler注册给Mesos master,然后接受资源。
<!--EndFragment-->
相关推荐
《Juice:基于Mesos Framework的分布式任务调度云系统详解》 Juice,作为一个基于Mesos Framework构建的分布式任务调度云系统,旨在提供高效、灵活的任务分配和管理能力,为大规模分布式应用提供支撑。该系统充分...
使用Go创建Mesos框架本教程使用Go编程语言创建一个Mesos框架,并从Vagrant VM中启动。框架模板框架的最低要求是调度程序,执行程序和文件服务器。 调度程序从Mesos接收资源提议,并确定哪些任务消耗哪些资源。 执行...
在安全性和授权方面,Mesos支持Framework Authorization和Framework Rate Limiting来确保集群资源的安全和公平使用。日志与调试功能也非常关键,它帮助运维人员定位和解决问题。 为了确保系统的高可用性,Mesos设计...
6. **Mesos框架开发**:书中会详细介绍如何开发自定义的Mesos框架,这对于那些希望构建与Mesos兼容的应用和服务的开发者来说至关重要。 7. **Mesos容错机制**:Mesos设计时考虑到了高可用性,即使在部分节点故障的...
对于想要深入了解Mesos和分布式系统的人来说,这本书提供了丰富的案例研究和实践指南。无论你是开发人员、运维工程师还是系统架构师,都能从中受益,提升自己在大规模分布式环境中的操作和管理能力。 由于压缩包...
在我们开始之前你需要 你需要 你需要 你需要你需要程序克隆这个giter8模板 $ g8 mesosphere/scala-sbt-mesos-framework package [com.domain]: io.mycompany name [My Mesos Framework]: My Great Framework ...
Mesos 是一个强大的资源共享平台,设计用于在数据中心实现细粒度的资源共享,特别是针对多样化的集群计算框架,如 Hadoop 和 MPI。该平台的主要目标是提高集群的使用效率,避免因每个框架需要单独的数据复制而导致的...
你好, 这是一个随附博客文章的简单示例框架,可在...jar target/example-framework-1.0-SNAPSHOT-jar-with-dependencies.jar zk://localhost:2181/mesos您需要将 java 指向 mesos 共享库,该库通常位于 /usr/local/lib
### Mesos运行测试结果分析 #### 一、测试概述与目的 本次测试旨在评估Mesos在不同场景下的表现,特别是其资源管理和任务调度能力。通过对比MonteCarloArea算法在不同环境中的运行效率,我们可以更深入地了解Mesos...
** Mesos MicroHTTPD Framework 深入解析 ** Mesos MicroHTTPD Framework 是一个基于Apache Mesos构建的轻量级HTTP服务器框架,它允许开发者在Mesos集群上以分布式方式运行HTTP服务。该框架利用C语言实现,提供了一...
vagrant-mesos 是一款运维工具,可以使 Mesos 集群的安装和运行更加容易。vagrant-mesos 支持 Mesos 0.21.0 集群,同时包括 Marathon (0.8.0) 和 Chronos (2.1.0)正在运行的框架服务器节点。这意味着,你可以使用 ...
Mesos CLI由vektorlab开发,旨在提供更加丰富和便捷的交互方式,使用户可以更轻松地操作和管理Mesos集群。 首先,我们要理解Apache Mesos的基本概念。Mesos分为三个主要组件:Master、Agent和框架。Master节点负责...
### Mesos in Action #### 一、概述 《Mesos in Action》是一本全面介绍Apache Mesos技术原理与实践的书籍。Apache Mesos是分布式系统领域的重要项目之一,旨在为数据中心提供一个统一的资源管理平台。该书由Roger...
ITeye是一个知名的IT技术交流社区,用户在这里分享技术文章、讨论问题,因此这个链接可能指向一系列深入探讨Mesos的文章,内容可能包括Mesos的安装、配置、调度机制、容错能力、资源隔离、框架开发等方面。...
此存储库中不会有进一步的开发。戈麦斯Gomes 是集群管理器的 (100%) 纯 Go 框架 API。 Gomes 使用 HTTP 连线协议向正在运行的 Mesos 主节点发送消息和接收事件。 该项目提供了一个惯用的 Go API,使使用 Go 创建 ...
本书《Apache Mesos Essentials》旨在为读者提供Mesos的基础使用指南,同时深入探讨其内部工作机制,以及如何基于Mesos进行开发。这本书由Dharmesh Kakadia撰写,他在进入微软研究公司(Microsoft Research)之前,...