diff options
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/IceBox/ServiceManagerI.cpp | 10 | ||||
-rw-r--r-- | cpp/src/IceGrid/AdminI.cpp | 14 | ||||
-rw-r--r-- | cpp/src/IceGrid/AdminI.h | 4 | ||||
-rw-r--r-- | cpp/src/IceGrid/DescriptorBuilder.cpp | 8 | ||||
-rw-r--r-- | cpp/src/IceGrid/DescriptorBuilder.h | 2 | ||||
-rw-r--r-- | cpp/src/IceGrid/DescriptorParser.cpp | 6 | ||||
-rw-r--r-- | cpp/src/IceGrid/Grammar.y | 10 | ||||
-rw-r--r-- | cpp/src/IceGrid/Internal.ice | 28 | ||||
-rw-r--r-- | cpp/src/IceGrid/Parser.cpp | 48 | ||||
-rw-r--r-- | cpp/src/IceGrid/Parser.h | 2 | ||||
-rw-r--r-- | cpp/src/IceGrid/Scanner.l | 8 | ||||
-rw-r--r-- | cpp/src/IceGrid/ServerAdapterI.cpp | 4 | ||||
-rw-r--r-- | cpp/src/IceGrid/ServerI.cpp | 33 | ||||
-rw-r--r-- | cpp/src/IceGrid/ServerI.h | 12 |
14 files changed, 107 insertions, 82 deletions
diff --git a/cpp/src/IceBox/ServiceManagerI.cpp b/cpp/src/IceBox/ServiceManagerI.cpp index 6a9b6555c58..14317a827c9 100644 --- a/cpp/src/IceBox/ServiceManagerI.cpp +++ b/cpp/src/IceBox/ServiceManagerI.cpp @@ -292,11 +292,11 @@ IceBox::ServiceManagerI::start(const string& service, const string& entryPoint, try { // - // If Ice.UseSharedCommunicator.<name> is defined, create a - // communicator for the service. The communicator inherits - // from the shared communicator properties. If it's not - // defined, add the service properties to the shared - // commnunicator property set. + // If Ice.UseSharedCommunicator.<name> is not defined, create + // a communicator for the service. The communicator inherits + // from the shared communicator properties. If it's defined + // add the service properties to the shared commnunicator + // property set. // PropertiesPtr properties = _server->communicator()->getProperties(); if(properties->getPropertyAsInt("IceBox.UseSharedCommunicator." + service) > 0) diff --git a/cpp/src/IceGrid/AdminI.cpp b/cpp/src/IceGrid/AdminI.cpp index 505886a1c09..6fd687e655c 100644 --- a/cpp/src/IceGrid/AdminI.cpp +++ b/cpp/src/IceGrid/AdminI.cpp @@ -301,32 +301,32 @@ AdminI::getAllServerIds(const Current&) const return _database->getAllServers(); } -ServerActivation -AdminI::getServerActivation(const ::std::string& id, const Ice::Current&) const +void +AdminI::enableServer(const string& id, bool enable, const Ice::Current&) { ServerProxyWrapper proxy(_database, id); try { - return proxy->getActivationMode(); + proxy->setEnabled(enable); } catch(const Ice::Exception& ex) { proxy.handleException(ex); - return Manual; } } -void -AdminI::setServerActivation(const ::std::string& id, ServerActivation mode, const Ice::Current&) +bool +AdminI::isServerEnabled(const ::std::string& id, const Ice::Current&) const { ServerProxyWrapper proxy(_database, id); try { - proxy->setActivationMode(mode); + return proxy->isEnabled(); } catch(const Ice::Exception& ex) { proxy.handleException(ex); + return true; // Keeps the compiler happy. } } diff --git a/cpp/src/IceGrid/AdminI.h b/cpp/src/IceGrid/AdminI.h index 9d4779b4633..b949997d3e3 100644 --- a/cpp/src/IceGrid/AdminI.h +++ b/cpp/src/IceGrid/AdminI.h @@ -42,8 +42,8 @@ public: virtual void sendSignal(const ::std::string&, const ::std::string&, const Ice::Current&); virtual void writeMessage(const ::std::string&, const ::std::string&, Ice::Int, const Ice::Current&); virtual Ice::StringSeq getAllServerIds(const Ice::Current&) const; - virtual ServerActivation getServerActivation(const ::std::string&, const Ice::Current&) const; - virtual void setServerActivation(const ::std::string&, ServerActivation, const Ice::Current&); + virtual void enableServer(const ::std::string&, bool, const Ice::Current&); + virtual bool isServerEnabled(const ::std::string&, const Ice::Current&) const; virtual StringObjectProxyDict getAdapterEndpoints(const ::std::string&, const ::Ice::Current&) const; virtual void removeAdapterWithReplicaId(const std::string&, const std::string&, const Ice::Current&); diff --git a/cpp/src/IceGrid/DescriptorBuilder.cpp b/cpp/src/IceGrid/DescriptorBuilder.cpp index 9079ad98556..3d826e2fbf2 100644 --- a/cpp/src/IceGrid/DescriptorBuilder.cpp +++ b/cpp/src/IceGrid/DescriptorBuilder.cpp @@ -26,7 +26,8 @@ XmlAttributesHelper::XmlAttributesHelper(const IceXML::Attributes& attrs, { } -XmlAttributesHelper::~XmlAttributesHelper() +void +XmlAttributesHelper::checkUnknownAttributes() { vector<string> notUsed; for(map<string, string>::const_iterator p = _attributes.begin(); p != _attributes.end(); ++p) @@ -39,8 +40,9 @@ XmlAttributesHelper::~XmlAttributesHelper() if(!notUsed.empty()) { - Ice::Warning warn(_logger); - warn << "unknown attributes in <" << _filename << "> descriptor, line " << _line << ":\n" << toString(notUsed); + ostringstream os; + os << "unknown attributes in <" << _filename << "> descriptor, line " << _line << ":\n" << toString(notUsed); + throw os.str(); } } diff --git a/cpp/src/IceGrid/DescriptorBuilder.h b/cpp/src/IceGrid/DescriptorBuilder.h index 182a2c41969..d8c50964cf1 100644 --- a/cpp/src/IceGrid/DescriptorBuilder.h +++ b/cpp/src/IceGrid/DescriptorBuilder.h @@ -22,8 +22,8 @@ class XmlAttributesHelper public: XmlAttributesHelper(const IceXML::Attributes&, const Ice::LoggerPtr&, const std::string&, int); - ~XmlAttributesHelper(); + void checkUnknownAttributes(); bool contains(const std::string&) const; std::map<std::string, std::string> asMap() const; diff --git a/cpp/src/IceGrid/DescriptorParser.cpp b/cpp/src/IceGrid/DescriptorParser.cpp index aea6f22ad98..3ddbfbad404 100644 --- a/cpp/src/IceGrid/DescriptorParser.cpp +++ b/cpp/src/IceGrid/DescriptorParser.cpp @@ -136,7 +136,7 @@ DescriptorHandler::startElement(const string& name, const IceXML::Attributes& at // We don't bother to parse the elements if the elements are enclosed in a target element // which won't be deployed. // - attributes.asMap(); // NOTE: prevents warning about attributes not being used. + attributes.asMap(); return; } else if(name == "include") @@ -367,12 +367,14 @@ DescriptorHandler::startElement(const string& name, const IceXML::Attributes& at } _currentCommunicator->addDbEnvProperty(attributes); } + + attributes.checkUnknownAttributes(); } catch(const string& reason) { error(reason); } - + _data = ""; } diff --git a/cpp/src/IceGrid/Grammar.y b/cpp/src/IceGrid/Grammar.y index 6fac70b2fd4..7543112d832 100644 --- a/cpp/src/IceGrid/Grammar.y +++ b/cpp/src/IceGrid/Grammar.y @@ -67,6 +67,8 @@ yyerror(const char* s) %token ICE_GRID_INSTANTIATE %token ICE_GRID_TEMPLATE %token ICE_GRID_SERVICE +%token ICE_GRID_ENABLE +%token ICE_GRID_DISABLE %% @@ -199,9 +201,13 @@ command { parser->pidServer($3); } -| ICE_GRID_SERVER ICE_GRID_ACTIVATION strings ';' +| ICE_GRID_SERVER ICE_GRID_ENABLE strings ';' { - parser->activationServer($3); + parser->enableServer($3, true); +} +| ICE_GRID_SERVER ICE_GRID_DISABLE strings ';' +{ + parser->enableServer($3, false); } | ICE_GRID_SERVER ICE_GRID_LIST ';' { diff --git a/cpp/src/IceGrid/Internal.ice b/cpp/src/IceGrid/Internal.ice index 7557a344c3a..d9a22a7c5b7 100644 --- a/cpp/src/IceGrid/Internal.ice +++ b/cpp/src/IceGrid/Internal.ice @@ -134,6 +134,20 @@ interface Server * **/ void stop(); + + /** + * + * Enable or disable the server. + * + **/ + void setEnabled(bool enable); + + /** + * + * Check if the server is enabled. + * + **/ + nonmutating bool isEnabled(); /** * @@ -189,20 +203,6 @@ interface Server /** * - * Set the server activation mode. - * - **/ - void setActivationMode(ServerActivation mode); - - /** - * - * Get the server activation mode. - * - **/ - nonmutating ServerActivation getActivationMode(); - - /** - * * Set the process proxy. * **/ diff --git a/cpp/src/IceGrid/Parser.cpp b/cpp/src/IceGrid/Parser.cpp index 02899fd48ad..0d354e8ab97 100644 --- a/cpp/src/IceGrid/Parser.cpp +++ b/cpp/src/IceGrid/Parser.cpp @@ -97,9 +97,9 @@ Parser::usage() "server signal ID SIGNAL Send SIGNAL (e.g. SIGTERM or 15) to server ID.\n" "server stdout ID MESSAGE Write MESSAGE on server ID's stdout.\n" "server stderr ID MESSAGE Write MESSAGE on server ID's stderr.\n" - "server activation ID [on-demand | manual] \n" - " Set the server activation mode to on-demand or\n" - " manual." + "server enable ID Enable the server.\n" + "server disable ID Disable the server (a disabled server can't be\n" + " started on demand or administratively).\n" "\n" "adapter list List all registered adapters.\n" "adapter endpoints ID [REPLICAID]\n" @@ -788,33 +788,33 @@ Parser::stateServer(const list<string>& args) try { ServerState state = _admin->getServerState(args.front()); - + string enabled = _admin->isServerEnabled(args.front()) ? "enabled" : "disabled"; switch(state) { case Inactive: { - cout << "inactive" << endl; + cout << "inactive (" << enabled << ")" << endl; break; } case Activating: { - cout << "activating" << endl; + cout << "activating (" << enabled << ")" << endl; break; } case Active: { int pid = _admin->getServerPid(args.front()); - cout << "active (pid = " << pid << ")" << endl; + cout << "active (pid = " << pid << ", " << enabled << ")" << endl; break; } case Deactivating: { - cout << "deactivating" << endl; + cout << "deactivating (" << enabled << ")" << endl; break; } case Destroyed: { - cout << "destroyed" << endl; + cout << "destroyed (" << enabled << ")" << endl; break; } default: @@ -847,32 +847,24 @@ Parser::pidServer(const list<string>& args) } void -Parser::activationServer(const list<string>& args) +Parser::enableServer(const list<string>& args, bool enable) { - if(args.size() != 2) - { - error("`server activation' requires exactly two arguments\n(`help' for more info)"); - return; - } - - try + if(args.size() != 1) { - list<string>::const_iterator p = args.begin(); - string name = *p++; - string mode = *p++; - - if(mode == "on-demand") + if(enable) { - _admin->setServerActivation(name, OnDemand); - } - else if(mode == "manual") - { - _admin->setServerActivation(name, Manual); + error("`server enable' requires exactly one argument\n(`help' for more info)"); } else { - error("Unknown mode: " + mode); + error("`server disable' requires exactly one argument\n(`help' for more info)"); } + return; + } + + try + { + _admin->enableServer(args.front(), enable); } catch(const Ice::Exception& ex) { diff --git a/cpp/src/IceGrid/Parser.h b/cpp/src/IceGrid/Parser.h index 74454a26ce1..282da40f332 100644 --- a/cpp/src/IceGrid/Parser.h +++ b/cpp/src/IceGrid/Parser.h @@ -95,7 +95,7 @@ public: void writeMessage(const std::list<std::string>&, int fd); void describeServer(const std::list<std::string>&); void stateServer(const std::list<std::string>&); - void activationServer(const std::list<std::string>&); + void enableServer(const std::list<std::string>&, bool); void pidServer(const std::list<std::string>&); void listAllServers(); diff --git a/cpp/src/IceGrid/Scanner.l b/cpp/src/IceGrid/Scanner.l index b68242503f8..7698934a9b1 100644 --- a/cpp/src/IceGrid/Scanner.l +++ b/cpp/src/IceGrid/Scanner.l @@ -221,6 +221,14 @@ NL [\n] return ICE_GRID_SERVICE; } +"enable" { + return ICE_GRID_ENABLE; +} + +"disable" { + return ICE_GRID_DISABLE; +} + {WS}*(\\{WS}*{NL})? { size_t len = strlen(yytext); for(size_t i = 0; i < len; ++i) diff --git a/cpp/src/IceGrid/ServerAdapterI.cpp b/cpp/src/IceGrid/ServerAdapterI.cpp index 301bd43ecd0..86ae6c7b918 100644 --- a/cpp/src/IceGrid/ServerAdapterI.cpp +++ b/cpp/src/IceGrid/ServerAdapterI.cpp @@ -71,7 +71,7 @@ ServerAdapterI::activate_async(const AMD_Adapter_activatePtr& cb, const Ice::Cur // try { - if(_server->startInternal(OnDemand)) + if(_server->startInternal(ServerI::OnDemand)) { return; } @@ -106,7 +106,7 @@ ServerAdapterI::getDirectProxy(const Ice::Current& current) const { AdapterNotActiveException ex; ServerState state = _server->getState(); - ex.activatable = _server->getActivationMode() == OnDemand || state == Activating || state == Active; + ex.activatable = _server->getActivationMode() == ServerI::OnDemand || state == Activating || state == Active; ex.timeout = static_cast<int>(_waitTime.toMilliSeconds()); throw ex; } diff --git a/cpp/src/IceGrid/ServerI.cpp b/cpp/src/IceGrid/ServerI.cpp index cdbf90d8cc8..ff46c6981b3 100644 --- a/cpp/src/IceGrid/ServerI.cpp +++ b/cpp/src/IceGrid/ServerI.cpp @@ -7,10 +7,6 @@ // // ********************************************************************** -#ifdef __sun -#define _POSIX_PTHREAD_SEMANTICS -#endif - #include <Ice/Ice.h> #include <IceGrid/ServerI.h> #include <IceGrid/TraceLevels.h> @@ -138,7 +134,8 @@ ServerI::ServerI(const NodeIPtr& node, const ServerPrx& proxy, const string& ser _id(id), _waitTime(wt), _serversDir(serversDir), - _state(ServerI::Inactive) + _state(ServerI::Inactive), + _activation(ServerI::Manual) { assert(_node->getActivator()); } @@ -430,15 +427,15 @@ ServerI::getPid(const Ice::Current&) const } void -ServerI::setActivationMode(ServerActivation mode, const ::Ice::Current&) +ServerI::setEnabled(bool enabled, const ::Ice::Current&) { { Lock sync(*this); - if(mode == _activation) + if(enabled && _activation < Disabled || !enabled && _activation == Disabled) { return; } - _activation = mode; + _activation = enabled ? (_desc->activation == "on-demand" ? OnDemand : Manual) : Disabled; } NodeObserverPrx observer = _node->getObserver(); @@ -454,11 +451,11 @@ ServerI::setActivationMode(ServerActivation mode, const ::Ice::Current&) } } -ServerActivation -ServerI::getActivationMode(const ::Ice::Current&) const +bool +ServerI::isEnabled(const ::Ice::Current&) const { Lock sync(*this); - return _activation; + return _activation < Disabled; } void @@ -483,6 +480,13 @@ ServerI::getApplication() const return _application; } +ServerI::ServerActivation +ServerI::getActivationMode() const +{ + Lock sync(*this); + return _activation; +} + bool ServerI::startInternal(ServerActivation act, const AMD_Server_startPtr& amdCB) { @@ -986,7 +990,10 @@ ServerI::updateImpl(const string& app, const ServerDescriptorPtr& descriptor, bo _application = app; _desc = descriptor; _serverDir = _serversDir + "/" + descriptor->id; - _activation = descriptor->activation == "on-demand" ? OnDemand : Manual; + if(_activation < Disabled) + { + _activation = descriptor->activation == "on-demand" ? OnDemand : Manual; + } istringstream at(_desc->activationTimeout); if(!(at >> _activationTimeout) || !at.eof() || _activationTimeout == 0) @@ -1390,6 +1397,6 @@ ServerI::getDynamicInfo() const // be called from the activator locked. // info.pid = _state == ServerI::Active ? getPid() : 0; - info.enabled = _activation == OnDemand; + info.enabled = _activation < Disabled; return info; } diff --git a/cpp/src/IceGrid/ServerI.h b/cpp/src/IceGrid/ServerI.h index 4d6e123fe54..1b4eeaa6dc6 100644 --- a/cpp/src/IceGrid/ServerI.h +++ b/cpp/src/IceGrid/ServerI.h @@ -42,6 +42,13 @@ public: Updating }; + enum ServerActivation + { + OnDemand, + Manual, + Disabled + }; + ServerI(const NodeIPtr&, const ServerPrx&, const std::string&, const std::string&, int); virtual ~ServerI(); @@ -57,12 +64,13 @@ public: virtual ServerState getState(const ::Ice::Current& = Ice::Current()) const; virtual Ice::Int getPid(const ::Ice::Current& = Ice::Current()) const; - virtual void setActivationMode(ServerActivation, const ::Ice::Current&); - virtual ServerActivation getActivationMode(const ::Ice::Current& = Ice::Current()) const; + virtual void setEnabled(bool, const ::Ice::Current&); + virtual bool isEnabled(const ::Ice::Current& = Ice::Current()) const; virtual void setProcess(const ::Ice::ProcessPrx&, const ::Ice::Current&); ServerDescriptorPtr getDescriptor() const; std::string getApplication() const; + ServerActivation getActivationMode() const; bool startInternal(ServerActivation, const AMD_Server_startPtr& = AMD_Server_startPtr()); void adapterActivated(const std::string&); |