diff --git a/include/NebulaTemplate.h b/include/NebulaTemplate.h index c264942ef9..5cba67cb31 100644 --- a/include/NebulaTemplate.h +++ b/include/NebulaTemplate.h @@ -20,7 +20,7 @@ #include "Template.h" #include -/** +/** * This class provides the basic abstraction for OpenNebula configuration files */ class NebulaTemplate : public Template @@ -33,7 +33,7 @@ public: { conf_file = etc_location + _conf_name; } - + virtual ~NebulaTemplate(){}; // ----------------------------------------------------------------------- @@ -42,22 +42,22 @@ public: int get(const char * name, vector& values) const { string _name(name); - - return Template::get(_name,values); + + return Template::get(_name,values); }; - + void get(const char * name, string& values) const { string _name(name); - - Template::get(_name,values); + + Template::get(_name,values); }; - + void get(const char * name, int& values) const { string _name(name); - - Template::get(_name,values); + + Template::get(_name,values); }; void get(const char *name, unsigned int& values) const @@ -68,32 +68,32 @@ public: values = static_cast(ival); }; - + void get(const char * name, time_t& values) const { const SingleAttribute * sattr; vector attr; - + string _name(name); - + if ( Template::get(_name,attr) == 0 ) { values = 0; return; } - + sattr = dynamic_cast(attr[0]); - + if ( sattr != 0 ) { istringstream is; - + is.str(sattr->value()); is >> values; } else - values = 0; - }; + values = 0; + }; void get(const char *name, float& value) const { @@ -109,6 +109,13 @@ public: Template::get(_name,value); }; + void get(const char *name, long long& value) const + { + string _name(name); + + Template::get(_name,value); + } + // ----------------------------------------------------------------------- // ----------------------------------------------------------------------- @@ -119,10 +126,10 @@ public: protected: /** - * Full path to the configuration file + * Full path to the configuration file */ string conf_file; - + /** * Defaults for the configuration file */ @@ -138,13 +145,13 @@ protected: // ----------------------------------------------------------------------------- class OpenNebulaTemplate : public NebulaTemplate -{ +{ public: OpenNebulaTemplate(const string& etc_location, const string& _var_location): NebulaTemplate(etc_location, conf_name), var_location(_var_location) {}; - + ~OpenNebulaTemplate(){}; private: @@ -157,7 +164,7 @@ private: * Path for the var directory, for defaults */ string var_location; - + /** * Sets the defaults value for the template */ diff --git a/src/scheduler/etc/sched.conf b/src/scheduler/etc/sched.conf index c992f8d35b..05e5897b37 100644 --- a/src/scheduler/etc/sched.conf +++ b/src/scheduler/etc/sched.conf @@ -5,6 +5,8 @@ #******************************************************************************* # Daemon configuration attributes #------------------------------------------------------------------------------- +# MESSAGE_SIZE: Buffer size in bytes for XML-RPC responses. +# # ONED_PORT: Port to connect to the OpenNebula daemon (oned) # # SCHED_INTERVAL: Seconds between two scheduling actions @@ -57,6 +59,8 @@ # - debug_level: 0 = ERROR, 1 = WARNING, 2 = INFO, 3 = DEBU #******************************************************************************* +MESSAGE_SIZE = 1073741824 + ONED_PORT = 2633 SCHED_INTERVAL = 30 diff --git a/src/scheduler/include/Client.h b/src/scheduler/include/Client.h index 2a7ad2f632..db1b42cee2 100644 --- a/src/scheduler/include/Client.h +++ b/src/scheduler/include/Client.h @@ -55,15 +55,15 @@ public: * @param endpoint Where the rpc server is listening, must be something * like "http://localhost:2633/RPC2". If not set, the endpoint will be set * to $ONE_XMLRPC. + * @param message_size for XML elements in the client library (in bytes) * @throws Exception if the authorization options are invalid */ - Client( string secret = "", - string endpoint = "") + Client(const string& secret, const string& endpoint, size_t message_size) { set_one_auth(secret); set_one_endpoint(endpoint); - xmlrpc_limit_set(XMLRPC_XML_SIZE_LIMIT_ID, 1024*MESSAGE_SIZE); + xmlrpc_limit_set(XMLRPC_XML_SIZE_LIMIT_ID, message_size); } const string& get_oneauth() @@ -76,17 +76,16 @@ public: return one_endpoint; } + size_t get_message_size() + { + return xmlrpc_limit_get(XMLRPC_XML_SIZE_LIMIT_ID); + } + //-------------------------------------------------------------------------- // PRIVATE ATTRIBUTES AND METHODS //-------------------------------------------------------------------------- private: - - /** - * Default message size for XML data off the network - */ - static const int MESSAGE_SIZE; - string one_auth; string one_endpoint; diff --git a/src/scheduler/src/client/Client.cc b/src/scheduler/src/client/Client.cc index 0c3e0327f5..8a4e5e5cf6 100644 --- a/src/scheduler/src/client/Client.cc +++ b/src/scheduler/src/client/Client.cc @@ -33,11 +33,6 @@ /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ -const int Client::MESSAGE_SIZE = 51200; -// -/* -------------------------------------------------------------------------- */ -/* -------------------------------------------------------------------------- */ - void Client::set_one_auth(string secret) { if (secret.empty()) diff --git a/src/scheduler/src/sched/Scheduler.cc b/src/scheduler/src/sched/Scheduler.cc index cd06de4f47..3196f24702 100644 --- a/src/scheduler/src/sched/Scheduler.cc +++ b/src/scheduler/src/sched/Scheduler.cc @@ -195,7 +195,18 @@ void Scheduler::start() try { - client = new Client("",url); + long long message_size; + + conf.get("MESSAGE_SIZE", message_size); + + client = new Client("", url, message_size); + + oss.str(""); + + oss << "XML-RPC client using " << client->get_message_size() + << " bytes for response buffer.\n"; + + NebulaLog::log("SCHED", Log::INFO, oss); } catch(runtime_error &) { diff --git a/src/scheduler/src/sched/SchedulerTemplate.cc b/src/scheduler/src/sched/SchedulerTemplate.cc index a419d5fe0e..8e6e813ad3 100644 --- a/src/scheduler/src/sched/SchedulerTemplate.cc +++ b/src/scheduler/src/sched/SchedulerTemplate.cc @@ -35,6 +35,7 @@ void SchedulerTemplate::set_conf_default() #******************************************************************************* # Daemon configuration attributes #------------------------------------------------------------------------------- +# XML_RPC_MESSAGE_SIZE # ONED_PORT # SCHED_INTERVAL # MAX_VM @@ -47,6 +48,12 @@ void SchedulerTemplate::set_conf_default() # LOG #------------------------------------------------------------------------------- */ + // XML_RPC_MESSAGE_SIZE + value = "1073741824"; + + attribute = new SingleAttribute("MESSAGE_SIZE",value); + conf_default.insert(make_pair(attribute->name(),attribute)); + // ONED_PORT value = "2633";