博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
[OpenNebula]中间件訪问驱动程序
阅读量:5286 次
发布时间:2019-06-14

本文共 4534 字,大约阅读时间需要 15 分钟。

/* -------------------------------------------------------------------------- *//* Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs        *//*                                                                            *//* Licensed under the Apache License, Version 2.0 (the "License"); you may    *//* not use this file except in compliance with the License. You may obtain    *//* a copy of the License at                                                   *//*                                                                            *//* http://www.apache.org/licenses/LICENSE-2.0                                 *//*                                                                            *//* Unless required by applicable law or agreed to in writing, software        *//* distributed under the License is distributed on an "AS IS" BASIS,          *//* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   *//* See the License for the specific language governing permissions and        *//* limitations under the License.                                             *//* -------------------------------------------------------------------------- */#ifndef MAD_H_#define MAD_H_#include 
#include
#include
#include
#include
#include
#include "Log.h"using namespace std;/** * Base class to build specific middleware access drivers (MAD). * This class provides generic MAD functionality. */class Mad{protected: /** * The constructor initialize the class members but DOES NOT start the * driver. A subsequent call to the start() method is needed. * @param userid user running this MAD * @param attrs configuration attributes for the driver * @param sudo the driver is started through sudo if true */ Mad( int userid, const map
&attrs, bool sudo): uid(userid), attributes(attrs), sudo_execution(sudo), pid(-1) {}; /** * The destructor of the class finalizes the driver process, and all its * associated resources (i.e. pipes) */ virtual ~Mad(); /** * Send a command to the driver * @param os an output string stream with the message, it must be * terminated with the end of line character. */ void write( ostringstream& os) const { string str; const char * cstr; str = os.str(); cstr = str.c_str(); ::write(nebula_mad_pipe, cstr, str.size()); }; /** * Send a DRIVER_CANCEL command to the driver * @param oid identifies the action (that associated with oid) */ void driver_cancel (const int oid) const { ostringstream os; os << "DRIVER_CANCEL " << oid << endl; write(os); }; /** * Sets the log message type as specify by the driver. * @param first character of the type string * @return the message type */ Log::MessageType log_type(const char r) const { Log::MessageType lt; switch (r) { case 'E': lt = Log::ERROR; break; case 'I': lt = Log::INFO; break; case 'D': lt = Log::DEBUG; break; default: lt = Log::INFO; } return lt; }private: friend class MadManager; /** * Communication pipe file descriptor. Represents the MAD to nebula * communication stream (nebula<-mad) */ int mad_nebula_pipe; /** * Communication pipe file descriptor. Represents the nebula to MAD * communication stream (nebula->mad) */ int nebula_mad_pipe; /** * User running this MAD as defined in the upool DB */ int uid; /** * Mad configuration attributes (e.g. executable, attributes...). Attribute * names MUST be lowecase. */ map
attributes; /** * True if the mad is to be executed through sudo, with the identity of the * Mad owner (uid). */ bool sudo_execution; /** * Process ID of the running MAD. */ pid_t pid; /** * Starts the MAD. This function creates a new process, sets up the * communication pipes and sends the initialization command to the driver. * @return 0 on success */ int start(); /** * Reloads the driver: sends the finalize command, "waits" for the * driver process and closes the communication pipes. Then the driver is * started again by calling the start() function * @return 0 on success */ int reload(); /** * Implements the driver specific protocol, this function should trigger * actions on the associated manager. * @param message the string read from the driver */ virtual void protocol(const string& message) const = 0; /** * This function is called whenever the driver crashes. This function * should perform the actions needed to recover the VMs. */ virtual void recover() = 0;};#endif /*MAD_H_*/

上面这个类是OpenNebula 中间件訪问驱动的接口.

转载于:https://www.cnblogs.com/bhlsheji/p/5329498.html

你可能感兴趣的文章
Yarn资源调度管理
查看>>
JSON数据解析
查看>>
渗透资源大全
查看>>
jQuery简介
查看>>
作业3
查看>>
如鹏网 静态Web开发 第五章:JQuery
查看>>
sublime 常用快捷键
查看>>
xgb+lr
查看>>
[POST] What Is the Linux fstab File, and How Does It Work?
查看>>
spark 熟悉过程
查看>>
oracle NVL与Coalesce的区别
查看>>
03-11考试总结
查看>>
Linux yum安装过程图文详解
查看>>
bzoj2733: [HNOI2012]永无乡
查看>>
一文读懂MapReduce
查看>>
30个新鲜的社会化图标集合
查看>>
线段树
查看>>
java基础知识点回顾
查看>>
Ado.Net五大对象
查看>>
C语言 读入-fgets()
查看>>