summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2006-09-29 13:37:23 +0000
committerBenoit Foucher <benoit@zeroc.com>2006-09-29 13:37:23 +0000
commit5417605aa88e9019997ca50b4ad7692bedc09fc5 (patch)
tree5c2df2f7eb277606f02919009f68f8a55cec91f7 /cpp/src
parentFixed windows compile error (diff)
downloadice-5417605aa88e9019997ca50b4ad7692bedc09fc5.tar.bz2
ice-5417605aa88e9019997ca50b4ad7692bedc09fc5.tar.xz
ice-5417605aa88e9019997ca50b4ad7692bedc09fc5.zip
Added back support for --deploy option. Locking the registry isn't required
anymore to update the database.
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/IceGrid/Client.cpp11
-rw-r--r--cpp/src/IceGrid/Database.cpp10
-rw-r--r--cpp/src/IceGrid/Database.h4
-rw-r--r--cpp/src/IceGrid/IceGridNode.cpp150
4 files changed, 108 insertions, 67 deletions
diff --git a/cpp/src/IceGrid/Client.cpp b/cpp/src/IceGrid/Client.cpp
index c9d9d6b122b..329d12dc2ab 100644
--- a/cpp/src/IceGrid/Client.cpp
+++ b/cpp/src/IceGrid/Client.cpp
@@ -407,7 +407,6 @@ Client::run(int argc, char* argv[])
}
ParserPtr p = Parser::createParser(communicator(), admin);
- session->startUpdate();
int status = EXIT_SUCCESS;
@@ -471,16 +470,6 @@ Client::run(int argc, char* argv[])
}
}
- try
- {
- session->finishUpdate();
- }
- catch(const Ice::Exception&)
- {
- // Ignore. If the registry has been shutdown this will cause
- // an exception.
- }
-
keepAlive->destroy();
keepAlive->getThreadControl().join();
diff --git a/cpp/src/IceGrid/Database.cpp b/cpp/src/IceGrid/Database.cpp
index df7c4130c29..683bf379d52 100644
--- a/cpp/src/IceGrid/Database.cpp
+++ b/cpp/src/IceGrid/Database.cpp
@@ -239,11 +239,7 @@ Database::getObserverTopic(TopicName name) const
void
Database::checkSessionLock(AdminSessionI* session)
{
- if(_lock == 0 && session)
- {
- throw AccessDeniedException(); // Sessions must first acquire the lock!
- }
- else if(_lock != 0 && session != _lock)
+ if(_lock != 0 && session != _lock)
{
throw AccessDeniedException(_lockUserId); // Lock held by another session.
}
@@ -495,8 +491,6 @@ Database::updateApplication(const ApplicationUpdateInfo& updt, AdminSessionI* se
void
Database::syncApplicationDescriptor(const ApplicationDescriptor& newDesc, AdminSessionI* session)
{
- assert(session);
-
ServerEntrySeq entries;
ApplicationUpdateInfo update;
ApplicationInfo oldApp;
@@ -539,8 +533,6 @@ Database::instantiateServer(const string& application,
const ServerInstanceDescriptor& instance,
AdminSessionI* session)
{
- assert(session);
-
ServerEntrySeq entries;
ApplicationUpdateInfo update;
ApplicationInfo oldApp;
diff --git a/cpp/src/IceGrid/Database.h b/cpp/src/IceGrid/Database.h
index aa97addfd94..9c027cab800 100644
--- a/cpp/src/IceGrid/Database.h
+++ b/cpp/src/IceGrid/Database.h
@@ -75,8 +75,8 @@ public:
void addApplication(const ApplicationInfo&, AdminSessionI* = 0);
void updateApplication(const ApplicationUpdateInfo&, AdminSessionI* = 0);
- void syncApplicationDescriptor(const ApplicationDescriptor&, AdminSessionI*);
- void instantiateServer(const std::string&, const std::string&, const ServerInstanceDescriptor&, AdminSessionI*);
+ void syncApplicationDescriptor(const ApplicationDescriptor&, AdminSessionI* = 0);
+ void instantiateServer(const std::string&, const std::string&, const ServerInstanceDescriptor&, AdminSessionI* =0);
void removeApplication(const std::string&, AdminSessionI* = 0);
ApplicationInfo getApplicationInfo(const std::string&);
diff --git a/cpp/src/IceGrid/IceGridNode.cpp b/cpp/src/IceGrid/IceGridNode.cpp
index c963a231620..f28413dd856 100644
--- a/cpp/src/IceGrid/IceGridNode.cpp
+++ b/cpp/src/IceGrid/IceGridNode.cpp
@@ -81,6 +81,7 @@ protected:
private:
void usage(const std::string&);
+ string trim(const string&);
ActivatorPtr _activator;
WaitQueuePtr _waitQueue;
@@ -495,65 +496,112 @@ NodeService::start(int argc, char* argv[])
//
_adapter->activate();
+ string bundleName = properties->getProperty("IceGrid.Node.PrintServersReady");
+ if(!bundleName.empty() || !desc.empty())
+ {
+ enableInterrupt();
+ _sessions.waitForCreate();
+ disableInterrupt();
+ }
+
//
// Deploy application if a descriptor is passed as a command-line option.
//
if(!desc.empty())
{
- AdminPrx admin;
- try
- {
- const string adminId = instanceName + "/Admin";
- admin = AdminPrx::checkedCast(communicator()->stringToProxy(adminId));
- }
- catch(const LocalException& ex)
- {
- ostringstream ostr;
- ostr << "couldn't contact IceGrid admin interface to deploy application `" << desc << "':\n" << ex;
- warning(ostr.str());
- }
-
- if(admin)
- {
- try
- {
- map<string, string> vars;
- ApplicationDescriptor app;
- app = DescriptorParser::parseDescriptor(desc, targets, vars, communicator(), admin);
- try
+ try
+ {
+ Ice::Identity registryId;
+ registryId.category = instanceName;
+ registryId.name = "Registry";
+
+ RegistryPrx registry = RegistryPrx::checkedCast(
+ communicator()->stringToProxy("\"" + communicator()->identityToString(registryId) + "\""));
+ if(!registry)
+ {
+ throw "invalid registry";
+ }
+
+ //
+ // Use SSL if available.
+ //
+ try
+ {
+ registry = RegistryPrx::checkedCast(registry->ice_secure(true));
+ }
+ catch(const Ice::NoEndpointException&)
+ {
+ }
+
+ IceGrid::AdminSessionPrx session;
+ if(communicator()->getProperties()->getPropertyAsInt("IceGridAdmin.AuthenticateUsingSSL"))
+ {
+ session = registry->createAdminSessionFromSecureConnection();
+ }
+ else
+ {
+ string id = communicator()->getProperties()->getProperty("IceGridAdmin.Username");
+ string password = communicator()->getProperties()->getProperty("IceGridAdmin.Password");
+ while(id.empty())
{
- admin->syncApplication(app);
+ cout << "user id: " << flush;
+ getline(cin, id);
+ id = trim(id);
}
- catch(const ApplicationNotExistException&)
+
+ if(password.empty())
{
- admin->addApplication(app);
+ cout << "password: " << flush;
+ getline(cin, password);
+ password = trim(password);
}
+
+ session = registry->createAdminSession(id, password);
}
- catch(const DeploymentException& ex)
- {
- ostringstream ostr;
- ostr << "failed to deploy application `" << desc << "':\n" << ex << ": " << ex.reason;
- warning(ostr.str());
- }
- catch(const LocalException& ex)
- {
- ostringstream ostr;
- ostr << "failed to deploy application `" << desc << "':\n" << ex;
- warning(ostr.str());
- }
- }
+ assert(session);
+
+ AdminPrx admin = session->getAdmin();
+ map<string, string> vars;
+ ApplicationDescriptor app = DescriptorParser::parseDescriptor(desc, targets, vars, communicator(), admin);
+
+ try
+ {
+ admin->syncApplication(app);
+ }
+ catch(const ApplicationNotExistException&)
+ {
+ admin->addApplication(app);
+ }
+ }
+ catch(const DeploymentException& ex)
+ {
+ ostringstream ostr;
+ ostr << "failed to deploy application `" << desc << "':\n" << ex << ": " << ex.reason;
+ warning(ostr.str());
+ }
+ catch(const AccessDeniedException& ex)
+ {
+ ostringstream ostr;
+ ostr << "failed to deploy application `" << desc << "':\n"
+ << "registry database is locked by `" << ex.lockUserId << "'";
+ warning(ostr.str());
+ }
+ catch(const LocalException& ex)
+ {
+ ostringstream ostr;
+ ostr << "failed to deploy application `" << desc << "':\n" << ex;
+ warning(ostr.str());
+ }
+ catch(const string& reason)
+ {
+ ostringstream ostr;
+ ostr << "failed to deploy application `" << desc << "':\n" << reason;
+ warning(ostr.str());
+ }
}
- string bundleName = properties->getProperty("IceGrid.Node.PrintServersReady");
if(!bundleName.empty())
{
- //
- // We wait for the node to be registered with the registry
- // before to claim it's ready.
- //
- enableInterrupt();
- _sessions.waitForCreate();
- disableInterrupt();
print(bundleName + " ready");
}
@@ -712,6 +760,18 @@ NodeService::usage(const string& appName)
print("Usage: " + appName + " [options]\n" + options);
}
+string
+NodeService::trim(const string& s)
+{
+ static const string delims = "\t\r\n ";
+ string::size_type last = s.find_last_not_of(delims);
+ if(last != string::npos)
+ {
+ return s.substr(s.find_first_not_of(delims), last+1);
+ }
+ return s;
+}
+
int
main(int argc, char* argv[])
{