diff options
author | Benoit Foucher <benoit@zeroc.com> | 2005-06-21 12:40:26 +0000 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2005-06-21 12:40:26 +0000 |
commit | 91b10476449de133a15743272be8c5fab8010c7f (patch) | |
tree | 5c721ee19d9d3a8aa228cc9466412a1edd978446 /cpp | |
parent | Fix (diff) | |
download | ice-91b10476449de133a15743272be8c5fab8010c7f.tar.bz2 ice-91b10476449de133a15743272be8c5fab8010c7f.tar.xz ice-91b10476449de133a15743272be8c5fab8010c7f.zip |
Fixes
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/config/PropertyNames.def | 1 | ||||
-rw-r--r-- | cpp/src/Ice/PropertyNames.cpp | 3 | ||||
-rw-r--r-- | cpp/src/Ice/PropertyNames.h | 2 | ||||
-rw-r--r-- | cpp/src/IceGrid/DescriptorHelper.cpp | 23 | ||||
-rw-r--r-- | cpp/src/IceGrid/IceGridNode.cpp | 79 | ||||
-rw-r--r-- | cpp/src/IceGrid/ObserverSessionI.cpp | 1 | ||||
-rw-r--r-- | cpp/src/IceGrid/ServerI.cpp | 1 | ||||
-rw-r--r-- | cpp/test/IceGrid/Makefile | 2 | ||||
-rw-r--r-- | cpp/test/IceGrid/simple/Makefile | 2 | ||||
-rw-r--r-- | cpp/test/IceGrid/update/AllTests.cpp | 107 | ||||
-rw-r--r-- | cpp/test/IceGrid/update/Client.cpp | 3 | ||||
-rwxr-xr-x | cpp/test/IceGrid/update/run.py | 7 |
12 files changed, 203 insertions, 28 deletions
diff --git a/cpp/config/PropertyNames.def b/cpp/config/PropertyNames.def index 57b97cbf074..2d44991b008 100644 --- a/cpp/config/PropertyNames.def +++ b/cpp/config/PropertyNames.def @@ -234,6 +234,7 @@ IcePack: IceGrid: Node.AdapterId + Node.RegisterProcess Node.CollocateRegistry Node.Data Node.Endpoints diff --git a/cpp/src/Ice/PropertyNames.cpp b/cpp/src/Ice/PropertyNames.cpp index e9bfeb811e3..606dfb730ee 100644 --- a/cpp/src/Ice/PropertyNames.cpp +++ b/cpp/src/Ice/PropertyNames.cpp @@ -7,7 +7,7 @@ // // ********************************************************************** -// Generated by makeprops.py from file `../config/PropertyNames.def', Tue Jun 14 10:24:30 2005 +// Generated by makeprops.py from file `../config/PropertyNames.def', Mon Jun 20 17:04:26 2005 // IMPORTANT: Do not edit this file -- any edits made here will be lost! @@ -155,6 +155,7 @@ const char* IceInternal::PropertyNames::IcePackProps[] = const char* IceInternal::PropertyNames::IceGridProps[] = { "IceGrid.Node.AdapterId", + "IceGrid.Node.RegisterProcess", "IceGrid.Node.CollocateRegistry", "IceGrid.Node.Data", "IceGrid.Node.Endpoints", diff --git a/cpp/src/Ice/PropertyNames.h b/cpp/src/Ice/PropertyNames.h index 0ca294e8e73..79cdfab575b 100644 --- a/cpp/src/Ice/PropertyNames.h +++ b/cpp/src/Ice/PropertyNames.h @@ -7,7 +7,7 @@ // // ********************************************************************** -// Generated by makeprops.py from file `../config/PropertyNames.def', Tue Jun 14 10:24:30 2005 +// Generated by makeprops.py from file `../config/PropertyNames.def', Mon Jun 20 17:04:26 2005 // IMPORTANT: Do not edit this file -- any edits made here will be lost! diff --git a/cpp/src/IceGrid/DescriptorHelper.cpp b/cpp/src/IceGrid/DescriptorHelper.cpp index 14525b4fcd2..d9ba7fd861e 100644 --- a/cpp/src/IceGrid/DescriptorHelper.cpp +++ b/cpp/src/IceGrid/DescriptorHelper.cpp @@ -757,14 +757,27 @@ ServerInstanceDescriptor ApplicationDescriptorHelper::instantiate(const ServerInstanceDescriptor& inst) { ServerInstanceDescriptor instance = inst; + pushNodeVariables(inst.node); if(instance._cpp_template.empty()) { - assert(instance.descriptor); - return instance; + // + // We can't re-instantiate here -- this would break escaped variables. + // +// assert(instance.descriptor); +// set<string> missing; +// instance.descriptor = ServerDescriptorHelper(*this, instance.descriptor).instantiate(missing); +// if(!missing.empty()) +// { +// ostringstream os; +// os << "server undefined variables: "; +// copy(missing.begin(), missing.end(), ostream_iterator<string>(os, " ")); +// throw os.str(); +// } + } + else + { + instance.descriptor = _templates->instantiateServer(*this, instance._cpp_template, instance.parameterValues); } - - pushNodeVariables(inst.node); - instance.descriptor = _templates->instantiateServer(*this, instance._cpp_template, instance.parameterValues); _variables->pop(); return instance; } diff --git a/cpp/src/IceGrid/IceGridNode.cpp b/cpp/src/IceGrid/IceGridNode.cpp index 805a05c28a6..883d116627a 100644 --- a/cpp/src/IceGrid/IceGridNode.cpp +++ b/cpp/src/IceGrid/IceGridNode.cpp @@ -9,6 +9,7 @@ #include <IceUtil/UUID.h> #include <Ice/Ice.h> +#include <Ice/Locator.h> #include <Ice/Service.h> #include <IceGrid/Activator.h> #include <IceGrid/WaitQueue.h> @@ -81,6 +82,21 @@ private: }; typedef IceUtil::Handle<KeepAliveThread> KeepAliveThreadPtr; +class ProcessI : public Process +{ +public: + + ProcessI(const ActivatorPtr&); + + virtual void shutdown(const Current&); + virtual void writeMessage(const std::string&, Int, const Current&); + +private: + + ActivatorPtr _activator; +}; + + class NodeService : public Service { public: @@ -162,6 +178,34 @@ CollocatedRegistry::shutdown() _activator->shutdown(); } +ProcessI::ProcessI(const ActivatorPtr& activator) : _activator(activator) +{ +} + +void +ProcessI::shutdown(const Current&) +{ + _activator->shutdown(); +} + +void +ProcessI::writeMessage(const string& message, Int fd, const Current&) +{ + switch(fd) + { + case 1: + { + cout << message << endl; + break; + } + case 2: + { + cerr << message << endl; + break; + } + } +} + NodeService::NodeService() { } @@ -314,7 +358,8 @@ NodeService::start(int argc, char* argv[]) if(::_stat(dataPath.c_str(), &filestat) != 0 || !S_ISDIR(filestat.st_mode)) { ostringstream os; - SyscallException ex(__FILE__, __LINE__); + FileException ex(__FILE__, __LINE__); + ex.path = dataPath; ex.error = getSystemErrno(); os << ex; error("property `IceGrid.Node.Data' is set to an invalid path:\n" + os.str()); @@ -325,7 +370,8 @@ NodeService::start(int argc, char* argv[]) if(::stat(dataPath.c_str(), &filestat) != 0 || !S_ISDIR(filestat.st_mode)) { ostringstream os; - SyscallException ex(__FILE__, __LINE__); + FileException ex(__FILE__, __LINE__); + ex.path = dataPath; ex.error = getSystemErrno(); os << ex; error("property `IceGrid.Node.Data' is set to an invalid path:\n" + os.str()); @@ -390,6 +436,8 @@ NodeService::start(int argc, char* argv[]) // // Create the node object adapter. // + properties->setProperty("IceGrid.Node.RegisterProcess", "0"); + properties->setProperty("IceGrid.Node.AdapterId", ""); ObjectAdapterPtr adapter = communicator()->createObjectAdapter("IceGrid.Node"); // @@ -416,19 +464,34 @@ NodeService::start(int argc, char* argv[]) _keepAliveThread->start(); // + // Add a process servant to allow shutdown through the process + // interface if a server id is set on the node. + // + if(!properties->getProperty("Ice.ServerId").empty() && communicator()->getDefaultLocator()) + { + try + { + ProcessPrx proxy = ProcessPrx::uncheckedCast(adapter->addWithUUID(new ProcessI(_activator))); + LocatorRegistryPrx locatorRegistry = communicator()->getDefaultLocator()->getRegistry(); + locatorRegistry->setServerProcessProxy(properties->getProperty("Ice.ServerId"), proxy); + } + catch(const Ice::ServerNotFoundException&) + { + } + catch(const Ice::LocalException& ex) + { + } + } + + // // Start the activator. // _activator->start(); // - // We are ready to go! Activate the object adapter. NOTE: we don't want the activate call to - // set the direct proxy of the object adapter with the locator registry. This was already - // taken care of by the node registry. Furthermore, this wouldn't work anyway because the - // locator registry proxy would have collocation optimization enabled. + // Activate the adapter. // - adapter->setLocator(0); adapter->activate(); - adapter->setLocator(communicator()->getDefaultLocator()); // // Deploy application if a descriptor is passed as a command-line option. diff --git a/cpp/src/IceGrid/ObserverSessionI.cpp b/cpp/src/IceGrid/ObserverSessionI.cpp index f2c4e8760a2..5803eb008e0 100644 --- a/cpp/src/IceGrid/ObserverSessionI.cpp +++ b/cpp/src/IceGrid/ObserverSessionI.cpp @@ -19,6 +19,7 @@ ObserverSessionI::ObserverSessionI(const string& userId, RegistryObserverTopic& registryObserverTopic, NodeObserverTopic& nodeObserverTopic) : _userId(userId), + _updating(false), _destroyed(false), _database(database), _registryObserverTopic(registryObserverTopic), diff --git a/cpp/src/IceGrid/ServerI.cpp b/cpp/src/IceGrid/ServerI.cpp index b7b6ca15e3c..d4cb62ab9bf 100644 --- a/cpp/src/IceGrid/ServerI.cpp +++ b/cpp/src/IceGrid/ServerI.cpp @@ -785,6 +785,7 @@ ServerI::addAdapter(const AdapterDescriptor& descriptor, const ServerPrx& self, current.adapter->add(new ServerAdapterI(_node, self, descriptor.id, _waitTime), id); } _adapters[descriptor.id] = AdapterPrx::uncheckedCast(current.adapter->createProxy(id)); + _processRegistered |= descriptor.registerProcess; } void diff --git a/cpp/test/IceGrid/Makefile b/cpp/test/IceGrid/Makefile index ee81f12fc54..78a043ff5d7 100644 --- a/cpp/test/IceGrid/Makefile +++ b/cpp/test/IceGrid/Makefile @@ -11,7 +11,7 @@ top_srcdir = ../.. include $(top_srcdir)/config/Make.rules -SUBDIRS = perf simple deployer +SUBDIRS = perf simple deployer update $(EVERYTHING):: @for subdir in $(SUBDIRS); \ diff --git a/cpp/test/IceGrid/simple/Makefile b/cpp/test/IceGrid/simple/Makefile index 523f458bbba..b17534becb4 100644 --- a/cpp/test/IceGrid/simple/Makefile +++ b/cpp/test/IceGrid/simple/Makefile @@ -34,7 +34,7 @@ CPPFLAGS := -I. -I../../include $(CPPFLAGS) $(CLIENT): $(OBJS) $(COBJS) rm -f $@ - $(CXX) $(LDFLAGS) -o $@ $(OBJS) $(COBJS) $(LIBS) -lIceGrid -lGlacier2 + $(CXX) $(LDFLAGS) -o $@ $(OBJS) $(COBJS) $(LIBS) -lIceGrid $(SERVER): $(OBJS) $(SOBJS) rm -f $@ diff --git a/cpp/test/IceGrid/update/AllTests.cpp b/cpp/test/IceGrid/update/AllTests.cpp index ef29323fd87..f2ad4bca864 100644 --- a/cpp/test/IceGrid/update/AllTests.cpp +++ b/cpp/test/IceGrid/update/AllTests.cpp @@ -10,6 +10,7 @@ #include <IceUtil/Thread.h> #include <Ice/Ice.h> #include <IceGrid/Observer.h> +#include <IceGrid/Admin.h> #include <TestCommon.h> #include <Test.h> @@ -94,7 +95,7 @@ public: { this->applications.insert(make_pair((*p)->name, *p)); } - this->nodes = nodes; + this->nodes = set<string>(nodes.begin(), nodes.end()); updated(serial); } @@ -136,11 +137,17 @@ public: virtual void nodeUp(const string& name, const Ice::Current& current) { + Lock sync(*this); + this->nodes.insert(name); + updated(); } virtual void nodeDown(const string& name, const Ice::Current& current) { + Lock sync(*this); + this->nodes.erase(name); + updated(); } void @@ -160,14 +167,17 @@ public: int serial; map<string, ApplicationDescriptorPtr> applications; - Ice::StringSeq nodes; + set<string> nodes; private: void - updated(int serial) + updated(int serial = -1) { - this->serial = serial; + if(serial != -1) + { + this->serial = serial; + } _updated = true; notifyAll(); } @@ -206,6 +216,11 @@ allTests(const Ice::CommunicatorPtr& communicator) SessionManagerPrx manager = SessionManagerPrx::checkedCast(communicator->stringToProxy("IceGrid/SessionManager")); test(manager); + AdminPrx admin = AdminPrx::checkedCast(communicator->stringToProxy("IceGrid/Admin")); + test(admin); + + Ice::PropertiesPtr properties = communicator->getProperties(); + SessionKeepAliveThreadPtr keepAlive; keepAlive = new SessionKeepAliveThread(communicator->getLogger(), IceUtil::Time::seconds(5)); keepAlive->start(); @@ -413,7 +428,7 @@ allTests(const Ice::CommunicatorPtr& communicator) } { - cout << "testing observers... " << flush; + cout << "testing registry observer... " << flush; SessionPrx session1 = manager->createLocalSession("Observer1"); keepAlive->add(session1); @@ -443,8 +458,9 @@ allTests(const Ice::CommunicatorPtr& communicator) test(regObs1->applications["Application"]); test(++serial == regObs1->serial); } - catch(const Ice::UserException&) + catch(const Ice::UserException& ex) { + cerr << ex << endl; test(false); } @@ -459,8 +475,9 @@ allTests(const Ice::CommunicatorPtr& communicator) test(regObs1->applications["Application"]->variables["test"] == "test"); test(++serial == regObs1->serial); } - catch(const Ice::UserException&) + catch(const Ice::UserException& ex) { + cerr << ex << endl; test(false); } @@ -477,8 +494,9 @@ allTests(const Ice::CommunicatorPtr& communicator) test(regObs1->applications["Application"]->variables["test1"] == "test"); test(++serial == regObs1->serial); } - catch(const Ice::UserException&) + catch(const Ice::UserException& ex) { + cerr << ex << endl; test(false); } @@ -489,8 +507,79 @@ allTests(const Ice::CommunicatorPtr& communicator) test(regObs1->applications.empty()); test(++serial == regObs1->serial); } - catch(const Ice::UserException&) + catch(const Ice::UserException& ex) + { + cerr << ex << endl; + test(false); + } + + // + // Setup a descriptor to deploy a node on the node. + // + ApplicationDescriptorPtr nodeApp = new ApplicationDescriptor(); + nodeApp->name = "NodeApp"; + ServerDescriptorPtr server = new ServerDescriptor(); + server->name = "node-1"; + server->exe = properties->getProperty("IceDir") + "/bin/icegridnode"; + AdapterDescriptor adapter; + adapter.name = "IceGrid.Node"; + adapter.endpoints = "default"; + adapter.id = "IceGrid.Node.node-1"; + adapter.registerProcess = true; + server->adapters.push_back(adapter); + PropertyDescriptor prop; + prop.name = "IceGrid.Node.Name"; + prop.value = "node-1"; + server->properties.push_back(prop); + prop.name = "IceGrid.Node.Data"; + prop.value = properties->getProperty("TestDir") + "/db/node-1"; + server->properties.push_back(prop); + ServerInstanceDescriptor instance; + instance.descriptor = server; + instance.node = "localnode"; + nodeApp->servers.push_back(instance); + + try + { + session1->startUpdate(serial); + session1->addApplication(nodeApp); + regObs1->waitForUpdate(__FILE__, __LINE__); + test(regObs1->applications["NodeApp"]); + test(++serial == regObs1->serial); + } + catch(const DeploymentException& ex) + { + cerr << ex.reason << endl; + test(false); + } + catch(const Ice::UserException& ex) { + cerr << ex << endl; + test(false); + } + + admin->startServer("node-1"); + regObs1->waitForUpdate(__FILE__, __LINE__); + test(regObs1->nodes.find("node-1") != regObs1->nodes.end()); + admin->stopServer("node-1"); + regObs1->waitForUpdate(__FILE__, __LINE__); + test(regObs1->nodes.find("node-1") == regObs1->nodes.end()); + + try + { + session1->removeApplication("NodeApp"); + regObs1->waitForUpdate(__FILE__, __LINE__); + test(regObs1->applications.empty()); + test(++serial == regObs1->serial); + } + catch(const DeploymentException& ex) + { + cerr << ex.reason << endl; + test(false); + } + catch(const Ice::UserException& ex) + { + cerr << ex << endl; test(false); } diff --git a/cpp/test/IceGrid/update/Client.cpp b/cpp/test/IceGrid/update/Client.cpp index 4e4c921ec05..c2dc6eac0b1 100644 --- a/cpp/test/IceGrid/update/Client.cpp +++ b/cpp/test/IceGrid/update/Client.cpp @@ -26,10 +26,11 @@ main(int argc, char* argv[]) { int status; Ice::CommunicatorPtr communicator; - try { + communicator = Ice::initialize(argc, argv); + communicator->getProperties()->parseCommandLineOptions("", Ice::argsToStringSeq(argc, argv)); status = run(argc, argv, communicator); } catch(const Ice::Exception& ex) diff --git a/cpp/test/IceGrid/update/run.py b/cpp/test/IceGrid/update/run.py index 6f94ef3559b..1319b654aeb 100755 --- a/cpp/test/IceGrid/update/run.py +++ b/cpp/test/IceGrid/update/run.py @@ -30,12 +30,17 @@ client = os.path.join(testdir, "client") # invokes on the locator it's also considered to be a client. # additionalOptions = " --Ice.Default.Locator=\"IceGrid/Locator:default -p 12345\" " + \ - "--Ice.PrintAdapterReady=0 --Ice.PrintProcessId=0" + "--Ice.PrintAdapterReady=0 --Ice.PrintProcessId=0 --IceDir=\"" + toplevel + "\" --TestDir=\"" + testdir + "\"" IceGridAdmin.cleanDbDir(os.path.join(testdir, "db")) iceGridRegistryThread = IceGridAdmin.startIceGridRegistry("12345", testdir) iceGridNodeThread = IceGridAdmin.startIceGridNode(testdir) +node1Dir = os.path.join(testdir, "db", "node-1") +if not os.path.exists(node1Dir): + os.mkdir(node1Dir) +IceGridAdmin.cleanServerDir(node1Dir); + print "starting client...", clientPipe = os.popen(client + TestUtil.clientServerOptions + additionalOptions + " 2>&1") print "ok" |