summaryrefslogtreecommitdiff
path: root/cpp/src/IceGrid
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src/IceGrid')
-rw-r--r--cpp/src/IceGrid/Activator.cpp1182
-rw-r--r--cpp/src/IceGrid/Activator.h12
-rw-r--r--cpp/src/IceGrid/AdapterCache.cpp274
-rw-r--r--cpp/src/IceGrid/AdapterCache.h2
-rw-r--r--cpp/src/IceGrid/AdminI.cpp362
-rw-r--r--cpp/src/IceGrid/AdminI.h4
-rw-r--r--cpp/src/IceGrid/AdminSessionI.cpp266
-rw-r--r--cpp/src/IceGrid/AdminSessionI.h8
-rw-r--r--cpp/src/IceGrid/Allocatable.cpp476
-rw-r--r--cpp/src/IceGrid/Allocatable.h8
-rw-r--r--cpp/src/IceGrid/AllocatableObjectCache.cpp224
-rw-r--r--cpp/src/IceGrid/AllocatableObjectCache.h24
-rw-r--r--cpp/src/IceGrid/Cache.h114
-rw-r--r--cpp/src/IceGrid/Client.cpp644
-rw-r--r--cpp/src/IceGrid/Database.cpp1358
-rw-r--r--cpp/src/IceGrid/Database.h4
-rw-r--r--cpp/src/IceGrid/DescriptorBuilder.cpp216
-rw-r--r--cpp/src/IceGrid/DescriptorBuilder.h4
-rw-r--r--cpp/src/IceGrid/DescriptorHelper.cpp2678
-rw-r--r--cpp/src/IceGrid/DescriptorHelper.h18
-rw-r--r--cpp/src/IceGrid/DescriptorParser.cpp1220
-rw-r--r--cpp/src/IceGrid/DescriptorParser.h8
-rw-r--r--cpp/src/IceGrid/FileCache.cpp170
-rwxr-xr-xcpp/src/IceGrid/FileParserI.cpp6
-rw-r--r--cpp/src/IceGrid/FileUserAccountMapperI.cpp82
-rw-r--r--cpp/src/IceGrid/IceGridNode.cpp518
-rw-r--r--cpp/src/IceGrid/IceGridRegistry.cpp74
-rw-r--r--cpp/src/IceGrid/Internal.ice40
-rw-r--r--cpp/src/IceGrid/InternalRegistryI.cpp62
-rw-r--r--cpp/src/IceGrid/InternalRegistryI.h6
-rw-r--r--cpp/src/IceGrid/LocatorI.cpp414
-rw-r--r--cpp/src/IceGrid/LocatorI.h42
-rw-r--r--cpp/src/IceGrid/LocatorRegistryI.cpp370
-rw-r--r--cpp/src/IceGrid/LocatorRegistryI.h10
-rw-r--r--cpp/src/IceGrid/NodeCache.cpp824
-rw-r--r--cpp/src/IceGrid/NodeI.cpp1066
-rw-r--r--cpp/src/IceGrid/NodeI.h20
-rw-r--r--cpp/src/IceGrid/NodeSessionI.cpp208
-rw-r--r--cpp/src/IceGrid/NodeSessionI.h4
-rw-r--r--cpp/src/IceGrid/NodeSessionManager.cpp458
-rw-r--r--cpp/src/IceGrid/NodeSessionManager.h50
-rw-r--r--cpp/src/IceGrid/ObjectCache.cpp36
-rw-r--r--cpp/src/IceGrid/ObjectCache.h14
-rw-r--r--cpp/src/IceGrid/Parser.cpp1744
-rw-r--r--cpp/src/IceGrid/PlatformInfo.cpp158
-rw-r--r--cpp/src/IceGrid/QueryI.cpp40
-rw-r--r--cpp/src/IceGrid/QueryI.h2
-rw-r--r--cpp/src/IceGrid/ReapThread.cpp146
-rw-r--r--cpp/src/IceGrid/ReapThread.h48
-rw-r--r--cpp/src/IceGrid/RegistryI.cpp942
-rw-r--r--cpp/src/IceGrid/RegistryI.h8
-rw-r--r--cpp/src/IceGrid/ReplicaCache.cpp194
-rw-r--r--cpp/src/IceGrid/ReplicaSessionI.cpp134
-rw-r--r--cpp/src/IceGrid/ReplicaSessionI.h4
-rw-r--r--cpp/src/IceGrid/ReplicaSessionManager.cpp698
-rw-r--r--cpp/src/IceGrid/ReplicaSessionManager.h40
-rw-r--r--cpp/src/IceGrid/ServerAdapterI.cpp140
-rw-r--r--cpp/src/IceGrid/ServerCache.cpp1000
-rw-r--r--cpp/src/IceGrid/ServerI.cpp2484
-rw-r--r--cpp/src/IceGrid/ServerI.h32
-rw-r--r--cpp/src/IceGrid/SessionI.cpp168
-rw-r--r--cpp/src/IceGrid/SessionI.h6
-rw-r--r--cpp/src/IceGrid/SessionManager.h352
-rw-r--r--cpp/src/IceGrid/SessionServantLocatorI.cpp4
-rw-r--r--cpp/src/IceGrid/SessionServantLocatorI.h6
-rw-r--r--cpp/src/IceGrid/Topics.cpp530
-rw-r--r--cpp/src/IceGrid/Util.cpp72
-rw-r--r--cpp/src/IceGrid/Util.h26
-rw-r--r--cpp/src/IceGrid/WaitQueue.cpp160
-rw-r--r--cpp/src/IceGrid/WellKnownObjectsManager.cpp6
70 files changed, 11362 insertions, 11362 deletions
diff --git a/cpp/src/IceGrid/Activator.cpp b/cpp/src/IceGrid/Activator.cpp
index c9535ba7814..8d6c04aa3ca 100644
--- a/cpp/src/IceGrid/Activator.cpp
+++ b/cpp/src/IceGrid/Activator.cpp
@@ -41,14 +41,14 @@ class TerminationListenerThread : public IceUtil::Thread
public:
TerminationListenerThread(Activator& activator) :
- _activator(activator)
+ _activator(activator)
{
}
virtual
void run()
{
- _activator.runTerminationListener();
+ _activator.runTerminationListener();
}
private:
@@ -81,8 +81,8 @@ reportChildError(int err, int fd, const char* cannot, const char* name)
strcat(msg, "'");
if(err)
{
- strcat(msg, ": ");
- strcat(msg, strerror(err));
+ strcat(msg, ": ");
+ strcat(msg, strerror(err));
}
write(fd, msg, strlen(msg));
close(fd);
@@ -102,68 +102,68 @@ signalToString(int signal)
{
switch(signal)
{
- case SIGHUP:
- {
- return ICE_STRING(SIGHUP);
- }
- case SIGINT:
- {
- return ICE_STRING(SIGINT);
- }
- case SIGQUIT:
- {
- return ICE_STRING(SIGQUIT);
- }
- case SIGILL:
- {
- return ICE_STRING(SIGILL);
- }
- case SIGTRAP:
- {
- return ICE_STRING(SIGTRAP);
- }
- case SIGABRT:
- {
- return ICE_STRING(SIGABRT);
- }
- case SIGBUS:
- {
- return ICE_STRING(SIGBUS);
- }
- case SIGFPE:
- {
- return ICE_STRING(SIGFPE);
- }
- case SIGKILL:
- {
- return ICE_STRING(SIGKILL);
- }
- case SIGUSR1:
- {
- return ICE_STRING(SIGUSR1);
- }
- case SIGSEGV:
- {
- return ICE_STRING(SIGSEGV);
- }
- case SIGPIPE:
- {
- return ICE_STRING(SIGPIPE);
- }
- case SIGALRM:
- {
- return ICE_STRING(SIGALRM);
- }
- case SIGTERM:
- {
- return ICE_STRING(SIGTERM);
- }
- default:
- {
- ostringstream os;
- os << "signal " << signal;
- return os.str();
- }
+ case SIGHUP:
+ {
+ return ICE_STRING(SIGHUP);
+ }
+ case SIGINT:
+ {
+ return ICE_STRING(SIGINT);
+ }
+ case SIGQUIT:
+ {
+ return ICE_STRING(SIGQUIT);
+ }
+ case SIGILL:
+ {
+ return ICE_STRING(SIGILL);
+ }
+ case SIGTRAP:
+ {
+ return ICE_STRING(SIGTRAP);
+ }
+ case SIGABRT:
+ {
+ return ICE_STRING(SIGABRT);
+ }
+ case SIGBUS:
+ {
+ return ICE_STRING(SIGBUS);
+ }
+ case SIGFPE:
+ {
+ return ICE_STRING(SIGFPE);
+ }
+ case SIGKILL:
+ {
+ return ICE_STRING(SIGKILL);
+ }
+ case SIGUSR1:
+ {
+ return ICE_STRING(SIGUSR1);
+ }
+ case SIGSEGV:
+ {
+ return ICE_STRING(SIGSEGV);
+ }
+ case SIGPIPE:
+ {
+ return ICE_STRING(SIGPIPE);
+ }
+ case SIGALRM:
+ {
+ return ICE_STRING(SIGALRM);
+ }
+ case SIGTERM:
+ {
+ return ICE_STRING(SIGTERM);
+ }
+ default:
+ {
+ ostringstream os;
+ os << "signal " << signal;
+ return os.str();
+ }
}
#endif
}
@@ -177,77 +177,77 @@ stringToSignal(const string& str)
if(str == ICE_STRING(SIGHUP))
{
- return SIGHUP;
+ return SIGHUP;
}
else if(str == ICE_STRING(SIGINT))
{
- return SIGINT;
+ return SIGINT;
}
else if(str == ICE_STRING(SIGQUIT))
{
- return SIGQUIT;
+ return SIGQUIT;
}
else if(str == ICE_STRING(SIGILL))
{
- return SIGILL;
+ return SIGILL;
}
else if(str == ICE_STRING(SIGTRAP))
{
- return SIGTRAP;
+ return SIGTRAP;
}
else if(str == ICE_STRING(SIGABRT))
{
- return SIGABRT;
+ return SIGABRT;
}
else if(str == ICE_STRING(SIGBUS))
{
- return SIGBUS;
+ return SIGBUS;
}
else if(str == ICE_STRING(SIGFPE))
{
- return SIGFPE;
+ return SIGFPE;
}
else if(str == ICE_STRING(SIGKILL))
{
- return SIGKILL;
+ return SIGKILL;
}
else if(str == ICE_STRING(SIGUSR1))
{
- return SIGUSR1;
+ return SIGUSR1;
}
else if(str == ICE_STRING(SIGSEGV))
{
- return SIGSEGV;
+ return SIGSEGV;
}
else if(str == ICE_STRING(SIGUSR2))
{
- return SIGUSR2;
+ return SIGUSR2;
}
else if(str == ICE_STRING(SIGPIPE))
{
- return SIGPIPE;
+ return SIGPIPE;
}
else if(str == ICE_STRING(SIGALRM))
{
- return SIGALRM;
+ return SIGALRM;
}
else if(str == ICE_STRING(SIGTERM))
{
- return SIGTERM;
+ return SIGTERM;
}
else
{
- if(str != "")
- {
- char* end;
- long int signal = strtol(str.c_str(), &end, 10);
- if(*end == '\0' && signal > 0 && signal < 64)
- {
- return static_cast<int>(signal);
- }
- }
- throw BadSignalException("unknown signal `" + str + "'");
- return SIGTERM; // Keep the compiler happy.
+ if(str != "")
+ {
+ char* end;
+ long int signal = strtol(str.c_str(), &end, 10);
+ if(*end == '\0' && signal > 0 && signal < 64)
+ {
+ return static_cast<int>(signal);
+ }
+ }
+ throw BadSignalException("unknown signal `" + str + "'");
+ return SIGTERM; // Keep the compiler happy.
}
}
#endif
@@ -268,17 +268,17 @@ Activator::Activator(const TraceLevelsPtr& traceLevels) :
if(_hIntr == NULL)
{
- SyscallException ex(__FILE__, __LINE__);
- ex.error = getSystemErrno();
- throw ex;
+ SyscallException ex(__FILE__, __LINE__);
+ ex.error = getSystemErrno();
+ throw ex;
}
#else
int fds[2];
if(pipe(fds) != 0)
{
- SyscallException ex(__FILE__, __LINE__);
- ex.error = getSystemErrno();
- throw ex;
+ SyscallException ex(__FILE__, __LINE__);
+ ex.error = getSystemErrno();
+ throw ex;
}
_fdIntrRead = fds[0];
_fdIntrWrite = fds[1];
@@ -307,56 +307,56 @@ Activator::~Activator()
int
Activator::activate(const string& name,
- const string& exePath,
- const string& pwdPath,
+ const string& exePath,
+ const string& pwdPath,
#ifndef _WIN32
- uid_t uid,
- gid_t gid,
+ uid_t uid,
+ gid_t gid,
#endif
- const Ice::StringSeq& options,
- const Ice::StringSeq& envs,
- const ServerIPtr& server)
+ const Ice::StringSeq& options,
+ const Ice::StringSeq& envs,
+ const ServerIPtr& server)
{
IceUtil::Monitor< IceUtil::Mutex>::Lock sync(*this);
if(_deactivating)
{
- throw string("The node is being shutdown.");
+ throw string("The node is being shutdown.");
}
string path = exePath;
if(path.empty())
{
- throw string("The server executable path is empty.");
+ throw string("The server executable path is empty.");
}
string pwd = IcePatch2::simplify(pwdPath);
#ifdef _WIN32
if(!IcePatch2::isAbsolute(path))
{
- if(path.find('/') == string::npos)
- {
- //
- // Get the absolute pathname of the executable.
- //
- char absbuf[_MAX_PATH];
- char* filePart;
- string ext = path.size() <= 4 || path[path.size() - 4] != '.' ? ".exe" : "";
- if(SearchPath(NULL, path.c_str(), ext.c_str(), _MAX_PATH, absbuf, &filePart) == 0)
- {
- if(_traceLevels->activator > 0)
- {
- Trace out(_traceLevels->logger, _traceLevels->activatorCat);
- out << "cannot convert `" << path << "' into an absolute path";
- }
- throw string("The server executable path `" + path + "' can't be converted into an absolute path.");
- }
- path = absbuf;
- }
- else if(!pwd.empty())
- {
- path = pwd + "/" + path;
- }
+ if(path.find('/') == string::npos)
+ {
+ //
+ // Get the absolute pathname of the executable.
+ //
+ char absbuf[_MAX_PATH];
+ char* filePart;
+ string ext = path.size() <= 4 || path[path.size() - 4] != '.' ? ".exe" : "";
+ if(SearchPath(NULL, path.c_str(), ext.c_str(), _MAX_PATH, absbuf, &filePart) == 0)
+ {
+ if(_traceLevels->activator > 0)
+ {
+ Trace out(_traceLevels->logger, _traceLevels->activatorCat);
+ out << "cannot convert `" << path << "' into an absolute path";
+ }
+ throw string("The server executable path `" + path + "' can't be converted into an absolute path.");
+ }
+ path = absbuf;
+ }
+ else if(!pwd.empty())
+ {
+ path = pwd + "/" + path;
+ }
}
//
@@ -364,17 +364,17 @@ Activator::activate(const string& name,
//
if(!pwd.empty())
{
- char absbuf[_MAX_PATH];
- if(_fullpath(absbuf, pwd.c_str(), _MAX_PATH) == NULL)
- {
- if(_traceLevels->activator > 0)
- {
- Trace out(_traceLevels->logger, _traceLevels->activatorCat);
- out << "cannot convert `" << pwd << "' into an absolute path";
- }
- throw string("The server working directory path `" + pwd + "' can't be converted into an absolute path.");
- }
- pwd = absbuf;
+ char absbuf[_MAX_PATH];
+ if(_fullpath(absbuf, pwd.c_str(), _MAX_PATH) == NULL)
+ {
+ if(_traceLevels->activator > 0)
+ {
+ Trace out(_traceLevels->logger, _traceLevels->activatorCat);
+ out << "cannot convert `" << pwd << "' into an absolute path";
+ }
+ throw string("The server working directory path `" + pwd + "' can't be converted into an absolute path.");
+ }
+ pwd = absbuf;
}
#endif
@@ -387,41 +387,41 @@ Activator::activate(const string& name,
if(_traceLevels->activator > 0)
{
- Ice::Trace out(_traceLevels->logger, _traceLevels->activatorCat);
- out << "activating server `" << name << "'";
- if(_traceLevels->activator > 1)
- {
- out << "\n";
- out << "path = " << path << "\n";
- if(pwd.empty())
- {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->activatorCat);
+ out << "activating server `" << name << "'";
+ if(_traceLevels->activator > 1)
+ {
+ out << "\n";
+ out << "path = " << path << "\n";
+ if(pwd.empty())
+ {
#ifdef _WIN32
- char cwd[_MAX_PATH];
- if(_getcwd(cwd, _MAX_PATH) != NULL)
+ char cwd[_MAX_PATH];
+ if(_getcwd(cwd, _MAX_PATH) != NULL)
#else
- char cwd[PATH_MAX];
- if(getcwd(cwd, PATH_MAX) != NULL)
+ char cwd[PATH_MAX];
+ if(getcwd(cwd, PATH_MAX) != NULL)
#endif
- {
- out << "pwd = " << string(cwd) << "\n";
- }
- }
- else
- {
- out << "pwd = " << pwd << "\n";
- }
+ {
+ out << "pwd = " << string(cwd) << "\n";
+ }
+ }
+ else
+ {
+ out << "pwd = " << pwd << "\n";
+ }
#ifndef _WIN32
- out << "uid/gid = " << uid << "/" << gid << "\n";
+ out << "uid/gid = " << uid << "/" << gid << "\n";
#endif
- if(!envs.empty())
- {
- out << "envs = " << toString(envs, ", ") << "\n";
- }
- if(!args.empty())
- {
- out << "args = " << toString(args);
- }
- }
+ if(!envs.empty())
+ {
+ out << "envs = " << toString(envs, ", ") << "\n";
+ }
+ if(!args.empty())
+ {
+ out << "args = " << toString(args);
+ }
+ }
}
//
@@ -500,8 +500,8 @@ Activator::activate(const string& name,
string::size_type pos = s.find('=');
if(pos != string::npos)
{
- string key = s.substr(0, pos);
- std::transform(key.begin(), key.end(), key.begin(), toupper);
+ string key = s.substr(0, pos);
+ std::transform(key.begin(), key.end(), key.begin(), toupper);
envMap.insert(map<string, string>::value_type(key, s.substr(pos + 1)));
}
var += s.size();
@@ -514,9 +514,9 @@ Activator::activate(const string& name,
string::size_type pos = s.find('=');
if(pos != string::npos)
{
- string key = s.substr(0, pos);
- std::transform(key.begin(), key.end(), key.begin(), toupper);
- envMap.erase(key);
+ string key = s.substr(0, pos);
+ std::transform(key.begin(), key.end(), key.begin(), toupper);
+ envMap.erase(key);
envMap.insert(map<string, string>::value_type(key, s.substr(pos + 1)));
}
}
@@ -591,9 +591,9 @@ Activator::activate(const string& name,
int fds[2];
if(pipe(fds) != 0)
{
- SyscallException ex(__FILE__, __LINE__);
- ex.error = getSystemErrno();
- throw ex;
+ SyscallException ex(__FILE__, __LINE__);
+ ex.error = getSystemErrno();
+ throw ex;
}
//
@@ -604,8 +604,8 @@ Activator::activate(const string& name,
int i = 0;
for(StringSeq::const_iterator p = args.begin(); p != args.end(); ++p, ++i)
{
- assert(i < argc);
- argv[i] = strdup(p->c_str());
+ assert(i < argc);
+ argv[i] = strdup(p->c_str());
}
assert(i == argc);
argv[argc] = 0;
@@ -615,7 +615,7 @@ Activator::activate(const string& name,
i = 0;
for(StringSeq::const_iterator q = envs.begin(); q != envs.end(); ++q)
{
- envArray[i++] = strdup(q->c_str());
+ envArray[i++] = strdup(q->c_str());
}
//
@@ -626,118 +626,118 @@ Activator::activate(const string& name,
pid_t pid = fork();
if(pid == -1)
{
- SyscallException ex(__FILE__, __LINE__);
- ex.error = getSystemErrno();
- throw ex;
+ SyscallException ex(__FILE__, __LINE__);
+ ex.error = getSystemErrno();
+ throw ex;
}
if(pid == 0) // Child process.
{
- //
- // Until exec, we can only use async-signal safe functions
- //
-
- //
- // Change the uid/gid under which the process will run.
- //
- if(setgid(gid) == -1)
- {
- ostringstream os;
- os << gid;
- reportChildError(getSystemErrno(), fds[1], "cannot set process group id", os.str().c_str());
- }
-
- if(setuid(uid) == -1)
- {
- ostringstream os;
- os << uid;
- reportChildError(getSystemErrno(), fds[1], "cannot set process user id", os.str().c_str());
- }
-
- //
- // Assign a new process group for this process.
- //
- setpgid(0, 0);
-
- //
- // Close all file descriptors, except for standard input,
- // standard output, standard error, and the write side
- // of the newly created pipe.
- //
- int maxFd = static_cast<int>(sysconf(_SC_OPEN_MAX));
- for(int fd = 3; fd < maxFd; ++fd)
- {
- if(fd != fds[1])
- {
- close(fd);
- }
- }
-
- for(i = 0; i < envCount; i++)
- {
- if(putenv(envArray[i]) != 0)
- {
- reportChildError(errno, fds[1], "cannot set environment variable", envArray[i]);
- }
- }
- //
- // Each env is leaked on purpose ... see man putenv().
- //
- delete[] envArray;
-
- //
- // Change working directory.
- //
- if(strlen(pwdCStr) != 0)
- {
- if(chdir(pwdCStr) == -1)
- {
- reportChildError(errno, fds[1], "cannot change working directory to", pwdCStr);
- }
- }
-
- if(execvp(argv[0], argv) == -1)
- {
- reportChildError(errno, fds[1], "cannot execute", argv[0]);
- }
+ //
+ // Until exec, we can only use async-signal safe functions
+ //
+
+ //
+ // Change the uid/gid under which the process will run.
+ //
+ if(setgid(gid) == -1)
+ {
+ ostringstream os;
+ os << gid;
+ reportChildError(getSystemErrno(), fds[1], "cannot set process group id", os.str().c_str());
+ }
+
+ if(setuid(uid) == -1)
+ {
+ ostringstream os;
+ os << uid;
+ reportChildError(getSystemErrno(), fds[1], "cannot set process user id", os.str().c_str());
+ }
+
+ //
+ // Assign a new process group for this process.
+ //
+ setpgid(0, 0);
+
+ //
+ // Close all file descriptors, except for standard input,
+ // standard output, standard error, and the write side
+ // of the newly created pipe.
+ //
+ int maxFd = static_cast<int>(sysconf(_SC_OPEN_MAX));
+ for(int fd = 3; fd < maxFd; ++fd)
+ {
+ if(fd != fds[1])
+ {
+ close(fd);
+ }
+ }
+
+ for(i = 0; i < envCount; i++)
+ {
+ if(putenv(envArray[i]) != 0)
+ {
+ reportChildError(errno, fds[1], "cannot set environment variable", envArray[i]);
+ }
+ }
+ //
+ // Each env is leaked on purpose ... see man putenv().
+ //
+ delete[] envArray;
+
+ //
+ // Change working directory.
+ //
+ if(strlen(pwdCStr) != 0)
+ {
+ if(chdir(pwdCStr) == -1)
+ {
+ reportChildError(errno, fds[1], "cannot change working directory to", pwdCStr);
+ }
+ }
+
+ if(execvp(argv[0], argv) == -1)
+ {
+ reportChildError(errno, fds[1], "cannot execute", argv[0]);
+ }
}
else // Parent process.
{
- close(fds[1]);
-
- for(i = 0; argv[i]; i++)
- {
- free(argv[i]);
- }
- free(argv);
-
- for(i = 0; i < envCount; ++i)
- {
- free(envArray[i]);
- }
- delete[] envArray;
-
- Process process;
- process.pid = pid;
- process.pipeFd = fds[0];
- process.server = server;
- _processes.insert(make_pair(name, process));
-
- int flags = fcntl(process.pipeFd, F_GETFL);
- flags |= O_NONBLOCK;
- fcntl(process.pipeFd, F_SETFL, flags);
-
- setInterrupt();
+ close(fds[1]);
+
+ for(i = 0; argv[i]; i++)
+ {
+ free(argv[i]);
+ }
+ free(argv);
+
+ for(i = 0; i < envCount; ++i)
+ {
+ free(envArray[i]);
+ }
+ delete[] envArray;
+
+ Process process;
+ process.pid = pid;
+ process.pipeFd = fds[0];
+ process.server = server;
+ _processes.insert(make_pair(name, process));
+
+ int flags = fcntl(process.pipeFd, F_GETFL);
+ flags |= O_NONBLOCK;
+ fcntl(process.pipeFd, F_SETFL, flags);
+
+ setInterrupt();
//
// Don't print the following trace, this might interfere with the
// output of the started process if it fails with an error message.
//
-// if(_traceLevels->activator > 0)
-// {
-// Ice::Trace out(_traceLevels->logger, _traceLevels->activatorCat);
-// out << "activated server `" << name << "' (pid = " << pid << ")";
-// }
+// if(_traceLevels->activator > 0)
+// {
+// Ice::Trace out(_traceLevels->logger, _traceLevels->activatorCat);
+// out << "activated server `" << name << "' (pid = " << pid << ")";
+// }
}
return pid;
@@ -751,10 +751,10 @@ Activator::deactivate(const string& name, const Ice::ProcessPrx& process)
Ice::Int pid = getServerPid(name);
if(pid == 0)
{
- //
- // Server is already deactivated.
- //
- return;
+ //
+ // Server is already deactivated.
+ //
+ return;
}
#endif
@@ -763,21 +763,21 @@ Activator::deactivate(const string& name, const Ice::ProcessPrx& process)
//
if(process)
{
- if(_traceLevels->activator > 1)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->activatorCat);
- out << "deactivating `" << name << "' using process proxy";
- }
- try
- {
- process->shutdown();
- return;
- }
- catch(const Ice::LocalException& ex)
- {
- Ice::Warning out(_traceLevels->logger);
- out << "exception occurred while deactivating `" << name << "' using process proxy:\n" << ex;
- }
+ if(_traceLevels->activator > 1)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->activatorCat);
+ out << "deactivating `" << name << "' using process proxy";
+ }
+ try
+ {
+ process->shutdown();
+ return;
+ }
+ catch(const Ice::LocalException& ex)
+ {
+ Ice::Warning out(_traceLevels->logger);
+ out << "exception occurred while deactivating `" << name << "' using process proxy:\n" << ex;
+ }
}
if(_traceLevels->activator > 1)
@@ -820,10 +820,10 @@ Activator::kill(const string& name)
Ice::Int pid = getServerPid(name);
if(pid == 0)
{
- //
- // Server is already deactivated.
- //
- return;
+ //
+ // Server is already deactivated.
+ //
+ return;
}
HANDLE hnd = OpenProcess(PROCESS_TERMINATE, FALSE, pid);
@@ -840,8 +840,8 @@ Activator::kill(const string& name)
if(_traceLevels->activator > 1)
{
- Ice::Trace out(_traceLevels->logger, _traceLevels->activatorCat);
- out << "terminating server `" << name << "' (pid = " << pid << ")";
+ Ice::Trace out(_traceLevels->logger, _traceLevels->activatorCat);
+ out << "terminating server `" << name << "' (pid = " << pid << ")";
}
#else
@@ -869,24 +869,24 @@ Activator::sendSignal(const string& name, int signal)
Ice::Int pid = getServerPid(name);
if(pid == 0)
{
- //
- // Server is already deactivated.
- //
- return;
+ //
+ // Server is already deactivated.
+ //
+ return;
}
int ret = ::kill(static_cast<pid_t>(pid), signal);
if(ret != 0 && getSystemErrno() != ESRCH)
{
- SyscallException ex(__FILE__, __LINE__);
- ex.error = getSystemErrno();
- throw ex;
+ SyscallException ex(__FILE__, __LINE__);
+ ex.error = getSystemErrno();
+ throw ex;
}
if(_traceLevels->activator > 1)
{
- Ice::Trace out(_traceLevels->logger, _traceLevels->activatorCat);
- out << "sent " << signalToString(signal) << " to server `" << name << "' (pid = " << pid << ")";
+ Ice::Trace out(_traceLevels->logger, _traceLevels->activatorCat);
+ out << "sent " << signalToString(signal) << " to server `" << name << "' (pid = " << pid << ")";
}
#endif
}
@@ -899,7 +899,7 @@ Activator::getServerPid(const string& name)
map<string, Process>::const_iterator p = _processes.find(name);
if(p == _processes.end())
{
- return 0;
+ return 0;
}
return static_cast<Ice::Int>(p->second.pid);
@@ -921,7 +921,7 @@ Activator::waitForShutdown()
IceUtil::Monitor< IceUtil::Mutex>::Lock sync(*this);
while(!_deactivating)
{
- wait();
+ wait();
}
}
@@ -945,9 +945,9 @@ Activator::destroy()
{
map<string, Process> processes;
{
- IceUtil::Monitor< IceUtil::Mutex>::Lock sync(*this);
- assert(_deactivating);
- processes = _processes;
+ IceUtil::Monitor< IceUtil::Mutex>::Lock sync(*this);
+ assert(_deactivating);
+ processes = _processes;
}
//
@@ -955,30 +955,30 @@ Activator::destroy()
//
for(map<string, Process>::iterator p = processes.begin(); p != processes.end(); ++p)
{
- //
- // Stop the server. The listener thread should detect the
- // process deactivation and remove it from the activator's
- // list of active processes.
- //
- try
- {
- p->second.server->stop_async(0);
- }
- catch(const ServerStopException&)
- {
- // Server already stopped or destroyed.
- }
- catch(const ObjectNotExistException&)
- {
- //
- // Expected if the server was in the process of being destroyed.
- //
- }
- catch(const Ice::LocalException& ex)
- {
- Ice::Warning out(_traceLevels->logger);
- out << "unexpected exception raised by server `" << p->first << "' stop:\n" << ex;
- }
+ //
+ // Stop the server. The listener thread should detect the
+ // process deactivation and remove it from the activator's
+ // list of active processes.
+ //
+ try
+ {
+ p->second.server->stop_async(0);
+ }
+ catch(const ServerStopException&)
+ {
+ // Server already stopped or destroyed.
+ }
+ catch(const ObjectNotExistException&)
+ {
+ //
+ // Expected if the server was in the process of being destroyed.
+ //
+ }
+ catch(const Ice::LocalException& ex)
+ {
+ Ice::Warning out(_traceLevels->logger);
+ out << "unexpected exception raised by server `" << p->first << "' stop:\n" << ex;
+ }
}
//
@@ -996,21 +996,21 @@ Activator::runTerminationListener()
{
while(true)
{
- try
- {
- terminationListener();
- break;
- }
- catch(const Exception& ex)
- {
- Error out(_traceLevels->logger);
- out << "exception in process termination listener:\n" << ex;
- }
- catch(...)
- {
- Error out(_traceLevels->logger);
- out << "unknown exception in process termination listener";
- }
+ try
+ {
+ terminationListener();
+ break;
+ }
+ catch(const Exception& ex)
+ {
+ Error out(_traceLevels->logger);
+ out << "exception in process termination listener:\n" << ex;
+ }
+ catch(...)
+ {
+ Error out(_traceLevels->logger);
+ out << "unknown exception in process termination listener";
+ }
}
}
@@ -1051,60 +1051,60 @@ Activator::terminationListener()
assert(pos < handles.size());
HANDLE hnd = handles[pos];
- vector<Process> terminated;
- bool deactivated = false;
- {
- IceUtil::Monitor< IceUtil::Mutex>::Lock sync(*this);
-
- if(hnd == _hIntr)
- {
- clearInterrupt();
- }
- else
- {
- for(map<string, Process>::iterator p = _processes.begin(); p != _processes.end(); ++p)
- {
- if(p->second.hnd == hnd)
- {
- terminated.push_back(p->second);
- _processes.erase(p);
- break;
- }
- }
+ vector<Process> terminated;
+ bool deactivated = false;
+ {
+ IceUtil::Monitor< IceUtil::Mutex>::Lock sync(*this);
+
+ if(hnd == _hIntr)
+ {
+ clearInterrupt();
+ }
+ else
+ {
+ for(map<string, Process>::iterator p = _processes.begin(); p != _processes.end(); ++p)
+ {
+ if(p->second.hnd == hnd)
+ {
+ terminated.push_back(p->second);
+ _processes.erase(p);
+ break;
+ }
+ }
+ }
+
+ deactivated = _deactivating && _processes.empty();
+ }
+
+ for(vector<Process>::const_iterator p = terminated.begin(); p != terminated.end(); ++p)
+ {
+ DWORD status;
+ GetExitCodeProcess(p->hnd, &status);
+ CloseHandle(p->hnd);
+ assert(status != STILL_ACTIVE);
+
+ if(_traceLevels->activator > 0)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->activatorCat);
+ out << "detected termination of server `" << p->server->getId() << "'";
+ if(status != 0)
+ {
+ out << "\nexit code = " << status;
+ }
+ }
+
+ try
+ {
+ p->server->terminated("", status);
}
+ catch(const Ice::LocalException& ex)
+ {
+ Ice::Warning out(_traceLevels->logger);
+ out << "unexpected exception raised by server `" << p->server->getId() << "' termination:\n" << ex;
+ }
+ }
- deactivated = _deactivating && _processes.empty();
- }
-
- for(vector<Process>::const_iterator p = terminated.begin(); p != terminated.end(); ++p)
- {
- DWORD status;
- GetExitCodeProcess(p->hnd, &status);
- CloseHandle(p->hnd);
- assert(status != STILL_ACTIVE);
-
- if(_traceLevels->activator > 0)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->activatorCat);
- out << "detected termination of server `" << p->server->getId() << "'";
- if(status != 0)
- {
- out << "\nexit code = " << status;
- }
- }
-
- try
- {
- p->server->terminated("", status);
- }
- catch(const Ice::LocalException& ex)
- {
- Ice::Warning out(_traceLevels->logger);
- out << "unexpected exception raised by server `" << p->server->getId() << "' termination:\n" << ex;
- }
- }
-
- if(deactivated)
+ if(deactivated)
{
return;
}
@@ -1112,197 +1112,197 @@ Activator::terminationListener()
#else
while(true)
{
- fd_set fdSet;
- int maxFd = _fdIntrRead;
- FD_ZERO(&fdSet);
- FD_SET(_fdIntrRead, &fdSet);
-
- {
- IceUtil::Monitor< IceUtil::Mutex>::Lock sync(*this);
-
- for(map<string, Process>::iterator p = _processes.begin(); p != _processes.end(); ++p)
- {
- int fd = p->second.pipeFd;
- FD_SET(fd, &fdSet);
- if(maxFd < fd)
- {
- maxFd = fd;
- }
- }
- }
-
+ fd_set fdSet;
+ int maxFd = _fdIntrRead;
+ FD_ZERO(&fdSet);
+ FD_SET(_fdIntrRead, &fdSet);
+
+ {
+ IceUtil::Monitor< IceUtil::Mutex>::Lock sync(*this);
+
+ for(map<string, Process>::iterator p = _processes.begin(); p != _processes.end(); ++p)
+ {
+ int fd = p->second.pipeFd;
+ FD_SET(fd, &fdSet);
+ if(maxFd < fd)
+ {
+ maxFd = fd;
+ }
+ }
+ }
+
repeatSelect:
- int ret = ::select(maxFd + 1, &fdSet, 0, 0, 0);
- assert(ret != 0);
-
- if(ret == -1)
- {
+ int ret = ::select(maxFd + 1, &fdSet, 0, 0, 0);
+ assert(ret != 0);
+
+ if(ret == -1)
+ {
#ifdef EPROTO
- if(errno == EINTR || errno == EPROTO)
- {
- goto repeatSelect;
- }
+ if(errno == EINTR || errno == EPROTO)
+ {
+ goto repeatSelect;
+ }
#else
- if(errno == EINTR)
- {
- goto repeatSelect;
- }
+ if(errno == EINTR)
+ {
+ goto repeatSelect;
+ }
#endif
-
- SyscallException ex(__FILE__, __LINE__);
- ex.error = getSystemErrno();
- throw ex;
- }
-
- vector<Process> terminated;
- bool deactivated = false;
- {
- IceUtil::Monitor< IceUtil::Mutex>::Lock sync(*this);
-
- if(FD_ISSET(_fdIntrRead, &fdSet))
- {
- clearInterrupt();
-
- if(_deactivating && _processes.empty())
+
+ SyscallException ex(__FILE__, __LINE__);
+ ex.error = getSystemErrno();
+ throw ex;
+ }
+
+ vector<Process> terminated;
+ bool deactivated = false;
+ {
+ IceUtil::Monitor< IceUtil::Mutex>::Lock sync(*this);
+
+ if(FD_ISSET(_fdIntrRead, &fdSet))
+ {
+ clearInterrupt();
+
+ if(_deactivating && _processes.empty())
{
return;
}
- }
-
- map<string, Process>::iterator p = _processes.begin();
- while(p != _processes.end())
- {
- int fd = p->second.pipeFd;
- if(!FD_ISSET(fd, &fdSet))
- {
- ++p;
- continue;
- }
-
- char s[16];
- ssize_t rs;
- string message;
-
- //
- // Read the message over the pipe.
- //
- while((rs = read(fd, &s, 16)) > 0)
- {
- message.append(s, rs);
- }
-
- //
- // Keep the received message.
- //
- if(!message.empty())
- {
- p->second.msg += message;
- }
-
- if(rs == -1)
- {
- if(errno != EAGAIN || message.empty())
- {
- SyscallException ex(__FILE__, __LINE__);
- ex.error = getSystemErrno();
- throw ex;
- }
-
- ++p;
- }
- else if(rs == 0)
- {
- //
- // If the pipe was closed, the process has terminated.
- //
-
- terminated.push_back(p->second);
+ }
+
+ map<string, Process>::iterator p = _processes.begin();
+ while(p != _processes.end())
+ {
+ int fd = p->second.pipeFd;
+ if(!FD_ISSET(fd, &fdSet))
+ {
+ ++p;
+ continue;
+ }
+
+ char s[16];
+ ssize_t rs;
+ string message;
+
+ //
+ // Read the message over the pipe.
+ //
+ while((rs = read(fd, &s, 16)) > 0)
+ {
+ message.append(s, rs);
+ }
+
+ //
+ // Keep the received message.
+ //
+ if(!message.empty())
+ {
+ p->second.msg += message;
+ }
+
+ if(rs == -1)
+ {
+ if(errno != EAGAIN || message.empty())
+ {
+ SyscallException ex(__FILE__, __LINE__);
+ ex.error = getSystemErrno();
+ throw ex;
+ }
+
+ ++p;
+ }
+ else if(rs == 0)
+ {
+ //
+ // If the pipe was closed, the process has terminated.
+ //
+
+ terminated.push_back(p->second);
- close(p->second.pipeFd);
- _processes.erase(p++);
- }
- }
-
- //
- // We are deactivating and there's no more active processes.
- //
- deactivated = _deactivating && _processes.empty();
- }
-
- for(vector<Process>::const_iterator p = terminated.begin(); p != terminated.end(); ++p)
- {
- int status;
+ close(p->second.pipeFd);
+ _processes.erase(p++);
+ }
+ }
+
+ //
+ // We are deactivating and there's no more active processes.
+ //
+ deactivated = _deactivating && _processes.empty();
+ }
+
+ for(vector<Process>::const_iterator p = terminated.begin(); p != terminated.end(); ++p)
+ {
+ int status;
#if defined(__linux)
- int nRetry = 0;
- while(true) // The while loop is necessary for the linux workaround.
- {
- pid_t pid = waitpid(p->pid, &status, 0);
- if(pid < 0)
- {
- //
- // Some Linux distribution have a bogus waitpid() (e.g.: CentOS 4.x). It doesn't
- // block and reports an incorrect ECHILD error on the first call. We sleep a
- // little and retry to work around this issue (it appears from testing that a
- // single retry is enough but to make sure we retry up to 10 times before to throw.)
- //
- if(errno == ECHILD && nRetry < 10)
- {
- // Wait 1ms, 11ms, 21ms, etc.
- IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(nRetry * 10 + 1));
- ++nRetry;
- continue;
- }
- SyscallException ex(__FILE__, __LINE__);
- ex.error = getSystemErrno();
- throw ex;
- }
- assert(pid == p->pid);
- break;
- }
+ int nRetry = 0;
+ while(true) // The while loop is necessary for the linux workaround.
+ {
+ pid_t pid = waitpid(p->pid, &status, 0);
+ if(pid < 0)
+ {
+ //
+ // Some Linux distribution have a bogus waitpid() (e.g.: CentOS 4.x). It doesn't
+ // block and reports an incorrect ECHILD error on the first call. We sleep a
+ // little and retry to work around this issue (it appears from testing that a
+ // single retry is enough but to make sure we retry up to 10 times before to throw.)
+ //
+ if(errno == ECHILD && nRetry < 10)
+ {
+ // Wait 1ms, 11ms, 21ms, etc.
+ IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(nRetry * 10 + 1));
+ ++nRetry;
+ continue;
+ }
+ SyscallException ex(__FILE__, __LINE__);
+ ex.error = getSystemErrno();
+ throw ex;
+ }
+ assert(pid == p->pid);
+ break;
+ }
#else
- pid_t pid = waitpid(p->pid, &status, 0);
- if(pid < 0)
- {
- SyscallException ex(__FILE__, __LINE__);
- ex.error = getSystemErrno();
- throw ex;
- }
- assert(pid == p->pid);
+ pid_t pid = waitpid(p->pid, &status, 0);
+ if(pid < 0)
+ {
+ SyscallException ex(__FILE__, __LINE__);
+ ex.error = getSystemErrno();
+ throw ex;
+ }
+ assert(pid == p->pid);
#endif
- if(_traceLevels->activator > 0)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->activatorCat);
- out << "detected termination of server `" << p->server->getId() << "'";
- if(!p->msg.empty())
- {
- out << "\nreason = " << p->msg;
- }
- if(WIFEXITED(status) && status != 0)
- {
- out << "\nexit code = " << WEXITSTATUS(status);
- }
- else if(WIFSIGNALED(status))
- {
- out << "\nsignal = " << signalToString(WTERMSIG(status));
- }
- }
-
- try
- {
- p->server->terminated(p->msg, status);
- }
- catch(const Ice::LocalException& ex)
- {
- Ice::Warning out(_traceLevels->logger);
- out << "unexpected exception raised by server `" << p->server->getId() << "' termination:\n" << ex;
- }
- }
-
- if(deactivated)
- {
- return;
- }
+ if(_traceLevels->activator > 0)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->activatorCat);
+ out << "detected termination of server `" << p->server->getId() << "'";
+ if(!p->msg.empty())
+ {
+ out << "\nreason = " << p->msg;
+ }
+ if(WIFEXITED(status) && status != 0)
+ {
+ out << "\nexit code = " << WEXITSTATUS(status);
+ }
+ else if(WIFSIGNALED(status))
+ {
+ out << "\nsignal = " << signalToString(WTERMSIG(status));
+ }
+ }
+
+ try
+ {
+ p->server->terminated(p->msg, status);
+ }
+ catch(const Ice::LocalException& ex)
+ {
+ Ice::Warning out(_traceLevels->logger);
+ out << "unexpected exception raised by server `" << p->server->getId() << "' termination:\n" << ex;
+ }
+ }
+
+ if(deactivated)
+ {
+ return;
+ }
}
#endif
}
diff --git a/cpp/src/IceGrid/Activator.h b/cpp/src/IceGrid/Activator.h
index 40c7a9b3878..24a2b60f800 100644
--- a/cpp/src/IceGrid/Activator.h
+++ b/cpp/src/IceGrid/Activator.h
@@ -37,9 +37,9 @@ public:
virtual int activate(const std::string&, const std::string&, const std::string&,
#ifndef _WIN32
- uid_t, gid_t,
+ uid_t, gid_t,
#endif
- const Ice::StringSeq&, const Ice::StringSeq&, const ServerIPtr&);
+ const Ice::StringSeq&, const Ice::StringSeq&, const ServerIPtr&);
virtual void deactivate(const std::string&, const Ice::ProcessPrx&);
virtual void kill(const std::string&);
virtual void sendSignal(const std::string&, const std::string&);
@@ -67,11 +67,11 @@ private:
DWORD pid;
HANDLE hnd;
#else
- pid_t pid;
- int pipeFd;
- std::string msg;
+ pid_t pid;
+ int pipeFd;
+ std::string msg;
#endif
- ServerIPtr server;
+ ServerIPtr server;
};
TraceLevelsPtr _traceLevels;
diff --git a/cpp/src/IceGrid/AdapterCache.cpp b/cpp/src/IceGrid/AdapterCache.cpp
index 5ebd4ba6c8d..64d235bacea 100644
--- a/cpp/src/IceGrid/AdapterCache.cpp
+++ b/cpp/src/IceGrid/AdapterCache.cpp
@@ -28,7 +28,7 @@ struct ReplicaLoadComp : binary_function<ServerAdapterEntryPtr&, ServerAdapterEn
{
bool operator()(const pair<float, ServerAdapterEntryPtr>& lhs, const pair<float, ServerAdapterEntryPtr>& rhs)
{
- return lhs.first < rhs.first;
+ return lhs.first < rhs.first;
}
};
@@ -36,12 +36,12 @@ struct ReplicaPriorityComp : binary_function<ServerAdapterEntryPtr&, ServerAdapt
{
bool operator()(const ServerAdapterEntryPtr& lhs, const ServerAdapterEntryPtr& rhs)
{
- return lhs->getPriority() < rhs->getPriority();
+ return lhs->getPriority() < rhs->getPriority();
}
};
struct TransformToReplicaLoad :
- public unary_function<const ServerAdapterEntryPtr&, pair<float, ServerAdapterEntryPtr> >
+ public unary_function<const ServerAdapterEntryPtr&, pair<float, ServerAdapterEntryPtr> >
{
public:
@@ -50,7 +50,7 @@ public:
pair<float, ServerAdapterEntryPtr>
operator()(const ServerAdapterEntryPtr& value)
{
- return make_pair(value->getLeastLoadedNodeLoad(_loadSample), value);
+ return make_pair(value->getLeastLoadedNodeLoad(_loadSample), value);
}
LoadSample _loadSample;
@@ -61,7 +61,7 @@ struct TransformToReplica : public unary_function<const pair<string, ServerAdapt
ServerAdapterEntryPtr
operator()(const pair<float, ServerAdapterEntryPtr>& value)
{
- return value.second;
+ return value.second;
}
};
@@ -82,9 +82,9 @@ AdapterCache::addServerAdapter(const AdapterDescriptor& desc, const ServerEntryP
if(!desc.replicaGroupId.empty())
{
- ReplicaGroupEntryPtr repEntry = ReplicaGroupEntryPtr::dynamicCast(getImpl(desc.replicaGroupId));
- assert(repEntry);
- repEntry->addReplica(desc.id, entry);
+ ReplicaGroupEntryPtr repEntry = ReplicaGroupEntryPtr::dynamicCast(getImpl(desc.replicaGroupId));
+ assert(repEntry);
+ repEntry->addReplica(desc.id, entry);
}
return entry;
@@ -107,7 +107,7 @@ AdapterCache::get(const string& id) const
AdapterEntryPtr entry = getImpl(id);
if(!entry)
{
- throw AdapterNotExistException(id);
+ throw AdapterNotExistException(id);
}
return entry;
}
@@ -124,9 +124,9 @@ AdapterCache::removeServerAdapter(const string& id)
string replicaGroupId = entry->getReplicaGroupId();
if(!replicaGroupId.empty())
{
- ReplicaGroupEntryPtr repEntry = ReplicaGroupEntryPtr::dynamicCast(getImpl(replicaGroupId));
- assert(repEntry);
- repEntry->removeReplica(id);
+ ReplicaGroupEntryPtr repEntry = ReplicaGroupEntryPtr::dynamicCast(getImpl(replicaGroupId));
+ assert(repEntry);
+ repEntry->removeReplica(id);
}
}
@@ -142,8 +142,8 @@ AdapterCache::addImpl(const string& id, const AdapterEntryPtr& entry)
{
if(_traceLevels && _traceLevels->adapter > 0)
{
- Ice::Trace out(_traceLevels->logger, _traceLevels->adapterCat);
- out << "added adapter `" << id << "'";
+ Ice::Trace out(_traceLevels->logger, _traceLevels->adapterCat);
+ out << "added adapter `" << id << "'";
}
return Cache<string, AdapterEntry>::addImpl(id, entry);
}
@@ -153,8 +153,8 @@ AdapterCache::removeImpl(const string& id)
{
if(_traceLevels && _traceLevels->adapter > 0)
{
- Ice::Trace out(_traceLevels->logger, _traceLevels->adapterCat);
- out << "removed adapter `" << id << "'";
+ Ice::Trace out(_traceLevels->logger, _traceLevels->adapterCat);
+ out << "removed adapter `" << id << "'";
}
Cache<string, AdapterEntry>::removeImpl(id);
}
@@ -185,11 +185,11 @@ AdapterEntry::getApplication() const
}
ServerAdapterEntry::ServerAdapterEntry(AdapterCache& cache,
- const string& id,
- const string& application,
- const string& replicaGroupId,
- int priority,
- const ServerEntryPtr& server) :
+ const string& id,
+ const string& application,
+ const string& replicaGroupId,
+ int priority,
+ const ServerEntryPtr& server) :
AdapterEntry(cache, id, application),
_replicaGroupId(replicaGroupId),
_priority(priority),
@@ -213,23 +213,23 @@ ServerAdapterEntry::getLeastLoadedNodeLoad(LoadSample loadSample) const
{
try
{
- return _server->getLoad(loadSample);
+ return _server->getLoad(loadSample);
}
catch(const ServerNotExistException&)
{
- // This might happen if the application is updated concurrently.
+ // This might happen if the application is updated concurrently.
}
catch(const NodeNotExistException&)
{
- // This might happen if the application is updated concurrently.
+ // This might happen if the application is updated concurrently.
}
catch(const NodeUnreachableException&)
{
}
catch(const Ice::Exception& ex)
{
- Ice::Error error(_cache.getTraceLevels()->logger);
- error << "unexpected exception while getting node load:\n" << ex;
+ Ice::Error error(_cache.getTraceLevels()->logger);
+ error << "unexpected exception while getting node load:\n" << ex;
}
return 999.9f;
}
@@ -242,7 +242,7 @@ ServerAdapterEntry::getAdapterInfo() const
info.replicaGroupId = _replicaGroupId;
try
{
- info.proxy = _server->getAdapter(_id, true)->getDirectProxy();
+ info.proxy = _server->getAdapter(_id, true)->getDirectProxy();
}
catch(const Ice::Exception&)
{
@@ -257,15 +257,15 @@ ServerAdapterEntry::getProxy(const string& replicaGroupId, bool upToDate) const
{
if(replicaGroupId.empty())
{
- return _server->getAdapter(_id, upToDate);
+ return _server->getAdapter(_id, upToDate);
}
else
{
- if(_replicaGroupId != replicaGroupId) // Validate the replica group.
- {
- throw Ice::InvalidReplicaGroupIdException();
- }
- return _server->getAdapter(_id, upToDate);
+ if(_replicaGroupId != replicaGroupId) // Validate the replica group.
+ {
+ throw Ice::InvalidReplicaGroupIdException();
+ }
+ return _server->getAdapter(_id, upToDate);
}
}
@@ -276,9 +276,9 @@ ServerAdapterEntry::getPriority() const
}
ReplicaGroupEntry::ReplicaGroupEntry(AdapterCache& cache,
- const string& id,
- const string& application,
- const LoadBalancingPolicyPtr& policy) :
+ const string& id,
+ const string& application,
+ const LoadBalancingPolicyPtr& policy) :
AdapterEntry(cache, id, application),
_lastReplica(0)
{
@@ -298,13 +298,13 @@ ReplicaGroupEntry::removeReplica(const string& replicaId)
Lock sync(*this);
for(vector<ServerAdapterEntryPtr>::iterator p = _replicas.begin(); p != _replicas.end(); ++p)
{
- if(replicaId == (*p)->getId())
- {
- _replicas.erase(p);
- // Make sure _lastReplica is still within the bounds.
- _lastReplica = _replicas.empty() ? 0 : _lastReplica % static_cast<int>(_replicas.size());
- break;
- }
+ if(replicaId == (*p)->getId())
+ {
+ _replicas.erase(p);
+ // Make sure _lastReplica is still within the bounds.
+ _lastReplica = _replicas.empty() ? 0 : _lastReplica % static_cast<int>(_replicas.size());
+ break;
+ }
}
}
@@ -323,22 +323,22 @@ ReplicaGroupEntry::update(const LoadBalancingPolicyPtr& policy)
AdaptiveLoadBalancingPolicyPtr alb = AdaptiveLoadBalancingPolicyPtr::dynamicCast(_loadBalancing);
if(alb)
{
- if(alb->loadSample == "1")
- {
- _loadSample = LoadSample1;
- }
- else if(alb->loadSample == "5")
- {
- _loadSample = LoadSample5;
- }
- else if(alb->loadSample == "15")
- {
- _loadSample = LoadSample15;
- }
- else
- {
- _loadSample = LoadSample1;
- }
+ if(alb->loadSample == "1")
+ {
+ _loadSample = LoadSample1;
+ }
+ else if(alb->loadSample == "5")
+ {
+ _loadSample = LoadSample5;
+ }
+ else if(alb->loadSample == "15")
+ {
+ _loadSample = LoadSample15;
+ }
+ else
+ {
+ _loadSample = LoadSample1;
+ }
}
}
@@ -349,59 +349,59 @@ ReplicaGroupEntry::getLocatorAdapterInfo(LocatorAdapterInfoSeq& adapters, int& n
bool adaptive = false;
LoadSample loadSample = LoadSample1;
{
- Lock sync(*this);
- replicaGroup = true;
- nReplicas = _loadBalancingNReplicas > 0 ? _loadBalancingNReplicas : static_cast<int>(_replicas.size());
-
- if(_replicas.empty())
- {
- return;
- }
-
- replicas.reserve(_replicas.size());
- if(RoundRobinLoadBalancingPolicyPtr::dynamicCast(_loadBalancing))
- {
- for(unsigned int i = 0; i < _replicas.size(); ++i)
- {
- replicas.push_back(_replicas[(_lastReplica + i) % _replicas.size()]);
- }
- _lastReplica = (_lastReplica + 1) % static_cast<int>(_replicas.size());
- }
- else if(AdaptiveLoadBalancingPolicyPtr::dynamicCast(_loadBalancing))
- {
- replicas = _replicas;
- RandomNumberGenerator rng;
- random_shuffle(replicas.begin(), replicas.end(), rng);
- loadSample = _loadSample;
- adaptive = true;
- }
- else if(OrderedLoadBalancingPolicyPtr::dynamicCast(_loadBalancing))
- {
- replicas = _replicas;
- sort(replicas.begin(), replicas.end(), ReplicaPriorityComp());
- }
- else if(RandomLoadBalancingPolicyPtr::dynamicCast(_loadBalancing))
- {
- replicas = _replicas;
- RandomNumberGenerator rng;
- random_shuffle(replicas.begin(), replicas.end(), rng);
- }
+ Lock sync(*this);
+ replicaGroup = true;
+ nReplicas = _loadBalancingNReplicas > 0 ? _loadBalancingNReplicas : static_cast<int>(_replicas.size());
+
+ if(_replicas.empty())
+ {
+ return;
+ }
+
+ replicas.reserve(_replicas.size());
+ if(RoundRobinLoadBalancingPolicyPtr::dynamicCast(_loadBalancing))
+ {
+ for(unsigned int i = 0; i < _replicas.size(); ++i)
+ {
+ replicas.push_back(_replicas[(_lastReplica + i) % _replicas.size()]);
+ }
+ _lastReplica = (_lastReplica + 1) % static_cast<int>(_replicas.size());
+ }
+ else if(AdaptiveLoadBalancingPolicyPtr::dynamicCast(_loadBalancing))
+ {
+ replicas = _replicas;
+ RandomNumberGenerator rng;
+ random_shuffle(replicas.begin(), replicas.end(), rng);
+ loadSample = _loadSample;
+ adaptive = true;
+ }
+ else if(OrderedLoadBalancingPolicyPtr::dynamicCast(_loadBalancing))
+ {
+ replicas = _replicas;
+ sort(replicas.begin(), replicas.end(), ReplicaPriorityComp());
+ }
+ else if(RandomLoadBalancingPolicyPtr::dynamicCast(_loadBalancing))
+ {
+ replicas = _replicas;
+ RandomNumberGenerator rng;
+ random_shuffle(replicas.begin(), replicas.end(), rng);
+ }
}
if(adaptive)
{
- //
- // This must be done outside the synchronization block since
- // the trasnform() might call and lock each server adapter
- // entry. We also can't sort directly as the load of each
- // server adapter is not stable so we first take a snapshot of
- // each adapter and sort the snapshot.
- //
- vector<pair<float, ServerAdapterEntryPtr> > rl;
- transform(replicas.begin(), replicas.end(), back_inserter(rl), TransformToReplicaLoad(loadSample));
- sort(rl.begin(), rl.end(), ReplicaLoadComp());
- replicas.clear();
- transform(rl.begin(), rl.end(), back_inserter(replicas), TransformToReplica());
+ //
+ // This must be done outside the synchronization block since
+ // the trasnform() might call and lock each server adapter
+ // entry. We also can't sort directly as the load of each
+ // server adapter is not stable so we first take a snapshot of
+ // each adapter and sort the snapshot.
+ //
+ vector<pair<float, ServerAdapterEntryPtr> > rl;
+ transform(replicas.begin(), replicas.end(), back_inserter(rl), TransformToReplicaLoad(loadSample));
+ sort(rl.begin(), rl.end(), ReplicaLoadComp());
+ replicas.clear();
+ transform(rl.begin(), rl.end(), back_inserter(replicas), TransformToReplica());
}
//
@@ -411,21 +411,21 @@ ReplicaGroupEntry::getLocatorAdapterInfo(LocatorAdapterInfoSeq& adapters, int& n
//
for(vector<ServerAdapterEntryPtr>::const_iterator p = replicas.begin(); p != replicas.end(); ++p)
{
- try
- {
- int dummy;
- bool dummy2;
- (*p)->getLocatorAdapterInfo(adapters, dummy, dummy2);
- }
- catch(const AdapterNotExistException&)
- {
- }
- catch(const NodeUnreachableException&)
- {
- }
- catch(const DeploymentException&)
- {
- }
+ try
+ {
+ int dummy;
+ bool dummy2;
+ (*p)->getLocatorAdapterInfo(adapters, dummy, dummy2);
+ }
+ catch(const AdapterNotExistException&)
+ {
+ }
+ catch(const NodeUnreachableException&)
+ {
+ }
+ catch(const DeploymentException&)
+ {
+ }
}
}
@@ -434,25 +434,25 @@ ReplicaGroupEntry::getLeastLoadedNodeLoad(LoadSample loadSample) const
{
vector<ServerAdapterEntryPtr> replicas;
{
- Lock sync(*this);
- replicas = _replicas;
+ Lock sync(*this);
+ replicas = _replicas;
}
if(replicas.empty())
{
- return 999.9f;
+ return 999.9f;
}
else if(replicas.size() == 1)
{
- return replicas.back()->getLeastLoadedNodeLoad(loadSample);
+ return replicas.back()->getLeastLoadedNodeLoad(loadSample);
}
else
{
- RandomNumberGenerator rng;
- random_shuffle(replicas.begin(), replicas.end(), rng);
- vector<pair<float, ServerAdapterEntryPtr> > rl;
- transform(replicas.begin(), replicas.end(), back_inserter(rl), TransformToReplicaLoad(loadSample));
- return min_element(rl.begin(), rl.end(), ReplicaLoadComp())->first;
+ RandomNumberGenerator rng;
+ random_shuffle(replicas.begin(), replicas.end(), rng);
+ vector<pair<float, ServerAdapterEntryPtr> > rl;
+ transform(replicas.begin(), replicas.end(), back_inserter(rl), TransformToReplicaLoad(loadSample));
+ return min_element(rl.begin(), rl.end(), ReplicaLoadComp())->first;
}
}
@@ -461,16 +461,16 @@ ReplicaGroupEntry::getAdapterInfo() const
{
vector<ServerAdapterEntryPtr> replicas;
{
- Lock sync(*this);
- replicas = _replicas;
+ Lock sync(*this);
+ replicas = _replicas;
}
AdapterInfoSeq infos;
for(vector<ServerAdapterEntryPtr>::const_iterator p = replicas.begin(); p != replicas.end(); ++p)
{
- AdapterInfoSeq infs = (*p)->getAdapterInfo();
- assert(infs.size() == 1);
- infos.push_back(infs[0]);
+ AdapterInfoSeq infs = (*p)->getAdapterInfo();
+ assert(infs.size() == 1);
+ infos.push_back(infs[0]);
}
return infos;
}
diff --git a/cpp/src/IceGrid/AdapterCache.h b/cpp/src/IceGrid/AdapterCache.h
index 14debc9838d..8e45f5b186e 100644
--- a/cpp/src/IceGrid/AdapterCache.h
+++ b/cpp/src/IceGrid/AdapterCache.h
@@ -65,7 +65,7 @@ class ServerAdapterEntry : public AdapterEntry
public:
ServerAdapterEntry(AdapterCache&, const std::string&, const std::string&, const std::string&, int,
- const ServerEntryPtr&);
+ const ServerEntryPtr&);
virtual void getLocatorAdapterInfo(LocatorAdapterInfoSeq&, int&, bool&);
virtual float getLeastLoadedNodeLoad(LoadSample) const;
diff --git a/cpp/src/IceGrid/AdminI.cpp b/cpp/src/IceGrid/AdminI.cpp
index 70a95368cd4..cf2d752f6b9 100644
--- a/cpp/src/IceGrid/AdminI.cpp
+++ b/cpp/src/IceGrid/AdminI.cpp
@@ -36,48 +36,48 @@ public:
ServerProxyWrapper(const DatabasePtr& database, const string& id) : _id(id)
{
- _proxy = database->getServer(_id)->getProxy(_activationTimeout, _deactivationTimeout, _node);
+ _proxy = database->getServer(_id)->getProxy(_activationTimeout, _deactivationTimeout, _node);
}
void
useActivationTimeout()
{
- _proxy = ServerPrx::uncheckedCast(_proxy->ice_timeout(_activationTimeout * 1000));
+ _proxy = ServerPrx::uncheckedCast(_proxy->ice_timeout(_activationTimeout * 1000));
}
void
useDeactivationTimeout()
{
- _proxy = ServerPrx::uncheckedCast(_proxy->ice_timeout(_deactivationTimeout * 1000));
+ _proxy = ServerPrx::uncheckedCast(_proxy->ice_timeout(_deactivationTimeout * 1000));
}
IceProxy::IceGrid::Server*
operator->() const
{
- return _proxy.get();
+ return _proxy.get();
}
void
handleException(const Ice::Exception& ex)
{
- try
- {
- ex.ice_throw();
- }
- catch(const Ice::UserException&)
- {
- throw;
- }
- catch(const Ice::ObjectNotExistException&)
- {
- throw ServerNotExistException(_id);
- }
- catch(const Ice::LocalException& e)
- {
- ostringstream os;
- os << e;
- throw NodeUnreachableException(_node, os.str());
- }
+ try
+ {
+ ex.ice_throw();
+ }
+ catch(const Ice::UserException&)
+ {
+ throw;
+ }
+ catch(const Ice::ObjectNotExistException&)
+ {
+ throw ServerNotExistException(_id);
+ }
+ catch(const Ice::LocalException& e)
+ {
+ ostringstream os;
+ os << e;
+ throw NodeUnreachableException(_node, os.str());
+ }
}
private:
@@ -95,13 +95,13 @@ class AMDPatcherFeedbackAggregator : public PatcherFeedbackAggregator
public:
AMDPatcherFeedbackAggregator(const AmdCB& cb,
- Ice::Identity id,
- const TraceLevelsPtr& traceLevels,
- const string& type,
- const string& name,
- int nodeCount) :
- PatcherFeedbackAggregator(id, traceLevels, type, name, nodeCount),
- _cb(cb)
+ Ice::Identity id,
+ const TraceLevelsPtr& traceLevels,
+ const string& type,
+ const string& name,
+ int nodeCount) :
+ PatcherFeedbackAggregator(id, traceLevels, type, name, nodeCount),
+ _cb(cb)
{
}
@@ -110,13 +110,13 @@ private:
void
response()
{
- _cb->ice_response();
+ _cb->ice_response();
}
void
exception(const Ice::Exception& ex)
{
- _cb->ice_exception(ex);
+ _cb->ice_exception(ex);
}
const AmdCB _cb;
@@ -125,11 +125,11 @@ private:
template<typename AmdCB> PatcherFeedbackAggregatorPtr
static newPatcherFeedback(const AmdCB& cb,
- Ice::Identity id,
- const TraceLevelsPtr& traceLevels,
- const string& type,
- const string& name,
- int nodeCount)
+ Ice::Identity id,
+ const TraceLevelsPtr& traceLevels,
+ const string& type,
+ const string& name,
+ int nodeCount)
{
return new AMDPatcherFeedbackAggregator<AmdCB>(cb, id, traceLevels, type, name, nodeCount);
}
@@ -200,9 +200,9 @@ AdminI::instantiateServer(const string& app, const string& node, const ServerIns
void
AdminI::patchApplication_async(const AMD_Admin_patchApplicationPtr& amdCB,
- const string& name,
- bool shutdown,
- const Current& current)
+ const string& name,
+ bool shutdown,
+ const Current& current)
{
ApplicationHelper helper(current.adapter->getCommunicator(), _database->getApplicationInfo(name).descriptor);
DistributionDescriptor appDistrib;
@@ -211,8 +211,8 @@ AdminI::patchApplication_async(const AMD_Admin_patchApplicationPtr& amdCB,
if(nodes.empty())
{
- amdCB->ice_response();
- return;
+ amdCB->ice_response();
+ return;
}
Ice::Identity id;
@@ -220,39 +220,39 @@ AdminI::patchApplication_async(const AMD_Admin_patchApplicationPtr& amdCB,
id.name = IceUtil::generateUUID();
PatcherFeedbackAggregatorPtr feedback =
- newPatcherFeedback(amdCB, id, _traceLevels, "application", name, static_cast<int>(nodes.size()));
+ newPatcherFeedback(amdCB, id, _traceLevels, "application", name, static_cast<int>(nodes.size()));
for(vector<string>::const_iterator p = nodes.begin(); p != nodes.end(); ++p)
{
- try
- {
- if(_traceLevels->patch > 0)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->patchCat);
- out << "started patching of application `" << name << "' on node `" << *p << "'";
- }
-
- NodeEntryPtr node = _database->getNode(*p);
- Resolver resolve(node->getInfo(), _database->getCommunicator());
- DistributionDescriptor desc = resolve(appDistrib);
- InternalDistributionDescriptorPtr intAppDistrib = new InternalDistributionDescriptor(desc.icepatch,
- desc.directories);
- node->getSession()->patch(feedback, name, "", intAppDistrib, shutdown);
- }
- catch(const NodeNotExistException&)
- {
- feedback->failed(*p, "node doesn't exist");
- }
- catch(const NodeUnreachableException& e)
- {
- feedback->failed(*p, "node is unreachable: " + e.reason);
- }
- catch(const Ice::Exception& e)
- {
- ostringstream os;
- os << e;
- feedback->failed(*p, "node is unreachable:\n" + os.str());
- }
+ try
+ {
+ if(_traceLevels->patch > 0)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->patchCat);
+ out << "started patching of application `" << name << "' on node `" << *p << "'";
+ }
+
+ NodeEntryPtr node = _database->getNode(*p);
+ Resolver resolve(node->getInfo(), _database->getCommunicator());
+ DistributionDescriptor desc = resolve(appDistrib);
+ InternalDistributionDescriptorPtr intAppDistrib = new InternalDistributionDescriptor(desc.icepatch,
+ desc.directories);
+ node->getSession()->patch(feedback, name, "", intAppDistrib, shutdown);
+ }
+ catch(const NodeNotExistException&)
+ {
+ feedback->failed(*p, "node doesn't exist");
+ }
+ catch(const NodeUnreachableException& e)
+ {
+ feedback->failed(*p, "node is unreachable: " + e.reason);
+ }
+ catch(const Ice::Exception& e)
+ {
+ ostringstream os;
+ os << e;
+ feedback->failed(*p, "node is unreachable:\n" + os.str());
+ }
}
}
@@ -269,49 +269,49 @@ AdminI::getDefaultApplicationDescriptor(const Current& current) const
string path = properties->getProperty("IceGrid.Registry.DefaultTemplates");
if(path.empty())
{
- throw DeploymentException("no default templates configured, you need to set "
- "IceGrid.Registry.DefaultTemplates in the IceGrid registry configuration.");
+ throw DeploymentException("no default templates configured, you need to set "
+ "IceGrid.Registry.DefaultTemplates in the IceGrid registry configuration.");
}
ApplicationDescriptor desc;
try
{
- desc = DescriptorParser::parseDescriptor(path, current.adapter->getCommunicator());
+ desc = DescriptorParser::parseDescriptor(path, current.adapter->getCommunicator());
}
catch(const IceXML::ParserException& ex)
{
- throw DeploymentException("can't parse default templates:\n" + ex.reason());
+ throw DeploymentException("can't parse default templates:\n" + ex.reason());
}
desc.name = "";
if(!desc.nodes.empty())
{
- Ice::Warning warn(_traceLevels->logger);
- warn << "default application descriptor:\nnode definitions are not allowed.";
- desc.nodes.clear();
+ Ice::Warning warn(_traceLevels->logger);
+ warn << "default application descriptor:\nnode definitions are not allowed.";
+ desc.nodes.clear();
}
if(!desc.distrib.icepatch.empty() || !desc.distrib.directories.empty())
{
- Ice::Warning warn(_traceLevels->logger);
- warn << "default application descriptor:\ndistribution is not allowed.";
- desc.distrib = DistributionDescriptor();
+ Ice::Warning warn(_traceLevels->logger);
+ warn << "default application descriptor:\ndistribution is not allowed.";
+ desc.distrib = DistributionDescriptor();
}
if(!desc.replicaGroups.empty())
{
- Ice::Warning warn(_traceLevels->logger);
- warn << "default application descriptor:\nreplica group definitions are not allowed.";
- desc.replicaGroups.clear();
+ Ice::Warning warn(_traceLevels->logger);
+ warn << "default application descriptor:\nreplica group definitions are not allowed.";
+ desc.replicaGroups.clear();
}
if(!desc.description.empty())
{
- Ice::Warning warn(_traceLevels->logger);
- warn << "default application descriptor:\ndescription is not allowed.";
- desc.description = "";
+ Ice::Warning warn(_traceLevels->logger);
+ warn << "default application descriptor:\ndescription is not allowed.";
+ desc.description = "";
}
if(!desc.variables.empty())
{
- Ice::Warning warn(_traceLevels->logger);
- warn << "default application descriptor:\nvariable definitions are not allowed.";
- desc.variables.clear();
+ Ice::Warning warn(_traceLevels->logger);
+ warn << "default application descriptor:\nvariable definitions are not allowed.";
+ desc.variables.clear();
}
return desc;
}
@@ -334,12 +334,12 @@ AdminI::getServerState(const string& id, const Current&) const
ServerProxyWrapper proxy(_database, id);
try
{
- return proxy->getState();
+ return proxy->getState();
}
catch(const Ice::Exception& ex)
{
- proxy.handleException(ex);
- return Inactive;
+ proxy.handleException(ex);
+ return Inactive;
}
}
@@ -349,12 +349,12 @@ AdminI::getServerPid(const string& id, const Current&) const
ServerProxyWrapper proxy(_database, id);
try
{
- return proxy->getPid();
+ return proxy->getPid();
}
catch(const Ice::Exception& ex)
{
- proxy.handleException(ex);
- return 0;
+ proxy.handleException(ex);
+ return 0;
}
}
@@ -365,11 +365,11 @@ AdminI::startServer(const string& id, const Current&)
proxy.useActivationTimeout();
try
{
- proxy->start();
+ proxy->start();
}
catch(const Ice::Exception& ex)
{
- proxy.handleException(ex);
+ proxy.handleException(ex);
}
}
@@ -380,20 +380,20 @@ AdminI::stopServer(const string& id, const Current&)
proxy.useDeactivationTimeout();
try
{
- proxy->stop();
+ proxy->stop();
}
catch(const Ice::TimeoutException&)
{
}
catch(const Ice::Exception& ex)
{
- proxy.handleException(ex);
+ proxy.handleException(ex);
}
}
void
AdminI::patchServer_async(const AMD_Admin_patchServerPtr& amdCB, const string& id, bool shutdown,
- const Current& current)
+ const Current& current)
{
ServerInfo info = _database->getServer(id)->getInfo();
ApplicationInfo appInfo = _database->getApplicationInfo(info.application);
@@ -404,8 +404,8 @@ AdminI::patchServer_async(const AMD_Admin_patchServerPtr& amdCB, const string& i
if(appDistrib.icepatch.empty() && nodes.empty())
{
- amdCB->ice_response();
- return;
+ amdCB->ice_response();
+ return;
}
assert(nodes.size() == 1);
@@ -415,37 +415,37 @@ AdminI::patchServer_async(const AMD_Admin_patchServerPtr& amdCB, const string& i
identity.name = IceUtil::generateUUID();
PatcherFeedbackAggregatorPtr feedback =
- newPatcherFeedback(amdCB, identity, _traceLevels, "server", id, static_cast<int>(nodes.size()));
+ newPatcherFeedback(amdCB, identity, _traceLevels, "server", id, static_cast<int>(nodes.size()));
vector<string>::const_iterator p = nodes.begin();
try
{
- if(_traceLevels->patch > 0)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->patchCat);
- out << "started patching of server `" << id << "' on node `" << *p << "'";
- }
+ if(_traceLevels->patch > 0)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->patchCat);
+ out << "started patching of server `" << id << "' on node `" << *p << "'";
+ }
- NodeEntryPtr node = _database->getNode(*p);
- Resolver resolve(node->getInfo(), _database->getCommunicator());
- DistributionDescriptor desc = resolve(appDistrib);
- InternalDistributionDescriptorPtr intAppDistrib = new InternalDistributionDescriptor(desc.icepatch,
- desc.directories);
- node->getSession()->patch(feedback, info.application, id, intAppDistrib, shutdown);
+ NodeEntryPtr node = _database->getNode(*p);
+ Resolver resolve(node->getInfo(), _database->getCommunicator());
+ DistributionDescriptor desc = resolve(appDistrib);
+ InternalDistributionDescriptorPtr intAppDistrib = new InternalDistributionDescriptor(desc.icepatch,
+ desc.directories);
+ node->getSession()->patch(feedback, info.application, id, intAppDistrib, shutdown);
}
catch(const NodeNotExistException&)
{
- feedback->failed(*p, "node doesn't exist");
+ feedback->failed(*p, "node doesn't exist");
}
catch(const NodeUnreachableException& e)
{
- feedback->failed(*p, "node is unreachable: " + e.reason);
+ feedback->failed(*p, "node is unreachable: " + e.reason);
}
catch(const Ice::Exception& e)
{
- ostringstream os;
- os << e;
- feedback->failed(*p, "node is unreachable:\n" + os.str());
+ ostringstream os;
+ os << e;
+ feedback->failed(*p, "node is unreachable:\n" + os.str());
}
}
@@ -455,11 +455,11 @@ AdminI::sendSignal(const string& id, const string& signal, const Current&)
ServerProxyWrapper proxy(_database, id);
try
{
- proxy->sendSignal(signal);
+ proxy->sendSignal(signal);
}
catch(const Ice::Exception& ex)
{
- proxy.handleException(ex);
+ proxy.handleException(ex);
}
}
@@ -469,11 +469,11 @@ AdminI::writeMessage(const string& id, const string& message, Int fd, const Curr
ServerProxyWrapper proxy(_database, id);
try
{
- proxy->writeMessage(message, fd);
+ proxy->writeMessage(message, fd);
}
catch(const Ice::Exception& ex)
{
- proxy.handleException(ex);
+ proxy.handleException(ex);
}
}
@@ -489,11 +489,11 @@ AdminI::enableServer(const string& id, bool enable, const Ice::Current&)
ServerProxyWrapper proxy(_database, id);
try
{
- proxy->setEnabled(enable);
+ proxy->setEnabled(enable);
}
catch(const Ice::Exception& ex)
{
- proxy.handleException(ex);
+ proxy.handleException(ex);
}
}
@@ -503,12 +503,12 @@ AdminI::isServerEnabled(const ::std::string& id, const Ice::Current&) const
ServerProxyWrapper proxy(_database, id);
try
{
- return proxy->isEnabled();
+ return proxy->isEnabled();
}
catch(const Ice::Exception& ex)
{
- proxy.handleException(ex);
- return true; // Keeps the compiler happy.
+ proxy.handleException(ex);
+ return true; // Keeps the compiler happy.
}
}
@@ -537,15 +537,15 @@ AdminI::addObject(const Ice::ObjectPrx& proxy, const ::Ice::Current& current)
checkIsMaster();
try
{
- addObjectWithType(proxy, proxy->ice_id(), current);
+ addObjectWithType(proxy, proxy->ice_id(), current);
}
catch(const Ice::LocalException& e)
{
- ostringstream os;
+ ostringstream os;
- os << "failed to invoke ice_id() on proxy `" + current.adapter->getCommunicator()->proxyToString(proxy);
- os << "':\n" << e;
- throw DeploymentException(os.str());
+ os << "failed to invoke ice_id() on proxy `" + current.adapter->getCommunicator()->proxyToString(proxy);
+ os << "':\n" << e;
+ throw DeploymentException(os.str());
}
}
@@ -556,9 +556,9 @@ AdminI::updateObject(const Ice::ObjectPrx& proxy, const ::Ice::Current& current)
const Ice::Identity id = proxy->ice_getIdentity();
if(id.category == _database->getInstanceName())
{
- DeploymentException ex;
- ex.reason ="updating object `" + _database->getCommunicator()->identityToString(id) + "' is not allowed";
- throw ex;
+ DeploymentException ex;
+ ex.reason ="updating object `" + _database->getCommunicator()->identityToString(id) + "' is not allowed";
+ throw ex;
}
_database->updateObject(proxy);
}
@@ -570,9 +570,9 @@ AdminI::addObjectWithType(const Ice::ObjectPrx& proxy, const string& type, const
const Ice::Identity id = proxy->ice_getIdentity();
if(id.category == _database->getInstanceName())
{
- DeploymentException ex;
- ex.reason = "adding object `" + _database->getCommunicator()->identityToString(id) + "' is not allowed";
- throw ex;
+ DeploymentException ex;
+ ex.reason = "adding object `" + _database->getCommunicator()->identityToString(id) + "' is not allowed";
+ throw ex;
}
ObjectInfo info;
@@ -587,9 +587,9 @@ AdminI::removeObject(const Ice::Identity& id, const Ice::Current& current)
checkIsMaster();
if(id.category == _database->getInstanceName())
{
- DeploymentException ex;
- ex.reason = "removing object `" + _database->getCommunicator()->identityToString(id) + "' is not allowed";
- throw ex;
+ DeploymentException ex;
+ ex.reason = "removing object `" + _database->getCommunicator()->identityToString(id) + "' is not allowed";
+ throw ex;
}
_database->removeObject(id);
}
@@ -623,20 +623,20 @@ AdminI::pingNode(const string& name, const Current&) const
{
try
{
- _database->getNode(name)->getProxy()->ice_ping();
- return true;
+ _database->getNode(name)->getProxy()->ice_ping();
+ return true;
}
catch(const NodeUnreachableException&)
{
- return false;
+ return false;
}
catch(const Ice::ObjectNotExistException&)
{
- throw NodeNotExistException();
+ throw NodeNotExistException();
}
catch(const Ice::LocalException&)
{
- return false;
+ return false;
}
}
@@ -645,17 +645,17 @@ AdminI::getNodeLoad(const string& name, const Current&) const
{
try
{
- return _database->getNode(name)->getProxy()->getLoad();
+ return _database->getNode(name)->getProxy()->getLoad();
}
catch(const Ice::ObjectNotExistException&)
{
- throw NodeNotExistException();
+ throw NodeNotExistException();
}
catch(const Ice::LocalException& ex)
{
- ostringstream os;
- os << ex;
- throw NodeUnreachableException(name, os.str());
+ ostringstream os;
+ os << ex;
+ throw NodeUnreachableException(name, os.str());
}
return LoadInfo(); // Keep the compiler happy.
}
@@ -665,17 +665,17 @@ AdminI::shutdownNode(const string& name, const Current&)
{
try
{
- _database->getNode(name)->getProxy()->shutdown();
+ _database->getNode(name)->getProxy()->shutdown();
}
catch(const Ice::ObjectNotExistException&)
{
- throw NodeNotExistException(name);
+ throw NodeNotExistException(name);
}
catch(const Ice::LocalException& ex)
{
- ostringstream os;
- os << ex;
- throw NodeUnreachableException(name, os.str());
+ ostringstream os;
+ os << ex;
+ throw NodeUnreachableException(name, os.str());
}
}
@@ -684,18 +684,18 @@ AdminI::getNodeHostname(const string& name, const Current&) const
{
try
{
- return _database->getNode(name)->getInfo()->hostname;
+ return _database->getNode(name)->getInfo()->hostname;
}
catch(const Ice::ObjectNotExistException&)
{
- throw NodeNotExistException(name);
+ throw NodeNotExistException(name);
}
catch(const Ice::LocalException& ex)
{
- ostringstream os;
- os << ex;
- throw NodeUnreachableException(name, os.str());
- return ""; // Keep the compiler happy.
+ ostringstream os;
+ os << ex;
+ throw NodeUnreachableException(name, os.str());
+ return ""; // Keep the compiler happy.
}
}
@@ -711,11 +711,11 @@ AdminI::getRegistryInfo(const string& name, const Ice::Current&) const
{
if(name == _registry->getName())
{
- return _registry->getInfo();
+ return _registry->getInfo();
}
else
{
- return toRegistryInfo(_database->getReplica(name)->getInfo());
+ return toRegistryInfo(_database->getReplica(name)->getInfo());
}
}
@@ -724,21 +724,21 @@ AdminI::pingRegistry(const string& name, const Current&) const
{
if(name == _registry->getName())
{
- return true;
+ return true;
}
try
{
- _database->getReplica(name)->getProxy()->ice_ping();
- return true;
+ _database->getReplica(name)->getProxy()->ice_ping();
+ return true;
}
catch(const Ice::ObjectNotExistException&)
{
- throw RegistryNotExistException();
+ throw RegistryNotExistException();
}
catch(const Ice::LocalException&)
{
- return false;
+ return false;
}
return false;
}
@@ -748,23 +748,23 @@ AdminI::shutdownRegistry(const string& name, const Current&)
{
if(name == _registry->getName())
{
- _registry->shutdown();
- return;
+ _registry->shutdown();
+ return;
}
try
{
- _database->getReplica(name)->getProxy()->shutdown();
+ _database->getReplica(name)->getProxy()->shutdown();
}
catch(const Ice::ObjectNotExistException&)
{
- throw RegistryNotExistException(name);
+ throw RegistryNotExistException(name);
}
catch(const Ice::LocalException& ex)
{
- ostringstream os;
- os << ex;
- throw RegistryUnreachableException(name, os.str());
+ ostringstream os;
+ os << ex;
+ throw RegistryUnreachableException(name, os.str());
}
}
@@ -793,9 +793,9 @@ AdminI::checkIsMaster() const
{
if(!_database->isMaster())
{
- DeploymentException ex;
- ex.reason = "this operation is only allowed on the master registry.";
- throw ex;
+ DeploymentException ex;
+ ex.reason = "this operation is only allowed on the master registry.";
+ throw ex;
}
}
diff --git a/cpp/src/IceGrid/AdminI.h b/cpp/src/IceGrid/AdminI.h
index bce347df242..a5c63735ad9 100644
--- a/cpp/src/IceGrid/AdminI.h
+++ b/cpp/src/IceGrid/AdminI.h
@@ -39,9 +39,9 @@ public:
virtual void updateApplication(const ApplicationUpdateDescriptor&, const Ice::Current&);
virtual void removeApplication(const std::string&, const Ice::Current&);
virtual void instantiateServer(const std::string&, const std::string&, const ServerInstanceDescriptor&,
- const Ice::Current&);
+ const Ice::Current&);
virtual void patchApplication_async(const AMD_Admin_patchApplicationPtr&, const std::string&, bool,
- const Ice::Current&);
+ const Ice::Current&);
virtual ApplicationInfo getApplicationInfo(const ::std::string&, const Ice::Current&) const;
virtual ApplicationDescriptor getDefaultApplicationDescriptor(const Ice::Current&) const;
virtual Ice::StringSeq getAllApplicationNames(const Ice::Current&) const;
diff --git a/cpp/src/IceGrid/AdminSessionI.cpp b/cpp/src/IceGrid/AdminSessionI.cpp
index 44a634abd5d..8422018e210 100644
--- a/cpp/src/IceGrid/AdminSessionI.cpp
+++ b/cpp/src/IceGrid/AdminSessionI.cpp
@@ -20,10 +20,10 @@ using namespace std;
using namespace IceGrid;
FileIteratorI::FileIteratorI(const AdminSessionIPtr& session,
- const FileReaderPrx& reader,
- const string& filename,
- Ice::Long offset,
- int messageSizeMax) :
+ const FileReaderPrx& reader,
+ const string& filename,
+ Ice::Long offset,
+ int messageSizeMax) :
_session(session),
_reader(reader),
_filename(filename),
@@ -37,13 +37,13 @@ FileIteratorI::read(int size, Ice::StringSeq& lines, const Ice::Current& current
{
try
{
- return _reader->read(_filename, _offset, size > _messageSizeMax ? _messageSizeMax : size, _offset, lines);
+ return _reader->read(_filename, _offset, size > _messageSizeMax ? _messageSizeMax : size, _offset, lines);
}
catch(const Ice::LocalException& ex)
{
- ostringstream os;
- os << ex;
- throw FileNotAvailableException(os.str());
+ ostringstream os;
+ os << ex;
+ throw FileNotAvailableException(os.str());
}
return false; // Keep the compiler happy.
}
@@ -67,8 +67,8 @@ AdminSessionI::~AdminSessionI()
Ice::ObjectPrx
AdminSessionI::registerWithServantLocator(const SessionServantLocatorIPtr& servantLoc,
- const Ice::ConnectionPtr& con,
- const RegistryIPtr& registry)
+ const Ice::ConnectionPtr& con,
+ const RegistryIPtr& registry)
{
Ice::ObjectPrx proxy = BaseSessionI::registerWithServantLocator(servantLoc, con);
_admin = AdminPrx::uncheckedCast(servantLoc->add(new AdminI(_database, registry, this), con));
@@ -94,18 +94,18 @@ AdminSessionI::getAdmin(const Ice::Current& current) const
void
AdminSessionI::setObservers(const RegistryObserverPrx& registryObserver,
- const NodeObserverPrx& nodeObserver,
- const ApplicationObserverPrx& appObserver,
- const AdapterObserverPrx& adapterObserver,
- const ObjectObserverPrx& objectObserver,
- const Ice::Current& current)
+ const NodeObserverPrx& nodeObserver,
+ const ApplicationObserverPrx& appObserver,
+ const AdapterObserverPrx& adapterObserver,
+ const ObjectObserverPrx& objectObserver,
+ const Ice::Current& current)
{
Lock sync(*this);
if(_destroyed)
{
- Ice::ObjectNotExistException ex(__FILE__, __LINE__);
- ex.id = current.id;
- throw ex;
+ Ice::ObjectNotExistException ex(__FILE__, __LINE__);
+ ex.id = current.id;
+ throw ex;
}
if(registryObserver)
@@ -114,7 +114,7 @@ AdminSessionI::setObservers(const RegistryObserverPrx& registryObserver,
}
else
{
- setupObserverSubscription(RegistryObserverTopicName, Ice::ObjectPrx());
+ setupObserverSubscription(RegistryObserverTopicName, Ice::ObjectPrx());
}
if(nodeObserver)
@@ -156,18 +156,18 @@ AdminSessionI::setObservers(const RegistryObserverPrx& registryObserver,
void
AdminSessionI::setObserversByIdentity(const Ice::Identity& registryObserver,
- const Ice::Identity& nodeObserver,
- const Ice::Identity& appObserver,
- const Ice::Identity& adapterObserver,
- const Ice::Identity& objectObserver,
- const Ice::Current& current)
+ const Ice::Identity& nodeObserver,
+ const Ice::Identity& appObserver,
+ const Ice::Identity& adapterObserver,
+ const Ice::Identity& objectObserver,
+ const Ice::Current& current)
{
Lock sync(*this);
if(_destroyed)
{
- Ice::ObjectNotExistException ex(__FILE__, __LINE__);
- ex.id = current.id;
- throw ex;
+ Ice::ObjectNotExistException ex(__FILE__, __LINE__);
+ ex.id = current.id;
+ throw ex;
}
setupObserverSubscription(RegistryObserverTopicName, toProxy(registryObserver, current.con));
@@ -184,9 +184,9 @@ AdminSessionI::startUpdate(const Ice::Current& current)
Lock sync(*this);
if(_destroyed)
{
- Ice::ObjectNotExistException ex(__FILE__, __LINE__);
- ex.id = current.id;
- throw ex;
+ Ice::ObjectNotExistException ex(__FILE__, __LINE__);
+ ex.id = current.id;
+ throw ex;
}
int serial = _database->lock(this, _id);
@@ -199,9 +199,9 @@ AdminSessionI::finishUpdate(const Ice::Current& current)
Lock sync(*this);
if(_destroyed)
{
- Ice::ObjectNotExistException ex(__FILE__, __LINE__);
- ex.id = current.id;
- throw ex;
+ Ice::ObjectNotExistException ex(__FILE__, __LINE__);
+ ex.id = current.id;
+ throw ex;
}
_database->unlock(this);
@@ -249,11 +249,11 @@ AdminSessionI::openRegistryStdOut(const string& name, int nLines, const Ice::Cur
FileReaderPrx reader;
if(name == _replicaName)
{
- reader = _database->getReplicaCache().getInternalRegistry();
+ reader = _database->getReplicaCache().getInternalRegistry();
}
else
{
- reader = _database->getReplica(name)->getProxy();
+ reader = _database->getReplica(name)->getProxy();
}
return addFileIterator(reader, "stdout", nLines, current);
}
@@ -264,11 +264,11 @@ AdminSessionI::openRegistryStdErr(const string& name, int nLines, const Ice::Cur
FileReaderPrx reader;
if(name == _replicaName)
{
- reader = _database->getReplicaCache().getInternalRegistry();
+ reader = _database->getReplicaCache().getInternalRegistry();
}
else
{
- reader = _database->getReplica(name)->getProxy();
+ reader = _database->getReplica(name)->getProxy();
}
return addFileIterator(reader, "stderr", nLines, current);
}
@@ -284,14 +284,14 @@ AdminSessionI::setupObserverSubscription(TopicName name, const Ice::ObjectPrx& o
{
if(_observers[name] && _observers[name] != observer)
{
- _database->getObserverTopic(name)->unsubscribe(_observers[name]);
- _observers[name] = 0;
+ _database->getObserverTopic(name)->unsubscribe(_observers[name]);
+ _observers[name] = 0;
}
if(observer)
{
- _observers[name] = observer;
- _database->getObserverTopic(name)->subscribe(_observers[name]);
+ _observers[name] = observer;
+ _database->getObserverTopic(name)->subscribe(_observers[name]);
}
}
@@ -303,16 +303,16 @@ AdminSessionI::toProxy(const Ice::Identity& id, const Ice::ConnectionPtr& connec
FileIteratorPrx
AdminSessionI::addFileIterator(const FileReaderPrx& reader,
- const string& filename,
- int nLines,
- const Ice::Current& current)
+ const string& filename,
+ int nLines,
+ const Ice::Current& current)
{
Lock sync(*this);
if(_destroyed)
{
- Ice::ObjectNotExistException ex(__FILE__, __LINE__);
- ex.id = current.id;
- throw ex;
+ Ice::ObjectNotExistException ex(__FILE__, __LINE__);
+ ex.id = current.id;
+ throw ex;
}
//
@@ -338,12 +338,12 @@ AdminSessionI::addFileIterator(const FileReaderPrx& reader,
Ice::ObjectPtr servant = new FileIteratorI(this, reader, filename, offset, messageSizeMax);
if(_servantLocator)
{
- obj = _servantLocator->add(servant, current.con);
+ obj = _servantLocator->add(servant, current.con);
}
else
{
- assert(_adapter);
- obj = _adapter->addWithUUID(servant);
+ assert(_adapter);
+ obj = _adapter->addWithUUID(servant);
}
_iterators.insert(obj->ice_getIdentity());
return FileIteratorPrx::uncheckedCast(obj);
@@ -355,18 +355,18 @@ AdminSessionI::removeFileIterator(const Ice::Identity& id, const Ice::Current& c
Lock sync(*this);
if(_servantLocator)
{
- _servantLocator->remove(id);
+ _servantLocator->remove(id);
}
else
{
- try
- {
- assert(_adapter);
- _adapter->remove(id);
- }
- catch(const Ice::ObjectAdapterDeactivatedException&)
- {
- }
+ try
+ {
+ assert(_adapter);
+ _adapter->remove(id);
+ }
+ catch(const Ice::ObjectAdapterDeactivatedException&)
+ {
+ }
}
_iterators.erase(id);
}
@@ -378,7 +378,7 @@ AdminSessionI::destroyImpl(bool shutdown)
try
{
- _database->unlock(this);
+ _database->unlock(this);
}
catch(AccessDeniedException&)
{
@@ -390,58 +390,58 @@ AdminSessionI::destroyImpl(bool shutdown)
//
if(!shutdown)
{
- if(_servantLocator)
- {
- _servantLocator->remove(_admin->ice_getIdentity());
- }
- else if(_adapter)
- {
- try
- {
- _adapter->remove(_admin->ice_getIdentity());
- }
- catch(const Ice::ObjectAdapterDeactivatedException&)
- {
- }
- }
-
- //
- // Unregister the iterators from the session servant locator or
- // object adapter.
- //
- for(set<Ice::Identity>::const_iterator p = _iterators.begin(); p != _iterators.end(); ++p)
- {
- if(_servantLocator)
- {
- _servantLocator->remove(*p);
- }
- else if(_adapter)
- {
- try
- {
- _adapter->remove(*p);
- }
- catch(const Ice::ObjectAdapterDeactivatedException&)
- {
- }
- }
- }
-
- //
- // Unsubscribe from the topics.
- //
- setupObserverSubscription(RegistryObserverTopicName, 0);
- setupObserverSubscription(NodeObserverTopicName, 0);
- setupObserverSubscription(ApplicationObserverTopicName, 0);
- setupObserverSubscription(AdapterObserverTopicName, 0);
- setupObserverSubscription(ObjectObserverTopicName, 0);
+ if(_servantLocator)
+ {
+ _servantLocator->remove(_admin->ice_getIdentity());
+ }
+ else if(_adapter)
+ {
+ try
+ {
+ _adapter->remove(_admin->ice_getIdentity());
+ }
+ catch(const Ice::ObjectAdapterDeactivatedException&)
+ {
+ }
+ }
+
+ //
+ // Unregister the iterators from the session servant locator or
+ // object adapter.
+ //
+ for(set<Ice::Identity>::const_iterator p = _iterators.begin(); p != _iterators.end(); ++p)
+ {
+ if(_servantLocator)
+ {
+ _servantLocator->remove(*p);
+ }
+ else if(_adapter)
+ {
+ try
+ {
+ _adapter->remove(*p);
+ }
+ catch(const Ice::ObjectAdapterDeactivatedException&)
+ {
+ }
+ }
+ }
+
+ //
+ // Unsubscribe from the topics.
+ //
+ setupObserverSubscription(RegistryObserverTopicName, 0);
+ setupObserverSubscription(NodeObserverTopicName, 0);
+ setupObserverSubscription(ApplicationObserverTopicName, 0);
+ setupObserverSubscription(AdapterObserverTopicName, 0);
+ setupObserverSubscription(ObjectObserverTopicName, 0);
}
}
AdminSessionFactory::AdminSessionFactory(const Ice::ObjectAdapterPtr& adapter,
- const DatabasePtr& database,
- const ReapThreadPtr& reaper,
- const RegistryIPtr& registry) :
+ const DatabasePtr& database,
+ const ReapThreadPtr& reaper,
+ const RegistryIPtr& registry) :
_adapter(adapter),
_database(database),
_timeout(registry->getSessionTimeout()),
@@ -470,21 +470,21 @@ AdminSessionFactory::createGlacier2Session(const string& sessionId, const Glacie
int timeout = 0;
if(ctl)
{
- try
- {
- ctl->identities()->add(ids);
- }
- catch(const Ice::LocalException&)
- {
- session->destroy(Ice::Current());
- return 0;
- }
- timeout = ctl->getSessionTimeout();
+ try
+ {
+ ctl->identities()->add(ids);
+ }
+ catch(const Ice::LocalException&)
+ {
+ session->destroy(Ice::Current());
+ return 0;
+ }
+ timeout = ctl->getSessionTimeout();
}
if(timeout > 0)
{
- _reaper->add(new SessionReapable<AdminSessionI>(_database->getTraceLevels()->logger, session), timeout);
+ _reaper->add(new SessionReapable<AdminSessionI>(_database->getTraceLevels()->logger, session), timeout);
}
return Glacier2::SessionPrx::uncheckedCast(proxy);
@@ -518,24 +518,24 @@ AdminSSLSessionManagerI::AdminSSLSessionManagerI(const AdminSessionFactoryPtr& f
Glacier2::SessionPrx
AdminSSLSessionManagerI::create(const Glacier2::SSLInfo& info,
- const Glacier2::SessionControlPrx& ctl,
- const Ice::Current& current)
+ const Glacier2::SessionControlPrx& ctl,
+ const Ice::Current& current)
{
string userDN;
if(!info.certs.empty()) // TODO: Require userDN?
{
- try
- {
- IceSSL::CertificatePtr cert = IceSSL::Certificate::decode(info.certs[0]);
- userDN = cert->getSubjectDN();
- }
- catch(const Ice::Exception& ex)
- {
- // This shouldn't happen, the SSLInfo is supposed to be encoded by Glacier2.
- Ice::Error out(_factory->getTraceLevels()->logger);
- out << "SSL session manager couldn't decode SSL certificates:\n" << ex;
- return 0;
- }
+ try
+ {
+ IceSSL::CertificatePtr cert = IceSSL::Certificate::decode(info.certs[0]);
+ userDN = cert->getSubjectDN();
+ }
+ catch(const Ice::Exception& ex)
+ {
+ // This shouldn't happen, the SSLInfo is supposed to be encoded by Glacier2.
+ Ice::Error out(_factory->getTraceLevels()->logger);
+ out << "SSL session manager couldn't decode SSL certificates:\n" << ex;
+ return 0;
+ }
}
return _factory->createGlacier2Session(userDN, ctl);
diff --git a/cpp/src/IceGrid/AdminSessionI.h b/cpp/src/IceGrid/AdminSessionI.h
index 0f0ec222c72..7fc506b7cc9 100644
--- a/cpp/src/IceGrid/AdminSessionI.h
+++ b/cpp/src/IceGrid/AdminSessionI.h
@@ -32,7 +32,7 @@ public:
virtual ~AdminSessionI();
virtual Ice::ObjectPrx registerWithServantLocator(const SessionServantLocatorIPtr&, const Ice::ConnectionPtr&,
- const RegistryIPtr&);
+ const RegistryIPtr&);
virtual Ice::ObjectPrx registerWithObjectAdapter(const Ice::ObjectAdapterPtr&, const RegistryIPtr&);
virtual void keepAlive(const Ice::Current& current) { BaseSessionI::keepAlive(current); }
@@ -40,10 +40,10 @@ public:
virtual AdminPrx getAdmin(const Ice::Current& = Ice::Current()) const;
virtual void setObservers(const RegistryObserverPrx&, const NodeObserverPrx&, const ApplicationObserverPrx&,
- const AdapterObserverPrx&, const ObjectObserverPrx&, const Ice::Current&);
+ const AdapterObserverPrx&, const ObjectObserverPrx&, const Ice::Current&);
virtual void setObserversByIdentity(const Ice::Identity&, const Ice::Identity&, const Ice::Identity&,
- const Ice::Identity&, const Ice::Identity&, const Ice::Current&);
+ const Ice::Identity&, const Ice::Identity&, const Ice::Current&);
virtual int startUpdate(const Ice::Current&);
virtual void finishUpdate(const Ice::Current&);
@@ -121,7 +121,7 @@ public:
AdminSSLSessionManagerI(const AdminSessionFactoryPtr&);
virtual Glacier2::SessionPrx create(const Glacier2::SSLInfo&, const Glacier2::SessionControlPrx&,
- const Ice::Current&);
+ const Ice::Current&);
private:
diff --git a/cpp/src/IceGrid/Allocatable.cpp b/cpp/src/IceGrid/Allocatable.cpp
index 428bed9d086..5d05acda6b8 100644
--- a/cpp/src/IceGrid/Allocatable.cpp
+++ b/cpp/src/IceGrid/Allocatable.cpp
@@ -25,20 +25,20 @@ AllocationRequest::pending()
if(_timeout == 0)
{
- _state = Canceled;
- canceled(AllocationTimeoutException());
- return false;
+ _state = Canceled;
+ canceled(AllocationTimeoutException());
+ return false;
}
else if(!_session->addAllocationRequest(this))
{
- _state = Canceled;
- canceled(AllocationException("session destroyed"));
- return false;
+ _state = Canceled;
+ canceled(AllocationException("session destroyed"));
+ return false;
}
if(_timeout > 0)
{
- _session->getWaitQueue()->add(this, IceUtil::Time::milliSeconds(_timeout));
+ _session->getWaitQueue()->add(this, IceUtil::Time::milliSeconds(_timeout));
}
_state = Pending;
return true;
@@ -51,19 +51,19 @@ AllocationRequest::allocate(const AllocatablePtr& allocatable, const SessionIPtr
switch(_state)
{
case Initial:
- break;
+ break;
case Canceled:
- return false;
+ return false;
case Pending:
- if(_timeout > 0)
- {
- _session->getWaitQueue()->remove(this);
- }
- _session->removeAllocationRequest(this);
- break;
+ if(_timeout > 0)
+ {
+ _session->getWaitQueue()->remove(this);
+ }
+ _session->removeAllocationRequest(this);
+ break;
case Allocated:
- assert(false);
- break;
+ assert(false);
+ break;
}
//
@@ -71,14 +71,14 @@ AllocationRequest::allocate(const AllocatablePtr& allocatable, const SessionIPtr
//
if(_session == session)
{
- _state = Canceled;
- canceled(AllocationException("already allocated by the session"));
- return false;
+ _state = Canceled;
+ canceled(AllocationException("already allocated by the session"));
+ return false;
}
else
{
- _state = Allocated;
- return true;
+ _state = Allocated;
+ return true;
}
}
@@ -89,17 +89,17 @@ AllocationRequest::cancel(const AllocationException& ex)
switch(_state)
{
case Initial:
- break;
+ break;
case Canceled:
case Allocated:
- return;
+ return;
case Pending:
- if(_timeout > 0)
- {
- _session->getWaitQueue()->remove(this);
- }
- _session->removeAllocationRequest(this);
- break;
+ if(_timeout > 0)
+ {
+ _session->getWaitQueue()->remove(this);
+ }
+ _session->removeAllocationRequest(this);
+ break;
}
_state = Canceled;
@@ -113,13 +113,13 @@ AllocationRequest::expired(bool destroyed)
switch(_state)
{
case Initial:
- assert(false);
+ assert(false);
case Canceled:
case Allocated:
- return;
+ return;
case Pending:
- _session->removeAllocationRequest(this);
- break;
+ _session->removeAllocationRequest(this);
+ break;
}
_state = Canceled;
@@ -175,7 +175,7 @@ Allocatable::checkAllocatable()
{
if(!isAllocatable())
{
- throw AllocationException("not allocatable");
+ throw AllocationException("not allocatable");
}
}
@@ -184,11 +184,11 @@ Allocatable::allocate(const AllocationRequestPtr& request, bool fromRelease)
{
try
{
- return allocate(request, false, fromRelease);
+ return allocate(request, false, fromRelease);
}
catch(const SessionDestroyedException&)
{
- return false; // The session was destroyed
+ return false; // The session was destroyed
}
}
@@ -197,11 +197,11 @@ Allocatable::tryAllocate(const AllocationRequestPtr& request, bool fromRelease)
{
try
{
- return allocate(request, true, fromRelease);
+ return allocate(request, true, fromRelease);
}
catch(const AllocationException&)
{
- return false; // Not allocatable
+ return false; // Not allocatable
}
}
@@ -211,117 +211,117 @@ Allocatable::release(const SessionIPtr& session, bool fromRelease)
bool isReleased = false;
bool hasRequests = false;
{
- Lock sync(*this);
- if(!fromRelease)
- {
- while(_releasing)
- {
- wait();
- }
- assert(!_releasing);
- }
-
- if(!_session || _session != session)
- {
- throw AllocationException("can't release object which is not allocated");
- }
-
- if(--_count == 0)
- {
- _session = 0;
-
- released(session);
-
- isReleased = true;
-
- if(!fromRelease && !_requests.empty())
- {
- assert(!_parent);
- _releasing = true; // Prevent new allocations.
- hasRequests = true;
- }
- }
+ Lock sync(*this);
+ if(!fromRelease)
+ {
+ while(_releasing)
+ {
+ wait();
+ }
+ assert(!_releasing);
+ }
+
+ if(!_session || _session != session)
+ {
+ throw AllocationException("can't release object which is not allocated");
+ }
+
+ if(--_count == 0)
+ {
+ _session = 0;
+
+ released(session);
+
+ isReleased = true;
+
+ if(!fromRelease && !_requests.empty())
+ {
+ assert(!_parent);
+ _releasing = true; // Prevent new allocations.
+ hasRequests = true;
+ }
+ }
}
if(isReleased)
{
- releasedNoSync(session);
+ releasedNoSync(session);
}
if(_parent)
{
- _parent->release(session, fromRelease);
+ _parent->release(session, fromRelease);
}
else if(!fromRelease)
{
- if(hasRequests)
- {
- while(true)
- {
- AllocationRequestPtr request;
- AllocatablePtr allocatable;
- {
- Lock sync(*this);
- allocatable = dequeueAllocationAttempt(request);
- if(!allocatable)
- {
- assert(_count == 0 && _requests.empty());
- _releasing = false;
- notifyAll();
- return;
- }
- }
-
- //
- // Try to allocate the allocatable with the request or if
- // there's no request, just notify the allocatable that it can
- // be allocated again.
- //
- if(request && allocatable->allocate(request, true) || !request && allocatable->canTryAllocate())
- {
- while(true)
- {
- {
- Lock sync(*this);
- assert(_count);
-
- allocatable = 0;
- request = 0;
-
- //
- // Check if there's other requests from the session
- // waiting to allocate this allocatable.
- //
- list<pair<AllocatablePtr, AllocationRequestPtr> >::iterator p = _requests.begin();
- while(p != _requests.end())
- {
- if(p->second && p->second->getSession() == _session)
- {
- allocatable = p->first;
- request = p->second;
- _requests.erase(p);
- break;
- }
- ++p;
- }
- if(!allocatable)
- {
- _releasing = false;
- notifyAll();
- return; // We're done, the allocatable was released (but is allocated again)!
- }
- }
-
- assert(allocatable && request);
- allocatable->allocate(request, true);
- }
- }
- }
- }
- else if(isReleased)
- {
- canTryAllocate(); // Notify that this allocatable can be allocated.
- }
+ if(hasRequests)
+ {
+ while(true)
+ {
+ AllocationRequestPtr request;
+ AllocatablePtr allocatable;
+ {
+ Lock sync(*this);
+ allocatable = dequeueAllocationAttempt(request);
+ if(!allocatable)
+ {
+ assert(_count == 0 && _requests.empty());
+ _releasing = false;
+ notifyAll();
+ return;
+ }
+ }
+
+ //
+ // Try to allocate the allocatable with the request or if
+ // there's no request, just notify the allocatable that it can
+ // be allocated again.
+ //
+ if(request && allocatable->allocate(request, true) || !request && allocatable->canTryAllocate())
+ {
+ while(true)
+ {
+ {
+ Lock sync(*this);
+ assert(_count);
+
+ allocatable = 0;
+ request = 0;
+
+ //
+ // Check if there's other requests from the session
+ // waiting to allocate this allocatable.
+ //
+ list<pair<AllocatablePtr, AllocationRequestPtr> >::iterator p = _requests.begin();
+ while(p != _requests.end())
+ {
+ if(p->second && p->second->getSession() == _session)
+ {
+ allocatable = p->first;
+ request = p->second;
+ _requests.erase(p);
+ break;
+ }
+ ++p;
+ }
+ if(!allocatable)
+ {
+ _releasing = false;
+ notifyAll();
+ return; // We're done, the allocatable was released (but is allocated again)!
+ }
+ }
+
+ assert(allocatable && request);
+ allocatable->allocate(request, true);
+ }
+ }
+ }
+ }
+ else if(isReleased)
+ {
+ canTryAllocate(); // Notify that this allocatable can be allocated.
+ }
}
}
@@ -340,20 +340,20 @@ Allocatable::operator<(const Allocatable& r) const
void
Allocatable::queueAllocationAttempt(const AllocatablePtr& allocatable,
- const AllocationRequestPtr& request,
- bool tryAllocate)
+ const AllocationRequestPtr& request,
+ bool tryAllocate)
{
assert(!_parent);
if(!tryAllocate)
{
- if(request->pending())
- {
- _requests.push_back(make_pair(allocatable, request));
- }
+ if(request->pending())
+ {
+ _requests.push_back(make_pair(allocatable, request));
+ }
}
else
{
- _requests.push_back(make_pair(allocatable, AllocationRequestPtr()));
+ _requests.push_back(make_pair(allocatable, AllocationRequestPtr()));
}
}
@@ -362,8 +362,8 @@ Allocatable::queueAllocationAttemptFromChild(const AllocatablePtr& allocatable)
{
if(_parent)
{
- _parent->queueAllocationAttemptFromChild(allocatable);
- return;
+ _parent->queueAllocationAttemptFromChild(allocatable);
+ return;
}
Lock sync(*this);
@@ -375,14 +375,14 @@ Allocatable::dequeueAllocationAttempt(AllocationRequestPtr& request)
{
if(_requests.empty())
{
- return 0;
+ return 0;
}
pair<AllocatablePtr, AllocationRequestPtr> alloc = _requests.front();
_requests.pop_front();
if(alloc.second)
{
- request = alloc.second;
+ request = alloc.second;
}
return alloc.first;
}
@@ -392,130 +392,130 @@ Allocatable::allocate(const AllocationRequestPtr& request, bool tryAllocate, boo
{
if(_parent && !_parent->allocateFromChild(request, this, tryAllocate, fromRelease))
{
- return false;
+ return false;
}
bool queueWithParent = false;
int allocationCount = 0;
try
{
- Lock sync(*this);
- checkAllocatable();
-
- if(!_session && (fromRelease || !_releasing))
- {
- if(request->allocate(this, _session))
- {
- try
- {
- allocated(request->getSession()); // This might throw SessionDestroyedException
- }
- catch(const SessionDestroyedException&)
- {
- request->canceled(AllocationException("session destroyed"));
- throw;
- }
- assert(_count == 0);
- _session = request->getSession();
- request->allocated(this, request->getSession());
- ++_count;
- allocationCount = _count;
- }
- }
- else if(_session == request->getSession())
- {
- if(!tryAllocate)
- {
- if(request->allocate(this, _session))
- {
- assert(_count > 0);
- ++_count;
- request->allocated(this, _session);
- allocationCount = _count;
- }
- }
- else
- {
- queueWithParent = true;
- }
- }
- else
- {
- queueAllocationAttempt(this, request, tryAllocate);
- }
+ Lock sync(*this);
+ checkAllocatable();
+
+ if(!_session && (fromRelease || !_releasing))
+ {
+ if(request->allocate(this, _session))
+ {
+ try
+ {
+ allocated(request->getSession()); // This might throw SessionDestroyedException
+ }
+ catch(const SessionDestroyedException&)
+ {
+ request->canceled(AllocationException("session destroyed"));
+ throw;
+ }
+ assert(_count == 0);
+ _session = request->getSession();
+ request->allocated(this, request->getSession());
+ ++_count;
+ allocationCount = _count;
+ }
+ }
+ else if(_session == request->getSession())
+ {
+ if(!tryAllocate)
+ {
+ if(request->allocate(this, _session))
+ {
+ assert(_count > 0);
+ ++_count;
+ request->allocated(this, _session);
+ allocationCount = _count;
+ }
+ }
+ else
+ {
+ queueWithParent = true;
+ }
+ }
+ else
+ {
+ queueAllocationAttempt(this, request, tryAllocate);
+ }
}
catch(const SessionDestroyedException& ex)
{
- if(_parent)
- {
- _parent->release(request->getSession(), fromRelease);
- }
- throw ex;
+ if(_parent)
+ {
+ _parent->release(request->getSession(), fromRelease);
+ }
+ throw ex;
}
catch(const AllocationException& ex)
{
- if(_parent)
- {
- _parent->release(request->getSession(), fromRelease);
- }
- throw ex;
+ if(_parent)
+ {
+ _parent->release(request->getSession(), fromRelease);
+ }
+ throw ex;
}
if(allocationCount == 1)
{
- allocatedNoSync(request->getSession());
+ allocatedNoSync(request->getSession());
}
else if(allocationCount == 0 && _parent)
{
- if(queueWithParent)
- {
- _parent->queueAllocationAttemptFromChild(this);
- }
- _parent->release(request->getSession(), fromRelease);
+ if(queueWithParent)
+ {
+ _parent->queueAllocationAttemptFromChild(this);
+ }
+ _parent->release(request->getSession(), fromRelease);
}
return allocationCount > 0;
}
bool
Allocatable::allocateFromChild(const AllocationRequestPtr& request,
- const AllocatablePtr& child,
- bool tryAllocate,
- bool fromRelease)
+ const AllocatablePtr& child,
+ bool tryAllocate,
+ bool fromRelease)
{
if(_parent && !_parent->allocateFromChild(request, child, tryAllocate, fromRelease))
{
- return false;
+ return false;
}
int allocationCount = 0;
{
- Lock sync(*this);
- if((!_session || _session == request->getSession()) && (fromRelease || !_releasing))
- {
- if(!_session)
- {
- try
- {
- allocated(request->getSession());
- }
- catch(const SessionDestroyedException&)
- {
- // Ignore
- }
- }
- _session = request->getSession();
- ++_count;
- allocationCount = _count;
- }
- else
- {
- queueAllocationAttempt(child, request, tryAllocate);
- }
+ Lock sync(*this);
+ if((!_session || _session == request->getSession()) && (fromRelease || !_releasing))
+ {
+ if(!_session)
+ {
+ try
+ {
+ allocated(request->getSession());
+ }
+ catch(const SessionDestroyedException&)
+ {
+ // Ignore
+ }
+ }
+ _session = request->getSession();
+ ++_count;
+ allocationCount = _count;
+ }
+ else
+ {
+ queueAllocationAttempt(child, request, tryAllocate);
+ }
}
if(allocationCount == 1)
{
- allocatedNoSync(request->getSession());
+ allocatedNoSync(request->getSession());
}
return allocationCount > 0;
}
diff --git a/cpp/src/IceGrid/Allocatable.h b/cpp/src/IceGrid/Allocatable.h
index 325cfeb6bd7..11543ffc426 100644
--- a/cpp/src/IceGrid/Allocatable.h
+++ b/cpp/src/IceGrid/Allocatable.h
@@ -58,10 +58,10 @@ private:
enum State
{
- Initial,
- Pending,
- Canceled,
- Allocated
+ Initial,
+ Pending,
+ Canceled,
+ Allocated
};
const SessionIPtr _session;
diff --git a/cpp/src/IceGrid/AllocatableObjectCache.cpp b/cpp/src/IceGrid/AllocatableObjectCache.cpp
index 97484f85949..7df3a45afc3 100644
--- a/cpp/src/IceGrid/AllocatableObjectCache.cpp
+++ b/cpp/src/IceGrid/AllocatableObjectCache.cpp
@@ -26,7 +26,7 @@ struct AllocatableObjectEntryCI : binary_function<AllocatableObjectEntryPtr&, Al
bool
operator()(const AllocatableObjectEntryPtr& lhs, const AllocatableObjectEntryPtr& rhs)
{
- return ::Ice::proxyIdentityLess(lhs->getProxy(), rhs->getProxy());
+ return ::Ice::proxyIdentityLess(lhs->getProxy(), rhs->getProxy());
}
};
@@ -45,7 +45,7 @@ AllocatableObjectCache::TypeEntry::add(const AllocatableObjectEntryPtr& obj)
_objects.insert(lower_bound(_objects.begin(), _objects.end(), obj, AllocatableObjectEntryCI()), obj);
if(!_requests.empty())
{
- canTryAllocate(obj, false);
+ canTryAllocate(obj, false);
}
}
@@ -62,10 +62,10 @@ AllocatableObjectCache::TypeEntry::remove(const AllocatableObjectEntryPtr& obj)
if(!_requests.empty() && _objects.empty())
{
- for(list<ObjectAllocationRequestPtr>::const_iterator p = _requests.begin(); p != _requests.end(); ++p)
- {
- (*p)->cancel(AllocationException("no allocatable objects with type `" + obj->getType() + "' registered"));
- }
+ for(list<ObjectAllocationRequestPtr>::const_iterator p = _requests.begin(); p != _requests.end(); ++p)
+ {
+ (*p)->cancel(AllocationException("no allocatable objects with type `" + obj->getType() + "' registered"));
+ }
}
return _objects.empty();
}
@@ -78,7 +78,7 @@ AllocatableObjectCache::TypeEntry::addAllocationRequest(const ObjectAllocationRe
//
if(request->pending())
{
- _requests.push_back(request);
+ _requests.push_back(request);
}
}
@@ -91,31 +91,31 @@ AllocatableObjectCache::TypeEntry::canTryAllocate(const AllocatableObjectEntryPt
list<ObjectAllocationRequestPtr>::iterator p = _requests.begin();
while(p != _requests.end())
{
- AllocationRequestPtr request = *p;
- try
- {
- if(request->isCanceled()) // If the request has been canceled, we just remove it.
- {
- p = _requests.erase(p);
- }
- else if(entry->tryAllocate(request, fromRelease))
- {
- p = _requests.erase(p);
- return true; // The request successfully allocated the entry!
- }
- else if(entry->getSession()) // If entry is allocated, we're done
- {
- return false;
- }
- else
- {
- ++p;
- }
- }
- catch(const SessionDestroyedException&)
- {
- p = _requests.erase(p);
- }
+ AllocationRequestPtr request = *p;
+ try
+ {
+ if(request->isCanceled()) // If the request has been canceled, we just remove it.
+ {
+ p = _requests.erase(p);
+ }
+ else if(entry->tryAllocate(request, fromRelease))
+ {
+ p = _requests.erase(p);
+ return true; // The request successfully allocated the entry!
+ }
+ else if(entry->getSession()) // If entry is allocated, we're done
+ {
+ return false;
+ }
+ else
+ {
+ ++p;
+ }
+ }
+ catch(const SessionDestroyedException&)
+ {
+ p = _requests.erase(p);
+ }
}
return false;
}
@@ -139,14 +139,14 @@ AllocatableObjectCache::add(const ObjectInfo& info, const AllocatablePtr& parent
map<string, TypeEntry>::iterator p = _types.find(entry->getType());
if(p == _types.end())
{
- p = _types.insert(p, map<string, TypeEntry>::value_type(entry->getType(), TypeEntry()));
+ p = _types.insert(p, map<string, TypeEntry>::value_type(entry->getType(), TypeEntry()));
}
p->second.add(entry);
if(_traceLevels && _traceLevels->object > 0)
{
- Ice::Trace out(_traceLevels->logger, _traceLevels->objectCat);
- out << "added allocatable object `" << _communicator->identityToString(id) << "'";
+ Ice::Trace out(_traceLevels->logger, _traceLevels->objectCat);
+ out << "added allocatable object `" << _communicator->identityToString(id) << "'";
}
}
@@ -157,7 +157,7 @@ AllocatableObjectCache::get(const Ice::Identity& id) const
AllocatableObjectEntryPtr entry = getImpl(id);
if(!entry)
{
- throw ObjectNotRegisteredException(id);
+ throw ObjectNotRegisteredException(id);
}
return entry;
}
@@ -167,23 +167,23 @@ AllocatableObjectCache::remove(const Ice::Identity& id)
{
AllocatableObjectEntryPtr entry;
{
- Lock sync(*this);
- entry = getImpl(id);
- assert(entry);
- removeImpl(id);
-
- map<string, TypeEntry>::iterator p = _types.find(entry->getType());
- assert(p != _types.end());
- if(p->second.remove(entry))
- {
- _types.erase(p);
- }
-
- if(_traceLevels && _traceLevels->object > 0)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->objectCat);
- out << "removed allocatable object `" << _communicator->identityToString(id) << "'";
- }
+ Lock sync(*this);
+ entry = getImpl(id);
+ assert(entry);
+ removeImpl(id);
+
+ map<string, TypeEntry>::iterator p = _types.find(entry->getType());
+ assert(p != _types.end());
+ if(p->second.remove(entry))
+ {
+ _types.erase(p);
+ }
+
+ if(_traceLevels && _traceLevels->object > 0)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->objectCat);
+ out << "removed allocatable object `" << _communicator->identityToString(id) << "'";
+ }
}
//
@@ -202,7 +202,7 @@ AllocatableObjectCache::allocateByType(const string& type, const ObjectAllocatio
map<string, TypeEntry>::iterator p = _types.find(type);
if(p == _types.end())
{
- throw AllocationException("no allocatable objects with type `" + type + "' registered");
+ throw AllocationException("no allocatable objects with type `" + type + "' registered");
}
vector<AllocatableObjectEntryPtr> objects = p->second.getObjects();
@@ -210,17 +210,17 @@ AllocatableObjectCache::allocateByType(const string& type, const ObjectAllocatio
random_shuffle(objects.begin(), objects.end(), rng); // TODO: OPTIMIZE
try
{
- for(vector<AllocatableObjectEntryPtr>::const_iterator q = objects.begin(); q != objects.end(); ++q)
- {
- if((*q)->tryAllocate(request))
- {
- return;
- }
- }
+ for(vector<AllocatableObjectEntryPtr>::const_iterator q = objects.begin(); q != objects.end(); ++q)
+ {
+ if((*q)->tryAllocate(request))
+ {
+ return;
+ }
+ }
}
catch(const SessionDestroyedException&)
{
- return; // The request has been answered already, no need to throw here.
+ return; // The request has been answered already, no need to throw here.
}
p->second.addAllocationRequest(request);
@@ -236,14 +236,14 @@ AllocatableObjectCache::canTryAllocate(const AllocatableObjectEntryPtr& entry)
map<string, TypeEntry>::iterator p = _types.find(entry->getType());
if(p == _types.end())
{
- return false;
+ return false;
}
return p->second.canTryAllocate(entry, true);
}
AllocatableObjectEntry::AllocatableObjectEntry(AllocatableObjectCache& cache,
- const ObjectInfo& info,
- const AllocatablePtr& parent) :
+ const ObjectInfo& info,
+ const AllocatablePtr& parent) :
Allocatable(true, parent),
_cache(cache),
_info(info),
@@ -281,29 +281,29 @@ AllocatableObjectEntry::allocated(const SessionIPtr& session)
TraceLevelsPtr traceLevels = _cache.getTraceLevels();
if(traceLevels && traceLevels->object > 1)
{
- Ice::Trace out(traceLevels->logger, traceLevels->objectCat);
- out << "object `" << _info.proxy->ice_toString() << "' allocated by `" << session->getId() << "' (" << _count
- << ")";
+ Ice::Trace out(traceLevels->logger, traceLevels->objectCat);
+ out << "object `" << _info.proxy->ice_toString() << "' allocated by `" << session->getId() << "' (" << _count
+ << ")";
}
Glacier2::SessionControlPrx ctl = session->getSessionControl();
if(ctl)
{
- try
- {
- Ice::IdentitySeq seq(1);
- seq.push_back(_info.proxy->ice_getIdentity());
- ctl->identities()->add(seq);
- }
- catch(const Ice::LocalException& ex)
- {
- if(traceLevels && traceLevels->object > 0)
- {
- Ice::Trace out(traceLevels->logger, traceLevels->objectCat);
- out << "couldn't add Glacier2 filter for object `" << _info.proxy->ice_toString();
- out << "' allocated by `" << session->getId() << "':\n" << ex;
- }
- }
+ try
+ {
+ Ice::IdentitySeq seq(1);
+ seq.push_back(_info.proxy->ice_getIdentity());
+ ctl->identities()->add(seq);
+ }
+ catch(const Ice::LocalException& ex)
+ {
+ if(traceLevels && traceLevels->object > 0)
+ {
+ Ice::Trace out(traceLevels->logger, traceLevels->objectCat);
+ out << "couldn't add Glacier2 filter for object `" << _info.proxy->ice_toString();
+ out << "' allocated by `" << session->getId() << "':\n" << ex;
+ }
+ }
}
}
@@ -320,28 +320,28 @@ AllocatableObjectEntry::released(const SessionIPtr& session)
Glacier2::SessionControlPrx ctl = session->getSessionControl();
if(ctl)
{
- try
- {
- Ice::IdentitySeq seq(1);
- seq.push_back(_info.proxy->ice_getIdentity());
- ctl->identities()->remove(seq);
- }
- catch(const Ice::LocalException& ex)
- {
- if(traceLevels && traceLevels->object > 0)
- {
- Ice::Trace out(traceLevels->logger, traceLevels->objectCat);
- out << "couldn't remove Glacier2 filter for object `" << _info.proxy->ice_toString();
- out << "' allocated by `" << session->getId() << "':\n" << ex;
- }
- }
+ try
+ {
+ Ice::IdentitySeq seq(1);
+ seq.push_back(_info.proxy->ice_getIdentity());
+ ctl->identities()->remove(seq);
+ }
+ catch(const Ice::LocalException& ex)
+ {
+ if(traceLevels && traceLevels->object > 0)
+ {
+ Ice::Trace out(traceLevels->logger, traceLevels->objectCat);
+ out << "couldn't remove Glacier2 filter for object `" << _info.proxy->ice_toString();
+ out << "' allocated by `" << session->getId() << "':\n" << ex;
+ }
+ }
}
if(traceLevels && traceLevels->object > 1)
{
- Ice::Trace out(traceLevels->logger, traceLevels->objectCat);
- out << "object `" << _info.proxy->ice_toString() << "' released by `" << session->getId() << "' (" << _count
- << ")";
+ Ice::Trace out(traceLevels->logger, traceLevels->objectCat);
+ out << "object `" << _info.proxy->ice_toString() << "' released by `" << session->getId() << "' (" << _count
+ << ")";
}
}
@@ -350,19 +350,19 @@ AllocatableObjectEntry::destroy()
{
SessionIPtr session;
{
- Lock sync(*this);
- _destroyed = true;
- session = _session;
+ Lock sync(*this);
+ _destroyed = true;
+ session = _session;
}
if(session)
{
- try
- {
- release(session);
- }
- catch(const AllocationException&)
- {
- }
+ try
+ {
+ release(session);
+ }
+ catch(const AllocationException&)
+ {
+ }
}
}
@@ -371,7 +371,7 @@ AllocatableObjectEntry::checkAllocatable()
{
if(_destroyed)
{
- throw ObjectNotRegisteredException(_info.proxy->ice_getIdentity());
+ throw ObjectNotRegisteredException(_info.proxy->ice_getIdentity());
}
Allocatable::checkAllocatable();
diff --git a/cpp/src/IceGrid/AllocatableObjectCache.h b/cpp/src/IceGrid/AllocatableObjectCache.h
index a46279e04e1..8c794a1f91f 100644
--- a/cpp/src/IceGrid/AllocatableObjectCache.h
+++ b/cpp/src/IceGrid/AllocatableObjectCache.h
@@ -59,12 +59,12 @@ private:
virtual void allocated(const AllocatablePtr& allocatable, const SessionIPtr& session)
{
- response(AllocatableObjectEntryPtr::dynamicCast(allocatable)->getProxy());
+ response(AllocatableObjectEntryPtr::dynamicCast(allocatable)->getProxy());
}
virtual void canceled(const AllocationException& ex)
{
- exception(ex);
+ exception(ex);
}
};
typedef IceUtil::Handle<ObjectAllocationRequest> ObjectAllocationRequestPtr;
@@ -92,20 +92,20 @@ private:
{
public:
- TypeEntry();
+ TypeEntry();
- void add(const AllocatableObjectEntryPtr&);
- bool remove(const AllocatableObjectEntryPtr&);
-
- void addAllocationRequest(const ObjectAllocationRequestPtr&);
- bool canTryAllocate(const AllocatableObjectEntryPtr&, bool);
+ void add(const AllocatableObjectEntryPtr&);
+ bool remove(const AllocatableObjectEntryPtr&);
+
+ void addAllocationRequest(const ObjectAllocationRequestPtr&);
+ bool canTryAllocate(const AllocatableObjectEntryPtr&, bool);
- const std::vector<AllocatableObjectEntryPtr>& getObjects() const { return _objects; }
+ const std::vector<AllocatableObjectEntryPtr>& getObjects() const { return _objects; }
private:
-
- std::vector<AllocatableObjectEntryPtr> _objects;
- std::list<ObjectAllocationRequestPtr> _requests;
+
+ std::vector<AllocatableObjectEntryPtr> _objects;
+ std::list<ObjectAllocationRequestPtr> _requests;
};
const Ice::CommunicatorPtr _communicator;
diff --git a/cpp/src/IceGrid/Cache.h b/cpp/src/IceGrid/Cache.h
index 284ba6953d0..295aa4a55b4 100644
--- a/cpp/src/IceGrid/Cache.h
+++ b/cpp/src/IceGrid/Cache.h
@@ -38,21 +38,21 @@ public:
bool
has(const Key& key) const
{
- Lock sync(*this);
- return getImpl(key);
+ Lock sync(*this);
+ return getImpl(key);
}
void
remove(const Key& key)
{
- Lock sync(*this);
- removeImpl(key);
+ Lock sync(*this);
+ removeImpl(key);
}
void
setTraceLevels(const TraceLevelsPtr& traceLevels)
{
- _traceLevels = traceLevels;
+ _traceLevels = traceLevels;
}
const TraceLevelsPtr& getTraceLevels() const { return _traceLevels; }
@@ -62,66 +62,66 @@ protected:
virtual ValuePtr
getImpl(const Key& key) const
{
- typename ValueMap::iterator p = const_cast<ValueMap&>(_entries).end();
- if(_entriesHint != p)
- {
- if(_entriesHint->first == key)
- {
- p = _entriesHint;
- }
- }
-
- if(p == const_cast<ValueMap&>(_entries).end())
- {
- p = const_cast<ValueMap&>(_entries).find(key);
- }
-
- if(p != const_cast<ValueMap&>(_entries).end())
- {
- const_cast<typename ValueMap::iterator&>(_entriesHint) = p;
- return p->second;
- }
- else
- {
- return 0;
- }
+ typename ValueMap::iterator p = const_cast<ValueMap&>(_entries).end();
+ if(_entriesHint != p)
+ {
+ if(_entriesHint->first == key)
+ {
+ p = _entriesHint;
+ }
+ }
+
+ if(p == const_cast<ValueMap&>(_entries).end())
+ {
+ p = const_cast<ValueMap&>(_entries).find(key);
+ }
+
+ if(p != const_cast<ValueMap&>(_entries).end())
+ {
+ const_cast<typename ValueMap::iterator&>(_entriesHint) = p;
+ return p->second;
+ }
+ else
+ {
+ return 0;
+ }
}
virtual ValuePtr
addImpl(const Key& key, const ValuePtr& entry)
{
- typename ValueMap::value_type v(key, entry);
- _entriesHint = _entries.insert(_entriesHint, v);
- return entry;
+ typename ValueMap::value_type v(key, entry);
+ _entriesHint = _entries.insert(_entriesHint, v);
+ return entry;
}
virtual void
removeImpl(const Key& key)
{
- typename ValueMap::iterator p = _entries.end();
- if(_entriesHint != _entries.end())
- {
- if(_entriesHint->first == key)
- {
- p = _entriesHint;
- }
- }
-
- if(p == _entries.end())
- {
- p = _entries.find(key);
- }
-
- assert(p != _entries.end());
- if(p->second->canRemove())
- {
- _entries.erase(p);
- _entriesHint = _entries.end();
- }
- else
- {
- _entriesHint = p;
- }
+ typename ValueMap::iterator p = _entries.end();
+ if(_entriesHint != _entries.end())
+ {
+ if(_entriesHint->first == key)
+ {
+ p = _entriesHint;
+ }
+ }
+
+ if(p == _entries.end())
+ {
+ p = _entries.find(key);
+ }
+
+ assert(p != _entries.end());
+ if(p->second->canRemove())
+ {
+ _entries.erase(p);
+ _entriesHint = _entries.end();
+ }
+ else
+ {
+ _entriesHint = p;
+ }
}
TraceLevelsPtr _traceLevels;
@@ -139,8 +139,8 @@ public:
virtual std::vector<std::string>
getAll(const std::string& expr)
{
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
- return getMatchingKeys<std::map<std::string,TPtr> >(Cache<std::string, T>::_entries, expr);
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+ return getMatchingKeys<std::map<std::string,TPtr> >(Cache<std::string, T>::_entries, expr);
}
};
diff --git a/cpp/src/IceGrid/Client.cpp b/cpp/src/IceGrid/Client.cpp
index 965fc931a3b..08f1b384dd1 100644
--- a/cpp/src/IceGrid/Client.cpp
+++ b/cpp/src/IceGrid/Client.cpp
@@ -33,7 +33,7 @@ class SessionKeepAliveThread : public IceUtil::Thread, public IceUtil::Monitor<I
public:
SessionKeepAliveThread(const AdminSessionPrx& session, long timeout) :
- _session(session),
+ _session(session),
_timeout(IceUtil::Time::seconds(timeout)),
_destroy(false)
{
@@ -48,15 +48,15 @@ public:
timedWait(_timeout);
if(_destroy)
{
- break;
- }
+ break;
+ }
try
{
_session->keepAlive();
}
catch(const Ice::Exception&)
{
- break;
+ break;
}
}
}
@@ -103,7 +103,7 @@ static void interruptCallback(int signal)
IceUtil::StaticMutex::Lock lock(_staticMutex);
if(_globalClient)
{
- _globalClient->interrupted();
+ _globalClient->interrupted();
}
}
@@ -118,23 +118,23 @@ void
Client::usage()
{
cerr << "Usage: " << appName() << " [options] [file...]\n";
- cerr <<
- "Options:\n"
- "-h, --help Show this message.\n"
- "-v, --version Display the Ice version.\n"
- "-DNAME Define NAME as 1.\n"
- "-DNAME=DEF Define NAME as DEF.\n"
- "-UNAME Remove any definition for NAME.\n"
- "-IDIR Put DIR in the include file search path.\n"
- "-e COMMANDS Execute COMMANDS.\n"
- "-d, --debug Print debug messages.\n"
+ cerr <<
+ "Options:\n"
+ "-h, --help Show this message.\n"
+ "-v, --version Display the Ice version.\n"
+ "-DNAME Define NAME as 1.\n"
+ "-DNAME=DEF Define NAME as DEF.\n"
+ "-UNAME Remove any definition for NAME.\n"
+ "-IDIR Put DIR in the include file search path.\n"
+ "-e COMMANDS Execute COMMANDS.\n"
+ "-d, --debug Print debug messages.\n"
"-s, --server Start icegridadmin as a server (to parse XML files).\n"
"-u, --username Login with the given username.\n"
"-p, --password Login with the given password.\n"
"-s, --ssl Authenticate through SSL.\n"
"-r, --routed Login through a Glacier2 router.\n"
"-R, --replica NAME Connect to the replica NAME.\n"
- ;
+ ;
}
int
@@ -144,74 +144,74 @@ Client::main(int argc, char* argv[])
try
{
- _appName = argv[0];
- _communicator = Ice::initialize(argc, argv);
-
- {
- IceUtil::StaticMutex::Lock sync(_staticMutex);
- _globalClient = this;
- }
- _ctrlCHandler.setCallback(interruptCallback);
-
- try
- {
- run(argc, argv);
- }
- catch(const Ice::CommunicatorDestroyedException&)
- {
- // Expected if the client is interrupted during the initialization.
- }
+ _appName = argv[0];
+ _communicator = Ice::initialize(argc, argv);
+
+ {
+ IceUtil::StaticMutex::Lock sync(_staticMutex);
+ _globalClient = this;
+ }
+ _ctrlCHandler.setCallback(interruptCallback);
+
+ try
+ {
+ run(argc, argv);
+ }
+ catch(const Ice::CommunicatorDestroyedException&)
+ {
+ // Expected if the client is interrupted during the initialization.
+ }
}
catch(const IceUtil::Exception& ex)
{
- cerr << _appName << ": " << ex << endl;
- status = EXIT_FAILURE;
+ cerr << _appName << ": " << ex << endl;
+ status = EXIT_FAILURE;
}
catch(const std::exception& ex)
{
- cerr << _appName << ": std::exception: " << ex.what() << endl;
- status = EXIT_FAILURE;
+ cerr << _appName << ": std::exception: " << ex.what() << endl;
+ status = EXIT_FAILURE;
}
catch(const std::string& msg)
{
- cerr << _appName << ": " << msg << endl;
- status = EXIT_FAILURE;
+ cerr << _appName << ": " << msg << endl;
+ status = EXIT_FAILURE;
}
catch(const char* msg)
{
- cerr << _appName << ": " << msg << endl;
- status = EXIT_FAILURE;
+ cerr << _appName << ": " << msg << endl;
+ status = EXIT_FAILURE;
}
catch(...)
{
- cerr << _appName << ": unknown exception" << endl;
- status = EXIT_FAILURE;
+ cerr << _appName << ": unknown exception" << endl;
+ status = EXIT_FAILURE;
}
if(_communicator)
{
- try
- {
- _communicator->destroy();
- }
- catch(const Ice::CommunicatorDestroyedException&)
- {
- }
- catch(const Ice::Exception& ex)
- {
- cerr << ex << endl;
- status = EXIT_FAILURE;
- }
+ try
+ {
+ _communicator->destroy();
+ }
+ catch(const Ice::CommunicatorDestroyedException&)
+ {
+ }
+ catch(const Ice::Exception& ex)
+ {
+ cerr << ex << endl;
+ status = EXIT_FAILURE;
+ }
}
_ctrlCHandler.setCallback(0);
{
- IceUtil::StaticMutex::Lock sync(_staticMutex);
- _globalClient = 0;
+ IceUtil::StaticMutex::Lock sync(_staticMutex);
+ _globalClient = 0;
}
return status;
-
+
}
void
@@ -220,21 +220,21 @@ Client::interrupted()
Lock sync(*this);
if(_parser) // If there's an interactive parser, notify the parser.
{
- _parser->interrupt();
+ _parser->interrupt();
}
else
{
- //
- // Otherwise, destroy the communicator.
- //
- assert(_communicator);
- try
- {
- _communicator->destroy();
- }
- catch(const Ice::Exception&)
- {
- }
+ //
+ // Otherwise, destroy the communicator.
+ //
+ assert(_communicator);
+ try
+ {
+ _communicator->destroy();
+ }
+ catch(const Ice::Exception&)
+ {
+ }
}
}
@@ -263,103 +263,103 @@ Client::run(int argc, char* argv[])
vector<string> args;
try
{
- args = opts.parse(argc, (const char**)argv);
+ args = opts.parse(argc, (const char**)argv);
}
catch(const IceUtil::BadOptException& e)
{
cerr << e.reason << endl;
- usage();
- return EXIT_FAILURE;
+ usage();
+ return EXIT_FAILURE;
}
if(opts.isSet("help"))
{
- usage();
- return EXIT_SUCCESS;
+ usage();
+ return EXIT_SUCCESS;
}
if(opts.isSet("version"))
{
- cout << ICE_STRING_VERSION << endl;
- return EXIT_SUCCESS;
+ cout << ICE_STRING_VERSION << endl;
+ return EXIT_SUCCESS;
}
if(opts.isSet("server"))
{
- ObjectAdapterPtr adapter = communicator()->createObjectAdapterWithEndpoints("FileParser", "tcp -h localhost");
- adapter->activate();
- ObjectPrx proxy = adapter->add(new FileParserI, communicator()->stringToIdentity("FileParser"));
- cout << proxy << endl;
+ ObjectAdapterPtr adapter = communicator()->createObjectAdapterWithEndpoints("FileParser", "tcp -h localhost");
+ adapter->activate();
+ ObjectPrx proxy = adapter->add(new FileParserI, communicator()->stringToIdentity("FileParser"));
+ cout << proxy << endl;
- communicator()->waitForShutdown();
- return EXIT_SUCCESS;
+ communicator()->waitForShutdown();
+ return EXIT_SUCCESS;
}
if(opts.isSet("D"))
{
- vector<string> optargs = opts.argVec("D");
- for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i)
- {
- cpp += " -D" + *i;
- }
+ vector<string> optargs = opts.argVec("D");
+ for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i)
+ {
+ cpp += " -D" + *i;
+ }
}
if(opts.isSet("U"))
{
- vector<string> optargs = opts.argVec("U");
- for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i)
- {
- cpp += " -U" + *i;
- }
+ vector<string> optargs = opts.argVec("U");
+ for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i)
+ {
+ cpp += " -U" + *i;
+ }
}
if(opts.isSet("I"))
{
- vector<string> optargs = opts.argVec("I");
- for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i)
- {
- cpp += " -I" + *i;
- }
+ vector<string> optargs = opts.argVec("I");
+ for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i)
+ {
+ cpp += " -I" + *i;
+ }
}
if(opts.isSet("e"))
{
- vector<string> optargs = opts.argVec("e");
- for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i)
- {
- commands += *i + ";";
- }
+ vector<string> optargs = opts.argVec("e");
+ for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i)
+ {
+ commands += *i + ";";
+ }
}
debug = opts.isSet("debug");
if(!args.empty() && !commands.empty())
{
- cerr << appName() << ": `-e' option cannot be used if input files are given" << endl;
- usage();
- return EXIT_FAILURE;
+ cerr << appName() << ": `-e' option cannot be used if input files are given" << endl;
+ usage();
+ return EXIT_FAILURE;
}
string instanceName;
if(communicator()->getDefaultLocator())
{
- instanceName = communicator()->getDefaultLocator()->ice_getIdentity().category;
+ instanceName = communicator()->getDefaultLocator()->ice_getIdentity().category;
}
else
{
- instanceName = communicator()->getProperties()->getPropertyWithDefault("IceGrid.InstanceName", "IceGrid");
+ instanceName = communicator()->getProperties()->getPropertyWithDefault("IceGrid.InstanceName", "IceGrid");
}
bool ssl = communicator()->getProperties()->getPropertyAsInt("IceGridAdmin.AuthenticateUsingSSL");
if(opts.isSet("ssl"))
{
- ssl = true;
+ ssl = true;
}
string id = communicator()->getProperties()->getProperty("IceGridAdmin.Username");
if(!opts.optArg("username").empty())
{
- id = opts.optArg("username");
+ id = opts.optArg("username");
}
string password = communicator()->getProperties()->getProperty("IceGridAdmin.Password");
if(!opts.optArg("password").empty())
{
- password = opts.optArg("password");
+ password = opts.optArg("password");
}
//
@@ -370,12 +370,12 @@ Client::run(int argc, char* argv[])
bool routed = properties->getPropertyAsIntWithDefault("IceGridAdmin.Routed", communicator()->getDefaultRouter());
if(opts.isSet("routed"))
{
- routed = true;
+ routed = true;
}
string replica = properties->getProperty("IceGridAdmin.Replica");
if(!opts.optArg("replica").empty())
{
- replica = opts.optArg("replica");
+ replica = opts.optArg("replica");
}
AdminSessionPrx session;
@@ -383,227 +383,227 @@ Client::run(int argc, char* argv[])
int status = EXIT_SUCCESS;
try
{
- int timeout;
- if(routed)
- {
- Glacier2::RouterPrx router = Glacier2::RouterPrx::checkedCast(communicator()->getDefaultRouter());
- if(!router)
- {
- cerr << argv[0] << ": configured router is not a Glacier2 router" << endl;
- return EXIT_FAILURE;
- }
-
- // Use SSL if available.
- try
- {
- router = Glacier2::RouterPrx::checkedCast(router->ice_secure(true));
- }
- catch(const Ice::NoEndpointException&)
- {
- }
-
- if(ssl)
- {
- session = AdminSessionPrx::uncheckedCast(router->createSessionFromSecureConnection());
- if(!session)
- {
- cerr << argv[0]
- << ": Glacier2 returned a null session, please set the Glacier2.SSLSessionManager property"
- << endl;
- return EXIT_FAILURE;
- }
- }
- else
- {
- while(id.empty())
- {
- cout << "user id: " << flush;
- getline(cin, id);
- id = trim(id);
- }
-
- if(password.empty())
- {
- cout << "password: " << flush;
- getline(cin, password);
- password = trim(password);
- }
-
- session = AdminSessionPrx::uncheckedCast(router->createSession(id, password));
- if(!session)
- {
- cerr << argv[0]
- << ": Glacier2 returned a null session, please set the Glacier2.SessionManager property"
- << endl;
- return EXIT_FAILURE;
- }
- }
- timeout = static_cast<int>(router->getSessionTimeout());
- }
- else
- {
- Identity registryId;
- registryId.category = instanceName;
- registryId.name = "Registry";
- if(!replica.empty() && replica != "Master")
- {
- registryId.name += "-" + replica;
- }
-
- RegistryPrx registry;
- try
- {
- registry = RegistryPrx::checkedCast(
- communicator()->stringToProxy("\"" + communicator()->identityToString(registryId) + "\""));
- if(!registry)
- {
- cerr << argv[0] << ": could not contact registry" << endl;
- return EXIT_FAILURE;
- }
- }
- catch(const Ice::NotRegisteredException&)
- {
- cerr << argv[0] << ": no active registry replica named `" << replica << "'" << endl;
- return EXIT_FAILURE;
- }
-
- // Use SSL if available.
- try
- {
- registry = RegistryPrx::checkedCast(registry->ice_secure(true));
- }
- catch(const Ice::NoEndpointException&)
- {
- }
-
- if(ssl)
- {
- session = registry->createAdminSessionFromSecureConnection();
- }
- else
- {
- while(id.empty())
- {
- cout << "user id: " << flush;
- getline(cin, id);
- id = trim(id);
- }
-
- if(password.empty())
- {
- cout << "password: " << flush;
- getline(cin, password);
- password = trim(password);
- }
-
- session = registry->createAdminSession(id, password);
- }
- assert(session);
- timeout = registry->getSessionTimeout();
- }
-
- keepAlive = new SessionKeepAliveThread(session, timeout / 2);
- keepAlive->start();
-
- AdminPrx admin = session->getAdmin();
-
- Ice::SliceChecksumDict serverChecksums = admin->getSliceChecksums();
- Ice::SliceChecksumDict localChecksums = Ice::sliceChecksums();
-
- //
- // The following slice types are only used by the admin CLI.
- //
- localChecksums.erase("::IceGrid::FileParser");
- localChecksums.erase("::IceGrid::ParseException");
-
- for(Ice::SliceChecksumDict::const_iterator q = localChecksums.begin(); q != localChecksums.end(); ++q)
- {
- Ice::SliceChecksumDict::const_iterator r = serverChecksums.find(q->first);
- if(r == serverChecksums.end())
- {
- cerr << appName() << ": server is using unknown Slice type `" << q->first << "'" << endl;
- }
- else if(q->second != r->second)
- {
- cerr << appName() << ": server is using a different Slice definition of `" << q->first << "'" << endl;
- }
- }
-
- {
- Lock sync(*this);
- _parser = Parser::createParser(communicator(), session, admin, args.empty() && commands.empty());
- }
-
- if(!args.empty()) // Files given
- {
- // Process files given on the command line
- for(vector<string>::const_iterator i = args.begin(); i != args.end(); ++i)
- {
- ifstream test(i->c_str());
- if(!test)
- {
- cerr << appName() << ": can't open `" << *i << "' for reading: " << strerror(errno) << endl;
- return EXIT_FAILURE;
- }
- test.close();
-
- string cmd = cpp + " " + *i;
+ int timeout;
+ if(routed)
+ {
+ Glacier2::RouterPrx router = Glacier2::RouterPrx::checkedCast(communicator()->getDefaultRouter());
+ if(!router)
+ {
+ cerr << argv[0] << ": configured router is not a Glacier2 router" << endl;
+ return EXIT_FAILURE;
+ }
+
+ // Use SSL if available.
+ try
+ {
+ router = Glacier2::RouterPrx::checkedCast(router->ice_secure(true));
+ }
+ catch(const Ice::NoEndpointException&)
+ {
+ }
+
+ if(ssl)
+ {
+ session = AdminSessionPrx::uncheckedCast(router->createSessionFromSecureConnection());
+ if(!session)
+ {
+ cerr << argv[0]
+ << ": Glacier2 returned a null session, please set the Glacier2.SSLSessionManager property"
+ << endl;
+ return EXIT_FAILURE;
+ }
+ }
+ else
+ {
+ while(id.empty())
+ {
+ cout << "user id: " << flush;
+ getline(cin, id);
+ id = trim(id);
+ }
+
+ if(password.empty())
+ {
+ cout << "password: " << flush;
+ getline(cin, password);
+ password = trim(password);
+ }
+
+ session = AdminSessionPrx::uncheckedCast(router->createSession(id, password));
+ if(!session)
+ {
+ cerr << argv[0]
+ << ": Glacier2 returned a null session, please set the Glacier2.SessionManager property"
+ << endl;
+ return EXIT_FAILURE;
+ }
+ }
+ timeout = static_cast<int>(router->getSessionTimeout());
+ }
+ else
+ {
+ Identity registryId;
+ registryId.category = instanceName;
+ registryId.name = "Registry";
+ if(!replica.empty() && replica != "Master")
+ {
+ registryId.name += "-" + replica;
+ }
+
+ RegistryPrx registry;
+ try
+ {
+ registry = RegistryPrx::checkedCast(
+ communicator()->stringToProxy("\"" + communicator()->identityToString(registryId) + "\""));
+ if(!registry)
+ {
+ cerr << argv[0] << ": could not contact registry" << endl;
+ return EXIT_FAILURE;
+ }
+ }
+ catch(const Ice::NotRegisteredException&)
+ {
+ cerr << argv[0] << ": no active registry replica named `" << replica << "'" << endl;
+ return EXIT_FAILURE;
+ }
+
+ // Use SSL if available.
+ try
+ {
+ registry = RegistryPrx::checkedCast(registry->ice_secure(true));
+ }
+ catch(const Ice::NoEndpointException&)
+ {
+ }
+
+ if(ssl)
+ {
+ session = registry->createAdminSessionFromSecureConnection();
+ }
+ else
+ {
+ while(id.empty())
+ {
+ cout << "user id: " << flush;
+ getline(cin, id);
+ id = trim(id);
+ }
+
+ if(password.empty())
+ {
+ cout << "password: " << flush;
+ getline(cin, password);
+ password = trim(password);
+ }
+
+ session = registry->createAdminSession(id, password);
+ }
+ assert(session);
+ timeout = registry->getSessionTimeout();
+ }
+
+ keepAlive = new SessionKeepAliveThread(session, timeout / 2);
+ keepAlive->start();
+
+ AdminPrx admin = session->getAdmin();
+
+ Ice::SliceChecksumDict serverChecksums = admin->getSliceChecksums();
+ Ice::SliceChecksumDict localChecksums = Ice::sliceChecksums();
+
+ //
+ // The following slice types are only used by the admin CLI.
+ //
+ localChecksums.erase("::IceGrid::FileParser");
+ localChecksums.erase("::IceGrid::ParseException");
+
+ for(Ice::SliceChecksumDict::const_iterator q = localChecksums.begin(); q != localChecksums.end(); ++q)
+ {
+ Ice::SliceChecksumDict::const_iterator r = serverChecksums.find(q->first);
+ if(r == serverChecksums.end())
+ {
+ cerr << appName() << ": server is using unknown Slice type `" << q->first << "'" << endl;
+ }
+ else if(q->second != r->second)
+ {
+ cerr << appName() << ": server is using a different Slice definition of `" << q->first << "'" << endl;
+ }
+ }
+
+ {
+ Lock sync(*this);
+ _parser = Parser::createParser(communicator(), session, admin, args.empty() && commands.empty());
+ }
+
+ if(!args.empty()) // Files given
+ {
+ // Process files given on the command line
+ for(vector<string>::const_iterator i = args.begin(); i != args.end(); ++i)
+ {
+ ifstream test(i->c_str());
+ if(!test)
+ {
+ cerr << appName() << ": can't open `" << *i << "' for reading: " << strerror(errno) << endl;
+ return EXIT_FAILURE;
+ }
+ test.close();
+
+ string cmd = cpp + " " + *i;
#ifdef _WIN32
- FILE* cppHandle = _popen(cmd.c_str(), "r");
+ FILE* cppHandle = _popen(cmd.c_str(), "r");
#else
- FILE* cppHandle = popen(cmd.c_str(), "r");
+ FILE* cppHandle = popen(cmd.c_str(), "r");
#endif
- if(cppHandle == NULL)
- {
- cerr << appName() << ": can't run C++ preprocessor: " << strerror(errno) << endl;
- return EXIT_FAILURE;
- }
-
- int parseStatus = _parser->parse(cppHandle, debug);
-
+ if(cppHandle == NULL)
+ {
+ cerr << appName() << ": can't run C++ preprocessor: " << strerror(errno) << endl;
+ return EXIT_FAILURE;
+ }
+
+ int parseStatus = _parser->parse(cppHandle, debug);
+
#ifdef _WIN32
- _pclose(cppHandle);
+ _pclose(cppHandle);
#else
- pclose(cppHandle);
+ pclose(cppHandle);
#endif
- if(parseStatus == EXIT_FAILURE)
- {
- status = EXIT_FAILURE;
- }
- }
- }
- else if(!commands.empty()) // Commands were given
- {
- int parseStatus = _parser->parse(commands, debug);
- if(parseStatus == EXIT_FAILURE)
- {
- status = EXIT_FAILURE;
- }
- }
- else // No commands, let's use standard input
- {
- _parser->showBanner();
-
- int parseStatus = _parser->parse(stdin, debug);
- if(parseStatus == EXIT_FAILURE)
- {
- status = EXIT_FAILURE;
- }
- }
+ if(parseStatus == EXIT_FAILURE)
+ {
+ status = EXIT_FAILURE;
+ }
+ }
+ }
+ else if(!commands.empty()) // Commands were given
+ {
+ int parseStatus = _parser->parse(commands, debug);
+ if(parseStatus == EXIT_FAILURE)
+ {
+ status = EXIT_FAILURE;
+ }
+ }
+ else // No commands, let's use standard input
+ {
+ _parser->showBanner();
+
+ int parseStatus = _parser->parse(stdin, debug);
+ if(parseStatus == EXIT_FAILURE)
+ {
+ status = EXIT_FAILURE;
+ }
+ }
}
catch(const IceGrid::PermissionDeniedException& ex)
{
- cout << "permission denied:\n" << ex.reason << endl;
- return EXIT_FAILURE;
+ cout << "permission denied:\n" << ex.reason << endl;
+ return EXIT_FAILURE;
}
catch(...)
{
- if(keepAlive)
- {
- keepAlive->destroy();
- keepAlive->getThreadControl().join();
- }
+ if(keepAlive)
+ {
+ keepAlive->destroy();
+ keepAlive->getThreadControl().join();
+ }
if(session)
{
@@ -615,7 +615,7 @@ Client::run(int argc, char* argv[])
{
}
}
- throw;
+ throw;
}
keepAlive->destroy();
diff --git a/cpp/src/IceGrid/Database.cpp b/cpp/src/IceGrid/Database.cpp
index aa4803f9269..15dafc7bf4d 100644
--- a/cpp/src/IceGrid/Database.cpp
+++ b/cpp/src/IceGrid/Database.cpp
@@ -38,17 +38,17 @@ struct ObjectLoadCI : binary_function<pair<Ice::ObjectPrx, float>&, pair<Ice::Ob
{
bool operator()(const pair<Ice::ObjectPrx, float>& lhs, const pair<Ice::ObjectPrx, float>& rhs)
{
- return lhs.second < rhs.second;
+ return lhs.second < rhs.second;
}
};
}
Database::Database(const Ice::ObjectAdapterPtr& registryAdapter,
- const IceStorm::TopicManagerPrx& topicManager,
- const string& instanceName,
- const TraceLevelsPtr& traceLevels,
- const RegistryInfo& info) :
+ const IceStorm::TopicManagerPrx& topicManager,
+ const string& instanceName,
+ const TraceLevelsPtr& traceLevels,
+ const RegistryInfo& info) :
_communicator(registryAdapter->getCommunicator()),
_internalAdapter(registryAdapter),
_topicManager(topicManager),
@@ -72,31 +72,31 @@ Database::Database(const Ice::ObjectAdapterPtr& registryAdapter,
ServerEntrySeq entries;
for(StringApplicationInfoDict::iterator p = _applications.begin(); p != _applications.end(); ++p)
{
- try
- {
- //
- // Create an application helper for the application
- // without instantiating. The application might be invalid
- // if we need to upgrade it.
- //
- ApplicationInfo info = p->second;
-
- ApplicationHelper helper(_communicator, p->second.descriptor, false, false);
- if(helper.upgrade(info.descriptor))
- {
- ++info.revision;
- info.updateUser = "IceGrid Registry (database upgrade)";
- info.updateTime = IceUtil::Time::now().toMilliSeconds();
- p.set(info);
- }
-
- load(ApplicationHelper(_communicator, info.descriptor), entries, info.uuid, info.revision);
- }
- catch(const DeploymentException& ex)
- {
- Ice::Error err(_traceLevels->logger);
- err << "invalid application `" << p->first << "':\n" << ex.reason;
- }
+ try
+ {
+ //
+ // Create an application helper for the application
+ // without instantiating. The application might be invalid
+ // if we need to upgrade it.
+ //
+ ApplicationInfo info = p->second;
+
+ ApplicationHelper helper(_communicator, p->second.descriptor, false, false);
+ if(helper.upgrade(info.descriptor))
+ {
+ ++info.revision;
+ info.updateUser = "IceGrid Registry (database upgrade)";
+ info.updateTime = IceUtil::Time::now().toMilliSeconds();
+ p.set(info);
+ }
+
+ load(ApplicationHelper(_communicator, info.descriptor), entries, info.uuid, info.revision);
+ }
+ catch(const DeploymentException& ex)
+ {
+ Ice::Error err(_traceLevels->logger);
+ err << "invalid application `" << p->first << "':\n" << ex.reason;
+ }
}
_serverCache.setTraceLevels(_traceLevels);
@@ -141,17 +141,17 @@ Database::getObserverTopic(TopicName name) const
switch(name)
{
case RegistryObserverTopicName:
- return _registryObserverTopic;
+ return _registryObserverTopic;
case NodeObserverTopicName:
- return _nodeObserverTopic;
+ return _nodeObserverTopic;
case ApplicationObserverTopicName:
- return _applicationObserverTopic;
+ return _applicationObserverTopic;
case AdapterObserverTopicName:
- return _adapterObserverTopic;
+ return _adapterObserverTopic;
case ObjectObserverTopicName:
- return _objectObserverTopic;
+ return _objectObserverTopic;
default:
- break;
+ break;
}
return 0;
}
@@ -161,7 +161,7 @@ Database::checkSessionLock(AdminSessionI* session)
{
if(_lock != 0 && session != _lock)
{
- throw AccessDeniedException(_lockUserId); // Lock held by another session.
+ throw AccessDeniedException(_lockUserId); // Lock held by another session.
}
}
@@ -172,7 +172,7 @@ Database::lock(AdminSessionI* session, const string& userId)
if(_lock != 0 && session != _lock)
{
- throw AccessDeniedException(_lockUserId); // Lock held by another session.
+ throw AccessDeniedException(_lockUserId); // Lock held by another session.
}
assert(_lock == 0 || _lock == session);
@@ -188,7 +188,7 @@ Database::unlock(AdminSessionI* session)
Lock sync(*this);
if(_lock != session)
{
- throw AccessDeniedException();
+ throw AccessDeniedException();
}
_lock = 0;
@@ -200,54 +200,54 @@ Database::syncApplications(const ApplicationInfoSeq& applications)
{
int serial;
{
- Lock sync(*this);
+ Lock sync(*this);
- Freeze::TransactionHolder txHolder(_connection);
- ServerEntrySeq entries;
- set<string> names;
- for(ApplicationInfoSeq::const_iterator p = applications.begin(); p != applications.end(); ++p)
- {
- try
- {
- StringApplicationInfoDict::const_iterator s = _applications.find(p->descriptor.name);
- if(s != _applications.end())
- {
- ApplicationHelper previous(_communicator, s->second.descriptor);
- ApplicationHelper helper(_communicator, p->descriptor);
- reload(previous, helper, entries, p->uuid, p->revision);
- }
- else
- {
- load(ApplicationHelper(_communicator, p->descriptor), entries, p->uuid, p->revision);
- }
- }
- catch(const DeploymentException& ex)
- {
- Ice::Warning warn(_traceLevels->logger);
- warn << "invalid application `" << p->descriptor.name << "':\n" << ex.reason;
- }
- _applications.put(StringApplicationInfoDict::value_type(p->descriptor.name, *p));
- names.insert(p->descriptor.name);
- }
-
- StringApplicationInfoDict::iterator s = _applications.begin();
- while(s != _applications.end())
- {
- if(names.find(s->first) == names.end())
- {
- unload(ApplicationHelper(_communicator, s->second.descriptor), entries);
- _applications.erase(s++);
- }
- else
- {
- ++s;
- }
- }
- ++_applicationSerial;
+ Freeze::TransactionHolder txHolder(_connection);
+ ServerEntrySeq entries;
+ set<string> names;
+ for(ApplicationInfoSeq::const_iterator p = applications.begin(); p != applications.end(); ++p)
+ {
+ try
+ {
+ StringApplicationInfoDict::const_iterator s = _applications.find(p->descriptor.name);
+ if(s != _applications.end())
+ {
+ ApplicationHelper previous(_communicator, s->second.descriptor);
+ ApplicationHelper helper(_communicator, p->descriptor);
+ reload(previous, helper, entries, p->uuid, p->revision);
+ }
+ else
+ {
+ load(ApplicationHelper(_communicator, p->descriptor), entries, p->uuid, p->revision);
+ }
+ }
+ catch(const DeploymentException& ex)
+ {
+ Ice::Warning warn(_traceLevels->logger);
+ warn << "invalid application `" << p->descriptor.name << "':\n" << ex.reason;
+ }
+ _applications.put(StringApplicationInfoDict::value_type(p->descriptor.name, *p));
+ names.insert(p->descriptor.name);
+ }
+
+ StringApplicationInfoDict::iterator s = _applications.begin();
+ while(s != _applications.end())
+ {
+ if(names.find(s->first) == names.end())
+ {
+ unload(ApplicationHelper(_communicator, s->second.descriptor), entries);
+ _applications.erase(s++);
+ }
+ else
+ {
+ ++s;
+ }
+ }
+ ++_applicationSerial;
- serial = _applicationObserverTopic->applicationInit(_applicationSerial, applications);
+ serial = _applicationObserverTopic->applicationInit(_applicationSerial, applications);
- txHolder.commit();
+ txHolder.commit();
}
_applicationObserverTopic->waitForSyncedSubscribers(serial);
}
@@ -257,15 +257,15 @@ Database::syncAdapters(const AdapterInfoSeq& adapters)
{
int serial;
{
- Lock sync(*this);
- Freeze::TransactionHolder txHolder(_connection);
- _adapters.clear();
- for(AdapterInfoSeq::const_iterator r = adapters.begin(); r != adapters.end(); ++r)
- {
- _adapters.put(StringAdapterInfoDict::value_type(r->id, *r));
- }
- serial = _adapterObserverTopic->adapterInit(adapters);
- txHolder.commit();
+ Lock sync(*this);
+ Freeze::TransactionHolder txHolder(_connection);
+ _adapters.clear();
+ for(AdapterInfoSeq::const_iterator r = adapters.begin(); r != adapters.end(); ++r)
+ {
+ _adapters.put(StringAdapterInfoDict::value_type(r->id, *r));
+ }
+ serial = _adapterObserverTopic->adapterInit(adapters);
+ txHolder.commit();
}
_adapterObserverTopic->waitForSyncedSubscribers(serial);
}
@@ -275,15 +275,15 @@ Database::syncObjects(const ObjectInfoSeq& objects)
{
int serial;
{
- Lock sync(*this);
- Freeze::TransactionHolder txHolder(_connection);
- _objects.clear();
- for(ObjectInfoSeq::const_iterator q = objects.begin(); q != objects.end(); ++q)
- {
- _objects.put(IdentityObjectInfoDict::value_type(q->proxy->ice_getIdentity(), *q));
- }
- serial = _objectObserverTopic->objectInit(objects);
- txHolder.commit();
+ Lock sync(*this);
+ Freeze::TransactionHolder txHolder(_connection);
+ _objects.clear();
+ for(ObjectInfoSeq::const_iterator q = objects.begin(); q != objects.end(); ++q)
+ {
+ _objects.put(IdentityObjectInfoDict::value_type(q->proxy->ice_getIdentity(), *q));
+ }
+ serial = _objectObserverTopic->objectInit(objects);
+ txHolder.commit();
}
_objectObserverTopic->waitForSyncedSubscribers(serial);
}
@@ -293,62 +293,62 @@ Database::addApplication(const ApplicationInfo& info, AdminSessionI* session)
{
ServerEntrySeq entries;
{
- Lock sync(*this);
- checkSessionLock(session);
+ Lock sync(*this);
+ checkSessionLock(session);
- while(_updating.find(info.descriptor.name) != _updating.end())
- {
- wait();
- }
+ while(_updating.find(info.descriptor.name) != _updating.end())
+ {
+ wait();
+ }
- if(_applications.find(info.descriptor.name) != _applications.end())
- {
- throw DeploymentException("application `" + info.descriptor.name + "' already exists");
- }
+ if(_applications.find(info.descriptor.name) != _applications.end())
+ {
+ throw DeploymentException("application `" + info.descriptor.name + "' already exists");
+ }
- ApplicationHelper helper(_communicator, info.descriptor, true);
- checkForAddition(helper);
- load(helper, entries, info.uuid, info.revision);
- startUpdating(info.descriptor.name);
+ ApplicationHelper helper(_communicator, info.descriptor, true);
+ checkForAddition(helper);
+ load(helper, entries, info.uuid, info.revision);
+ startUpdating(info.descriptor.name);
}
if(_master)
{
- try
- {
- for_each(entries.begin(), entries.end(), IceUtil::voidMemFun(&ServerEntry::syncAndWait));
- }
- catch(const DeploymentException& ex)
- {
- try
- {
- Lock sync(*this);
- entries.clear();
- unload(ApplicationHelper(_communicator, info.descriptor), entries);
- }
- catch(const DeploymentException& ex)
- {
- Ice::Error err(_traceLevels->logger);
- err << "failed to rollback previous application `" << info.descriptor.name << "':\n" << ex.reason;
- }
- finishUpdating(info.descriptor.name);
- throw ex;
- }
+ try
+ {
+ for_each(entries.begin(), entries.end(), IceUtil::voidMemFun(&ServerEntry::syncAndWait));
+ }
+ catch(const DeploymentException& ex)
+ {
+ try
+ {
+ Lock sync(*this);
+ entries.clear();
+ unload(ApplicationHelper(_communicator, info.descriptor), entries);
+ }
+ catch(const DeploymentException& ex)
+ {
+ Ice::Error err(_traceLevels->logger);
+ err << "failed to rollback previous application `" << info.descriptor.name << "':\n" << ex.reason;
+ }
+ finishUpdating(info.descriptor.name);
+ throw ex;
+ }
}
int serial;
{
- Lock sync(*this);
- ++_applicationSerial;
- _applications.put(StringApplicationInfoDict::value_type(info.descriptor.name, info));
+ Lock sync(*this);
+ ++_applicationSerial;
+ _applications.put(StringApplicationInfoDict::value_type(info.descriptor.name, info));
- serial = _applicationObserverTopic->applicationAdded(_applicationSerial, info);
+ serial = _applicationObserverTopic->applicationAdded(_applicationSerial, info);
- if(_traceLevels->application > 0)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->applicationCat);
- out << "added application `" << info.descriptor.name << "'";
- }
+ if(_traceLevels->application > 0)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->applicationCat);
+ out << "added application `" << info.descriptor.name << "'";
+ }
}
_applicationObserverTopic->waitForSyncedSubscribers(serial);
@@ -364,35 +364,35 @@ Database::updateApplication(const ApplicationUpdateInfo& updt, AdminSessionI* se
ApplicationDescriptor newDesc;
ApplicationUpdateInfo update = updt;
{
- Lock sync(*this);
- checkSessionLock(session);
+ Lock sync(*this);
+ checkSessionLock(session);
- while(_updating.find(update.descriptor.name) != _updating.end())
- {
- wait();
- }
+ while(_updating.find(update.descriptor.name) != _updating.end())
+ {
+ wait();
+ }
- StringApplicationInfoDict::const_iterator p = _applications.find(update.descriptor.name);
- if(p == _applications.end())
- {
- throw ApplicationNotExistException(update.descriptor.name);
- }
- oldApp = p->second;
+ StringApplicationInfoDict::const_iterator p = _applications.find(update.descriptor.name);
+ if(p == _applications.end())
+ {
+ throw ApplicationNotExistException(update.descriptor.name);
+ }
+ oldApp = p->second;
- if(update.revision < 0)
- {
- update.revision = oldApp.revision + 1;
- }
+ if(update.revision < 0)
+ {
+ update.revision = oldApp.revision + 1;
+ }
- ApplicationHelper previous(_communicator, oldApp.descriptor);
- ApplicationHelper helper(_communicator, previous.update(update.descriptor), true);
+ ApplicationHelper previous(_communicator, oldApp.descriptor);
+ ApplicationHelper helper(_communicator, previous.update(update.descriptor), true);
- checkForUpdate(previous, helper);
- reload(previous, helper, entries, oldApp.uuid, oldApp.revision + 1);
+ checkForUpdate(previous, helper);
+ reload(previous, helper, entries, oldApp.uuid, oldApp.revision + 1);
- newDesc = helper.getDefinition();
+ newDesc = helper.getDefinition();
- startUpdating(update.descriptor.name);
+ startUpdating(update.descriptor.name);
}
finishApplicationUpdate(entries, update, oldApp, newDesc, session);
@@ -405,33 +405,33 @@ Database::syncApplicationDescriptor(const ApplicationDescriptor& newDesc, AdminS
ApplicationUpdateInfo update;
ApplicationInfo oldApp;
{
- Lock sync(*this);
- checkSessionLock(session);
+ Lock sync(*this);
+ checkSessionLock(session);
- while(_updating.find(update.descriptor.name) != _updating.end())
- {
- wait();
- }
+ while(_updating.find(update.descriptor.name) != _updating.end())
+ {
+ wait();
+ }
- StringApplicationInfoDict::const_iterator p = _applications.find(newDesc.name);
- if(p == _applications.end())
- {
- throw ApplicationNotExistException(newDesc.name);
- }
- oldApp = p->second;
+ StringApplicationInfoDict::const_iterator p = _applications.find(newDesc.name);
+ if(p == _applications.end())
+ {
+ throw ApplicationNotExistException(newDesc.name);
+ }
+ oldApp = p->second;
- ApplicationHelper previous(_communicator, oldApp.descriptor);
- ApplicationHelper helper(_communicator, newDesc, true);
+ ApplicationHelper previous(_communicator, oldApp.descriptor);
+ ApplicationHelper helper(_communicator, newDesc, true);
- update.updateTime = IceUtil::Time::now().toMilliSeconds();
- update.updateUser = _lockUserId;
- update.revision = oldApp.revision + 1;
- update.descriptor = helper.diff(previous);
-
- checkForUpdate(previous, helper);
- reload(previous, helper, entries, oldApp.uuid, oldApp.revision + 1);
+ update.updateTime = IceUtil::Time::now().toMilliSeconds();
+ update.updateUser = _lockUserId;
+ update.revision = oldApp.revision + 1;
+ update.descriptor = helper.diff(previous);
+
+ checkForUpdate(previous, helper);
+ reload(previous, helper, entries, oldApp.uuid, oldApp.revision + 1);
- startUpdating(update.descriptor.name);
+ startUpdating(update.descriptor.name);
}
finishApplicationUpdate(entries, update, oldApp, newDesc, session);
@@ -439,44 +439,44 @@ Database::syncApplicationDescriptor(const ApplicationDescriptor& newDesc, AdminS
void
Database::instantiateServer(const string& application,
- const string& node,
- const ServerInstanceDescriptor& instance,
- AdminSessionI* session)
+ const string& node,
+ const ServerInstanceDescriptor& instance,
+ AdminSessionI* session)
{
ServerEntrySeq entries;
ApplicationUpdateInfo update;
ApplicationInfo oldApp;
ApplicationDescriptor newDesc;
{
- Lock sync(*this);
- checkSessionLock(session);
+ Lock sync(*this);
+ checkSessionLock(session);
- while(_updating.find(application) != _updating.end())
- {
- wait();
- }
+ while(_updating.find(application) != _updating.end())
+ {
+ wait();
+ }
- StringApplicationInfoDict::const_iterator p = _applications.find(application);
- if(p == _applications.end())
- {
- throw ApplicationNotExistException(application);
- }
- oldApp = p->second;
+ StringApplicationInfoDict::const_iterator p = _applications.find(application);
+ if(p == _applications.end())
+ {
+ throw ApplicationNotExistException(application);
+ }
+ oldApp = p->second;
- ApplicationHelper previous(_communicator, oldApp.descriptor);
- ApplicationHelper helper(_communicator, previous.instantiateServer(node, instance), true);
+ ApplicationHelper previous(_communicator, oldApp.descriptor);
+ ApplicationHelper helper(_communicator, previous.instantiateServer(node, instance), true);
- update.updateTime = IceUtil::Time::now().toMilliSeconds();
- update.updateUser = _lockUserId;
- update.revision = oldApp.revision + 1;
- update.descriptor = helper.diff(previous);
+ update.updateTime = IceUtil::Time::now().toMilliSeconds();
+ update.updateUser = _lockUserId;
+ update.revision = oldApp.revision + 1;
+ update.descriptor = helper.diff(previous);
- checkForUpdate(previous, helper);
- reload(previous, helper, entries, oldApp.uuid, oldApp.revision + 1);
+ checkForUpdate(previous, helper);
+ reload(previous, helper, entries, oldApp.uuid, oldApp.revision + 1);
- newDesc = helper.getDefinition();
+ newDesc = helper.getDefinition();
- startUpdating(update.descriptor.name);
+ startUpdating(update.descriptor.name);
}
finishApplicationUpdate(entries, update, oldApp, newDesc, session);
@@ -488,55 +488,55 @@ Database::removeApplication(const string& name, AdminSessionI* session)
ServerEntrySeq entries;
int serial;
{
- Lock sync(*this);
- checkSessionLock(session);
-
- while(_updating.find(name) != _updating.end())
- {
- wait();
- }
-
- StringApplicationInfoDict::iterator p = _applications.find(name);
- if(p == _applications.end())
- {
- throw ApplicationNotExistException(name);
- }
-
- try
- {
- ApplicationHelper helper(_communicator, p->second.descriptor);
- unload(helper, entries);
- }
- catch(const DeploymentException&)
- {
- //
- // For some reasons the application became invalid. If
- // it's invalid, it's most likely not loaded either. So we
- // ignore the error and erase the descriptor.
- //
- }
-
- startUpdating(name);
+ Lock sync(*this);
+ checkSessionLock(session);
+
+ while(_updating.find(name) != _updating.end())
+ {
+ wait();
+ }
+
+ StringApplicationInfoDict::iterator p = _applications.find(name);
+ if(p == _applications.end())
+ {
+ throw ApplicationNotExistException(name);
+ }
+
+ try
+ {
+ ApplicationHelper helper(_communicator, p->second.descriptor);
+ unload(helper, entries);
+ }
+ catch(const DeploymentException&)
+ {
+ //
+ // For some reasons the application became invalid. If
+ // it's invalid, it's most likely not loaded either. So we
+ // ignore the error and erase the descriptor.
+ //
+ }
+
+ startUpdating(name);
}
if(_master)
{
- for_each(entries.begin(), entries.end(), IceUtil::voidMemFun(&ServerEntry::sync));
- for_each(entries.begin(), entries.end(), IceUtil::voidMemFun(&ServerEntry::waitNoThrow));
+ for_each(entries.begin(), entries.end(), IceUtil::voidMemFun(&ServerEntry::sync));
+ for_each(entries.begin(), entries.end(), IceUtil::voidMemFun(&ServerEntry::waitNoThrow));
}
{
- Lock sync(*this);
- _applications.erase(name);
- ++_applicationSerial;
+ Lock sync(*this);
+ _applications.erase(name);
+ ++_applicationSerial;
- serial = _applicationObserverTopic->applicationRemoved(_applicationSerial, name);
+ serial = _applicationObserverTopic->applicationRemoved(_applicationSerial, name);
- if(_traceLevels->application > 0)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->applicationCat);
- out << "removed application `" << name << "'";
- }
+ if(_traceLevels->application > 0)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->applicationCat);
+ out << "removed application `" << name << "'";
+ }
}
_applicationObserverTopic->waitForSyncedSubscribers(serial);
@@ -553,7 +553,7 @@ Database::getApplicationInfo(const std::string& name)
StringApplicationInfoDict::const_iterator p = descriptors.find(name);
if(p == descriptors.end())
{
- throw ApplicationNotExistException(name);
+ throw ApplicationNotExistException(name);
}
return p->second;
@@ -569,18 +569,18 @@ Database::getAllApplications(const string& expression)
void
Database::waitForApplicationUpdate(const AMD_NodeSession_waitForApplicationUpdatePtr& cb,
- const string& application,
- int revision)
+ const string& application,
+ int revision)
{
Lock sync(*this);
map<string, vector<AMD_NodeSession_waitForApplicationUpdatePtr> >::iterator p = _updating.find(application);
if(p != _updating.end())
{
- p->second.push_back(cb);
+ p->second.push_back(cb);
}
else
{
- cb->ice_response();
+ cb->ice_response();
}
}
@@ -637,67 +637,67 @@ Database::setAdapterDirectProxy(const string& adapterId, const string& replicaGr
{
int serial;
{
- Lock sync(*this);
- if(_adapterCache.has(adapterId))
- {
- throw AdapterExistsException(adapterId);
- }
-
- StringAdapterInfoDict::iterator p = _adapters.find(adapterId);
- AdapterInfo info;
- bool updated = false;
- if(proxy)
- {
- if(p != _adapters.end())
- {
- info = p->second;
- info.proxy = proxy;
- info.replicaGroupId = replicaGroupId;
- p.set(info);
- updated = true;
- }
- else
- {
- info.id = adapterId;
- info.proxy = proxy;
- info.replicaGroupId = replicaGroupId;
- _adapters.put(StringAdapterInfoDict::value_type(adapterId, info));
- }
- }
- else
- {
- if(p == _adapters.end())
- {
- return;
- }
- _adapters.erase(p);
- }
-
- if(_traceLevels->adapter > 0)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->adapterCat);
- out << (proxy ? (updated ? "updated" : "added") : "removed") << " adapter `" << adapterId << "'";
- if(!replicaGroupId.empty())
- {
- out << " with replica group `" << replicaGroupId << "'";
- }
- }
+ Lock sync(*this);
+ if(_adapterCache.has(adapterId))
+ {
+ throw AdapterExistsException(adapterId);
+ }
+
+ StringAdapterInfoDict::iterator p = _adapters.find(adapterId);
+ AdapterInfo info;
+ bool updated = false;
+ if(proxy)
+ {
+ if(p != _adapters.end())
+ {
+ info = p->second;
+ info.proxy = proxy;
+ info.replicaGroupId = replicaGroupId;
+ p.set(info);
+ updated = true;
+ }
+ else
+ {
+ info.id = adapterId;
+ info.proxy = proxy;
+ info.replicaGroupId = replicaGroupId;
+ _adapters.put(StringAdapterInfoDict::value_type(adapterId, info));
+ }
+ }
+ else
+ {
+ if(p == _adapters.end())
+ {
+ return;
+ }
+ _adapters.erase(p);
+ }
+
+ if(_traceLevels->adapter > 0)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->adapterCat);
+ out << (proxy ? (updated ? "updated" : "added") : "removed") << " adapter `" << adapterId << "'";
+ if(!replicaGroupId.empty())
+ {
+ out << " with replica group `" << replicaGroupId << "'";
+ }
+ }
- if(proxy)
- {
- if(updated)
- {
- serial = _adapterObserverTopic->adapterUpdated(info);
- }
- else
- {
- serial = _adapterObserverTopic->adapterAdded(info);
- }
- }
- else
- {
- serial = _adapterObserverTopic->adapterRemoved(adapterId);
- }
+ if(proxy)
+ {
+ if(updated)
+ {
+ serial = _adapterObserverTopic->adapterUpdated(info);
+ }
+ else
+ {
+ serial = _adapterObserverTopic->adapterAdded(info);
+ }
+ }
+ else
+ {
+ serial = _adapterObserverTopic->adapterRemoved(adapterId);
+ }
}
_adapterObserverTopic->waitForSyncedSubscribers(serial);
}
@@ -710,18 +710,18 @@ Database::getAdapterDirectProxy(const string& id)
StringAdapterInfoDict::const_iterator p = adapters.find(id);
if(p != adapters.end())
{
- return p->second.proxy;
+ return p->second.proxy;
}
Ice::EndpointSeq endpoints;
for(p = adapters.findByReplicaGroupId(id, true); p != adapters.end(); ++p)
{
- Ice::EndpointSeq edpts = p->second.proxy->ice_getEndpoints();
- endpoints.insert(endpoints.end(), edpts.begin(), edpts.end());
+ Ice::EndpointSeq edpts = p->second.proxy->ice_getEndpoints();
+ endpoints.insert(endpoints.end(), edpts.begin(), edpts.end());
}
if(!endpoints.empty())
{
- return _communicator->stringToProxy("dummy:default")->ice_endpoints(endpoints);
+ return _communicator->stringToProxy("dummy:default")->ice_endpoints(endpoints);
}
throw AdapterNotExistException(id);
@@ -732,61 +732,61 @@ Database::removeAdapter(const string& adapterId)
{
int serial;
{
- Lock sync(*this);
- if(_adapterCache.has(adapterId))
- {
- AdapterEntryPtr adpt = _adapterCache.get(adapterId);
- DeploymentException ex;
- ex.reason = "removing adapter `" + adapterId + "' is not allowed:\n";
- ex.reason += "the adapter was added with the application descriptor `" + adpt->getApplication() + "'";
- throw ex;
- }
-
- Freeze::TransactionHolder txHolder(_connection); // Required because of the iterator
-
- StringAdapterInfoDict::iterator p = _adapters.find(adapterId);
- AdapterInfoSeq infos;
- if(p != _adapters.end())
- {
- _adapters.erase(p);
- }
- else
- {
- p = _adapters.findByReplicaGroupId(adapterId, true);
- if(p == _adapters.end())
- {
- throw AdapterNotExistException(adapterId);
- }
-
- while(p != _adapters.end())
- {
- AdapterInfo info = p->second;
- info.replicaGroupId = "";
- infos.push_back(info);
- _adapters.put(StringAdapterInfoDict::value_type(p->first, info));
- ++p;
- }
- }
-
- if(_traceLevels->adapter > 0)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->adapterCat);
- out << "removed " << (infos.empty() ? "adapter" : "replica group") << " `" << adapterId << "'";
- }
-
- if(infos.empty())
- {
- serial = _adapterObserverTopic->adapterRemoved(adapterId);
- }
- else
- {
- for(AdapterInfoSeq::const_iterator p = infos.begin(); p != infos.end(); ++p)
- {
- serial = _adapterObserverTopic->adapterUpdated(*p);
- }
- }
-
- txHolder.commit();
+ Lock sync(*this);
+ if(_adapterCache.has(adapterId))
+ {
+ AdapterEntryPtr adpt = _adapterCache.get(adapterId);
+ DeploymentException ex;
+ ex.reason = "removing adapter `" + adapterId + "' is not allowed:\n";
+ ex.reason += "the adapter was added with the application descriptor `" + adpt->getApplication() + "'";
+ throw ex;
+ }
+
+ Freeze::TransactionHolder txHolder(_connection); // Required because of the iterator
+
+ StringAdapterInfoDict::iterator p = _adapters.find(adapterId);
+ AdapterInfoSeq infos;
+ if(p != _adapters.end())
+ {
+ _adapters.erase(p);
+ }
+ else
+ {
+ p = _adapters.findByReplicaGroupId(adapterId, true);
+ if(p == _adapters.end())
+ {
+ throw AdapterNotExistException(adapterId);
+ }
+
+ while(p != _adapters.end())
+ {
+ AdapterInfo info = p->second;
+ info.replicaGroupId = "";
+ infos.push_back(info);
+ _adapters.put(StringAdapterInfoDict::value_type(p->first, info));
+ ++p;
+ }
+ }
+
+ if(_traceLevels->adapter > 0)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->adapterCat);
+ out << "removed " << (infos.empty() ? "adapter" : "replica group") << " `" << adapterId << "'";
+ }
+
+ if(infos.empty())
+ {
+ serial = _adapterObserverTopic->adapterRemoved(adapterId);
+ }
+ else
+ {
+ for(AdapterInfoSeq::const_iterator p = infos.begin(); p != infos.end(); ++p)
+ {
+ serial = _adapterObserverTopic->adapterUpdated(*p);
+ }
+ }
+
+ txHolder.commit();
}
_adapterObserverTopic->waitForSyncedSubscribers(serial);
}
@@ -807,7 +807,7 @@ Database::getAdapterInfo(const string& id)
//
try
{
- return _adapterCache.get(id)->getAdapterInfo();
+ return _adapterCache.get(id)->getAdapterInfo();
}
catch(AdapterNotExistException&)
{
@@ -822,9 +822,9 @@ Database::getAdapterInfo(const string& id)
StringAdapterInfoDict::const_iterator p = adapters.find(id);
if(p != adapters.end())
{
- AdapterInfoSeq infos;
- infos.push_back(p->second);
- return infos;
+ AdapterInfoSeq infos;
+ infos.push_back(p->second);
+ return infos;
}
//
@@ -834,13 +834,13 @@ Database::getAdapterInfo(const string& id)
p = adapters.findByReplicaGroupId(id, true);
if(p != adapters.end())
{
- AdapterInfoSeq infos;
- while(p != adapters.end())
- {
- infos.push_back(p->second);
- ++p;
- }
- return infos;
+ AdapterInfoSeq infos;
+ while(p != adapters.end())
+ {
+ infos.push_back(p->second);
+ ++p;
+ }
+ return infos;
}
throw AdapterNotExistException(id);
@@ -857,15 +857,15 @@ Database::getAllAdapters(const string& expression)
set<string> groups;
for(StringAdapterInfoDict::const_iterator p = _adapters.begin(); p != _adapters.end(); ++p)
{
- if(expression.empty() || IceUtil::match(p->first, expression, true))
- {
- result.push_back(p->first);
- }
- string replicaGroupId = p->second.replicaGroupId;
- if(!replicaGroupId.empty() && (expression.empty() || IceUtil::match(replicaGroupId, expression, true)))
- {
- groups.insert(replicaGroupId);
- }
+ if(expression.empty() || IceUtil::match(p->first, expression, true))
+ {
+ result.push_back(p->first);
+ }
+ string replicaGroupId = p->second.replicaGroupId;
+ if(!replicaGroupId.empty() && (expression.empty() || IceUtil::match(replicaGroupId, expression, true)))
+ {
+ groups.insert(replicaGroupId);
+ }
}
//
// COMPILERFIX: We're not using result.insert() here, this doesn't compile on Sun.
@@ -873,7 +873,7 @@ Database::getAllAdapters(const string& expression)
//result.insert(result.end(), groups.begin(), groups.end())
for(set<string>::const_iterator q = groups.begin(); q != groups.end(); ++q)
{
- result.push_back(*q);
+ result.push_back(*q);
}
return result;
}
@@ -883,27 +883,27 @@ Database::addObject(const ObjectInfo& info)
{
int serial;
{
- Lock sync(*this);
- const Ice::Identity id = info.proxy->ice_getIdentity();
-
- if(_objectCache.has(id))
- {
- throw ObjectExistsException(id);
- }
-
- if(_objects.find(id) != _objects.end())
- {
- throw ObjectExistsException(id);
- }
- _objects.put(IdentityObjectInfoDict::value_type(id, info));
-
- serial = _objectObserverTopic->objectAdded(info);
-
- if(_traceLevels->object > 0)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->objectCat);
- out << "added object `" << _communicator->identityToString(id) << "'";
- }
+ Lock sync(*this);
+ const Ice::Identity id = info.proxy->ice_getIdentity();
+
+ if(_objectCache.has(id))
+ {
+ throw ObjectExistsException(id);
+ }
+
+ if(_objects.find(id) != _objects.end())
+ {
+ throw ObjectExistsException(id);
+ }
+ _objects.put(IdentityObjectInfoDict::value_type(id, info));
+
+ serial = _objectObserverTopic->objectAdded(info);
+
+ if(_traceLevels->object > 0)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->objectCat);
+ out << "added object `" << _communicator->identityToString(id) << "'";
+ }
}
_objectObserverTopic->waitForSyncedSubscribers(serial);
}
@@ -913,31 +913,31 @@ Database::addOrUpdateObject(const ObjectInfo& info)
{
int serial;
{
- Lock sync(*this);
- const Ice::Identity id = info.proxy->ice_getIdentity();
-
- if(_objectCache.has(id))
- {
- throw ObjectExistsException(id);
- }
-
- bool update = _objects.find(id) != _objects.end();
- _objects.put(IdentityObjectInfoDict::value_type(id, info));
-
- if(update)
- {
- serial = _objectObserverTopic->objectUpdated(info);
- }
- else
- {
- serial = _objectObserverTopic->objectAdded(info);
- }
-
- if(_traceLevels->object > 0)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->objectCat);
- out << (!update ? "added" : "updated") << " object `" << _communicator->identityToString(id) << "'";
- }
+ Lock sync(*this);
+ const Ice::Identity id = info.proxy->ice_getIdentity();
+
+ if(_objectCache.has(id))
+ {
+ throw ObjectExistsException(id);
+ }
+
+ bool update = _objects.find(id) != _objects.end();
+ _objects.put(IdentityObjectInfoDict::value_type(id, info));
+
+ if(update)
+ {
+ serial = _objectObserverTopic->objectUpdated(info);
+ }
+ else
+ {
+ serial = _objectObserverTopic->objectAdded(info);
+ }
+
+ if(_traceLevels->object > 0)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->objectCat);
+ out << (!update ? "added" : "updated") << " object `" << _communicator->identityToString(id) << "'";
+ }
}
_objectObserverTopic->waitForSyncedSubscribers(serial);
}
@@ -947,33 +947,33 @@ Database::removeObject(const Ice::Identity& id)
{
int serial;
{
- Lock sync(*this);
- if(_objectCache.has(id))
- {
- DeploymentException ex;
- ex.reason = "removing object `" + _communicator->identityToString(id) + "' is not allowed:\n";
- ex.reason += "the object was added with the application descriptor `";
- ex.reason += _objectCache.get(id)->getApplication();
- ex.reason += "'";
- throw ex;
- }
-
- IdentityObjectInfoDict::iterator p = _objects.find(id);
- if(p == _objects.end())
- {
- ObjectNotRegisteredException ex;
- ex.id = id;
- throw ex;
- }
- _objects.erase(p);
-
- serial = _objectObserverTopic->objectRemoved(id);
-
- if(_traceLevels->object > 0)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->objectCat);
- out << "removed object `" << _communicator->identityToString(id) << "'";
- }
+ Lock sync(*this);
+ if(_objectCache.has(id))
+ {
+ DeploymentException ex;
+ ex.reason = "removing object `" + _communicator->identityToString(id) + "' is not allowed:\n";
+ ex.reason += "the object was added with the application descriptor `";
+ ex.reason += _objectCache.get(id)->getApplication();
+ ex.reason += "'";
+ throw ex;
+ }
+
+ IdentityObjectInfoDict::iterator p = _objects.find(id);
+ if(p == _objects.end())
+ {
+ ObjectNotRegisteredException ex;
+ ex.id = id;
+ throw ex;
+ }
+ _objects.erase(p);
+
+ serial = _objectObserverTopic->objectRemoved(id);
+
+ if(_traceLevels->object > 0)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->objectCat);
+ out << "removed object `" << _communicator->identityToString(id) << "'";
+ }
}
_objectObserverTopic->waitForSyncedSubscribers(serial);
}
@@ -983,39 +983,39 @@ Database::updateObject(const Ice::ObjectPrx& proxy)
{
int serial;
{
- Lock sync(*this);
-
- const Ice::Identity id = proxy->ice_getIdentity();
- if(_objectCache.has(id))
- {
- DeploymentException ex;
- ex.reason = "updating object `" + _communicator->identityToString(id) + "' is not allowed:\n";
- ex.reason += "the object was added with the application descriptor `";
- ex.reason += _objectCache.get(id)->getApplication();
- ex.reason += "'";
- throw ex;
- }
+ Lock sync(*this);
+
+ const Ice::Identity id = proxy->ice_getIdentity();
+ if(_objectCache.has(id))
+ {
+ DeploymentException ex;
+ ex.reason = "updating object `" + _communicator->identityToString(id) + "' is not allowed:\n";
+ ex.reason += "the object was added with the application descriptor `";
+ ex.reason += _objectCache.get(id)->getApplication();
+ ex.reason += "'";
+ throw ex;
+ }
- IdentityObjectInfoDict::iterator p = _objects.find(id);
- if(p == _objects.end())
- {
- ObjectNotRegisteredException ex;
- ex.id = id;
- throw ex;
- }
-
- ObjectInfo info;
- info = p->second;
- info.proxy = proxy;
- p.set(info);
+ IdentityObjectInfoDict::iterator p = _objects.find(id);
+ if(p == _objects.end())
+ {
+ ObjectNotRegisteredException ex;
+ ex.id = id;
+ throw ex;
+ }
+
+ ObjectInfo info;
+ info = p->second;
+ info.proxy = proxy;
+ p.set(info);
- serial = _objectObserverTopic->objectUpdated(info);
-
- if(_traceLevels->object > 0)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->objectCat);
- out << "updated object `" << _communicator->identityToString(id) << "'";
- }
+ serial = _objectObserverTopic->objectUpdated(info);
+
+ if(_traceLevels->object > 0)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->objectCat);
+ out << "updated object `" << _communicator->identityToString(id) << "'";
+ }
}
_objectObserverTopic->waitForSyncedSubscribers(serial);
}
@@ -1027,7 +1027,7 @@ Database::addOrUpdateObjectsInDatabase(const ObjectInfoSeq& objects)
Freeze::TransactionHolder txHolder(_connection);
for(ObjectInfoSeq::const_iterator p = objects.begin(); p != objects.end(); ++p)
{
- _objects.put(IdentityObjectInfoDict::value_type(p->proxy->ice_getIdentity(), *p));
+ _objects.put(IdentityObjectInfoDict::value_type(p->proxy->ice_getIdentity(), *p));
}
int serial = _objectObserverTopic->objectsAddedOrUpdated(objects);
txHolder.commit();
@@ -1041,7 +1041,7 @@ Database::removeObjectsInDatabase(const ObjectInfoSeq& objects)
Freeze::TransactionHolder txHolder(_connection);
for(ObjectInfoSeq::const_iterator p = objects.begin(); p != objects.end(); ++p)
{
- _objects.erase(p->proxy->ice_getIdentity());
+ _objects.erase(p->proxy->ice_getIdentity());
}
_objectObserverTopic->objectsRemoved(objects);
txHolder.commit();
@@ -1052,10 +1052,10 @@ Database::getObjectProxy(const Ice::Identity& id)
{
try
{
- //
- // Only return proxies for non allocatable objects.
- //
- return _objectCache.get(id)->getProxy();
+ //
+ // Only return proxies for non allocatable objects.
+ //
+ return _objectCache.get(id)->getProxy();
}
catch(ObjectNotRegisteredException&)
{
@@ -1066,9 +1066,9 @@ Database::getObjectProxy(const Ice::Identity& id)
IdentityObjectInfoDict::const_iterator p = objects.find(id);
if(p == objects.end())
{
- ObjectNotRegisteredException ex;
- ex.id = id;
- throw ex;
+ ObjectNotRegisteredException ex;
+ ex.id = id;
+ throw ex;
}
return p->second.proxy;
}
@@ -1079,7 +1079,7 @@ Database::getObjectByType(const string& type)
Ice::ObjectProxySeq objs = getObjectsByType(type);
if(objs.empty())
{
- return 0;
+ return 0;
}
return objs[IceUtil::random(static_cast<int>(objs.size()))];
}
@@ -1090,7 +1090,7 @@ Database::getObjectByTypeOnLeastLoadedNode(const string& type, LoadSample sample
Ice::ObjectProxySeq objs = getObjectsByType(type);
if(objs.empty())
{
- return 0;
+ return 0;
}
RandomNumberGenerator rng;
@@ -1099,18 +1099,18 @@ Database::getObjectByTypeOnLeastLoadedNode(const string& type, LoadSample sample
objectsWithLoad.reserve(objs.size());
for(Ice::ObjectProxySeq::const_iterator p = objs.begin(); p != objs.end(); ++p)
{
- float load = 1.0f;
- if(!(*p)->ice_getAdapterId().empty())
- {
- try
- {
- load = _adapterCache.get((*p)->ice_getAdapterId())->getLeastLoadedNodeLoad(sample);
- }
- catch(const AdapterNotExistException&)
- {
- }
- }
- objectsWithLoad.push_back(make_pair(*p, load));
+ float load = 1.0f;
+ if(!(*p)->ice_getAdapterId().empty())
+ {
+ try
+ {
+ load = _adapterCache.get((*p)->ice_getAdapterId())->getLeastLoadedNodeLoad(sample);
+ }
+ catch(const AdapterNotExistException&)
+ {
+ }
+ }
+ objectsWithLoad.push_back(make_pair(*p, load));
}
return min_element(objectsWithLoad.begin(), objectsWithLoad.end(), ObjectLoadCI())->first;
}
@@ -1124,7 +1124,7 @@ Database::getObjectsByType(const string& type)
IdentityObjectInfoDict objects(connection, _objectDbName);
for(IdentityObjectInfoDict::const_iterator p = objects.findByType(type); p != objects.end(); ++p)
{
- proxies.push_back(p->second.proxy);
+ proxies.push_back(p->second.proxy);
}
return proxies;
}
@@ -1134,8 +1134,8 @@ Database::getObjectInfo(const Ice::Identity& id)
{
try
{
- ObjectEntryPtr object = _objectCache.get(id);
- return object->getObjectInfo();
+ ObjectEntryPtr object = _objectCache.get(id);
+ return object->getObjectInfo();
}
catch(ObjectNotRegisteredException&)
{
@@ -1146,7 +1146,7 @@ Database::getObjectInfo(const Ice::Identity& id)
IdentityObjectInfoDict::const_iterator p = objects.find(id);
if(p == objects.end())
{
- throw ObjectNotRegisteredException(id);
+ throw ObjectNotRegisteredException(id);
}
return p->second;
}
@@ -1159,10 +1159,10 @@ Database::getAllObjectInfos(const string& expression)
IdentityObjectInfoDict objects(connection, _objectDbName);
for(IdentityObjectInfoDict::const_iterator p = objects.begin(); p != objects.end(); ++p)
{
- if(expression.empty() || IceUtil::match(_communicator->identityToString(p->first), expression, true))
- {
- infos.push_back(p->second);
- }
+ if(expression.empty() || IceUtil::match(_communicator->identityToString(p->first), expression, true))
+ {
+ infos.push_back(p->second);
+ }
}
return infos;
}
@@ -1175,7 +1175,7 @@ Database::getObjectInfosByType(const string& type)
IdentityObjectInfoDict objects(connection, _objectDbName);
for(IdentityObjectInfoDict::const_iterator p = objects.findByType(type); p != objects.end(); ++p)
{
- infos.push_back(p->second);
+ infos.push_back(p->second);
}
return infos;
}
@@ -1183,11 +1183,11 @@ Database::getObjectInfosByType(const string& type)
void
Database::addInternalObject(const ObjectInfo& info, bool replace)
{
- Lock sync(*this);
+ Lock sync(*this);
const Ice::Identity id = info.proxy->ice_getIdentity();
if(!replace && _internalObjects.find(id) != _internalObjects.end())
{
- throw ObjectExistsException(id);
+ throw ObjectExistsException(id);
}
_internalObjects.put(IdentityObjectInfoDict::value_type(id, info));
}
@@ -1199,9 +1199,9 @@ Database::removeInternalObject(const Ice::Identity& id)
IdentityObjectInfoDict::iterator p = _internalObjects.find(id);
if(p == _internalObjects.end())
{
- ObjectNotRegisteredException ex;
- ex.id = id;
- throw ex;
+ ObjectNotRegisteredException ex;
+ ex.id = id;
+ throw ex;
}
_internalObjects.erase(p);
}
@@ -1214,7 +1214,7 @@ Database::getInternalObjectsByType(const string& type)
Ice::ObjectProxySeq proxies;
for(IdentityObjectInfoDict::const_iterator p = internalObjects.findByType(type); p != internalObjects.end(); ++p)
{
- proxies.push_back(p->second.proxy);
+ proxies.push_back(p->second.proxy);
}
return proxies;
}
@@ -1261,9 +1261,9 @@ Database::checkServerForAddition(const string& id)
{
if(_serverCache.has(id))
{
- DeploymentException ex;
- ex.reason = "server `" + id + "' is already registered";
- throw ex;
+ DeploymentException ex;
+ ex.reason = "server `" + id + "' is already registered";
+ throw ex;
}
}
@@ -1274,9 +1274,9 @@ Database::checkAdapterForAddition(const string& id)
_adapters.find(id) != _adapters.end() ||
_adapters.findByReplicaGroupId(id) != _adapters.end())
{
- DeploymentException ex;
- ex.reason = "adapter `" + id + "' is already registered";
- throw ex;
+ DeploymentException ex;
+ ex.reason = "adapter `" + id + "' is already registered";
+ throw ex;
}
}
@@ -1287,9 +1287,9 @@ Database::checkObjectForAddition(const Ice::Identity& objectId)
_allocatableObjectCache.has(objectId) ||
_objects.find(objectId) != _objects.end())
{
- DeploymentException ex;
- ex.reason = "object `" + _communicator->identityToString(objectId) + "' is already registered";
- throw ex;
+ DeploymentException ex;
+ ex.reason = "object `" + _communicator->identityToString(objectId) + "' is already registered";
+ throw ex;
}
}
@@ -1300,27 +1300,27 @@ Database::load(const ApplicationHelper& app, ServerEntrySeq& entries, const stri
const string application = app.getInstance().name;
for(NodeDescriptorDict::const_iterator n = nodes.begin(); n != nodes.end(); ++n)
{
- _nodeCache.get(n->first, true)->addDescriptor(application, n->second);
+ _nodeCache.get(n->first, true)->addDescriptor(application, n->second);
}
const ReplicaGroupDescriptorSeq& adpts = app.getInstance().replicaGroups;
for(ReplicaGroupDescriptorSeq::const_iterator r = adpts.begin(); r != adpts.end(); ++r)
{
- assert(!r->id.empty());
- _adapterCache.addReplicaGroup(*r, application);
- for(ObjectDescriptorSeq::const_iterator o = r->objects.begin(); o != r->objects.end(); ++o)
- {
- ObjectInfo info;
- info.type = o->type;
- info.proxy = _communicator->stringToProxy("\"" + _communicator->identityToString(o->id) + "\" @ " + r->id);
- _objectCache.add(info, application);
- }
+ assert(!r->id.empty());
+ _adapterCache.addReplicaGroup(*r, application);
+ for(ObjectDescriptorSeq::const_iterator o = r->objects.begin(); o != r->objects.end(); ++o)
+ {
+ ObjectInfo info;
+ info.type = o->type;
+ info.proxy = _communicator->stringToProxy("\"" + _communicator->identityToString(o->id) + "\" @ " + r->id);
+ _objectCache.add(info, application);
+ }
}
map<string, ServerInfo> servers = app.getServerInfos(uuid, revision);
for(map<string, ServerInfo>::const_iterator p = servers.begin(); p != servers.end(); ++p)
{
- entries.push_back(_serverCache.add(p->second));
+ entries.push_back(_serverCache.add(p->second));
}
}
@@ -1330,33 +1330,33 @@ Database::unload(const ApplicationHelper& app, ServerEntrySeq& entries)
map<string, ServerInfo> servers = app.getServerInfos("", 0);
for(map<string, ServerInfo>::const_iterator p = servers.begin(); p != servers.end(); ++p)
{
- entries.push_back(_serverCache.remove(p->first));
+ entries.push_back(_serverCache.remove(p->first));
}
const ReplicaGroupDescriptorSeq& adpts = app.getInstance().replicaGroups;
for(ReplicaGroupDescriptorSeq::const_iterator r = adpts.begin(); r != adpts.end(); ++r)
{
- for(ObjectDescriptorSeq::const_iterator o = r->objects.begin(); o != r->objects.end(); ++o)
- {
- _objectCache.remove(o->id);
- }
- _adapterCache.removeReplicaGroup(r->id);
+ for(ObjectDescriptorSeq::const_iterator o = r->objects.begin(); o != r->objects.end(); ++o)
+ {
+ _objectCache.remove(o->id);
+ }
+ _adapterCache.removeReplicaGroup(r->id);
}
const NodeDescriptorDict& nodes = app.getInstance().nodes;
const string application = app.getInstance().name;
for(NodeDescriptorDict::const_iterator n = nodes.begin(); n != nodes.end(); ++n)
{
- _nodeCache.get(n->first)->removeDescriptor(application);
+ _nodeCache.get(n->first)->removeDescriptor(application);
}
}
void
Database::reload(const ApplicationHelper& oldApp,
- const ApplicationHelper& newApp,
- ServerEntrySeq& entries,
- const string& uuid,
- int revision)
+ const ApplicationHelper& newApp,
+ ServerEntrySeq& entries,
+ const string& uuid,
+ int revision)
{
const string application = oldApp.getInstance().name;
@@ -1369,24 +1369,24 @@ Database::reload(const ApplicationHelper& oldApp,
map<string, ServerInfo>::const_iterator p;
for(p = newServers.begin(); p != newServers.end(); ++p)
{
- map<string, ServerInfo>::const_iterator q = oldServers.find(p->first);
- if(q == oldServers.end())
- {
- load.push_back(p->second);
- }
- else
- {
- _serverCache.remove(p->first, false); // Don't destroy the server if it was updated.
- load.push_back(p->second);
- }
+ map<string, ServerInfo>::const_iterator q = oldServers.find(p->first);
+ if(q == oldServers.end())
+ {
+ load.push_back(p->second);
+ }
+ else
+ {
+ _serverCache.remove(p->first, false); // Don't destroy the server if it was updated.
+ load.push_back(p->second);
+ }
}
for(p = oldServers.begin(); p != oldServers.end(); ++p)
{
- map<string, ServerInfo>::const_iterator q = newServers.find(p->first);
- if(q == newServers.end())
- {
- entries.push_back(_serverCache.remove(p->first));
- }
+ map<string, ServerInfo>::const_iterator q = newServers.find(p->first);
+ if(q == newServers.end())
+ {
+ entries.push_back(_serverCache.remove(p->first));
+ }
}
//
@@ -1397,22 +1397,22 @@ Database::reload(const ApplicationHelper& oldApp,
ReplicaGroupDescriptorSeq::const_iterator r;
for(r = oldAdpts.begin(); r != oldAdpts.end(); ++r)
{
- ReplicaGroupDescriptorSeq::const_iterator t;
- for(t = newAdpts.begin(); t != newAdpts.end(); ++t)
- {
- if(t->id == r->id)
- {
- break;
- }
- }
- for(ObjectDescriptorSeq::const_iterator o = r->objects.begin(); o != r->objects.end(); ++o)
- {
- _objectCache.remove(o->id);
- }
- if(t == newAdpts.end())
- {
- _adapterCache.removeReplicaGroup(r->id);
- }
+ ReplicaGroupDescriptorSeq::const_iterator t;
+ for(t = newAdpts.begin(); t != newAdpts.end(); ++t)
+ {
+ if(t->id == r->id)
+ {
+ break;
+ }
+ }
+ for(ObjectDescriptorSeq::const_iterator o = r->objects.begin(); o != r->objects.end(); ++o)
+ {
+ _objectCache.remove(o->id);
+ }
+ if(t == newAdpts.end())
+ {
+ _adapterCache.removeReplicaGroup(r->id);
+ }
}
//
@@ -1422,7 +1422,7 @@ Database::reload(const ApplicationHelper& oldApp,
NodeDescriptorDict::const_iterator n;
for(n = oldNodes.begin(); n != oldNodes.end(); ++n)
{
- _nodeCache.get(n->first)->removeDescriptor(application);
+ _nodeCache.get(n->first)->removeDescriptor(application);
}
//
@@ -1431,7 +1431,7 @@ Database::reload(const ApplicationHelper& oldApp,
const NodeDescriptorDict& newNodes = newApp.getInstance().nodes;
for(n = newNodes.begin(); n != newNodes.end(); ++n)
{
- _nodeCache.get(n->first, true)->addDescriptor(application, n->second);
+ _nodeCache.get(n->first, true)->addDescriptor(application, n->second);
}
//
@@ -1439,24 +1439,24 @@ Database::reload(const ApplicationHelper& oldApp,
//
for(r = newAdpts.begin(); r != newAdpts.end(); ++r)
{
- try
- {
- ReplicaGroupEntryPtr entry = ReplicaGroupEntryPtr::dynamicCast(_adapterCache.get(r->id));
- assert(entry);
- entry->update(r->loadBalancing);
- }
- catch(const AdapterNotExistException&)
- {
- _adapterCache.addReplicaGroup(*r, application);
- }
-
- for(ObjectDescriptorSeq::const_iterator o = r->objects.begin(); o != r->objects.end(); ++o)
- {
- ObjectInfo info;
- info.type = o->type;
- info.proxy = _communicator->stringToProxy(_communicator->identityToString(o->id) + "@" + r->id);
- _objectCache.add(info, application);
- }
+ try
+ {
+ ReplicaGroupEntryPtr entry = ReplicaGroupEntryPtr::dynamicCast(_adapterCache.get(r->id));
+ assert(entry);
+ entry->update(r->loadBalancing);
+ }
+ catch(const AdapterNotExistException&)
+ {
+ _adapterCache.addReplicaGroup(*r, application);
+ }
+
+ for(ObjectDescriptorSeq::const_iterator o = r->objects.begin(); o != r->objects.end(); ++o)
+ {
+ ObjectInfo info;
+ info.type = o->type;
+ info.proxy = _communicator->stringToProxy(_communicator->identityToString(o->id) + "@" + r->id);
+ _objectCache.add(info, application);
+ }
}
//
@@ -1464,51 +1464,51 @@ Database::reload(const ApplicationHelper& oldApp,
//
for(vector<ServerInfo>::const_iterator q = load.begin(); q != load.end(); ++q)
{
- entries.push_back(_serverCache.add(*q));
+ entries.push_back(_serverCache.add(*q));
}
}
void
Database::finishApplicationUpdate(ServerEntrySeq& entries,
- const ApplicationUpdateInfo& update,
- const ApplicationInfo& oldApp,
- const ApplicationDescriptor& newDesc,
- AdminSessionI* session)
+ const ApplicationUpdateInfo& update,
+ const ApplicationInfo& oldApp,
+ const ApplicationDescriptor& newDesc,
+ AdminSessionI* session)
{
if(_master)
{
- //
- // Load the servers on the nodes. If a server couldn't be
- // deployed we unload the application and throw.
- //
- try
- {
- for_each(entries.begin(), entries.end(), IceUtil::voidMemFun(&ServerEntry::syncAndWait));
- }
- catch(const DeploymentException& ex)
- {
- ApplicationUpdateInfo newUpdate;
- {
- Lock sync(*this);
- entries.clear();
- ApplicationHelper previous(_communicator, newDesc);
- ApplicationHelper helper(_communicator, oldApp.descriptor);
- reload(previous, helper, entries, oldApp.uuid, oldApp.revision);
- }
-
- try
- {
- for_each(entries.begin(), entries.end(), IceUtil::voidMemFun(&ServerEntry::syncAndWait));
- }
- catch(const DeploymentException& ex)
- {
- Ice::Error err(_traceLevels->logger);
- err << "failed to rollback previous application `" << oldApp.descriptor.name << "':\n" << ex.reason;
- }
-
- finishUpdating(newDesc.name);
- throw ex;
- }
+ //
+ // Load the servers on the nodes. If a server couldn't be
+ // deployed we unload the application and throw.
+ //
+ try
+ {
+ for_each(entries.begin(), entries.end(), IceUtil::voidMemFun(&ServerEntry::syncAndWait));
+ }
+ catch(const DeploymentException& ex)
+ {
+ ApplicationUpdateInfo newUpdate;
+ {
+ Lock sync(*this);
+ entries.clear();
+ ApplicationHelper previous(_communicator, newDesc);
+ ApplicationHelper helper(_communicator, oldApp.descriptor);
+ reload(previous, helper, entries, oldApp.uuid, oldApp.revision);
+ }
+
+ try
+ {
+ for_each(entries.begin(), entries.end(), IceUtil::voidMemFun(&ServerEntry::syncAndWait));
+ }
+ catch(const DeploymentException& ex)
+ {
+ Ice::Error err(_traceLevels->logger);
+ err << "failed to rollback previous application `" << oldApp.descriptor.name << "':\n" << ex.reason;
+ }
+
+ finishUpdating(newDesc.name);
+ throw ex;
+ }
}
//
@@ -1516,24 +1516,24 @@ Database::finishApplicationUpdate(ServerEntrySeq& entries,
//
int serial;
{
- Lock sync(*this);
-
- ApplicationInfo info = oldApp;
- info.updateTime = update.updateTime;
- info.updateUser = update.updateUser;
- info.revision = update.revision;
- info.descriptor = newDesc;
-
- _applications.put(StringApplicationInfoDict::value_type(update.descriptor.name, info));
- ++_applicationSerial;
+ Lock sync(*this);
+
+ ApplicationInfo info = oldApp;
+ info.updateTime = update.updateTime;
+ info.updateUser = update.updateUser;
+ info.revision = update.revision;
+ info.descriptor = newDesc;
+
+ _applications.put(StringApplicationInfoDict::value_type(update.descriptor.name, info));
+ ++_applicationSerial;
- if(_traceLevels->application > 0)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->applicationCat);
- out << "updated application `" << update.descriptor.name << "'";
- }
-
- serial = _applicationObserverTopic->applicationUpdated(_applicationSerial, update);
+ if(_traceLevels->application > 0)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->applicationCat);
+ out << "updated application `" << update.descriptor.name << "'";
+ }
+
+ serial = _applicationObserverTopic->applicationUpdated(_applicationSerial, update);
}
_applicationObserverTopic->waitForSyncedSubscribers(serial);
@@ -1556,9 +1556,9 @@ Database::finishUpdating(const string& name)
map<string, vector<AMD_NodeSession_waitForApplicationUpdatePtr> >::iterator p = _updating.find(name);
assert(p != _updating.end());
for(vector<AMD_NodeSession_waitForApplicationUpdatePtr>::const_iterator q = p->second.begin();
- q != p->second.end(); ++q)
+ q != p->second.end(); ++q)
{
- (*q)->ice_response();
+ (*q)->ice_response();
}
_updating.erase(p);
diff --git a/cpp/src/IceGrid/Database.h b/cpp/src/IceGrid/Database.h
index 339d52722e8..a02bbe02eb2 100644
--- a/cpp/src/IceGrid/Database.h
+++ b/cpp/src/IceGrid/Database.h
@@ -51,7 +51,7 @@ class Database : public IceUtil::Shared, public IceUtil::Monitor<IceUtil::Mutex>
public:
Database(const Ice::ObjectAdapterPtr&, const IceStorm::TopicManagerPrx&, const std::string&, const TraceLevelsPtr&,
- const RegistryInfo&);
+ const RegistryInfo&);
virtual ~Database();
std::string getInstanceName() const;
@@ -133,7 +133,7 @@ private:
void unload(const ApplicationHelper&, ServerEntrySeq&);
void reload(const ApplicationHelper&, const ApplicationHelper&, ServerEntrySeq&, const std::string&, int);
void finishApplicationUpdate(ServerEntrySeq&, const ApplicationUpdateInfo&, const ApplicationInfo&,
- const ApplicationDescriptor&, AdminSessionI*);
+ const ApplicationDescriptor&, AdminSessionI*);
void checkSessionLock(AdminSessionI*);
diff --git a/cpp/src/IceGrid/DescriptorBuilder.cpp b/cpp/src/IceGrid/DescriptorBuilder.cpp
index a5405ad18c9..eeb0c11c723 100644
--- a/cpp/src/IceGrid/DescriptorBuilder.cpp
+++ b/cpp/src/IceGrid/DescriptorBuilder.cpp
@@ -16,9 +16,9 @@ using namespace std;
using namespace IceGrid;
XmlAttributesHelper::XmlAttributesHelper(const IceXML::Attributes& attrs,
- const Ice::LoggerPtr& logger,
- const string& filename,
- int line) :
+ const Ice::LoggerPtr& logger,
+ const string& filename,
+ int line) :
_attributes(attrs),
_logger(logger),
_filename(filename),
@@ -32,17 +32,17 @@ XmlAttributesHelper::checkUnknownAttributes()
vector<string> notUsed;
for(map<string, string>::const_iterator p = _attributes.begin(); p != _attributes.end(); ++p)
{
- if(_used.find(p->first) == _used.end())
- {
- notUsed.push_back(p->first);
- }
+ if(_used.find(p->first) == _used.end())
+ {
+ notUsed.push_back(p->first);
+ }
}
if(!notUsed.empty())
{
- ostringstream os;
- os << "unknown attributes in <" << _filename << "> descriptor, line " << _line << ":\n" << toString(notUsed);
- throw os.str();
+ ostringstream os;
+ os << "unknown attributes in <" << _filename << "> descriptor, line " << _line << ":\n" << toString(notUsed);
+ throw os.str();
}
}
@@ -60,12 +60,12 @@ XmlAttributesHelper::operator()(const string& name) const
IceXML::Attributes::const_iterator p = _attributes.find(name);
if(p == _attributes.end())
{
- throw "missing attribute '" + name + "'";
+ throw "missing attribute '" + name + "'";
}
string v = p->second;
if(v.empty())
{
- throw "attribute '" + name + "' is empty";
+ throw "attribute '" + name + "' is empty";
}
return v;
}
@@ -77,11 +77,11 @@ XmlAttributesHelper::operator()(const string& name, const string& def) const
IceXML::Attributes::const_iterator p = _attributes.find(name);
if(p == _attributes.end())
{
- return def;
+ return def;
}
else
{
- return p->second;
+ return p->second;
}
}
@@ -90,7 +90,7 @@ XmlAttributesHelper::asMap() const
{
for(map<string, string>::const_iterator p = _attributes.begin(); p != _attributes.end(); ++p)
{
- _used.insert(p->first);
+ _used.insert(p->first);
}
return _attributes;
}
@@ -102,21 +102,21 @@ XmlAttributesHelper::asBool(const string& name) const
IceXML::Attributes::const_iterator p = _attributes.find(name);
if(p == _attributes.end())
{
- throw "missing attribute '" + name + "'";
- return true; // Keep the compiler happy.
+ throw "missing attribute '" + name + "'";
+ return true; // Keep the compiler happy.
}
else if(p->second == "true")
{
- return true;
+ return true;
}
else if(p->second == "false")
{
- return false;
+ return false;
}
else
{
- throw "invalid attribute `" + name + "': value is not 'false' or 'true'";
- return true; // Keep the compiler happy.
+ throw "invalid attribute `" + name + "': value is not 'false' or 'true'";
+ return true; // Keep the compiler happy.
}
}
@@ -127,20 +127,20 @@ XmlAttributesHelper::asBool(const string& name, bool def) const
IceXML::Attributes::const_iterator p = _attributes.find(name);
if(p == _attributes.end())
{
- return def;
+ return def;
}
else if(p->second == "true")
{
- return true;
+ return true;
}
else if(p->second == "false")
{
- return false;
+ return false;
}
else
{
- throw "invalid attribute `" + name + "': value is not 'false' or 'true'";
- return true; // Keep the compiler happy.
+ throw "invalid attribute `" + name + "': value is not 'false' or 'true'";
+ return true; // Keep the compiler happy.
}
}
@@ -206,11 +206,11 @@ PropertySetDescriptorBuilder::addPropertySet(const XmlAttributesHelper& attrs)
{
if(attrs.contains("id") || !attrs.contains("refid"))
{
- throw "only <properties refid=\"\"> can be a child of a <properties> element";
+ throw "only <properties refid=\"\"> can be a child of a <properties> element";
}
if(!_descriptor.properties.empty())
{
- throw "<properties refid=\"\"> can't be defined after a <property> element";
+ throw "<properties refid=\"\"> can't be defined after a <property> element";
}
_descriptor.references.push_back(attrs("refid"));
_inPropertySetRef = true;
@@ -221,15 +221,15 @@ PropertySetDescriptorBuilder::finish()
{
if(_inPropertySetRef)
{
- _inPropertySetRef = false;
- return false;
+ _inPropertySetRef = false;
+ return false;
}
return true;
}
ApplicationDescriptorBuilder::ApplicationDescriptorBuilder(const Ice::CommunicatorPtr& communicator,
- const XmlAttributesHelper& attrs,
- const map<string, string>& overrides) :
+ const XmlAttributesHelper& attrs,
+ const map<string, string>& overrides) :
_communicator(communicator),
_overrides(overrides)
{
@@ -238,9 +238,9 @@ ApplicationDescriptorBuilder::ApplicationDescriptorBuilder(const Ice::Communicat
}
ApplicationDescriptorBuilder::ApplicationDescriptorBuilder(const Ice::CommunicatorPtr& communicator,
- const ApplicationDescriptor& app,
- const XmlAttributesHelper& attrs,
- const map<string, string>& overrides) :
+ const ApplicationDescriptor& app,
+ const XmlAttributesHelper& attrs,
+ const map<string, string>& overrides) :
_communicator(communicator),
_descriptor(app),
_overrides(overrides)
@@ -274,8 +274,8 @@ ApplicationDescriptorBuilder::finishReplicaGroup()
{
if(!_descriptor.replicaGroups.back().loadBalancing)
{
- _descriptor.replicaGroups.back().loadBalancing = new RandomLoadBalancingPolicy();
- _descriptor.replicaGroups.back().loadBalancing->nReplicas = "0";
+ _descriptor.replicaGroups.back().loadBalancing = new RandomLoadBalancingPolicy();
+ _descriptor.replicaGroups.back().loadBalancing->nReplicas = "0";
}
}
@@ -286,25 +286,25 @@ ApplicationDescriptorBuilder::setLoadBalancing(const XmlAttributesHelper& attrs)
string type = attrs("type");
if(type == "random")
{
- policy = new RandomLoadBalancingPolicy();
+ policy = new RandomLoadBalancingPolicy();
}
else if(type == "ordered")
{
- policy = new OrderedLoadBalancingPolicy();
+ policy = new OrderedLoadBalancingPolicy();
}
else if(type == "round-robin")
{
- policy = new RoundRobinLoadBalancingPolicy();
+ policy = new RoundRobinLoadBalancingPolicy();
}
else if(type == "adaptive")
{
- AdaptiveLoadBalancingPolicyPtr alb = new AdaptiveLoadBalancingPolicy();
- alb->loadSample = attrs("load-sample", "1");
- policy = alb;
+ AdaptiveLoadBalancingPolicyPtr alb = new AdaptiveLoadBalancingPolicy();
+ alb->loadSample = attrs("load-sample", "1");
+ policy = alb;
}
else
{
- throw "invalid load balancing policy `" + type + "'";
+ throw "invalid load balancing policy `" + type + "'";
}
policy->nReplicas = attrs("n-replicas", "1");
_descriptor.replicaGroups.back().loadBalancing = policy;
@@ -324,7 +324,7 @@ ApplicationDescriptorBuilder::addObject(const XmlAttributesHelper& attrs)
object.id = _communicator->stringToIdentity(attrs("identity"));
if(attrs.contains("property"))
{
- throw "property attribute is not allowed in object descriptors from a replica group";
+ throw "property attribute is not allowed in object descriptors from a replica group";
}
_descriptor.replicaGroups.back().objects.push_back(object);
}
@@ -334,11 +334,11 @@ ApplicationDescriptorBuilder::addVariable(const XmlAttributesHelper& attrs)
{
if(!isOverride(attrs("name")))
{
- _descriptor.variables[attrs("name")] = attrs("value", "");
+ _descriptor.variables[attrs("name")] = attrs("value", "");
}
else
{
- attrs.contains("value"); // NOTE: prevents warning about "value" not being used.
+ attrs.contains("value"); // NOTE: prevents warning about "value" not being used.
}
}
@@ -381,11 +381,11 @@ ApplicationDescriptorBuilder::addServerTemplate(const string& id, const Template
{
if(!templ.descriptor)
{
- throw "invalid server template `" + id + "': server definition is missing";
+ throw "invalid server template `" + id + "': server definition is missing";
}
if(!_descriptor.serverTemplates.insert(make_pair(id, templ)).second)
{
- throw "duplicate server template `" + id + "'";
+ throw "duplicate server template `" + id + "'";
}
}
@@ -394,11 +394,11 @@ ApplicationDescriptorBuilder::addServiceTemplate(const string& id, const Templat
{
if(!templ.descriptor)
{
- throw "invalid service template `" + id + "': service definition is missing";
+ throw "invalid service template `" + id + "': service definition is missing";
}
if(!_descriptor.serviceTemplates.insert(make_pair(id, templ)).second)
{
- throw "duplicate service template `" + id + "'";
+ throw "duplicate service template `" + id + "'";
}
}
@@ -407,7 +407,7 @@ ApplicationDescriptorBuilder::addPropertySet(const string& id, const PropertySet
{
if(!_descriptor.propertySets.insert(make_pair(id, desc)).second)
{
- throw "duplicate property set `" + id + "'";
+ throw "duplicate property set `" + id + "'";
}
}
@@ -442,7 +442,7 @@ ServerInstanceDescriptorBuilder::createPropertySet(const XmlAttributesHelper& at
string service;
if(attrs.contains("service"))
{
- service = attrs("service"); // Can't be empty.
+ service = attrs("service"); // Can't be empty.
}
PropertySetDescriptorBuilder* builder = new PropertySetDescriptorBuilder();
@@ -462,8 +462,8 @@ ServerInstanceDescriptorBuilder::addPropertySet(const string& service, const Pro
}
NodeDescriptorBuilder::NodeDescriptorBuilder(ApplicationDescriptorBuilder& app,
- const NodeDescriptor& desc,
- const XmlAttributesHelper& attrs) :
+ const NodeDescriptor& desc,
+ const XmlAttributesHelper& attrs) :
_application(app),
_descriptor(desc)
{
@@ -504,11 +504,11 @@ NodeDescriptorBuilder::addVariable(const XmlAttributesHelper& attrs)
{
if(!_application.isOverride(attrs("name")))
{
- _descriptor.variables[attrs("name")] = attrs("value", "");
+ _descriptor.variables[attrs("name")] = attrs("value", "");
}
else
{
- attrs.contains("value"); // NOTE: prevents warning about "value" not being used.
+ attrs.contains("value"); // NOTE: prevents warning about "value" not being used.
}
}
@@ -529,7 +529,7 @@ NodeDescriptorBuilder::addPropertySet(const string& id, const PropertySetDescrip
{
if(!_descriptor.propertySets.insert(make_pair(id, desc)).second)
{
- throw "duplicate property set `" + id + "'";
+ throw "duplicate property set `" + id + "'";
}
}
@@ -540,8 +540,8 @@ NodeDescriptorBuilder::setDescription(const string& description)
}
TemplateDescriptorBuilder::TemplateDescriptorBuilder(ApplicationDescriptorBuilder& application,
- const XmlAttributesHelper& attrs,
- bool serviceTemplate) :
+ const XmlAttributesHelper& attrs,
+ bool serviceTemplate) :
_application(application),
_serviceTemplate(serviceTemplate),
_id(attrs("id"))
@@ -554,13 +554,13 @@ TemplateDescriptorBuilder::addParameter(const XmlAttributesHelper& attrs)
if(find(_descriptor.parameters.begin(), _descriptor.parameters.end(), attrs("name")) !=
_descriptor.parameters.end())
{
- throw "duplicate parameter `" + attrs("name") + "'";
+ throw "duplicate parameter `" + attrs("name") + "'";
}
_descriptor.parameters.push_back(attrs("name"));
if(attrs.contains("default"))
{
- _descriptor.parameterDefaults.insert(make_pair(attrs("name"), attrs("default", "")));
+ _descriptor.parameterDefaults.insert(make_pair(attrs("name"), attrs("default", "")));
}
}
@@ -575,7 +575,7 @@ TemplateDescriptorBuilder::createServer(const XmlAttributesHelper& attrs)
{
if(_serviceTemplate)
{
- throw "<server> element can't be a child of <service-template>";
+ throw "<server> element can't be a child of <service-template>";
}
return new ServerDescriptorBuilder(_application.getCommunicator(), attrs);
}
@@ -585,7 +585,7 @@ TemplateDescriptorBuilder::createIceBox(const XmlAttributesHelper& attrs)
{
if(_serviceTemplate)
{
- throw "<icebox> element can't be a child of <service-template>";
+ throw "<icebox> element can't be a child of <service-template>";
}
return new IceBoxDescriptorBuilder(_application.getCommunicator(), attrs);
}
@@ -595,7 +595,7 @@ TemplateDescriptorBuilder::createService(const XmlAttributesHelper& attrs)
{
if(!_serviceTemplate)
{
- throw "<service> element can't be a child of <server-template>";
+ throw "<service> element can't be a child of <server-template>";
}
return new ServiceDescriptorBuilder(_application.getCommunicator(), attrs);
}
@@ -621,7 +621,7 @@ CommunicatorDescriptorBuilder::finish()
// before references to property sets.
//
_descriptor->propertySet.properties.insert(_descriptor->propertySet.properties.begin(),
- _hiddenProperties.begin(), _hiddenProperties.end());
+ _hiddenProperties.begin(), _hiddenProperties.end());
}
void
@@ -660,23 +660,23 @@ CommunicatorDescriptorBuilder::addAdapter(const XmlAttributesHelper& attrs)
desc.name = attrs("name");
if(attrs.contains("id"))
{
- desc.id = attrs("id");
+ desc.id = attrs("id");
}
else
{
- string fqn = "${server}";
- if(ServiceDescriptorPtr::dynamicCast(_descriptor))
- {
- fqn += ".${service}";
- }
- desc.id = fqn + "." + desc.name;
+ string fqn = "${server}";
+ if(ServiceDescriptorPtr::dynamicCast(_descriptor))
+ {
+ fqn += ".${service}";
+ }
+ desc.id = fqn + "." + desc.name;
}
desc.replicaGroupId = attrs("replica-group", "");
desc.priority = attrs("priority", "");
desc.registerProcess = attrs.asBool("register-process", false);
if(desc.id == "")
{
- throw "empty `id' for adapter `" + desc.name + "'";
+ throw "empty `id' for adapter `" + desc.name + "'";
}
desc.serverLifetime = attrs.asBool("server-lifetime", true);
_descriptor->adapters.push_back(desc);
@@ -698,7 +698,7 @@ CommunicatorDescriptorBuilder::addObject(const XmlAttributesHelper& attrs)
object.id = _communicator->stringToIdentity(attrs("identity"));
if(attrs.contains("property"))
{
- addProperty(_hiddenProperties, attrs("property"), attrs("identity"));
+ addProperty(_hiddenProperties, attrs("property"), attrs("identity"));
}
_descriptor->adapters.back().objects.push_back(object);
}
@@ -711,7 +711,7 @@ CommunicatorDescriptorBuilder::addAllocatable(const XmlAttributesHelper& attrs)
object.id = _communicator->stringToIdentity(attrs("identity"));
if(attrs.contains("property"))
{
- addProperty(_hiddenProperties, attrs("property"), attrs("identity"));
+ addProperty(_hiddenProperties, attrs("property"), attrs("identity"));
}
_descriptor->adapters.back().allocatables.push_back(object);
}
@@ -726,28 +726,28 @@ CommunicatorDescriptorBuilder::addDbEnv(const XmlAttributesHelper& attrs)
DbEnvDescriptorSeq::iterator p;
for(p = _descriptor->dbEnvs.begin(); p != _descriptor->dbEnvs.end(); ++p)
{
- //
- // We are re-opening the dbenv element to define more properties.
- //
- if(p->name == desc.name)
- {
- break;
- }
+ //
+ // We are re-opening the dbenv element to define more properties.
+ //
+ if(p->name == desc.name)
+ {
+ break;
+ }
}
if(p != _descriptor->dbEnvs.end())
{
- //
- // Remove the previously defined dbenv, we'll add it back again when
- // the dbenv element end tag is reached.
- //
- desc = *p;
- _descriptor->dbEnvs.erase(p);
- }
+ //
+ // Remove the previously defined dbenv, we'll add it back again when
+ // the dbenv element end tag is reached.
+ //
+ desc = *p;
+ _descriptor->dbEnvs.erase(p);
+ }
if(desc.dbHome.empty())
{
- desc.dbHome = attrs("home", "");
+ desc.dbHome = attrs("home", "");
}
_descriptor->dbEnvs.push_back(desc);
@@ -758,9 +758,9 @@ CommunicatorDescriptorBuilder::addDbEnvProperty(const XmlAttributesHelper& attrs
{
if(!_descriptor->dbEnvs.back().dbHome.empty())
{
- throw "can't add property to the database environment:\n"
- "properties are only allowed if the database\n"
- "environment home directory is managed by the node";
+ throw "can't add property to the database environment:\n"
+ "properties are only allowed if the database\n"
+ "environment home directory is managed by the node";
}
PropertyDescriptor prop;
@@ -780,7 +780,7 @@ CommunicatorDescriptorBuilder::addLog(const XmlAttributesHelper& attrs)
{
if(attrs.contains("property"))
{
- addProperty(_hiddenProperties, attrs("property"), attrs("path"));
+ addProperty(_hiddenProperties, attrs("property"), attrs("path"));
}
_descriptor->logs.push_back(attrs("path"));
}
@@ -819,7 +819,7 @@ ServiceInstanceDescriptorBuilder::addPropertySet(const PropertySetDescriptor& de
}
ServerDescriptorBuilder::ServerDescriptorBuilder(const Ice::CommunicatorPtr& communicator,
- const XmlAttributesHelper& attrs) :
+ const XmlAttributesHelper& attrs) :
CommunicatorDescriptorBuilder(communicator)
{
init(new ServerDescriptor(), attrs);
@@ -898,7 +898,7 @@ ServerDescriptorBuilder::addDistributionDirectory(const string& directory)
}
IceBoxDescriptorBuilder::IceBoxDescriptorBuilder(const Ice::CommunicatorPtr& communicator,
- const XmlAttributesHelper& attrs) :
+ const XmlAttributesHelper& attrs) :
ServerDescriptorBuilder(communicator)
{
init(new IceBoxDescriptor(), attrs);
@@ -916,18 +916,18 @@ IceBoxDescriptorBuilder::finish()
{
if(getProperty(_descriptor->propertySet.properties, "IceBox.InstanceName").empty())
{
- _hiddenProperties.push_back(createProperty("IceBox.InstanceName", "${server}"));
+ _hiddenProperties.push_back(createProperty("IceBox.InstanceName", "${server}"));
}
if(_descriptor->adapters.empty())
{
- if(getProperty(_descriptor->propertySet.properties, "Ice.OA.IceBox.ServiceManager.Endpoints").empty())
- {
- _hiddenProperties.push_back(createProperty("Ice.OA.IceBox.ServiceManager.Endpoints", "tcp -h 127.0.0.1"));
- }
- if(getProperty(_descriptor->propertySet.properties, "Ice.OA.IceBox.ServiceManager.RegisterProcess").empty())
- {
- _hiddenProperties.push_back(createProperty("Ice.OA.IceBox.ServiceManager.RegisterProcess", "1"));
- }
+ if(getProperty(_descriptor->propertySet.properties, "Ice.OA.IceBox.ServiceManager.Endpoints").empty())
+ {
+ _hiddenProperties.push_back(createProperty("Ice.OA.IceBox.ServiceManager.Endpoints", "tcp -h 127.0.0.1"));
+ }
+ if(getProperty(_descriptor->propertySet.properties, "Ice.OA.IceBox.ServiceManager.RegisterProcess").empty())
+ {
+ _hiddenProperties.push_back(createProperty("Ice.OA.IceBox.ServiceManager.RegisterProcess", "1"));
+ }
}
ServerDescriptorBuilder::finish();
@@ -950,7 +950,7 @@ IceBoxDescriptorBuilder::addAdapter(const XmlAttributesHelper& attrs)
{
if(attrs("name") != "IceBox.ServiceManager")
{
- throw "<adapter> element can't be a child of an <icebox> element";
+ throw "<adapter> element can't be a child of an <icebox> element";
}
ServerDescriptorBuilder::addAdapter(attrs);
@@ -978,7 +978,7 @@ IceBoxDescriptorBuilder::addService(const ServiceDescriptorPtr& desc)
}
ServiceDescriptorBuilder::ServiceDescriptorBuilder(const Ice::CommunicatorPtr& communicator,
- const XmlAttributesHelper& attrs) :
+ const XmlAttributesHelper& attrs) :
CommunicatorDescriptorBuilder(communicator)
{
init(new ServiceDescriptor(), attrs);
diff --git a/cpp/src/IceGrid/DescriptorBuilder.h b/cpp/src/IceGrid/DescriptorBuilder.h
index 04f0ca60d4e..532df9e61df 100644
--- a/cpp/src/IceGrid/DescriptorBuilder.h
+++ b/cpp/src/IceGrid/DescriptorBuilder.h
@@ -89,9 +89,9 @@ class ApplicationDescriptorBuilder : public DescriptorBuilder
public:
ApplicationDescriptorBuilder(const Ice::CommunicatorPtr&, const XmlAttributesHelper&,
- const std::map<std::string, std::string>&);
+ const std::map<std::string, std::string>&);
ApplicationDescriptorBuilder(const Ice::CommunicatorPtr&, const ApplicationDescriptor&, const XmlAttributesHelper&,
- const std::map<std::string, std::string>&);
+ const std::map<std::string, std::string>&);
const ApplicationDescriptor& getDescriptor() const;
diff --git a/cpp/src/IceGrid/DescriptorHelper.cpp b/cpp/src/IceGrid/DescriptorHelper.cpp
index 1e540b5938f..f1cf78d4367 100644
--- a/cpp/src/IceGrid/DescriptorHelper.cpp
+++ b/cpp/src/IceGrid/DescriptorHelper.cpp
@@ -25,7 +25,7 @@ struct GetReplicaGroupId : unary_function<ReplicaGroupDescriptor&, const string&
const string&
operator()(const ReplicaGroupDescriptor& desc)
{
- return desc.id;
+ return desc.id;
}
};
@@ -34,42 +34,42 @@ struct TemplateDescriptorEqual : std::binary_function<TemplateDescriptor&, Templ
bool
operator()(const TemplateDescriptor& lhs, const TemplateDescriptor& rhs)
{
- if(lhs.parameters != rhs.parameters)
- {
- return false;
- }
-
- if(lhs.parameterDefaults != rhs.parameterDefaults)
- {
- return false;
- }
-
- {
- IceBoxDescriptorPtr slhs = IceBoxDescriptorPtr::dynamicCast(lhs.descriptor);
- IceBoxDescriptorPtr srhs = IceBoxDescriptorPtr::dynamicCast(rhs.descriptor);
- if(slhs && srhs)
- {
- return IceBoxHelper(slhs) == IceBoxHelper(srhs);
- }
- }
- {
- ServerDescriptorPtr slhs = ServerDescriptorPtr::dynamicCast(lhs.descriptor);
- ServerDescriptorPtr srhs = ServerDescriptorPtr::dynamicCast(rhs.descriptor);
- if(slhs && srhs)
- {
- return ServerHelper(slhs) == ServerHelper(srhs);
- }
- }
- {
- ServiceDescriptorPtr slhs = ServiceDescriptorPtr::dynamicCast(lhs.descriptor);
- ServiceDescriptorPtr srhs = ServiceDescriptorPtr::dynamicCast(rhs.descriptor);
- if(slhs && srhs)
- {
- return ServiceHelper(slhs) == ServiceHelper(srhs);
- }
- }
-
- return false;
+ if(lhs.parameters != rhs.parameters)
+ {
+ return false;
+ }
+
+ if(lhs.parameterDefaults != rhs.parameterDefaults)
+ {
+ return false;
+ }
+
+ {
+ IceBoxDescriptorPtr slhs = IceBoxDescriptorPtr::dynamicCast(lhs.descriptor);
+ IceBoxDescriptorPtr srhs = IceBoxDescriptorPtr::dynamicCast(rhs.descriptor);
+ if(slhs && srhs)
+ {
+ return IceBoxHelper(slhs) == IceBoxHelper(srhs);
+ }
+ }
+ {
+ ServerDescriptorPtr slhs = ServerDescriptorPtr::dynamicCast(lhs.descriptor);
+ ServerDescriptorPtr srhs = ServerDescriptorPtr::dynamicCast(rhs.descriptor);
+ if(slhs && srhs)
+ {
+ return ServerHelper(slhs) == ServerHelper(srhs);
+ }
+ }
+ {
+ ServiceDescriptorPtr slhs = ServiceDescriptorPtr::dynamicCast(lhs.descriptor);
+ ServiceDescriptorPtr srhs = ServiceDescriptorPtr::dynamicCast(rhs.descriptor);
+ if(slhs && srhs)
+ {
+ return ServiceHelper(slhs) == ServiceHelper(srhs);
+ }
+ }
+
+ return false;
}
};
@@ -78,38 +78,38 @@ struct ReplicaGroupEq : std::binary_function<ReplicaGroupDescriptor&, ReplicaGro
bool
operator()(const ReplicaGroupDescriptor& lhs, const ReplicaGroupDescriptor& rhs)
{
- if(lhs.id != rhs.id)
- {
- return false;
- }
- if(set<ObjectDescriptor>(lhs.objects.begin(), lhs.objects.end()) !=
- set<ObjectDescriptor>(rhs.objects.begin(), rhs.objects.end()))
- {
- return false;
- }
- if(lhs.loadBalancing && rhs.loadBalancing)
- {
- if(lhs.loadBalancing->ice_id() != rhs.loadBalancing->ice_id())
- {
- return false;
- }
- if(lhs.loadBalancing->nReplicas != rhs.loadBalancing->nReplicas)
- {
- return false;
- }
- AdaptiveLoadBalancingPolicyPtr alhs = AdaptiveLoadBalancingPolicyPtr::dynamicCast(lhs.loadBalancing);
- AdaptiveLoadBalancingPolicyPtr arhs = AdaptiveLoadBalancingPolicyPtr::dynamicCast(rhs.loadBalancing);
- if(alhs && arhs && alhs->loadSample != arhs->loadSample)
- {
- return false;
- }
- }
- else if(lhs.loadBalancing || rhs.loadBalancing)
- {
- return false;
- }
-
- return true;
+ if(lhs.id != rhs.id)
+ {
+ return false;
+ }
+ if(set<ObjectDescriptor>(lhs.objects.begin(), lhs.objects.end()) !=
+ set<ObjectDescriptor>(rhs.objects.begin(), rhs.objects.end()))
+ {
+ return false;
+ }
+ if(lhs.loadBalancing && rhs.loadBalancing)
+ {
+ if(lhs.loadBalancing->ice_id() != rhs.loadBalancing->ice_id())
+ {
+ return false;
+ }
+ if(lhs.loadBalancing->nReplicas != rhs.loadBalancing->nReplicas)
+ {
+ return false;
+ }
+ AdaptiveLoadBalancingPolicyPtr alhs = AdaptiveLoadBalancingPolicyPtr::dynamicCast(lhs.loadBalancing);
+ AdaptiveLoadBalancingPolicyPtr arhs = AdaptiveLoadBalancingPolicyPtr::dynamicCast(rhs.loadBalancing);
+ if(alhs && arhs && alhs->loadSample != arhs->loadSample)
+ {
+ return false;
+ }
+ }
+ else if(lhs.loadBalancing || rhs.loadBalancing)
+ {
+ return false;
+ }
+
+ return true;
}
};
@@ -133,18 +133,18 @@ getSeqUpdatedEltsWithEq(const Seq& lseq, const Seq& rseq, GetKeyFunc func, EqFun
Seq result;
for(typename Seq::const_iterator p = rseq.begin(); p != rseq.end(); ++p)
{
- typename Seq::const_iterator q = lseq.begin();
- for(; q != lseq.end(); ++q)
- {
- if(func(*p) == func(*q))
- {
- break;
- }
- }
- if(q == lseq.end() || !eq(*p, *q))
- {
- result.push_back(*p);
- }
+ typename Seq::const_iterator q = lseq.begin();
+ for(; q != lseq.end(); ++q)
+ {
+ if(func(*p) == func(*q))
+ {
+ break;
+ }
+ }
+ if(q == lseq.end() || !eq(*p, *q))
+ {
+ result.push_back(*p);
+ }
}
return result;
}
@@ -155,18 +155,18 @@ getSeqRemovedElts(const Seq& lseq, const Seq& rseq, GetKeyFunc func)
Ice::StringSeq removed;
for(typename Seq::const_iterator p = lseq.begin(); p != lseq.end(); ++p)
{
- typename Seq::const_iterator q;
- for(q = rseq.begin(); q != rseq.end(); ++q)
- {
- if(func(*p) == func(*q))
- {
- break;
- }
- }
- if(q == rseq.end())
- {
- removed.push_back(func(*p));
- }
+ typename Seq::const_iterator q;
+ for(q = rseq.begin(); q != rseq.end(); ++q)
+ {
+ if(func(*p) == func(*q))
+ {
+ break;
+ }
+ }
+ if(q == rseq.end())
+ {
+ removed.push_back(func(*p));
+ }
}
return removed;
}
@@ -178,21 +178,21 @@ updateSeqElts(const Seq& seq, const Seq& update, const Ice::StringSeq& remove, G
set<string> removed(remove.begin(), remove.end());
for(typename Seq::const_iterator p = seq.begin(); p != seq.end(); ++p)
{
- if(removed.find(func(*p)) == removed.end())
- {
- typename Seq::const_iterator q = update.begin();
- for(; q != update.end(); ++q)
- {
- if(func(*p) == func(*q))
- {
- break;
- }
- }
- if(q == update.end())
- {
- result.push_back(*p);
- }
- }
+ if(removed.find(func(*p)) == removed.end())
+ {
+ typename Seq::const_iterator q = update.begin();
+ for(; q != update.end(); ++q)
+ {
+ if(func(*p) == func(*q))
+ {
+ break;
+ }
+ }
+ if(q == update.end())
+ {
+ result.push_back(*p);
+ }
+ }
}
return result;
}
@@ -213,11 +213,11 @@ getDictUpdatedEltsWithEq(const Dict& ldict, const Dict& rdict, EqFunc eq)
Dict result;
for(typename Dict::const_iterator p = rdict.begin(); p != rdict.end(); ++p)
{
- typename Dict::const_iterator q = ldict.find(p->first);
- if(q == ldict.end() || !eq(p->second, q->second))
- {
- result.insert(*p);
- }
+ typename Dict::const_iterator q = ldict.find(p->first);
+ if(q == ldict.end() || !eq(p->second, q->second))
+ {
+ result.insert(*p);
+ }
}
return result;
}
@@ -228,10 +228,10 @@ getDictRemovedElts(const Dict& ldict, const Dict& rdict)
Ice::StringSeq removed;
for(typename Dict::const_iterator p = ldict.begin(); p != ldict.end(); ++p)
{
- if(rdict.find(p->first) == rdict.end())
- {
- removed.push_back(p->first);
- }
+ if(rdict.find(p->first) == rdict.end())
+ {
+ removed.push_back(p->first);
+ }
}
return removed;
}
@@ -242,11 +242,11 @@ updateDictElts(const Dict& dict, const Dict& update, const Ice::StringSeq& remov
Dict result = dict;
for(Ice::StringSeq::const_iterator p = remove.begin(); p != remove.end(); ++p)
{
- result.erase(*p);
+ result.erase(*p);
}
for(typename Dict::const_iterator q = update.begin(); q != update.end(); ++q)
{
- result[q->first] = q->second;
+ result[q->first] = q->second;
}
return result;
}
@@ -281,63 +281,63 @@ Resolver::Resolver(const ApplicationDescriptor& app, const Ice::CommunicatorPtr&
for(StringStringDict::const_iterator v = _variables.begin(); v != _variables.end(); ++v)
{
- if(v->first == "")
- {
- exception("empty variable name");
- }
+ if(v->first == "")
+ {
+ exception("empty variable name");
+ }
}
TemplateDescriptorDict::const_iterator t;
for(t = _application->serverTemplates.begin(); t != _application->serverTemplates.end(); ++t)
{
- if(t->first == "")
- {
- exception("empty server template id");
- }
- if(!t->second.descriptor)
- {
- exception("invalid server template `" + t->first + "': server definition is empty");
- }
-
- Ice::StringSeq params = t->second.parameters;
- sort(params.begin(), params.end());
- Ice::StringSeq wdups = params;
- Ice::StringSeq dups;
- set_difference(wdups.begin(), wdups.end(), params.begin(), unique(params.begin(), params.end()),
- back_inserter(dups));
- if(!dups.empty())
- {
- dups.erase(unique(dups.begin(), dups.end()), dups.end());
- exception("invalid server template `" + t->first + "': duplicate parameters " + toString(dups));
- }
+ if(t->first == "")
+ {
+ exception("empty server template id");
+ }
+ if(!t->second.descriptor)
+ {
+ exception("invalid server template `" + t->first + "': server definition is empty");
+ }
+
+ Ice::StringSeq params = t->second.parameters;
+ sort(params.begin(), params.end());
+ Ice::StringSeq wdups = params;
+ Ice::StringSeq dups;
+ set_difference(wdups.begin(), wdups.end(), params.begin(), unique(params.begin(), params.end()),
+ back_inserter(dups));
+ if(!dups.empty())
+ {
+ dups.erase(unique(dups.begin(), dups.end()), dups.end());
+ exception("invalid server template `" + t->first + "': duplicate parameters " + toString(dups));
+ }
}
for(t = _application->serviceTemplates.begin(); t != _application->serviceTemplates.end(); ++t)
{
- if(t->first == "")
- {
- exception("empty service template id");
- }
- if(!t->second.descriptor)
- {
- exception("invalid service template `" + t->first + "': service definition is empty");
- }
- Ice::StringSeq params = t->second.parameters;
- sort(params.begin(), params.end());
- Ice::StringSeq wdups = params;
- Ice::StringSeq dups;
- set_difference(wdups.begin(), wdups.end(), params.begin(), unique(params.begin(), params.end()),
- back_inserter(dups));
- if(!dups.empty())
- {
- dups.erase(unique(dups.begin(), dups.end()), dups.end());
- exception("invalid server template `" + t->first + "': duplicate parameters " + toString(dups));
- }
+ if(t->first == "")
+ {
+ exception("empty service template id");
+ }
+ if(!t->second.descriptor)
+ {
+ exception("invalid service template `" + t->first + "': service definition is empty");
+ }
+ Ice::StringSeq params = t->second.parameters;
+ sort(params.begin(), params.end());
+ Ice::StringSeq wdups = params;
+ Ice::StringSeq dups;
+ set_difference(wdups.begin(), wdups.end(), params.begin(), unique(params.begin(), params.end()),
+ back_inserter(dups));
+ if(!dups.empty())
+ {
+ dups.erase(unique(dups.begin(), dups.end()), dups.end());
+ exception("invalid server template `" + t->first + "': duplicate parameters " + toString(dups));
+ }
}
}
Resolver::Resolver(const Resolver& resolve,
- const map<string, string>& values,
- bool params) :
+ const map<string, string>& values,
+ bool params) :
_application(resolve._application),
_communicator(resolve._communicator),
_escape(resolve._escape),
@@ -351,20 +351,20 @@ Resolver::Resolver(const Resolver& resolve,
{
if(params)
{
- checkReserved("parameter", values);
+ checkReserved("parameter", values);
}
else
{
- _variables.insert(resolve._variables.begin(), resolve._variables.end());
- checkReserved("variable", values);
+ _variables.insert(resolve._variables.begin(), resolve._variables.end());
+ checkReserved("variable", values);
}
for(StringStringDict::const_iterator v = _variables.begin(); v != _variables.end(); ++v)
{
- if(v->first == "")
- {
- exception("empty variable name");
- }
+ if(v->first == "")
+ {
+ exception("empty variable name");
+ }
}
}
@@ -390,40 +390,40 @@ Resolver::operator()(const string& value, const string& name, bool allowEmpty) c
{
try
{
- string val;
- try
- {
- val = substitute(value, true, true);
- }
- catch(const string& reason)
- {
- throw "invalid variable `" + value + "': " + reason;
- }
- catch(const char* reason)
- {
- throw "invalid variable `" + value + "': " + reason;
- }
-
- if(!allowEmpty)
- {
- if(value.empty())
- {
- throw "empty string";
- }
- else if(val.empty())
- {
- throw "the value of `" + value + "' is an empty string";
- }
- }
- return val;
+ string val;
+ try
+ {
+ val = substitute(value, true, true);
+ }
+ catch(const string& reason)
+ {
+ throw "invalid variable `" + value + "': " + reason;
+ }
+ catch(const char* reason)
+ {
+ throw "invalid variable `" + value + "': " + reason;
+ }
+
+ if(!allowEmpty)
+ {
+ if(value.empty())
+ {
+ throw "empty string";
+ }
+ else if(val.empty())
+ {
+ throw "the value of `" + value + "' is an empty string";
+ }
+ }
+ return val;
}
catch(const string& reason)
{
- exception("invalid value for attribute `" + name + "':\n" + reason);
+ exception("invalid value for attribute `" + name + "':\n" + reason);
}
catch(const char* reason)
{
- exception("invalid value for attribute `" + name + "':\n" + reason);
+ exception("invalid value for attribute `" + name + "':\n" + reason);
}
return ""; // To prevent compiler warning.
}
@@ -434,7 +434,7 @@ Resolver::operator()(const Ice::StringSeq& values, const string& name) const
Ice::StringSeq result;
for(Ice::StringSeq::const_iterator p = values.begin(); p != values.end(); ++p)
{
- result.push_back(operator()(*p, name));
+ result.push_back(operator()(*p, name));
}
return result;
}
@@ -454,10 +454,10 @@ Resolver::operator()(const PropertyDescriptorSeq& properties, const string& name
PropertyDescriptorSeq result;
for(PropertyDescriptorSeq::const_iterator q = properties.begin(); q != properties.end(); ++q)
{
- PropertyDescriptor prop;
- prop.name = operator()(q->name, name + " name");
- prop.value = operator()(q->value, name + " value");
- result.push_back(prop);
+ PropertyDescriptor prop;
+ prop.name = operator()(q->name, name + " name");
+ prop.value = operator()(q->value, name + " value");
+ result.push_back(prop);
}
return result;
}
@@ -469,10 +469,10 @@ Resolver::operator()(const PropertySetDescriptorDict& propertySets) const
PropertySetDescriptorDict::const_iterator ps;
for(ps = propertySets.begin(); ps != propertySets.end(); ++ps)
{
- PropertySetDescriptor desc;
- desc.references = operator()(ps->second.references, "property set `" + ps->first + "' reference");
- desc.properties = operator()(ps->second.properties, "property set `" + ps->first + "' property");
- result.insert(make_pair(ps->first, desc));
+ PropertySetDescriptor desc;
+ desc.references = operator()(ps->second.references, "property set `" + ps->first + "' reference");
+ desc.properties = operator()(ps->second.properties, "property set `" + ps->first + "' property");
+ result.insert(make_pair(ps->first, desc));
}
return result;
}
@@ -483,10 +483,10 @@ Resolver::operator()(const ObjectDescriptorSeq& objects, const string& type) con
ObjectDescriptorSeq result;
for(ObjectDescriptorSeq::const_iterator q = objects.begin(); q != objects.end(); ++q)
{
- ObjectDescriptor obj;
- obj.type = operator()(q->type, type + " object type");
- obj.id = operator()(q->id, type + " object identity");
- result.push_back(obj);
+ ObjectDescriptor obj;
+ obj.type = operator()(q->type, type + " object type");
+ obj.id = operator()(q->id, type + " object identity");
+ result.push_back(obj);
}
return result;
}
@@ -499,7 +499,7 @@ Resolver::operator()(const Ice::Identity& value, const string& name) const
Ice::Identity id = _communicator->stringToIdentity(str);
if(id.name.empty())
{
- exception("invalid object identity `" + _communicator->identityToString(value) + "': name empty");
+ exception("invalid object identity `" + _communicator->identityToString(value) + "': name empty");
}
return id;
}
@@ -520,20 +520,20 @@ Resolver::asInt(const string& value, const string& name) const
string v = operator()(value, name);
if(!v.empty())
{
- string::size_type beg = v.find_first_not_of(' ');
- string::size_type end = v.find_last_not_of(' ');
- v = v.substr(beg == string::npos ? 0 : beg, end == string::npos ? v.length() - 1 : end - beg + 1);
+ string::size_type beg = v.find_first_not_of(' ');
+ string::size_type end = v.find_last_not_of(' ');
+ v = v.substr(beg == string::npos ? 0 : beg, end == string::npos ? v.length() - 1 : end - beg + 1);
- int val;
- istringstream is(v);
- if(!(is >> val) || !is.eof())
- {
- exception("invalid value `" + value + "' for `" + name + "':\nnot an integer");
- }
+ int val;
+ istringstream is(v);
+ if(!(is >> val) || !is.eof())
+ {
+ exception("invalid value `" + value + "' for `" + name + "':\nnot an integer");
+ }
- ostringstream os;
- os << val;
- v = os.str();
+ ostringstream os;
+ os << val;
+ v = os.str();
}
return v;
}
@@ -544,16 +544,16 @@ Resolver::asFloat(const string& value, const string& name) const
string v = operator()(value, name);
if(!v.empty())
{
- string::size_type beg = v.find_first_not_of(' ');
- string::size_type end = v.find_last_not_of(' ');
- v = v.substr(beg == string::npos ? 0 : beg, end == string::npos ? v.length() - 1 : end - beg + 1);
+ string::size_type beg = v.find_first_not_of(' ');
+ string::size_type end = v.find_last_not_of(' ');
+ v = v.substr(beg == string::npos ? 0 : beg, end == string::npos ? v.length() - 1 : end - beg + 1);
- float val;
- istringstream is(v);
- if(!(is >> val) || !is.eof())
- {
- exception("invalid value `" + value + "' for `" + name + "':\nnot a float");
- }
+ float val;
+ istringstream is(v);
+ if(!(is >> val) || !is.eof())
+ {
+ exception("invalid value `" + value + "' for `" + name + "':\nnot a float");
+ }
}
return v;
}
@@ -563,38 +563,38 @@ Resolver::asId(const string& value, const string& name, bool allowEmpty) const
{
try
{
- if(!allowEmpty && value.empty())
- {
- throw "empty string";
- }
-
- string val;
- try
- {
- val = substitute(value, true, false);
- }
- catch(const string& reason)
- {
- throw "invalid variable `" + value + "':\n" + reason;
- }
- catch(const char* reason)
- {
- throw "invalid variable `" + value + "':\n" + reason;
- }
-
- if(!allowEmpty && val.empty())
- {
- throw "the value of `" + value + "' is an empty string";
- }
- return val;
+ if(!allowEmpty && value.empty())
+ {
+ throw "empty string";
+ }
+
+ string val;
+ try
+ {
+ val = substitute(value, true, false);
+ }
+ catch(const string& reason)
+ {
+ throw "invalid variable `" + value + "':\n" + reason;
+ }
+ catch(const char* reason)
+ {
+ throw "invalid variable `" + value + "':\n" + reason;
+ }
+
+ if(!allowEmpty && val.empty())
+ {
+ throw "the value of `" + value + "' is an empty string";
+ }
+ return val;
}
catch(const string& reason)
{
- exception("invalid value for attribute `" + name + "':\n" + reason);
+ exception("invalid value for attribute `" + name + "':\n" + reason);
}
catch(const char* reason)
{
- exception("invalid value for attribute `" + name + "':\n" + reason);
+ exception("invalid value for attribute `" + name + "':\n" + reason);
}
return ""; // To prevent compiler warning.
}
@@ -611,15 +611,15 @@ Resolver::setContext(const string& context)
{
try
{
- _context = substitute(context, true, true);
+ _context = substitute(context, true, true);
}
catch(const string& reason)
{
- exception(reason);
+ exception(reason);
}
catch(const char* reason)
{
- exception(reason);
+ exception(reason);
}
}
@@ -631,10 +631,10 @@ Resolver::addPropertySets(const PropertySetDescriptorDict& propertySets)
PropertySetDescriptorDict::const_iterator p;
for(p = propertySets.begin(); p != propertySets.end(); ++p)
{
- if(!_propertySets.insert(*p).second)
- {
- exception("property set with id `" + p->first + "' is already defined at this scope");
- }
+ if(!_propertySets.insert(*p).second)
+ {
+ exception("property set with id `" + p->first + "' is already defined at this scope");
+ }
}
_propertySets.insert(oldPropertySets.begin(), oldPropertySets.end());
@@ -643,7 +643,7 @@ Resolver::addPropertySets(const PropertySetDescriptorDict& propertySets)
//
for(p = propertySets.begin(); p != propertySets.end(); ++p)
{
- getProperties(p->second.references);
+ getProperties(p->second.references);
}
}
@@ -653,7 +653,7 @@ Resolver::getPropertySet(const string& id) const
PropertySetDescriptorDict::const_iterator p = _propertySets.find(id);
if(p == _propertySets.end())
{
- exception("invalid reference to property set, property set `" + id + "' doesn't exist");
+ exception("invalid reference to property set, property set `" + id + "' doesn't exist");
}
return p->second;
}
@@ -684,7 +684,7 @@ Resolver::getServerTemplate(const string& tmpl) const
TemplateDescriptorDict::const_iterator p = _application->serverTemplates.find(tmpl);
if(p == _application->serverTemplates.end())
{
- throw DeploymentException("unknown server template `" + tmpl + "'");
+ throw DeploymentException("unknown server template `" + tmpl + "'");
}
return p->second;
}
@@ -696,7 +696,7 @@ Resolver::getServiceTemplate(const string& tmpl) const
TemplateDescriptorDict::const_iterator p = _application->serviceTemplates.find(tmpl);
if(p == _application->serviceTemplates.end())
{
- throw DeploymentException("unknown service template `" + tmpl + "'");
+ throw DeploymentException("unknown service template `" + tmpl + "'");
}
return p->second;
}
@@ -706,22 +706,22 @@ Resolver::hasReplicaGroup(const string& id) const
{
if(!_application)
{
- //
- // If we don't know the application descrpitor we assume that
- // the replica group exists (this is possible if the resolver
- // wasn't built from an application helper, that's the case if
- // it's built from NodeCache just to resolve ${node.*} and
- // ${session.*} variables.
- //
- return true;
+ //
+ // If we don't know the application descrpitor we assume that
+ // the replica group exists (this is possible if the resolver
+ // wasn't built from an application helper, that's the case if
+ // it's built from NodeCache just to resolve ${node.*} and
+ // ${session.*} variables.
+ //
+ return true;
}
ReplicaGroupDescriptorSeq::const_iterator p;
for(p = _application->replicaGroups.begin(); p != _application->replicaGroups.end(); ++p)
{
- if(p->id == id)
- {
- return true;
- }
+ if(p->id == id)
+ {
+ return true;
+ }
}
return false;
}
@@ -735,66 +735,66 @@ Resolver::substitute(const string& v, bool useParams, bool useIgnored) const
while((beg = value.find("${", beg)) != string::npos)
{
- if(beg > 0 && value[beg - 1] == '$')
- {
- string::size_type escape = beg - 1;
- while(escape > 0 && value[escape - 1] == '$')
- {
- --escape;
- }
-
- if((beg - escape) % 2)
- {
- if(_escape)
- {
- value.replace(escape, beg - escape, (beg - escape) / 2, '$');
- }
- ++beg;
- continue;
- }
- else
- {
- value.replace(escape, beg - escape, (beg - escape) / 2, '$');
- beg -= (beg - escape) / 2;
- }
- }
-
- end = value.find("}", beg);
- if(end == string::npos)
- {
- throw "malformed variable name `" + value + "'";
- }
-
- //
- // Get the name of the variable and get its value if the
- // variable is not currently ignored (in which case we do
- // nothing, the variable will be substituted later). If the
- // name refered to a parameter we don't do any recursive
- // substitution: the parameter value is computed at the point
- // of definition.
- //
- string name = value.substr(beg + 2, end - beg - 2);
- if(_ignore.find(name) != _ignore.end())
- {
- if(useIgnored)
- {
- ++beg;
- continue;
- }
- else
- {
- throw "use of the `" + name + "' variable is now allowed here";
- }
- }
-
- bool param;
- string val = getVariable(name, useParams, param);
- if(!param)
- {
- val = substitute(val, false, useIgnored); // Recursive resolution
- }
- value.replace(beg, end - beg + 1, val);
- beg += val.length();
+ if(beg > 0 && value[beg - 1] == '$')
+ {
+ string::size_type escape = beg - 1;
+ while(escape > 0 && value[escape - 1] == '$')
+ {
+ --escape;
+ }
+
+ if((beg - escape) % 2)
+ {
+ if(_escape)
+ {
+ value.replace(escape, beg - escape, (beg - escape) / 2, '$');
+ }
+ ++beg;
+ continue;
+ }
+ else
+ {
+ value.replace(escape, beg - escape, (beg - escape) / 2, '$');
+ beg -= (beg - escape) / 2;
+ }
+ }
+
+ end = value.find("}", beg);
+ if(end == string::npos)
+ {
+ throw "malformed variable name `" + value + "'";
+ }
+
+ //
+ // Get the name of the variable and get its value if the
+ // variable is not currently ignored (in which case we do
+ // nothing, the variable will be substituted later). If the
+ // name refered to a parameter we don't do any recursive
+ // substitution: the parameter value is computed at the point
+ // of definition.
+ //
+ string name = value.substr(beg + 2, end - beg - 2);
+ if(_ignore.find(name) != _ignore.end())
+ {
+ if(useIgnored)
+ {
+ ++beg;
+ continue;
+ }
+ else
+ {
+ throw "use of the `" + name + "' variable is now allowed here";
+ }
+ }
+
+ bool param;
+ string val = getVariable(name, useParams, param);
+ if(!param)
+ {
+ val = substitute(val, false, useIgnored); // Recursive resolution
+ }
+ value.replace(beg, end - beg + 1, val);
+ beg += val.length();
}
return value;
}
@@ -810,25 +810,25 @@ Resolver::getVariable(const string& name, bool checkParams, bool& param) const
map<string, string>::const_iterator p = _reserved.find(name);
if(p != _reserved.end())
{
- if(p->second.empty())
- {
- throw "undefined variable `" + name + "'";
- }
- return p->second;
+ if(p->second.empty())
+ {
+ throw "undefined variable `" + name + "'";
+ }
+ return p->second;
}
if(checkParams)
{
- p = _parameters.find(name);
- if(p != _parameters.end())
- {
- param = true;
- return p->second;
- }
+ p = _parameters.find(name);
+ if(p != _parameters.end())
+ {
+ param = true;
+ return p->second;
+ }
}
p = _variables.find(name);
if(p != _variables.end())
{
- return p->second;
+ return p->second;
}
throw "undefined variable `" + name + "'";
@@ -841,21 +841,21 @@ Resolver::getProperties(const Ice::StringSeq& references, set<string>& resolved)
PropertyDescriptorSeq properties;
for(Ice::StringSeq::const_iterator p = references.begin(); p != references.end(); ++p)
{
- if(resolved.find(*p) != resolved.end())
- {
- exception("detected circular dependency with property reference `" + *p + "'");
- }
-
- PropertySetDescriptor desc = getPropertySet(*p);
- if(!desc.references.empty())
- {
- resolved.insert(*p);
- PropertyDescriptorSeq p = getProperties(desc.references, resolved);
- properties.insert(properties.end(), p.begin(), p.end());
- }
-
- PropertyDescriptorSeq pds = operator()(desc.properties);
- properties.insert(properties.end(), pds.begin(), pds.end());
+ if(resolved.find(*p) != resolved.end())
+ {
+ exception("detected circular dependency with property reference `" + *p + "'");
+ }
+
+ PropertySetDescriptor desc = getPropertySet(*p);
+ if(!desc.references.empty())
+ {
+ resolved.insert(*p);
+ PropertyDescriptorSeq p = getProperties(desc.references, resolved);
+ properties.insert(properties.end(), p.begin(), p.end());
+ }
+
+ PropertyDescriptorSeq pds = operator()(desc.properties);
+ properties.insert(properties.end(), pds.begin(), pds.end());
}
return properties;
}
@@ -890,10 +890,10 @@ Resolver::checkReserved(const string& type, const map<string, string>& values) c
{
for(map<string, string>::const_iterator p = values.begin(); p != values.end(); ++p)
{
- if(_reserved.find(p->first) != _reserved.end())
- {
- exception("invalid " + type + " `" + p->first + "': reserved variable name");
- }
+ if(_reserved.find(p->first) != _reserved.end())
+ {
+ exception("invalid " + type + " `" + p->first + "': reserved variable name");
+ }
}
}
@@ -907,34 +907,34 @@ CommunicatorHelper::operator==(const CommunicatorHelper& helper) const
{
if(_desc->ice_id() != helper._desc->ice_id())
{
- return false;
+ return false;
}
if(_desc->description != helper._desc->description)
{
- return false;
+ return false;
}
if(set<AdapterDescriptor>(_desc->adapters.begin(), _desc->adapters.end()) !=
set<AdapterDescriptor>(helper._desc->adapters.begin(), helper._desc->adapters.end()))
{
- return false;
+ return false;
}
if(_desc->propertySet != helper._desc->propertySet)
{
- return false;
+ return false;
}
if(set<DbEnvDescriptor>(_desc->dbEnvs.begin(), _desc->dbEnvs.end()) !=
set<DbEnvDescriptor>(helper._desc->dbEnvs.begin(), helper._desc->dbEnvs.end()))
{
- return false;
+ return false;
}
if(_desc->logs != helper._desc->logs)
{
- return false;
+ return false;
}
return true;
@@ -950,23 +950,23 @@ void
CommunicatorHelper::getIds(multiset<string>& adapterIds, multiset<Ice::Identity>& objectIds) const
{
for(AdapterDescriptorSeq::const_iterator p = _desc->adapters.begin(); p != _desc->adapters.end(); ++p)
- {
- if(!p->id.empty())
- {
- adapterIds.insert(p->id);
- }
-
- set<Ice::Identity> ids;
- ObjectDescriptorSeq::const_iterator q;
- for(q = p->objects.begin(); q != p->objects.end(); ++q)
- {
- ids.insert(q->id);
- }
- for(q = p->allocatables.begin(); q != p->allocatables.end(); ++q)
- {
- ids.insert(q->id);
- }
- objectIds.insert(ids.begin(), ids.end());
+ {
+ if(!p->id.empty())
+ {
+ adapterIds.insert(p->id);
+ }
+
+ set<Ice::Identity> ids;
+ ObjectDescriptorSeq::const_iterator q;
+ for(q = p->objects.begin(); q != p->objects.end(); ++q)
+ {
+ ids.insert(q->id);
+ }
+ for(q = p->allocatables.begin(); q != p->allocatables.end(); ++q)
+ {
+ ids.insert(q->id);
+ }
+ objectIds.insert(ids.begin(), ids.end());
}
}
@@ -978,44 +978,44 @@ CommunicatorHelper::instantiateImpl(const CommunicatorDescriptorPtr& instance, c
for(AdapterDescriptorSeq::const_iterator p = _desc->adapters.begin(); p != _desc->adapters.end(); ++p)
{
- AdapterDescriptor adapter;
- adapter.name = resolve(p->name, "object adapter name", false);
- adapter.description = resolve(p->description, "object adapter description");
- adapter.id = resolve.asId(p->id, "object adapter id");
- adapter.registerProcess = p->registerProcess;
- adapter.serverLifetime = p->serverLifetime;
- adapter.replicaGroupId = resolve.asId(p->replicaGroupId, "object adapter replica group id", true);
- if(!adapter.replicaGroupId.empty() && !resolve.hasReplicaGroup(adapter.replicaGroupId))
- {
- resolve.exception("unknown replica group `" + adapter.replicaGroupId + "'");
- }
- adapter.priority = resolve.asInt(p->priority, "object adapter priority");
- adapter.objects = resolve(p->objects, "well-known");
- adapter.allocatables = resolve(p->allocatables, "allocatable");
- instance->adapters.push_back(adapter);
-
- //
- // Make sure the endpoints are defined.
- //
- if(IceGrid::getProperty(instance->propertySet.properties, "Ice.OA." + adapter.name + ".Endpoints").empty())
- {
- resolve.exception("invalid endpoints for adapter `" + adapter.name + "': empty string");
- }
+ AdapterDescriptor adapter;
+ adapter.name = resolve(p->name, "object adapter name", false);
+ adapter.description = resolve(p->description, "object adapter description");
+ adapter.id = resolve.asId(p->id, "object adapter id");
+ adapter.registerProcess = p->registerProcess;
+ adapter.serverLifetime = p->serverLifetime;
+ adapter.replicaGroupId = resolve.asId(p->replicaGroupId, "object adapter replica group id", true);
+ if(!adapter.replicaGroupId.empty() && !resolve.hasReplicaGroup(adapter.replicaGroupId))
+ {
+ resolve.exception("unknown replica group `" + adapter.replicaGroupId + "'");
+ }
+ adapter.priority = resolve.asInt(p->priority, "object adapter priority");
+ adapter.objects = resolve(p->objects, "well-known");
+ adapter.allocatables = resolve(p->allocatables, "allocatable");
+ instance->adapters.push_back(adapter);
+
+ //
+ // Make sure the endpoints are defined.
+ //
+ if(IceGrid::getProperty(instance->propertySet.properties, "Ice.OA." + adapter.name + ".Endpoints").empty())
+ {
+ resolve.exception("invalid endpoints for adapter `" + adapter.name + "': empty string");
+ }
}
for(DbEnvDescriptorSeq::const_iterator s = _desc->dbEnvs.begin(); s != _desc->dbEnvs.end(); ++s)
{
- DbEnvDescriptor dbEnv;
- dbEnv.name = resolve(s->name, "database environment name", false);
- dbEnv.description = resolve(s->description, "database environment description");
- dbEnv.dbHome = resolve(s->dbHome, "database environment home directory");
- dbEnv.properties = resolve(s->properties, "database environment property");
- instance->dbEnvs.push_back(dbEnv);
+ DbEnvDescriptor dbEnv;
+ dbEnv.name = resolve(s->name, "database environment name", false);
+ dbEnv.description = resolve(s->description, "database environment description");
+ dbEnv.dbHome = resolve(s->dbHome, "database environment home directory");
+ dbEnv.properties = resolve(s->properties, "database environment property");
+ instance->dbEnvs.push_back(dbEnv);
}
for(Ice::StringSeq::const_iterator l = _desc->logs.begin(); l != _desc->logs.end(); ++l)
{
- instance->logs.push_back(resolve(*l, "log path", false));
+ instance->logs.push_back(resolve(*l, "log path", false));
}
}
@@ -1039,17 +1039,17 @@ CommunicatorHelper::upgrade(CommunicatorDescriptorPtr& desc) const
bool upgraded = false;
for(AdapterDescriptorSeq::const_iterator p = _desc->adapters.begin(); p != _desc->adapters.end(); ++p)
{
- const string oaPrefix = p->name + ".";
- for(PropertyDescriptorSeq::iterator q = properties.begin(); q != properties.end(); ++q)
- {
- if(q->name.find(oaPrefix) == 0 &&
- q->name.size() > oaPrefix.size() &&
- oaProperties.find(q->name.substr(oaPrefix.size())) != oaProperties.end())
- {
- q->name = "Ice.OA." + q->name;
- upgraded = true;
- }
- }
+ const string oaPrefix = p->name + ".";
+ for(PropertyDescriptorSeq::iterator q = properties.begin(); q != properties.end(); ++q)
+ {
+ if(q->name.find(oaPrefix) == 0 &&
+ q->name.size() > oaPrefix.size() &&
+ oaProperties.find(q->name.substr(oaPrefix.size())) != oaProperties.end())
+ {
+ q->name = "Ice.OA." + q->name;
+ upgraded = true;
+ }
+ }
}
return upgraded;
}
@@ -1059,48 +1059,48 @@ CommunicatorHelper::print(const Ice::CommunicatorPtr& communicator, Output& out)
{
if(!_desc->description.empty())
{
- out << nl << "description";
- out << sb;
- out << nl << _desc->description;
- out << eb;
+ out << nl << "description";
+ out << sb;
+ out << nl << _desc->description;
+ out << eb;
}
set<string> hiddenProperties;
{
- for(DbEnvDescriptorSeq::const_iterator p = _desc->dbEnvs.begin(); p != _desc->dbEnvs.end(); ++p)
- {
- printDbEnv(out, *p);
- }
+ for(DbEnvDescriptorSeq::const_iterator p = _desc->dbEnvs.begin(); p != _desc->dbEnvs.end(); ++p)
+ {
+ printDbEnv(out, *p);
+ }
}
{
- for(AdapterDescriptorSeq::const_iterator p = _desc->adapters.begin(); p != _desc->adapters.end(); ++p)
- {
- hiddenProperties.insert("Ice.OA." + p->name + ".Endpoints");
- printObjectAdapter(communicator, out, *p);
- }
+ for(AdapterDescriptorSeq::const_iterator p = _desc->adapters.begin(); p != _desc->adapters.end(); ++p)
+ {
+ hiddenProperties.insert("Ice.OA." + p->name + ".Endpoints");
+ printObjectAdapter(communicator, out, *p);
+ }
}
{
- for(Ice::StringSeq::const_iterator p = _desc->logs.begin(); p != _desc->logs.end(); ++p)
- {
- out << nl << "log `" << *p << "'";
- }
+ for(Ice::StringSeq::const_iterator p = _desc->logs.begin(); p != _desc->logs.end(); ++p)
+ {
+ out << nl << "log `" << *p << "'";
+ }
}
if(!_desc->propertySet.properties.empty() || !_desc->propertySet.references.empty())
{
- out << nl << "properties";
- out << sb;
- if(!_desc->propertySet.references.empty())
- {
- out << nl << "references = " << toString(_desc->propertySet.references);
- }
- PropertyDescriptorSeq::const_iterator q;
- for(q = _desc->propertySet.properties.begin(); q != _desc->propertySet.properties.end(); ++q)
- {
- if(hiddenProperties.find(q->name) == hiddenProperties.end())
- {
- out << nl << q->name << " = `" << q->value << "'";
- }
- }
- out << eb;
+ out << nl << "properties";
+ out << sb;
+ if(!_desc->propertySet.references.empty())
+ {
+ out << nl << "references = " << toString(_desc->propertySet.references);
+ }
+ PropertyDescriptorSeq::const_iterator q;
+ for(q = _desc->propertySet.properties.begin(); q != _desc->propertySet.properties.end(); ++q)
+ {
+ if(hiddenProperties.find(q->name) == hiddenProperties.end())
+ {
+ out << nl << q->name << " = `" << q->value << "'";
+ }
+ }
+ out << eb;
}
}
@@ -1110,82 +1110,82 @@ CommunicatorHelper::printDbEnv(Output& out, const DbEnvDescriptor& dbEnv) const
out << nl << "database environment `" << dbEnv.name << "'";
if(!dbEnv.dbHome.empty() || !dbEnv.properties.empty() || !dbEnv.description.empty())
{
- out << sb;
- if(!dbEnv.dbHome.empty())
- {
- out << nl << "home = `" << dbEnv.dbHome << "'";
- }
- if(!dbEnv.description.empty())
- {
- out << nl << "description = `" << dbEnv.description << "'";
- }
- if(!dbEnv.properties.empty())
- {
- out << nl << "properties";
- out << sb;
- for(PropertyDescriptorSeq::const_iterator p = dbEnv.properties.begin(); p != dbEnv.properties.end(); ++p)
- {
- out << nl << p->name << " = `" << p->value << "'";
- }
- out << eb;
- }
- out << eb;
+ out << sb;
+ if(!dbEnv.dbHome.empty())
+ {
+ out << nl << "home = `" << dbEnv.dbHome << "'";
+ }
+ if(!dbEnv.description.empty())
+ {
+ out << nl << "description = `" << dbEnv.description << "'";
+ }
+ if(!dbEnv.properties.empty())
+ {
+ out << nl << "properties";
+ out << sb;
+ for(PropertyDescriptorSeq::const_iterator p = dbEnv.properties.begin(); p != dbEnv.properties.end(); ++p)
+ {
+ out << nl << p->name << " = `" << p->value << "'";
+ }
+ out << eb;
+ }
+ out << eb;
}
}
void
CommunicatorHelper::printObjectAdapter(const Ice::CommunicatorPtr& communicator,
- Output& out,
- const AdapterDescriptor& adapter) const
+ Output& out,
+ const AdapterDescriptor& adapter) const
{
out << nl << "adapter `" << adapter.name << "'";
out << sb;
if(!adapter.id.empty())
{
- out << nl << "id = `" << adapter.id << "'";
+ out << nl << "id = `" << adapter.id << "'";
}
if(!adapter.replicaGroupId.empty())
{
- out << nl << "replica group id = `" << adapter.replicaGroupId << "'";
+ out << nl << "replica group id = `" << adapter.replicaGroupId << "'";
}
if(!adapter.priority.empty())
{
- out << nl << "priority = `" << adapter.priority << "'";
+ out << nl << "priority = `" << adapter.priority << "'";
}
string endpoints = getProperty("Ice.OA." + adapter.name + ".Endpoints");
if(!endpoints.empty())
{
- out << nl << "endpoints = `" << endpoints << "'";
+ out << nl << "endpoints = `" << endpoints << "'";
}
out << nl << "register process = `" << (adapter.registerProcess ? "true" : "false") << "'";
out << nl << "server lifetime = `" << (adapter.serverLifetime ? "true" : "false") << "'";
ObjectDescriptorSeq::const_iterator p;
for(p = adapter.objects.begin(); p != adapter.objects.end(); ++p)
{
- out << nl << "well-known object";
- out << sb;
- out << nl << "identity = `" << communicator->identityToString(p->id) << "' ";
- if(!p->type.empty())
- {
- out << nl << "type = `" << p->type << "'";
- }
- out << eb;
+ out << nl << "well-known object";
+ out << sb;
+ out << nl << "identity = `" << communicator->identityToString(p->id) << "' ";
+ if(!p->type.empty())
+ {
+ out << nl << "type = `" << p->type << "'";
+ }
+ out << eb;
}
for(p = adapter.allocatables.begin(); p != adapter.allocatables.end(); ++p)
{
- out << nl << "allocatable";
- out << sb;
- out << nl << "identity = `" << communicator->identityToString(p->id) << "' ";
- if(!p->type.empty())
- {
- out << nl << "type = `" << p->type << "'";
- }
- out << eb;
+ out << nl << "allocatable";
+ out << sb;
+ out << nl << "identity = `" << communicator->identityToString(p->id) << "' ";
+ if(!p->type.empty())
+ {
+ out << nl << "type = `" << p->type << "'";
+ }
+ out << eb;
}
if(!adapter.description.empty())
{
- out << nl << "description = `" << adapter.description << "'";
+ out << nl << "description = `" << adapter.description << "'";
}
out << eb;
}
@@ -1207,17 +1207,17 @@ ServiceHelper::operator==(const ServiceHelper& helper) const
{
if(!CommunicatorHelper::operator==(helper))
{
- return false;
+ return false;
}
if(_desc->name != helper._desc->name)
{
- return false;
+ return false;
}
if(_desc->entry != helper._desc->entry)
{
- return false;
+ return false;
}
return true;
@@ -1237,7 +1237,7 @@ ServiceHelper::getDescriptor() const
ServiceDescriptorPtr
ServiceHelper::instantiate(const Resolver& resolver, const PropertyDescriptorSeq& props,
- const PropertySetDescriptorDict& serviceProps) const
+ const PropertySetDescriptorDict& serviceProps) const
{
ServiceDescriptorPtr service = new ServiceDescriptor();
instantiateImpl(service, resolver, props, serviceProps);
@@ -1246,9 +1246,9 @@ ServiceHelper::instantiate(const Resolver& resolver, const PropertyDescriptorSeq
void
ServiceHelper::instantiateImpl(const ServiceDescriptorPtr& instance,
- const Resolver& resolve,
- const PropertyDescriptorSeq& props,
- const PropertySetDescriptorDict& serviceProps) const
+ const Resolver& resolve,
+ const PropertyDescriptorSeq& props,
+ const PropertySetDescriptorDict& serviceProps) const
{
CommunicatorHelper::instantiateImpl(instance, resolve);
instance->name = resolve(_desc->name, "name", false);
@@ -1257,9 +1257,9 @@ ServiceHelper::instantiateImpl(const ServiceDescriptorPtr& instance,
PropertySetDescriptorDict::const_iterator p = serviceProps.find(instance->name);
if(p != serviceProps.end())
{
- instance->propertySet.properties.insert(instance->propertySet.properties.end(),
- p->second.properties.begin(),
- p->second.properties.end());
+ instance->propertySet.properties.insert(instance->propertySet.properties.end(),
+ p->second.properties.begin(),
+ p->second.properties.end());
}
}
@@ -1284,69 +1284,69 @@ ServerHelper::operator==(const ServerHelper& helper) const
{
if(!CommunicatorHelper::operator==(helper))
{
- return false;
+ return false;
}
if(_desc->id != helper._desc->id)
{
- return false;
+ return false;
}
if(_desc->exe != helper._desc->exe)
{
- return false;
+ return false;
}
if(_desc->pwd != helper._desc->pwd)
{
- return false;
+ return false;
}
if(set<string>(_desc->options.begin(), _desc->options.end()) !=
set<string>(helper._desc->options.begin(), helper._desc->options.end()))
{
- return false;
+ return false;
}
if(set<string>(_desc->envs.begin(), _desc->envs.end()) !=
set<string>(helper._desc->envs.begin(), helper._desc->envs.end()))
{
- return false;
+ return false;
}
if(_desc->activation != helper._desc->activation)
{
- return false;
+ return false;
}
if(_desc->activationTimeout != helper._desc->activationTimeout)
{
- return false;
+ return false;
}
if(_desc->deactivationTimeout != helper._desc->deactivationTimeout)
{
- return false;
+ return false;
}
if(_desc->distrib != helper._desc->distrib)
{
- return false;
+ return false;
}
if(_desc->allocatable != helper._desc->allocatable)
{
- return false;
+ return false;
}
if(_desc->user != helper._desc->user)
{
- return false;
+ return false;
}
if(_desc->iceVersion != helper._desc->iceVersion)
{
- return false;
+ return false;
}
return true;
@@ -1366,12 +1366,12 @@ ServerHelper::getDescriptor() const
ServerDescriptorPtr
ServerHelper::instantiate(const Resolver& resolver,
- const PropertyDescriptorSeq& props,
- const PropertySetDescriptorDict& serviceProps) const
+ const PropertyDescriptorSeq& props,
+ const PropertySetDescriptorDict& serviceProps) const
{
if(!serviceProps.empty())
{
- resolver.exception("service property sets are only allowed in IceBox server instances");
+ resolver.exception("service property sets are only allowed in IceBox server instances");
}
ServerDescriptorPtr server = new ServerDescriptor();
@@ -1399,70 +1399,70 @@ ServerHelper::printImpl(const Ice::CommunicatorPtr& communicator, Output& out, c
{
if(!info.application.empty())
{
- out << nl << "application = `" << info.application << "'";
- out << nl << "application uuid = `" << info.uuid << "'";
- out << nl << "application revision = `" << info.revision << "'";
+ out << nl << "application = `" << info.application << "'";
+ out << nl << "application uuid = `" << info.uuid << "'";
+ out << nl << "application revision = `" << info.revision << "'";
}
if(!info.node.empty())
{
- out << nl << "node = `" << info.node << "'";
+ out << nl << "node = `" << info.node << "'";
}
if(!info.sessionId.empty())
{
- out << nl << "session id = `" << info.sessionId << "'";
+ out << nl << "session id = `" << info.sessionId << "'";
}
out << nl << "exe = `" << _desc->exe << "'";
if(!_desc->pwd.empty())
{
- out << nl << "pwd = `" << _desc->pwd << "'";
+ out << nl << "pwd = `" << _desc->pwd << "'";
}
out << nl << "activation = `" << _desc->activation << "'";
if(!_desc->activationTimeout.empty() && _desc->activationTimeout != "0")
{
- out << nl << "activationTimeout = `" << _desc->activationTimeout << "'";
+ out << nl << "activationTimeout = `" << _desc->activationTimeout << "'";
}
if(!_desc->deactivationTimeout.empty() && _desc->deactivationTimeout != "0")
{
- out << nl << "deactivationTimeout = `" << _desc->deactivationTimeout << "'";
+ out << nl << "deactivationTimeout = `" << _desc->deactivationTimeout << "'";
}
if(!_desc->user.empty())
{
- out << nl << "user = `" << _desc->user << "'";
+ out << nl << "user = `" << _desc->user << "'";
}
if(!_desc->iceVersion.empty())
{
- out << nl << "ice version = `" << _desc->iceVersion << "'";
+ out << nl << "ice version = `" << _desc->iceVersion << "'";
}
if(!_desc->applicationDistrib)
{
- out << nl << "application distribution = `false'";
+ out << nl << "application distribution = `false'";
}
if(!_desc->options.empty())
{
- out << nl << "options = `" << toString(_desc->options) << "'";
+ out << nl << "options = `" << toString(_desc->options) << "'";
}
if(!_desc->envs.empty())
{
- out << nl << "envs = `" << toString(_desc->envs) << "'";
+ out << nl << "envs = `" << toString(_desc->envs) << "'";
}
if(!_desc->distrib.icepatch.empty())
{
- out << nl << "distribution";
- out << sb;
- out << nl << "proxy = `" << _desc->distrib.icepatch << "'";
- if(!_desc->distrib.directories.empty())
- {
- out << nl << "directories = `" << toString(_desc->distrib.directories) << "'";
- }
- out << eb;
+ out << nl << "distribution";
+ out << sb;
+ out << nl << "proxy = `" << _desc->distrib.icepatch << "'";
+ if(!_desc->distrib.directories.empty())
+ {
+ out << nl << "directories = `" << toString(_desc->distrib.directories) << "'";
+ }
+ out << eb;
}
CommunicatorHelper::print(communicator, out);
}
void
ServerHelper::instantiateImpl(const ServerDescriptorPtr& instance,
- const Resolver& resolve,
- const PropertyDescriptorSeq& props) const
+ const Resolver& resolve,
+ const PropertyDescriptorSeq& props) const
{
CommunicatorHelper::instantiateImpl(instance, resolve);
@@ -1476,22 +1476,22 @@ ServerHelper::instantiateImpl(const ServerDescriptorPtr& instance,
instance->iceVersion = resolve(_desc->iceVersion, "ice version");
if(!instance->iceVersion.empty())
{
- int version = getMMVersion(instance->iceVersion);
- if(version < 0)
- {
- resolve.exception("invalid ice version: " + instance->iceVersion);
- }
- else if(version > ICE_INT_VERSION)
- {
- //resolve.exception("invalid ice version: " + instance->iceVersion + " is superior to the IceGrid \n"
- //"registry version (" + ICE_STRING_VERSION + ")");
- if(resolve.warningEnabled())
- {
- Ice::Warning out(resolve.getCommunicator()->getLogger());
- out << "invalid ice version: " << instance->iceVersion << " is superior to the IceGrid ";
- out << "registry version (" << ICE_STRING_VERSION << ")";
- }
- }
+ int version = getMMVersion(instance->iceVersion);
+ if(version < 0)
+ {
+ resolve.exception("invalid ice version: " + instance->iceVersion);
+ }
+ else if(version > ICE_INT_VERSION)
+ {
+ //resolve.exception("invalid ice version: " + instance->iceVersion + " is superior to the IceGrid \n"
+ //"registry version (" + ICE_STRING_VERSION + ")");
+ if(resolve.warningEnabled())
+ {
+ Ice::Warning out(resolve.getCommunicator()->getLogger());
+ out << "invalid ice version: " << instance->iceVersion << " is superior to the IceGrid ";
+ out << "registry version (" << ICE_STRING_VERSION << ")";
+ }
+ }
}
if(!instance->activation.empty() &&
instance->activation != "manual" &&
@@ -1499,7 +1499,7 @@ ServerHelper::instantiateImpl(const ServerDescriptorPtr& instance,
instance->activation != "always" &&
instance->activation != "session")
{
- resolve.exception("unknown activation `" + instance->activation + "'");
+ resolve.exception("unknown activation `" + instance->activation + "'");
}
instance->activationTimeout = resolve.asInt(_desc->activationTimeout, "activation timeout");
instance->deactivationTimeout = resolve.asInt(_desc->deactivationTimeout, "deactivation timeout");
@@ -1515,7 +1515,7 @@ IceBoxHelper::IceBoxHelper(const IceBoxDescriptorPtr& descriptor) :
{
for(ServiceInstanceDescriptorSeq::const_iterator p = _desc->services.begin(); p != _desc->services.end(); ++p)
{
- _services.push_back(ServiceInstanceHelper(*p));
+ _services.push_back(ServiceInstanceHelper(*p));
}
}
@@ -1524,12 +1524,12 @@ IceBoxHelper::operator==(const IceBoxHelper& helper) const
{
if(!ServerHelper::operator==(helper))
{
- return false;
+ return false;
}
-
+
if(_services != helper._services)
{
- return false;
+ return false;
}
return true;
@@ -1543,8 +1543,8 @@ IceBoxHelper::operator!=(const IceBoxHelper& helper) const
ServerDescriptorPtr
IceBoxHelper::instantiate(const Resolver& resolver,
- const PropertyDescriptorSeq& props,
- const PropertySetDescriptorDict& serviceProps) const
+ const PropertyDescriptorSeq& props,
+ const PropertySetDescriptorDict& serviceProps) const
{
IceBoxDescriptorPtr iceBox = new IceBoxDescriptor();
instantiateImpl(iceBox, resolver, props, serviceProps);
@@ -1557,7 +1557,7 @@ IceBoxHelper::getIds(multiset<string>& adapterIds, multiset<Ice::Identity>& obje
CommunicatorHelper::getIds(adapterIds, objectIds);
for(vector<ServiceInstanceHelper>::const_iterator p = _services.begin(); p != _services.end(); ++p)
{
- p->getIds(adapterIds, objectIds);
+ p->getIds(adapterIds, objectIds);
}
}
@@ -1568,16 +1568,16 @@ IceBoxHelper::upgrade(CommunicatorDescriptorPtr& communicator) const
IceBoxDescriptorPtr iceBox = IceBoxDescriptorPtr::dynamicCast(communicator);
for(ServiceInstanceDescriptorSeq::iterator p = iceBox->services.begin(); p != iceBox->services.end(); ++p)
{
- if(p->descriptor)
- {
- CommunicatorDescriptorPtr com;
- if(ServiceHelper(p->descriptor).upgrade(com))
- {
- upgraded = true;
- p->descriptor = ServiceDescriptorPtr::dynamicCast(com);
- assert(p->descriptor);
- }
- }
+ if(p->descriptor)
+ {
+ CommunicatorDescriptorPtr com;
+ if(ServiceHelper(p->descriptor).upgrade(com))
+ {
+ upgraded = true;
+ p->descriptor = ServiceDescriptorPtr::dynamicCast(com);
+ assert(p->descriptor);
+ }
+ }
}
return upgraded;
}
@@ -1599,42 +1599,42 @@ IceBoxHelper::print(const Ice::CommunicatorPtr& communicator, Output& out, const
printImpl(communicator, out, info);
for(vector<ServiceInstanceHelper>::const_iterator p = _services.begin(); p != _services.end(); ++p)
{
- out << nl;
- p->print(communicator, out);
+ out << nl;
+ p->print(communicator, out);
}
out << eb;
}
void
IceBoxHelper::instantiateImpl(const IceBoxDescriptorPtr& instance,
- const Resolver& resolver,
- const PropertyDescriptorSeq& props,
- const PropertySetDescriptorDict& serviceProps) const
+ const Resolver& resolver,
+ const PropertyDescriptorSeq& props,
+ const PropertySetDescriptorDict& serviceProps) const
{
ServerHelper::instantiateImpl(instance, resolver, props);
set<string> serviceNames;
for(vector<ServiceInstanceHelper>::const_iterator p = _services.begin(); p != _services.end(); ++p)
{
- ServiceInstanceDescriptor desc = p->instantiate(resolver, serviceProps);
- assert(desc.descriptor);
- serviceNames.insert(desc.descriptor->name);
- instance->services.push_back(desc);
+ ServiceInstanceDescriptor desc = p->instantiate(resolver, serviceProps);
+ assert(desc.descriptor);
+ serviceNames.insert(desc.descriptor->name);
+ instance->services.push_back(desc);
}
for(PropertySetDescriptorDict::const_iterator q = serviceProps.begin(); q != serviceProps.end(); ++q)
{
- if(serviceNames.find(q->first) == serviceNames.end())
- {
- resolver.exception("invalid service property set: service `" + q->first + "' doesn't exist");
- }
+ if(serviceNames.find(q->first) == serviceNames.end())
+ {
+ resolver.exception("invalid service property set: service `" + q->first + "' doesn't exist");
+ }
}
}
map<string, string>
InstanceHelper::instantiateParams(const Resolver& resolve,
- const string& tmpl,
- const map<string, string>& parameters,
- const vector<string>& requiredParameters,
- const map<string, string>& defaults) const
+ const string& tmpl,
+ const map<string, string>& parameters,
+ const vector<string>& requiredParameters,
+ const map<string, string>& defaults) const
{
map<string, string> params;
@@ -1642,42 +1642,42 @@ InstanceHelper::instantiateParams(const Resolver& resolve,
set<string> unknown;
for(map<string, string>::const_iterator p = parameters.begin(); p != parameters.end(); ++p)
{
- if(required.find(p->first) == required.end())
- {
- unknown.insert(p->first);
- }
- params.insert(make_pair(p->first, resolve(p->second, "parameter `" + p->first + "'")));
+ if(required.find(p->first) == required.end())
+ {
+ unknown.insert(p->first);
+ }
+ params.insert(make_pair(p->first, resolve(p->second, "parameter `" + p->first + "'")));
}
if(!unknown.empty())
{
- ostringstream os;
- os << "unknown parameters when instantiating `" + tmpl + "' template: ";
- copy(unknown.begin(), unknown.end(), ostream_iterator<string>(os, " "));
- resolve.exception(os.str());
+ ostringstream os;
+ os << "unknown parameters when instantiating `" + tmpl + "' template: ";
+ copy(unknown.begin(), unknown.end(), ostream_iterator<string>(os, " "));
+ resolve.exception(os.str());
}
set<string> missingParams;
for(set<string>::const_iterator q = required.begin(); q != required.end(); ++q)
{
- if(params.find(*q) == params.end())
- {
- map<string, string>::const_iterator r = defaults.find(*q);
- if(r == defaults.end())
- {
- missingParams.insert(*q);
- }
- else
- {
- params.insert(make_pair(r->first, resolve(r->second, "default parameter `" + r->first + "'")));
- }
- }
+ if(params.find(*q) == params.end())
+ {
+ map<string, string>::const_iterator r = defaults.find(*q);
+ if(r == defaults.end())
+ {
+ missingParams.insert(*q);
+ }
+ else
+ {
+ params.insert(make_pair(r->first, resolve(r->second, "default parameter `" + r->first + "'")));
+ }
+ }
}
if(!missingParams.empty())
{
- ostringstream os;
- os << "undefined parameters when instantiating `" + tmpl + "' template: ";
- copy(missingParams.begin(), missingParams.end(), ostream_iterator<string>(os, " "));
- resolve.exception(os.str());
+ ostringstream os;
+ os << "undefined parameters when instantiating `" + tmpl + "' template: ";
+ copy(missingParams.begin(), missingParams.end(), ostream_iterator<string>(os, " "));
+ resolve.exception(os.str());
}
return params;
@@ -1693,12 +1693,12 @@ ServiceInstanceHelper::ServiceInstanceHelper(const ServiceInstanceDescriptor& de
//
if(_def._cpp_template.empty() && !_def.descriptor)
{
- throw DeploymentException("invalid service instance: no template defined");
+ throw DeploymentException("invalid service instance: no template defined");
}
if(_def.descriptor)
{
- _service = ServiceHelper(_def.descriptor);
+ _service = ServiceHelper(_def.descriptor);
}
}
@@ -1707,13 +1707,13 @@ ServiceInstanceHelper::operator==(const ServiceInstanceHelper& helper) const
{
if(_def._cpp_template.empty())
{
- return _service == helper._service;
+ return _service == helper._service;
}
else
{
- return _def._cpp_template == helper._def._cpp_template &&
- _def.parameterValues == helper._def.parameterValues &&
- _def.propertySet == helper._def.propertySet;
+ return _def._cpp_template == helper._def._cpp_template &&
+ _def.parameterValues == helper._def.parameterValues &&
+ _def.propertySet == helper._def.propertySet;
}
}
@@ -1730,14 +1730,14 @@ ServiceInstanceHelper::instantiate(const Resolver& resolve, const PropertySetDes
std::map<std::string, std::string> parameterValues;
if(!def.getDescriptor())
{
- assert(!_def._cpp_template.empty());
- TemplateDescriptor tmpl = resolve.getServiceTemplate(_def._cpp_template);
- def = ServiceHelper(ServiceDescriptorPtr::dynamicCast(tmpl.descriptor));
- parameterValues = instantiateParams(resolve,
- _def._cpp_template,
- _def.parameterValues,
- tmpl.parameters,
- tmpl.parameterDefaults);
+ assert(!_def._cpp_template.empty());
+ TemplateDescriptor tmpl = resolve.getServiceTemplate(_def._cpp_template);
+ def = ServiceHelper(ServiceDescriptorPtr::dynamicCast(tmpl.descriptor));
+ parameterValues = instantiateParams(resolve,
+ _def._cpp_template,
+ _def.parameterValues,
+ tmpl.parameters,
+ tmpl.parameterDefaults);
}
//
@@ -1776,36 +1776,36 @@ ServiceInstanceHelper::print(const Ice::CommunicatorPtr& communicator, Output& o
{
if(_service.getDescriptor())
{
- _service.print(communicator, out);
+ _service.print(communicator, out);
}
else
{
- assert(!_def._cpp_template.empty());
- out << "service instance";
- out << sb;
- out << nl << "template = `" << _def._cpp_template << "'";
- out << nl << "parameters";
- out << sb;
- for(StringStringDict::const_iterator p = _def.parameterValues.begin(); p != _def.parameterValues.end(); ++p)
- {
- out << nl << p->first << " = `" << p->second << "'";
- }
- out << eb;
- out << eb;
+ assert(!_def._cpp_template.empty());
+ out << "service instance";
+ out << sb;
+ out << nl << "template = `" << _def._cpp_template << "'";
+ out << nl << "parameters";
+ out << sb;
+ for(StringStringDict::const_iterator p = _def.parameterValues.begin(); p != _def.parameterValues.end(); ++p)
+ {
+ out << nl << p->first << " = `" << p->second << "'";
+ }
+ out << eb;
+ out << eb;
}
}
ServerInstanceHelper::ServerInstanceHelper(const ServerInstanceDescriptor& desc,
- const Resolver& resolve,
- bool instantiate) :
+ const Resolver& resolve,
+ bool instantiate) :
_def(desc)
{
init(0, resolve, instantiate);
}
ServerInstanceHelper::ServerInstanceHelper(const ServerDescriptorPtr& definition,
- const Resolver& resolve,
- bool instantiate) :
+ const Resolver& resolve,
+ bool instantiate) :
_def(ServerInstanceDescriptor())
{
init(definition, resolve, instantiate);
@@ -1821,21 +1821,21 @@ ServerInstanceHelper::init(const ServerDescriptorPtr& definition, const Resolver
std::map<std::string, std::string> parameterValues;
if(!def)
{
- if(_def._cpp_template.empty())
- {
- resolve.exception("invalid server instance: template is not defined");
- }
-
- //
- // Get the server definition and the template property sets.
- //
- TemplateDescriptor tmpl = resolve.getServerTemplate(_def._cpp_template);
- def = ServerDescriptorPtr::dynamicCast(tmpl.descriptor);
- parameterValues = instantiateParams(resolve,
- _def._cpp_template,
- _def.parameterValues,
- tmpl.parameters,
- tmpl.parameterDefaults);
+ if(_def._cpp_template.empty())
+ {
+ resolve.exception("invalid server instance: template is not defined");
+ }
+
+ //
+ // Get the server definition and the template property sets.
+ //
+ TemplateDescriptor tmpl = resolve.getServerTemplate(_def._cpp_template);
+ def = ServerDescriptorPtr::dynamicCast(tmpl.descriptor);
+ parameterValues = instantiateParams(resolve,
+ _def._cpp_template,
+ _def.parameterValues,
+ tmpl.parameters,
+ tmpl.parameterDefaults);
}
assert(def);
@@ -1854,7 +1854,7 @@ ServerInstanceHelper::init(const ServerDescriptorPtr& definition, const Resolver
if(!instantiate)
{
- return; // We're done.
+ return; // We're done.
}
//
@@ -1863,30 +1863,30 @@ ServerInstanceHelper::init(const ServerDescriptorPtr& definition, const Resolver
//
if(svrResolve(def->activation, "server activation", true) == "session")
{
- svrResolve.addIgnored("session.id");
+ svrResolve.addIgnored("session.id");
}
-
+
//
// Instantiate the server instance definition (we use the server
// resolver above, so using parameters in properties is possible).
//
if(!_def._cpp_template.empty())
{
- _instance._cpp_template = _def._cpp_template;
- _instance.parameterValues = parameterValues;
- _instance.propertySet = svrResolve(_def.propertySet);
- for(PropertySetDescriptorDict::const_iterator p = _def.servicePropertySets.begin();
- p != _def.servicePropertySets.end(); ++p)
- {
- _instance.servicePropertySets.insert(make_pair(svrResolve(p->first), svrResolve(p->second)));
- }
+ _instance._cpp_template = _def._cpp_template;
+ _instance.parameterValues = parameterValues;
+ _instance.propertySet = svrResolve(_def.propertySet);
+ for(PropertySetDescriptorDict::const_iterator p = _def.servicePropertySets.begin();
+ p != _def.servicePropertySets.end(); ++p)
+ {
+ _instance.servicePropertySets.insert(make_pair(svrResolve(p->first), svrResolve(p->second)));
+ }
}
//
// Instantiate the server definition.
//
ServerDescriptorPtr inst = _serverDefinition->instantiate(svrResolve, _instance.propertySet.properties,
- _instance.servicePropertySets);
+ _instance.servicePropertySets);
_serverInstance = createHelper(inst);
}
@@ -1895,14 +1895,14 @@ ServerInstanceHelper::operator==(const ServerInstanceHelper& helper) const
{
if(_def._cpp_template.empty())
{
- return *_serverDefinition == *helper._serverDefinition;
+ return *_serverDefinition == *helper._serverDefinition;
}
else
{
- return _def._cpp_template == helper._def._cpp_template &&
- _def.parameterValues == helper._def.parameterValues &&
- _def.propertySet == helper._def.propertySet &&
- _def.servicePropertySets == helper._def.servicePropertySets;
+ return _def._cpp_template == helper._def._cpp_template &&
+ _def.parameterValues == helper._def.parameterValues &&
+ _def.propertySet == helper._def.propertySet &&
+ _def.servicePropertySets == helper._def.servicePropertySets;
}
}
@@ -1954,16 +1954,16 @@ ServerInstanceHelper::getIds(multiset<string>& adapterIds, multiset<Ice::Identit
}
NodeHelper::NodeHelper(const string& name,
- const NodeDescriptor& descriptor,
- const Resolver& appResolve,
- bool instantiate) :
+ const NodeDescriptor& descriptor,
+ const Resolver& appResolve,
+ bool instantiate) :
_name(name),
_def(descriptor),
_instantiated(instantiate)
{
if(_name.empty())
{
- appResolve.exception("invalid node: empty name");
+ appResolve.exception("invalid node: empty name");
}
Resolver resolve(appResolve, _def.variables, false);
@@ -1972,48 +1972,48 @@ NodeHelper::NodeHelper(const string& name,
if(instantiate)
{
- //
- // Instantiate the node definition.
- //
- _instance.variables = _def.variables;
- _instance.loadFactor = resolve.asFloat(_def.loadFactor, "load factor");
- _instance.description = resolve(_def.description, "description");
- _instance.propertySets = resolve(_def.propertySets);
+ //
+ // Instantiate the node definition.
+ //
+ _instance.variables = _def.variables;
+ _instance.loadFactor = resolve.asFloat(_def.loadFactor, "load factor");
+ _instance.description = resolve(_def.description, "description");
+ _instance.propertySets = resolve(_def.propertySets);
- //
- // Set the named property sets on the resolver. We use the
- // instantiated named property sets here -- named property sets
- // must be fully definied at the node level.
- //
- resolve.addPropertySets(_instance.propertySets);
+ //
+ // Set the named property sets on the resolver. We use the
+ // instantiated named property sets here -- named property sets
+ // must be fully definied at the node level.
+ //
+ resolve.addPropertySets(_instance.propertySets);
}
ServerInstanceDescriptorSeq::const_iterator p;
for(p = _def.serverInstances.begin(); p != _def.serverInstances.end(); ++p)
{
- ServerInstanceHelper helper(*p, resolve, instantiate);
- if(!_serverInstances.insert(make_pair(helper.getId(), helper)).second)
- {
- resolve.exception("duplicate server `" + helper.getId() + "' in node `" + _name + "'");
- }
- if(instantiate)
- {
- _instance.serverInstances.push_back(helper.getInstance());
- }
+ ServerInstanceHelper helper(*p, resolve, instantiate);
+ if(!_serverInstances.insert(make_pair(helper.getId(), helper)).second)
+ {
+ resolve.exception("duplicate server `" + helper.getId() + "' in node `" + _name + "'");
+ }
+ if(instantiate)
+ {
+ _instance.serverInstances.push_back(helper.getInstance());
+ }
}
ServerDescriptorSeq::const_iterator q;
for(q = _def.servers.begin(); q != _def.servers.end(); ++q)
{
- ServerInstanceHelper helper(*q, resolve, instantiate);
- if(!_servers.insert(make_pair(helper.getId(), helper)).second)
- {
- resolve.exception("duplicate server `" + helper.getId() + "' in node `" + _name + "'");
- }
- if(instantiate)
- {
- _instance.servers.push_back(helper.getServerInstance());
- }
+ ServerInstanceHelper helper(*q, resolve, instantiate);
+ if(!_servers.insert(make_pair(helper.getId(), helper)).second)
+ {
+ resolve.exception("duplicate server `" + helper.getId() + "' in node `" + _name + "'");
+ }
+ if(instantiate)
+ {
+ _instance.servers.push_back(helper.getServerInstance());
+ }
}
}
@@ -2022,32 +2022,32 @@ NodeHelper::operator==(const NodeHelper& helper) const
{
if(_def.variables != helper._def.variables)
{
- return false;
+ return false;
}
if(_serverInstances != helper._serverInstances)
{
- return false;
+ return false;
}
if(_servers != helper._servers)
{
- return false;
+ return false;
}
if(_def.loadFactor != helper._def.loadFactor)
{
- return false;
+ return false;
}
if(_def.description != helper._def.description)
{
- return false;
+ return false;
}
if(_def.propertySets != helper._def.propertySets)
{
- return false;
+ return false;
}
return true;
@@ -2069,12 +2069,12 @@ NodeHelper::diff(const NodeHelper& helper) const
update.name = _name;
if(_def.loadFactor != helper._def.loadFactor)
{
- update.loadFactor = new BoxedString(_def.loadFactor);
+ update.loadFactor = new BoxedString(_def.loadFactor);
}
if(_def.description != helper._def.description)
{
- update.description = new BoxedString(_def.description);
+ update.description = new BoxedString(_def.description);
}
update.variables = getDictUpdatedElts(helper._def.variables, _def.variables);
@@ -2086,14 +2086,14 @@ NodeHelper::diff(const NodeHelper& helper) const
ServerInstanceHelperDict updated = getDictUpdatedElts(helper._serverInstances, _serverInstances);
for(ServerInstanceHelperDict::const_iterator p = updated.begin(); p != updated.end(); ++p)
{
- update.serverInstances.push_back(p->second.getDefinition());
+ update.serverInstances.push_back(p->second.getDefinition());
}
update.removeServers = getDictRemovedElts(helper._serverInstances, _serverInstances);
updated = getDictUpdatedElts(helper._servers, _servers);
for(ServerInstanceHelperDict::const_iterator q = updated.begin(); q != updated.end(); ++q)
{
- update.servers.push_back(q->second.getServerDefinition());
+ update.servers.push_back(q->second.getServerDefinition());
}
Ice::StringSeq removed = getDictRemovedElts(helper._servers, _servers);
update.removeServers.insert(update.removeServers.end(), removed.begin(), removed.end());
@@ -2137,63 +2137,63 @@ NodeHelper::update(const NodeUpdateDescriptor& update, const Resolver& appResolv
ServerInstanceDescriptorSeq::const_iterator q;
for(q = update.serverInstances.begin(); q != update.serverInstances.end(); ++q)
{
- ServerInstanceHelper helper(*q, resolve, false);
- if(!added.insert(helper.getId()).second)
- {
- resolve.exception("duplicate server `" + helper.getId() + "' in node `" + _name + "'");
- }
- def.serverInstances.push_back(helper.getDefinition());
+ ServerInstanceHelper helper(*q, resolve, false);
+ if(!added.insert(helper.getId()).second)
+ {
+ resolve.exception("duplicate server `" + helper.getId() + "' in node `" + _name + "'");
+ }
+ def.serverInstances.push_back(helper.getDefinition());
}
for(r = _serverInstances.begin(); r != _serverInstances.end(); ++r)
{
- if(removed.find(r->first) != removed.end() || added.find(r->first) != added.end())
- {
- continue;
- }
-
- //
- // Re-instantiate the server. Make sure the server ID didn't
- // change, if the ID of a server changes the update descriptor
- // has to remove the server and add an update entry for it.
- //
- ServerInstanceHelper helper(r->second.getDefinition(), resolve, false);
- if(helper.getId() != r->first)
- {
- resolve.exception("invalid update in node `" + _name + "':\n" + "server instance id `" + r->first +
- "' changed to `" + helper.getId() + "'");
- }
- def.serverInstances.push_back(helper.getDefinition());
+ if(removed.find(r->first) != removed.end() || added.find(r->first) != added.end())
+ {
+ continue;
+ }
+
+ //
+ // Re-instantiate the server. Make sure the server ID didn't
+ // change, if the ID of a server changes the update descriptor
+ // has to remove the server and add an update entry for it.
+ //
+ ServerInstanceHelper helper(r->second.getDefinition(), resolve, false);
+ if(helper.getId() != r->first)
+ {
+ resolve.exception("invalid update in node `" + _name + "':\n" + "server instance id `" + r->first +
+ "' changed to `" + helper.getId() + "'");
+ }
+ def.serverInstances.push_back(helper.getDefinition());
}
added.clear();
for(ServerDescriptorSeq::const_iterator s = update.servers.begin(); s != update.servers.end(); ++s)
{
- ServerInstanceHelper helper(*s, resolve, false);
- if(!added.insert(helper.getId()).second)
- {
- resolve.exception("duplicate server `" + helper.getId() + "' in node `" + _name + "'");
- }
- def.servers.push_back(helper.getServerDefinition());
+ ServerInstanceHelper helper(*s, resolve, false);
+ if(!added.insert(helper.getId()).second)
+ {
+ resolve.exception("duplicate server `" + helper.getId() + "' in node `" + _name + "'");
+ }
+ def.servers.push_back(helper.getServerDefinition());
}
for(r = _servers.begin(); r != _servers.end(); ++r)
{
- if(removed.find(r->first) != removed.end() || added.find(r->first) != added.end())
- {
- continue;
- }
-
- //
- // Re-instantiate the server. Make sure the server ID didn't
- // change, if the ID of a server changes the update descriptor
- // has to remove the server and add an update entry for it.
- //
- ServerInstanceHelper helper(r->second.getServerDefinition(), resolve, false);
- if(helper.getId() != r->first)
- {
- resolve.exception("invalid update in node `" + _name + "':\nserver instance id `" + r->first +
- "' changed to `" + helper.getId() + "'");
- }
- def.servers.push_back(helper.getServerDefinition());
+ if(removed.find(r->first) != removed.end() || added.find(r->first) != added.end())
+ {
+ continue;
+ }
+
+ //
+ // Re-instantiate the server. Make sure the server ID didn't
+ // change, if the ID of a server changes the update descriptor
+ // has to remove the server and add an update entry for it.
+ //
+ ServerInstanceHelper helper(r->second.getServerDefinition(), resolve, false);
+ if(helper.getId() != r->first)
+ {
+ resolve.exception("invalid update in node `" + _name + "':\nserver instance id `" + r->first +
+ "' changed to `" + helper.getId() + "'");
+ }
+ def.servers.push_back(helper.getServerDefinition());
}
return def;
}
@@ -2206,12 +2206,12 @@ NodeHelper::upgrade(NodeDescriptor& desc) const
bool upgraded = false;
for(ServerDescriptorSeq::iterator j = desc.servers.begin(); j != desc.servers.end(); ++j)
{
- CommunicatorDescriptorPtr com;
- if(createHelper(*j)->upgrade(com))
- {
- *j = ServerDescriptorPtr::dynamicCast(com);
- upgraded = true;
- }
+ CommunicatorDescriptorPtr com;
+ if(createHelper(*j)->upgrade(com))
+ {
+ *j = ServerDescriptorPtr::dynamicCast(com);
+ upgraded = true;
+ }
}
return upgraded;
@@ -2224,13 +2224,13 @@ NodeHelper::getIds(multiset<string>& serverIds, multiset<string>& adapterIds, mu
ServerInstanceHelperDict::const_iterator p;
for(p = _serverInstances.begin(); p != _serverInstances.end(); ++p)
{
- serverIds.insert(p->first);
- p->second.getIds(adapterIds, objectIds);
+ serverIds.insert(p->first);
+ p->second.getIds(adapterIds, objectIds);
}
for(p = _servers.begin(); p != _servers.end(); ++p)
{
- serverIds.insert(p->first);
- p->second.getIds(adapterIds, objectIds);
+ serverIds.insert(p->first);
+ p->second.getIds(adapterIds, objectIds);
}
}
@@ -2255,23 +2255,23 @@ NodeHelper::getServerInfos(const string& app, const string& uuid, int revision,
ServerInstanceHelperDict::const_iterator p;
for(p = _serverInstances.begin(); p != _serverInstances.end(); ++p)
{
- ServerInfo info;
- info.node = _name;
- info.application = app;
- info.uuid = uuid;
- info.revision = revision;
- info.descriptor = p->second.getServerInstance();
- servers.insert(make_pair(p->second.getId(), info));
+ ServerInfo info;
+ info.node = _name;
+ info.application = app;
+ info.uuid = uuid;
+ info.revision = revision;
+ info.descriptor = p->second.getServerInstance();
+ servers.insert(make_pair(p->second.getId(), info));
}
for(p = _servers.begin(); p != _servers.end(); ++p)
{
- ServerInfo info;
- info.node = _name;
- info.application = app;
- info.uuid = uuid;
- info.revision = revision;
- info.descriptor = p->second.getServerInstance();
- servers.insert(make_pair(p->second.getId(), info));
+ ServerInfo info;
+ info.node = _name;
+ info.application = app;
+ info.uuid = uuid;
+ info.revision = revision;
+ info.descriptor = p->second.getServerInstance();
+ servers.insert(make_pair(p->second.getId(), info));
}
}
@@ -2285,38 +2285,38 @@ NodeHelper::hasDistributions(const string& server) const
//
if(server.empty())
{
- ServerInstanceHelperDict::const_iterator p;
- for(p = _serverInstances.begin(); p != _serverInstances.end(); ++p)
- {
- if(!p->second.getServerInstance()->distrib.icepatch.empty())
- {
- return true;
- }
- }
- for(p = _servers.begin(); p != _servers.end(); ++p)
- {
- if(!p->second.getServerInstance()->distrib.icepatch.empty())
- {
- return true;
- }
- }
+ ServerInstanceHelperDict::const_iterator p;
+ for(p = _serverInstances.begin(); p != _serverInstances.end(); ++p)
+ {
+ if(!p->second.getServerInstance()->distrib.icepatch.empty())
+ {
+ return true;
+ }
+ }
+ for(p = _servers.begin(); p != _servers.end(); ++p)
+ {
+ if(!p->second.getServerInstance()->distrib.icepatch.empty())
+ {
+ return true;
+ }
+ }
}
else
{
- ServerInstanceHelperDict::const_iterator p = _serverInstances.find(server);
- if(p == _serverInstances.end())
- {
- p = _servers.find(server);
- if(p == _servers.end())
- {
- return false;
- }
- }
+ ServerInstanceHelperDict::const_iterator p = _serverInstances.find(server);
+ if(p == _serverInstances.end())
+ {
+ p = _servers.find(server);
+ if(p == _servers.end())
+ {
+ return false;
+ }
+ }
- if(!p->second.getServerInstance()->distrib.icepatch.empty())
- {
- return true;
- }
+ if(!p->second.getServerInstance()->distrib.icepatch.empty())
+ {
+ return true;
+ }
}
return false;
@@ -2343,45 +2343,45 @@ NodeHelper::print(Output& out) const
out << sb;
if(!_instance.loadFactor.empty())
{
- out << nl << "load factor = `" << _instance.loadFactor << "'";
+ out << nl << "load factor = `" << _instance.loadFactor << "'";
}
if(!_instance.description.empty())
{
- out << nl << "description = `" << _instance.description << "'";
+ out << nl << "description = `" << _instance.description << "'";
}
if(!_instance.variables.empty())
{
- out << nl << "variables";
- out << sb;
- for(StringStringDict::const_iterator q = _instance.variables.begin(); q != _instance.variables.end(); ++q)
- {
- out << nl << q->first << " = `" << q->second << "'";
- }
- out << eb;
+ out << nl << "variables";
+ out << sb;
+ for(StringStringDict::const_iterator q = _instance.variables.begin(); q != _instance.variables.end(); ++q)
+ {
+ out << nl << q->first << " = `" << q->second << "'";
+ }
+ out << eb;
}
if(!_instance.propertySets.empty())
{
- PropertySetDescriptorDict::const_iterator q;
- for(q = _instance.propertySets.begin(); q != _instance.propertySets.end(); ++q)
- {
- out << nl << "properties `" << q->first << "'";
- out << sb;
- if(!q->second.references.empty())
- {
- out << nl << "references = " << toString(q->second.references);
- }
- PropertyDescriptorSeq::const_iterator r;
- for(r = q->second.properties.begin(); r != q->second.properties.end(); ++r)
- {
- out << nl << r->name << " = `" << r->value << "'";
- }
- out << eb;
- }
+ PropertySetDescriptorDict::const_iterator q;
+ for(q = _instance.propertySets.begin(); q != _instance.propertySets.end(); ++q)
+ {
+ out << nl << "properties `" << q->first << "'";
+ out << sb;
+ if(!q->second.references.empty())
+ {
+ out << nl << "references = " << toString(q->second.references);
+ }
+ PropertyDescriptorSeq::const_iterator r;
+ for(r = q->second.properties.begin(); r != q->second.properties.end(); ++r)
+ {
+ out << nl << r->name << " = `" << r->value << "'";
+ }
+ out << eb;
+ }
}
if(_serverInstances.empty() && _servers.empty())
{
- return;
+ return;
}
out << nl << "servers";
@@ -2389,11 +2389,11 @@ NodeHelper::print(Output& out) const
ServerInstanceHelperDict::const_iterator p;
for(p = _serverInstances.begin(); p != _serverInstances.end(); ++p)
{
- out << nl << p->first;
+ out << nl << p->first;
}
for(p = _servers.begin(); p != _servers.end(); ++p)
{
- out << nl << p->first;
+ out << nl << p->first;
}
out << eb;
out << eb;
@@ -2428,7 +2428,7 @@ NodeHelper::printDiff(Output& out, const NodeHelper& helper) const
_def.loadFactor == helper._def.loadFactor &&
_def.description == helper._def.description)
{
- return;
+ return;
}
//
@@ -2440,116 +2440,116 @@ NodeHelper::printDiff(Output& out, const NodeHelper& helper) const
if(_def.loadFactor != helper._def.loadFactor)
{
- out << nl << "load factor udpated";
+ out << nl << "load factor udpated";
}
if(_def.description != helper._def.description)
{
- out << nl << "description udpated";
+ out << nl << "description udpated";
}
if(!updatedPs.empty() || !removedPs.empty())
{
- out << nl << "property sets udpated";
+ out << nl << "property sets udpated";
}
if(!variables.empty() || !removeVariables.empty())
{
- out << nl << "variables udpated";
+ out << nl << "variables udpated";
}
if(!updated.empty() || !removed.empty())
{
- out << nl << "servers";
- out << sb;
- ServerInstanceHelperDict::const_iterator p;
- for(p = updated.begin(); p != updated.end(); ++p)
- {
- if(helper._serverInstances.find(p->first) == helper._serverInstances.end() &&
- helper._servers.find(p->first) == helper._servers.end())
- {
- out << nl << "server `" << p->first << "' added";
- }
- }
- for(p = updated.begin(); p != updated.end(); ++p)
- {
- if(helper._serverInstances.find(p->first) != helper._serverInstances.end() ||
- helper._servers.find(p->first) != helper._servers.end())
- {
- out << nl << "server `" << p->first << "' updated";
- }
- }
- for(Ice::StringSeq::const_iterator q = removed.begin(); q != removed.end(); ++q)
- {
- out << nl << "server `" << *q << "' removed";
- }
- out << eb;
+ out << nl << "servers";
+ out << sb;
+ ServerInstanceHelperDict::const_iterator p;
+ for(p = updated.begin(); p != updated.end(); ++p)
+ {
+ if(helper._serverInstances.find(p->first) == helper._serverInstances.end() &&
+ helper._servers.find(p->first) == helper._servers.end())
+ {
+ out << nl << "server `" << p->first << "' added";
+ }
+ }
+ for(p = updated.begin(); p != updated.end(); ++p)
+ {
+ if(helper._serverInstances.find(p->first) != helper._serverInstances.end() ||
+ helper._servers.find(p->first) != helper._servers.end())
+ {
+ out << nl << "server `" << p->first << "' updated";
+ }
+ }
+ for(Ice::StringSeq::const_iterator q = removed.begin(); q != removed.end(); ++q)
+ {
+ out << nl << "server `" << *q << "' removed";
+ }
+ out << eb;
}
out << eb;
}
ApplicationHelper::ApplicationHelper(const Ice::CommunicatorPtr& communicator,
- const ApplicationDescriptor& desc,
- bool enableWarning,
- bool instantiate) :
+ const ApplicationDescriptor& desc,
+ bool enableWarning,
+ bool instantiate) :
_communicator(communicator),
_def(desc)
{
if(_def.name.empty())
{
- throw DeploymentException("invalid application: empty name");
+ throw DeploymentException("invalid application: empty name");
}
Resolver resolve(_def, communicator, enableWarning);
if(instantiate)
{
- //
- // Instantiate the application definition.
- //
- _instance.name = _def.name;
- _instance.variables = _def.variables;
- _instance.serverTemplates = _def.serverTemplates;
- _instance.serviceTemplates = _def.serviceTemplates;
- _instance.description = resolve(_def.description, "description");
- _instance.distrib = resolve(_def.distrib);
- _instance.propertySets = resolve(_def.propertySets);
-
- for(ReplicaGroupDescriptorSeq::iterator r = _def.replicaGroups.begin(); r != _def.replicaGroups.end(); ++r)
- {
- ReplicaGroupDescriptor desc;
- desc.id = resolve.asId(r->id, "replica group id", false);
- desc.description = resolve(r->description, "replica group description");
- desc.objects = resolve(r->objects, "replica group well-known");
- if(!r->loadBalancing)
- {
- resolve.exception("replica group load balancing is not set");
- }
- desc.loadBalancing = LoadBalancingPolicyPtr::dynamicCast(r->loadBalancing->ice_clone());
- desc.loadBalancing->nReplicas =
- resolve.asInt(r->loadBalancing->nReplicas, "replica group number of replicas");
- if(desc.loadBalancing->nReplicas.empty())
- {
- resolve.exception("invalid replica group load balancing number of replicas value: empty value");
- }
- else if(desc.loadBalancing->nReplicas[0] == '-')
- {
- resolve.exception("invalid replica group load balancing number of replicas value: inferior to 0");
- }
- AdaptiveLoadBalancingPolicyPtr al = AdaptiveLoadBalancingPolicyPtr::dynamicCast(desc.loadBalancing);
- if(al)
- {
- al->loadSample = resolve(al->loadSample, "replica group load sample");
- if(al->loadSample != "" && al->loadSample != "1" && al->loadSample != "5" && al->loadSample != "15")
- {
- resolve.exception("invalid load sample value (allowed values are 1, 5 or 15)");
- }
- }
- _instance.replicaGroups.push_back(desc);
- }
-
- //
- // Set the named property sets on the resolver. We use the
- // instantiated named property sets here -- named property sets
- // must be fully definied at the application level.
- //
- resolve.addPropertySets(_instance.propertySets);
+ //
+ // Instantiate the application definition.
+ //
+ _instance.name = _def.name;
+ _instance.variables = _def.variables;
+ _instance.serverTemplates = _def.serverTemplates;
+ _instance.serviceTemplates = _def.serviceTemplates;
+ _instance.description = resolve(_def.description, "description");
+ _instance.distrib = resolve(_def.distrib);
+ _instance.propertySets = resolve(_def.propertySets);
+
+ for(ReplicaGroupDescriptorSeq::iterator r = _def.replicaGroups.begin(); r != _def.replicaGroups.end(); ++r)
+ {
+ ReplicaGroupDescriptor desc;
+ desc.id = resolve.asId(r->id, "replica group id", false);
+ desc.description = resolve(r->description, "replica group description");
+ desc.objects = resolve(r->objects, "replica group well-known");
+ if(!r->loadBalancing)
+ {
+ resolve.exception("replica group load balancing is not set");
+ }
+ desc.loadBalancing = LoadBalancingPolicyPtr::dynamicCast(r->loadBalancing->ice_clone());
+ desc.loadBalancing->nReplicas =
+ resolve.asInt(r->loadBalancing->nReplicas, "replica group number of replicas");
+ if(desc.loadBalancing->nReplicas.empty())
+ {
+ resolve.exception("invalid replica group load balancing number of replicas value: empty value");
+ }
+ else if(desc.loadBalancing->nReplicas[0] == '-')
+ {
+ resolve.exception("invalid replica group load balancing number of replicas value: inferior to 0");
+ }
+ AdaptiveLoadBalancingPolicyPtr al = AdaptiveLoadBalancingPolicyPtr::dynamicCast(desc.loadBalancing);
+ if(al)
+ {
+ al->loadSample = resolve(al->loadSample, "replica group load sample");
+ if(al->loadSample != "" && al->loadSample != "1" && al->loadSample != "5" && al->loadSample != "15")
+ {
+ resolve.exception("invalid load sample value (allowed values are 1, 5 or 15)");
+ }
+ }
+ _instance.replicaGroups.push_back(desc);
+ }
+
+ //
+ // Set the named property sets on the resolver. We use the
+ // instantiated named property sets here -- named property sets
+ // must be fully definied at the application level.
+ //
+ resolve.addPropertySets(_instance.propertySets);
}
//
@@ -2558,11 +2558,11 @@ ApplicationHelper::ApplicationHelper(const Ice::CommunicatorPtr& communicator,
NodeHelperDict::const_iterator n;
for(NodeDescriptorDict::const_iterator p = _def.nodes.begin(); p != _def.nodes.end(); ++p)
{
- n = _nodes.insert(make_pair(p->first, NodeHelper(p->first, p->second, resolve, instantiate))).first;
- if(instantiate)
- {
- _instance.nodes.insert(make_pair(n->first, n->second.getInstance()));
- }
+ n = _nodes.insert(make_pair(p->first, NodeHelper(p->first, p->second, resolve, instantiate))).first;
+ if(instantiate)
+ {
+ _instance.nodes.insert(make_pair(n->first, n->second.getInstance()));
+ }
}
//
@@ -2571,52 +2571,52 @@ ApplicationHelper::ApplicationHelper(const Ice::CommunicatorPtr& communicator,
//
if(instantiate)
{
- multiset<string> serverIds;
- multiset<string> adapterIds;
- multiset<Ice::Identity> objectIds;
- for(n = _nodes.begin(); n != _nodes.end(); ++n)
- {
- n->second.getIds(serverIds, adapterIds, objectIds);
- }
-
- for(ReplicaGroupDescriptorSeq::iterator r = _def.replicaGroups.begin(); r != _def.replicaGroups.end(); ++r)
- {
- if(r->id.empty())
- {
- throw DeploymentException("replica group id is empty");
- }
- if(adapterIds.find(r->id) != adapterIds.end())
- {
- throw DeploymentException("duplicate replica group `" + r->id + "'");
- }
- adapterIds.insert(r->id);
- for(ObjectDescriptorSeq::const_iterator o = r->objects.begin(); o != r->objects.end(); ++o)
- {
- objectIds.insert(o->id);
- }
- }
-
- for(multiset<string>::const_iterator s = serverIds.begin(); s != serverIds.end(); ++s)
- {
- if(serverIds.count(*s) > 1)
- {
- resolve.exception("duplicate server `" + *s + "'");
- }
- }
- for(multiset<string>::const_iterator a = adapterIds.begin(); a != adapterIds.end(); ++a)
- {
- if(adapterIds.count(*a) > 1)
- {
- resolve.exception("duplicate adapter `" + *a + "'");
- }
- }
- for(multiset<Ice::Identity>::const_iterator o = objectIds.begin(); o != objectIds.end(); ++o)
- {
- if(objectIds.count(*o) > 1)
- {
- resolve.exception("duplicate object `" + _communicator->identityToString(*o) + "'");
- }
- }
+ multiset<string> serverIds;
+ multiset<string> adapterIds;
+ multiset<Ice::Identity> objectIds;
+ for(n = _nodes.begin(); n != _nodes.end(); ++n)
+ {
+ n->second.getIds(serverIds, adapterIds, objectIds);
+ }
+
+ for(ReplicaGroupDescriptorSeq::iterator r = _def.replicaGroups.begin(); r != _def.replicaGroups.end(); ++r)
+ {
+ if(r->id.empty())
+ {
+ throw DeploymentException("replica group id is empty");
+ }
+ if(adapterIds.find(r->id) != adapterIds.end())
+ {
+ throw DeploymentException("duplicate replica group `" + r->id + "'");
+ }
+ adapterIds.insert(r->id);
+ for(ObjectDescriptorSeq::const_iterator o = r->objects.begin(); o != r->objects.end(); ++o)
+ {
+ objectIds.insert(o->id);
+ }
+ }
+
+ for(multiset<string>::const_iterator s = serverIds.begin(); s != serverIds.end(); ++s)
+ {
+ if(serverIds.count(*s) > 1)
+ {
+ resolve.exception("duplicate server `" + *s + "'");
+ }
+ }
+ for(multiset<string>::const_iterator a = adapterIds.begin(); a != adapterIds.end(); ++a)
+ {
+ if(adapterIds.count(*a) > 1)
+ {
+ resolve.exception("duplicate adapter `" + *a + "'");
+ }
+ }
+ for(multiset<Ice::Identity>::const_iterator o = objectIds.begin(); o != objectIds.end(); ++o)
+ {
+ if(objectIds.count(*o) > 1)
+ {
+ resolve.exception("duplicate object `" + _communicator->identityToString(*o) + "'");
+ }
+ }
}
}
@@ -2629,7 +2629,7 @@ ApplicationHelper::diff(const ApplicationHelper& helper) const
updt.name = _def.name;
if(_def.description != helper._def.description)
{
- updt.description = new BoxedString(_def.description);
+ updt.description = new BoxedString(_def.description);
}
updt.variables = getDictUpdatedElts(helper._def.variables, _def.variables);
@@ -2640,7 +2640,7 @@ ApplicationHelper::diff(const ApplicationHelper& helper) const
if(_def.distrib != helper._def.distrib)
{
- updt.distrib = new BoxedDistributionDescriptor(_def.distrib);
+ updt.distrib = new BoxedDistributionDescriptor(_def.distrib);
}
GetReplicaGroupId rk;
@@ -2657,23 +2657,23 @@ ApplicationHelper::diff(const ApplicationHelper& helper) const
NodeHelperDict updated = getDictUpdatedElts(helper._nodes, _nodes);
for(NodeHelperDict::const_iterator p = updated.begin(); p != updated.end(); ++p)
{
- NodeHelperDict::const_iterator q = helper._nodes.find(p->first);
- if(q == helper._nodes.end())
- {
- NodeUpdateDescriptor nodeUpdate;
- const NodeDescriptor& node = p->second.getDefinition();
- nodeUpdate.name = p->first;
- nodeUpdate.variables = node.variables;
- nodeUpdate.servers = node.servers;
- nodeUpdate.serverInstances = node.serverInstances;
- nodeUpdate.loadFactor = new BoxedString(node.loadFactor);
- nodeUpdate.description = new BoxedString(node.description);
- updt.nodes.push_back(nodeUpdate);
- }
- else
- {
- updt.nodes.push_back(p->second.diff(q->second));
- }
+ NodeHelperDict::const_iterator q = helper._nodes.find(p->first);
+ if(q == helper._nodes.end())
+ {
+ NodeUpdateDescriptor nodeUpdate;
+ const NodeDescriptor& node = p->second.getDefinition();
+ nodeUpdate.name = p->first;
+ nodeUpdate.variables = node.variables;
+ nodeUpdate.servers = node.servers;
+ nodeUpdate.serverInstances = node.serverInstances;
+ nodeUpdate.loadFactor = new BoxedString(node.loadFactor);
+ nodeUpdate.description = new BoxedString(node.description);
+ updt.nodes.push_back(nodeUpdate);
+ }
+ else
+ {
+ updt.nodes.push_back(p->second.diff(q->second));
+ }
}
updt.removeNodes = getDictRemovedElts(helper._nodes, _nodes);
@@ -2698,50 +2698,50 @@ ApplicationHelper::update(const ApplicationUpdateDescriptor& updt) const
Resolver resolve(def, _communicator, false); // A resolver based on the *updated* application descriptor.
for(NodeUpdateDescriptorSeq::const_iterator p = updt.nodes.begin(); p != updt.nodes.end(); ++p)
{
- NodeHelperDict::const_iterator q = _nodes.find(p->name);
- if(q != _nodes.end()) // Updated node
- {
- //
- // COMPILERBUG: AIX xlC (Visual Age 6, 64bit builds)
- // requires the `desc' temporary here. We can't do the
- // update call in the make_pair call directly (this
- // results in a SEGFAULT at runtime).
- //
- NodeDescriptor desc = q->second.update(*p, resolve);
- def.nodes.insert(make_pair(p->name, desc));
- }
- else // New node
- {
- NodeDescriptor desc;
- desc.variables = p->variables;
- if(!p->removeVariables.empty())
- {
- resolve.exception("can't remove variables for node `" + p->name + "': node doesn't exist");
- }
- desc.propertySets = p->propertySets;
- if(!p->removePropertySets.empty())
- {
- resolve.exception("can't remove property sets for node `" + p->name + "': node doesn't exist");
- }
- desc.servers = p->servers;
- desc.serverInstances = p->serverInstances;
- if(!p->removeServers.empty())
- {
- resolve.exception("can't remove servers for node `" + p->name + "': node doesn't exist");
- }
- desc.loadFactor = p->loadFactor ? p->loadFactor->value : string("");
- desc.description = p->description ? p->description->value : string("");
- def.nodes.insert(make_pair(p->name, desc));
- }
+ NodeHelperDict::const_iterator q = _nodes.find(p->name);
+ if(q != _nodes.end()) // Updated node
+ {
+ //
+ // COMPILERBUG: AIX xlC (Visual Age 6, 64bit builds)
+ // requires the `desc' temporary here. We can't do the
+ // update call in the make_pair call directly (this
+ // results in a SEGFAULT at runtime).
+ //
+ NodeDescriptor desc = q->second.update(*p, resolve);
+ def.nodes.insert(make_pair(p->name, desc));
+ }
+ else // New node
+ {
+ NodeDescriptor desc;
+ desc.variables = p->variables;
+ if(!p->removeVariables.empty())
+ {
+ resolve.exception("can't remove variables for node `" + p->name + "': node doesn't exist");
+ }
+ desc.propertySets = p->propertySets;
+ if(!p->removePropertySets.empty())
+ {
+ resolve.exception("can't remove property sets for node `" + p->name + "': node doesn't exist");
+ }
+ desc.servers = p->servers;
+ desc.serverInstances = p->serverInstances;
+ if(!p->removeServers.empty())
+ {
+ resolve.exception("can't remove servers for node `" + p->name + "': node doesn't exist");
+ }
+ desc.loadFactor = p->loadFactor ? p->loadFactor->value : string("");
+ desc.description = p->description ? p->description->value : string("");
+ def.nodes.insert(make_pair(p->name, desc));
+ }
}
set<string> removedNodes(updt.removeNodes.begin(), updt.removeNodes.end());
for(NodeHelperDict::const_iterator n = _nodes.begin(); n != _nodes.end(); ++n)
{
- if(removedNodes.find(n->first) != removedNodes.end() || def.nodes.find(n->first) != def.nodes.end())
- {
- continue; // Node was removed or updated.
- }
- def.nodes.insert(make_pair(n->first, n->second.getDefinition()));
+ if(removedNodes.find(n->first) != removedNodes.end() || def.nodes.find(n->first) != def.nodes.end())
+ {
+ continue; // Node was removed or updated.
+ }
+ def.nodes.insert(make_pair(n->first, n->second.getDefinition()));
}
return def;
@@ -2754,24 +2754,24 @@ ApplicationHelper::upgrade(ApplicationDescriptor& desc) const
bool upgraded = false;
for(NodeHelperDict::const_iterator n = _nodes.begin(); n != _nodes.end(); ++n)
{
- NodeDescriptor nodeDesc;
- if(n->second.upgrade(nodeDesc))
- {
- desc.nodes[n->first] = nodeDesc;
- upgraded = true;
- }
+ NodeDescriptor nodeDesc;
+ if(n->second.upgrade(nodeDesc))
+ {
+ desc.nodes[n->first] = nodeDesc;
+ upgraded = true;
+ }
}
TemplateDescriptorDict::iterator t;
for(t = desc.serverTemplates.begin(); t != desc.serverTemplates.end(); ++t)
{
- ServerDescriptorPtr desc = ServerDescriptorPtr::dynamicCast(t->second.descriptor);
- upgraded |= createHelper(desc)->upgrade(t->second.descriptor);
+ ServerDescriptorPtr desc = ServerDescriptorPtr::dynamicCast(t->second.descriptor);
+ upgraded |= createHelper(desc)->upgrade(t->second.descriptor);
}
for(t = desc.serviceTemplates.begin(); t != desc.serviceTemplates.end(); ++t)
{
- ServiceDescriptorPtr desc = ServiceDescriptorPtr::dynamicCast(t->second.descriptor);
- upgraded |= ServiceHelper(desc).upgrade(t->second.descriptor);
+ ServiceDescriptorPtr desc = ServiceDescriptorPtr::dynamicCast(t->second.descriptor);
+ upgraded |= ServiceHelper(desc).upgrade(t->second.descriptor);
}
return upgraded;
@@ -2790,13 +2790,13 @@ ApplicationHelper::instantiateServer(const string& node, const ServerInstanceDes
NodeDescriptorDict::iterator q = def.nodes.find(node);
if(q == def.nodes.end())
{
- NodeDescriptor desc;
- desc.serverInstances.push_back(instance);
- def.nodes.insert(make_pair(node, desc));
+ NodeDescriptor desc;
+ desc.serverInstances.push_back(instance);
+ def.nodes.insert(make_pair(node, desc));
}
else
{
- q->second.serverInstances.push_back(instance);
+ q->second.serverInstances.push_back(instance);
}
return def;
}
@@ -2810,16 +2810,16 @@ ApplicationHelper::getIds(set<string>& serverIds, set<string>& adapterIds, set<I
for(NodeHelperDict::const_iterator p = _nodes.begin(); p != _nodes.end(); ++p)
{
- p->second.getIds(sIds, aIds, oIds);
+ p->second.getIds(sIds, aIds, oIds);
}
ReplicaGroupDescriptorSeq::const_iterator r;
for(r = _def.replicaGroups.begin(); r != _def.replicaGroups.end(); ++r)
{
- aIds.insert(r->id);
- for(ObjectDescriptorSeq::const_iterator o = r->objects.begin(); o != r->objects.end(); ++o)
- {
- oIds.insert(o->id);
- }
+ aIds.insert(r->id);
+ for(ObjectDescriptorSeq::const_iterator o = r->objects.begin(); o != r->objects.end(); ++o)
+ {
+ oIds.insert(o->id);
+ }
}
copy(sIds.begin(), sIds.end(), inserter(serverIds, serverIds.begin()));
@@ -2848,34 +2848,34 @@ ApplicationHelper::getServerInfos(const string& uuid, int revision) const
map<string, ServerInfo> servers;
for(NodeHelperDict::const_iterator n = _nodes.begin(); n != _nodes.end(); ++n)
{
- n->second.getServerInfos(_def.name, uuid, revision, servers);
+ n->second.getServerInfos(_def.name, uuid, revision, servers);
}
return servers;
}
void
ApplicationHelper::getDistributions(DistributionDescriptor& distribution,
- vector<string>& nodes,
- const string& server) const
+ vector<string>& nodes,
+ const string& server) const
{
assert(!_instance.name.empty());
distribution = _instance.distrib;
for(NodeHelperDict::const_iterator n = _nodes.begin(); n != _nodes.end(); ++n)
{
- if(n->second.hasDistributions(server))
- {
- nodes.push_back(n->first);
- if(!server.empty())
- {
- break;
- }
- }
- else if(!_instance.distrib.icepatch.empty() &&
- (server.empty() && n->second.hasServers() || n->second.hasServer(server)))
- {
- nodes.push_back(n->first);
- }
+ if(n->second.hasDistributions(server))
+ {
+ nodes.push_back(n->first);
+ if(!server.empty())
+ {
+ break;
+ }
+ }
+ else if(!_instance.distrib.icepatch.empty() &&
+ (server.empty() && n->second.hasServers() || n->second.hasServer(server)))
+ {
+ nodes.push_back(n->first);
+ }
}
}
@@ -2895,109 +2895,109 @@ ApplicationHelper::print(Output& out, const ApplicationInfo& info) const
if(!_instance.description.empty())
{
- out << nl << "description = `" << _instance.description << "'";
+ out << nl << "description = `" << _instance.description << "'";
}
if(!_instance.variables.empty())
{
- out << nl << "variables";
- out << sb;
- for(StringStringDict::const_iterator p = _instance.variables.begin(); p != _instance.variables.end();
- ++p)
- {
- out << nl << p->first << " = `" << p->second << "'";
- }
- out << eb;
+ out << nl << "variables";
+ out << sb;
+ for(StringStringDict::const_iterator p = _instance.variables.begin(); p != _instance.variables.end();
+ ++p)
+ {
+ out << nl << p->first << " = `" << p->second << "'";
+ }
+ out << eb;
}
if(!_instance.propertySets.empty())
{
- PropertySetDescriptorDict::const_iterator q;
- for(q = _instance.propertySets.begin(); q != _instance.propertySets.end(); ++q)
- {
- out << nl << "properties `" << q->first << "'";
- out << sb;
- if(!q->second.references.empty())
- {
- out << nl << "references = " << toString(q->second.references);
- }
- PropertyDescriptorSeq::const_iterator r;
- for(r = q->second.properties.begin(); r != q->second.properties.end(); ++r)
- {
- out << nl << r->name << " = `" << r->value << "'";
- }
- out << eb;
- }
+ PropertySetDescriptorDict::const_iterator q;
+ for(q = _instance.propertySets.begin(); q != _instance.propertySets.end(); ++q)
+ {
+ out << nl << "properties `" << q->first << "'";
+ out << sb;
+ if(!q->second.references.empty())
+ {
+ out << nl << "references = " << toString(q->second.references);
+ }
+ PropertyDescriptorSeq::const_iterator r;
+ for(r = q->second.properties.begin(); r != q->second.properties.end(); ++r)
+ {
+ out << nl << r->name << " = `" << r->value << "'";
+ }
+ out << eb;
+ }
}
if(!_instance.distrib.icepatch.empty())
{
- out << nl << "distribution";
- out << sb;
- out << nl << "proxy = `" << _instance.distrib.icepatch << "'";
- if(!_instance.distrib.directories.empty())
- {
- out << nl << "directories = `" << toString(_instance.distrib.directories) << "'";
- }
- out << eb;
+ out << nl << "distribution";
+ out << sb;
+ out << nl << "proxy = `" << _instance.distrib.icepatch << "'";
+ if(!_instance.distrib.directories.empty())
+ {
+ out << nl << "directories = `" << toString(_instance.distrib.directories) << "'";
+ }
+ out << eb;
}
if(!_instance.replicaGroups.empty())
{
- out << nl << "replica groups";
- out << sb;
- ReplicaGroupDescriptorSeq::const_iterator p;
- for(p = _instance.replicaGroups.begin(); p != _instance.replicaGroups.end(); ++p)
- {
- out << nl << "id = `" << p->id << "' load balancing = `";
- if(!p->loadBalancing)
- {
- out << "default (return all endpoints)";
- }
- else if(RandomLoadBalancingPolicyPtr::dynamicCast(p->loadBalancing))
- {
- out << "random";
- }
- else if(RoundRobinLoadBalancingPolicyPtr::dynamicCast(p->loadBalancing))
- {
- out << "round-robin";
- }
- else if(AdaptiveLoadBalancingPolicyPtr::dynamicCast(p->loadBalancing))
- {
- out << "adaptive" ;
- }
- else
- {
- out << "<unknown load balancing policy>";
- }
- out << "'";
- }
- out << eb;
+ out << nl << "replica groups";
+ out << sb;
+ ReplicaGroupDescriptorSeq::const_iterator p;
+ for(p = _instance.replicaGroups.begin(); p != _instance.replicaGroups.end(); ++p)
+ {
+ out << nl << "id = `" << p->id << "' load balancing = `";
+ if(!p->loadBalancing)
+ {
+ out << "default (return all endpoints)";
+ }
+ else if(RandomLoadBalancingPolicyPtr::dynamicCast(p->loadBalancing))
+ {
+ out << "random";
+ }
+ else if(RoundRobinLoadBalancingPolicyPtr::dynamicCast(p->loadBalancing))
+ {
+ out << "round-robin";
+ }
+ else if(AdaptiveLoadBalancingPolicyPtr::dynamicCast(p->loadBalancing))
+ {
+ out << "adaptive" ;
+ }
+ else
+ {
+ out << "<unknown load balancing policy>";
+ }
+ out << "'";
+ }
+ out << eb;
}
if(!_instance.serverTemplates.empty())
{
- out << nl << "server templates";
- out << sb;
- TemplateDescriptorDict::const_iterator p;
- for(p = _instance.serverTemplates.begin(); p != _instance.serverTemplates.end(); ++p)
- {
- out << nl << p->first;
- }
- out << eb;
+ out << nl << "server templates";
+ out << sb;
+ TemplateDescriptorDict::const_iterator p;
+ for(p = _instance.serverTemplates.begin(); p != _instance.serverTemplates.end(); ++p)
+ {
+ out << nl << p->first;
+ }
+ out << eb;
}
if(!_instance.serviceTemplates.empty())
{
- out << nl << "service templates";
- out << sb;
- TemplateDescriptorDict::const_iterator p;
- for(p = _instance.serviceTemplates.begin(); p != _instance.serviceTemplates.end(); ++p)
- {
- out << nl << p->first;
- }
- out << eb;
+ out << nl << "service templates";
+ out << sb;
+ TemplateDescriptorDict::const_iterator p;
+ for(p = _instance.serviceTemplates.begin(); p != _instance.serviceTemplates.end(); ++p)
+ {
+ out << nl << p->first;
+ }
+ out << eb;
}
if(!_nodes.empty())
{
- for(NodeHelperDict::const_iterator p = _nodes.begin(); p != _nodes.end(); ++p)
- {
- p->second.print(out);
- }
+ for(NodeHelperDict::const_iterator p = _nodes.begin(); p != _nodes.end(); ++p)
+ {
+ p->second.print(out);
+ }
}
out << eb;
}
@@ -3011,157 +3011,157 @@ ApplicationHelper::printDiff(Output& out, const ApplicationHelper& helper) const
out << sb;
{
- map<string, string> variables = getDictUpdatedElts(helper._def.variables, _def.variables);
- Ice::StringSeq removeVariables = getDictRemovedElts(helper._def.variables, _def.variables);
- if(!variables.empty() || !removeVariables.empty())
- {
- out << nl << "variables udpated";
- }
- }
- {
- if(_def.distrib != helper._def.distrib)
- {
- out << nl << "distribution updated";
- }
- }
- {
- PropertySetDescriptorDict updt = getDictUpdatedElts(helper._def.propertySets, _def.propertySets);
- Ice::StringSeq removed = getDictRemovedElts(helper._def.propertySets, _def.propertySets);
- if(!updt.empty() || !removed.empty())
- {
- out << nl << "property sets udpated";
- }
- }
- {
- GetReplicaGroupId rk;
- ReplicaGroupEq req;
- ReplicaGroupDescriptorSeq updated =
- getSeqUpdatedEltsWithEq(helper._def.replicaGroups, _def.replicaGroups, rk, req);
- Ice::StringSeq removed = getSeqRemovedElts(helper._def.replicaGroups, _def.replicaGroups, rk);
- if(!updated.empty() || !removed.empty())
- {
- out << nl << "replica groups";
- out << sb;
- ReplicaGroupDescriptorSeq::iterator p = updated.begin();
- while(p != updated.end())
- {
- ReplicaGroupDescriptorSeq::const_iterator r;
- for(r = helper._def.replicaGroups.begin(); r != helper._def.replicaGroups.end();
- ++r)
- {
- if(p->id == r->id)
- {
- out << nl << "replica group `" << r->id << "' updated";
- p = updated.erase(p);
- break;
- }
- }
- if(r == helper._def.replicaGroups.end())
- {
- ++p;
- }
- }
- for(p = updated.begin(); p != updated.end(); ++p)
- {
- out << nl << "replica group `" << p->id << "' added";
- }
- for(Ice::StringSeq::const_iterator q = removed.begin(); q != removed.end(); ++q)
- {
- out << nl << "replica group `" << *q << "' removed";
- }
- out << eb;
- }
- }
-
- {
- TemplateDescriptorEqual eq;
- TemplateDescriptorDict updated;
- updated = getDictUpdatedEltsWithEq(helper._def.serverTemplates, _def.serverTemplates, eq);
- Ice::StringSeq removed = getDictRemovedElts(helper._def.serverTemplates, _def.serverTemplates);
- if(!updated.empty() || !removed.empty())
- {
- out << nl << "server templates";
- out << sb;
- for(TemplateDescriptorDict::const_iterator p = updated.begin(); p != updated.end(); ++p)
- {
- if(helper._def.serverTemplates.find(p->first) == helper._def.serverTemplates.end())
- {
- out << nl << "server template `" << p->first << "' added";
- }
- }
- for(TemplateDescriptorDict::const_iterator q = updated.begin(); q != updated.end(); ++q)
- {
- if(helper._def.serverTemplates.find(q->first) != helper._def.serverTemplates.end())
- {
- out << nl << "server template `" << q->first << "' updated";
- }
- }
- for(Ice::StringSeq::const_iterator r = removed.begin(); r != removed.end(); ++r)
- {
- out << nl << "server template `" << *r << "' removed";
- }
- out << eb;
- }
- }
- {
- TemplateDescriptorEqual eq;
- TemplateDescriptorDict updated;
- updated = getDictUpdatedEltsWithEq(helper._def.serviceTemplates, _def.serviceTemplates, eq);
- Ice::StringSeq removed = getDictRemovedElts(helper._def.serviceTemplates, _def.serviceTemplates);
- if(!updated.empty() || !removed.empty())
- {
- out << nl << "service templates";
- out << sb;
- for(TemplateDescriptorDict::const_iterator p = updated.begin(); p != updated.end(); ++p)
- {
- if(helper._def.serviceTemplates.find(p->first) == helper._def.serviceTemplates.end())
- {
- out << nl << "service template `" << p->first << "' added";
- }
- }
- for(TemplateDescriptorDict::const_iterator q = updated.begin(); q != updated.end(); ++q)
- {
- if(helper._def.serviceTemplates.find(q->first) != helper._def.serviceTemplates.end())
- {
- out << nl << "service template `" << q->first << "' updated";
- }
- }
- for(Ice::StringSeq::const_iterator r = removed.begin(); r != removed.end(); ++r)
- {
- out << nl << "service template `" << *r << "' removed";
- }
- out << eb;
- }
- }
- {
- NodeHelperDict updated = getDictUpdatedElts(helper._nodes, _nodes);
- Ice::StringSeq removed = getDictRemovedElts(helper._nodes, _nodes);
- if(!updated.empty() || !removed.empty())
- {
- out << nl << "nodes";
- out << sb;
- for(NodeHelperDict::const_iterator p = updated.begin(); p != updated.end(); ++p)
- {
- NodeHelperDict::const_iterator q = helper._nodes.find(p->first);
- if(q == helper._nodes.end())
- {
- p->second.print(out);
- }
- }
- for(NodeHelperDict::const_iterator r = updated.begin(); r != updated.end(); ++r)
- {
- NodeHelperDict::const_iterator q = helper._nodes.find(r->first);
- if(q != helper._nodes.end())
- {
- r->second.printDiff(out, q->second);
- }
- }
- for(Ice::StringSeq::const_iterator s = removed.begin(); s != removed.end(); ++s)
- {
- out << nl << "node `" << *s << "' removed";
- }
- out << eb;
- }
+ map<string, string> variables = getDictUpdatedElts(helper._def.variables, _def.variables);
+ Ice::StringSeq removeVariables = getDictRemovedElts(helper._def.variables, _def.variables);
+ if(!variables.empty() || !removeVariables.empty())
+ {
+ out << nl << "variables udpated";
+ }
+ }
+ {
+ if(_def.distrib != helper._def.distrib)
+ {
+ out << nl << "distribution updated";
+ }
+ }
+ {
+ PropertySetDescriptorDict updt = getDictUpdatedElts(helper._def.propertySets, _def.propertySets);
+ Ice::StringSeq removed = getDictRemovedElts(helper._def.propertySets, _def.propertySets);
+ if(!updt.empty() || !removed.empty())
+ {
+ out << nl << "property sets udpated";
+ }
+ }
+ {
+ GetReplicaGroupId rk;
+ ReplicaGroupEq req;
+ ReplicaGroupDescriptorSeq updated =
+ getSeqUpdatedEltsWithEq(helper._def.replicaGroups, _def.replicaGroups, rk, req);
+ Ice::StringSeq removed = getSeqRemovedElts(helper._def.replicaGroups, _def.replicaGroups, rk);
+ if(!updated.empty() || !removed.empty())
+ {
+ out << nl << "replica groups";
+ out << sb;
+ ReplicaGroupDescriptorSeq::iterator p = updated.begin();
+ while(p != updated.end())
+ {
+ ReplicaGroupDescriptorSeq::const_iterator r;
+ for(r = helper._def.replicaGroups.begin(); r != helper._def.replicaGroups.end();
+ ++r)
+ {
+ if(p->id == r->id)
+ {
+ out << nl << "replica group `" << r->id << "' updated";
+ p = updated.erase(p);
+ break;
+ }
+ }
+ if(r == helper._def.replicaGroups.end())
+ {
+ ++p;
+ }
+ }
+ for(p = updated.begin(); p != updated.end(); ++p)
+ {
+ out << nl << "replica group `" << p->id << "' added";
+ }
+ for(Ice::StringSeq::const_iterator q = removed.begin(); q != removed.end(); ++q)
+ {
+ out << nl << "replica group `" << *q << "' removed";
+ }
+ out << eb;
+ }
+ }
+
+ {
+ TemplateDescriptorEqual eq;
+ TemplateDescriptorDict updated;
+ updated = getDictUpdatedEltsWithEq(helper._def.serverTemplates, _def.serverTemplates, eq);
+ Ice::StringSeq removed = getDictRemovedElts(helper._def.serverTemplates, _def.serverTemplates);
+ if(!updated.empty() || !removed.empty())
+ {
+ out << nl << "server templates";
+ out << sb;
+ for(TemplateDescriptorDict::const_iterator p = updated.begin(); p != updated.end(); ++p)
+ {
+ if(helper._def.serverTemplates.find(p->first) == helper._def.serverTemplates.end())
+ {
+ out << nl << "server template `" << p->first << "' added";
+ }
+ }
+ for(TemplateDescriptorDict::const_iterator q = updated.begin(); q != updated.end(); ++q)
+ {
+ if(helper._def.serverTemplates.find(q->first) != helper._def.serverTemplates.end())
+ {
+ out << nl << "server template `" << q->first << "' updated";
+ }
+ }
+ for(Ice::StringSeq::const_iterator r = removed.begin(); r != removed.end(); ++r)
+ {
+ out << nl << "server template `" << *r << "' removed";
+ }
+ out << eb;
+ }
+ }
+ {
+ TemplateDescriptorEqual eq;
+ TemplateDescriptorDict updated;
+ updated = getDictUpdatedEltsWithEq(helper._def.serviceTemplates, _def.serviceTemplates, eq);
+ Ice::StringSeq removed = getDictRemovedElts(helper._def.serviceTemplates, _def.serviceTemplates);
+ if(!updated.empty() || !removed.empty())
+ {
+ out << nl << "service templates";
+ out << sb;
+ for(TemplateDescriptorDict::const_iterator p = updated.begin(); p != updated.end(); ++p)
+ {
+ if(helper._def.serviceTemplates.find(p->first) == helper._def.serviceTemplates.end())
+ {
+ out << nl << "service template `" << p->first << "' added";
+ }
+ }
+ for(TemplateDescriptorDict::const_iterator q = updated.begin(); q != updated.end(); ++q)
+ {
+ if(helper._def.serviceTemplates.find(q->first) != helper._def.serviceTemplates.end())
+ {
+ out << nl << "service template `" << q->first << "' updated";
+ }
+ }
+ for(Ice::StringSeq::const_iterator r = removed.begin(); r != removed.end(); ++r)
+ {
+ out << nl << "service template `" << *r << "' removed";
+ }
+ out << eb;
+ }
+ }
+ {
+ NodeHelperDict updated = getDictUpdatedElts(helper._nodes, _nodes);
+ Ice::StringSeq removed = getDictRemovedElts(helper._nodes, _nodes);
+ if(!updated.empty() || !removed.empty())
+ {
+ out << nl << "nodes";
+ out << sb;
+ for(NodeHelperDict::const_iterator p = updated.begin(); p != updated.end(); ++p)
+ {
+ NodeHelperDict::const_iterator q = helper._nodes.find(p->first);
+ if(q == helper._nodes.end())
+ {
+ p->second.print(out);
+ }
+ }
+ for(NodeHelperDict::const_iterator r = updated.begin(); r != updated.end(); ++r)
+ {
+ NodeHelperDict::const_iterator q = helper._nodes.find(r->first);
+ if(q != helper._nodes.end())
+ {
+ r->second.printDiff(out, q->second);
+ }
+ }
+ for(Ice::StringSeq::const_iterator s = removed.begin(); s != removed.end(); ++s)
+ {
+ out << nl << "node `" << *s << "' removed";
+ }
+ out << eb;
+ }
}
out << eb;
}
@@ -3173,15 +3173,15 @@ IceGrid::descriptorEqual(const ServerDescriptorPtr& lhs, const ServerDescriptorP
IceBoxDescriptorPtr rhsIceBox = IceBoxDescriptorPtr::dynamicCast(rhs);
if(lhsIceBox && rhsIceBox)
{
- return IceBoxHelper(lhsIceBox) == IceBoxHelper(rhsIceBox);
+ return IceBoxHelper(lhsIceBox) == IceBoxHelper(rhsIceBox);
}
else if(!lhsIceBox && !rhsIceBox)
{
- return ServerHelper(lhs) == ServerHelper(rhs);
+ return ServerHelper(lhs) == ServerHelper(rhs);
}
else
{
- return false;
+ return false;
}
}
@@ -3191,10 +3191,10 @@ IceGrid::createHelper(const ServerDescriptorPtr& desc)
IceBoxDescriptorPtr iceBox = IceBoxDescriptorPtr::dynamicCast(desc);
if(iceBox)
{
- return new IceBoxHelper(iceBox);
+ return new IceBoxHelper(iceBox);
}
else
{
- return new ServerHelper(desc);
+ return new ServerHelper(desc);
}
}
diff --git a/cpp/src/IceGrid/DescriptorHelper.h b/cpp/src/IceGrid/DescriptorHelper.h
index 6ca60f0a170..2564d68d18d 100644
--- a/cpp/src/IceGrid/DescriptorHelper.h
+++ b/cpp/src/IceGrid/DescriptorHelper.h
@@ -120,14 +120,14 @@ public:
ServiceDescriptorPtr getDescriptor() const;
ServiceDescriptorPtr instantiate(const Resolver&, const PropertyDescriptorSeq&,
- const PropertySetDescriptorDict&) const;
+ const PropertySetDescriptorDict&) const;
void print(const Ice::CommunicatorPtr&, IceUtil::Output&) const;
protected:
void instantiateImpl(const ServiceDescriptorPtr&, const Resolver&, const PropertyDescriptorSeq&,
- const PropertySetDescriptorDict&) const;
+ const PropertySetDescriptorDict&) const;
private:
@@ -146,7 +146,7 @@ public:
ServerDescriptorPtr getDescriptor() const;
virtual ServerDescriptorPtr instantiate(const Resolver&, const PropertyDescriptorSeq&,
- const PropertySetDescriptorDict&) const;
+ const PropertySetDescriptorDict&) const;
void print(const Ice::CommunicatorPtr&, IceUtil::Output&) const;
void print(const Ice::CommunicatorPtr&, IceUtil::Output&, const ServerInfo&) const;
@@ -167,10 +167,10 @@ class InstanceHelper
protected:
std::map<std::string, std::string> instantiateParams(const Resolver&,
- const std::string&,
- const std::map<std::string, std::string>&,
- const std::vector<std::string>&,
- const std::map<std::string, std::string>&) const;
+ const std::string&,
+ const std::map<std::string, std::string>&,
+ const std::vector<std::string>&,
+ const std::map<std::string, std::string>&) const;
};
@@ -206,7 +206,7 @@ public:
bool operator!=(const IceBoxHelper&) const;
virtual ServerDescriptorPtr instantiate(const Resolver&, const PropertyDescriptorSeq&,
- const PropertySetDescriptorDict&) const;
+ const PropertySetDescriptorDict&) const;
virtual void getIds(std::multiset<std::string>&, std::multiset<Ice::Identity>&) const;
@@ -218,7 +218,7 @@ public:
protected:
void instantiateImpl(const IceBoxDescriptorPtr&, const Resolver&, const PropertyDescriptorSeq&,
- const PropertySetDescriptorDict&) const;
+ const PropertySetDescriptorDict&) const;
private:
diff --git a/cpp/src/IceGrid/DescriptorParser.cpp b/cpp/src/IceGrid/DescriptorParser.cpp
index 4fd68f57a7f..fac00758c70 100644
--- a/cpp/src/IceGrid/DescriptorParser.cpp
+++ b/cpp/src/IceGrid/DescriptorParser.cpp
@@ -114,366 +114,366 @@ DescriptorHandler::startElement(const string& name, const IceXML::Attributes& at
try
{
- if(name == "icegrid")
- {
- if(!_isTopLevel)
- {
- error("element <icegrid> is a top level element");
- }
- _isTopLevel = false;
- }
- else if(_isTopLevel)
- {
- error("only the <icegrid> element is allowed at the top-level");
- }
- else if(name == "target")
- {
- if(!_isCurrentTargetDeployable)
- {
- ++_targetCounter;
- }
- else
- {
- _isCurrentTargetDeployable = isTargetDeployable(attributes("name"));
- _targetCounter = 1;
- return;
- }
- }
- else if(!isCurrentTargetDeployable())
- {
- //
- // We don't bother to parse the elements if the elements are enclosed in a target element
- // which won't be deployed.
- //
- attributes.asMap();
- return;
- }
- else if(name == "include")
- {
- string targets = attributes("targets", "");
- string file = attributes("file");
- if(file[0] != '/')
- {
- string::size_type end = _filename.find_last_of('/');
- if(end != string::npos)
- {
- file = _filename.substr(0, end) + "/" + file;
- }
- }
-
- string oldFileName = _filename;
- vector<string> oldTargets = _targets;
- _isTopLevel = true;
- _filename = file;
- _targets = getTargets(targets);
-
- IceXML::Parser::parse(file, *this);
-
- _filename = oldFileName;
- _targets = oldTargets;
- }
- else if(name == "application")
- {
- if(_currentApplication.get())
- {
- error("only one <application> element is allowed");
- }
-
- bool importTemplates = attributes.asBool("import-default-templates", false);
-
- //
- // TODO: is ignoring importTemplates the desired behavior when _admin == 0?
- //
- if(importTemplates && _admin != 0)
- {
- try
- {
- ApplicationDescriptor application = _admin->getDefaultApplicationDescriptor();
- _currentApplication.reset(new ApplicationDescriptorBuilder(_communicator, application,
- attributes, _overrides));
- }
- catch(const DeploymentException& ex)
- {
- throw ex.reason;
- }
- }
- else
- {
- _currentApplication.reset(new ApplicationDescriptorBuilder(_communicator, attributes, _overrides));
- }
- }
- else if(name == "node")
- {
- if(!_currentApplication.get())
- {
- error("the <node> element can only be a child of an <application> element");
- }
- _currentNode.reset(_currentApplication->createNode(attributes));
- }
- else if(name == "server-instance")
- {
- if(!_currentNode.get() || _currentServer.get())
- {
- error("the <server-instance> element can only be a child of a <node> element");
- }
- _currentServerInstance.reset(_currentNode->createServerInstance(attributes));
- }
- else if(name == "server")
- {
- if(!_currentNode.get() && !_currentTemplate.get() || _currentServer.get())
- {
- error("the <server> element can only be a child of a <node> or <server-template> element");
- }
- if(_currentNode.get())
- {
- _currentServer.reset(_currentNode->createServer(attributes));
- }
- else
- {
- _currentServer.reset(_currentTemplate->createServer(attributes));
- }
- _currentCommunicator = _currentServer.get();
- }
- else if(name == "icebox")
- {
- if(!_currentNode.get() && !_currentTemplate.get() || _currentServer.get())
- {
- error("the <icebox> element can only be a child of a <node> or <server-template> element");
- }
- if(_currentNode.get())
- {
- _currentServer.reset(_currentNode->createIceBox(attributes));
- }
- else
- {
- _currentServer.reset(_currentTemplate->createIceBox(attributes));
- }
- _currentCommunicator = _currentServer.get();
- }
- else if(name == "server-template")
- {
- if(!_currentApplication.get() || _currentTemplate.get() || _currentNode.get())
- {
- error("the <server-template> element can only be a child of an <application> element");
- }
- _currentTemplate.reset(_currentApplication->createServerTemplate(attributes));
- }
- else if(name == "service-instance")
- {
- if(!_currentServer.get())
- {
- error("the <service-instance> element can only be a child of an <icebox> element");
- }
- _currentServiceInstance.reset(_currentServer->createServiceInstance(attributes));
- }
- else if(name == "service")
- {
- if(!_currentServer.get() && !_currentTemplate.get() || _currentService.get())
- {
- error("the <service> element can only be a child of an <icebox> or <service-template> element");
- }
-
- if(_currentServer.get())
- {
- _currentService.reset(_currentServer->createService(attributes));
- }
- else
- {
- _currentService.reset(_currentTemplate->createService(attributes));
- }
- _currentCommunicator = _currentService.get();
- }
- else if(name == "service-template")
- {
- if(!_currentApplication.get() || _currentNode.get() || _currentTemplate.get())
- {
- error("the <service-template> element can only be a child of an <application> element");
- }
-
- _currentTemplate.reset(_currentApplication->createServiceTemplate(attributes));
- }
- else if(name == "replica-group")
- {
- if(!_currentApplication.get())
- {
- error("the <replica-group> element can only be a child of an <application> element");
- }
- _currentApplication->addReplicaGroup(attributes);
- _inReplicaGroup = true;
- }
- else if(name == "load-balancing")
- {
- if(!_inReplicaGroup)
- {
- error("the <load-balancing> element can only be a child of a <replica-group> element");
- }
- _currentApplication->setLoadBalancing(attributes);
- }
- else if(name == "variable")
- {
- if(_currentNode.get())
- {
- _currentNode->addVariable(attributes);
- }
- else if(_currentApplication.get())
- {
- _currentApplication->addVariable(attributes);
- }
- else
- {
- error("the <variable> element can only be a child of an <application> or <node> element");
- }
- }
- else if(name == "parameter")
- {
- if(!_currentTemplate.get())
- {
- error("the <parameter> element can only be a child of a <template> element");
- }
- _currentTemplate->addParameter(attributes);
- }
- else if(name == "properties")
- {
- if(_currentPropertySet.get())
- {
- _currentPropertySet->addPropertySet(attributes);
- }
- else if(_currentServiceInstance.get())
- {
- _currentPropertySet.reset(_currentServiceInstance->createPropertySet());
- }
- else if(_currentServerInstance.get())
- {
- _currentPropertySet.reset(_currentServerInstance->createPropertySet(attributes));
- }
- else if(_currentCommunicator)
- {
- _currentPropertySet.reset(_currentCommunicator->createPropertySet());
- }
- else if(_currentNode.get())
- {
- _currentPropertySet.reset(_currentNode->createPropertySet(attributes));
- }
- else if(_currentApplication.get() && !_currentTemplate.get())
- {
- _currentPropertySet.reset(_currentApplication->createPropertySet(attributes));
- }
- else
- {
- error("the <properties> element is not allowed here");
- }
- }
- else if(name == "property")
- {
- if(_currentPropertySet.get())
- {
- _currentPropertySet->addProperty(attributes);
- }
- else if(_currentCommunicator)
- {
- _currentCommunicator->addProperty(attributes);
- }
- else
- {
- error("the <property> element can only be a child of a <properties>, <icebox>, <server> or <service> "
- "element");
- }
- }
- else if(name == "adapter")
- {
- if(!_currentCommunicator)
- {
- error("the <adapter> element can only be a child of a <server> or <service> element");
- }
- _currentCommunicator->addAdapter(attributes);
- _inAdapter = true;
- }
- else if(name == "object")
- {
- if(!_inAdapter && !_inReplicaGroup)
- {
- error("the <object> element can only be a child of an <adapter> or <replica-group> element");
- }
- if(_inReplicaGroup)
- {
- _currentApplication->addObject(attributes);
- }
- else
- {
- _currentCommunicator->addObject(attributes);
- }
- }
- else if(name == "allocatable")
- {
- if(!_inAdapter)
- {
- error("the <allocatable> element can only be a child of an <adapter> element");
- }
- _currentCommunicator->addAllocatable(attributes);
- }
- else if(name == "distrib")
- {
- if(!_currentApplication.get() ||
- (_currentNode.get() || _currentTemplate.get()) && !_currentServer.get() ||
- _currentServer.get() != _currentCommunicator)
- {
- error("the <distrib> element can only be a child of an <application>, <server> or <icebox> element");
- }
- if(!_currentServer.get())
- {
- _currentApplication->addDistribution(attributes);
- }
- else
- {
- _currentServer->addDistribution(attributes);
- }
- _inDistrib = true;
- }
- else if(name == "dbenv")
- {
- if(!_currentCommunicator)
- {
- error("the <dbenv> element can only be a child of a <server> or <service> element");
- }
- _currentCommunicator->addDbEnv(attributes);
- _inDbEnv = true;
- }
- else if(name == "log")
- {
- if(!_currentCommunicator)
- {
- error("the <log> element can only be a child of a <server> or <service> element");
- }
- _currentCommunicator->addLog(attributes);
- }
- else if(name == "dbproperty")
- {
- if(!_inDbEnv)
- {
- error("the <dbproperty> element can only be a child of a <dbenv> element");
- }
- _currentCommunicator->addDbEnvProperty(attributes);
- }
- else if(name == "description" || name == "option" || name == "env" || name == "directory")
- {
- //
- // Nothing to do.
- //
- }
- else
- {
- error("unknown element `" + name + "'");
- }
-
- attributes.checkUnknownAttributes();
+ if(name == "icegrid")
+ {
+ if(!_isTopLevel)
+ {
+ error("element <icegrid> is a top level element");
+ }
+ _isTopLevel = false;
+ }
+ else if(_isTopLevel)
+ {
+ error("only the <icegrid> element is allowed at the top-level");
+ }
+ else if(name == "target")
+ {
+ if(!_isCurrentTargetDeployable)
+ {
+ ++_targetCounter;
+ }
+ else
+ {
+ _isCurrentTargetDeployable = isTargetDeployable(attributes("name"));
+ _targetCounter = 1;
+ return;
+ }
+ }
+ else if(!isCurrentTargetDeployable())
+ {
+ //
+ // We don't bother to parse the elements if the elements are enclosed in a target element
+ // which won't be deployed.
+ //
+ attributes.asMap();
+ return;
+ }
+ else if(name == "include")
+ {
+ string targets = attributes("targets", "");
+ string file = attributes("file");
+ if(file[0] != '/')
+ {
+ string::size_type end = _filename.find_last_of('/');
+ if(end != string::npos)
+ {
+ file = _filename.substr(0, end) + "/" + file;
+ }
+ }
+
+ string oldFileName = _filename;
+ vector<string> oldTargets = _targets;
+ _isTopLevel = true;
+ _filename = file;
+ _targets = getTargets(targets);
+
+ IceXML::Parser::parse(file, *this);
+
+ _filename = oldFileName;
+ _targets = oldTargets;
+ }
+ else if(name == "application")
+ {
+ if(_currentApplication.get())
+ {
+ error("only one <application> element is allowed");
+ }
+
+ bool importTemplates = attributes.asBool("import-default-templates", false);
+
+ //
+ // TODO: is ignoring importTemplates the desired behavior when _admin == 0?
+ //
+ if(importTemplates && _admin != 0)
+ {
+ try
+ {
+ ApplicationDescriptor application = _admin->getDefaultApplicationDescriptor();
+ _currentApplication.reset(new ApplicationDescriptorBuilder(_communicator, application,
+ attributes, _overrides));
+ }
+ catch(const DeploymentException& ex)
+ {
+ throw ex.reason;
+ }
+ }
+ else
+ {
+ _currentApplication.reset(new ApplicationDescriptorBuilder(_communicator, attributes, _overrides));
+ }
+ }
+ else if(name == "node")
+ {
+ if(!_currentApplication.get())
+ {
+ error("the <node> element can only be a child of an <application> element");
+ }
+ _currentNode.reset(_currentApplication->createNode(attributes));
+ }
+ else if(name == "server-instance")
+ {
+ if(!_currentNode.get() || _currentServer.get())
+ {
+ error("the <server-instance> element can only be a child of a <node> element");
+ }
+ _currentServerInstance.reset(_currentNode->createServerInstance(attributes));
+ }
+ else if(name == "server")
+ {
+ if(!_currentNode.get() && !_currentTemplate.get() || _currentServer.get())
+ {
+ error("the <server> element can only be a child of a <node> or <server-template> element");
+ }
+ if(_currentNode.get())
+ {
+ _currentServer.reset(_currentNode->createServer(attributes));
+ }
+ else
+ {
+ _currentServer.reset(_currentTemplate->createServer(attributes));
+ }
+ _currentCommunicator = _currentServer.get();
+ }
+ else if(name == "icebox")
+ {
+ if(!_currentNode.get() && !_currentTemplate.get() || _currentServer.get())
+ {
+ error("the <icebox> element can only be a child of a <node> or <server-template> element");
+ }
+ if(_currentNode.get())
+ {
+ _currentServer.reset(_currentNode->createIceBox(attributes));
+ }
+ else
+ {
+ _currentServer.reset(_currentTemplate->createIceBox(attributes));
+ }
+ _currentCommunicator = _currentServer.get();
+ }
+ else if(name == "server-template")
+ {
+ if(!_currentApplication.get() || _currentTemplate.get() || _currentNode.get())
+ {
+ error("the <server-template> element can only be a child of an <application> element");
+ }
+ _currentTemplate.reset(_currentApplication->createServerTemplate(attributes));
+ }
+ else if(name == "service-instance")
+ {
+ if(!_currentServer.get())
+ {
+ error("the <service-instance> element can only be a child of an <icebox> element");
+ }
+ _currentServiceInstance.reset(_currentServer->createServiceInstance(attributes));
+ }
+ else if(name == "service")
+ {
+ if(!_currentServer.get() && !_currentTemplate.get() || _currentService.get())
+ {
+ error("the <service> element can only be a child of an <icebox> or <service-template> element");
+ }
+
+ if(_currentServer.get())
+ {
+ _currentService.reset(_currentServer->createService(attributes));
+ }
+ else
+ {
+ _currentService.reset(_currentTemplate->createService(attributes));
+ }
+ _currentCommunicator = _currentService.get();
+ }
+ else if(name == "service-template")
+ {
+ if(!_currentApplication.get() || _currentNode.get() || _currentTemplate.get())
+ {
+ error("the <service-template> element can only be a child of an <application> element");
+ }
+
+ _currentTemplate.reset(_currentApplication->createServiceTemplate(attributes));
+ }
+ else if(name == "replica-group")
+ {
+ if(!_currentApplication.get())
+ {
+ error("the <replica-group> element can only be a child of an <application> element");
+ }
+ _currentApplication->addReplicaGroup(attributes);
+ _inReplicaGroup = true;
+ }
+ else if(name == "load-balancing")
+ {
+ if(!_inReplicaGroup)
+ {
+ error("the <load-balancing> element can only be a child of a <replica-group> element");
+ }
+ _currentApplication->setLoadBalancing(attributes);
+ }
+ else if(name == "variable")
+ {
+ if(_currentNode.get())
+ {
+ _currentNode->addVariable(attributes);
+ }
+ else if(_currentApplication.get())
+ {
+ _currentApplication->addVariable(attributes);
+ }
+ else
+ {
+ error("the <variable> element can only be a child of an <application> or <node> element");
+ }
+ }
+ else if(name == "parameter")
+ {
+ if(!_currentTemplate.get())
+ {
+ error("the <parameter> element can only be a child of a <template> element");
+ }
+ _currentTemplate->addParameter(attributes);
+ }
+ else if(name == "properties")
+ {
+ if(_currentPropertySet.get())
+ {
+ _currentPropertySet->addPropertySet(attributes);
+ }
+ else if(_currentServiceInstance.get())
+ {
+ _currentPropertySet.reset(_currentServiceInstance->createPropertySet());
+ }
+ else if(_currentServerInstance.get())
+ {
+ _currentPropertySet.reset(_currentServerInstance->createPropertySet(attributes));
+ }
+ else if(_currentCommunicator)
+ {
+ _currentPropertySet.reset(_currentCommunicator->createPropertySet());
+ }
+ else if(_currentNode.get())
+ {
+ _currentPropertySet.reset(_currentNode->createPropertySet(attributes));
+ }
+ else if(_currentApplication.get() && !_currentTemplate.get())
+ {
+ _currentPropertySet.reset(_currentApplication->createPropertySet(attributes));
+ }
+ else
+ {
+ error("the <properties> element is not allowed here");
+ }
+ }
+ else if(name == "property")
+ {
+ if(_currentPropertySet.get())
+ {
+ _currentPropertySet->addProperty(attributes);
+ }
+ else if(_currentCommunicator)
+ {
+ _currentCommunicator->addProperty(attributes);
+ }
+ else
+ {
+ error("the <property> element can only be a child of a <properties>, <icebox>, <server> or <service> "
+ "element");
+ }
+ }
+ else if(name == "adapter")
+ {
+ if(!_currentCommunicator)
+ {
+ error("the <adapter> element can only be a child of a <server> or <service> element");
+ }
+ _currentCommunicator->addAdapter(attributes);
+ _inAdapter = true;
+ }
+ else if(name == "object")
+ {
+ if(!_inAdapter && !_inReplicaGroup)
+ {
+ error("the <object> element can only be a child of an <adapter> or <replica-group> element");
+ }
+ if(_inReplicaGroup)
+ {
+ _currentApplication->addObject(attributes);
+ }
+ else
+ {
+ _currentCommunicator->addObject(attributes);
+ }
+ }
+ else if(name == "allocatable")
+ {
+ if(!_inAdapter)
+ {
+ error("the <allocatable> element can only be a child of an <adapter> element");
+ }
+ _currentCommunicator->addAllocatable(attributes);
+ }
+ else if(name == "distrib")
+ {
+ if(!_currentApplication.get() ||
+ (_currentNode.get() || _currentTemplate.get()) && !_currentServer.get() ||
+ _currentServer.get() != _currentCommunicator)
+ {
+ error("the <distrib> element can only be a child of an <application>, <server> or <icebox> element");
+ }
+ if(!_currentServer.get())
+ {
+ _currentApplication->addDistribution(attributes);
+ }
+ else
+ {
+ _currentServer->addDistribution(attributes);
+ }
+ _inDistrib = true;
+ }
+ else if(name == "dbenv")
+ {
+ if(!_currentCommunicator)
+ {
+ error("the <dbenv> element can only be a child of a <server> or <service> element");
+ }
+ _currentCommunicator->addDbEnv(attributes);
+ _inDbEnv = true;
+ }
+ else if(name == "log")
+ {
+ if(!_currentCommunicator)
+ {
+ error("the <log> element can only be a child of a <server> or <service> element");
+ }
+ _currentCommunicator->addLog(attributes);
+ }
+ else if(name == "dbproperty")
+ {
+ if(!_inDbEnv)
+ {
+ error("the <dbproperty> element can only be a child of a <dbenv> element");
+ }
+ _currentCommunicator->addDbEnvProperty(attributes);
+ }
+ else if(name == "description" || name == "option" || name == "env" || name == "directory")
+ {
+ //
+ // Nothing to do.
+ //
+ }
+ else
+ {
+ error("unknown element `" + name + "'");
+ }
+
+ attributes.checkUnknownAttributes();
}
catch(const string& reason)
{
- error(reason);
+ error(reason);
}
catch(const char* reason)
{
- error(reason);
+ error(reason);
}
//
@@ -483,7 +483,7 @@ DescriptorHandler::startElement(const string& name, const IceXML::Attributes& at
string value = elementValue();
if(!value.empty() && value.find_first_not_of(" \t\r\n") != string::npos)
{
- error("invalid element value for element `" + _previousElementName + "'");
+ error("invalid element value for element `" + _previousElementName + "'");
}
_previousElementName = name;
}
@@ -496,206 +496,206 @@ DescriptorHandler::endElement(const string& name, int line, int column)
try
{
- if(name == "target")
- {
- if(!_isCurrentTargetDeployable && --_targetCounter == 0)
- {
- _isCurrentTargetDeployable = true;
- _targetCounter = 0;
- }
- return;
- }
- else if(!isCurrentTargetDeployable())
- {
- //
- // We don't bother to parse the elements if the elements are enclosed in a target element
- // which won't be deployed.
- //
- return;
- }
- else if(name == "node")
- {
- _currentApplication->addNode(_currentNode->getName(), _currentNode->getDescriptor());
- _currentNode.reset(0);
- }
- else if(name == "server" || name == "icebox")
- {
- assert(_currentServer.get());
- if(_currentTemplate.get())
- {
- _currentTemplate->setDescriptor(_currentServer->getDescriptor());
- }
- else
- {
- assert(_currentNode.get());
- _currentNode->addServer(_currentServer->getDescriptor());
- }
- _currentServer->finish();
- _currentServer.reset(0);
- _currentCommunicator = 0;
- }
- else if(name == "server-template")
- {
- assert(_currentApplication.get());
- _currentApplication->addServerTemplate(_currentTemplate->getId(), _currentTemplate->getDescriptor());
- _currentTemplate.reset(0);
- }
- else if(name == "service")
- {
- assert(_currentService.get());
- if(_currentServer.get())
- {
- _currentServer->addService(_currentService->getDescriptor());
- }
- else
- {
- _currentTemplate->setDescriptor(_currentService->getDescriptor());
- }
- _currentService->finish();
- _currentService.reset(0);
- _currentCommunicator = _currentServer.get();
- }
- else if(name == "service-template")
- {
- assert(_currentTemplate.get());
- _currentApplication->addServiceTemplate(_currentTemplate->getId(), _currentTemplate->getDescriptor());
- _currentTemplate.reset(0);
- }
- else if(name == "server-instance")
- {
- assert(_currentNode.get() && _currentServerInstance.get());
- _currentNode->addServerInstance(_currentServerInstance->getDescriptor());
- _currentServerInstance.reset(0);
- }
- else if(name == "service-instance")
- {
- assert(_currentServer.get() && _currentServiceInstance.get());
- _currentServer->addServiceInstance(_currentServiceInstance->getDescriptor());
- _currentServiceInstance.reset(0);
- }
- else if(name == "properties")
- {
- assert(_currentPropertySet.get());
- if(_currentPropertySet->finish())
- {
- if(_currentServiceInstance.get())
- {
- _currentServiceInstance->addPropertySet(_currentPropertySet->getDescriptor());
- }
- else if(_currentServerInstance.get())
- {
- _currentServerInstance->addPropertySet(_currentPropertySet->getService(),
- _currentPropertySet->getDescriptor());
- }
- else if(_currentCommunicator)
- {
- _currentCommunicator->addPropertySet(_currentPropertySet->getDescriptor());
- }
- else if(_currentNode.get())
- {
- _currentNode->addPropertySet(_currentPropertySet->getId(),
- _currentPropertySet->getDescriptor());
- }
- else if(_currentApplication.get())
- {
- _currentApplication->addPropertySet(_currentPropertySet->getId(),
- _currentPropertySet->getDescriptor());
- }
- else
- {
- assert(false);
- }
- _currentPropertySet.reset(0);
- }
- }
- else if(name == "description")
- {
- if(_inAdapter)
- {
- _currentCommunicator->setAdapterDescription(elementValue());
- }
- else if(_inReplicaGroup)
- {
- _currentApplication->setReplicaGroupDescription(elementValue());
- }
- else if(_inDbEnv)
- {
- assert(_currentCommunicator);
- _currentCommunicator->setDbEnvDescription(elementValue());
- }
- else if(_currentCommunicator)
- {
- _currentCommunicator->setDescription(elementValue());
- }
- else if(_currentNode.get())
- {
- _currentNode->setDescription(elementValue());
- }
- else if(_currentApplication.get())
- {
- _currentApplication->setDescription(elementValue());
- }
- else
- {
- error("element <description> is not allowed here");
- }
- }
- else if(name == "option")
- {
- if(!_currentServer.get())
- {
- error("element <option> can only be the child of a <server> element");
- }
- _currentServer->addOption(elementValue());
- }
- else if(name == "env")
- {
- if(!_currentServer.get())
- {
- error("element <env> can only be the child of a <server> element");
- }
- _currentServer->addEnv(elementValue());
- }
- else if(name == "directory")
- {
- if(!_inDistrib)
- {
- error("the <directory> element can only be a child of a <distrib> element");
- }
- if(!_currentServer.get())
- {
- _currentApplication->addDistributionDirectory(elementValue());
- }
- else
- {
- _currentServer->addDistributionDirectory(elementValue());
- }
- }
- else if(name == "adapter")
- {
- _inAdapter = false;
- }
- else if(name == "replica-group")
- {
- _currentApplication->finishReplicaGroup();
- _inReplicaGroup = false;
- }
- else if(name == "dbenv")
- {
- _inDbEnv = false;
- }
- else if(name == "distrib")
- {
- _inDistrib = false;
- }
+ if(name == "target")
+ {
+ if(!_isCurrentTargetDeployable && --_targetCounter == 0)
+ {
+ _isCurrentTargetDeployable = true;
+ _targetCounter = 0;
+ }
+ return;
+ }
+ else if(!isCurrentTargetDeployable())
+ {
+ //
+ // We don't bother to parse the elements if the elements are enclosed in a target element
+ // which won't be deployed.
+ //
+ return;
+ }
+ else if(name == "node")
+ {
+ _currentApplication->addNode(_currentNode->getName(), _currentNode->getDescriptor());
+ _currentNode.reset(0);
+ }
+ else if(name == "server" || name == "icebox")
+ {
+ assert(_currentServer.get());
+ if(_currentTemplate.get())
+ {
+ _currentTemplate->setDescriptor(_currentServer->getDescriptor());
+ }
+ else
+ {
+ assert(_currentNode.get());
+ _currentNode->addServer(_currentServer->getDescriptor());
+ }
+ _currentServer->finish();
+ _currentServer.reset(0);
+ _currentCommunicator = 0;
+ }
+ else if(name == "server-template")
+ {
+ assert(_currentApplication.get());
+ _currentApplication->addServerTemplate(_currentTemplate->getId(), _currentTemplate->getDescriptor());
+ _currentTemplate.reset(0);
+ }
+ else if(name == "service")
+ {
+ assert(_currentService.get());
+ if(_currentServer.get())
+ {
+ _currentServer->addService(_currentService->getDescriptor());
+ }
+ else
+ {
+ _currentTemplate->setDescriptor(_currentService->getDescriptor());
+ }
+ _currentService->finish();
+ _currentService.reset(0);
+ _currentCommunicator = _currentServer.get();
+ }
+ else if(name == "service-template")
+ {
+ assert(_currentTemplate.get());
+ _currentApplication->addServiceTemplate(_currentTemplate->getId(), _currentTemplate->getDescriptor());
+ _currentTemplate.reset(0);
+ }
+ else if(name == "server-instance")
+ {
+ assert(_currentNode.get() && _currentServerInstance.get());
+ _currentNode->addServerInstance(_currentServerInstance->getDescriptor());
+ _currentServerInstance.reset(0);
+ }
+ else if(name == "service-instance")
+ {
+ assert(_currentServer.get() && _currentServiceInstance.get());
+ _currentServer->addServiceInstance(_currentServiceInstance->getDescriptor());
+ _currentServiceInstance.reset(0);
+ }
+ else if(name == "properties")
+ {
+ assert(_currentPropertySet.get());
+ if(_currentPropertySet->finish())
+ {
+ if(_currentServiceInstance.get())
+ {
+ _currentServiceInstance->addPropertySet(_currentPropertySet->getDescriptor());
+ }
+ else if(_currentServerInstance.get())
+ {
+ _currentServerInstance->addPropertySet(_currentPropertySet->getService(),
+ _currentPropertySet->getDescriptor());
+ }
+ else if(_currentCommunicator)
+ {
+ _currentCommunicator->addPropertySet(_currentPropertySet->getDescriptor());
+ }
+ else if(_currentNode.get())
+ {
+ _currentNode->addPropertySet(_currentPropertySet->getId(),
+ _currentPropertySet->getDescriptor());
+ }
+ else if(_currentApplication.get())
+ {
+ _currentApplication->addPropertySet(_currentPropertySet->getId(),
+ _currentPropertySet->getDescriptor());
+ }
+ else
+ {
+ assert(false);
+ }
+ _currentPropertySet.reset(0);
+ }
+ }
+ else if(name == "description")
+ {
+ if(_inAdapter)
+ {
+ _currentCommunicator->setAdapterDescription(elementValue());
+ }
+ else if(_inReplicaGroup)
+ {
+ _currentApplication->setReplicaGroupDescription(elementValue());
+ }
+ else if(_inDbEnv)
+ {
+ assert(_currentCommunicator);
+ _currentCommunicator->setDbEnvDescription(elementValue());
+ }
+ else if(_currentCommunicator)
+ {
+ _currentCommunicator->setDescription(elementValue());
+ }
+ else if(_currentNode.get())
+ {
+ _currentNode->setDescription(elementValue());
+ }
+ else if(_currentApplication.get())
+ {
+ _currentApplication->setDescription(elementValue());
+ }
+ else
+ {
+ error("element <description> is not allowed here");
+ }
+ }
+ else if(name == "option")
+ {
+ if(!_currentServer.get())
+ {
+ error("element <option> can only be the child of a <server> element");
+ }
+ _currentServer->addOption(elementValue());
+ }
+ else if(name == "env")
+ {
+ if(!_currentServer.get())
+ {
+ error("element <env> can only be the child of a <server> element");
+ }
+ _currentServer->addEnv(elementValue());
+ }
+ else if(name == "directory")
+ {
+ if(!_inDistrib)
+ {
+ error("the <directory> element can only be a child of a <distrib> element");
+ }
+ if(!_currentServer.get())
+ {
+ _currentApplication->addDistributionDirectory(elementValue());
+ }
+ else
+ {
+ _currentServer->addDistributionDirectory(elementValue());
+ }
+ }
+ else if(name == "adapter")
+ {
+ _inAdapter = false;
+ }
+ else if(name == "replica-group")
+ {
+ _currentApplication->finishReplicaGroup();
+ _inReplicaGroup = false;
+ }
+ else if(name == "dbenv")
+ {
+ _inDbEnv = false;
+ }
+ else if(name == "distrib")
+ {
+ _inDistrib = false;
+ }
}
catch(const string& reason)
{
- error(reason);
+ error(reason);
}
catch(const char* reason)
{
- error(reason);
+ error(reason);
}
//
@@ -705,7 +705,7 @@ DescriptorHandler::endElement(const string& name, int line, int column)
string value = elementValue();
if(!value.empty() && value.find_first_not_of(" \t\r\n") != string::npos)
{
- error("invalid element value for element `" + name + "'");
+ error("invalid element value for element `" + name + "'");
}
}
@@ -714,7 +714,7 @@ DescriptorHandler::characters(const string& chars, int, int)
{
if(isCurrentTargetDeployable())
{
- _data += chars;
+ _data += chars;
}
}
@@ -731,7 +731,7 @@ DescriptorHandler::getApplicationDescriptor() const
{
if(!_currentApplication.get())
{
- error("no application descriptor defined in this file");
+ error("no application descriptor defined in this file");
}
return _currentApplication->getDescriptor();
}
@@ -749,22 +749,22 @@ DescriptorHandler::getTargets(const string& targets) const
if(!targets.empty())
{
- const string delim = " \t\n\r";
-
- string::size_type beg = 0;
- string::size_type end = 0;
- do
- {
- end = targets.find_first_of(delim, end);
- if(end == string::npos)
- {
- end = targets.size();
- }
-
- result.push_back(targets.substr(beg, end - beg));
- beg = ++end;
- }
- while(end < targets.size());
+ const string delim = " \t\n\r";
+
+ string::size_type beg = 0;
+ string::size_type end = 0;
+ do
+ {
+ end = targets.find_first_of(delim, end);
+ if(end == string::npos)
+ {
+ end = targets.size();
+ }
+
+ result.push_back(targets.substr(beg, end - beg));
+ beg = ++end;
+ }
+ while(end < targets.size());
}
copy(_targets.begin(), _targets.end(), back_inserter(result));
@@ -803,19 +803,19 @@ DescriptorHandler::isTargetDeployable(const string& target) const
string fqn;
if(!application.empty())
{
- fqn += (fqn.empty() ? "" : ".") + application;
+ fqn += (fqn.empty() ? "" : ".") + application;
}
if(!node.empty())
{
- fqn += (fqn.empty() ? "" : ".") + node;
+ fqn += (fqn.empty() ? "" : ".") + node;
}
if(!server.empty())
{
- fqn += (fqn.empty() ? "" : ".") + server;
+ fqn += (fqn.empty() ? "" : ".") + server;
}
if(!service.empty())
{
- fqn += (fqn.empty() ? "" : ".") + service;
+ fqn += (fqn.empty() ? "" : ".") + service;
}
//
@@ -823,40 +823,40 @@ DescriptorHandler::isTargetDeployable(const string& target) const
//
for(vector<string>::const_iterator p = _targets.begin(); p != _targets.end(); ++p)
{
- if((*p) == target)
- {
- //
- // A supplied target without any communicator prefix is matching the target.
- //
- return true;
- }
- else
- {
- string communicatorTarget;
- string::size_type end = 0;
- while(end != string::npos)
- {
- //
- // Add the first communicator name from the communicator fully qualified name to the
- // target and see if matches.
- //
- end = fqn.find('.', end);
- if(end == string::npos)
- {
- communicatorTarget = fqn + "." + target;
- }
- else
- {
- communicatorTarget = fqn.substr(0, end) + "." + target;
- ++end;
- }
-
- if((*p) == communicatorTarget)
- {
- return true;
- }
- }
- }
+ if((*p) == target)
+ {
+ //
+ // A supplied target without any communicator prefix is matching the target.
+ //
+ return true;
+ }
+ else
+ {
+ string communicatorTarget;
+ string::size_type end = 0;
+ while(end != string::npos)
+ {
+ //
+ // Add the first communicator name from the communicator fully qualified name to the
+ // target and see if matches.
+ //
+ end = fqn.find('.', end);
+ if(end == string::npos)
+ {
+ communicatorTarget = fqn + "." + target;
+ }
+ else
+ {
+ communicatorTarget = fqn.substr(0, end) + "." + target;
+ ++end;
+ }
+
+ if((*p) == communicatorTarget)
+ {
+ return true;
+ }
+ }
+ }
}
return false;
@@ -864,10 +864,10 @@ DescriptorHandler::isTargetDeployable(const string& target) const
ApplicationDescriptor
DescriptorParser::parseDescriptor(const string& descriptor,
- const Ice::StringSeq& targets,
- const map<string, string>& variables,
- const Ice::CommunicatorPtr& communicator,
- const IceGrid::AdminPrx& admin)
+ const Ice::StringSeq& targets,
+ const map<string, string>& variables,
+ const Ice::CommunicatorPtr& communicator,
+ const IceGrid::AdminPrx& admin)
{
string filename = IcePatch2::simplify(descriptor);
DescriptorHandler handler(filename, communicator);
diff --git a/cpp/src/IceGrid/DescriptorParser.h b/cpp/src/IceGrid/DescriptorParser.h
index c1187f29949..f5a801225e1 100644
--- a/cpp/src/IceGrid/DescriptorParser.h
+++ b/cpp/src/IceGrid/DescriptorParser.h
@@ -18,10 +18,10 @@ class DescriptorParser
public:
static ApplicationDescriptor parseDescriptor(const std::string&,
- const Ice::StringSeq&,
- const std::map<std::string, std::string>&,
- const Ice::CommunicatorPtr&,
- const IceGrid::AdminPrx&);
+ const Ice::StringSeq&,
+ const std::map<std::string, std::string>&,
+ const Ice::CommunicatorPtr&,
+ const IceGrid::AdminPrx&);
static ApplicationDescriptor parseDescriptor(const std::string&, const Ice::CommunicatorPtr&);
diff --git a/cpp/src/IceGrid/FileCache.cpp b/cpp/src/IceGrid/FileCache.cpp
index b09b5dcbf9f..fa06add4ca7 100644
--- a/cpp/src/IceGrid/FileCache.cpp
+++ b/cpp/src/IceGrid/FileCache.cpp
@@ -30,7 +30,7 @@ FileCache::getOffsetFromEnd(const string& file, int originalCount)
ifstream is(file.c_str());
if(is.fail())
{
- throw FileNotAvailableException("failed to open file `" + file + "'");
+ throw FileNotAvailableException("failed to open file `" + file + "'");
}
if(originalCount < 0)
@@ -54,64 +54,64 @@ FileCache::getOffsetFromEnd(const string& file, int originalCount)
{
lines.clear();
- //
- // Move the current position of the stream to the new block to
- // read.
- //
- is.clear();
- if(lastBlockOffset - blockSize > streamoff(0))
- {
- is.seekg(lastBlockOffset - blockSize);
- getline(is, line); // Ignore the first line as it's most likely not complete.
- }
- else
- {
- is.seekg(0, ios::beg); // We've reach the begining of the file.
- }
-
- //
- // Read the block and count the number of lines in the block
- // If we found the "first last N lines", we start throwing out
- // the lines read at the begining of the file.
- //
- int count = originalCount - totalCount; // Number of lines left to find.
- while(is.good() && is.tellg() <= streamoff(lastBlockOffset))
- {
+ //
+ // Move the current position of the stream to the new block to
+ // read.
+ //
+ is.clear();
+ if(lastBlockOffset - blockSize > streamoff(0))
+ {
+ is.seekg(lastBlockOffset - blockSize);
+ getline(is, line); // Ignore the first line as it's most likely not complete.
+ }
+ else
+ {
+ is.seekg(0, ios::beg); // We've reach the begining of the file.
+ }
+
+ //
+ // Read the block and count the number of lines in the block
+ // If we found the "first last N lines", we start throwing out
+ // the lines read at the begining of the file.
+ //
+ int count = originalCount - totalCount; // Number of lines left to find.
+ while(is.good() && is.tellg() <= streamoff(lastBlockOffset))
+ {
streampos beg = is.tellg();
- getline(is, line);
- if(is.eof() && line.empty()) // Don't count the last line if it's empty.
- {
- continue;
- }
-
- lines.push_back(make_pair(beg, line));
- ++totalCount;
- if(lines.size() == static_cast<unsigned int>(count + 1))
- {
- --totalCount;
- lines.pop_front();
- }
- }
-
- if(lastBlockOffset - blockSize < streamoff(0))
- {
- break; // We're done if the block started at the begining of the file.
- }
- else if(totalCount < originalCount)
- {
- //
- // Otherwise, it we still didn't find the required number of lines,
- // read another block of text before this block.
- //
- lastBlockOffset -= blockSize; // Position of the block we just read.
- blockSize *= 2; // Read a bigger block.
- }
+ getline(is, line);
+ if(is.eof() && line.empty()) // Don't count the last line if it's empty.
+ {
+ continue;
+ }
+
+ lines.push_back(make_pair(beg, line));
+ ++totalCount;
+ if(lines.size() == static_cast<unsigned int>(count + 1))
+ {
+ --totalCount;
+ lines.pop_front();
+ }
+ }
+
+ if(lastBlockOffset - blockSize < streamoff(0))
+ {
+ break; // We're done if the block started at the begining of the file.
+ }
+ else if(totalCount < originalCount)
+ {
+ //
+ // Otherwise, it we still didn't find the required number of lines,
+ // read another block of text before this block.
+ //
+ lastBlockOffset -= blockSize; // Position of the block we just read.
+ blockSize *= 2; // Read a bigger block.
+ }
}
while(totalCount < originalCount && !is.bad());
if(is.bad())
{
- throw FileNotAvailableException("unrecoverable error occured while reading file `" + file + "'");
+ throw FileNotAvailableException("unrecoverable error occured while reading file `" + file + "'");
}
if(lines.empty())
@@ -131,18 +131,18 @@ FileCache::read(const string& file, Ice::Long offset, int size, Ice::Long& newOf
if(size > _messageSizeMax)
{
- size = _messageSizeMax;
+ size = _messageSizeMax;
}
if(size <= 5)
{
- throw FileNotAvailableException("maximum bytes per read request is too low");
+ throw FileNotAvailableException("maximum bytes per read request is too low");
}
ifstream is(file.c_str());
if(is.fail())
{
- throw FileNotAvailableException("failed to open file `" + file + "'");
+ throw FileNotAvailableException("failed to open file `" + file + "'");
}
//
@@ -153,9 +153,9 @@ FileCache::read(const string& file, Ice::Long offset, int size, Ice::Long& newOf
is.seekg(0, ios::end);
if(offset >= is.tellg())
{
- newOffset = is.tellg();
- lines = Ice::StringSeq();
- return true;
+ newOffset = is.tellg();
+ lines = Ice::StringSeq();
+ return true;
}
//
@@ -173,44 +173,44 @@ FileCache::read(const string& file, Ice::Long offset, int size, Ice::Long& newOf
for(int i = 0; is.good(); ++i)
{
- getline(is, line);
+ getline(is, line);
- int lineSize = static_cast<int>(line.size()) + 5; // 5 bytes for the encoding of the string size (worst case)
- if(lineSize + totalSize > size)
- {
- if(totalSize + 5 < size)
- {
+ int lineSize = static_cast<int>(line.size()) + 5; // 5 bytes for the encoding of the string size (worst case)
+ if(lineSize + totalSize > size)
+ {
+ if(totalSize + 5 < size)
+ {
// There's some room left for a part of the string, return a partial string
line = line.substr(0, size - totalSize - 5);
- lines.push_back(line);
- newOffset += line.size();
- }
- else
- {
- lines.push_back("");
- }
+ lines.push_back(line);
+ newOffset += line.size();
+ }
+ else
+ {
+ lines.push_back("");
+ }
return false; // We didn't reach the end of file, we've just reached the size limit!
- }
+ }
- totalSize += lineSize;
- lines.push_back(line);
+ totalSize += lineSize;
+ lines.push_back(line);
#if defined(_MSC_VER) && (_MSC_VER < 1300)
- if(is.eof())
- {
- newOffset += line.size();
- }
- else
+ if(is.eof())
+ {
+ newOffset += line.size();
+ }
+ else
#else
- if(!is.fail())
+ if(!is.fail())
#endif
- {
- newOffset = is.tellg();
- }
+ {
+ newOffset = is.tellg();
+ }
}
if(is.bad())
{
- throw FileNotAvailableException("unrecoverable error occured while reading file `" + file + "'");
+ throw FileNotAvailableException("unrecoverable error occured while reading file `" + file + "'");
}
return is.eof();
diff --git a/cpp/src/IceGrid/FileParserI.cpp b/cpp/src/IceGrid/FileParserI.cpp
index f2e33fbb69b..9e71dd0b55d 100755
--- a/cpp/src/IceGrid/FileParserI.cpp
+++ b/cpp/src/IceGrid/FileParserI.cpp
@@ -20,12 +20,12 @@ FileParserI::parse(const string& file, const AdminPrx& admin, const Ice::Current
{
try
{
- return DescriptorParser::parseDescriptor(file, Ice::StringSeq(), map<string, string>(),
- current.adapter->getCommunicator(), admin);
+ return DescriptorParser::parseDescriptor(file, Ice::StringSeq(), map<string, string>(),
+ current.adapter->getCommunicator(), admin);
}
catch(const IceXML::ParserException& e)
{
- throw ParseException(e.reason());
+ throw ParseException(e.reason());
return ApplicationDescriptor();
}
}
diff --git a/cpp/src/IceGrid/FileUserAccountMapperI.cpp b/cpp/src/IceGrid/FileUserAccountMapperI.cpp
index b57b57af61a..0ab37bed844 100644
--- a/cpp/src/IceGrid/FileUserAccountMapperI.cpp
+++ b/cpp/src/IceGrid/FileUserAccountMapperI.cpp
@@ -20,55 +20,55 @@ FileUserAccountMapperI::FileUserAccountMapperI(const string& filename)
ifstream file(filename.c_str());
if(!file)
{
- throw "cannot open `" + filename + "' for reading: " + strerror(errno);
+ throw "cannot open `" + filename + "' for reading: " + strerror(errno);
}
-
+
const string delim = " \t\r\n";
while(true)
{
- string line;
- getline(file, line);
- if(!file)
- {
- break;
- }
+ string line;
+ getline(file, line);
+ if(!file)
+ {
+ break;
+ }
- string::size_type idx = line.find('#');
- if(idx != string::npos)
- {
- line.erase(idx);
- }
-
- idx = line.find_last_not_of(delim);
- if(idx != string::npos && idx + 1 < line.length())
- {
- line.erase(idx + 1);
- }
+ string::size_type idx = line.find('#');
+ if(idx != string::npos)
+ {
+ line.erase(idx);
+ }
+
+ idx = line.find_last_not_of(delim);
+ if(idx != string::npos && idx + 1 < line.length())
+ {
+ line.erase(idx + 1);
+ }
- string::size_type beg = line.find_first_not_of(delim);
- if(beg == string::npos)
- {
- continue;
- }
+ string::size_type beg = line.find_first_not_of(delim);
+ if(beg == string::npos)
+ {
+ continue;
+ }
- string::size_type end = line.find_first_of(delim, beg);
- if(end == string::npos || end <= beg)
- {
- continue;
- }
- string account = line.substr(beg, end - beg);
+ string::size_type end = line.find_first_of(delim, beg);
+ if(end == string::npos || end <= beg)
+ {
+ continue;
+ }
+ string account = line.substr(beg, end - beg);
- beg = line.find_first_not_of(delim, end);
- if(beg == string::npos)
- {
- continue;
- }
- string user = line.substr(beg);
-
- assert(!user.empty());
- assert(!account.empty());
+ beg = line.find_first_not_of(delim, end);
+ if(beg == string::npos)
+ {
+ continue;
+ }
+ string user = line.substr(beg);
+
+ assert(!user.empty());
+ assert(!account.empty());
- _accounts[user] = account;
+ _accounts[user] = account;
}
}
@@ -78,7 +78,7 @@ FileUserAccountMapperI::getUserAccount(const string& user, const Ice::Current&)
map<string, string>::const_iterator p = _accounts.find(user);
if(p == _accounts.end())
{
- throw UserAccountNotFoundException();
+ throw UserAccountNotFoundException();
}
return p->second;
}
diff --git a/cpp/src/IceGrid/IceGridNode.cpp b/cpp/src/IceGrid/IceGridNode.cpp
index 012e35f8333..3f38c508056 100644
--- a/cpp/src/IceGrid/IceGridNode.cpp
+++ b/cpp/src/IceGrid/IceGridNode.cpp
@@ -132,16 +132,16 @@ ProcessI::writeMessage(const string& message, Int fd, const Current&)
{
switch(fd)
{
- case 1:
- {
- cout << message << endl;
- break;
- }
- case 2:
- {
- cerr << message << endl;
- break;
- }
+ case 1:
+ {
+ cout << message << endl;
+ break;
+ }
+ case 2:
+ {
+ cerr << message << endl;
+ break;
+ }
}
}
@@ -196,12 +196,12 @@ NodeService::start(int argc, char* argv[])
targets.push_back(argv[i]);
}
}
- else
- {
- error("invalid option: `" + string(argv[i]) + "'");
- usage(argv[0]);
- return false;
- }
+ else
+ {
+ error("invalid option: `" + string(argv[i]) + "'");
+ usage(argv[0]);
+ return false;
+ }
}
PropertiesPtr properties = communicator()->getProperties();
@@ -222,59 +222,59 @@ NodeService::start(int argc, char* argv[])
//
if(!nowarn && properties->getPropertyAsIntWithDefault("Ice.ThreadPool.Server.Size", 0) > 0)
{
- Warning out(communicator()->getLogger());
- out << "setting `Ice.ThreadPool.Server.Size' is not useful,\n";
- out << "you should set individual adapter thread pools instead.";
+ Warning out(communicator()->getLogger());
+ out << "setting `Ice.ThreadPool.Server.Size' is not useful,\n";
+ out << "you should set individual adapter thread pools instead.";
}
//
// DEPRECATED PROPERTY: Remove extra code in future release
//
int size = properties->getPropertyAsIntWithDefault("Ice.OA.IceGrid.Node.ThreadPool.Size",
- properties->getPropertyAsIntWithDefault("IceGrid.Node.ThreadPool.Size", 0));
+ properties->getPropertyAsIntWithDefault("IceGrid.Node.ThreadPool.Size", 0));
if(size <= 0)
{
- properties->setProperty("Ice.OA.IceGrid.Node.ThreadPool.Size", "1");
- size = 1;
+ properties->setProperty("Ice.OA.IceGrid.Node.ThreadPool.Size", "1");
+ size = 1;
}
//
// DEPRECATED PROPERTY: Remove extra code in future release
//
int sizeMax = properties->getPropertyAsIntWithDefault("Ice.OA.IceGrid.Node.ThreadPool.SizeMax",
- properties->getPropertyAsIntWithDefault("IceGrid.Node.ThreadPool.SizeMax", 0));
+ properties->getPropertyAsIntWithDefault("IceGrid.Node.ThreadPool.SizeMax", 0));
if(sizeMax <= 0)
{
- if(size >= sizeMax)
- {
- sizeMax = size * 10;
- }
-
- ostringstream os;
- os << sizeMax;
- properties->setProperty("Ice.OA.IceGrid.Node.ThreadPool.SizeMax", os.str());
+ if(size >= sizeMax)
+ {
+ sizeMax = size * 10;
+ }
+
+ ostringstream os;
+ os << sizeMax;
+ properties->setProperty("Ice.OA.IceGrid.Node.ThreadPool.SizeMax", os.str());
}
size = properties->getPropertyAsIntWithDefault("Ice.ThreadPool.Client.Size", 0);
if(size <= 0)
{
- properties->setProperty("Ice.ThreadPool.Client.Size", "1");
- size = 1;
+ properties->setProperty("Ice.ThreadPool.Client.Size", "1");
+ size = 1;
}
sizeMax = properties->getPropertyAsIntWithDefault("Ice.ThreadPool.Client.SizeMax", 0);
if(sizeMax <= 0)
{
- if(size >= sizeMax)
- {
- sizeMax = size * 10;
- }
- if(sizeMax < 100)
- {
- sizeMax = 100;
- }
- ostringstream os;
- os << sizeMax;
- properties->setProperty("Ice.ThreadPool.Client.SizeMax", os.str());
+ if(size >= sizeMax)
+ {
+ sizeMax = size * 10;
+ }
+ if(sizeMax < 100)
+ {
+ sizeMax = 100;
+ }
+ ostringstream os;
+ os << sizeMax;
+ properties->setProperty("Ice.ThreadPool.Client.SizeMax", os.str());
}
//
@@ -294,27 +294,27 @@ NodeService::start(int argc, char* argv[])
return false;
}
- //
- // Set the default locator property to point to the collocated
- // locator (this property is passed by the activator to each
- // activated server). The default locator is also needed by
- // the node session manager.
//
- if(properties->getProperty("Ice.Default.Locator").empty())
- {
- Identity locatorId;
- locatorId.category = properties->getPropertyWithDefault("IceGrid.InstanceName", "IceGrid");
- locatorId.name = "Locator";
- //
- // DEPRECATED PROPERTY: Remove extra code in future release
- //
- string endpoints =
- properties->getPropertyWithDefault("Ice.OA.IceGrid.Registry.Client.Endpoints",
- properties->getProperty("IceGrid.Registry.Client.Endpoints"));
- string locatorPrx = "\"" + communicator()->identityToString(locatorId) + "\" :" + endpoints;
- communicator()->setDefaultLocator(LocatorPrx::uncheckedCast(communicator()->stringToProxy(locatorPrx)));
- properties->setProperty("Ice.Default.Locator", locatorPrx);
- }
+ // Set the default locator property to point to the collocated
+ // locator (this property is passed by the activator to each
+ // activated server). The default locator is also needed by
+ // the node session manager.
+ //
+ if(properties->getProperty("Ice.Default.Locator").empty())
+ {
+ Identity locatorId;
+ locatorId.category = properties->getPropertyWithDefault("IceGrid.InstanceName", "IceGrid");
+ locatorId.name = "Locator";
+ //
+ // DEPRECATED PROPERTY: Remove extra code in future release
+ //
+ string endpoints =
+ properties->getPropertyWithDefault("Ice.OA.IceGrid.Registry.Client.Endpoints",
+ properties->getProperty("IceGrid.Registry.Client.Endpoints"));
+ string locatorPrx = "\"" + communicator()->identityToString(locatorId) + "\" :" + endpoints;
+ communicator()->setDefaultLocator(LocatorPrx::uncheckedCast(communicator()->stringToProxy(locatorPrx)));
+ properties->setProperty("Ice.Default.Locator", locatorPrx);
+ }
}
else if(properties->getProperty("Ice.Default.Locator").empty())
{
@@ -338,25 +338,25 @@ NodeService::start(int argc, char* argv[])
struct _stat filestat;
if(::_stat(dataPath.c_str(), &filestat) != 0 || !S_ISDIR(filestat.st_mode))
{
- ostringstream os;
- FileException ex(__FILE__, __LINE__);
- ex.path = dataPath;
- ex.error = getSystemErrno();
- os << ex;
+ ostringstream os;
+ 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());
- return false;
+ return false;
}
#else
struct stat filestat;
if(::stat(dataPath.c_str(), &filestat) != 0 || !S_ISDIR(filestat.st_mode))
{
- ostringstream os;
- FileException ex(__FILE__, __LINE__);
- ex.path = dataPath;
- ex.error = getSystemErrno();
- os << ex;
+ ostringstream os;
+ 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());
- return false;
+ return false;
}
#endif
@@ -368,9 +368,9 @@ NodeService::start(int argc, char* argv[])
dataPath += "/";
}
- IcePatch2::createDirectory(dataPath + "servers");
- IcePatch2::createDirectory(dataPath + "tmp");
- IcePatch2::createDirectory(dataPath + "distrib");
+ IcePatch2::createDirectory(dataPath + "servers");
+ IcePatch2::createDirectory(dataPath + "tmp");
+ IcePatch2::createDirectory(dataPath + "distrib");
}
//
@@ -388,8 +388,8 @@ NodeService::start(int argc, char* argv[])
string name = properties->getProperty("IceGrid.Node.Name");
if(name.empty())
{
- error("property `IceGrid.Node.Name' is not set");
- return false;
+ error("property `IceGrid.Node.Name' is not set");
+ return false;
}
//
@@ -416,35 +416,35 @@ NodeService::start(int argc, char* argv[])
UserAccountMapperPrx mapper;
if(!mapperProperty.empty())
{
- try
- {
- mapper = UserAccountMapperPrx::uncheckedCast(communicator()->stringToProxy(mapperProperty));
- }
- catch(const Ice::LocalException& ex)
- {
- ostringstream os;
- os << "user account mapper `" << mapperProperty << "' is invalid:\n" << ex;
- error(os.str());
- return false;
- }
+ try
+ {
+ mapper = UserAccountMapperPrx::uncheckedCast(communicator()->stringToProxy(mapperProperty));
+ }
+ catch(const Ice::LocalException& ex)
+ {
+ ostringstream os;
+ os << "user account mapper `" << mapperProperty << "' is invalid:\n" << ex;
+ error(os.str());
+ return false;
+ }
}
else
{
- string userAccountFileProperty = properties->getProperty("IceGrid.Node.UserAccounts");
- if(!userAccountFileProperty.empty())
- {
- try
- {
- Ice::ObjectPrx object = _adapter->addWithUUID(new FileUserAccountMapperI(userAccountFileProperty));
- object = object->ice_collocationOptimized(true);
- mapper = UserAccountMapperPrx::uncheckedCast(object);
- }
- catch(const std::string& msg)
- {
- error(msg);
- return false;
- }
- }
+ string userAccountFileProperty = properties->getProperty("IceGrid.Node.UserAccounts");
+ if(!userAccountFileProperty.empty())
+ {
+ try
+ {
+ Ice::ObjectPrx object = _adapter->addWithUUID(new FileUserAccountMapperI(userAccountFileProperty));
+ object = object->ice_collocationOptimized(true);
+ mapper = UserAccountMapperPrx::uncheckedCast(object);
+ }
+ catch(const std::string& msg)
+ {
+ error(msg);
+ return false;
+ }
+ }
}
//
@@ -479,18 +479,18 @@ NodeService::start(int argc, char* argv[])
//
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 ServerNotFoundException&)
- {
- }
- catch(const LocalException&)
- {
- }
+ try
+ {
+ ProcessPrx proxy = ProcessPrx::uncheckedCast(_adapter->addWithUUID(new ProcessI(_activator)));
+ LocatorRegistryPrx locatorRegistry = communicator()->getDefaultLocator()->getRegistry();
+ locatorRegistry->setServerProcessProxy(properties->getProperty("Ice.ServerId"), proxy);
+ }
+ catch(const ServerNotFoundException&)
+ {
+ }
+ catch(const LocalException&)
+ {
+ }
}
//
@@ -512,16 +512,16 @@ NodeService::start(int argc, char* argv[])
string bundleName = properties->getProperty("IceGrid.Node.PrintServersReady");
if(!bundleName.empty() || !desc.empty())
{
- enableInterrupt();
- if(!_sessions.waitForCreate())
- {
- //
- // Create was interrupted, return true as if the service was
- // correctly initiliazed to make sure it's properly stopped.
- //
- return true;
- }
- disableInterrupt();
+ enableInterrupt();
+ if(!_sessions.waitForCreate())
+ {
+ //
+ // Create was interrupted, return true as if the service was
+ // correctly initiliazed to make sure it's properly stopped.
+ //
+ return true;
+ }
+ disableInterrupt();
}
//
@@ -529,100 +529,100 @@ NodeService::start(int argc, char* argv[])
//
if(!desc.empty())
{
- 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())
- {
- cout << "user id: " << flush;
- getline(cin, id);
- id = trim(id);
- }
-
- if(password.empty())
- {
- cout << "password: " << flush;
- getline(cin, password);
- password = trim(password);
- }
-
- session = registry->createAdminSession(id, password);
- }
- 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());
- }
+ 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())
+ {
+ cout << "user id: " << flush;
+ getline(cin, id);
+ id = trim(id);
+ }
+
+ if(password.empty())
+ {
+ cout << "password: " << flush;
+ getline(cin, password);
+ password = trim(password);
+ }
+
+ session = registry->createAdminSession(id, password);
+ }
+ 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());
+ }
}
if(!bundleName.empty())
{
- print(bundleName + " ready");
+ print(bundleName + " ready");
}
return true;
@@ -649,7 +649,7 @@ NodeService::stop()
}
catch(...)
{
- assert(false);
+ assert(false);
}
//
@@ -659,11 +659,11 @@ NodeService::stop()
try
{
_waitQueue->destroy();
- _waitQueue = 0;
+ _waitQueue = 0;
}
catch(...)
{
- assert(false);
+ assert(false);
}
_activator = 0;
@@ -673,14 +673,14 @@ NodeService::stop()
//
try
{
- _adapter->deactivate();
- _adapter = 0;
+ _adapter->deactivate();
+ _adapter = 0;
}
catch(const Ice::LocalException& ex)
{
- ostringstream ostr;
- ostr << "unexpected exception while shutting down node:\n" << ex;
- warning(ostr.str());
+ ostringstream ostr;
+ ostr << "unexpected exception while shutting down node:\n" << ex;
+ warning(ostr.str());
}
//
@@ -704,9 +704,9 @@ NodeService::stop()
}
catch(const Ice::LocalException& ex)
{
- ostringstream ostr;
- ostr << "unexpected exception while shutting down node:\n" << ex;
- warning(ostr.str());
+ ostringstream ostr;
+ ostr << "unexpected exception while shutting down node:\n" << ex;
+ warning(ostr.str());
}
//
@@ -714,8 +714,8 @@ NodeService::stop()
//
if(_registry)
{
- _registry->stop();
- _registry = 0;
+ _registry->stop();
+ _registry = 0;
}
return true;
@@ -723,7 +723,7 @@ NodeService::stop()
CommunicatorPtr
NodeService::initializeCommunicator(int& argc, char* argv[],
- const InitializationData& initializationData)
+ const InitializationData& initializationData)
{
InitializationData initData = initializationData;
initData.properties = createProperties(argc, argv, initData.properties);
@@ -742,35 +742,35 @@ void
NodeService::usage(const string& appName)
{
string options =
- "Options:\n"
- "-h, --help Show this message.\n"
- "-v, --version Display the Ice version.\n"
- "--nowarn Don't print any security warnings.\n"
- "\n"
- "--deploy DESCRIPTOR [TARGET1 [TARGET2 ...]]\n"
- " Add or update descriptor in file DESCRIPTOR, with\n"
- " optional targets.\n";
+ "Options:\n"
+ "-h, --help Show this message.\n"
+ "-v, --version Display the Ice version.\n"
+ "--nowarn Don't print any security warnings.\n"
+ "\n"
+ "--deploy DESCRIPTOR [TARGET1 [TARGET2 ...]]\n"
+ " Add or update descriptor in file DESCRIPTOR, with\n"
+ " optional targets.\n";
#ifdef _WIN32
if(checkSystem())
{
options.append(
- "\n"
- "\n"
- "--service NAME Run as the Windows service NAME.\n"
- "\n"
- "--install NAME [--display DISP] [--executable EXEC] [args]\n"
- " Install as Windows service NAME. If DISP is\n"
- " provided, use it as the display name,\n"
- " otherwise NAME is used. If EXEC is provided,\n"
- " use it as the service executable, otherwise\n"
- " this executable is used. Any additional\n"
- " arguments are passed unchanged to the\n"
- " service at startup.\n"
- "--uninstall NAME Uninstall Windows service NAME.\n"
- "--start NAME [args] Start Windows service NAME. Any additional\n"
- " arguments are passed unchanged to the\n"
- " service.\n"
- "--stop NAME Stop Windows service NAME."
+ "\n"
+ "\n"
+ "--service NAME Run as the Windows service NAME.\n"
+ "\n"
+ "--install NAME [--display DISP] [--executable EXEC] [args]\n"
+ " Install as Windows service NAME. If DISP is\n"
+ " provided, use it as the display name,\n"
+ " otherwise NAME is used. If EXEC is provided,\n"
+ " use it as the service executable, otherwise\n"
+ " this executable is used. Any additional\n"
+ " arguments are passed unchanged to the\n"
+ " service at startup.\n"
+ "--uninstall NAME Uninstall Windows service NAME.\n"
+ "--start NAME [args] Start Windows service NAME. Any additional\n"
+ " arguments are passed unchanged to the\n"
+ " service.\n"
+ "--stop NAME Stop Windows service NAME."
);
}
#else
@@ -780,7 +780,7 @@ NodeService::usage(const string& appName)
"--daemon Run as a daemon.\n"
"--noclose Do not close open file descriptors.\n"
"--nochdir Do not change the current working directory.\n"
- "--pidfile <file> Write process ID to <file>."
+ "--pidfile <file> Write process ID to <file>."
);
#endif
print("Usage: " + appName + " [options]\n" + options);
diff --git a/cpp/src/IceGrid/IceGridRegistry.cpp b/cpp/src/IceGrid/IceGridRegistry.cpp
index 825dc50bd4a..413a0264fd7 100644
--- a/cpp/src/IceGrid/IceGridRegistry.cpp
+++ b/cpp/src/IceGrid/IceGridRegistry.cpp
@@ -76,31 +76,31 @@ RegistryService::start(int argc, char* argv[])
vector<string> args;
try
{
- args = opts.parse(argc, (const char**)argv);
+ args = opts.parse(argc, (const char**)argv);
}
catch(const IceUtil::BadOptException& e)
{
error(e.reason);
- usage(argv[0]);
- return false;
+ usage(argv[0]);
+ return false;
}
if(opts.isSet("help"))
{
- usage(argv[0]);
- return false;
+ usage(argv[0]);
+ return false;
}
if(opts.isSet("version"))
{
- print(ICE_STRING_VERSION);
- return false;
+ print(ICE_STRING_VERSION);
+ return false;
}
nowarn = opts.isSet("nowarn");
if(!args.empty())
{
- usage(argv[0]);
- return false;
+ usage(argv[0]);
+ return false;
}
Ice::PropertiesPtr properties = communicator()->getProperties();
@@ -110,9 +110,9 @@ RegistryService::start(int argc, char* argv[])
//
if(!nowarn && properties->getPropertyAsIntWithDefault("Ice.ThreadPool.Server.Size", 0) > 0)
{
- Warning out(communicator()->getLogger());
- out << "setting `Ice.ThreadPool.Server.Size' is not useful,\n";
- out << "you should set individual adapter thread pools instead.";
+ Warning out(communicator()->getLogger());
+ out << "setting `Ice.ThreadPool.Server.Size' is not useful,\n";
+ out << "you should set individual adapter thread pools instead.";
}
TraceLevelsPtr traceLevels = new TraceLevels(communicator(), "IceGrid.Registry");
@@ -120,7 +120,7 @@ RegistryService::start(int argc, char* argv[])
_registry = new RegistryI(communicator(), traceLevels);
if(!_registry->start(nowarn))
{
- return false;
+ return false;
}
return true;
@@ -147,7 +147,7 @@ RegistryService::stop()
CommunicatorPtr
RegistryService::initializeCommunicator(int& argc, char* argv[],
- const InitializationData& initializationData)
+ const InitializationData& initializationData)
{
InitializationData initData = initializationData;
initData.properties = createProperties(argc, argv, initData.properties);
@@ -166,31 +166,31 @@ void
RegistryService::usage(const string& appName)
{
string options =
- "Options:\n"
- "-h, --help Show this message.\n"
- "-v, --version Display the Ice version.\n"
- "--nowarn Don't print any security warnings.";
+ "Options:\n"
+ "-h, --help Show this message.\n"
+ "-v, --version Display the Ice version.\n"
+ "--nowarn Don't print any security warnings.";
#ifdef _WIN32
if(checkSystem())
{
options.append(
- "\n"
- "\n"
- "--service NAME Run as the Windows service NAME.\n"
- "\n"
- "--install NAME [--display DISP] [--executable EXEC] [args]\n"
- " Install as Windows service NAME. If DISP is\n"
- " provided, use it as the display name,\n"
- " otherwise NAME is used. If EXEC is provided,\n"
- " use it as the service executable, otherwise\n"
- " this executable is used. Any additional\n"
- " arguments are passed unchanged to the\n"
- " service at startup.\n"
- "--uninstall NAME Uninstall Windows service NAME.\n"
- "--start NAME [args] Start Windows service NAME. Any additional\n"
- " arguments are passed unchanged to the\n"
- " service.\n"
- "--stop NAME Stop Windows service NAME."
+ "\n"
+ "\n"
+ "--service NAME Run as the Windows service NAME.\n"
+ "\n"
+ "--install NAME [--display DISP] [--executable EXEC] [args]\n"
+ " Install as Windows service NAME. If DISP is\n"
+ " provided, use it as the display name,\n"
+ " otherwise NAME is used. If EXEC is provided,\n"
+ " use it as the service executable, otherwise\n"
+ " this executable is used. Any additional\n"
+ " arguments are passed unchanged to the\n"
+ " service at startup.\n"
+ "--uninstall NAME Uninstall Windows service NAME.\n"
+ "--start NAME [args] Start Windows service NAME. Any additional\n"
+ " arguments are passed unchanged to the\n"
+ " service.\n"
+ "--stop NAME Stop Windows service NAME."
);
}
#else
@@ -199,8 +199,8 @@ RegistryService::usage(const string& appName)
"\n"
"--daemon Run as a daemon.\n"
"--noclose Do not close open file descriptors.\n"
- "--nochdir Do not change the current working directory.\n"
- "--pidfile <file> Write process ID to <file>."
+ "--nochdir Do not change the current working directory.\n"
+ "--pidfile <file> Write process ID to <file>."
);
#endif
print("Usage: " + appName + " [options]\n" + options);
diff --git a/cpp/src/IceGrid/Internal.ice b/cpp/src/IceGrid/Internal.ice
index da569db2803..ed516ff5822 100644
--- a/cpp/src/IceGrid/Internal.ice
+++ b/cpp/src/IceGrid/Internal.ice
@@ -159,7 +159,7 @@ interface Adapter
*
**/
["ami", "nonmutating", "cpp:const"] idempotent Object* getDirectProxy()
- throws AdapterNotActiveException;
+ throws AdapterNotActiveException;
/**
*
@@ -175,7 +175,7 @@ interface Adapter
*
**/
["ami"] void setDirectProxy(Object* proxy)
- throws AdapterActiveException;
+ throws AdapterActiveException;
};
/**
@@ -200,7 +200,7 @@ interface FileReader
*
**/
["cpp:const"] idempotent long getOffsetFromEnd(string filename, int lines)
- throws FileNotAvailableException;
+ throws FileNotAvailableException;
/**
*
@@ -208,7 +208,7 @@ interface FileReader
*
**/
["cpp:const"] idempotent bool read(string filename, long pos, int size, out long newPos, out Ice::StringSeq lines)
- throws FileNotAvailableException;
+ throws FileNotAvailableException;
};
interface Server extends FileReader
@@ -222,7 +222,7 @@ interface Server extends FileReader
*
**/
["amd"] void start()
- throws ServerStartException;
+ throws ServerStartException;
/**
*
@@ -232,7 +232,7 @@ interface Server extends FileReader
*
**/
["amd"] void stop()
- throws ServerStopException;
+ throws ServerStopException;
/**
*
@@ -254,7 +254,7 @@ interface Server extends FileReader
*
**/
void sendSignal(string signal)
- throws BadSignalException;
+ throws BadSignalException;
/**
*
@@ -348,11 +348,11 @@ interface Node extends FileReader, ReplicaObserver
*
**/
["amd", "ami"] idempotent Server* loadServer(InternalServerDescriptor svr,
- string replicaName,
- out AdapterPrxDict adapters,
- out int actTimeout,
- out int deactTimeout)
- throws DeploymentException;
+ string replicaName,
+ out AdapterPrxDict adapters,
+ out int actTimeout,
+ out int deactTimeout)
+ throws DeploymentException;
/**
*
@@ -360,7 +360,7 @@ interface Node extends FileReader, ReplicaObserver
*
**/
["amd", "ami"] idempotent void destroyServer(string name, string uuid, int revision, string replicaName)
- throws DeploymentException;
+ throws DeploymentException;
/**
*
@@ -371,10 +371,10 @@ interface Node extends FileReader, ReplicaObserver
*
**/
["amd"] idempotent void patch(PatcherFeedback* feedback,
- string application,
- string server,
- InternalDistributionDescriptor appDistrib,
- bool shutdown);
+ string application,
+ string server,
+ InternalDistributionDescriptor appDistrib,
+ bool shutdown);
/**
*
@@ -562,7 +562,7 @@ interface ReplicaSession
*
**/
["ami"] idempotent void setAdapterDirectProxy(string adapterId, string replicaGroupId, Object* proxy)
- throws AdapterNotExistException, AdapterExistsException;
+ throws AdapterNotExistException, AdapterExistsException;
/**
*
@@ -690,7 +690,7 @@ interface InternalRegistry extends FileReader
*
**/
NodeSession* registerNode(InternalNodeInfo info, Node* prx, LoadInfo loadInf)
- throws NodeActiveException;
+ throws NodeActiveException;
/**
*
@@ -709,7 +709,7 @@ interface InternalRegistry extends FileReader
*
**/
ReplicaSession* registerReplica(InternalReplicaInfo info, InternalRegistry* prx)
- throws ReplicaActiveException;
+ throws ReplicaActiveException;
/**
*
diff --git a/cpp/src/IceGrid/InternalRegistryI.cpp b/cpp/src/IceGrid/InternalRegistryI.cpp
index 997d2b1769a..ae54ddda0cf 100644
--- a/cpp/src/IceGrid/InternalRegistryI.cpp
+++ b/cpp/src/IceGrid/InternalRegistryI.cpp
@@ -24,10 +24,10 @@ using namespace std;
using namespace IceGrid;
InternalRegistryI::InternalRegistryI(const RegistryIPtr& registry,
- const DatabasePtr& database,
- const ReapThreadPtr& reaper,
- const WellKnownObjectsManagerPtr& wellKnownObjects,
- ReplicaSessionManager& session) :
+ const DatabasePtr& database,
+ const ReapThreadPtr& reaper,
+ const WellKnownObjectsManagerPtr& wellKnownObjects,
+ ReplicaSessionManager& session) :
_registry(registry),
_database(database),
_reaper(reaper),
@@ -46,38 +46,38 @@ InternalRegistryI::~InternalRegistryI()
NodeSessionPrx
InternalRegistryI::registerNode(const InternalNodeInfoPtr& info,
- const NodePrx& node,
- const LoadInfo& load,
- const Ice::Current& current)
+ const NodePrx& node,
+ const LoadInfo& load,
+ const Ice::Current& current)
{
const Ice::LoggerPtr logger = _database->getTraceLevels()->logger;
try
{
- NodeSessionIPtr session = new NodeSessionI(_database, node, info, _nodeSessionTimeout, load);
- _reaper->add(new SessionReapable<NodeSessionI>(logger, session), _nodeSessionTimeout);
- return session->getProxy();
+ NodeSessionIPtr session = new NodeSessionI(_database, node, info, _nodeSessionTimeout, load);
+ _reaper->add(new SessionReapable<NodeSessionI>(logger, session), _nodeSessionTimeout);
+ return session->getProxy();
}
catch(const Ice::ObjectAdapterDeactivatedException&)
{
- throw Ice::ObjectNotExistException(__FILE__, __LINE__, current.id, current.facet, current.operation);
+ throw Ice::ObjectNotExistException(__FILE__, __LINE__, current.id, current.facet, current.operation);
}
}
ReplicaSessionPrx
InternalRegistryI::registerReplica(const InternalReplicaInfoPtr& info,
- const InternalRegistryPrx& prx,
- const Ice::Current& current)
+ const InternalRegistryPrx& prx,
+ const Ice::Current& current)
{
const Ice::LoggerPtr logger = _database->getTraceLevels()->logger;
try
{
- ReplicaSessionIPtr s = new ReplicaSessionI(_database, _wellKnownObjects, info, prx, _replicaSessionTimeout);
- _reaper->add(new SessionReapable<ReplicaSessionI>(logger, s), _replicaSessionTimeout);
- return s->getProxy();
+ ReplicaSessionIPtr s = new ReplicaSessionI(_database, _wellKnownObjects, info, prx, _replicaSessionTimeout);
+ _reaper->add(new SessionReapable<ReplicaSessionI>(logger, s), _replicaSessionTimeout);
+ return s->getProxy();
}
catch(const Ice::ObjectAdapterDeactivatedException&)
{
- throw Ice::ObjectNotExistException(__FILE__, __LINE__, current.id, current.facet, current.operation);
+ throw Ice::ObjectNotExistException(__FILE__, __LINE__, current.id, current.facet, current.operation);
}
}
@@ -94,7 +94,7 @@ InternalRegistryI::getNodes(const Ice::Current&) const
Ice::ObjectProxySeq proxies = _database->getInternalObjectsByType(Node::ice_staticId());
for(Ice::ObjectProxySeq::const_iterator p = proxies.begin(); p != proxies.end(); ++p)
{
- nodes.push_back(NodePrx::uncheckedCast(*p));
+ nodes.push_back(NodePrx::uncheckedCast(*p));
}
return nodes;
}
@@ -106,7 +106,7 @@ InternalRegistryI::getReplicas(const Ice::Current&) const
Ice::ObjectProxySeq proxies = _database->getObjectsByType(InternalRegistry::ice_staticId());
for(Ice::ObjectProxySeq::const_iterator p = proxies.begin(); p != proxies.end(); ++p)
{
- replicas.push_back(InternalRegistryPrx::uncheckedCast(*p));
+ replicas.push_back(InternalRegistryPrx::uncheckedCast(*p));
}
return replicas;
}
@@ -125,7 +125,7 @@ InternalRegistryI::getOffsetFromEnd(const string& filename, int count, const Ice
bool
InternalRegistryI::read(const string& filename, Ice::Long pos, int size, Ice::Long& newPos, Ice::StringSeq& lines,
- const Ice::Current&) const
+ const Ice::Current&) const
{
return _fileCache->read(getFilePath(filename), pos, size, newPos, lines);
}
@@ -136,23 +136,23 @@ InternalRegistryI::getFilePath(const string& filename) const
string file;
if(filename == "stderr")
{
- file = _database->getCommunicator()->getProperties()->getProperty("Ice.StdErr");
- if(file.empty())
- {
- throw FileNotAvailableException("Ice.StdErr configuration property is not set");
- }
+ file = _database->getCommunicator()->getProperties()->getProperty("Ice.StdErr");
+ if(file.empty())
+ {
+ throw FileNotAvailableException("Ice.StdErr configuration property is not set");
+ }
}
else if(filename == "stdout")
{
- file = _database->getCommunicator()->getProperties()->getProperty("Ice.StdOut");
- if(file.empty())
- {
- throw FileNotAvailableException("Ice.StdOut configuration property is not set");
- }
+ file = _database->getCommunicator()->getProperties()->getProperty("Ice.StdOut");
+ if(file.empty())
+ {
+ throw FileNotAvailableException("Ice.StdOut configuration property is not set");
+ }
}
else
{
- throw FileNotAvailableException("unknown file");
+ throw FileNotAvailableException("unknown file");
}
return file;
}
diff --git a/cpp/src/IceGrid/InternalRegistryI.h b/cpp/src/IceGrid/InternalRegistryI.h
index d528e8ce088..e13e292b8e9 100644
--- a/cpp/src/IceGrid/InternalRegistryI.h
+++ b/cpp/src/IceGrid/InternalRegistryI.h
@@ -38,13 +38,13 @@ class InternalRegistryI : public InternalRegistry
public:
InternalRegistryI(const RegistryIPtr&, const DatabasePtr&, const ReapThreadPtr&,
- const WellKnownObjectsManagerPtr&, ReplicaSessionManager&);
+ const WellKnownObjectsManagerPtr&, ReplicaSessionManager&);
virtual ~InternalRegistryI();
virtual NodeSessionPrx registerNode(const InternalNodeInfoPtr&, const NodePrx&, const LoadInfo&,
- const Ice::Current&);
+ const Ice::Current&);
virtual ReplicaSessionPrx registerReplica(const InternalReplicaInfoPtr&, const InternalRegistryPrx&,
- const Ice::Current&);
+ const Ice::Current&);
virtual void registerWithReplica(const InternalRegistryPrx&, const Ice::Current&);
diff --git a/cpp/src/IceGrid/LocatorI.cpp b/cpp/src/IceGrid/LocatorI.cpp
index 58cd8503f7a..9158def55ff 100644
--- a/cpp/src/IceGrid/LocatorI.cpp
+++ b/cpp/src/IceGrid/LocatorI.cpp
@@ -27,19 +27,19 @@ class AMI_Adapter_getDirectProxyI : public AMI_Adapter_getDirectProxy
public:
AMI_Adapter_getDirectProxyI(const LocatorIPtr& locator, const string& id, const LocatorAdapterInfo& adapter) :
- _locator(locator), _id(id), _adapter(adapter)
+ _locator(locator), _id(id), _adapter(adapter)
{
}
virtual void ice_response(const ::Ice::ObjectPrx& obj)
{
- assert(obj);
- _locator->getDirectProxyCallback(_adapter.proxy->ice_getIdentity(), obj);
+ assert(obj);
+ _locator->getDirectProxyCallback(_adapter.proxy->ice_getIdentity(), obj);
}
virtual void ice_exception(const ::Ice::Exception& ex)
{
- _locator->getDirectProxyException(_adapter, _id, ex);
+ _locator->getDirectProxyException(_adapter, _id, ex);
}
private:
@@ -54,18 +54,18 @@ class AMI_Adapter_activateI : public AMI_Adapter_activate
public:
AMI_Adapter_activateI(const LocatorIPtr& locator, const string& id, const LocatorAdapterInfo& adapter) :
- _locator(locator), _id(id), _adapter(adapter)
+ _locator(locator), _id(id), _adapter(adapter)
{
}
virtual void ice_response(const ::Ice::ObjectPrx& obj)
{
- _locator->getDirectProxyCallback(_adapter.proxy->ice_getIdentity(), obj);
+ _locator->getDirectProxyCallback(_adapter.proxy->ice_getIdentity(), obj);
}
virtual void ice_exception(const ::Ice::Exception& ex)
{
- _locator->getDirectProxyException(_adapter, _id, ex);
+ _locator->getDirectProxyException(_adapter, _id, ex);
}
private:
@@ -84,66 +84,66 @@ class AMD_Locator_findAdapterByIdI : public Ice::AMD_Locator_findAdapterById
public:
AMD_Locator_findAdapterByIdI(const Ice::AMD_Locator_findObjectByIdPtr& cb, const Ice::ObjectPrx& obj) :
- _cb(cb),
- _obj(obj)
+ _cb(cb),
+ _obj(obj)
{
}
virtual void ice_response(const ::Ice::ObjectPrx& obj)
{
- //
- // If the adapter dummy direct proxy is not null, return a
- // proxy containing the identity we were looking for and the
- // endpoints of the adapter.
- //
- // If null, return the proxy registered with the object
- // registry.
- //
- if(obj)
- {
- _cb->ice_response(obj->ice_identity(_obj->ice_getIdentity()));
- }
- else
- {
- _cb->ice_response(_obj);
- }
+ //
+ // If the adapter dummy direct proxy is not null, return a
+ // proxy containing the identity we were looking for and the
+ // endpoints of the adapter.
+ //
+ // If null, return the proxy registered with the object
+ // registry.
+ //
+ if(obj)
+ {
+ _cb->ice_response(obj->ice_identity(_obj->ice_getIdentity()));
+ }
+ else
+ {
+ _cb->ice_response(_obj);
+ }
}
virtual void ice_exception(const ::Ice::Exception& ex)
{
- try
- {
- ex.ice_throw();
- }
- catch(Ice::AdapterNotFoundException&)
- {
- //
- // We couldn't find the adapter, we ignore and return the
- // original proxy containing the adapter id.
- //
- _cb->ice_response(_obj);
- return;
- }
- catch(const Ice::Exception& ex)
- {
- //
- // Rethrow unexpected exception.
- //
- _cb->ice_exception(ex);
- return;
- }
-
- assert(false);
+ try
+ {
+ ex.ice_throw();
+ }
+ catch(Ice::AdapterNotFoundException&)
+ {
+ //
+ // We couldn't find the adapter, we ignore and return the
+ // original proxy containing the adapter id.
+ //
+ _cb->ice_response(_obj);
+ return;
+ }
+ catch(const Ice::Exception& ex)
+ {
+ //
+ // Rethrow unexpected exception.
+ //
+ _cb->ice_exception(ex);
+ return;
+ }
+
+ assert(false);
}
virtual void ice_exception(const std::exception& ex)
{
- _cb->ice_exception(ex);
+ _cb->ice_exception(ex);
}
virtual void ice_exception()
{
- _cb->ice_exception();
+ _cb->ice_exception();
}
private:
@@ -155,12 +155,12 @@ private:
}
LocatorI::Request::Request(const Ice::AMD_Locator_findAdapterByIdPtr& amdCB,
- const LocatorIPtr& locator,
- const string& id,
- bool replicaGroup,
- const LocatorAdapterInfoSeq& adapters,
- int count,
- const TraceLevelsPtr& traceLevels) :
+ const LocatorIPtr& locator,
+ const string& id,
+ bool replicaGroup,
+ const LocatorAdapterInfoSeq& adapters,
+ int count,
+ const TraceLevelsPtr& traceLevels) :
_amdCB(amdCB),
_locator(locator),
_id(id),
@@ -182,8 +182,8 @@ LocatorI::Request::execute()
//
if(_adapters.empty())
{
- sendResponse();
- return;
+ sendResponse();
+ return;
}
//
@@ -191,24 +191,24 @@ LocatorI::Request::execute()
//
LocatorAdapterInfoSeq adapters;
{
- Lock sync(*this);
- assert(_count > 0 && _lastAdapter != _adapters.end());
- for(unsigned int i = 0; i < _count; ++i)
- {
- if(_lastAdapter == _adapters.end())
- {
- _count = i;
- break;
- }
- assert(_lastAdapter->proxy);
- adapters.push_back(*_lastAdapter);
- ++_lastAdapter;
- }
+ Lock sync(*this);
+ assert(_count > 0 && _lastAdapter != _adapters.end());
+ for(unsigned int i = 0; i < _count; ++i)
+ {
+ if(_lastAdapter == _adapters.end())
+ {
+ _count = i;
+ break;
+ }
+ assert(_lastAdapter->proxy);
+ adapters.push_back(*_lastAdapter);
+ ++_lastAdapter;
+ }
}
assert(!adapters.empty());
for(LocatorAdapterInfoSeq::const_iterator p = adapters.begin(); p != adapters.end(); ++p)
{
- requestAdapter(*p);
+ requestAdapter(*p);
}
}
@@ -217,32 +217,32 @@ LocatorI::Request::exception(const Ice::Exception& ex)
{
LocatorAdapterInfo adapter;
{
- Lock sync(*this);
-
- if(!_exception.get())
- {
- _exception.reset(ex.ice_clone());
- }
-
- if(_lastAdapter == _adapters.end())
- {
- --_count; // Expect one less adapter proxy if there's no more adapters to query.
-
- //
- // If we received all the required proxies, it's time to send the
- // answer back to the client.
- //
- if(_count == _proxies.size())
- {
- sendResponse();
- }
- return;
- }
- else
- {
- adapter = *_lastAdapter;
- ++_lastAdapter;
- }
+ Lock sync(*this);
+
+ if(!_exception.get())
+ {
+ _exception.reset(ex.ice_clone());
+ }
+
+ if(_lastAdapter == _adapters.end())
+ {
+ --_count; // Expect one less adapter proxy if there's no more adapters to query.
+
+ //
+ // If we received all the required proxies, it's time to send the
+ // answer back to the client.
+ //
+ if(_count == _proxies.size())
+ {
+ sendResponse();
+ }
+ return;
+ }
+ else
+ {
+ adapter = *_lastAdapter;
+ ++_lastAdapter;
+ }
}
requestAdapter(adapter);
}
@@ -261,7 +261,7 @@ LocatorI::Request::response(const Ice::ObjectPrx& proxy)
//
if(_proxies.size() == _count)
{
- sendResponse();
+ sendResponse();
}
}
@@ -271,8 +271,8 @@ LocatorI::Request::requestAdapter(const LocatorAdapterInfo& adapter)
assert(adapter.proxy);
if(_locator->getDirectProxyRequest(this, adapter))
{
- AMI_Adapter_getDirectProxyPtr amiCB = new AMI_Adapter_getDirectProxyI(_locator, _id, adapter);
- adapter.proxy->getDirectProxy_async(amiCB);
+ AMI_Adapter_getDirectProxyPtr amiCB = new AMI_Adapter_getDirectProxyI(_locator, _id, adapter);
+ adapter.proxy->getDirectProxy_async(amiCB);
}
}
@@ -281,45 +281,45 @@ LocatorI::Request::sendResponse()
{
if(_proxies.size() == 1)
{
- _amdCB->ice_response(_proxies.back());
+ _amdCB->ice_response(_proxies.back());
}
else if(_proxies.empty())
{
- //
- // If there's no proxies, it's either because we couldn't
- // contact the adapters or because the replica group has
- // no members.
- //
- assert(_exception.get() || _replicaGroup && _adapters.empty());
-
- if(_traceLevels->locator > 0)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->locatorCat);
- out << "couldn't resolve " << (_replicaGroup ? "replica group `" : "adapter `") << _id << "' endpoints:\n";
- out << (_exception.get() ? toString(*_exception) : string("replica group is empty"));
- }
- _amdCB->ice_response(0);
+ //
+ // If there's no proxies, it's either because we couldn't
+ // contact the adapters or because the replica group has
+ // no members.
+ //
+ assert(_exception.get() || _replicaGroup && _adapters.empty());
+
+ if(_traceLevels->locator > 0)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->locatorCat);
+ out << "couldn't resolve " << (_replicaGroup ? "replica group `" : "adapter `") << _id << "' endpoints:\n";
+ out << (_exception.get() ? toString(*_exception) : string("replica group is empty"));
+ }
+ _amdCB->ice_response(0);
}
else if(_proxies.size() > 1)
{
- Ice::EndpointSeq endpoints;
- endpoints.reserve(_proxies.size());
- for(vector<Ice::ObjectPrx>::const_iterator p = _proxies.begin(); p != _proxies.end(); ++p)
- {
- Ice::EndpointSeq edpts = (*p)->ice_getEndpoints();
- endpoints.insert(endpoints.end(), edpts.begin(), edpts.end());
- }
+ Ice::EndpointSeq endpoints;
+ endpoints.reserve(_proxies.size());
+ for(vector<Ice::ObjectPrx>::const_iterator p = _proxies.begin(); p != _proxies.end(); ++p)
+ {
+ Ice::EndpointSeq edpts = (*p)->ice_getEndpoints();
+ endpoints.insert(endpoints.end(), edpts.begin(), edpts.end());
+ }
- Ice::ObjectPrx proxy = _locator->getCommunicator()->stringToProxy("dummy:default");
- _amdCB->ice_response(proxy->ice_endpoints(endpoints));
+ Ice::ObjectPrx proxy = _locator->getCommunicator()->stringToProxy("dummy:default");
+ _amdCB->ice_response(proxy->ice_endpoints(endpoints));
}
}
LocatorI::LocatorI(const Ice::CommunicatorPtr& communicator,
- const DatabasePtr& database,
- const Ice::LocatorRegistryPrx& locatorRegistry,
- const RegistryPrx& registry,
- const QueryPrx& query) :
+ const DatabasePtr& database,
+ const Ice::LocatorRegistryPrx& locatorRegistry,
+ const RegistryPrx& registry,
+ const QueryPrx& query) :
_communicator(communicator),
_database(database),
_locatorRegistry(locatorRegistry),
@@ -334,17 +334,17 @@ LocatorI::LocatorI(const Ice::CommunicatorPtr& communicator,
//
void
LocatorI::findObjectById_async(const Ice::AMD_Locator_findObjectByIdPtr& cb,
- const Ice::Identity& id,
- const Ice::Current& current) const
+ const Ice::Identity& id,
+ const Ice::Current& current) const
{
Ice::ObjectPrx proxy;
try
{
- proxy = _database->getObjectProxy(id);
+ proxy = _database->getObjectProxy(id);
}
catch(const ObjectNotRegisteredException&)
{
- throw Ice::ObjectNotFoundException();
+ throw Ice::ObjectNotFoundException();
}
assert(proxy);
@@ -358,12 +358,12 @@ LocatorI::findObjectById_async(const Ice::AMD_Locator_findObjectByIdPtr& cb,
const string adapterId = proxy->ice_getAdapterId();
if(!adapterId.empty())
{
- Ice::AMD_Locator_findAdapterByIdPtr amiCB = new AMD_Locator_findAdapterByIdI(cb, proxy);
- findAdapterById_async(amiCB, adapterId, current);
+ Ice::AMD_Locator_findAdapterByIdPtr amiCB = new AMD_Locator_findAdapterByIdI(cb, proxy);
+ findAdapterById_async(amiCB, adapterId, current);
}
else
{
- cb->ice_response(proxy);
+ cb->ice_response(proxy);
}
}
@@ -373,54 +373,54 @@ LocatorI::findObjectById_async(const Ice::AMD_Locator_findObjectByIdPtr& cb,
//
void
LocatorI::findAdapterById_async(const Ice::AMD_Locator_findAdapterByIdPtr& cb,
- const string& id,
- const Ice::Current&) const
+ const string& id,
+ const Ice::Current&) const
{
bool replicaGroup = false;
try
{
- //
- // NOTE: getProxies() might throw if the adapter is a server
- // adapter and the node is unreachable (it doesn't throw for
- // replica groups).
- //
- int count;
- LocatorAdapterInfoSeq adapters;
- _database->getAdapter(id)->getLocatorAdapterInfo(adapters, count, replicaGroup);
+ //
+ // NOTE: getProxies() might throw if the adapter is a server
+ // adapter and the node is unreachable (it doesn't throw for
+ // replica groups).
+ //
+ int count;
+ LocatorAdapterInfoSeq adapters;
+ _database->getAdapter(id)->getLocatorAdapterInfo(adapters, count, replicaGroup);
- LocatorIPtr self = const_cast<LocatorI*>(this);
- RequestPtr request = new Request(cb, self, id, replicaGroup, adapters, count, _database->getTraceLevels());
- request->execute();
+ LocatorIPtr self = const_cast<LocatorI*>(this);
+ RequestPtr request = new Request(cb, self, id, replicaGroup, adapters, count, _database->getTraceLevels());
+ request->execute();
}
catch(const AdapterNotExistException&)
{
- try
- {
- cb->ice_response(_database->getAdapterDirectProxy(id));
- }
- catch(const AdapterNotExistException&)
- {
- cb->ice_exception(Ice::AdapterNotFoundException());
- }
- return;
+ try
+ {
+ cb->ice_response(_database->getAdapterDirectProxy(id));
+ }
+ catch(const AdapterNotExistException&)
+ {
+ cb->ice_exception(Ice::AdapterNotFoundException());
+ }
+ return;
}
catch(const Ice::Exception& ex)
{
- const TraceLevelsPtr traceLevels = _database->getTraceLevels();
- if(traceLevels->locator > 0)
- {
- Ice::Trace out(traceLevels->logger, traceLevels->locatorCat);
- if(replicaGroup)
- {
- out << "couldn't resolve replica group `" << id << "' endpoints:\n" << toString(ex);
- }
- else
- {
- out << "couldn't resolve adapter `" << id << "' endpoints:\n" << toString(ex);
- }
- }
- cb->ice_response(0);
- return;
+ const TraceLevelsPtr traceLevels = _database->getTraceLevels();
+ if(traceLevels->locator > 0)
+ {
+ Ice::Trace out(traceLevels->logger, traceLevels->locatorCat);
+ if(replicaGroup)
+ {
+ out << "couldn't resolve replica group `" << id << "' endpoints:\n" << toString(ex);
+ }
+ else
+ {
+ out << "couldn't resolve adapter `" << id << "' endpoints:\n" << toString(ex);
+ }
+ }
+ cb->ice_response(0);
+ return;
}
}
@@ -463,24 +463,24 @@ LocatorI::getDirectProxyException(const LocatorAdapterInfo& adpt, const string&
{
try
{
- ex.ice_throw();
+ ex.ice_throw();
}
catch(const AdapterNotActiveException& ex)
{
- if(ex.activatable)
- {
- //
- // Activate the adapter if it can be activated on demand.
- //
- // NOTE: we use a timeout large enough to ensure that the
- // activate() call won't timeout if the server hangs in
- // deactivation and/or activation.
- //
- AMI_Adapter_activatePtr amiCB = new AMI_Adapter_activateI(this, id, adpt);
- int timeout = adpt.activationTimeout + adpt.deactivationTimeout;
- AdapterPrx::uncheckedCast(adpt.proxy->ice_timeout(timeout * 1000))->activate_async(amiCB);
- return;
- }
+ if(ex.activatable)
+ {
+ //
+ // Activate the adapter if it can be activated on demand.
+ //
+ // NOTE: we use a timeout large enough to ensure that the
+ // activate() call won't timeout if the server hangs in
+ // deactivation and/or activation.
+ //
+ AMI_Adapter_activatePtr amiCB = new AMI_Adapter_activateI(this, id, adpt);
+ int timeout = adpt.activationTimeout + adpt.deactivationTimeout;
+ AdapterPrx::uncheckedCast(adpt.proxy->ice_timeout(timeout * 1000))->activate_async(amiCB);
+ return;
+ }
}
catch(const Ice::Exception&)
{
@@ -488,16 +488,16 @@ LocatorI::getDirectProxyException(const LocatorAdapterInfo& adpt, const string&
PendingRequests requests;
{
- Lock sync(*this);
- PendingRequestsMap::iterator p = _pendingRequests.find(adpt.proxy->ice_getIdentity());
- assert(p != _pendingRequests.end());
- requests.swap(p->second);
- _pendingRequests.erase(p);
+ Lock sync(*this);
+ PendingRequestsMap::iterator p = _pendingRequests.find(adpt.proxy->ice_getIdentity());
+ assert(p != _pendingRequests.end());
+ requests.swap(p->second);
+ _pendingRequests.erase(p);
}
for(PendingRequests::iterator q = requests.begin(); q != requests.end(); ++q)
{
- (*q)->exception(ex);
+ (*q)->exception(ex);
}
}
@@ -506,26 +506,26 @@ LocatorI::getDirectProxyCallback(const Ice::Identity& adapterId, const Ice::Obje
{
PendingRequests requests;
{
- Lock sync(*this);
- PendingRequestsMap::iterator p = _pendingRequests.find(adapterId);
- assert(p != _pendingRequests.end());
- requests.swap(p->second);
- _pendingRequests.erase(p);
+ Lock sync(*this);
+ PendingRequestsMap::iterator p = _pendingRequests.find(adapterId);
+ assert(p != _pendingRequests.end());
+ requests.swap(p->second);
+ _pendingRequests.erase(p);
}
if(proxy)
{
- for(PendingRequests::const_iterator q = requests.begin(); q != requests.end(); ++q)
- {
- (*q)->response(proxy);
- }
+ for(PendingRequests::const_iterator q = requests.begin(); q != requests.end(); ++q)
+ {
+ (*q)->response(proxy);
+ }
}
else
{
- for(PendingRequests::const_iterator q = requests.begin(); q != requests.end(); ++q)
- {
- (*q)->exception(AdapterNotActiveException());
- }
+ for(PendingRequests::const_iterator q = requests.begin(); q != requests.end(); ++q)
+ {
+ (*q)->exception(AdapterNotActiveException());
+ }
}
}
diff --git a/cpp/src/IceGrid/LocatorI.h b/cpp/src/IceGrid/LocatorI.h
index 96cd6a96d37..e36741631f9 100644
--- a/cpp/src/IceGrid/LocatorI.h
+++ b/cpp/src/IceGrid/LocatorI.h
@@ -34,41 +34,41 @@ class LocatorI : public Locator, public IceUtil::Mutex
{
public:
- Request(const Ice::AMD_Locator_findAdapterByIdPtr&, const LocatorIPtr&, const std::string&, bool,
- const LocatorAdapterInfoSeq&, int, const TraceLevelsPtr&);
+ Request(const Ice::AMD_Locator_findAdapterByIdPtr&, const LocatorIPtr&, const std::string&, bool,
+ const LocatorAdapterInfoSeq&, int, const TraceLevelsPtr&);
- void execute();
- void response(const Ice::ObjectPrx&);
- void exception(const Ice::Exception&);
+ void execute();
+ void response(const Ice::ObjectPrx&);
+ void exception(const Ice::Exception&);
private:
- void requestAdapter(const LocatorAdapterInfo&);
- void sendResponse();
-
- const Ice::AMD_Locator_findAdapterByIdPtr _amdCB;
- const LocatorIPtr _locator;
- const std::string _id;
- const bool _replicaGroup;
- LocatorAdapterInfoSeq _adapters;
- const TraceLevelsPtr _traceLevels;
- unsigned int _count;
- LocatorAdapterInfoSeq::const_iterator _lastAdapter;
- std::vector<Ice::ObjectPrx> _proxies;
- std::auto_ptr<Ice::Exception> _exception;
+ void requestAdapter(const LocatorAdapterInfo&);
+ void sendResponse();
+
+ const Ice::AMD_Locator_findAdapterByIdPtr _amdCB;
+ const LocatorIPtr _locator;
+ const std::string _id;
+ const bool _replicaGroup;
+ LocatorAdapterInfoSeq _adapters;
+ const TraceLevelsPtr _traceLevels;
+ unsigned int _count;
+ LocatorAdapterInfoSeq::const_iterator _lastAdapter;
+ std::vector<Ice::ObjectPrx> _proxies;
+ std::auto_ptr<Ice::Exception> _exception;
};
typedef IceUtil::Handle<Request> RequestPtr;
public:
LocatorI(const Ice::CommunicatorPtr&, const DatabasePtr&, const Ice::LocatorRegistryPrx&, const RegistryPrx&,
- const QueryPrx&);
+ const QueryPrx&);
virtual void findObjectById_async(const Ice::AMD_Locator_findObjectByIdPtr&, const Ice::Identity&,
- const Ice::Current&) const;
+ const Ice::Current&) const;
virtual void findAdapterById_async(const Ice::AMD_Locator_findAdapterByIdPtr&, const ::std::string&,
- const Ice::Current&) const;
+ const Ice::Current&) const;
virtual Ice::LocatorRegistryPrx getRegistry(const Ice::Current&) const;
virtual RegistryPrx getLocalRegistry(const Ice::Current&) const;
diff --git a/cpp/src/IceGrid/LocatorRegistryI.cpp b/cpp/src/IceGrid/LocatorRegistryI.cpp
index c4958152f20..01b01795192 100644
--- a/cpp/src/IceGrid/LocatorRegistryI.cpp
+++ b/cpp/src/IceGrid/LocatorRegistryI.cpp
@@ -25,53 +25,53 @@ class SetDirectProxyCB : public AMI_Adapter_setDirectProxy
public:
SetDirectProxyCB(const AmdCB& cb,
- const TraceLevelsPtr& traceLevels,
- const string& id,
- const Ice::ObjectPrx& proxy) :
- _cb(cb), _traceLevels(traceLevels), _id(id), _proxy(proxy)
+ const TraceLevelsPtr& traceLevels,
+ const string& id,
+ const Ice::ObjectPrx& proxy) :
+ _cb(cb), _traceLevels(traceLevels), _id(id), _proxy(proxy)
{
}
virtual void ice_response()
{
- if(_traceLevels->locator > 1)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->locatorCat);
- out << "registered adapter `" << _id << "' endpoints: `";
- out << (_proxy ? _proxy->ice_toString() : string("")) << "'";
- }
- _cb->ice_response();
+ if(_traceLevels->locator > 1)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->locatorCat);
+ out << "registered adapter `" << _id << "' endpoints: `";
+ out << (_proxy ? _proxy->ice_toString() : string("")) << "'";
+ }
+ _cb->ice_response();
}
virtual void ice_exception(const ::Ice::Exception& ex)
{
- if(_traceLevels->locator > 1)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->locatorCat);
- out << "failed to register adapter `" << _id << "' endpoints:\n" << ex;
- }
-
- try
- {
- ex.ice_throw();
- }
- catch(const AdapterActiveException&)
- {
- _cb->ice_exception(Ice::AdapterAlreadyActiveException());
- return;
- }
- catch(const Ice::ObjectNotExistException&)
- {
- _cb->ice_exception(Ice::AdapterNotFoundException()); // Expected if the adapter was destroyed.
- return;
- }
- catch(const Ice::LocalException&)
- {
- _cb->ice_exception(Ice::AdapterNotFoundException());
- return;
- }
+ if(_traceLevels->locator > 1)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->locatorCat);
+ out << "failed to register adapter `" << _id << "' endpoints:\n" << ex;
+ }
+
+ try
+ {
+ ex.ice_throw();
+ }
+ catch(const AdapterActiveException&)
+ {
+ _cb->ice_exception(Ice::AdapterAlreadyActiveException());
+ return;
+ }
+ catch(const Ice::ObjectNotExistException&)
+ {
+ _cb->ice_exception(Ice::AdapterNotFoundException()); // Expected if the adapter was destroyed.
+ return;
+ }
+ catch(const Ice::LocalException&)
+ {
+ _cb->ice_exception(Ice::AdapterNotFoundException());
+ return;
+ }
- assert(false);
+ assert(false);
}
private:
@@ -93,49 +93,49 @@ class AMI_Server_setProcessI : public AMI_Server_setProcess
public:
AMI_Server_setProcessI(const Ice::AMD_LocatorRegistry_setServerProcessProxyPtr& cb,
- const TraceLevelsPtr& traceLevels,
- const string& id,
- const Ice::ObjectPrx& proxy) :
- _cb(cb), _traceLevels(traceLevels), _id(id), _proxy(proxy)
+ const TraceLevelsPtr& traceLevels,
+ const string& id,
+ const Ice::ObjectPrx& proxy) :
+ _cb(cb), _traceLevels(traceLevels), _id(id), _proxy(proxy)
{
}
virtual void ice_response()
{
- if(_traceLevels->locator > 1)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->locatorCat);
- out << "registered server `" << _id << "' process proxy: `";
- out << (_proxy ? _proxy->ice_toString() : string("")) << "'";
- }
- _cb->ice_response();
+ if(_traceLevels->locator > 1)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->locatorCat);
+ out << "registered server `" << _id << "' process proxy: `";
+ out << (_proxy ? _proxy->ice_toString() : string("")) << "'";
+ }
+ _cb->ice_response();
}
virtual void ice_exception(const ::Ice::Exception& ex)
{
- if(_traceLevels->locator > 1)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->locatorCat);
- out << "failed to register server process proxy `" << _id << "':\n" << ex;
- }
+ if(_traceLevels->locator > 1)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->locatorCat);
+ out << "failed to register server process proxy `" << _id << "':\n" << ex;
+ }
- try
- {
- ex.ice_throw();
- }
- catch(const Ice::ObjectNotExistException&)
- {
- // Expected if the server was destroyed.
- _cb->ice_exception(Ice::ServerNotFoundException());
- return;
- }
- catch(const Ice::LocalException&)
- {
- _cb->ice_exception(Ice::ServerNotFoundException());
- return;
- }
+ try
+ {
+ ex.ice_throw();
+ }
+ catch(const Ice::ObjectNotExistException&)
+ {
+ // Expected if the server was destroyed.
+ _cb->ice_exception(Ice::ServerNotFoundException());
+ return;
+ }
+ catch(const Ice::LocalException&)
+ {
+ _cb->ice_exception(Ice::ServerNotFoundException());
+ return;
+ }
- assert(false);
+ assert(false);
}
private:
@@ -149,9 +149,9 @@ private:
};
LocatorRegistryI::LocatorRegistryI(const DatabasePtr& database,
- bool dynamicRegistration,
- bool master,
- ReplicaSessionManager& session) :
+ bool dynamicRegistration,
+ bool master,
+ ReplicaSessionManager& session) :
_database(database),
_dynamicRegistration(dynamicRegistration),
_master(master),
@@ -161,14 +161,14 @@ LocatorRegistryI::LocatorRegistryI(const DatabasePtr& database,
void
LocatorRegistryI::setAdapterDirectProxy_async(const Ice::AMD_LocatorRegistry_setAdapterDirectProxyPtr& cb,
- const string& adapterId,
- const Ice::ObjectPrx& proxy,
- const Ice::Current&)
+ const string& adapterId,
+ const Ice::ObjectPrx& proxy,
+ const Ice::Current&)
{
setAdapterDirectProxy(newSetDirectProxyCB(cb, _database->getTraceLevels(), adapterId, proxy),
- adapterId,
- "",
- proxy);
+ adapterId,
+ "",
+ proxy);
}
void
@@ -180,140 +180,140 @@ LocatorRegistryI::setReplicatedAdapterDirectProxy_async(
const Ice::Current&)
{
setAdapterDirectProxy(newSetDirectProxyCB(cb, _database->getTraceLevels(), adapterId, proxy),
- adapterId,
- replicaGroupId,
- proxy);
+ adapterId,
+ replicaGroupId,
+ proxy);
}
void
LocatorRegistryI::setServerProcessProxy_async(const Ice::AMD_LocatorRegistry_setServerProcessProxyPtr& cb,
- const string& id,
- const Ice::ProcessPrx& proxy,
- const Ice::Current&)
+ const string& id,
+ const Ice::ProcessPrx& proxy,
+ const Ice::Current&)
{
try
{
//
// Get the server from the registry and set its process proxy.
//
- // NOTE: We pass false to the getServer call to indicate that
- // we don't necessarily want an up-to-date adapter proxy. This
- // is needed for the session activation mode for cases where
- // the server is released during the server startup.
- //
- AMI_Server_setProcessPtr amiCB = new AMI_Server_setProcessI(cb, _database->getTraceLevels(), id, proxy);
+ // NOTE: We pass false to the getServer call to indicate that
+ // we don't necessarily want an up-to-date adapter proxy. This
+ // is needed for the session activation mode for cases where
+ // the server is released during the server startup.
+ //
+ AMI_Server_setProcessPtr amiCB = new AMI_Server_setProcessI(cb, _database->getTraceLevels(), id, proxy);
_database->getServer(id)->getProxy(false)->setProcess_async(amiCB, proxy);
}
catch(const ServerNotExistException&)
{
- cb->ice_exception(Ice::ServerNotFoundException());
+ cb->ice_exception(Ice::ServerNotFoundException());
}
catch(const Ice::Exception& ex)
{
- const TraceLevelsPtr traceLevels = _database->getTraceLevels();
- if(traceLevels->locator > 0)
- {
- Ice::Trace out(traceLevels->logger, traceLevels->locatorCat);
- out << "couldn't register server `" << id << "' process proxy:\n" << toString(ex);
- }
- cb->ice_exception(Ice::ServerNotFoundException());
+ const TraceLevelsPtr traceLevels = _database->getTraceLevels();
+ if(traceLevels->locator > 0)
+ {
+ Ice::Trace out(traceLevels->logger, traceLevels->locatorCat);
+ out << "couldn't register server `" << id << "' process proxy:\n" << toString(ex);
+ }
+ cb->ice_exception(Ice::ServerNotFoundException());
}
}
void
LocatorRegistryI::setAdapterDirectProxy(const AMI_Adapter_setDirectProxyPtr& amiCB,
- const string& adapterId,
- const string& replicaGroupId,
- const Ice::ObjectPrx& proxy)
+ const string& adapterId,
+ const string& replicaGroupId,
+ const Ice::ObjectPrx& proxy)
{
int nRetry = 5;
do
{
- try
- {
- //
- // Get the adapter from the registry and set its direct proxy.
- //
- ServerAdapterEntryPtr adapter = ServerAdapterEntryPtr::dynamicCast(_database->getAdapter(adapterId));
- if(!adapter)
- {
- throw Ice::AdapterNotFoundException();
- }
- adapter->getProxy(replicaGroupId, false)->setDirectProxy_async(amiCB, proxy);
- return;
- }
- catch(const AdapterNotExistException&)
- {
- if(!_dynamicRegistration)
- {
- throw Ice::AdapterNotFoundException();
- }
- }
- catch(const Ice::Exception& ex)
- {
- const TraceLevelsPtr traceLevels = _database->getTraceLevels();
- if(traceLevels->locator > 0)
- {
- Ice::Trace out(traceLevels->logger, traceLevels->locatorCat);
- out << "couldn't register adapter `" << adapterId << "' endpoints:\n" << toString(ex);
- }
- throw Ice::AdapterNotFoundException();
- }
-
- assert(_dynamicRegistration);
- if(_master)
- {
- try
- {
- _database->setAdapterDirectProxy(adapterId, replicaGroupId, proxy);
- amiCB->ice_response();
- return;
- }
- catch(const AdapterExistsException&)
- {
- // Continue
- }
- }
- else
- {
- ReplicaSessionPrx session = _session.getSession();
- if(!session)
- {
- const TraceLevelsPtr traceLevels = _database->getTraceLevels();
- if(traceLevels->locator > 0)
- {
- Ice::Trace out(traceLevels->logger, traceLevels->locatorCat);
- out << "couldn't register adapter `" << adapterId << "' endpoints with master:\n";
- out << "no session established with the master";
- }
- throw Ice::AdapterNotFoundException();
- }
+ try
+ {
+ //
+ // Get the adapter from the registry and set its direct proxy.
+ //
+ ServerAdapterEntryPtr adapter = ServerAdapterEntryPtr::dynamicCast(_database->getAdapter(adapterId));
+ if(!adapter)
+ {
+ throw Ice::AdapterNotFoundException();
+ }
+ adapter->getProxy(replicaGroupId, false)->setDirectProxy_async(amiCB, proxy);
+ return;
+ }
+ catch(const AdapterNotExistException&)
+ {
+ if(!_dynamicRegistration)
+ {
+ throw Ice::AdapterNotFoundException();
+ }
+ }
+ catch(const Ice::Exception& ex)
+ {
+ const TraceLevelsPtr traceLevels = _database->getTraceLevels();
+ if(traceLevels->locator > 0)
+ {
+ Ice::Trace out(traceLevels->logger, traceLevels->locatorCat);
+ out << "couldn't register adapter `" << adapterId << "' endpoints:\n" << toString(ex);
+ }
+ throw Ice::AdapterNotFoundException();
+ }
+
+ assert(_dynamicRegistration);
+ if(_master)
+ {
+ try
+ {
+ _database->setAdapterDirectProxy(adapterId, replicaGroupId, proxy);
+ amiCB->ice_response();
+ return;
+ }
+ catch(const AdapterExistsException&)
+ {
+ // Continue
+ }
+ }
+ else
+ {
+ ReplicaSessionPrx session = _session.getSession();
+ if(!session)
+ {
+ const TraceLevelsPtr traceLevels = _database->getTraceLevels();
+ if(traceLevels->locator > 0)
+ {
+ Ice::Trace out(traceLevels->logger, traceLevels->locatorCat);
+ out << "couldn't register adapter `" << adapterId << "' endpoints with master:\n";
+ out << "no session established with the master";
+ }
+ throw Ice::AdapterNotFoundException();
+ }
- try
- {
- session->setAdapterDirectProxy(adapterId, replicaGroupId, proxy);
- amiCB->ice_response();
- return;
- }
- catch(const AdapterExistsException&)
- {
- // Continue
- }
- catch(const AdapterNotExistException&)
- {
- throw Ice::AdapterNotFoundException(); // Dynamic registration not allowed on the master.
- }
- catch(const Ice::LocalException& ex)
- {
- const TraceLevelsPtr traceLevels = _database->getTraceLevels();
- if(traceLevels->locator > 0)
- {
- Ice::Trace out(traceLevels->logger, traceLevels->locatorCat);
- out << "couldn't register adapter `" << adapterId << "' endpoints with master:\n" << toString(ex);
- }
- throw Ice::AdapterNotFoundException();
- }
- }
+ try
+ {
+ session->setAdapterDirectProxy(adapterId, replicaGroupId, proxy);
+ amiCB->ice_response();
+ return;
+ }
+ catch(const AdapterExistsException&)
+ {
+ // Continue
+ }
+ catch(const AdapterNotExistException&)
+ {
+ throw Ice::AdapterNotFoundException(); // Dynamic registration not allowed on the master.
+ }
+ catch(const Ice::LocalException& ex)
+ {
+ const TraceLevelsPtr traceLevels = _database->getTraceLevels();
+ if(traceLevels->locator > 0)
+ {
+ Ice::Trace out(traceLevels->logger, traceLevels->locatorCat);
+ out << "couldn't register adapter `" << adapterId << "' endpoints with master:\n" << toString(ex);
+ }
+ throw Ice::AdapterNotFoundException();
+ }
+ }
}
while(nRetry-- > 0);
throw Ice::AdapterNotFoundException();
diff --git a/cpp/src/IceGrid/LocatorRegistryI.h b/cpp/src/IceGrid/LocatorRegistryI.h
index 51ed4319109..58139160106 100644
--- a/cpp/src/IceGrid/LocatorRegistryI.h
+++ b/cpp/src/IceGrid/LocatorRegistryI.h
@@ -28,19 +28,19 @@ public:
LocatorRegistryI(const DatabasePtr&, bool, bool, ReplicaSessionManager&);
virtual void setAdapterDirectProxy_async(const Ice::AMD_LocatorRegistry_setAdapterDirectProxyPtr&,
- const std::string&, const Ice::ObjectPrx&, const Ice::Current&);
+ const std::string&, const Ice::ObjectPrx&, const Ice::Current&);
virtual void setReplicatedAdapterDirectProxy_async(
- const Ice::AMD_LocatorRegistry_setReplicatedAdapterDirectProxyPtr&, const std::string&, const std::string&,
- const Ice::ObjectPrx&, const Ice::Current&);
+ const Ice::AMD_LocatorRegistry_setReplicatedAdapterDirectProxyPtr&, const std::string&, const std::string&,
+ const Ice::ObjectPrx&, const Ice::Current&);
virtual void setServerProcessProxy_async(const Ice::AMD_LocatorRegistry_setServerProcessProxyPtr&,
- const ::std::string&, const ::Ice::ProcessPrx&, const ::Ice::Current&);
+ const ::std::string&, const ::Ice::ProcessPrx&, const ::Ice::Current&);
private:
void setAdapterDirectProxy(const AMI_Adapter_setDirectProxyPtr&, const std::string&, const std::string&,
- const Ice::ObjectPrx&);
+ const Ice::ObjectPrx&);
const DatabasePtr _database;
const bool _dynamicRegistration;
diff --git a/cpp/src/IceGrid/NodeCache.cpp b/cpp/src/IceGrid/NodeCache.cpp
index 63e23ea919c..a431b527712 100644
--- a/cpp/src/IceGrid/NodeCache.cpp
+++ b/cpp/src/IceGrid/NodeCache.cpp
@@ -29,107 +29,107 @@ namespace IceGrid
struct ToInternalServerDescriptor : std::unary_function<CommunicatorDescriptorPtr&, void>
{
ToInternalServerDescriptor(const InternalServerDescriptorPtr& descriptor, const InternalNodeInfoPtr& node) :
- _desc(descriptor),
- _node(node)
+ _desc(descriptor),
+ _node(node)
{
}
void
operator()(const CommunicatorDescriptorPtr& desc)
{
- //
- // Figure out the configuration file name for the communicator
- // (if it's a service, it's "config_<service name>", if it's
- // the server, it's just "config").
- //
- string filename = "config";
- ServiceDescriptorPtr svc = ServiceDescriptorPtr::dynamicCast(desc);
- if(svc)
- {
- filename += "_" + svc->name;
- }
- PropertyDescriptorSeq& props = _desc->properties[filename];
-
- PropertyDescriptorSeq communicatorProps = desc->propertySet.properties;
-
- //
- // Add the adapters and their configuration.
- //
- for(AdapterDescriptorSeq::const_iterator q = desc->adapters.begin(); q != desc->adapters.end(); ++q)
- {
- _desc->adapters.push_back(new InternalAdapterDescriptor(q->id, q->serverLifetime));
-
- props.push_back(createProperty("# Object adapter " + q->name));
- PropertyDescriptor prop = removeProperty(communicatorProps, "Ice.OA." + q->name + ".Endpoints");
- prop.name = "Ice.OA." + q->name + ".Endpoints";
- props.push_back(prop);
- props.push_back(createProperty("Ice.OA." + q->name + ".AdapterId", q->id));
- if(!q->replicaGroupId.empty())
- {
- props.push_back(createProperty("Ice.OA." + q->name + ".ReplicaGroupId", q->replicaGroupId));
- }
- if(q->registerProcess)
- {
- props.push_back(createProperty("Ice.OA." + q->name + ".RegisterProcess", "1"));
- _desc->processRegistered = true;
- }
- }
-
- _desc->logs.insert(_desc->logs.end(), desc->logs.begin(), desc->logs.end());
-
- const string dbsPath = _node->dataDir + "/servers/" + _desc->id + "/dbs/";
- for(DbEnvDescriptorSeq::const_iterator p = desc->dbEnvs.begin(); p != desc->dbEnvs.end(); ++p)
- {
- props.push_back(createProperty("# Database environment " + p->name));
- if(p->dbHome.empty())
- {
- _desc->dbEnvs.push_back(new InternalDbEnvDescriptor(p->name, p->properties));
- props.push_back(createProperty("Freeze.DbEnv." + p->name + ".DbHome", dbsPath + p->name));
- }
- else
- {
- props.push_back(createProperty("Freeze.DbEnv." + p->name + ".DbHome", p->dbHome));
- }
- }
-
- //
- // Copy the communicator descriptor properties.
- //
- if(!communicatorProps.empty())
- {
- if(svc)
- {
- props.push_back(createProperty("# Service descriptor properties"));
- }
- else
- {
- props.push_back(createProperty("# Server descriptor properties"));
- }
- copy(communicatorProps.begin(), communicatorProps.end(), back_inserter(props));
- }
+ //
+ // Figure out the configuration file name for the communicator
+ // (if it's a service, it's "config_<service name>", if it's
+ // the server, it's just "config").
+ //
+ string filename = "config";
+ ServiceDescriptorPtr svc = ServiceDescriptorPtr::dynamicCast(desc);
+ if(svc)
+ {
+ filename += "_" + svc->name;
+ }
+ PropertyDescriptorSeq& props = _desc->properties[filename];
+
+ PropertyDescriptorSeq communicatorProps = desc->propertySet.properties;
+
+ //
+ // Add the adapters and their configuration.
+ //
+ for(AdapterDescriptorSeq::const_iterator q = desc->adapters.begin(); q != desc->adapters.end(); ++q)
+ {
+ _desc->adapters.push_back(new InternalAdapterDescriptor(q->id, q->serverLifetime));
+
+ props.push_back(createProperty("# Object adapter " + q->name));
+ PropertyDescriptor prop = removeProperty(communicatorProps, "Ice.OA." + q->name + ".Endpoints");
+ prop.name = "Ice.OA." + q->name + ".Endpoints";
+ props.push_back(prop);
+ props.push_back(createProperty("Ice.OA." + q->name + ".AdapterId", q->id));
+ if(!q->replicaGroupId.empty())
+ {
+ props.push_back(createProperty("Ice.OA." + q->name + ".ReplicaGroupId", q->replicaGroupId));
+ }
+ if(q->registerProcess)
+ {
+ props.push_back(createProperty("Ice.OA." + q->name + ".RegisterProcess", "1"));
+ _desc->processRegistered = true;
+ }
+ }
+
+ _desc->logs.insert(_desc->logs.end(), desc->logs.begin(), desc->logs.end());
+
+ const string dbsPath = _node->dataDir + "/servers/" + _desc->id + "/dbs/";
+ for(DbEnvDescriptorSeq::const_iterator p = desc->dbEnvs.begin(); p != desc->dbEnvs.end(); ++p)
+ {
+ props.push_back(createProperty("# Database environment " + p->name));
+ if(p->dbHome.empty())
+ {
+ _desc->dbEnvs.push_back(new InternalDbEnvDescriptor(p->name, p->properties));
+ props.push_back(createProperty("Freeze.DbEnv." + p->name + ".DbHome", dbsPath + p->name));
+ }
+ else
+ {
+ props.push_back(createProperty("Freeze.DbEnv." + p->name + ".DbHome", p->dbHome));
+ }
+ }
+
+ //
+ // Copy the communicator descriptor properties.
+ //
+ if(!communicatorProps.empty())
+ {
+ if(svc)
+ {
+ props.push_back(createProperty("# Service descriptor properties"));
+ }
+ else
+ {
+ props.push_back(createProperty("# Server descriptor properties"));
+ }
+ copy(communicatorProps.begin(), communicatorProps.end(), back_inserter(props));
+ }
}
PropertyDescriptor
removeProperty(PropertyDescriptorSeq& properties, const string& name)
{
- string value;
- PropertyDescriptorSeq::iterator p = properties.begin();
- while(p != properties.end())
- {
- if(p->name == name)
- {
- value = p->value;
- p = properties.erase(p);
- }
- else
- {
- ++p;
- }
- }
- PropertyDescriptor desc;
- desc.name = name;
- desc.value = value;
- return desc;
+ string value;
+ PropertyDescriptorSeq::iterator p = properties.begin();
+ while(p != properties.end())
+ {
+ if(p->name == name)
+ {
+ value = p->value;
+ p = properties.erase(p);
+ }
+ else
+ {
+ ++p;
+ }
+ }
+ PropertyDescriptor desc;
+ desc.name = name;
+ desc.value = value;
+ return desc;
}
InternalServerDescriptorPtr _desc;
@@ -141,60 +141,60 @@ class LoadCB : public AMI_Node_loadServer
public:
LoadCB(const TraceLevelsPtr& traceLevels,
- const ServerEntryPtr& server,
- const string& node,
- int timeout) :
- _traceLevels(traceLevels), _server(server), _id(server->getId()), _node(node), _timeout(timeout)
+ const ServerEntryPtr& server,
+ const string& node,
+ int timeout) :
+ _traceLevels(traceLevels), _server(server), _id(server->getId()), _node(node), _timeout(timeout)
{
}
void
ice_response(const ServerPrx& server, const AdapterPrxDict& adapters, int at, int dt)
{
- if(_traceLevels && _traceLevels->server > 1)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->serverCat);
- out << "loaded `" << _id << "' on node `" << _node << "'";
- }
+ if(_traceLevels && _traceLevels->server > 1)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->serverCat);
+ out << "loaded `" << _id << "' on node `" << _node << "'";
+ }
- //
- // Add the node session timeout on the proxies to ensure the
- // timeout is large enough.
- //
- _server->loadCallback(server, adapters, at + _timeout, dt + _timeout);
+ //
+ // Add the node session timeout on the proxies to ensure the
+ // timeout is large enough.
+ //
+ _server->loadCallback(server, adapters, at + _timeout, dt + _timeout);
}
void
ice_exception(const Ice::Exception& ex)
{
- try
- {
- ex.ice_throw();
- }
- catch(const DeploymentException& ex)
- {
- if(_traceLevels && _traceLevels->server > 1)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->serverCat);
- out << "couldn't load `" << _id << "' on node `" << _node << "':\n" << ex.reason;
- }
-
- ostringstream os;
- os << "couldn't load `" << _id << "' on node `" << _node << "':\n" << ex.reason;
- _server->exception(DeploymentException(os.str()));
- }
- catch(const Ice::Exception& ex)
- {
- if(_traceLevels && _traceLevels->server > 1)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->serverCat);
- out << "couldn't load `" << _id << "' on node `" << _node << "':\n" << ex;
- }
-
- ostringstream os;
- os << ex;
- _server->exception(NodeUnreachableException(_node, os.str()));
- }
+ try
+ {
+ ex.ice_throw();
+ }
+ catch(const DeploymentException& ex)
+ {
+ if(_traceLevels && _traceLevels->server > 1)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->serverCat);
+ out << "couldn't load `" << _id << "' on node `" << _node << "':\n" << ex.reason;
+ }
+
+ ostringstream os;
+ os << "couldn't load `" << _id << "' on node `" << _node << "':\n" << ex.reason;
+ _server->exception(DeploymentException(os.str()));
+ }
+ catch(const Ice::Exception& ex)
+ {
+ if(_traceLevels && _traceLevels->server > 1)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->serverCat);
+ out << "couldn't load `" << _id << "' on node `" << _node << "':\n" << ex;
+ }
+
+ ostringstream os;
+ os << ex;
+ _server->exception(NodeUnreachableException(_node, os.str()));
+ }
}
private:
@@ -211,51 +211,51 @@ class DestroyCB : public AMI_Node_destroyServer
public:
DestroyCB(const TraceLevelsPtr& traceLevels, const ServerEntryPtr& server, const string& node) :
- _traceLevels(traceLevels), _server(server), _id(server->getId()), _node(node)
+ _traceLevels(traceLevels), _server(server), _id(server->getId()), _node(node)
{
}
void
ice_response()
{
- if(_traceLevels && _traceLevels->server > 1)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->serverCat);
- out << "unloaded `" << _id << "' on node `" << _node << "'";
- }
- _server->destroyCallback();
+ if(_traceLevels && _traceLevels->server > 1)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->serverCat);
+ out << "unloaded `" << _id << "' on node `" << _node << "'";
+ }
+ _server->destroyCallback();
}
void
ice_exception(const Ice::Exception& ex)
{
- try
- {
- ex.ice_throw();
- }
- catch(const DeploymentException& ex)
- {
- if(_traceLevels && _traceLevels->server > 1)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->serverCat);
- out << "couldn't unload `" << _id << "' on node `" << _node << "':\n" << ex.reason;
- }
-
- ostringstream os;
- os << "couldn't unload `" << _id << "' on node `" << _node << "':\n" << ex.reason;
- _server->exception(DeploymentException(os.str()));
- }
- catch(const Ice::Exception& ex)
- {
- if(_traceLevels && _traceLevels->server > 1)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->serverCat);
- out << "couldn't unload `" << _id << "' on node `" << _node << "':\n" << ex;
- }
- ostringstream os;
- os << ex;
- _server->exception(NodeUnreachableException(_node, os.str()));
- }
+ try
+ {
+ ex.ice_throw();
+ }
+ catch(const DeploymentException& ex)
+ {
+ if(_traceLevels && _traceLevels->server > 1)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->serverCat);
+ out << "couldn't unload `" << _id << "' on node `" << _node << "':\n" << ex.reason;
+ }
+
+ ostringstream os;
+ os << "couldn't unload `" << _id << "' on node `" << _node << "':\n" << ex.reason;
+ _server->exception(DeploymentException(os.str()));
+ }
+ catch(const Ice::Exception& ex)
+ {
+ if(_traceLevels && _traceLevels->server > 1)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->serverCat);
+ out << "couldn't unload `" << _id << "' on node `" << _node << "':\n" << ex;
+ }
+ ostringstream os;
+ os << ex;
+ _server->exception(NodeUnreachableException(_node, os.str()));
+ }
}
private:
@@ -277,13 +277,13 @@ public:
void
ice_response()
{
- _node->finishedRegistration();
+ _node->finishedRegistration();
}
void
ice_exception(const Ice::Exception& ex)
{
- _node->finishedRegistration(ex);
+ _node->finishedRegistration(ex);
}
private:
@@ -306,15 +306,15 @@ NodeCache::get(const string& name, bool create) const
NodeEntryPtr entry = getImpl(name);
if(!entry && create)
{
- NodeCache& self = const_cast<NodeCache&>(*this);
- entry = new NodeEntry(self, name);
- self.addImpl(name, entry);
+ NodeCache& self = const_cast<NodeCache&>(*this);
+ entry = new NodeEntry(self, name);
+ self.addImpl(name, entry);
}
if(!entry)
{
- NodeNotExistException ex;
- ex.name = name;
- throw ex;
+ NodeNotExistException ex;
+ ex.name = name;
+ throw ex;
}
return entry;
}
@@ -366,50 +366,50 @@ NodeEntry::setSession(const NodeSessionIPtr& session)
if(session)
{
- while(_session)
- {
- if(_session->isDestroyed())
- {
- // If the current session has just been destroyed, wait for the setSession(0) call.
- assert(session != _session);
- wait();
- }
- else
- {
- NodeSessionIPtr session = _session;
- sync.release();
- try
- {
- session->getNode()->ice_ping();
- throw NodeActiveException();
- }
- catch(const Ice::LocalException&)
- {
- try
- {
- session->destroy();
- }
- catch(const Ice::ObjectNotExistException&)
- {
- }
- }
- sync.acquire();
- }
- }
-
- //
- // Clear the saved proxy, the node has established a session
- // so we won't need anymore to try to register it with this
- // registry.
- //
- _proxy = 0;
+ while(_session)
+ {
+ if(_session->isDestroyed())
+ {
+ // If the current session has just been destroyed, wait for the setSession(0) call.
+ assert(session != _session);
+ wait();
+ }
+ else
+ {
+ NodeSessionIPtr session = _session;
+ sync.release();
+ try
+ {
+ session->getNode()->ice_ping();
+ throw NodeActiveException();
+ }
+ catch(const Ice::LocalException&)
+ {
+ try
+ {
+ session->destroy();
+ }
+ catch(const Ice::ObjectNotExistException&)
+ {
+ }
+ }
+ sync.acquire();
+ }
+ }
+
+ //
+ // Clear the saved proxy, the node has established a session
+ // so we won't need anymore to try to register it with this
+ // registry.
+ //
+ _proxy = 0;
}
else
{
- if(!_session)
- {
- return;
- }
+ if(!_session)
+ {
+ return;
+ }
}
_session = session;
@@ -417,25 +417,25 @@ NodeEntry::setSession(const NodeSessionIPtr& session)
if(_registering)
{
- _registering = false;
- notifyAll();
+ _registering = false;
+ notifyAll();
}
if(session)
{
- if(_cache.getTraceLevels() && _cache.getTraceLevels()->node > 0)
- {
- Ice::Trace out(_cache.getTraceLevels()->logger, _cache.getTraceLevels()->nodeCat);
- out << "node `" << _name << "' up";
- }
+ if(_cache.getTraceLevels() && _cache.getTraceLevels()->node > 0)
+ {
+ Ice::Trace out(_cache.getTraceLevels()->logger, _cache.getTraceLevels()->nodeCat);
+ out << "node `" << _name << "' up";
+ }
}
else
{
- if(_cache.getTraceLevels() && _cache.getTraceLevels()->node > 0)
- {
- Ice::Trace out(_cache.getTraceLevels()->logger, _cache.getTraceLevels()->nodeCat);
- out << "node `" << _name << "' down";
- }
+ if(_cache.getTraceLevels() && _cache.getTraceLevels()->node > 0)
+ {
+ Ice::Trace out(_cache.getTraceLevels()->logger, _cache.getTraceLevels()->nodeCat);
+ out << "node `" << _name << "' down";
+ }
}
}
@@ -462,7 +462,7 @@ NodeEntry::getServers() const
ServerEntrySeq entries;
for(map<string, ServerEntryPtr>::const_iterator p = _servers.begin(); p != _servers.end(); ++p)
{
- entries.push_back(p->second);
+ entries.push_back(p->second);
}
return entries;
}
@@ -476,7 +476,7 @@ NodeEntry::getLoadInfoAndLoadFactor(const string& application, float& loadFactor
map<string, NodeDescriptor>::const_iterator p = _descriptors.find(application);
if(p == _descriptors.end())
{
- throw NodeNotExistException(); // The node doesn't exist in the given application.
+ throw NodeNotExistException(); // The node doesn't exist in the given application.
}
//
@@ -486,30 +486,30 @@ NodeEntry::getLoadInfoAndLoadFactor(const string& application, float& loadFactor
loadFactor = -1.0f;
if(!p->second.loadFactor.empty())
{
- istringstream is(p->second.loadFactor);
- is >> loadFactor;
+ istringstream is(p->second.loadFactor);
+ is >> loadFactor;
}
if(loadFactor < 0.0f)
{
- if(_session->getInfo()->os != "Windows")
- {
- //
- // On Unix platforms, we divide the load averages by the
- // number of processors. A load of 2 on a dual processor
- // machine is the same as a load of 1 on a single process
- // machine.
- //
- loadFactor = 1.0f / _session->getInfo()->nProcessors;
- }
- else
- {
- //
- // On Windows, load1, load5 and load15 are the average of
- // the CPU utilization (all CPUs). We don't need to divide
- // by the number of CPU.
- //
- loadFactor = 1.0f;
- }
+ if(_session->getInfo()->os != "Windows")
+ {
+ //
+ // On Unix platforms, we divide the load averages by the
+ // number of processors. A load of 2 on a dual processor
+ // machine is the same as a load of 1 on a single process
+ // machine.
+ //
+ loadFactor = 1.0f / _session->getInfo()->nProcessors;
+ }
+ else
+ {
+ //
+ // On Windows, load1, load5 and load15 are the average of
+ // the CPU utilization (all CPUs). We don't need to divide
+ // by the number of CPU.
+ //
+ loadFactor = 1.0f;
+ }
}
return _session->getLoadInfo();
@@ -535,60 +535,60 @@ NodeEntry::loadServer(const ServerEntryPtr& entry, const ServerInfo& server, con
{
try
{
- NodePrx node;
- int sessionTimeout;
- InternalServerDescriptorPtr desc;
- {
- Lock sync(*this);
- checkSession();
- node = _session->getNode();
- sessionTimeout = _session->getTimeout();
-
- //
- // Check if we should use a specific timeout (the load
- // call can deactivate the server and it can take some
- // time to deactivate, up to "deactivation-timeout"
- // seconds).
- //
- if(timeout > 0)
- {
- node = NodePrx::uncheckedCast(node->ice_timeout(timeout * 1000));
- }
-
- ServerInfo info = server;
- try
- {
- info.descriptor = getServerDescriptor(server, session);
- }
- catch(const DeploymentException&)
- {
- //
- // We ignore the deployment error for now (which can
- // only be caused in theory by session variables not
- // being defined because the server isn't
- // allocated...)
- //
- }
- desc = getInternalServerDescriptor(info);
- }
- assert(desc);
-
- if(_cache.getTraceLevels() && _cache.getTraceLevels()->server > 2)
- {
- Ice::Trace out(_cache.getTraceLevels()->logger, _cache.getTraceLevels()->serverCat);
- out << "loading `" << desc->id << "' on node `" << _name << "'";
- if(session)
- {
- out << " for session `" << session->getId() << "'";
- }
- }
-
- AMI_Node_loadServerPtr amiCB = new LoadCB(_cache.getTraceLevels(), entry, _name, sessionTimeout);
- node->loadServer_async(amiCB, desc, _cache.getReplicaName());
+ NodePrx node;
+ int sessionTimeout;
+ InternalServerDescriptorPtr desc;
+ {
+ Lock sync(*this);
+ checkSession();
+ node = _session->getNode();
+ sessionTimeout = _session->getTimeout();
+
+ //
+ // Check if we should use a specific timeout (the load
+ // call can deactivate the server and it can take some
+ // time to deactivate, up to "deactivation-timeout"
+ // seconds).
+ //
+ if(timeout > 0)
+ {
+ node = NodePrx::uncheckedCast(node->ice_timeout(timeout * 1000));
+ }
+
+ ServerInfo info = server;
+ try
+ {
+ info.descriptor = getServerDescriptor(server, session);
+ }
+ catch(const DeploymentException&)
+ {
+ //
+ // We ignore the deployment error for now (which can
+ // only be caused in theory by session variables not
+ // being defined because the server isn't
+ // allocated...)
+ //
+ }
+ desc = getInternalServerDescriptor(info);
+ }
+ assert(desc);
+
+ if(_cache.getTraceLevels() && _cache.getTraceLevels()->server > 2)
+ {
+ Ice::Trace out(_cache.getTraceLevels()->logger, _cache.getTraceLevels()->serverCat);
+ out << "loading `" << desc->id << "' on node `" << _name << "'";
+ if(session)
+ {
+ out << " for session `" << session->getId() << "'";
+ }
+ }
+
+ AMI_Node_loadServerPtr amiCB = new LoadCB(_cache.getTraceLevels(), entry, _name, sessionTimeout);
+ node->loadServer_async(amiCB, desc, _cache.getReplicaName());
}
catch(const NodeUnreachableException& ex)
{
- entry->exception(ex);
+ entry->exception(ex);
}
}
@@ -597,36 +597,36 @@ NodeEntry::destroyServer(const ServerEntryPtr& entry, const ServerInfo& info, in
{
try
{
- NodePrx node;
- {
- Lock sync(*this);
- checkSession();
- node = _session->getNode();
-
- //
- // Check if we should use a specific timeout (the load
- // call can deactivate the server and it can take some
- // time to deactivate, up to "deactivation-timeout"
- // seconds).
- //
- if(timeout > 0)
- {
- node = NodePrx::uncheckedCast(node->ice_timeout(timeout * 1000));
- }
- }
-
- if(_cache.getTraceLevels() && _cache.getTraceLevels()->server > 2)
- {
- Ice::Trace out(_cache.getTraceLevels()->logger, _cache.getTraceLevels()->serverCat);
- out << "unloading `" << info.descriptor->id << "' on node `" << _name << "'";
- }
-
- AMI_Node_destroyServerPtr amiCB = new DestroyCB(_cache.getTraceLevels(), entry, _name);
- node->destroyServer_async(amiCB, info.descriptor->id, info.uuid, info.revision, _cache.getReplicaName());
+ NodePrx node;
+ {
+ Lock sync(*this);
+ checkSession();
+ node = _session->getNode();
+
+ //
+ // Check if we should use a specific timeout (the load
+ // call can deactivate the server and it can take some
+ // time to deactivate, up to "deactivation-timeout"
+ // seconds).
+ //
+ if(timeout > 0)
+ {
+ node = NodePrx::uncheckedCast(node->ice_timeout(timeout * 1000));
+ }
+ }
+
+ if(_cache.getTraceLevels() && _cache.getTraceLevels()->server > 2)
+ {
+ Ice::Trace out(_cache.getTraceLevels()->logger, _cache.getTraceLevels()->serverCat);
+ out << "unloading `" << info.descriptor->id << "' on node `" << _name << "'";
+ }
+
+ AMI_Node_destroyServerPtr amiCB = new DestroyCB(_cache.getTraceLevels(), entry, _name);
+ node->destroyServer_async(amiCB, info.descriptor->id, info.uuid, info.revision, _cache.getReplicaName());
}
catch(const NodeUnreachableException& ex)
{
- entry->exception(ex);
+ entry->exception(ex);
}
}
@@ -654,18 +654,18 @@ NodeEntry::getServerDescriptor(const ServerInfo& server, const SessionIPtr& sess
if(session)
{
- resolve.setReserved("session.id", session->getId());
+ resolve.setReserved("session.id", session->getId());
}
IceBoxDescriptorPtr iceBox = IceBoxDescriptorPtr::dynamicCast(server.descriptor);
if(iceBox)
{
- return IceBoxHelper(iceBox).instantiate(resolve, PropertyDescriptorSeq(), PropertySetDescriptorDict());
+ return IceBoxHelper(iceBox).instantiate(resolve, PropertyDescriptorSeq(), PropertySetDescriptorDict());
}
else
{
- return ServerHelper(server.descriptor).instantiate(resolve, PropertyDescriptorSeq(),
- PropertySetDescriptorDict());
+ return ServerHelper(server.descriptor).instantiate(resolve, PropertyDescriptorSeq(),
+ PropertySetDescriptorDict());
}
}
@@ -691,28 +691,28 @@ NodeEntry::__decRef()
bool doRemove = false;
bool doDelete = false;
{
- Lock sync(*this); // We use a recursive mutex so it's fine to
- // create Ptr with the mutex locked.
- assert(_ref > 0);
- --_ref;
-
- if(_ref == 1)
- {
- doRemove = canRemove();
- }
- else if(_ref == 0)
- {
- doDelete = true;
- }
+ Lock sync(*this); // We use a recursive mutex so it's fine to
+ // create Ptr with the mutex locked.
+ assert(_ref > 0);
+ --_ref;
+
+ if(_ref == 1)
+ {
+ doRemove = canRemove();
+ }
+ else if(_ref == 0)
+ {
+ doDelete = true;
+ }
}
if(doRemove)
{
- _cache.remove(_name);
+ _cache.remove(_name);
}
else if(doDelete)
{
- delete this;
+ delete this;
}
}
@@ -721,45 +721,45 @@ NodeEntry::checkSession() const
{
if(_session && !_session->isDestroyed())
{
- return;
+ return;
}
else if(!_proxy && !_registering)
{
- throw NodeUnreachableException(_name, "the node is not active");
+ throw NodeUnreachableException(_name, "the node is not active");
}
else if(_proxy)
{
- //
- // If the node proxy is set, we attempt to get the node to
- // register with this registry.
- //
- assert(!_registering);
-
- if(_cache.getTraceLevels() && _cache.getTraceLevels()->node > 0)
- {
- Ice::Trace out(_cache.getTraceLevels()->logger, _cache.getTraceLevels()->nodeCat);
- out << "creating node `" << _name << "' session";
- }
-
- //
- // NOTE: setting _registering to true must be done before the
- // call otherwise if the callback is call immediately we'll
- // hang in the while loop.
- //
- _registering = true;
- NodeEntry* self = const_cast<NodeEntry*>(this);
- _proxy->registerWithReplica_async(new RegisterCB(self), _cache.getReplicaCache().getInternalRegistry());
- _proxy = 0; // Registration with the proxy is only attempted once.
+ //
+ // If the node proxy is set, we attempt to get the node to
+ // register with this registry.
+ //
+ assert(!_registering);
+
+ if(_cache.getTraceLevels() && _cache.getTraceLevels()->node > 0)
+ {
+ Ice::Trace out(_cache.getTraceLevels()->logger, _cache.getTraceLevels()->nodeCat);
+ out << "creating node `" << _name << "' session";
+ }
+
+ //
+ // NOTE: setting _registering to true must be done before the
+ // call otherwise if the callback is call immediately we'll
+ // hang in the while loop.
+ //
+ _registering = true;
+ NodeEntry* self = const_cast<NodeEntry*>(this);
+ _proxy->registerWithReplica_async(new RegisterCB(self), _cache.getReplicaCache().getInternalRegistry());
+ _proxy = 0; // Registration with the proxy is only attempted once.
}
while(_registering)
{
- wait();
+ wait();
}
if(!_session)
{
- throw NodeUnreachableException(_name, "the node is not active");
+ throw NodeUnreachableException(_name, "the node is not active");
}
}
@@ -776,7 +776,7 @@ NodeEntry::setProxy(const NodePrx& node)
//
if(!_session)
{
- _proxy = node;
+ _proxy = node;
}
}
@@ -786,21 +786,21 @@ NodeEntry::finishedRegistration()
Lock sync(*this);
if(_cache.getTraceLevels() && _cache.getTraceLevels()->node > 0)
{
- Ice::Trace out(_cache.getTraceLevels()->logger, _cache.getTraceLevels()->nodeCat);
- if(_session)
- {
- out << "node `" << _name << "' session created";
- }
- else
- {
- out << "node `" << _name << "' session creation failed";
- }
+ Ice::Trace out(_cache.getTraceLevels()->logger, _cache.getTraceLevels()->nodeCat);
+ if(_session)
+ {
+ out << "node `" << _name << "' session created";
+ }
+ else
+ {
+ out << "node `" << _name << "' session creation failed";
+ }
}
if(_registering)
{
- _registering = false;
- notifyAll();
+ _registering = false;
+ notifyAll();
}
}
@@ -810,14 +810,14 @@ NodeEntry::finishedRegistration(const Ice::Exception& ex)
Lock sync(*this);
if(_cache.getTraceLevels() && _cache.getTraceLevels()->node > 0)
{
- Ice::Trace out(_cache.getTraceLevels()->logger, _cache.getTraceLevels()->nodeCat);
- out << "node `" << _name << "' session creation failed:\n" << ex;
+ Ice::Trace out(_cache.getTraceLevels()->logger, _cache.getTraceLevels()->nodeCat);
+ out << "node `" << _name << "' session creation failed:\n" << ex;
}
if(_registering)
{
- _registering = false;
- notifyAll();
+ _registering = false;
+ notifyAll();
}
}
@@ -840,17 +840,17 @@ NodeEntry::getInternalServerDescriptor(const ServerInfo& info) const
server->deactivationTimeout = info.descriptor->deactivationTimeout;
if(!info.descriptor->iceVersion.empty())
{
- server->iceVersion = info.descriptor->iceVersion;
+ server->iceVersion = info.descriptor->iceVersion;
}
else
{
- server->iceVersion = string(ICE_STRING_VERSION);
+ server->iceVersion = string(ICE_STRING_VERSION);
}
server->applicationDistrib = info.descriptor->applicationDistrib;
if(!info.descriptor->distrib.icepatch.empty())
{
- server->distrib = new InternalDistributionDescriptor(info.descriptor->distrib.icepatch,
- info.descriptor->distrib.directories);
+ server->distrib = new InternalDistributionDescriptor(info.descriptor->distrib.icepatch,
+ info.descriptor->distrib.directories);
}
server->options = info.descriptor->options;
server->envs = info.descriptor->envs;
@@ -875,15 +875,15 @@ NodeEntry::getInternalServerDescriptor(const ServerInfo& info) const
IceBoxDescriptorPtr iceBox = IceBoxDescriptorPtr::dynamicCast(info.descriptor);
if(iceBox)
{
- for(ServiceInstanceDescriptorSeq::const_iterator p = iceBox->services.begin(); p != iceBox->services.end();++p)
- {
- ServiceDescriptorPtr s = p->descriptor;
- const string path = _session->getInfo()->dataDir + "/servers/" + server->id + "/config/config_" + s->name;
- props.push_back(
- createProperty("IceBox.Service." + s->name, s->entry + " --Ice.Config=\"" + path + "\""));
- servicesStr += s->name + " ";
- }
- props.push_back(createProperty("IceBox.LoadOrder", servicesStr));
+ for(ServiceInstanceDescriptorSeq::const_iterator p = iceBox->services.begin(); p != iceBox->services.end();++p)
+ {
+ ServiceDescriptorPtr s = p->descriptor;
+ const string path = _session->getInfo()->dataDir + "/servers/" + server->id + "/config/config_" + s->name;
+ props.push_back(
+ createProperty("IceBox.Service." + s->name, s->entry + " --Ice.Config=\"" + path + "\""));
+ servicesStr += s->name + " ";
+ }
+ props.push_back(createProperty("IceBox.LoadOrder", servicesStr));
}
//
@@ -899,17 +899,17 @@ NodeEntry::getInternalServerDescriptor(const ServerInfo& info) const
//
if(getMMVersion(server->iceVersion) < 30200)
{
- const string oaPrefix = "Ice.OA.";
- for(PropertyDescriptorSeqDict::iterator p = server->properties.begin(); p != server->properties.end(); ++p)
- {
- for(PropertyDescriptorSeq::iterator q = p->second.begin(); q != p->second.end(); ++q)
- {
- if(q->name.find(oaPrefix) == 0)
- {
- q->name = q->name.substr(oaPrefix.size());
- }
- }
- }
+ const string oaPrefix = "Ice.OA.";
+ for(PropertyDescriptorSeqDict::iterator p = server->properties.begin(); p != server->properties.end(); ++p)
+ {
+ for(PropertyDescriptorSeq::iterator q = p->second.begin(); q != p->second.end(); ++q)
+ {
+ if(q->name.find(oaPrefix) == 0)
+ {
+ q->name = q->name.substr(oaPrefix.size());
+ }
+ }
+ }
}
return server;
diff --git a/cpp/src/IceGrid/NodeI.cpp b/cpp/src/IceGrid/NodeI.cpp
index a1131fcae4c..4c3ca5c8c45 100644
--- a/cpp/src/IceGrid/NodeI.cpp
+++ b/cpp/src/IceGrid/NodeI.cpp
@@ -31,151 +31,151 @@ class LogPatcherFeedback : public IcePatch2::PatcherFeedback
public:
LogPatcherFeedback(const TraceLevelsPtr& traceLevels, const string& dest) :
- _traceLevels(traceLevels),
- _startedPatch(false),
- _lastProgress(0),
- _dest(dest)
+ _traceLevels(traceLevels),
+ _startedPatch(false),
+ _lastProgress(0),
+ _dest(dest)
{
}
void
setPatchingPath(const string& path)
{
- _path = path;
- _startedPatch = false;
- _lastProgress = 0;
+ _path = path;
+ _startedPatch = false;
+ _lastProgress = 0;
}
virtual bool
noFileSummary(const string& reason)
{
- if(_traceLevels->patch > 0)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->patchCat);
- out << _dest << ": can't load summary file (will perform a thorough patch):\n" << reason;
- }
- return true;
+ if(_traceLevels->patch > 0)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->patchCat);
+ out << _dest << ": can't load summary file (will perform a thorough patch):\n" << reason;
+ }
+ return true;
}
virtual bool
checksumStart()
{
- if(_traceLevels->patch > 0)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->patchCat);
- out << _dest << ": started checksum calculation";
- }
- return true;
+ if(_traceLevels->patch > 0)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->patchCat);
+ out << _dest << ": started checksum calculation";
+ }
+ return true;
}
virtual bool
checksumProgress(const string& path)
{
- if(_traceLevels->patch > 2)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->patchCat);
- out << _dest << ": calculating checksum for " << getBasename(path);
- }
- return true;
+ if(_traceLevels->patch > 2)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->patchCat);
+ out << _dest << ": calculating checksum for " << getBasename(path);
+ }
+ return true;
}
virtual bool
checksumEnd()
{
- if(_traceLevels->patch > 0)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->patchCat);
- out << _dest << ": finished checksum calculation";
- }
- return true;
+ if(_traceLevels->patch > 0)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->patchCat);
+ out << _dest << ": finished checksum calculation";
+ }
+ return true;
}
virtual bool
fileListStart()
{
- if(_traceLevels->patch > 0)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->patchCat);
- out << _dest << ": getting list of file to patch";
- }
- return true;
+ if(_traceLevels->patch > 0)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->patchCat);
+ out << _dest << ": getting list of file to patch";
+ }
+ return true;
}
virtual bool
fileListProgress(Ice::Int percent)
{
- return true;
+ return true;
}
virtual bool
fileListEnd()
{
- if(_traceLevels->patch > 0)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->patchCat);
- out << _dest << ": getting list of file to patch completed";
- }
- return true;
+ if(_traceLevels->patch > 0)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->patchCat);
+ out << _dest << ": getting list of file to patch completed";
+ }
+ return true;
}
virtual bool
patchStart(const string& path, Ice::Long size, Ice::Long totalProgress, Ice::Long totalSize)
{
- if(_traceLevels->patch > 1 && totalSize > (1024 * 1024))
- {
- int progress = static_cast<int>(static_cast<double>(totalProgress) / totalSize * 100.0);
- progress /= 5;
- progress *= 5;
- if(progress != _lastProgress)
- {
- _lastProgress = progress;
- Ice::Trace out(_traceLevels->logger, _traceLevels->patchCat);
- out << _dest << ": downloaded " << progress << "% (" << totalProgress << '/' << totalSize << ')';
- if(!_path.empty())
- {
- out << " of " << _path;
- }
- }
- }
- else if(_traceLevels->patch > 0)
- {
- if(!_startedPatch)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->patchCat);
- int roundedSize = static_cast<int>(static_cast<double>(totalSize) / 1024);
- if(roundedSize == 0 && totalSize > 0)
- {
- roundedSize = 1;
- }
- out << _dest << ": downloading " << (_path.empty() ? string("") : (_path + " ")) << roundedSize
- << "KB ";
- _startedPatch = true;
- }
- }
-
- return true;
+ if(_traceLevels->patch > 1 && totalSize > (1024 * 1024))
+ {
+ int progress = static_cast<int>(static_cast<double>(totalProgress) / totalSize * 100.0);
+ progress /= 5;
+ progress *= 5;
+ if(progress != _lastProgress)
+ {
+ _lastProgress = progress;
+ Ice::Trace out(_traceLevels->logger, _traceLevels->patchCat);
+ out << _dest << ": downloaded " << progress << "% (" << totalProgress << '/' << totalSize << ')';
+ if(!_path.empty())
+ {
+ out << " of " << _path;
+ }
+ }
+ }
+ else if(_traceLevels->patch > 0)
+ {
+ if(!_startedPatch)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->patchCat);
+ int roundedSize = static_cast<int>(static_cast<double>(totalSize) / 1024);
+ if(roundedSize == 0 && totalSize > 0)
+ {
+ roundedSize = 1;
+ }
+ out << _dest << ": downloading " << (_path.empty() ? string("") : (_path + " ")) << roundedSize
+ << "KB ";
+ _startedPatch = true;
+ }
+ }
+
+ return true;
}
virtual bool
patchProgress(Ice::Long progress, Ice::Long size, Ice::Long totalProgress, Ice::Long totalSize)
{
- return true;
+ return true;
}
virtual bool
patchEnd()
- {
- return true;
+ {
+ return true;
}
void
finishPatch()
{
- if(_traceLevels->patch > 0)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->patchCat);
- out << _dest << ": downloading completed";
- }
+ if(_traceLevels->patch > 0)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->patchCat);
+ out << _dest << ": downloading completed";
+ }
}
private:
@@ -190,13 +190,13 @@ private:
}
NodeI::NodeI(const Ice::ObjectAdapterPtr& adapter,
- NodeSessionManager& sessions,
- const ActivatorPtr& activator,
- const WaitQueuePtr& waitQueue,
- const TraceLevelsPtr& traceLevels,
- const NodePrx& proxy,
- const string& name,
- const UserAccountMapperPrx& mapper) :
+ NodeSessionManager& sessions,
+ const ActivatorPtr& activator,
+ const WaitQueuePtr& waitQueue,
+ const TraceLevelsPtr& traceLevels,
+ const NodePrx& proxy,
+ const string& name,
+ const UserAccountMapperPrx& mapper) :
_communicator(adapter->getCommunicator()),
_adapter(adapter),
_sessions(sessions),
@@ -229,32 +229,32 @@ NodeI::NodeI(const Ice::ObjectAdapterPtr& adapter,
Ice::StringSeq propsAsArgs;
if(!props.empty())
{
- string::size_type end = 0;
- while(end != string::npos)
- {
- const string delim = " \t\r\n";
-
- string::size_type beg = props.find_first_not_of(delim, end);
- if(beg == string::npos)
- {
- break;
- }
-
- end = props.find_first_of(delim, beg);
- string arg;
- if(end == string::npos)
- {
- arg = props.substr(beg);
- }
- else
- {
- arg = props.substr(beg, end - beg);
- }
-
- if(arg.find("--") == 0)
- {
- arg = arg.substr(2);
- }
+ string::size_type end = 0;
+ while(end != string::npos)
+ {
+ const string delim = " \t\r\n";
+
+ string::size_type beg = props.find_first_not_of(delim, end);
+ if(beg == string::npos)
+ {
+ break;
+ }
+
+ end = props.find_first_of(delim, beg);
+ string arg;
+ if(end == string::npos)
+ {
+ arg = props.substr(beg);
+ }
+ else
+ {
+ arg = props.substr(beg, end - beg);
+ }
+
+ if(arg.find("--") == 0)
+ {
+ arg = arg.substr(2);
+ }
//
// Extract the key/value
@@ -283,7 +283,7 @@ NodeI::NodeI(const Ice::ObjectAdapterPtr& adapter,
}
_propertiesOverride.push_back(createProperty(key, value));
- }
+ }
}
}
@@ -293,274 +293,274 @@ NodeI::~NodeI()
void
NodeI::loadServer_async(const AMD_Node_loadServerPtr& amdCB,
- const InternalServerDescriptorPtr& descriptor,
- const string& replicaName,
- const Ice::Current& current)
+ const InternalServerDescriptorPtr& descriptor,
+ const string& replicaName,
+ const Ice::Current& current)
{
ServerCommandPtr command;
{
- Lock sync(*this);
- ++_serial;
-
- Ice::Identity id = createServerIdentity(descriptor->id);
-
- //
- // Check if we already have a servant for this server. If that's
- // the case, the server is already loaded and we just need to
- // update it.
- //
- while(true)
- {
- bool added = false;
- ServerIPtr server = ServerIPtr::dynamicCast(_adapter->find(id));
- if(!server)
- {
- ServerPrx proxy = ServerPrx::uncheckedCast(_adapter->createProxy(id));
- server = new ServerI(this, proxy, _serversDir, descriptor->id, _waitTime);
- _adapter->add(server, id);
- added = true;
- }
-
- try
- {
- command = server->load(amdCB, descriptor, replicaName);
- }
- catch(const Ice::ObjectNotExistException&)
- {
- assert(!added);
- continue;
- }
- catch(const Ice::Exception&)
- {
- if(added)
- {
- _adapter->remove(id);
- }
- throw;
- }
- break;
- }
+ Lock sync(*this);
+ ++_serial;
+
+ Ice::Identity id = createServerIdentity(descriptor->id);
+
+ //
+ // Check if we already have a servant for this server. If that's
+ // the case, the server is already loaded and we just need to
+ // update it.
+ //
+ while(true)
+ {
+ bool added = false;
+ ServerIPtr server = ServerIPtr::dynamicCast(_adapter->find(id));
+ if(!server)
+ {
+ ServerPrx proxy = ServerPrx::uncheckedCast(_adapter->createProxy(id));
+ server = new ServerI(this, proxy, _serversDir, descriptor->id, _waitTime);
+ _adapter->add(server, id);
+ added = true;
+ }
+
+ try
+ {
+ command = server->load(amdCB, descriptor, replicaName);
+ }
+ catch(const Ice::ObjectNotExistException&)
+ {
+ assert(!added);
+ continue;
+ }
+ catch(const Ice::Exception&)
+ {
+ if(added)
+ {
+ _adapter->remove(id);
+ }
+ throw;
+ }
+ break;
+ }
}
if(command)
{
- command->execute();
+ command->execute();
}
}
void
NodeI::destroyServer_async(const AMD_Node_destroyServerPtr& amdCB,
- const string& serverId,
- const string& uuid,
- int revision,
- const string& replicaName,
- const Ice::Current& current)
+ const string& serverId,
+ const string& uuid,
+ int revision,
+ const string& replicaName,
+ const Ice::Current& current)
{
ServerCommandPtr command;
{
- Lock sync(*this);
- ++_serial;
-
- ServerIPtr server = ServerIPtr::dynamicCast(_adapter->find(createServerIdentity(serverId)));
- if(!server)
- {
- server = new ServerI(this, 0, _serversDir, serverId, _waitTime);
- }
-
- //
- // Destroy the server object if it's loaded.
- //
- try
- {
- command = server->destroy(amdCB, uuid, revision, replicaName);
- }
- catch(const Ice::ObjectNotExistException&)
- {
- }
+ Lock sync(*this);
+ ++_serial;
+
+ ServerIPtr server = ServerIPtr::dynamicCast(_adapter->find(createServerIdentity(serverId)));
+ if(!server)
+ {
+ server = new ServerI(this, 0, _serversDir, serverId, _waitTime);
+ }
+
+ //
+ // Destroy the server object if it's loaded.
+ //
+ try
+ {
+ command = server->destroy(amdCB, uuid, revision, replicaName);
+ }
+ catch(const Ice::ObjectNotExistException&)
+ {
+ }
}
if(command)
{
- command->execute();
+ command->execute();
}
}
void
NodeI::patch_async(const AMD_Node_patchPtr& amdCB,
- const PatcherFeedbackPrx& feedback,
- const string& application,
- const string& server,
- const InternalDistributionDescriptorPtr& appDistrib,
- bool shutdown,
- const Ice::Current&)
+ const PatcherFeedbackPrx& feedback,
+ const string& application,
+ const string& server,
+ const InternalDistributionDescriptorPtr& appDistrib,
+ bool shutdown,
+ const Ice::Current&)
{
amdCB->ice_response();
{
- Lock sync(*this);
- while(_patchInProgress.find(application) != _patchInProgress.end())
- {
- wait();
- }
- _patchInProgress.insert(application);
+ Lock sync(*this);
+ while(_patchInProgress.find(application) != _patchInProgress.end())
+ {
+ wait();
+ }
+ _patchInProgress.insert(application);
}
set<ServerIPtr> servers;
if(!appDistrib->icepatch.empty())
{
- //
- // Get all the application servers (even the ones which
- // don't have a distribution since they depend on the
- // application distribution).
- //
- servers = getApplicationServers(application);
+ //
+ // Get all the application servers (even the ones which
+ // don't have a distribution since they depend on the
+ // application distribution).
+ //
+ servers = getApplicationServers(application);
}
else if(server.empty())
{
- //
- // Get all the application servers which have a distribution.
- //
- servers = getApplicationServers(application);
- set<ServerIPtr>::iterator s = servers.begin();
- while(s != servers.end())
- {
- if((*s)->getDistribution())
- {
- ++s;
- }
- else
- {
- servers.erase(s++);
- }
- }
+ //
+ // Get all the application servers which have a distribution.
+ //
+ servers = getApplicationServers(application);
+ set<ServerIPtr>::iterator s = servers.begin();
+ while(s != servers.end())
+ {
+ if((*s)->getDistribution())
+ {
+ ++s;
+ }
+ else
+ {
+ servers.erase(s++);
+ }
+ }
}
else
{
- //
- // Get the given server.
- //
- Ice::Identity id = createServerIdentity(server);
- ServerIPtr svr = ServerIPtr::dynamicCast(_adapter->find(id));
- if(svr)
- {
- servers.insert(svr);
- }
+ //
+ // Get the given server.
+ //
+ Ice::Identity id = createServerIdentity(server);
+ ServerIPtr svr = ServerIPtr::dynamicCast(_adapter->find(id));
+ if(svr)
+ {
+ servers.insert(svr);
+ }
}
string failure;
try
{
- set<ServerIPtr>::iterator s = servers.begin();
- vector<string> running;
- while(s != servers.end())
- {
- try
- {
- if(!(*s)->startPatch(shutdown))
- {
- running.push_back((*s)->getId());
- servers.erase(s++);
- }
- else
- {
- ++s;
- }
- }
- catch(const Ice::ObjectNotExistException&)
- {
- servers.erase(s++);
- }
- }
-
- if((servers.empty() || !appDistrib->icepatch.empty()) && !running.empty())
- {
- if(running.size() == 1)
- {
- throw "server `" + toString(running) + "' is active";
- }
- else
- {
- throw "servers `" + toString(running, ", ") + "' are active";
- }
- }
-
- for(s = servers.begin(); s != servers.end(); ++s)
- {
- (*s)->waitForPatch();
- }
-
- //
- // Patch the application.
- //
- FileServerPrx icepatch;
- if(!appDistrib->icepatch.empty())
- {
- icepatch = FileServerPrx::checkedCast(_communicator->stringToProxy(appDistrib->icepatch));
- if(!icepatch)
- {
- throw "proxy `" + appDistrib->icepatch + "' is not a file server.";
- }
- patch(icepatch, "distrib/" + application, appDistrib->directories);
- }
-
- //
- // Patch the server(s).
- //
- for(s = servers.begin(); s != servers.end(); ++s)
- {
- InternalDistributionDescriptorPtr dist = (*s)->getDistribution();
- if(!dist || (!server.empty() && (*s)->getId() != server))
- {
- continue;
- }
-
- icepatch = FileServerPrx::checkedCast(_communicator->stringToProxy(dist->icepatch));
- if(!icepatch)
- {
- throw "proxy `" + dist->icepatch + "' is not a file server.";
- }
- patch(icepatch, "servers/" + (*s)->getId() + "/distrib", dist->directories);
-
- if(!server.empty())
- {
- break;
- }
- }
+ set<ServerIPtr>::iterator s = servers.begin();
+ vector<string> running;
+ while(s != servers.end())
+ {
+ try
+ {
+ if(!(*s)->startPatch(shutdown))
+ {
+ running.push_back((*s)->getId());
+ servers.erase(s++);
+ }
+ else
+ {
+ ++s;
+ }
+ }
+ catch(const Ice::ObjectNotExistException&)
+ {
+ servers.erase(s++);
+ }
+ }
+
+ if((servers.empty() || !appDistrib->icepatch.empty()) && !running.empty())
+ {
+ if(running.size() == 1)
+ {
+ throw "server `" + toString(running) + "' is active";
+ }
+ else
+ {
+ throw "servers `" + toString(running, ", ") + "' are active";
+ }
+ }
+
+ for(s = servers.begin(); s != servers.end(); ++s)
+ {
+ (*s)->waitForPatch();
+ }
+
+ //
+ // Patch the application.
+ //
+ FileServerPrx icepatch;
+ if(!appDistrib->icepatch.empty())
+ {
+ icepatch = FileServerPrx::checkedCast(_communicator->stringToProxy(appDistrib->icepatch));
+ if(!icepatch)
+ {
+ throw "proxy `" + appDistrib->icepatch + "' is not a file server.";
+ }
+ patch(icepatch, "distrib/" + application, appDistrib->directories);
+ }
+
+ //
+ // Patch the server(s).
+ //
+ for(s = servers.begin(); s != servers.end(); ++s)
+ {
+ InternalDistributionDescriptorPtr dist = (*s)->getDistribution();
+ if(!dist || (!server.empty() && (*s)->getId() != server))
+ {
+ continue;
+ }
+
+ icepatch = FileServerPrx::checkedCast(_communicator->stringToProxy(dist->icepatch));
+ if(!icepatch)
+ {
+ throw "proxy `" + dist->icepatch + "' is not a file server.";
+ }
+ patch(icepatch, "servers/" + (*s)->getId() + "/distrib", dist->directories);
+
+ if(!server.empty())
+ {
+ break;
+ }
+ }
}
catch(const Ice::LocalException& e)
{
- ostringstream os;
- os << e;
- failure = os.str();
+ ostringstream os;
+ os << e;
+ failure = os.str();
}
catch(const string& e)
{
- failure = e;
+ failure = e;
}
catch(const char* e)
{
- failure = e;
+ failure = e;
}
for(set<ServerIPtr>::const_iterator s = servers.begin(); s != servers.end(); ++s)
{
- (*s)->finishPatch();
+ (*s)->finishPatch();
}
{
- Lock sync(*this);
- _patchInProgress.erase(application);
- notifyAll();
+ Lock sync(*this);
+ _patchInProgress.erase(application);
+ notifyAll();
}
try
{
- if(failure.empty())
- {
- feedback->finished();
- }
- else
- {
- feedback->failed(failure);
- }
+ if(failure.empty())
+ {
+ feedback->finished();
+ }
+ else
+ {
+ feedback->failed(failure);
+ }
}
catch(const Ice::LocalException&)
{
@@ -623,7 +623,7 @@ NodeI::getOffsetFromEnd(const string& filename, int count, const Ice::Current&)
bool
NodeI::read(const string& filename, Ice::Long pos, int size, Ice::Long& newPos, Ice::StringSeq& lines,
- const Ice::Current&) const
+ const Ice::Current&) const
{
return _fileCache->read(getFilePath(filename), pos, size, newPos, lines);
}
@@ -731,26 +731,26 @@ NodeI::checkConsistency(const NodeSessionPrx& session)
vector<ServerCommandPtr> commands;
while(true)
{
- {
- Lock sync(*this);
- if(serial == _serial)
- {
- _serial = 1; // We can reset the serial number.
- commands = checkConsistencyNoSync(servers);
- break;
- }
- serial = _serial;
- }
- assert(session);
- try
- {
- servers = session->getServers();
- }
- catch(const Ice::LocalException&)
- {
- return; // The connection with the session was lost.
- }
- sort(servers.begin(), servers.end());
+ {
+ Lock sync(*this);
+ if(serial == _serial)
+ {
+ _serial = 1; // We can reset the serial number.
+ commands = checkConsistencyNoSync(servers);
+ break;
+ }
+ serial = _serial;
+ }
+ assert(session);
+ try
+ {
+ servers = session->getServers();
+ }
+ catch(const Ice::LocalException&)
+ {
+ return; // The connection with the session was lost.
+ }
+ sort(servers.begin(), servers.end());
}
for_each(commands.begin(), commands.end(), IceUtil::voidMemFun(&ServerCommand::execute));
@@ -766,31 +766,31 @@ NodeI::addObserver(const NodeSessionPrx& session, const NodeObserverPrx& observe
ServerDynamicInfoSeq serverInfos;
AdapterDynamicInfoSeq adapterInfos;
for(map<string, ServerDynamicInfo>::const_iterator p = _serversDynamicInfo.begin();
- p != _serversDynamicInfo.end(); ++p)
+ p != _serversDynamicInfo.end(); ++p)
{
- assert(p->second.state != Destroyed && (p->second.state != Inactive || !p->second.enabled));
- serverInfos.push_back(p->second);
+ assert(p->second.state != Destroyed && (p->second.state != Inactive || !p->second.enabled));
+ serverInfos.push_back(p->second);
}
for(map<string, AdapterDynamicInfo>::const_iterator q = _adaptersDynamicInfo.begin();
- q != _adaptersDynamicInfo.end(); ++q)
+ q != _adaptersDynamicInfo.end(); ++q)
{
- assert(q->second.proxy);
- adapterInfos.push_back(q->second);
+ assert(q->second.proxy);
+ adapterInfos.push_back(q->second);
}
try
{
- NodeDynamicInfo info;
- info.info = _platform.getNodeInfo();
- info.servers = serverInfos;
- info.adapters = adapterInfos;
- observer->nodeUp(info);
+ NodeDynamicInfo info;
+ info.info = _platform.getNodeInfo();
+ info.servers = serverInfos;
+ info.adapters = adapterInfos;
+ observer->nodeUp(info);
}
catch(const Ice::LocalException& ex)
{
- Ice::Warning out(_traceLevels->logger);
- out << "unexpected observer exception:\n" << ex;
+ Ice::Warning out(_traceLevels->logger);
+ out << "unexpected observer exception:\n" << ex;
}
}
@@ -808,11 +808,11 @@ NodeI::observerUpdateServer(const ServerDynamicInfo& info)
if(info.state == Destroyed || info.state == Inactive && info.enabled)
{
- _serversDynamicInfo.erase(info.id);
+ _serversDynamicInfo.erase(info.id);
}
else
{
- _serversDynamicInfo[info.id] = info;
+ _serversDynamicInfo[info.id] = info;
}
//
@@ -824,18 +824,18 @@ NodeI::observerUpdateServer(const ServerDynamicInfo& info)
set<NodeObserverPrx> sent;
for(map<NodeSessionPrx, NodeObserverPrx>::const_iterator p = _observers.begin(); p != _observers.end(); ++p)
{
- if(sent.find(p->second) == sent.end())
- {
- try
- {
- p->second->updateServer(_name, info);
- sent.insert(p->second);
- }
- catch(const Ice::LocalException&)
- {
- // IGNORE
- }
- }
+ if(sent.find(p->second) == sent.end())
+ {
+ try
+ {
+ p->second->updateServer(_name, info);
+ sent.insert(p->second);
+ }
+ catch(const Ice::LocalException&)
+ {
+ // IGNORE
+ }
+ }
}
}
@@ -846,11 +846,11 @@ NodeI::observerUpdateAdapter(const AdapterDynamicInfo& info)
if(info.proxy)
{
- _adaptersDynamicInfo[info.id] = info;
+ _adaptersDynamicInfo[info.id] = info;
}
else
{
- _adaptersDynamicInfo.erase(info.id);
+ _adaptersDynamicInfo.erase(info.id);
}
//
@@ -862,17 +862,17 @@ NodeI::observerUpdateAdapter(const AdapterDynamicInfo& info)
set<NodeObserverPrx> sent;
for(map<NodeSessionPrx, NodeObserverPrx>::const_iterator p = _observers.begin(); p != _observers.end(); ++p)
{
- if(sent.find(p->second) == sent.end())
- {
- try
- {
- p->second->updateAdapter(_name, info);
- }
- catch(const Ice::LocalException&)
- {
- // IGNORE
- }
- }
+ if(sent.find(p->second) == sent.end())
+ {
+ try
+ {
+ p->second->updateAdapter(_name, info);
+ }
+ catch(const Ice::LocalException&)
+ {
+ // IGNORE
+ }
+ }
}
}
@@ -883,13 +883,13 @@ NodeI::addServer(const ServerIPtr& server, const string& application, bool depen
if(dependsOnApplicationDistrib)
{
- map<string, set<ServerIPtr> >::iterator p = _serversByApplication.find(application);
- if(p == _serversByApplication.end())
- {
- map<string, set<ServerIPtr> >::value_type v(application, set<ServerIPtr>());
- p = _serversByApplication.insert(p, v);
- }
- p->second.insert(server);
+ map<string, set<ServerIPtr> >::iterator p = _serversByApplication.find(application);
+ if(p == _serversByApplication.end())
+ {
+ map<string, set<ServerIPtr> >::value_type v(application, set<ServerIPtr>());
+ p = _serversByApplication.insert(p, v);
+ }
+ p->second.insert(server);
}
}
@@ -900,15 +900,15 @@ NodeI::removeServer(const ServerIPtr& server, const std::string& application, bo
if(dependsOnApplicationDistrib)
{
- map<string, set<ServerIPtr> >::iterator p = _serversByApplication.find(application);
- if(p != _serversByApplication.end())
- {
- p->second.erase(server);
- if(p->second.empty())
- {
- _serversByApplication.erase(p);
- }
- }
+ map<string, set<ServerIPtr> >::iterator p = _serversByApplication.find(application);
+ if(p != _serversByApplication.end())
+ {
+ p->second.erase(server);
+ if(p->second.empty())
+ {
+ _serversByApplication.erase(p);
+ }
+ }
}
}
@@ -924,78 +924,78 @@ NodeI::checkConsistencyNoSync(const Ice::StringSeq& servers)
Ice::StringSeq contents;
try
{
- contents = readDirectory(_serversDir);
+ contents = readDirectory(_serversDir);
}
catch(const string& msg)
{
- Ice::Error out(_traceLevels->logger);
- out << "couldn't read directory `" << _serversDir << "':" << msg;
- return commands;
+ Ice::Error out(_traceLevels->logger);
+ out << "couldn't read directory `" << _serversDir << "':" << msg;
+ return commands;
}
vector<string> remove;
set_difference(contents.begin(), contents.end(), servers.begin(), servers.end(), back_inserter(remove));
-
+
//
// Remove the extra servers if possible.
//
{
- vector<string>::iterator p = remove.begin();
- while(p != remove.end())
- {
- ServerIPtr server = ServerIPtr::dynamicCast(_adapter->find(createServerIdentity(*p)));
- if(server)
- {
- //
- // If the server is loaded, we invoke on it to destroy it.
- //
- try
- {
- ServerCommandPtr command = server->destroy(0, "", 0, "Master");
- if(command)
- {
- commands.push_back(command);
- }
- p = remove.erase(p);
- continue;
- }
- catch(const Ice::LocalException& ex)
- {
- Ice::Error out(_traceLevels->logger);
- out << "server `" << *p << "' destroy failed:" << ex;
- }
- catch(const string&)
- {
- assert(false);
- }
- }
-
- try
- {
- if(canRemoveServerDirectory(*p))
- {
- //
- // If the server directory can be removed and we
- // either remove it or back it up before to remove it.
- //
- removeRecursive(_serversDir + "/" + *p);
- p = remove.erase(p);
- continue;
- }
- }
- catch(const string& msg)
- {
- Ice::Warning out(_traceLevels->logger);
- out << "removing server directory `" << _serversDir << "/" << *p << "' failed:" << msg;
- }
-
- ++p;
- }
+ vector<string>::iterator p = remove.begin();
+ while(p != remove.end())
+ {
+ ServerIPtr server = ServerIPtr::dynamicCast(_adapter->find(createServerIdentity(*p)));
+ if(server)
+ {
+ //
+ // If the server is loaded, we invoke on it to destroy it.
+ //
+ try
+ {
+ ServerCommandPtr command = server->destroy(0, "", 0, "Master");
+ if(command)
+ {
+ commands.push_back(command);
+ }
+ p = remove.erase(p);
+ continue;
+ }
+ catch(const Ice::LocalException& ex)
+ {
+ Ice::Error out(_traceLevels->logger);
+ out << "server `" << *p << "' destroy failed:" << ex;
+ }
+ catch(const string&)
+ {
+ assert(false);
+ }
+ }
+
+ try
+ {
+ if(canRemoveServerDirectory(*p))
+ {
+ //
+ // If the server directory can be removed and we
+ // either remove it or back it up before to remove it.
+ //
+ removeRecursive(_serversDir + "/" + *p);
+ p = remove.erase(p);
+ continue;
+ }
+ }
+ catch(const string& msg)
+ {
+ Ice::Warning out(_traceLevels->logger);
+ out << "removing server directory `" << _serversDir << "/" << *p << "' failed:" << msg;
+ }
+
+ ++p;
+ }
}
-
+
if(remove.empty())
{
- return commands;
+ return commands;
}
//
@@ -1005,54 +1005,54 @@ NodeI::checkConsistencyNoSync(const Ice::StringSeq& servers)
//
try
{
- contents.clear();
- contents = readDirectory(_tmpDir);
+ contents.clear();
+ contents = readDirectory(_tmpDir);
}
catch(const string& msg)
{
- Ice::Error out(_traceLevels->logger);
- out << "couldn't read directory `" << _tmpDir << "':" << msg;
- return commands;
+ Ice::Error out(_traceLevels->logger);
+ out << "couldn't read directory `" << _tmpDir << "':" << msg;
+ return commands;
}
if(contents.size() < 10)
{
- ostringstream os;
- os << "servers-" << contents.size();
- contents.push_back(os.str());
- sort(contents.begin(), contents.end(), greater<string>());
+ ostringstream os;
+ os << "servers-" << contents.size();
+ contents.push_back(os.str());
+ sort(contents.begin(), contents.end(), greater<string>());
}
else if(contents.size() == 10)
{
- sort(contents.begin(), contents.end(), greater<string>());
- try
- {
- removeRecursive(_tmpDir + "/" + *contents.begin());
- }
- catch(const string& msg)
- {
- Ice::Warning out(_traceLevels->logger);
- out << msg;
- }
+ sort(contents.begin(), contents.end(), greater<string>());
+ try
+ {
+ removeRecursive(_tmpDir + "/" + *contents.begin());
+ }
+ catch(const string& msg)
+ {
+ Ice::Warning out(_traceLevels->logger);
+ out << msg;
+ }
}
try
{
- Ice::StringSeq::const_iterator p;
- for(p = contents.begin(); p != (contents.end() - 1); ++p)
- {
- rename(_tmpDir + "/" + *(p + 1), _tmpDir + "/" + *p);
- }
- createDirectoryRecursive(_tmpDir + "/servers-0");
- for(p = remove.begin(); p != remove.end(); ++p)
- {
- rename(_serversDir + "/" + *p, _tmpDir + "/servers-0/" + *p);
- }
+ Ice::StringSeq::const_iterator p;
+ for(p = contents.begin(); p != (contents.end() - 1); ++p)
+ {
+ rename(_tmpDir + "/" + *(p + 1), _tmpDir + "/" + *p);
+ }
+ createDirectoryRecursive(_tmpDir + "/servers-0");
+ for(p = remove.begin(); p != remove.end(); ++p)
+ {
+ rename(_serversDir + "/" + *p, _tmpDir + "/servers-0/" + *p);
+ }
}
catch(const string& msg)
{
- Ice::Warning out(_traceLevels->logger);
- out << "rotation failed: " << msg;
+ Ice::Warning out(_traceLevels->logger);
+ out << "rotation failed: " << msg;
}
return commands;
@@ -1076,7 +1076,7 @@ NodeI::canRemoveServerDirectory(const string& name)
remove(contents.begin(), contents.end(), "distrib");
if(!contents.empty())
{
- return false;
+ return false;
}
contents = readDirectory(_serversDir + "/" + name + "/config");
@@ -1084,21 +1084,21 @@ NodeI::canRemoveServerDirectory(const string& name)
Ice::StringSeq::const_iterator p;
for(p = contents.begin() ; p != contents.end(); ++p)
{
- if(p->find("config") != 0)
- {
- return false;
- }
+ if(p->find("config") != 0)
+ {
+ return false;
+ }
}
contents = readDirectory(_serversDir + "/" + name + "/dbs");
for(p = contents.begin() ; p != contents.end(); ++p)
{
- Ice::StringSeq files = readDirectory(_serversDir + "/" + name + "/dbs/" + *p);
- remove(files.begin(), files.end(), "DB_CONFIG");
- if(!files.empty())
- {
- return false;
- }
+ Ice::StringSeq files = readDirectory(_serversDir + "/" + name + "/dbs/" + *p);
+ remove(files.begin(), files.end(), "DB_CONFIG");
+ if(!files.empty())
+ {
+ return false;
+ }
}
return true;
@@ -1113,28 +1113,28 @@ NodeI::patch(const FileServerPrx& icepatch, const string& dest, const vector<str
bool aborted = !patcher->prepare();
if(!aborted)
{
- if(directories.empty())
- {
- aborted = !patcher->patch("");
- dynamic_cast<LogPatcherFeedback*>(feedback.get())->finishPatch();
- }
- else
- {
- for(vector<string>::const_iterator p = directories.begin(); p != directories.end(); ++p)
- {
- dynamic_cast<LogPatcherFeedback*>(feedback.get())->setPatchingPath(*p);
- if(!patcher->patch(*p))
- {
- aborted = true;
- break;
- }
- dynamic_cast<LogPatcherFeedback*>(feedback.get())->finishPatch();
- }
- }
+ if(directories.empty())
+ {
+ aborted = !patcher->patch("");
+ dynamic_cast<LogPatcherFeedback*>(feedback.get())->finishPatch();
+ }
+ else
+ {
+ for(vector<string>::const_iterator p = directories.begin(); p != directories.end(); ++p)
+ {
+ dynamic_cast<LogPatcherFeedback*>(feedback.get())->setPatchingPath(*p);
+ if(!patcher->patch(*p))
+ {
+ aborted = true;
+ break;
+ }
+ dynamic_cast<LogPatcherFeedback*>(feedback.get())->finishPatch();
+ }
+ }
}
if(!aborted)
{
- patcher->finish();
+ patcher->finish();
}
//
@@ -1150,7 +1150,7 @@ NodeI::getApplicationServers(const string& application) const
map<string, set<ServerIPtr> >::const_iterator p = _serversByApplication.find(application);
if(p != _serversByApplication.end())
{
- servers = p->second;
+ servers = p->second;
}
return servers;
}
@@ -1170,23 +1170,23 @@ NodeI::getFilePath(const string& filename) const
string file;
if(filename == "stderr")
{
- file = _communicator->getProperties()->getProperty("Ice.StdErr");
- if(file.empty())
- {
- throw FileNotAvailableException("Ice.StdErr configuration property is not set");
- }
+ file = _communicator->getProperties()->getProperty("Ice.StdErr");
+ if(file.empty())
+ {
+ throw FileNotAvailableException("Ice.StdErr configuration property is not set");
+ }
}
else if(filename == "stdout")
{
- file = _communicator->getProperties()->getProperty("Ice.StdOut");
- if(file.empty())
- {
- throw FileNotAvailableException("Ice.StdOut configuration property is not set");
- }
+ file = _communicator->getProperties()->getProperty("Ice.StdOut");
+ if(file.empty())
+ {
+ throw FileNotAvailableException("Ice.StdOut configuration property is not set");
+ }
}
else
{
- throw FileNotAvailableException("unknown file");
+ throw FileNotAvailableException("unknown file");
}
return file;
}
diff --git a/cpp/src/IceGrid/NodeI.h b/cpp/src/IceGrid/NodeI.h
index 7572a0b648c..0f472f0bdbe 100644
--- a/cpp/src/IceGrid/NodeI.h
+++ b/cpp/src/IceGrid/NodeI.h
@@ -41,23 +41,23 @@ class NodeI : public Node, public IceUtil::Monitor<IceUtil::Mutex>
public:
NodeI(const Ice::ObjectAdapterPtr&, NodeSessionManager&, const ActivatorPtr&, const WaitQueuePtr&,
- const TraceLevelsPtr&, const NodePrx&, const std::string&, const UserAccountMapperPrx&);
+ const TraceLevelsPtr&, const NodePrx&, const std::string&, const UserAccountMapperPrx&);
virtual ~NodeI();
virtual void loadServer_async(const AMD_Node_loadServerPtr&,
- const InternalServerDescriptorPtr&,
- const std::string&,
- const Ice::Current&);
+ const InternalServerDescriptorPtr&,
+ const std::string&,
+ const Ice::Current&);
virtual void destroyServer_async(const AMD_Node_destroyServerPtr&,
- const std::string&,
- const std::string&,
- int,
- const std::string&,
- const Ice::Current&);
+ const std::string&,
+ const std::string&,
+ int,
+ const std::string&,
+ const Ice::Current&);
virtual void patch_async(const AMD_Node_patchPtr&, const PatcherFeedbackPrx&, const std::string&,
- const std::string&, const InternalDistributionDescriptorPtr&, bool, const Ice::Current&);
+ const std::string&, const InternalDistributionDescriptorPtr&, bool, const Ice::Current&);
virtual void registerWithReplica(const InternalRegistryPrx&, const Ice::Current&);
diff --git a/cpp/src/IceGrid/NodeSessionI.cpp b/cpp/src/IceGrid/NodeSessionI.cpp
index afc5619c2d5..6d12869379e 100644
--- a/cpp/src/IceGrid/NodeSessionI.cpp
+++ b/cpp/src/IceGrid/NodeSessionI.cpp
@@ -24,26 +24,26 @@ class PatcherFeedbackI : public PatcherFeedback
public:
PatcherFeedbackI(const string& node,
- const NodeSessionIPtr& session,
- const Ice::Identity id,
- const PatcherFeedbackAggregatorPtr& aggregator) :
- _node(node),
- _session(session),
- _id(id),
- _aggregator(aggregator)
+ const NodeSessionIPtr& session,
+ const Ice::Identity id,
+ const PatcherFeedbackAggregatorPtr& aggregator) :
+ _node(node),
+ _session(session),
+ _id(id),
+ _aggregator(aggregator)
{
}
void finished(const Ice::Current&)
{
- _aggregator->finished(_node);
- _session->removeFeedback(this, _id);
+ _aggregator->finished(_node);
+ _session->removeFeedback(this, _id);
}
virtual void failed(const string& reason, const Ice::Current& = Ice::Current())
{
- _aggregator->failed(_node, reason);
- _session->removeFeedback(this, _id);
+ _aggregator->failed(_node, reason);
+ _session->removeFeedback(this, _id);
}
private:
@@ -57,10 +57,10 @@ private:
};
PatcherFeedbackAggregator::PatcherFeedbackAggregator(Ice::Identity id,
- const TraceLevelsPtr& traceLevels,
- const string& type,
- const string& name,
- int nodeCount) :
+ const TraceLevelsPtr& traceLevels,
+ const string& type,
+ const string& name,
+ int nodeCount) :
_id(id),
_traceLevels(traceLevels),
_type(type),
@@ -79,13 +79,13 @@ PatcherFeedbackAggregator::finished(const string& node)
Lock sync(*this);
if(_successes.find(node) != _successes.end() || _failures.find(node) != _failures.end())
{
- return;
+ return;
}
if(_traceLevels->patch > 0)
{
- Ice::Trace out(_traceLevels->logger, _traceLevels->patchCat);
- out << "finished patching of " << _type << " `" << _name << "' on node `" << node << "'";
+ Ice::Trace out(_traceLevels->logger, _traceLevels->patchCat);
+ out << "finished patching of " << _type << " `" << _name << "' on node `" << node << "'";
}
_successes.insert(node);
@@ -98,13 +98,13 @@ PatcherFeedbackAggregator::failed(const string& node, const string& failure)
Lock sync(*this);
if(_successes.find(node) != _successes.end() || _failures.find(node) != _failures.end())
{
- return;
+ return;
}
if(_traceLevels->patch > 0)
{
- Ice::Trace out(_traceLevels->logger, _traceLevels->patchCat);
- out << "patching of " << _type << " `" << _name << "' on node `" << node <<"' failed:\n" << failure;
+ Ice::Trace out(_traceLevels->logger, _traceLevels->patchCat);
+ out << "patching of " << _type << " `" << _name << "' on node `" << node <<"' failed:\n" << failure;
}
_failures.insert(node);
@@ -117,25 +117,25 @@ PatcherFeedbackAggregator::checkIfDone()
{
if(static_cast<int>(_successes.size() + _failures.size()) == _count)
{
- if(!_failures.empty())
- {
- sort(_reasons.begin(), _reasons.end());
- PatchException ex;
- ex.reasons = _reasons;
- exception(ex);
- }
- else
- {
- response();
- }
+ if(!_failures.empty())
+ {
+ sort(_reasons.begin(), _reasons.end());
+ PatchException ex;
+ ex.reasons = _reasons;
+ exception(ex);
+ }
+ else
+ {
+ response();
+ }
}
}
NodeSessionI::NodeSessionI(const DatabasePtr& database,
- const NodePrx& node,
- const InternalNodeInfoPtr& info,
- int timeout,
- const LoadInfo& load) :
+ const NodePrx& node,
+ const InternalNodeInfoPtr& info,
+ int timeout,
+ const LoadInfo& load) :
_database(database),
_traceLevels(database->getTraceLevels()),
_node(node),
@@ -148,34 +148,34 @@ NodeSessionI::NodeSessionI(const DatabasePtr& database,
__setNoDelete(true);
try
{
- _database->getNode(info->name, true)->setSession(this);
+ _database->getNode(info->name, true)->setSession(this);
- ObjectInfo objInfo;
- objInfo.type = Node::ice_staticId();
- objInfo.proxy = _node;
- _database->addInternalObject(objInfo, true); // Add or update previous node proxy.
+ ObjectInfo objInfo;
+ objInfo.type = Node::ice_staticId();
+ objInfo.proxy = _node;
+ _database->addInternalObject(objInfo, true); // Add or update previous node proxy.
- _proxy = NodeSessionPrx::uncheckedCast(_database->getInternalAdapter()->addWithUUID(this));
+ _proxy = NodeSessionPrx::uncheckedCast(_database->getInternalAdapter()->addWithUUID(this));
}
catch(const NodeActiveException&)
{
- __setNoDelete(false);
- throw;
+ __setNoDelete(false);
+ throw;
}
catch(...)
{
- try
- {
- _database->removeInternalObject(_node->ice_getIdentity());
- }
- catch(const ObjectNotRegisteredException&)
- {
- }
-
- _database->getNode(info->name)->setSession(0);
-
- __setNoDelete(false);
- throw;
+ try
+ {
+ _database->removeInternalObject(_node->ice_getIdentity());
+ }
+ catch(const ObjectNotRegisteredException&)
+ {
+ }
+
+ _database->getNode(info->name)->setSession(0);
+
+ __setNoDelete(false);
+ throw;
}
__setNoDelete(false);
}
@@ -186,7 +186,7 @@ NodeSessionI::keepAlive(const LoadInfo& load, const Ice::Current& current)
Lock sync(*this);
if(_destroy)
{
- throw Ice::ObjectNotExistException(__FILE__, __LINE__);
+ throw Ice::ObjectNotExistException(__FILE__, __LINE__);
}
_timestamp = IceUtil::Time::now();
@@ -194,9 +194,9 @@ NodeSessionI::keepAlive(const LoadInfo& load, const Ice::Current& current)
if(_traceLevels->node > 2)
{
- Ice::Trace out(_traceLevels->logger, _traceLevels->nodeCat);
- out << "node `" << _info->name << "' keep alive ";
- out << "(load = " << _load.avg1 << ", " << _load.avg5 << ", " << _load.avg15 << ")";
+ Ice::Trace out(_traceLevels->logger, _traceLevels->nodeCat);
+ out << "node `" << _info->name << "' keep alive ";
+ out << "(load = " << _load.avg1 << ", " << _load.avg5 << ", " << _load.avg15 << ")";
}
}
@@ -206,12 +206,12 @@ NodeSessionI::setReplicaObserver(const ReplicaObserverPrx& observer, const Ice::
Lock sync(*this);
if(_destroy)
{
- return;
+ return;
}
else if(_replicaObserver) // This might happen on activation of the node.
{
- assert(_replicaObserver == observer);
- return;
+ assert(_replicaObserver == observer);
+ return;
}
_replicaObserver = observer;
@@ -255,16 +255,16 @@ NodeSessionI::getServers(const Ice::Current& current) const
Ice::StringSeq names;
for(ServerEntrySeq::const_iterator p = servers.begin(); p != servers.end(); ++p)
{
- names.push_back((*p)->getId());
+ names.push_back((*p)->getId());
}
return names;
}
void
NodeSessionI::waitForApplicationUpdate_async(const AMD_NodeSession_waitForApplicationUpdatePtr& cb,
- const std::string& application,
- int revision,
- const Ice::Current&) const
+ const std::string& application,
+ int revision,
+ const Ice::Current&) const
{
_database->waitForApplicationUpdate(cb, application, revision);
}
@@ -281,7 +281,7 @@ NodeSessionI::timestamp() const
Lock sync(*this);
if(_destroy)
{
- throw Ice::ObjectNotExistException(__FILE__, __LINE__);
+ throw Ice::ObjectNotExistException(__FILE__, __LINE__);
}
return _timestamp;
}
@@ -294,10 +294,10 @@ NodeSessionI::shutdown()
void
NodeSessionI::patch(const PatcherFeedbackAggregatorPtr& aggregator,
- const string& application,
- const string& server,
- const InternalDistributionDescriptorPtr& dist,
- bool shutdown)
+ const string& application,
+ const string& server,
+ const InternalDistributionDescriptorPtr& dist,
+ bool shutdown)
{
Ice::Identity id;
id.category = _database->getInstanceName();
@@ -306,21 +306,21 @@ NodeSessionI::patch(const PatcherFeedbackAggregatorPtr& aggregator,
PatcherFeedbackPtr obj = new PatcherFeedbackI(_info->name, this, id, aggregator);
try
{
- PatcherFeedbackPrx feedback = PatcherFeedbackPrx::uncheckedCast(_database->getInternalAdapter()->add(obj, id));
- _node->patch(feedback, application, server, dist, shutdown);
-
- Lock sync(*this);
- if(_destroy)
- {
- throw NodeUnreachableException(_info->name, "node is down");
- }
- _feedbacks.insert(obj);
+ PatcherFeedbackPrx feedback = PatcherFeedbackPrx::uncheckedCast(_database->getInternalAdapter()->add(obj, id));
+ _node->patch(feedback, application, server, dist, shutdown);
+
+ Lock sync(*this);
+ if(_destroy)
+ {
+ throw NodeUnreachableException(_info->name, "node is down");
+ }
+ _feedbacks.insert(obj);
}
catch(const Ice::LocalException& ex)
{
- ostringstream os;
- os << "node unreachable:\n" << ex;
- obj->failed(os.str());
+ ostringstream os;
+ os << "node unreachable:\n" << ex;
+ obj->failed(os.str());
}
}
@@ -360,12 +360,12 @@ void
NodeSessionI::destroyImpl(bool shutdown)
{
{
- Lock sync(*this);
- if(_destroy)
- {
- throw Ice::ObjectNotExistException(__FILE__, __LINE__);
- }
- _destroy = true;
+ Lock sync(*this);
+ if(_destroy)
+ {
+ throw Ice::ObjectNotExistException(__FILE__, __LINE__);
+ }
+ _destroy = true;
}
ServerEntrySeq servers = _database->getNode(_info->name)->getServers();
@@ -377,7 +377,7 @@ NodeSessionI::destroyImpl(bool shutdown)
//
if(!shutdown)
{
- _database->removeInternalObject(_node->ice_getIdentity());
+ _database->removeInternalObject(_node->ice_getIdentity());
}
//
@@ -390,8 +390,8 @@ NodeSessionI::destroyImpl(bool shutdown)
//
if(_replicaObserver)
{
- _database->getReplicaCache().unsubscribe(_replicaObserver);
- _replicaObserver = 0;
+ _database->getReplicaCache().unsubscribe(_replicaObserver);
+ _replicaObserver = 0;
}
//
@@ -409,18 +409,18 @@ NodeSessionI::destroyImpl(bool shutdown)
_feedbacks.swap(feedbacks);
for(set<PatcherFeedbackPtr>::const_iterator p = feedbacks.begin(); p != feedbacks.end(); ++p)
{
- (*p)->failed("node is down");
+ (*p)->failed("node is down");
}
if(!shutdown)
{
- try
- {
- _database->getInternalAdapter()->remove(_proxy->ice_getIdentity());
- }
- catch(const Ice::ObjectAdapterDeactivatedException&)
- {
- }
+ try
+ {
+ _database->getInternalAdapter()->remove(_proxy->ice_getIdentity());
+ }
+ catch(const Ice::ObjectAdapterDeactivatedException&)
+ {
+ }
}
}
@@ -429,14 +429,14 @@ NodeSessionI::removeFeedback(const PatcherFeedbackPtr& feedback, const Ice::Iden
{
try
{
- _database->getInternalAdapter()->remove(id);
+ _database->getInternalAdapter()->remove(id);
}
catch(const Ice::LocalException&)
{
}
{
- Lock sync(*this);
- _feedbacks.erase(feedback);
+ Lock sync(*this);
+ _feedbacks.erase(feedback);
}
}
diff --git a/cpp/src/IceGrid/NodeSessionI.h b/cpp/src/IceGrid/NodeSessionI.h
index a9653203ad1..50bf000e513 100644
--- a/cpp/src/IceGrid/NodeSessionI.h
+++ b/cpp/src/IceGrid/NodeSessionI.h
@@ -65,13 +65,13 @@ public:
virtual void loadServers_async(const AMD_NodeSession_loadServersPtr&, const Ice::Current&) const;
virtual Ice::StringSeq getServers(const Ice::Current&) const;
virtual void waitForApplicationUpdate_async(const AMD_NodeSession_waitForApplicationUpdatePtr&,
- const std::string&, int, const Ice::Current&) const;
+ const std::string&, int, const Ice::Current&) const;
virtual void destroy(const Ice::Current& = Ice::Current());
virtual IceUtil::Time timestamp() const;
virtual void shutdown();
void patch(const PatcherFeedbackAggregatorPtr&, const std::string&, const std::string&,
- const InternalDistributionDescriptorPtr&, bool);
+ const InternalDistributionDescriptorPtr&, bool);
const NodePrx& getNode() const;
const InternalNodeInfoPtr& getInfo() const;
diff --git a/cpp/src/IceGrid/NodeSessionManager.cpp b/cpp/src/IceGrid/NodeSessionManager.cpp
index ff522a1a58e..f723134a0a5 100644
--- a/cpp/src/IceGrid/NodeSessionManager.cpp
+++ b/cpp/src/IceGrid/NodeSessionManager.cpp
@@ -17,8 +17,8 @@ using namespace std;
using namespace IceGrid;
NodeSessionKeepAliveThread::NodeSessionKeepAliveThread(const InternalRegistryPrx& registry,
- const NodeIPtr& node,
- const vector<QueryPrx>& queryObjects) :
+ const NodeIPtr& node,
+ const vector<QueryPrx>& queryObjects) :
SessionKeepAliveThread<NodeSessionPrx>(registry),
_node(node),
_queryObjects(queryObjects)
@@ -29,7 +29,7 @@ NodeSessionKeepAliveThread::NodeSessionKeepAliveThread(const InternalRegistryPrx
string::size_type pos = name.find(prefix);
if(pos != string::npos)
{
- name = name.substr(prefix.size());
+ name = name.substr(prefix.size());
}
const_cast<string&>(_name) = name;
}
@@ -42,90 +42,90 @@ NodeSessionKeepAliveThread::createSession(InternalRegistryPrx& registry, IceUtil
TraceLevelsPtr traceLevels = _node->getTraceLevels();
try
{
- if(traceLevels && traceLevels->replica > 1)
- {
- Ice::Trace out(traceLevels->logger, traceLevels->replicaCat);
- out << "trying to establish session with replica `" << _name << "'";
- }
-
- set<InternalRegistryPrx> used;
- if(!registry->ice_getEndpoints().empty())
- {
- try
- {
- session = createSessionImpl(registry, timeout);
- }
- catch(const Ice::LocalException& ex)
- {
- exception.reset(ex.ice_clone());
- used.insert(registry);
- registry = InternalRegistryPrx::uncheckedCast(registry->ice_endpoints(Ice::EndpointSeq()));
- }
- }
-
- if(!session)
- {
- for(vector<QueryPrx>::const_iterator p = _queryObjects.begin(); p != _queryObjects.end(); ++p)
- {
- InternalRegistryPrx newRegistry;
- try
- {
- Ice::ObjectPrx obj = (*p)->findObjectById(registry->ice_getIdentity());
- newRegistry = InternalRegistryPrx::uncheckedCast(obj);
- if(newRegistry && used.find(newRegistry) == used.end())
- {
- session = createSessionImpl(newRegistry, timeout);
- registry = newRegistry;
- break;
- }
- }
- catch(const Ice::LocalException& ex)
- {
- exception.reset(ex.ice_clone());
- if(newRegistry)
- {
- used.insert(newRegistry);
- }
- }
- }
- }
+ if(traceLevels && traceLevels->replica > 1)
+ {
+ Ice::Trace out(traceLevels->logger, traceLevels->replicaCat);
+ out << "trying to establish session with replica `" << _name << "'";
+ }
+
+ set<InternalRegistryPrx> used;
+ if(!registry->ice_getEndpoints().empty())
+ {
+ try
+ {
+ session = createSessionImpl(registry, timeout);
+ }
+ catch(const Ice::LocalException& ex)
+ {
+ exception.reset(ex.ice_clone());
+ used.insert(registry);
+ registry = InternalRegistryPrx::uncheckedCast(registry->ice_endpoints(Ice::EndpointSeq()));
+ }
+ }
+
+ if(!session)
+ {
+ for(vector<QueryPrx>::const_iterator p = _queryObjects.begin(); p != _queryObjects.end(); ++p)
+ {
+ InternalRegistryPrx newRegistry;
+ try
+ {
+ Ice::ObjectPrx obj = (*p)->findObjectById(registry->ice_getIdentity());
+ newRegistry = InternalRegistryPrx::uncheckedCast(obj);
+ if(newRegistry && used.find(newRegistry) == used.end())
+ {
+ session = createSessionImpl(newRegistry, timeout);
+ registry = newRegistry;
+ break;
+ }
+ }
+ catch(const Ice::LocalException& ex)
+ {
+ exception.reset(ex.ice_clone());
+ if(newRegistry)
+ {
+ used.insert(newRegistry);
+ }
+ }
+ }
+ }
}
catch(const NodeActiveException& ex)
{
- if(traceLevels)
- {
- traceLevels->logger->error("a node with the same name is already active with the replica `" + _name + "'");
- }
- exception.reset(ex.ice_clone());
+ if(traceLevels)
+ {
+ traceLevels->logger->error("a node with the same name is already active with the replica `" + _name + "'");
+ }
+ exception.reset(ex.ice_clone());
}
catch(const Ice::Exception& ex)
{
- exception.reset(ex.ice_clone());
+ exception.reset(ex.ice_clone());
}
if(session)
{
- if(traceLevels && traceLevels->replica > 0)
- {
- Ice::Trace out(traceLevels->logger, traceLevels->replicaCat);
- out << "established session with replica `" << _name << "'";
- }
+ if(traceLevels && traceLevels->replica > 0)
+ {
+ Ice::Trace out(traceLevels->logger, traceLevels->replicaCat);
+ out << "established session with replica `" << _name << "'";
+ }
}
else
{
- if(traceLevels && traceLevels->replica > 1)
- {
- Ice::Trace out(traceLevels->logger, traceLevels->replicaCat);
- out << "failed to establish session with replica `" << _name << "':\n";
- if(exception.get())
- {
- out << *exception.get();
- }
- else
- {
- out << "failed to get replica proxy";
- }
- }
+ if(traceLevels && traceLevels->replica > 1)
+ {
+ Ice::Trace out(traceLevels->logger, traceLevels->replicaCat);
+ out << "failed to establish session with replica `" << _name << "':\n";
+ if(exception.get())
+ {
+ out << *exception.get();
+ }
+ else
+ {
+ out << "failed to get replica proxy";
+ }
+ }
}
return session;
@@ -138,7 +138,7 @@ NodeSessionKeepAliveThread::createSessionImpl(const InternalRegistryPrx& registr
int t = session->getTimeout();
if(t > 0)
{
- timeout = IceUtil::Time::seconds(t / 2);
+ timeout = IceUtil::Time::seconds(t / 2);
}
_node->addObserver(session, session->getObserver());
return session;
@@ -151,21 +151,21 @@ NodeSessionKeepAliveThread::destroySession(const NodeSessionPrx& session)
try
{
- session->destroy();
+ session->destroy();
- if(_node->getTraceLevels() && _node->getTraceLevels()->replica > 0)
- {
- Ice::Trace out(_node->getTraceLevels()->logger, _node->getTraceLevels()->replicaCat);
- out << "destroyed replica `" << _name << "' session";
- }
+ if(_node->getTraceLevels() && _node->getTraceLevels()->replica > 0)
+ {
+ Ice::Trace out(_node->getTraceLevels()->logger, _node->getTraceLevels()->replicaCat);
+ out << "destroyed replica `" << _name << "' session";
+ }
}
catch(const Ice::LocalException& ex)
{
- if(_node->getTraceLevels() && _node->getTraceLevels()->replica > 1)
- {
- Ice::Trace out(_node->getTraceLevels()->logger, _node->getTraceLevels()->replicaCat);
- out << "couldn't destroy replica `" << _name << "' session:\n" << ex;
- }
+ if(_node->getTraceLevels() && _node->getTraceLevels()->replica > 1)
+ {
+ Ice::Trace out(_node->getTraceLevels()->logger, _node->getTraceLevels()->replicaCat);
+ out << "couldn't destroy replica `" << _name << "' session:\n" << ex;
+ }
}
}
@@ -174,24 +174,24 @@ NodeSessionKeepAliveThread::keepAlive(const NodeSessionPrx& session)
{
if(_node->getTraceLevels() && _node->getTraceLevels()->replica > 2)
{
- Ice::Trace out(_node->getTraceLevels()->logger, _node->getTraceLevels()->replicaCat);
- out << "sending keep alive message to replica `" << _name << "'";
+ Ice::Trace out(_node->getTraceLevels()->logger, _node->getTraceLevels()->replicaCat);
+ out << "sending keep alive message to replica `" << _name << "'";
}
try
{
- session->keepAlive(_node->getPlatformInfo().getLoadInfo());
- return true;
+ session->keepAlive(_node->getPlatformInfo().getLoadInfo());
+ return true;
}
catch(const Ice::LocalException& ex)
{
- _node->removeObserver(session);
- if(_node->getTraceLevels() && _node->getTraceLevels()->replica > 0)
- {
- Ice::Trace out(_node->getTraceLevels()->logger, _node->getTraceLevels()->replicaCat);
- out << "lost session with replica `" << _name << "':\n" << ex;
- }
- return false;
+ _node->removeObserver(session);
+ if(_node->getTraceLevels() && _node->getTraceLevels()->replica > 0)
+ {
+ Ice::Trace out(_node->getTraceLevels()->logger, _node->getTraceLevels()->replicaCat);
+ out << "lost session with replica `" << _name << "':\n" << ex;
+ }
+ return false;
}
}
@@ -225,9 +225,9 @@ NodeSessionManager::create(const NodeIPtr& node)
QueryPrx query = QueryPrx::uncheckedCast(communicator->stringToProxy(communicator->identityToString(id)));
for(Ice::EndpointSeq::const_iterator p = endpoints.begin(); p != endpoints.end(); ++p)
{
- Ice::EndpointSeq singleEndpoint;
- singleEndpoint.push_back(*p);
- _queryObjects.push_back(QueryPrx::uncheckedCast(query->ice_endpoints(singleEndpoint)));
+ Ice::EndpointSeq singleEndpoint;
+ singleEndpoint.push_back(*p);
+ _queryObjects.push_back(QueryPrx::uncheckedCast(query->ice_endpoints(singleEndpoint)));
}
id.name = "InternalRegistry-Master";
@@ -252,17 +252,17 @@ NodeSessionManager::create(const InternalRegistryPrx& replica)
NodeSessionKeepAliveThreadPtr thread;
if(replica->ice_getIdentity() == _master->ice_getIdentity())
{
- thread = _thread;
- thread->setRegistry(replica);
+ thread = _thread;
+ thread->setRegistry(replica);
}
else
{
- thread = addReplicaSession(replica);
+ thread = addReplicaSession(replica);
}
if(thread)
{
- thread->tryCreateSession();
+ thread->tryCreateSession();
}
}
@@ -270,8 +270,8 @@ void
NodeSessionManager::activate()
{
{
- Lock sync(*this);
- _activated = true;
+ Lock sync(*this);
+ _activated = true;
}
//
@@ -282,19 +282,19 @@ NodeSessionManager::activate()
NodeSessionPrx session = _thread->getSession();
if(!session)
{
- _thread->tryCreateSession(true);
- session = _thread->getSession();
+ _thread->tryCreateSession(true);
+ session = _thread->getSession();
}
if(session)
{
- try
- {
- session->setReplicaObserver(_node->getProxy());
- syncServers(session);
- }
- catch(const Ice::LocalException&)
- {
- }
+ try
+ {
+ session->setReplicaObserver(_node->getProxy());
+ syncServers(session);
+ }
+ catch(const Ice::LocalException&)
+ {
+ }
}
}
@@ -317,23 +317,23 @@ NodeSessionManager::destroy()
{
NodeSessionMap sessions;
{
- Lock sync(*this);
- _destroyed = true;
- _sessions.swap(sessions);
- notifyAll();
+ Lock sync(*this);
+ _destroyed = true;
+ _sessions.swap(sessions);
+ notifyAll();
}
_thread->terminate();
NodeSessionMap::const_iterator p;
for(p = sessions.begin(); p != sessions.end(); ++p)
{
- p->second->terminate();
+ p->second->terminate();
}
_thread->getThreadControl().join();
for(p = sessions.begin(); p != sessions.end(); ++p)
{
- p->second->getThreadControl().join();
+ p->second->getThreadControl().join();
}
}
@@ -343,7 +343,7 @@ NodeSessionManager::replicaInit(const InternalRegistryPrxSeq& replicas)
Lock sync(*this);
if(_destroyed)
{
- return;
+ return;
}
//
@@ -352,8 +352,8 @@ NodeSessionManager::replicaInit(const InternalRegistryPrxSeq& replicas)
_replicas.clear();
for(InternalRegistryPrxSeq::const_iterator p = replicas.begin(); p != replicas.end(); ++p)
{
- _replicas.insert((*p)->ice_getIdentity());
- addReplicaSession(*p)->tryCreateSession(false);
+ _replicas.insert((*p)->ice_getIdentity());
+ addReplicaSession(*p)->tryCreateSession(false);
}
}
@@ -363,7 +363,7 @@ NodeSessionManager::replicaAdded(const InternalRegistryPrx& replica)
Lock sync(*this);
if(_destroyed)
{
- return;
+ return;
}
_replicas.insert(replica->ice_getIdentity());
addReplicaSession(replica)->tryCreateSession(false);
@@ -373,12 +373,12 @@ void
NodeSessionManager::replicaRemoved(const InternalRegistryPrx& replica)
{
{
- Lock sync(*this);
- if(_destroyed)
- {
- return;
- }
- _replicas.erase(replica->ice_getIdentity());
+ Lock sync(*this);
+ if(_destroyed)
+ {
+ return;
+ }
+ _replicas.erase(replica->ice_getIdentity());
}
//
@@ -396,14 +396,14 @@ NodeSessionManager::addReplicaSession(const InternalRegistryPrx& replica)
NodeSessionKeepAliveThreadPtr thread;
if(p != _sessions.end())
{
- thread = p->second;
- thread->setRegistry(replica);
+ thread = p->second;
+ thread->setRegistry(replica);
}
else
{
- thread = new NodeSessionKeepAliveThread(replica, _node, _queryObjects);
- _sessions.insert(make_pair(replica->ice_getIdentity(), thread));
- thread->start();
+ thread = new NodeSessionKeepAliveThread(replica, _node, _queryObjects);
+ _sessions.insert(make_pair(replica->ice_getIdentity(), thread));
+ thread->start();
}
return thread;
}
@@ -413,31 +413,31 @@ NodeSessionManager::reapReplicas()
{
vector<NodeSessionKeepAliveThreadPtr> reap;
{
- Lock sync(*this);
- if(_destroyed)
- {
- return;
- }
-
- NodeSessionMap::iterator q = _sessions.begin();
- while(q != _sessions.end())
- {
- if(_replicas.find(q->first) == _replicas.end() && q->second->terminateIfDisconnected())
- {
- _node->removeObserver(q->second->getSession());
- reap.push_back(q->second);
- _sessions.erase(q++);
- }
- else
- {
- ++q;
- }
- }
+ Lock sync(*this);
+ if(_destroyed)
+ {
+ return;
+ }
+
+ NodeSessionMap::iterator q = _sessions.begin();
+ while(q != _sessions.end())
+ {
+ if(_replicas.find(q->first) == _replicas.end() && q->second->terminateIfDisconnected())
+ {
+ _node->removeObserver(q->second->getSession());
+ reap.push_back(q->second);
+ _sessions.erase(q++);
+ }
+ else
+ {
+ ++q;
+ }
+ }
}
for(vector<NodeSessionKeepAliveThreadPtr>::const_iterator p = reap.begin(); p != reap.end(); ++p)
{
- (*p)->getThreadControl().join();
+ (*p)->getThreadControl().join();
}
}
@@ -465,8 +465,8 @@ NodeSessionManager::createdSession(const NodeSessionPrx& session)
{
bool activated;
{
- Lock sync(*this);
- activated = _activated;
+ Lock sync(*this);
+ activated = _activated;
}
//
@@ -479,15 +479,15 @@ NodeSessionManager::createdSession(const NodeSessionPrx& session)
//
if(session && activated)
{
- try
- {
- session->setReplicaObserver(_node->getProxy());
- syncServers(session);
- }
- catch(const Ice::LocalException&)
- {
- }
- return;
+ try
+ {
+ session->setReplicaObserver(_node->getProxy());
+ syncServers(session);
+ }
+ catch(const Ice::LocalException&)
+ {
+ }
+ return;
}
//
@@ -501,73 +501,73 @@ NodeSessionManager::createdSession(const NodeSessionPrx& session)
InternalRegistryPrxSeq replicas;
if(session)
{
- assert(!activated); // The node adapter isn't activated yet so
- // we're not subscribed yet to the replica
+ assert(!activated); // The node adapter isn't activated yet so
+ // we're not subscribed yet to the replica
// observer topic.
- try
- {
- replicas = _thread->getRegistry()->getReplicas();
- }
- catch(const Ice::LocalException&)
- {
- }
+ try
+ {
+ replicas = _thread->getRegistry()->getReplicas();
+ }
+ catch(const Ice::LocalException&)
+ {
+ }
}
else
{
- map<Ice::Identity, Ice::ObjectPrx> proxies;
- for(vector<QueryPrx>::const_iterator p = _queryObjects.begin(); p != _queryObjects.end(); ++p)
- {
- try
- {
- Ice::ObjectProxySeq prxs = (*p)->findAllObjectsByType(InternalRegistry::ice_staticId());
- for(Ice::ObjectProxySeq::const_iterator q = prxs.begin(); q != prxs.end(); ++q)
- {
- //
- // NOTE: We might override a good proxy here! We could improve this to make
- // sure that we don't override the proxy for replica N if that proxy was
- // obtained from replica N.
- //
- proxies[(*q)->ice_getIdentity()] = *q;
- }
- }
- catch(const Ice::LocalException&)
- {
- // IGNORE
- }
- }
-
- for(map<Ice::Identity, Ice::ObjectPrx>::const_iterator q = proxies.begin(); q != proxies.end(); ++q)
- {
- replicas.push_back(InternalRegistryPrx::uncheckedCast(q->second));
- }
+ map<Ice::Identity, Ice::ObjectPrx> proxies;
+ for(vector<QueryPrx>::const_iterator p = _queryObjects.begin(); p != _queryObjects.end(); ++p)
+ {
+ try
+ {
+ Ice::ObjectProxySeq prxs = (*p)->findAllObjectsByType(InternalRegistry::ice_staticId());
+ for(Ice::ObjectProxySeq::const_iterator q = prxs.begin(); q != prxs.end(); ++q)
+ {
+ //
+ // NOTE: We might override a good proxy here! We could improve this to make
+ // sure that we don't override the proxy for replica N if that proxy was
+ // obtained from replica N.
+ //
+ proxies[(*q)->ice_getIdentity()] = *q;
+ }
+ }
+ catch(const Ice::LocalException&)
+ {
+ // IGNORE
+ }
+ }
+
+ for(map<Ice::Identity, Ice::ObjectPrx>::const_iterator q = proxies.begin(); q != proxies.end(); ++q)
+ {
+ replicas.push_back(InternalRegistryPrx::uncheckedCast(q->second));
+ }
}
vector<NodeSessionKeepAliveThreadPtr> sessions;
{
- Lock sync(*this);
- if(_destroyed)
- {
- return;
- }
-
- //
- // If the node adapter was activated since we last check, we don't need
- // to initialize the replicas here, it will be done by replicaInit().
- //
- if(!session || !_activated)
- {
- _replicas.clear();
- for(InternalRegistryPrxSeq::const_iterator p = replicas.begin(); p != replicas.end(); ++p)
- {
- if((*p)->ice_getIdentity() != _master->ice_getIdentity())
- {
- _replicas.insert((*p)->ice_getIdentity());
- NodeSessionKeepAliveThreadPtr session = addReplicaSession(*p);
- session->tryCreateSession(false);
- sessions.push_back(session);
- }
- }
- }
+ Lock sync(*this);
+ if(_destroyed)
+ {
+ return;
+ }
+
+ //
+ // If the node adapter was activated since we last check, we don't need
+ // to initialize the replicas here, it will be done by replicaInit().
+ //
+ if(!session || !_activated)
+ {
+ _replicas.clear();
+ for(InternalRegistryPrxSeq::const_iterator p = replicas.begin(); p != replicas.end(); ++p)
+ {
+ if((*p)->ice_getIdentity() != _master->ice_getIdentity())
+ {
+ _replicas.insert((*p)->ice_getIdentity());
+ NodeSessionKeepAliveThreadPtr session = addReplicaSession(*p);
+ session->tryCreateSession(false);
+ sessions.push_back(session);
+ }
+ }
+ }
}
//
@@ -577,7 +577,7 @@ NodeSessionManager::createdSession(const NodeSessionPrx& session)
//
for(vector<NodeSessionKeepAliveThreadPtr>::const_iterator p = sessions.begin(); p != sessions.end(); ++p)
{
- (*p)->tryCreateSession(true);
+ (*p)->tryCreateSession(true);
}
}
diff --git a/cpp/src/IceGrid/NodeSessionManager.h b/cpp/src/IceGrid/NodeSessionManager.h
index 7c67e4d0dc0..11f12386aa9 100644
--- a/cpp/src/IceGrid/NodeSessionManager.h
+++ b/cpp/src/IceGrid/NodeSessionManager.h
@@ -78,39 +78,39 @@ private:
{
public:
- Thread(NodeSessionManager& manager) :
- NodeSessionKeepAliveThread(manager._master, manager._node, manager._queryObjects),
- _manager(manager)
+ Thread(NodeSessionManager& manager) :
+ NodeSessionKeepAliveThread(manager._master, manager._node, manager._queryObjects),
+ _manager(manager)
{
- }
+ }
- virtual NodeSessionPrx
- createSession(InternalRegistryPrx& master, IceUtil::Time& timeout)
+ virtual NodeSessionPrx
+ createSession(InternalRegistryPrx& master, IceUtil::Time& timeout)
{
- NodeSessionPrx session = NodeSessionKeepAliveThread::createSession(master, timeout);
- _manager.createdSession(session);
- _manager.reapReplicas();
- return session;
- }
-
- virtual void
- destroySession(const NodeSessionPrx& session)
+ NodeSessionPrx session = NodeSessionKeepAliveThread::createSession(master, timeout);
+ _manager.createdSession(session);
+ _manager.reapReplicas();
+ return session;
+ }
+
+ virtual void
+ destroySession(const NodeSessionPrx& session)
{
- NodeSessionKeepAliveThread::destroySession(session);
- _manager.reapReplicas();
- }
+ NodeSessionKeepAliveThread::destroySession(session);
+ _manager.reapReplicas();
+ }
- virtual bool
- keepAlive(const NodeSessionPrx& session)
+ virtual bool
+ keepAlive(const NodeSessionPrx& session)
{
- bool alive = NodeSessionKeepAliveThread::keepAlive(session);
- _manager.reapReplicas();
- return alive;
- }
+ bool alive = NodeSessionKeepAliveThread::keepAlive(session);
+ _manager.reapReplicas();
+ return alive;
+ }
private:
-
- NodeSessionManager& _manager;
+
+ NodeSessionManager& _manager;
};
typedef IceUtil::Handle<Thread> ThreadPtr;
friend class Thread;
diff --git a/cpp/src/IceGrid/ObjectCache.cpp b/cpp/src/IceGrid/ObjectCache.cpp
index baa608ee12f..65dfe17cf23 100644
--- a/cpp/src/IceGrid/ObjectCache.cpp
+++ b/cpp/src/IceGrid/ObjectCache.cpp
@@ -30,7 +30,7 @@ struct ObjectEntryCI : binary_function<ObjectEntryPtr&, ObjectEntryPtr&, bool>
bool
operator()(const ObjectEntryPtr& lhs, const ObjectEntryPtr& rhs)
{
- return ::Ice::proxyIdentityLess(lhs->getProxy(), rhs->getProxy());
+ return ::Ice::proxyIdentityLess(lhs->getProxy(), rhs->getProxy());
}
};
@@ -38,7 +38,7 @@ struct ObjectLoadCI : binary_function<pair<Ice::ObjectPrx, float>&, pair<Ice::Ob
{
bool operator()(const pair<Ice::ObjectPrx, float>& lhs, const pair<Ice::ObjectPrx, float>& rhs)
{
- return lhs.second < rhs.second;
+ return lhs.second < rhs.second;
}
};
@@ -87,14 +87,14 @@ ObjectCache::add(const ObjectInfo& info, const string& application)
map<string, TypeEntry>::iterator p = _types.find(entry->getType());
if(p == _types.end())
{
- p = _types.insert(p, map<string, TypeEntry>::value_type(entry->getType(), TypeEntry()));
+ p = _types.insert(p, map<string, TypeEntry>::value_type(entry->getType(), TypeEntry()));
}
p->second.add(entry);
if(_traceLevels && _traceLevels->object > 0)
{
- Ice::Trace out(_traceLevels->logger, _traceLevels->objectCat);
- out << "added object `" << _communicator->identityToString(id) << "'";
+ Ice::Trace out(_traceLevels->logger, _traceLevels->objectCat);
+ out << "added object `" << _communicator->identityToString(id) << "'";
}
}
@@ -105,7 +105,7 @@ ObjectCache::get(const Ice::Identity& id) const
ObjectEntryPtr entry = getImpl(id);
if(!entry)
{
- throw ObjectNotRegisteredException(id);
+ throw ObjectNotRegisteredException(id);
}
return entry;
}
@@ -121,14 +121,14 @@ ObjectCache::remove(const Ice::Identity& id)
map<string, TypeEntry>::iterator p = _types.find(entry->getType());
assert(p != _types.end());
if(p->second.remove(entry))
- {
- _types.erase(p);
+ {
+ _types.erase(p);
}
if(_traceLevels && _traceLevels->object > 0)
{
- Ice::Trace out(_traceLevels->logger, _traceLevels->objectCat);
- out << "removed object `" << _communicator->identityToString(id) << "'";
+ Ice::Trace out(_traceLevels->logger, _traceLevels->objectCat);
+ out << "removed object `" << _communicator->identityToString(id) << "'";
}
return entry;
@@ -142,12 +142,12 @@ ObjectCache::getObjectsByType(const string& type)
map<string, TypeEntry>::const_iterator p = _types.find(type);
if(p == _types.end())
{
- return proxies;
+ return proxies;
}
const vector<ObjectEntryPtr>& objects = p->second.getObjects();
for(vector<ObjectEntryPtr>::const_iterator q = objects.begin(); q != objects.end(); ++q)
{
- proxies.push_back((*q)->getProxy());
+ proxies.push_back((*q)->getProxy());
}
return proxies;
}
@@ -159,10 +159,10 @@ ObjectCache::getAll(const string& expression)
ObjectInfoSeq infos;
for(map<Ice::Identity, ObjectEntryPtr>::const_iterator p = _entries.begin(); p != _entries.end(); ++p)
{
- if(expression.empty() || IceUtil::match(_communicator->identityToString(p->first), expression, true))
- {
- infos.push_back(p->second->getObjectInfo());
- }
+ if(expression.empty() || IceUtil::match(_communicator->identityToString(p->first), expression, true))
+ {
+ infos.push_back(p->second->getObjectInfo());
+ }
}
return infos;
}
@@ -175,13 +175,13 @@ ObjectCache::getAllByType(const string& type)
map<string, TypeEntry>::const_iterator p = _types.find(type);
if(p == _types.end())
{
- return infos;
+ return infos;
}
const vector<ObjectEntryPtr>& objects = p->second.getObjects();
for(vector<ObjectEntryPtr>::const_iterator q = objects.begin(); q != objects.end(); ++q)
{
- infos.push_back((*q)->getObjectInfo());
+ infos.push_back((*q)->getObjectInfo());
}
return infos;
}
diff --git a/cpp/src/IceGrid/ObjectCache.h b/cpp/src/IceGrid/ObjectCache.h
index fc814a1c87e..7293d1c53fd 100644
--- a/cpp/src/IceGrid/ObjectCache.h
+++ b/cpp/src/IceGrid/ObjectCache.h
@@ -62,16 +62,16 @@ private:
{
public:
- TypeEntry();
+ TypeEntry();
- void add(const ObjectEntryPtr&);
- bool remove(const ObjectEntryPtr&);
-
- const std::vector<ObjectEntryPtr>& getObjects() const { return _objects; }
+ void add(const ObjectEntryPtr&);
+ bool remove(const ObjectEntryPtr&);
+
+ const std::vector<ObjectEntryPtr>& getObjects() const { return _objects; }
private:
-
- std::vector<ObjectEntryPtr> _objects;
+
+ std::vector<ObjectEntryPtr> _objects;
};
const Ice::CommunicatorPtr _communicator;
diff --git a/cpp/src/IceGrid/Parser.cpp b/cpp/src/IceGrid/Parser.cpp
index d2c90f05048..bfc95391d91 100644
--- a/cpp/src/IceGrid/Parser.cpp
+++ b/cpp/src/IceGrid/Parser.cpp
@@ -210,7 +210,7 @@ Parser* parser;
ParserPtr
Parser::createParser(const CommunicatorPtr& communicator, const AdminSessionPrx& session, const AdminPrx& admin,
- bool interactive)
+ bool interactive)
{
return new Parser(communicator, session, admin, interactive);
}
@@ -220,15 +220,15 @@ Parser::usage(const string& category, const string& command)
{
if(_helpCommands.find(category) == _helpCommands.end())
{
- invalidCommand("unknown category `" + category + "'");
+ invalidCommand("unknown category `" + category + "'");
}
else if(_helpCommands[category].find(command) == _helpCommands[category].end())
{
- invalidCommand("unknown command `" + category + " " + command + "'");
+ invalidCommand("unknown command `" + category + " " + command + "'");
}
else
{
- cout << _helpCommands[category][command];
+ cout << _helpCommands[category][command];
}
}
@@ -237,15 +237,15 @@ Parser::usage(const string& category, const list<string>& args)
{
if(args.empty())
{
- usage(category);
+ usage(category);
}
else if(args.size() > 1)
{
- invalidCommand("`help' requires at most 1 argument");
+ invalidCommand("`help' requires at most 1 argument");
}
else
{
- usage(category, *args.begin());
+ usage(category, *args.begin());
}
}
@@ -255,11 +255,11 @@ Parser::usage()
cout <<
"help Print this message.\n"
"exit, quit Exit this program.\n"
- "CATEGORY help Print the help section of the given CATEGORY.\n"
- "COMMAND help Print the help of the given COMMAND.\n"
- "\n"
- "List of help categories:\n"
- "\n"
+ "CATEGORY help Print the help section of the given CATEGORY.\n"
+ "COMMAND help Print the help of the given COMMAND.\n"
+ "\n"
+ "List of help categories:\n"
+ "\n"
" application: commands to manage applications\n"
" node: commands to manage nodes\n"
" registry: commands to manage registries\n"
@@ -268,7 +268,7 @@ Parser::usage()
" object: commands to manage objects\n"
" server template: commands to manage server templates\n"
" service template: commands to manage service templates\n"
- "\n";
+ "\n";
}
void
@@ -298,11 +298,11 @@ Parser::checkInterrupted()
{
if(!_interactive)
{
- Lock sync(*this);
- if(_interrupted)
- {
- throw "interrupted with Ctrl-C";
- }
+ Lock sync(*this);
+ if(_interrupted)
+ {
+ throw "interrupted with Ctrl-C";
+ }
}
}
@@ -317,69 +317,69 @@ Parser::addApplication(const list<string>& origArgs)
vector<string> args;
try
{
- for(list<string>::const_iterator p = copyArgs.begin(); p != copyArgs.end(); ++p)
- {
- args.push_back(*p);
- }
- args = opts.parse(args);
+ for(list<string>::const_iterator p = copyArgs.begin(); p != copyArgs.end(); ++p)
+ {
+ args.push_back(*p);
+ }
+ args = opts.parse(args);
}
catch(const IceUtil::BadOptException& e)
{
- error(e.reason);
- return;
+ error(e.reason);
+ return;
}
if(args.size() < 1)
{
- invalidCommand("application add", "requires at least one argument");
- return;
+ invalidCommand("application add", "requires at least one argument");
+ return;
}
try
{
- StringSeq targets;
- map<string, string> vars;
-
- vector<string>::const_iterator p = args.begin();
- string desc = *p++;
-
- for(; p != args.end(); ++p)
- {
- string::size_type pos = p->find('=');
- if(pos != string::npos)
- {
- vars[p->substr(0, pos)] = p->substr(pos + 1);
- }
- else
- {
- targets.push_back(*p);
- }
- }
-
- //
- // Add the application.
- //
- ApplicationDescriptor app = DescriptorParser::parseDescriptor(desc, targets, vars, _communicator, _admin);
- _admin->addApplication(app);
-
- if(!opts.isSet("no-patch"))
- {
- //
- // Patch the application.
- //
- try
- {
- _admin->patchApplication(app.name, true);
- }
- catch(const PatchException& ex)
- {
- patchFailed(ex.reasons);
- }
- }
+ StringSeq targets;
+ map<string, string> vars;
+
+ vector<string>::const_iterator p = args.begin();
+ string desc = *p++;
+
+ for(; p != args.end(); ++p)
+ {
+ string::size_type pos = p->find('=');
+ if(pos != string::npos)
+ {
+ vars[p->substr(0, pos)] = p->substr(pos + 1);
+ }
+ else
+ {
+ targets.push_back(*p);
+ }
+ }
+
+ //
+ // Add the application.
+ //
+ ApplicationDescriptor app = DescriptorParser::parseDescriptor(desc, targets, vars, _communicator, _admin);
+ _admin->addApplication(app);
+
+ if(!opts.isSet("no-patch"))
+ {
+ //
+ // Patch the application.
+ //
+ try
+ {
+ _admin->patchApplication(app.name, true);
+ }
+ catch(const PatchException& ex)
+ {
+ patchFailed(ex.reasons);
+ }
+ }
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -388,21 +388,21 @@ Parser::removeApplication(const list<string>& args)
{
if(args.size() != 1)
{
- invalidCommand("application remove", "requires exactly one argument");
- return;
+ invalidCommand("application remove", "requires exactly one argument");
+ return;
}
try
{
- list<string>::const_iterator p = args.begin();
+ list<string>::const_iterator p = args.begin();
- string name = *p++;
+ string name = *p++;
- _admin->removeApplication(name);
+ _admin->removeApplication(name);
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -411,25 +411,25 @@ Parser::describeApplication(const list<string>& args)
{
if(args.size() < 1)
{
- invalidCommand("application describe", "requires at least one argument");
- return;
+ invalidCommand("application describe", "requires at least one argument");
+ return;
}
try
{
- list<string>::const_iterator p = args.begin();
+ list<string>::const_iterator p = args.begin();
- string name = *p++;
+ string name = *p++;
- Output out(cout);
- ApplicationInfo info = _admin->getApplicationInfo(name);
- ApplicationHelper helper(_communicator, info.descriptor);
- helper.print(out, info);
- out << nl;
+ Output out(cout);
+ ApplicationInfo info = _admin->getApplicationInfo(name);
+ ApplicationHelper helper(_communicator, info.descriptor);
+ helper.print(out, info);
+ out << nl;
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -438,44 +438,44 @@ Parser::diffApplication(const list<string>& args)
{
if(args.size() < 1)
{
- invalidCommand("application diff" , "requires at least one argument");
- return;
+ invalidCommand("application diff" , "requires at least one argument");
+ return;
}
try
{
- StringSeq targets;
- map<string, string> vars;
-
- list<string>::const_iterator p = args.begin();
- string desc = *p++;
-
- for(; p != args.end(); ++p)
- {
- string::size_type pos = p->find('=');
- if(pos != string::npos)
- {
- vars[p->substr(0, pos)] = p->substr(pos + 1);
- }
- else
- {
- targets.push_back(*p);
- }
- }
-
- ApplicationDescriptor newApp = DescriptorParser::parseDescriptor(desc, targets, vars, _communicator, _admin);
- ApplicationInfo origApp = _admin->getApplicationInfo(newApp.name);
-
- ApplicationHelper newAppHelper(_communicator, newApp);
- ApplicationHelper oldAppHelper(_communicator, origApp.descriptor);
-
- Output out(cout);
- newAppHelper.printDiff(out, oldAppHelper);
- out << nl;
+ StringSeq targets;
+ map<string, string> vars;
+
+ list<string>::const_iterator p = args.begin();
+ string desc = *p++;
+
+ for(; p != args.end(); ++p)
+ {
+ string::size_type pos = p->find('=');
+ if(pos != string::npos)
+ {
+ vars[p->substr(0, pos)] = p->substr(pos + 1);
+ }
+ else
+ {
+ targets.push_back(*p);
+ }
+ }
+
+ ApplicationDescriptor newApp = DescriptorParser::parseDescriptor(desc, targets, vars, _communicator, _admin);
+ ApplicationInfo origApp = _admin->getApplicationInfo(newApp.name);
+
+ ApplicationHelper newAppHelper(_communicator, newApp);
+ ApplicationHelper oldAppHelper(_communicator, origApp.descriptor);
+
+ Output out(cout);
+ newAppHelper.printDiff(out, oldAppHelper);
+ out << nl;
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -484,36 +484,36 @@ Parser::updateApplication(const list<string>& args)
{
if(args.size() < 1)
{
- invalidCommand("application diff", "requires at least one argument");
- return;
+ invalidCommand("application diff", "requires at least one argument");
+ return;
}
try
{
- StringSeq targets;
- map<string, string> vars;
+ StringSeq targets;
+ map<string, string> vars;
- list<string>::const_iterator p = args.begin();
- string desc = *p++;
+ list<string>::const_iterator p = args.begin();
+ string desc = *p++;
- for(; p != args.end(); ++p)
- {
- string::size_type pos = p->find('=');
- if(pos != string::npos)
- {
- vars[p->substr(0, pos)] = p->substr(pos + 1);
- }
- else
- {
- targets.push_back(*p);
- }
- }
+ for(; p != args.end(); ++p)
+ {
+ string::size_type pos = p->find('=');
+ if(pos != string::npos)
+ {
+ vars[p->substr(0, pos)] = p->substr(pos + 1);
+ }
+ else
+ {
+ targets.push_back(*p);
+ }
+ }
- _admin->syncApplication(DescriptorParser::parseDescriptor(desc, targets, vars, _communicator, _admin));
+ _admin->syncApplication(DescriptorParser::parseDescriptor(desc, targets, vars, _communicator, _admin));
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -528,33 +528,33 @@ Parser::patchApplication(const list<string>& origArgs)
vector<string> args;
try
{
- for(list<string>::const_iterator p = copyArgs.begin(); p != copyArgs.end(); ++p)
- {
- args.push_back(*p);
- }
- args = opts.parse(args);
+ for(list<string>::const_iterator p = copyArgs.begin(); p != copyArgs.end(); ++p)
+ {
+ args.push_back(*p);
+ }
+ args = opts.parse(args);
}
catch(const IceUtil::BadOptException& e)
{
- error(e.reason);
- return;
+ error(e.reason);
+ return;
}
if(args.size() != 1)
{
- invalidCommand("application patch", "requires exactly one argument");
- return;
+ invalidCommand("application patch", "requires exactly one argument");
+ return;
}
try
{
- vector<string>::const_iterator p = args.begin();
- string name = *p++;
- _admin->patchApplication(name, opts.isSet("force"));
+ vector<string>::const_iterator p = args.begin();
+ string name = *p++;
+ _admin->patchApplication(name, opts.isSet("force"));
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -563,12 +563,12 @@ Parser::listAllApplications()
{
try
{
- Ice::StringSeq names = _admin->getAllApplicationNames();
- copy(names.begin(), names.end(), ostream_iterator<string>(cout,"\n"));
+ Ice::StringSeq names = _admin->getAllApplicationNames();
+ copy(names.begin(), names.end(), ostream_iterator<string>(cout,"\n"));
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -577,50 +577,50 @@ Parser::describeServerTemplate(const list<string>& args)
{
if(args.size() != 2)
{
- invalidCommand("server template describe", "requires exactly two arguments");
- return;
+ invalidCommand("server template describe", "requires exactly two arguments");
+ return;
}
try
{
- list<string>::const_iterator p = args.begin();
-
- string name = *p++;
- string templ = *p++;
-
- ApplicationInfo application = _admin->getApplicationInfo(name);
-
- Output out(cout);
- TemplateDescriptorDict::const_iterator q = application.descriptor.serverTemplates.find(templ);
- if(q != application.descriptor.serverTemplates.end())
- {
- out << "server template `" << templ << "'";
- out << sb;
-
- out << nl << "parameters = `" << toString(q->second.parameters) << "'";
- out << nl;
-
- ServerDescriptorPtr server = ServerDescriptorPtr::dynamicCast(q->second.descriptor);
- IceBoxDescriptorPtr iceBox = IceBoxDescriptorPtr::dynamicCast(server);
- if(iceBox)
- {
- IceBoxHelper(iceBox).print(_communicator, out);
- }
- else
- {
- ServerHelper(server).print(_communicator, out);
- }
- out << eb;
- out << nl;
- }
- else
- {
- error("no server template with id `" + templ + "'");
- }
+ list<string>::const_iterator p = args.begin();
+
+ string name = *p++;
+ string templ = *p++;
+
+ ApplicationInfo application = _admin->getApplicationInfo(name);
+
+ Output out(cout);
+ TemplateDescriptorDict::const_iterator q = application.descriptor.serverTemplates.find(templ);
+ if(q != application.descriptor.serverTemplates.end())
+ {
+ out << "server template `" << templ << "'";
+ out << sb;
+
+ out << nl << "parameters = `" << toString(q->second.parameters) << "'";
+ out << nl;
+
+ ServerDescriptorPtr server = ServerDescriptorPtr::dynamicCast(q->second.descriptor);
+ IceBoxDescriptorPtr iceBox = IceBoxDescriptorPtr::dynamicCast(server);
+ if(iceBox)
+ {
+ IceBoxHelper(iceBox).print(_communicator, out);
+ }
+ else
+ {
+ ServerHelper(server).print(_communicator, out);
+ }
+ out << eb;
+ out << nl;
+ }
+ else
+ {
+ error("no server template with id `" + templ + "'");
+ }
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -629,35 +629,35 @@ Parser::instantiateServerTemplate(const list<string>& args)
{
if(args.size() < 3)
{
- invalidCommand("server template instantiate", "requires at least three arguments");
- return;
+ invalidCommand("server template instantiate", "requires at least three arguments");
+ return;
}
try
{
- map<string, string> vars;
-
- list<string>::const_iterator p = args.begin();
- string application = *p++;
- string node = *p++;
- string templ = *p++;
- for(; p != args.end(); ++p)
- {
- string::size_type pos = p->find('=');
- if(pos != string::npos)
- {
- vars[p->substr(0, pos)] = p->substr(pos + 1);
- }
- }
-
- ServerInstanceDescriptor desc;
- desc._cpp_template = templ;
- desc.parameterValues = vars;
- _admin->instantiateServer(application, node, desc);
+ map<string, string> vars;
+
+ list<string>::const_iterator p = args.begin();
+ string application = *p++;
+ string node = *p++;
+ string templ = *p++;
+ for(; p != args.end(); ++p)
+ {
+ string::size_type pos = p->find('=');
+ if(pos != string::npos)
+ {
+ vars[p->substr(0, pos)] = p->substr(pos + 1);
+ }
+ }
+
+ ServerInstanceDescriptor desc;
+ desc._cpp_template = templ;
+ desc.parameterValues = vars;
+ _admin->instantiateServer(application, node, desc);
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -666,42 +666,42 @@ Parser::describeServiceTemplate(const list<string>& args)
{
if(args.size() != 2)
{
- invalidCommand("service template describe", "requires exactly two arguments");
- return;
+ invalidCommand("service template describe", "requires exactly two arguments");
+ return;
}
try
{
- list<string>::const_iterator p = args.begin();
-
- string name = *p++;
- string templ = *p++;
-
- ApplicationInfo application = _admin->getApplicationInfo(name);
-
- Output out(cout);
- TemplateDescriptorDict::const_iterator q = application.descriptor.serviceTemplates.find(templ);
- if(q != application.descriptor.serviceTemplates.end())
- {
- out << "service template `" << templ << "'";
- out << sb;
-
- out << nl << "parameters = `" << toString(q->second.parameters) << "'";
- out << nl;
-
- ServiceDescriptorPtr desc = ServiceDescriptorPtr::dynamicCast(q->second.descriptor);
- ServiceHelper(desc).print(_communicator, out);
- out << eb;
- out << nl;
- }
- else
- {
- invalidCommand("no service template with id `" + templ + "'");
- }
+ list<string>::const_iterator p = args.begin();
+
+ string name = *p++;
+ string templ = *p++;
+
+ ApplicationInfo application = _admin->getApplicationInfo(name);
+
+ Output out(cout);
+ TemplateDescriptorDict::const_iterator q = application.descriptor.serviceTemplates.find(templ);
+ if(q != application.descriptor.serviceTemplates.end())
+ {
+ out << "service template `" << templ << "'";
+ out << sb;
+
+ out << nl << "parameters = `" << toString(q->second.parameters) << "'";
+ out << nl;
+
+ ServiceDescriptorPtr desc = ServiceDescriptorPtr::dynamicCast(q->second.descriptor);
+ ServiceHelper(desc).print(_communicator, out);
+ out << eb;
+ out << nl;
+ }
+ else
+ {
+ invalidCommand("no service template with id `" + templ + "'");
+ }
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -710,28 +710,28 @@ Parser::describeNode(const list<string>& args)
{
if(args.size() != 1)
{
- invalidCommand("node describe", "requires exactly one argument");
- return;
+ invalidCommand("node describe", "requires exactly one argument");
+ return;
}
try
{
- NodeInfo info = _admin->getNodeInfo(args.front());
- Output out(cout);
- out << "node `" << args.front() << "'";
- out << sb;
- out << nl << "operating system = `" << info.os << "'";
- out << nl << "host name = `" << info.hostname << "'";
- out << nl << "release = `" << info.release << "'";
- out << nl << "version = `" << info.version << "'";
- out << nl << "machine type = `" << info.machine << "'";
- out << nl << "number of processors = `" << info.nProcessors << "'";
- out << eb;
- out << nl;
+ NodeInfo info = _admin->getNodeInfo(args.front());
+ Output out(cout);
+ out << "node `" << args.front() << "'";
+ out << sb;
+ out << nl << "operating system = `" << info.os << "'";
+ out << nl << "host name = `" << info.hostname << "'";
+ out << nl << "release = `" << info.release << "'";
+ out << nl << "version = `" << info.version << "'";
+ out << nl << "machine type = `" << info.machine << "'";
+ out << nl << "number of processors = `" << info.nProcessors << "'";
+ out << eb;
+ out << nl;
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -740,24 +740,24 @@ Parser::pingNode(const list<string>& args)
{
if(args.size() != 1)
{
- invalidCommand("node ping", "requires exactly one argument");
- return;
+ invalidCommand("node ping", "requires exactly one argument");
+ return;
}
try
{
- if(_admin->pingNode(args.front()))
- {
- cout << "node is up" << endl;
- }
- else
- {
- cout << "node is down" << endl;
- }
+ if(_admin->pingNode(args.front()))
+ {
+ cout << "node is up" << endl;
+ }
+ else
+ {
+ cout << "node is down" << endl;
+ }
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -766,18 +766,18 @@ Parser::printLoadNode(const list<string>& args)
{
if(args.size() != 1)
{
- invalidCommand("node load", "requires exactly one argument");
- return;
+ invalidCommand("node load", "requires exactly one argument");
+ return;
}
try
{
- LoadInfo load = _admin->getNodeLoad(args.front());
- cout << "load average (1/5/15): " << load.avg1 << " / " << load.avg5 << " / " << load.avg15 << endl;
+ LoadInfo load = _admin->getNodeLoad(args.front());
+ cout << "load average (1/5/15): " << load.avg1 << " / " << load.avg5 << " / " << load.avg15 << endl;
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -786,17 +786,17 @@ Parser::shutdownNode(const list<string>& args)
{
if(args.size() != 1)
{
- invalidCommand("node shutdown", "requires exactly one argument");
- return;
+ invalidCommand("node shutdown", "requires exactly one argument");
+ return;
}
try
{
- _admin->shutdownNode(args.front());
+ _admin->shutdownNode(args.front());
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -805,12 +805,12 @@ Parser::listAllNodes()
{
try
{
- Ice::StringSeq names = _admin->getAllNodeNames();
- copy(names.begin(), names.end(), ostream_iterator<string>(cout,"\n"));
+ Ice::StringSeq names = _admin->getAllNodeNames();
+ copy(names.begin(), names.end(), ostream_iterator<string>(cout,"\n"));
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -819,23 +819,23 @@ Parser::describeRegistry(const list<string>& args)
{
if(args.size() != 1)
{
- invalidCommand("registry describe", "requires exactly one argument");
- return;
+ invalidCommand("registry describe", "requires exactly one argument");
+ return;
}
try
{
- RegistryInfo info = _admin->getRegistryInfo(args.front());
- Output out(cout);
- out << "registry `" << args.front() << "'";
- out << sb;
- out << nl << "host name = `" << info.hostname << "'";
- out << eb;
- out << nl;
+ RegistryInfo info = _admin->getRegistryInfo(args.front());
+ Output out(cout);
+ out << "registry `" << args.front() << "'";
+ out << sb;
+ out << nl << "host name = `" << info.hostname << "'";
+ out << eb;
+ out << nl;
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -844,24 +844,24 @@ Parser::pingRegistry(const list<string>& args)
{
if(args.size() != 1)
{
- invalidCommand("registry ping", "requires exactly one argument");
- return;
+ invalidCommand("registry ping", "requires exactly one argument");
+ return;
}
try
{
- if(_admin->pingRegistry(args.front()))
- {
- cout << "registry is up" << endl;
- }
- else
- {
- cout << "registry is down" << endl;
- }
+ if(_admin->pingRegistry(args.front()))
+ {
+ cout << "registry is up" << endl;
+ }
+ else
+ {
+ cout << "registry is down" << endl;
+ }
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -870,24 +870,24 @@ Parser::shutdownRegistry(const list<string>& args)
{
if(args.size() > 1)
{
- invalidCommand("registry shutdown", "requires at most one argument");
- return;
+ invalidCommand("registry shutdown", "requires at most one argument");
+ return;
}
try
{
- if(args.empty())
- {
- _admin->shutdown();
- }
- else
- {
- _admin->shutdownRegistry(args.front());
- }
+ if(args.empty())
+ {
+ _admin->shutdown();
+ }
+ else
+ {
+ _admin->shutdownRegistry(args.front());
+ }
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -896,12 +896,12 @@ Parser::listAllRegistries()
{
try
{
- Ice::StringSeq names = _admin->getAllRegistryNames();
- copy(names.begin(), names.end(), ostream_iterator<string>(cout,"\n"));
+ Ice::StringSeq names = _admin->getAllRegistryNames();
+ copy(names.begin(), names.end(), ostream_iterator<string>(cout,"\n"));
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -910,24 +910,24 @@ Parser::removeServer(const list<string>& args)
{
if(args.size() != 1)
{
- invalidCommand("server remove", "requires exactly one argument");
- return;
+ invalidCommand("server remove", "requires exactly one argument");
+ return;
}
try
{
- ServerInfo info = _admin->getServerInfo(args.front());
- NodeUpdateDescriptor nodeUpdate;
- nodeUpdate.name = info.node;
- nodeUpdate.removeServers.push_back(args.front());
- ApplicationUpdateDescriptor update;
- update.name = info.application;
- update.nodes.push_back(nodeUpdate);
- _admin->updateApplication(update);
+ ServerInfo info = _admin->getServerInfo(args.front());
+ NodeUpdateDescriptor nodeUpdate;
+ nodeUpdate.name = info.node;
+ nodeUpdate.removeServers.push_back(args.front());
+ ApplicationUpdateDescriptor update;
+ update.name = info.application;
+ update.nodes.push_back(nodeUpdate);
+ _admin->updateApplication(update);
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -936,21 +936,21 @@ Parser::startServer(const list<string>& args)
{
if(args.size() != 1)
{
- invalidCommand("server start", "requires exactly one argument");
- return;
+ invalidCommand("server start", "requires exactly one argument");
+ return;
}
try
{
- _admin->startServer(args.front());
+ _admin->startServer(args.front());
}
catch(const ServerStartException& ex)
{
- error("the server didn't start successfully:\n" + ex.reason);
+ error("the server didn't start successfully:\n" + ex.reason);
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -959,21 +959,21 @@ Parser::stopServer(const list<string>& args)
{
if(args.size() != 1)
{
- invalidCommand("server stop", "requires exactly one argument");
- return;
+ invalidCommand("server stop", "requires exactly one argument");
+ return;
}
try
{
- _admin->stopServer(args.front());
+ _admin->stopServer(args.front());
}
catch(const ServerStopException& ex)
{
- error("the server didn't stop successfully:\n" + ex.reason);
+ error("the server didn't stop successfully:\n" + ex.reason);
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -988,31 +988,31 @@ Parser::patchServer(const list<string>& origArgs)
vector<string> args;
try
{
- for(list<string>::const_iterator p = copyArgs.begin(); p != copyArgs.end(); ++p)
- {
- args.push_back(*p);
- }
- args = opts.parse(args);
+ for(list<string>::const_iterator p = copyArgs.begin(); p != copyArgs.end(); ++p)
+ {
+ args.push_back(*p);
+ }
+ args = opts.parse(args);
}
catch(const IceUtil::BadOptException& e)
{
- error(e.reason);
- return;
+ error(e.reason);
+ return;
}
if(args.size() != 1)
{
- invalidCommand("server patch", "requires exactly one argument");
- return;
+ invalidCommand("server patch", "requires exactly one argument");
+ return;
}
try
{
- _admin->patchServer(args.front(), opts.isSet("force"));
+ _admin->patchServer(args.front(), opts.isSet("force"));
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -1021,19 +1021,19 @@ Parser::signalServer(const list<string>& args)
{
if(args.size() != 2)
{
- invalidCommand("server signal", "requires exactly two arguments");
- return;
+ invalidCommand("server signal", "requires exactly two arguments");
+ return;
}
try
{
- list<string>::const_iterator p = args.begin();
- string server = *p++;
- _admin->sendSignal(server, *p);
+ list<string>::const_iterator p = args.begin();
+ string server = *p++;
+ _admin->sendSignal(server, *p);
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -1043,19 +1043,19 @@ Parser::writeMessage(const list<string>& args, int fd)
{
if(args.size() != 2)
{
- invalidCommand("server stdout or server stderr", "requires exactly two arguments");
- return;
+ invalidCommand("server stdout or server stderr", "requires exactly two arguments");
+ return;
}
try
{
- list<string>::const_iterator p = args.begin();
- string server = *p++;
- _admin->writeMessage(server, *p, fd);
+ list<string>::const_iterator p = args.begin();
+ string server = *p++;
+ _admin->writeMessage(server, *p, fd);
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -1064,28 +1064,28 @@ Parser::describeServer(const list<string>& args)
{
if(args.size() != 1)
{
- invalidCommand("server describe", "requires exactly one argument");
- return;
+ invalidCommand("server describe", "requires exactly one argument");
+ return;
}
try
{
- ServerInfo info = _admin->getServerInfo(args.front());
- Output out(cout);
- IceBoxDescriptorPtr iceBox = IceBoxDescriptorPtr::dynamicCast(info.descriptor);
- if(iceBox)
- {
- IceBoxHelper(iceBox).print(_communicator, out, info);
- }
- else
- {
- ServerHelper(info.descriptor).print(_communicator, out, info);
- }
- out << nl;
+ ServerInfo info = _admin->getServerInfo(args.front());
+ Output out(cout);
+ IceBoxDescriptorPtr iceBox = IceBoxDescriptorPtr::dynamicCast(info.descriptor);
+ if(iceBox)
+ {
+ IceBoxHelper(iceBox).print(_communicator, out, info);
+ }
+ else
+ {
+ ServerHelper(info.descriptor).print(_communicator, out, info);
+ }
+ out << nl;
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -1094,60 +1094,60 @@ Parser::stateServer(const list<string>& args)
{
if(args.size() != 1)
{
- invalidCommand("server state", "requires exactly one argument");
- return;
+ invalidCommand("server state", "requires exactly one argument");
+ return;
}
try
{
- ServerState state = _admin->getServerState(args.front());
- string enabled = _admin->isServerEnabled(args.front()) ? "enabled" : "disabled";
- switch(state)
- {
- case Inactive:
- {
- cout << "inactive (" << enabled << ")" << endl;
- break;
- }
- case Activating:
- {
- cout << "activating (" << enabled << ")" << endl;
- break;
- }
- case Active:
- {
- int pid = _admin->getServerPid(args.front());
- cout << "active (pid = " << pid << ", " << enabled << ")" << endl;
- break;
- }
- case ActivationTimedOut:
- {
- int pid = _admin->getServerPid(args.front());
- cout << "activation timed out (pid = " << pid << ", " << enabled << ")" << endl;
- break;
- }
- case Deactivating:
- {
- cout << "deactivating (" << enabled << ")" << endl;
- break;
- }
- case Destroying:
- {
- cout << "destroying (" << enabled << ")" << endl;
- break;
- }
- case Destroyed:
- {
- cout << "destroyed (" << enabled << ")" << endl;
- break;
- }
- default:
- assert(false);
- }
+ ServerState state = _admin->getServerState(args.front());
+ string enabled = _admin->isServerEnabled(args.front()) ? "enabled" : "disabled";
+ switch(state)
+ {
+ case Inactive:
+ {
+ cout << "inactive (" << enabled << ")" << endl;
+ break;
+ }
+ case Activating:
+ {
+ cout << "activating (" << enabled << ")" << endl;
+ break;
+ }
+ case Active:
+ {
+ int pid = _admin->getServerPid(args.front());
+ cout << "active (pid = " << pid << ", " << enabled << ")" << endl;
+ break;
+ }
+ case ActivationTimedOut:
+ {
+ int pid = _admin->getServerPid(args.front());
+ cout << "activation timed out (pid = " << pid << ", " << enabled << ")" << endl;
+ break;
+ }
+ case Deactivating:
+ {
+ cout << "deactivating (" << enabled << ")" << endl;
+ break;
+ }
+ case Destroying:
+ {
+ cout << "destroying (" << enabled << ")" << endl;
+ break;
+ }
+ case Destroyed:
+ {
+ cout << "destroyed (" << enabled << ")" << endl;
+ break;
+ }
+ default:
+ assert(false);
+ }
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -1156,25 +1156,25 @@ Parser::pidServer(const list<string>& args)
{
if(args.size() != 1)
{
- invalidCommand("server pid", "requires exactly one argument");
- return;
+ invalidCommand("server pid", "requires exactly one argument");
+ return;
}
try
{
- int pid = _admin->getServerPid(args.front());
- if(pid > 0)
- {
- cout << pid << endl;
- }
- else
- {
- error("server is not running");
- }
+ int pid = _admin->getServerPid(args.front());
+ if(pid > 0)
+ {
+ cout << pid << endl;
+ }
+ else
+ {
+ error("server is not running");
+ }
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -1183,24 +1183,24 @@ Parser::enableServer(const list<string>& args, bool enable)
{
if(args.size() != 1)
{
- if(enable)
- {
- invalidCommand("server enable", "requires exactly one argument");
- }
- else
- {
- invalidCommand("server disable", "requires exactly one argument");
- }
- return;
+ if(enable)
+ {
+ invalidCommand("server enable", "requires exactly one argument");
+ }
+ else
+ {
+ invalidCommand("server disable", "requires exactly one argument");
+ }
+ return;
}
try
{
- _admin->enableServer(args.front(), enable);
+ _admin->enableServer(args.front(), enable);
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -1209,12 +1209,12 @@ Parser::listAllServers()
{
try
{
- Ice::StringSeq ids = _admin->getAllServerIds();
- copy(ids.begin(), ids.end(), ostream_iterator<string>(cout,"\n"));
+ Ice::StringSeq ids = _admin->getAllServerIds();
+ copy(ids.begin(), ids.end(), ostream_iterator<string>(cout,"\n"));
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -1223,32 +1223,32 @@ Parser::endpointsAdapter(const list<string>& args)
{
if(args.size() != 1)
{
- invalidCommand("adapter endpoints", "requires exactly one argument");
- return;
+ invalidCommand("adapter endpoints", "requires exactly one argument");
+ return;
}
try
{
- string adapterId = args.front();
- AdapterInfoSeq adpts = _admin->getAdapterInfo(adapterId);
- if(adpts.size() == 1 && adpts.begin()->id == adapterId)
- {
- string endpoints = _communicator->proxyToString(adpts.begin()->proxy);
- cout << (endpoints.empty() ? string("<inactive>") : endpoints) << endl;
- }
- else
- {
- for(AdapterInfoSeq::const_iterator p = adpts.begin(); p != adpts.end(); ++p)
- {
- cout << (p->id.empty() ? string("<empty>") : p->id) << ": ";
- string endpoints = _communicator->proxyToString(p->proxy);
- cout << (endpoints.empty() ? string("<inactive>") : endpoints) << endl;
- }
- }
+ string adapterId = args.front();
+ AdapterInfoSeq adpts = _admin->getAdapterInfo(adapterId);
+ if(adpts.size() == 1 && adpts.begin()->id == adapterId)
+ {
+ string endpoints = _communicator->proxyToString(adpts.begin()->proxy);
+ cout << (endpoints.empty() ? string("<inactive>") : endpoints) << endl;
+ }
+ else
+ {
+ for(AdapterInfoSeq::const_iterator p = adpts.begin(); p != adpts.end(); ++p)
+ {
+ cout << (p->id.empty() ? string("<empty>") : p->id) << ": ";
+ string endpoints = _communicator->proxyToString(p->proxy);
+ cout << (endpoints.empty() ? string("<inactive>") : endpoints) << endl;
+ }
+ }
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -1257,17 +1257,17 @@ Parser::removeAdapter(const list<string>& args)
{
if(args.size() != 1)
{
- invalidCommand("adapter remove", "requires exactly one argument");
- return;
+ invalidCommand("adapter remove", "requires exactly one argument");
+ return;
}
try
{
- _admin->removeAdapter(*args.begin());
+ _admin->removeAdapter(*args.begin());
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -1276,12 +1276,12 @@ Parser::listAllAdapters()
{
try
{
- Ice::StringSeq ids = _admin->getAllAdapterIds();
- copy(ids.begin(), ids.end(), ostream_iterator<string>(cout,"\n"));
+ Ice::StringSeq ids = _admin->getAllAdapterIds();
+ copy(ids.begin(), ids.end(), ostream_iterator<string>(cout,"\n"));
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -1290,29 +1290,29 @@ Parser::addObject(const list<string>& args)
{
if(args.size() < 1)
{
- invalidCommand("object add", "requires at least one argument");
- return;
+ invalidCommand("object add", "requires at least one argument");
+ return;
}
try
{
- list<string>::const_iterator p = args.begin();
+ list<string>::const_iterator p = args.begin();
- string proxy = *p++;
+ string proxy = *p++;
- if(p != args.end())
- {
- string type = *p++;
- _admin->addObjectWithType(_communicator->stringToProxy(proxy), type);
- }
- else
- {
- _admin->addObject(_communicator->stringToProxy(proxy));
- }
+ if(p != args.end())
+ {
+ string type = *p++;
+ _admin->addObjectWithType(_communicator->stringToProxy(proxy), type);
+ }
+ else
+ {
+ _admin->addObject(_communicator->stringToProxy(proxy));
+ }
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -1321,17 +1321,17 @@ Parser::removeObject(const list<string>& args)
{
if(args.size() != 1)
{
- invalidCommand("object remove", "requires exactly one argument");
- return;
+ invalidCommand("object remove", "requires exactly one argument");
+ return;
}
try
{
- _admin->removeObject(_communicator->stringToIdentity((*(args.begin()))));
+ _admin->removeObject(_communicator->stringToIdentity((*(args.begin()))));
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -1340,21 +1340,21 @@ Parser::findObject(const list<string>& args)
{
if(args.size() != 1)
{
- invalidCommand("object find", "requires exactly one argument");
- return;
+ invalidCommand("object find", "requires exactly one argument");
+ return;
}
try
{
- ObjectInfoSeq objects = _admin->getObjectInfosByType(*(args.begin()));
- for(ObjectInfoSeq::const_iterator p = objects.begin(); p != objects.end(); ++p)
- {
- cout << _communicator->proxyToString(p->proxy) << endl;
- }
+ ObjectInfoSeq objects = _admin->getObjectInfosByType(*(args.begin()));
+ for(ObjectInfoSeq::const_iterator p = objects.begin(); p != objects.end(); ++p)
+ {
+ cout << _communicator->proxyToString(p->proxy) << endl;
+ }
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -1363,36 +1363,36 @@ Parser::describeObject(const list<string>& args)
{
try
{
- ObjectInfoSeq objects;
- if(args.size() == 1)
- {
- string arg = *(args.begin());
- if(arg.find('*') == string::npos)
- {
- ObjectInfo info = _admin->getObjectInfo(_communicator->stringToIdentity(arg));
- cout << "proxy = `" << _communicator->proxyToString(info.proxy) << "'" << endl;
- cout << "type = `" << info.type << "'" << endl;
- return;
- }
- else
- {
- objects = _admin->getAllObjectInfos(arg);
- }
- }
- else
- {
- objects = _admin->getAllObjectInfos("");
- }
-
- for(ObjectInfoSeq::const_iterator p = objects.begin(); p != objects.end(); ++p)
- {
- cout << "proxy = `" << _communicator->proxyToString(p->proxy) << "' type = `" << p->type << "'" << endl;
- }
-
+ ObjectInfoSeq objects;
+ if(args.size() == 1)
+ {
+ string arg = *(args.begin());
+ if(arg.find('*') == string::npos)
+ {
+ ObjectInfo info = _admin->getObjectInfo(_communicator->stringToIdentity(arg));
+ cout << "proxy = `" << _communicator->proxyToString(info.proxy) << "'" << endl;
+ cout << "type = `" << info.type << "'" << endl;
+ return;
+ }
+ else
+ {
+ objects = _admin->getAllObjectInfos(arg);
+ }
+ }
+ else
+ {
+ objects = _admin->getAllObjectInfos("");
+ }
+
+ for(ObjectInfoSeq::const_iterator p = objects.begin(); p != objects.end(); ++p)
+ {
+ cout << "proxy = `" << _communicator->proxyToString(p->proxy) << "' type = `" << p->type << "'" << endl;
+ }
+
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -1401,24 +1401,24 @@ Parser::listObject(const list<string>& args)
{
try
{
- ObjectInfoSeq objects;
- if(args.size() == 1)
- {
- objects = _admin->getAllObjectInfos(*(args.begin()));
- }
- else
- {
- objects = _admin->getAllObjectInfos("");
- }
-
- for(ObjectInfoSeq::const_iterator p = objects.begin(); p != objects.end(); ++p)
- {
- cout << _communicator->identityToString(p->proxy->ice_getIdentity()) << endl;
- }
+ ObjectInfoSeq objects;
+ if(args.size() == 1)
+ {
+ objects = _admin->getAllObjectInfos(*(args.begin()));
+ }
+ else
+ {
+ objects = _admin->getAllObjectInfos("");
+ }
+
+ for(ObjectInfoSeq::const_iterator p = objects.begin(); p != objects.end(); ++p)
+ {
+ cout << _communicator->identityToString(p->proxy->ice_getIdentity()) << endl;
+ }
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -1436,184 +1436,184 @@ Parser::showFile(const string& reader, const list<string>& origArgs)
vector<string> args;
try
{
- for(list<string>::const_iterator p = copyArgs.begin(); p != copyArgs.end(); ++p)
- {
- args.push_back(*p);
- }
- args = opts.parse(args);
+ for(list<string>::const_iterator p = copyArgs.begin(); p != copyArgs.end(); ++p)
+ {
+ args.push_back(*p);
+ }
+ args = opts.parse(args);
}
catch(const IceUtil::BadOptException& e)
{
- error(e.reason);
- return;
+ error(e.reason);
+ return;
}
if(args.size() != 2)
{
- invalidCommand(reader + " show", "requires two arguments");
- return;
+ invalidCommand(reader + " show", "requires two arguments");
+ return;
}
try
{
- vector<string>::const_iterator p = args.begin();
- string id = *p++;
- string filename = *p++;
-
- cout << reader << " `" << id << "' " << filename << ": " << flush;
- Ice::StringSeq lines;
-
- bool head = opts.isSet("head");
- bool tail = opts.isSet("tail");
- if(head && tail)
- {
- invalidCommand("can't specify both -h | --head and -t | --tail options");
- return;
- }
- int lineCount = 20;
- int maxBytes = _communicator->getProperties()->getPropertyAsIntWithDefault("Ice.MessageSizeMax", 1024) * 1024;
- if(head || tail)
- {
- if(head)
- {
- istringstream is(opts.optArg("head"));
- is >> lineCount;
- }
- else
- {
- istringstream is(opts.optArg("tail"));
- is >> lineCount;
- }
- if(lineCount <= 0)
- {
- invalidCommand("invalid argument for -h | --head or -t | --tail option");
- return;
- }
- }
-
- FileIteratorPrx it;
- if(reader == "node")
- {
- if(filename == "stderr")
- {
- it = _session->openNodeStdErr(id, tail ? lineCount : -1);
- }
- else if(filename == "stdout")
- {
- it = _session->openNodeStdOut(id, tail ? lineCount : -1);
- }
- else
- {
- invalidCommand("invalid node log filename `" + filename + "'");
- return;
- }
- }
- else if(reader == "registry")
- {
- if(filename == "stderr")
- {
- it = _session->openRegistryStdErr(id, tail ? lineCount : -1);
- }
- else if(filename == "stdout")
- {
- it = _session->openRegistryStdOut(id, tail ? lineCount : -1);
- }
- else
- {
- invalidCommand("invalid registry log filename `" + filename + "'");
- return;
- }
- }
- else if(reader == "server")
- {
- if(filename == "stderr")
- {
- it = _session->openServerStdErr(id, tail ? lineCount : -1);
- }
- else if(filename == "stdout")
- {
- it = _session->openServerStdOut(id, tail ? lineCount : -1);
- }
- else
- {
- it = _session->openServerLog(id, filename, tail ? lineCount : -1);
- }
- }
-
- bool follow = opts.isSet("follow");
- resetInterrupt();
- if(head)
- {
- if(follow)
- {
- invalidCommand("can't use -f | --follow option with -h | --head option");
- return;
- }
-
- int i = 0;
- bool eof = false;
- while(!interrupted() && !eof && i < lineCount)
- {
- eof = it->read(maxBytes, lines);
- for(Ice::StringSeq::const_iterator p = lines.begin(); i < lineCount && p != lines.end(); ++p, ++i)
- {
- cout << endl << *p << flush;
- }
- }
- }
- else
- {
- bool eof = false;
- while(!interrupted() && !eof)
- {
- eof = it->read(maxBytes, lines);
- for(Ice::StringSeq::const_iterator p = lines.begin(); p != lines.end(); ++p)
- {
- cout << endl << *p << flush;
- }
- }
- }
-
- if(follow)
- {
- while(!interrupted())
- {
- bool eof = it->read(maxBytes, lines);
- for(Ice::StringSeq::const_iterator p = lines.begin(); p != lines.end(); ++p)
- {
- cout << *p;
- if((p + 1) != lines.end())
- {
- cout << endl;
- }
- else
- {
- cout << flush;
- }
- }
-
- if(eof)
- {
- Lock sync(*this);
- if(_interrupted)
- {
- break;
- }
- timedWait(IceUtil::Time::seconds(5));
- }
- }
- }
-
- if(lines.empty() || !lines.back().empty())
- {
- cout << endl;
- }
-
- it->destroy();
+ vector<string>::const_iterator p = args.begin();
+ string id = *p++;
+ string filename = *p++;
+
+ cout << reader << " `" << id << "' " << filename << ": " << flush;
+ Ice::StringSeq lines;
+
+ bool head = opts.isSet("head");
+ bool tail = opts.isSet("tail");
+ if(head && tail)
+ {
+ invalidCommand("can't specify both -h | --head and -t | --tail options");
+ return;
+ }
+ int lineCount = 20;
+ int maxBytes = _communicator->getProperties()->getPropertyAsIntWithDefault("Ice.MessageSizeMax", 1024) * 1024;
+ if(head || tail)
+ {
+ if(head)
+ {
+ istringstream is(opts.optArg("head"));
+ is >> lineCount;
+ }
+ else
+ {
+ istringstream is(opts.optArg("tail"));
+ is >> lineCount;
+ }
+ if(lineCount <= 0)
+ {
+ invalidCommand("invalid argument for -h | --head or -t | --tail option");
+ return;
+ }
+ }
+
+ FileIteratorPrx it;
+ if(reader == "node")
+ {
+ if(filename == "stderr")
+ {
+ it = _session->openNodeStdErr(id, tail ? lineCount : -1);
+ }
+ else if(filename == "stdout")
+ {
+ it = _session->openNodeStdOut(id, tail ? lineCount : -1);
+ }
+ else
+ {
+ invalidCommand("invalid node log filename `" + filename + "'");
+ return;
+ }
+ }
+ else if(reader == "registry")
+ {
+ if(filename == "stderr")
+ {
+ it = _session->openRegistryStdErr(id, tail ? lineCount : -1);
+ }
+ else if(filename == "stdout")
+ {
+ it = _session->openRegistryStdOut(id, tail ? lineCount : -1);
+ }
+ else
+ {
+ invalidCommand("invalid registry log filename `" + filename + "'");
+ return;
+ }
+ }
+ else if(reader == "server")
+ {
+ if(filename == "stderr")
+ {
+ it = _session->openServerStdErr(id, tail ? lineCount : -1);
+ }
+ else if(filename == "stdout")
+ {
+ it = _session->openServerStdOut(id, tail ? lineCount : -1);
+ }
+ else
+ {
+ it = _session->openServerLog(id, filename, tail ? lineCount : -1);
+ }
+ }
+
+ bool follow = opts.isSet("follow");
+ resetInterrupt();
+ if(head)
+ {
+ if(follow)
+ {
+ invalidCommand("can't use -f | --follow option with -h | --head option");
+ return;
+ }
+
+ int i = 0;
+ bool eof = false;
+ while(!interrupted() && !eof && i < lineCount)
+ {
+ eof = it->read(maxBytes, lines);
+ for(Ice::StringSeq::const_iterator p = lines.begin(); i < lineCount && p != lines.end(); ++p, ++i)
+ {
+ cout << endl << *p << flush;
+ }
+ }
+ }
+ else
+ {
+ bool eof = false;
+ while(!interrupted() && !eof)
+ {
+ eof = it->read(maxBytes, lines);
+ for(Ice::StringSeq::const_iterator p = lines.begin(); p != lines.end(); ++p)
+ {
+ cout << endl << *p << flush;
+ }
+ }
+ }
+
+ if(follow)
+ {
+ while(!interrupted())
+ {
+ bool eof = it->read(maxBytes, lines);
+ for(Ice::StringSeq::const_iterator p = lines.begin(); p != lines.end(); ++p)
+ {
+ cout << *p;
+ if((p + 1) != lines.end())
+ {
+ cout << endl;
+ }
+ else
+ {
+ cout << flush;
+ }
+ }
+
+ if(eof)
+ {
+ Lock sync(*this);
+ if(_interrupted)
+ {
+ break;
+ }
+ timedWait(IceUtil::Time::seconds(5));
+ }
+ }
+ }
+
+ if(lines.empty() || !lines.back().empty())
+ {
+ cout << endl;
+ }
+
+ it->destroy();
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -1640,104 +1640,104 @@ Parser::getInput(char* buf, int& result, int maxSize)
{
if(!_commands.empty())
{
- if(_commands == ";")
- {
- result = 0;
- }
- else
- {
+ if(_commands == ";")
+ {
+ result = 0;
+ }
+ else
+ {
#if defined(_MSC_VER) && !defined(_STLP_MSVC)
- // COMPILERBUG: Stupid Visual C++ defines min and max as macros
- result = _MIN(maxSize, static_cast<int>(_commands.length()));
+ // COMPILERBUG: Stupid Visual C++ defines min and max as macros
+ result = _MIN(maxSize, static_cast<int>(_commands.length()));
#else
- result = min(maxSize, static_cast<int>(_commands.length()));
+ result = min(maxSize, static_cast<int>(_commands.length()));
#endif
- strncpy(buf, _commands.c_str(), result);
- _commands.erase(0, result);
- if(_commands.empty())
- {
- _commands = ";";
- }
- }
+ strncpy(buf, _commands.c_str(), result);
+ _commands.erase(0, result);
+ if(_commands.empty())
+ {
+ _commands = ";";
+ }
+ }
}
else if(isatty(fileno(yyin)))
{
#ifdef HAVE_READLINE
const char* prompt = parser->getPrompt();
- char* line = readline(const_cast<char*>(prompt));
- if(!line)
- {
- result = 0;
- }
- else
- {
- if(*line)
- {
- add_history(line);
- }
-
- result = strlen(line) + 1;
- if(result > maxSize)
- {
- free(line);
- error("input line too long");
- result = 0;
- }
- else
- {
- strcpy(buf, line);
- strcat(buf, "\n");
- free(line);
- }
- }
+ char* line = readline(const_cast<char*>(prompt));
+ if(!line)
+ {
+ result = 0;
+ }
+ else
+ {
+ if(*line)
+ {
+ add_history(line);
+ }
+
+ result = strlen(line) + 1;
+ if(result > maxSize)
+ {
+ free(line);
+ error("input line too long");
+ result = 0;
+ }
+ else
+ {
+ strcpy(buf, line);
+ strcat(buf, "\n");
+ free(line);
+ }
+ }
#else
- cout << parser->getPrompt() << flush;
-
- string line;
- while(true)
- {
- char c = static_cast<char>(getc(yyin));
- if(c == EOF)
- {
- if(line.size())
- {
- line += '\n';
- }
- break;
- }
- line += c;
-
- if(c == '\n')
- {
- break;
- }
- }
-
- result = (int) line.length();
- if(result > maxSize)
- {
- error("input line too long");
- buf[0] = EOF;
- result = 1;
- }
- else
- {
- strcpy(buf, line.c_str());
- }
+ cout << parser->getPrompt() << flush;
+
+ string line;
+ while(true)
+ {
+ char c = static_cast<char>(getc(yyin));
+ if(c == EOF)
+ {
+ if(line.size())
+ {
+ line += '\n';
+ }
+ break;
+ }
+ line += c;
+
+ if(c == '\n')
+ {
+ break;
+ }
+ }
+
+ result = (int) line.length();
+ if(result > maxSize)
+ {
+ error("input line too long");
+ buf[0] = EOF;
+ result = 1;
+ }
+ else
+ {
+ strcpy(buf, line.c_str());
+ }
#endif
}
else
{
- if(((result = (int) fread(buf, 1, maxSize, yyin)) == 0) && ferror(yyin))
- {
- error("input in flex scanner failed");
- buf[0] = EOF;
- result = 1;
- }
+ if(((result = (int) fread(buf, 1, maxSize, yyin)) == 0) && ferror(yyin))
+ {
+ error("input in flex scanner failed");
+ buf[0] = EOF;
+ result = 1;
+ }
}
}
@@ -1760,12 +1760,12 @@ Parser::getPrompt()
if(_continue)
{
- _continue = false;
- return "(cont) ";
+ _continue = false;
+ return "(cont) ";
}
else
{
- return ">>> ";
+ return ">>> ";
}
}
@@ -1778,13 +1778,13 @@ Parser::scanPosition(const char* s)
idx = line.find("line");
if(idx != string::npos)
{
- line.erase(0, idx + 4);
+ line.erase(0, idx + 4);
}
idx = line.find_first_not_of(" \t\r#");
if(idx != string::npos)
{
- line.erase(0, idx);
+ line.erase(0, idx);
}
_currentLine = atoi(line.c_str()) - 1;
@@ -1792,24 +1792,24 @@ Parser::scanPosition(const char* s)
idx = line.find_first_of(" \t\r");
if(idx != string::npos)
{
- line.erase(0, idx);
+ line.erase(0, idx);
}
idx = line.find_first_not_of(" \t\r\"");
if(idx != string::npos)
{
- line.erase(0, idx);
+ line.erase(0, idx);
- idx = line.find_first_of(" \t\r\"");
- if(idx != string::npos)
- {
- _currentFile = line.substr(0, idx);
- line.erase(0, idx + 1);
- }
- else
- {
- _currentFile = line;
- }
+ idx = line.find_first_of(" \t\r\"");
+ if(idx != string::npos)
+ {
+ _currentFile = line.substr(0, idx);
+ line.erase(0, idx + 1);
+ }
+ else
+ {
+ _currentFile = line;
+ }
}
}
@@ -1840,31 +1840,31 @@ Parser::patchFailed(const Ice::StringSeq& reasons)
out << "the patch failed on some nodes:\n";
for(Ice::StringSeq::const_iterator p = reasons.begin(); p != reasons.end(); ++p)
{
- string reason = *p;
- string::size_type beg = 0;
- string::size_type end = reason.find_first_of("\n");
- if(end == string::npos)
- {
- end = reason.size();
- }
- out << "- " << reason.substr(beg, end - beg);
- out.inc();
- while(end < reason.size())
- {
- beg = end + 1;
- end = reason.find_first_of("\n", beg);
- if(end == string::npos)
- {
- end = reason.size();
- }
- out.newline();
- out << reason.substr(beg, end - beg);
- }
- out.dec();
- if(p + 1 != reasons.end())
- {
- out.newline();
- }
+ string reason = *p;
+ string::size_type beg = 0;
+ string::size_type end = reason.find_first_of("\n");
+ if(end == string::npos)
+ {
+ end = reason.size();
+ }
+ out << "- " << reason.substr(beg, end - beg);
+ out.inc();
+ while(end < reason.size())
+ {
+ beg = end + 1;
+ end = reason.find_first_of("\n", beg);
+ if(end == string::npos)
+ {
+ end = reason.size();
+ }
+ out.newline();
+ out << reason.substr(beg, end - beg);
+ }
+ out.dec();
+ if(p + 1 != reasons.end())
+ {
+ out.newline();
+ }
}
warning(os.str());
}
@@ -1874,11 +1874,11 @@ Parser::error(const char* s)
{
if(_commands.empty() && !isatty(fileno(yyin)))
{
- cerr << _currentFile << ':' << _currentLine << ": " << s << endl;
+ cerr << _currentFile << ':' << _currentLine << ": " << s << endl;
}
else
{
- cerr << "error: " << s << endl;
+ cerr << "error: " << s << endl;
}
_errors++;
}
@@ -1894,11 +1894,11 @@ Parser::warning(const char* s)
{
if(_commands.empty() && !isatty(fileno(yyin)))
{
- cerr << _currentFile << ':' << _currentLine << ": warning: " << s << endl;
+ cerr << _currentFile << ':' << _currentLine << ": warning: " << s << endl;
}
else
{
- cerr << "warning: " << s << endl;
+ cerr << "warning: " << s << endl;
}
}
@@ -1929,7 +1929,7 @@ Parser::parse(FILE* file, bool debug)
int status = yyparse();
if(_errors)
{
- status = EXIT_FAILURE;
+ status = EXIT_FAILURE;
}
parser = 0;
@@ -1957,7 +1957,7 @@ Parser::parse(const std::string& commands, bool debug)
int status = yyparse();
if(_errors)
{
- status = EXIT_FAILURE;
+ status = EXIT_FAILURE;
}
parser = 0;
@@ -1965,9 +1965,9 @@ Parser::parse(const std::string& commands, bool debug)
}
Parser::Parser(const CommunicatorPtr& communicator,
- const AdminSessionPrx& session,
- const AdminPrx& admin,
- bool interactive) :
+ const AdminSessionPrx& session,
+ const AdminPrx& admin,
+ bool interactive) :
_communicator(communicator),
_session(session),
_admin(admin),
@@ -1976,11 +1976,11 @@ Parser::Parser(const CommunicatorPtr& communicator,
{
for(int i = 0; _commandsHelp[i][0]; i++)
{
- const string category = _commandsHelp[i][0];
- const string cmd = _commandsHelp[i][1];
- const string help = _commandsHelp[i][2];
- _helpCommands[category][""] += help;
- _helpCommands[category][cmd] += help;
+ const string category = _commandsHelp[i][0];
+ const string cmd = _commandsHelp[i][1];
+ const string help = _commandsHelp[i][2];
+ _helpCommands[category][""] += help;
+ _helpCommands[category][cmd] += help;
}
}
@@ -1989,81 +1989,81 @@ Parser::exception(const Ice::Exception& ex)
{
try
{
- ex.ice_throw();
+ ex.ice_throw();
}
catch(const ApplicationNotExistException& ex)
{
- error("couldn't find application `" + ex.name + "'");
+ error("couldn't find application `" + ex.name + "'");
}
catch(const NodeNotExistException& ex)
{
- error("couldn't find node `" + ex.name + "'");
+ error("couldn't find node `" + ex.name + "'");
}
catch(const ServerNotExistException& ex)
{
- error("couldn't find server `" + ex.id + "'");
+ error("couldn't find server `" + ex.id + "'");
}
catch(const AdapterNotExistException& ex)
{
- error("couldn't find adapter `" + ex.id + "'");
+ error("couldn't find adapter `" + ex.id + "'");
}
catch(const ObjectExistsException& ex)
{
- error("object `" + _communicator->identityToString(ex.id) + "' already exists");
+ error("object `" + _communicator->identityToString(ex.id) + "' already exists");
}
catch(const DeploymentException& ex)
{
- ostringstream s;
- s << ex << ":\n" << ex.reason;
- error(s.str());
+ ostringstream s;
+ s << ex << ":\n" << ex.reason;
+ error(s.str());
}
catch(const PatchException& ex)
{
- if(ex.reasons.size() == 1)
- {
- ostringstream s;
- s << ex << ":\n" << ex.reasons[0];
- error(s.str());
- }
- else
- {
- patchFailed(ex.reasons);
- }
+ if(ex.reasons.size() == 1)
+ {
+ ostringstream s;
+ s << ex << ":\n" << ex.reasons[0];
+ error(s.str());
+ }
+ else
+ {
+ patchFailed(ex.reasons);
+ }
}
catch(const BadSignalException& ex)
{
- ostringstream s;
- s << ex.reason;
- error(s.str());
+ ostringstream s;
+ s << ex.reason;
+ error(s.str());
}
catch(const NodeUnreachableException& ex)
{
- error("node `" + ex.name + "' couldn't be reached:\n" + ex.reason);
+ error("node `" + ex.name + "' couldn't be reached:\n" + ex.reason);
}
catch(const AccessDeniedException& ex)
{
- error("couldn't update the registry, the session from `" + ex.lockUserId + "' is updating the registry");
+ error("couldn't update the registry, the session from `" + ex.lockUserId + "' is updating the registry");
}
catch(const FileNotAvailableException& ex)
{
- error("couldn't access file:\n" + ex.reason);
+ error("couldn't access file:\n" + ex.reason);
}
catch(const IceXML::ParserException& ex)
{
- ostringstream s;
- s << ex;
- error(s.str());
+ ostringstream s;
+ s << ex;
+ error(s.str());
}
catch(const Ice::LocalException& ex)
{
- ostringstream s;
- s << "couldn't reach the IceGrid registry:\n" << ex;
- error(s.str());
+ ostringstream s;
+ s << "couldn't reach the IceGrid registry:\n" << ex;
+ error(s.str());
}
catch(const Ice::Exception& ex)
{
- ostringstream s;
- s << ex;
- error(s.str());
+ ostringstream s;
+ s << ex;
+ error(s.str());
}
}
diff --git a/cpp/src/IceGrid/PlatformInfo.cpp b/cpp/src/IceGrid/PlatformInfo.cpp
index e9245b89527..ff7ccf65a3c 100644
--- a/cpp/src/IceGrid/PlatformInfo.cpp
+++ b/cpp/src/IceGrid/PlatformInfo.cpp
@@ -50,7 +50,7 @@ getLocalizedPerfName(const map<string, string>& perfNames, const string& name)
map<string, string>::const_iterator p = perfNames.find(name);
if(p == perfNames.end())
{
- return "";
+ return "";
}
istringstream is(p->second);
is >> idx;
@@ -60,8 +60,8 @@ getLocalizedPerfName(const map<string, string>& perfNames, const string& name)
localized.resize(size);
while(PdhLookupPerfNameByIndex(0, idx, &localized[0], &size) == PDH_MORE_DATA)
{
- size += 256;
- localized.resize(size);
+ size += 256;
+ localized.resize(size);
}
return string(&localized[0]);
}
@@ -94,8 +94,8 @@ toNodeInfo(const InternalNodeInfoPtr& node)
}
PlatformInfo::PlatformInfo(const string& prefix,
- const Ice::CommunicatorPtr& communicator,
- const TraceLevelsPtr& traceLevels) :
+ const Ice::CommunicatorPtr& communicator,
+ const TraceLevelsPtr& traceLevels) :
_traceLevels(traceLevels)
{
//
@@ -125,18 +125,18 @@ PlatformInfo::PlatformInfo(const string& prefix,
nl.n_value = 0;
if(knlist(&nl, 1, sizeof(nl)) == 0)
{
- _kmem = open("/dev/kmem", O_RDONLY);
+ _kmem = open("/dev/kmem", O_RDONLY);
- //
- // Give up root permissions to minimize security risks, it's
- // only needed to access /dev/kmem.
- //
+ //
+ // Give up root permissions to minimize security risks, it's
+ // only needed to access /dev/kmem.
+ //
setuid(getuid());
setgid(getgid());
}
else
{
- _kmem = -1;
+ _kmem = -1;
}
#endif
@@ -152,9 +152,9 @@ PlatformInfo::PlatformInfo(const string& prefix,
size_t sz = sizeof(_nProcessors);
if(sysctl(ncpu, 2, &_nProcessors, &sz, 0, 0) == -1)
{
- Ice::SyscallException ex(__FILE__, __LINE__);
- ex.error = getSystemErrno();
- throw ex;
+ Ice::SyscallException ex(__FILE__, __LINE__);
+ ex.error = getSystemErrno();
+ throw ex;
}
#elif defined(__hpux)
struct pst_dynamic dynInfo;
@@ -179,7 +179,7 @@ PlatformInfo::PlatformInfo(const string& prefix,
unsigned long size = sizeof(hostname);
if(GetComputerName(hostname, &size))
{
- _hostname = hostname;
+ _hostname = hostname;
}
OSVERSIONINFO osInfo;
osInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
@@ -196,17 +196,17 @@ PlatformInfo::PlatformInfo(const string& prefix,
#else
case PROCESSOR_ARCHITECTURE_AMD64:
#endif
- _machine = "x64";
- break;
+ _machine = "x64";
+ break;
case PROCESSOR_ARCHITECTURE_IA64:
- _machine = "IA64";
- break;
+ _machine = "IA64";
+ break;
case PROCESSOR_ARCHITECTURE_INTEL:
- _machine = "x86";
- break;
+ _machine = "x86";
+ break;
default:
- _machine = "unknown";
- break;
+ _machine = "unknown";
+ break;
};
#else
struct utsname utsinfo;
@@ -226,15 +226,15 @@ PlatformInfo::PlatformInfo(const string& prefix,
string oldEndpointsPrefix;
if(prefix == "IceGrid.Registry")
{
- _name = properties->getPropertyWithDefault("IceGrid.Registry.ReplicaName", "Master");
- endpointsPrefix = "Ice.OA." + prefix + ".Client";
- oldEndpointsPrefix = prefix + ".Client";
+ _name = properties->getPropertyWithDefault("IceGrid.Registry.ReplicaName", "Master");
+ endpointsPrefix = "Ice.OA." + prefix + ".Client";
+ oldEndpointsPrefix = prefix + ".Client";
}
else
{
- _name = properties->getProperty(prefix + ".Name");
- endpointsPrefix = "Ice.OA." + prefix;
- oldEndpointsPrefix = prefix;
+ _name = properties->getProperty(prefix + ".Name");
+ endpointsPrefix = "Ice.OA." + prefix;
+ oldEndpointsPrefix = prefix;
}
Ice::PropertyDict props = properties->getPropertiesForPrefix(endpointsPrefix);
@@ -254,7 +254,7 @@ PlatformInfo::PlatformInfo(const string& prefix,
else
{
_endpoints = properties->getPropertyWithDefault(
- endpointsPrefix + ".Endpoints", properties->getProperty(oldEndpointsPrefix + ".Endpoints"));
+ endpointsPrefix + ".Endpoints", properties->getProperty(oldEndpointsPrefix + ".Endpoints"));
}
}
@@ -262,7 +262,7 @@ PlatformInfo::PlatformInfo(const string& prefix,
char cwd[_MAX_PATH];
if(_getcwd(cwd, _MAX_PATH) == NULL)
#else
- char cwd[PATH_MAX];
+ char cwd[PATH_MAX];
if(getcwd(cwd, PATH_MAX) == NULL)
#endif
{
@@ -273,11 +273,11 @@ PlatformInfo::PlatformInfo(const string& prefix,
_dataDir = properties->getProperty(prefix + ".Data");
if(!IcePatch2::isAbsolute(_dataDir))
{
- _dataDir = _cwd + '/' + _dataDir;
+ _dataDir = _cwd + '/' + _dataDir;
}
if(_dataDir[_dataDir.length() - 1] == '/')
{
- _dataDir = _dataDir.substr(0, _dataDir.length() - 1);
+ _dataDir = _dataDir.substr(0, _dataDir.length() - 1);
}
}
@@ -286,12 +286,12 @@ PlatformInfo::~PlatformInfo()
#ifdef _WIN32
if(_query != NULL)
{
- PdhCloseQuery(_query);
+ PdhCloseQuery(_query);
}
#elif defined(_AIX)
if(_kmem > 0)
{
- close(_kmem);
+ close(_kmem);
}
#endif
}
@@ -344,14 +344,14 @@ PlatformInfo::getLoadInfo()
int usage = 100;
if(_query == NULL)
{
- initQuery();
+ initQuery();
}
if(_query != NULL && _counter != NULL && PdhCollectQueryData(_query) == ERROR_SUCCESS)
{
- DWORD type;
- PDH_FMT_COUNTERVALUE value;
- PdhGetFormattedCounterValue(_counter, PDH_FMT_LONG, &type, &value);
- usage = static_cast<int>(value.longValue);
+ DWORD type;
+ PDH_FMT_COUNTERVALUE value;
+ PdhGetFormattedCounterValue(_counter, PDH_FMT_LONG, &type, &value);
+ usage = static_cast<int>(value.longValue);
}
_last1Total += usage - _usages1.back();
@@ -377,34 +377,34 @@ PlatformInfo::getLoadInfo()
double loadAvg[3];
if(getloadavg(loadAvg, 3) != -1)
{
- info.avg1 = static_cast<float>(loadAvg[0]);
- info.avg5 = static_cast<float>(loadAvg[1]);
- info.avg15 = static_cast<float>(loadAvg[2]);
+ info.avg1 = static_cast<float>(loadAvg[0]);
+ info.avg5 = static_cast<float>(loadAvg[1]);
+ info.avg15 = static_cast<float>(loadAvg[2]);
}
#elif defined(__hpux)
struct pst_dynamic dynInfo;
if(pstat_getdynamic(&dynInfo, sizeof(dynInfo), 1, 0) >= 0)
{
- info.avg1 = dynInfo.psd_avg_1_min;
- info.avg5 = dynInfo.psd_avg_5_min;
- info.avg15 = dynInfo.psd_avg_15_min;
+ info.avg1 = dynInfo.psd_avg_1_min;
+ info.avg5 = dynInfo.psd_avg_5_min;
+ info.avg15 = dynInfo.psd_avg_15_min;
}
#elif defined(_AIX)
if(_kmem > 1)
{
- long long avenrun[3];
- struct nlist nl;
- nl.n_name = "avenrun";
- nl.n_value = 0;
- if(knlist(&nl, 1, sizeof(nl)) == 0)
- {
- if(pread(_kmem, avenrun, sizeof(avenrun), nl.n_value) >= sizeof(avenrun))
- {
- info.avg1 = avenrun[0] / 65536.0f;
- info.avg5 = avenrun[1] / 65536.0f;
- info.avg15 = avenrun[2] / 65536.0f;
- }
- }
+ long long avenrun[3];
+ struct nlist nl;
+ nl.n_name = "avenrun";
+ nl.n_value = 0;
+ if(knlist(&nl, 1, sizeof(nl)) == 0)
+ {
+ if(pread(_kmem, avenrun, sizeof(avenrun), nl.n_value) >= sizeof(avenrun))
+ {
+ info.avg1 = avenrun[0] / 65536.0f;
+ info.avg5 = avenrun[1] / 65536.0f;
+ info.avg15 = avenrun[2] / 65536.0f;
+ }
+ }
}
#endif
return info;
@@ -438,11 +438,11 @@ PlatformInfo::initQuery()
PDH_STATUS err = PdhOpenQuery(0, 0, &_query);
if(err != ERROR_SUCCESS)
{
- Ice::SyscallException ex(__FILE__, __LINE__);
- ex.error = err;
- Ice::Warning out(_traceLevels->logger);
- out << "can't open performance data query:\n" << ex;
- return;
+ Ice::SyscallException ex(__FILE__, __LINE__);
+ ex.error = err;
+ Ice::Warning out(_traceLevels->logger);
+ out << "can't open performance data query:\n" << ex;
+ return;
}
//
@@ -453,8 +453,8 @@ PlatformInfo::initQuery()
buffer.resize(size);
while(RegQueryValueEx(HKEY_PERFORMANCE_DATA, "Counter 09", 0, 0, &buffer[0], &size) == ERROR_MORE_DATA)
{
- size += 8192;
- buffer.resize(size);
+ size += 8192;
+ buffer.resize(size);
}
map<string, string> perfNames;
@@ -462,15 +462,15 @@ PlatformInfo::initQuery()
unsigned int i = 0;
while(i < buffer.size() && buf[i])
{
- string index(&buf[i]);
- i += static_cast<int>(index.size()) + 1;
- if(i >= buffer.size())
- {
- break;
- }
- string name(&buf[i]);
- i += static_cast<int>(name.size()) + 1;
- perfNames.insert(make_pair(name, index));
+ string index(&buf[i]);
+ i += static_cast<int>(index.size()) + 1;
+ if(i >= buffer.size())
+ {
+ break;
+ }
+ string name(&buf[i]);
+ i += static_cast<int>(name.size()) + 1;
+ perfNames.insert(make_pair(name, index));
}
//
@@ -486,10 +486,10 @@ PlatformInfo::initQuery()
err = PdhAddCounter(_query, name.c_str(), 0, &_counter);
if(err != ERROR_SUCCESS)
{
- Ice::SyscallException ex(__FILE__, __LINE__);
- ex.error = err;
- Ice::Warning out(_traceLevels->logger);
- out << "can't add performance counter `" << name << "':\n" << ex;
+ Ice::SyscallException ex(__FILE__, __LINE__);
+ ex.error = err;
+ Ice::Warning out(_traceLevels->logger);
+ out << "can't add performance counter `" << name << "':\n" << ex;
}
}
#endif
diff --git a/cpp/src/IceGrid/QueryI.cpp b/cpp/src/IceGrid/QueryI.cpp
index 187b6c1339f..3d5cddf03ea 100644
--- a/cpp/src/IceGrid/QueryI.cpp
+++ b/cpp/src/IceGrid/QueryI.cpp
@@ -30,11 +30,11 @@ QueryI::findObjectById(const Ice::Identity& id, const Ice::Current&) const
{
try
{
- return _database->getObjectProxy(id);
+ return _database->getObjectProxy(id);
}
catch(const ObjectNotRegisteredException&)
{
- return 0;
+ return 0;
}
}
@@ -62,28 +62,28 @@ QueryI::findAllReplicas(const Ice::ObjectPrx& proxy, const Ice::Current&) const
{
try
{
- if(!proxy)
- {
- return Ice::ObjectProxySeq();
- }
+ if(!proxy)
+ {
+ return Ice::ObjectProxySeq();
+ }
- AdapterInfoSeq infos = _database->getAdapterInfo(proxy->ice_getAdapterId());
- assert(!infos.empty());
- if(infos[0].replicaGroupId != proxy->ice_getAdapterId()) // The adapter id doesn't refer to a replica group.
- {
- return Ice::ObjectProxySeq();
- }
+ AdapterInfoSeq infos = _database->getAdapterInfo(proxy->ice_getAdapterId());
+ assert(!infos.empty());
+ if(infos[0].replicaGroupId != proxy->ice_getAdapterId()) // The adapter id doesn't refer to a replica group.
+ {
+ return Ice::ObjectProxySeq();
+ }
- Ice::ObjectProxySeq proxies;
- for(AdapterInfoSeq::const_iterator p = infos.begin(); p != infos.end(); ++p)
- {
- assert(!p->id.empty());
- proxies.push_back(proxy->ice_adapterId(p->id));
- }
- return proxies;
+ Ice::ObjectProxySeq proxies;
+ for(AdapterInfoSeq::const_iterator p = infos.begin(); p != infos.end(); ++p)
+ {
+ assert(!p->id.empty());
+ proxies.push_back(proxy->ice_adapterId(p->id));
+ }
+ return proxies;
}
catch(const AdapterNotExistException&)
{
- return Ice::ObjectProxySeq();
+ return Ice::ObjectProxySeq();
}
}
diff --git a/cpp/src/IceGrid/QueryI.h b/cpp/src/IceGrid/QueryI.h
index 58fb86c182b..37a6ea87df3 100644
--- a/cpp/src/IceGrid/QueryI.h
+++ b/cpp/src/IceGrid/QueryI.h
@@ -31,7 +31,7 @@ public:
virtual Ice::ObjectPrx findObjectByType(const ::std::string&, const ::Ice::Current&) const;
virtual Ice::ObjectPrx findObjectByTypeOnLeastLoadedNode(const ::std::string&, LoadSample,
- const ::Ice::Current&) const;
+ const ::Ice::Current&) const;
virtual Ice::ObjectProxySeq findAllObjectsByType(const ::std::string&, const ::Ice::Current&) const;
diff --git a/cpp/src/IceGrid/ReapThread.cpp b/cpp/src/IceGrid/ReapThread.cpp
index e781683bd41..06869232b6e 100644
--- a/cpp/src/IceGrid/ReapThread.cpp
+++ b/cpp/src/IceGrid/ReapThread.cpp
@@ -24,61 +24,61 @@ ReapThread::run()
vector<ReapableItem> reap;
while(true)
{
- {
- Lock sync(*this);
- if(_terminated)
- {
- break;
- }
-
- calcWakeInterval();
-
- //
- // If the wake interval is zero then we wait forever.
- //
- if(_wakeInterval == IceUtil::Time())
- {
- assert(_sessions.empty());
- wait();
- }
- else
- {
- assert(!_sessions.empty());
- timedWait(_wakeInterval);
- }
-
- if(_terminated)
- {
- break;
- }
-
- list<ReapableItem>::iterator p = _sessions.begin();
- while(p != _sessions.end())
- {
- try
- {
- if((IceUtil::Time::now() - p->item->timestamp()) > p->timeout)
- {
- reap.push_back(*p);
- p = _sessions.erase(p);
- }
- else
- {
- ++p;
- }
- }
- catch(const Ice::ObjectNotExistException&)
- {
- p = _sessions.erase(p);
- }
- }
- }
-
- for(vector<ReapableItem>::const_iterator p = reap.begin(); p != reap.end(); ++p)
- {
- p->item->destroy(false);
- }
- reap.clear();
+ {
+ Lock sync(*this);
+ if(_terminated)
+ {
+ break;
+ }
+
+ calcWakeInterval();
+
+ //
+ // If the wake interval is zero then we wait forever.
+ //
+ if(_wakeInterval == IceUtil::Time())
+ {
+ assert(_sessions.empty());
+ wait();
+ }
+ else
+ {
+ assert(!_sessions.empty());
+ timedWait(_wakeInterval);
+ }
+
+ if(_terminated)
+ {
+ break;
+ }
+
+ list<ReapableItem>::iterator p = _sessions.begin();
+ while(p != _sessions.end())
+ {
+ try
+ {
+ if((IceUtil::Time::now() - p->item->timestamp()) > p->timeout)
+ {
+ reap.push_back(*p);
+ p = _sessions.erase(p);
+ }
+ else
+ {
+ ++p;
+ }
+ }
+ catch(const Ice::ObjectNotExistException&)
+ {
+ p = _sessions.erase(p);
+ }
+ }
+ }
+
+ for(vector<ReapableItem>::const_iterator p = reap.begin(); p != reap.end(); ++p)
+ {
+ p->item->destroy(false);
+ }
+ reap.clear();
}
}
@@ -87,20 +87,20 @@ ReapThread::terminate()
{
list<ReapableItem> reap;
{
- Lock sync(*this);
- if(_terminated)
- {
- assert(_sessions.empty());
- return;
- }
- _terminated = true;
- notify();
- reap.swap(_sessions);
+ Lock sync(*this);
+ if(_terminated)
+ {
+ assert(_sessions.empty());
+ return;
+ }
+ _terminated = true;
+ notify();
+ reap.swap(_sessions);
}
for(list<ReapableItem>::iterator p = reap.begin(); p != reap.end(); ++p)
{
- p->item->destroy(true);
+ p->item->destroy(true);
}
}
@@ -110,7 +110,7 @@ ReapThread::add(const ReapablePtr& reapable, int timeout)
Lock sync(*this);
if(_terminated)
{
- return;
+ return;
}
//
@@ -118,7 +118,7 @@ ReapThread::add(const ReapablePtr& reapable, int timeout)
//
if(timeout < 10)
{
- timeout = 10;
+ timeout = 10;
}
ReapableItem item;
@@ -132,7 +132,7 @@ ReapThread::add(const ReapablePtr& reapable, int timeout)
//
if(calcWakeInterval())
{
- notify();
+ notify();
}
//
@@ -154,11 +154,11 @@ ReapThread::calcWakeInterval()
bool first = true;
for(list<ReapableItem>::const_iterator p = _sessions.begin(); p != _sessions.end(); ++p)
{
- if(first || p->timeout < minimum)
- {
- minimum = p->timeout;
- first = false;
- }
+ if(first || p->timeout < minimum)
+ {
+ minimum = p->timeout;
+ first = false;
+ }
}
_wakeInterval = minimum;
diff --git a/cpp/src/IceGrid/ReapThread.h b/cpp/src/IceGrid/ReapThread.h
index 317624fcba5..88729d500ac 100644
--- a/cpp/src/IceGrid/ReapThread.h
+++ b/cpp/src/IceGrid/ReapThread.h
@@ -43,42 +43,42 @@ class SessionReapable : public Reapable
public:
SessionReapable(const Ice::LoggerPtr& logger, const TPtr& session) :
- _logger(logger), _session(session)
+ _logger(logger), _session(session)
{
}
virtual ~SessionReapable()
{
}
-
+
virtual IceUtil::Time
timestamp() const
{
- return _session->timestamp();
+ return _session->timestamp();
}
virtual void
destroy(bool shutdown)
{
- try
- {
- if(shutdown)
- {
- _session->shutdown();
- }
- else
- {
- _session->destroy(Ice::Current());
- }
- }
- catch(const Ice::ObjectNotExistException&)
- {
- }
- catch(const Ice::LocalException& ex)
- {
- Ice::Warning out(_logger);
- out << "unexpected exception while reaping session:\n" << ex;
- }
+ try
+ {
+ if(shutdown)
+ {
+ _session->shutdown();
+ }
+ else
+ {
+ _session->destroy(Ice::Current());
+ }
+ }
+ catch(const Ice::ObjectNotExistException&)
+ {
+ }
+ catch(const Ice::LocalException& ex)
+ {
+ Ice::Warning out(_logger);
+ out << "unexpected exception while reaping session:\n" << ex;
+ }
}
private:
@@ -105,8 +105,8 @@ private:
bool _terminated;
struct ReapableItem
{
- ReapablePtr item;
- IceUtil::Time timeout;
+ ReapablePtr item;
+ IceUtil::Time timeout;
};
std::list<ReapableItem> _sessions;
};
diff --git a/cpp/src/IceGrid/RegistryI.cpp b/cpp/src/IceGrid/RegistryI.cpp
index e059519cbc0..8f9d0fc1287 100644
--- a/cpp/src/IceGrid/RegistryI.cpp
+++ b/cpp/src/IceGrid/RegistryI.cpp
@@ -65,7 +65,7 @@ public:
bool checkPermissions(const string& userId, const string& password, string&, const Current&) const
{
- return true;
+ return true;
}
};
@@ -76,7 +76,7 @@ public:
virtual bool
authorize(const Glacier2::SSLInfo&, std::string&, const Ice::Current&) const
{
- return true;
+ return true;
}
};
@@ -90,25 +90,25 @@ public:
bool checkPermissions(const string& userId, const string& password, string&, const Current&) const
{
- map<string, string>::const_iterator p = _passwords.find(userId);
- if(p == _passwords.end())
- {
- return false;
- }
-
- if(p->second.size() != 13) // Crypt passwords are 13 characters long.
- {
- return false;
- }
-
- char buff[14];
- string salt = p->second.substr(0, 2);
+ map<string, string>::const_iterator p = _passwords.find(userId);
+ if(p == _passwords.end())
+ {
+ return false;
+ }
+
+ if(p->second.size() != 13) // Crypt passwords are 13 characters long.
+ {
+ return false;
+ }
+
+ char buff[14];
+ string salt = p->second.substr(0, 2);
#if OPENSSL_VERSION_NUMBER >= 0x0090700fL
- DES_fcrypt(password.c_str(), salt.c_str(), buff);
+ DES_fcrypt(password.c_str(), salt.c_str(), buff);
#else
- des_fcrypt(password.c_str(), salt.c_str(), buff);
+ des_fcrypt(password.c_str(), salt.c_str(), buff);
#endif
- return p->second == buff;
+ return p->second == buff;
}
private:
@@ -141,21 +141,21 @@ RegistryI::start(bool nowarn)
string dbPath = properties->getProperty("IceGrid.Registry.Data");
if(dbPath.empty())
{
- Error out(_communicator->getLogger());
- out << "property `IceGrid.Registry.Data' is not set";
- return false;
+ Error out(_communicator->getLogger());
+ out << "property `IceGrid.Registry.Data' is not set";
+ return false;
}
else
{
- struct stat filestat;
- if(stat(dbPath.c_str(), &filestat) != 0 || !S_ISDIR(filestat.st_mode))
- {
- Error out(_communicator->getLogger());
- SyscallException ex(__FILE__, __LINE__);
- ex.error = getSystemErrno();
- out << "property `IceGrid.Registry.Data' is set to an invalid path:\n" << ex;
- return false;
- }
+ struct stat filestat;
+ if(stat(dbPath.c_str(), &filestat) != 0 || !S_ISDIR(filestat.st_mode))
+ {
+ Error out(_communicator->getLogger());
+ SyscallException ex(__FILE__, __LINE__);
+ ex.error = getSystemErrno();
+ out << "property `IceGrid.Registry.Data' is set to an invalid path:\n" << ex;
+ return false;
+ }
}
//
@@ -166,9 +166,9 @@ RegistryI::start(bool nowarn)
if(properties->getProperty("Ice.OA.IceGrid.Registry.Client.Endpoints").empty() &&
properties->getProperty("IceGrid.Registry.Client.Endpoints").empty())
{
- Error out(_communicator->getLogger());
- out << "property `Ice.OA.IceGrid.Registry.Client.Endpoints' is not set";
- return false;
+ Error out(_communicator->getLogger());
+ out << "property `Ice.OA.IceGrid.Registry.Client.Endpoints' is not set";
+ return false;
}
//
@@ -177,9 +177,9 @@ RegistryI::start(bool nowarn)
if(properties->getProperty("Ice.OA.IceGrid.Registry.Server.Endpoints").empty() &&
properties->getProperty("IceGrid.Registry.Server.Endpoints").empty())
{
- Error out(_communicator->getLogger());
- out << "property `Ice.OA.IceGrid.Registry.Server.Endpoints' is not set";
- return false;
+ Error out(_communicator->getLogger());
+ out << "property `Ice.OA.IceGrid.Registry.Server.Endpoints' is not set";
+ return false;
}
//
@@ -188,9 +188,9 @@ RegistryI::start(bool nowarn)
if(properties->getProperty("Ice.OA.IceGrid.Registry.Internal.Endpoints").empty() &&
properties->getProperty("IceGrid.Registry.Internal.Endpoints").empty())
{
- Error out(_communicator->getLogger());
- out << "property `Ice.OA.IceGrid.Registry.Internal.Endpoints' is not set";
- return false;
+ Error out(_communicator->getLogger());
+ out << "property `Ice.OA.IceGrid.Registry.Internal.Endpoints' is not set";
+ return false;
}
//
@@ -199,11 +199,11 @@ RegistryI::start(bool nowarn)
if(!properties->getProperty("Ice.OA.IceGrid.Registry.SessionManager.Endpoints").empty() ||
!properties->getProperty("IceGrid.Registry.SessionManager.Endpoints").empty())
{
- if(!nowarn)
- {
- Warning out(_communicator->getLogger());
- out << "session manager endpoints `Ice.OA.IceGrid.Registry.SessionManager.Endpoints' enabled";
- }
+ if(!nowarn)
+ {
+ Warning out(_communicator->getLogger());
+ out << "session manager endpoints `Ice.OA.IceGrid.Registry.SessionManager.Endpoints' enabled";
+ }
}
properties->setProperty("Ice.PrintProcessId", "0");
@@ -228,28 +228,28 @@ RegistryI::start(bool nowarn)
//
if(_master)
{
- _instanceName = properties->getProperty("IceGrid.InstanceName");
- if(_instanceName.empty())
- {
- if(_communicator->getDefaultLocator())
- {
- _instanceName = _communicator->getDefaultLocator()->ice_getIdentity().category;
- }
- else
- {
- _instanceName = "IceGrid";
- }
- }
+ _instanceName = properties->getProperty("IceGrid.InstanceName");
+ if(_instanceName.empty())
+ {
+ if(_communicator->getDefaultLocator())
+ {
+ _instanceName = _communicator->getDefaultLocator()->ice_getIdentity().category;
+ }
+ else
+ {
+ _instanceName = "IceGrid";
+ }
+ }
}
else
{
- if(properties->getProperty("Ice.Default.Locator").empty())
- {
- Error out(_communicator->getLogger());
- out << "property `Ice.Default.Locator' is not set";
- return false;
- }
- _instanceName = _communicator->getDefaultLocator()->ice_getIdentity().category;
+ if(properties->getProperty("Ice.Default.Locator").empty())
+ {
+ Error out(_communicator->getLogger());
+ out << "property `Ice.Default.Locator' is not set";
+ return false;
+ }
+ _instanceName = _communicator->getDefaultLocator()->ice_getIdentity().category;
}
//
@@ -261,18 +261,18 @@ RegistryI::start(bool nowarn)
try
{
//
- // DEPRECATED PROPERTY: Remove extra code in future release
- //
+ // DEPRECATED PROPERTY: Remove extra code in future release
+ //
string endpoints =
- properties->getPropertyWithDefault("Ice.OA.IceGrid.Registry.Client.Endpoints",
- properties->getProperty("IceGrid.Registry.Client.Endpoints"));
- string strPrx = _instanceName + "/Locator:" + endpoints;
- _communicator->stringToProxy(strPrx)->ice_timeout(5000)->ice_ping();
+ properties->getPropertyWithDefault("Ice.OA.IceGrid.Registry.Client.Endpoints",
+ properties->getProperty("IceGrid.Registry.Client.Endpoints"));
+ string strPrx = _instanceName + "/Locator:" + endpoints;
+ _communicator->stringToProxy(strPrx)->ice_timeout(5000)->ice_ping();
- Error out(_communicator->getLogger());
- out << "an IceGrid registry is already running and listening on\n";
- out << "the client endpoints `" << endpoints << "'";
- return false;
+ Error out(_communicator->getLogger());
+ out << "an IceGrid registry is already running and listening on\n";
+ out << "the client endpoints `" << endpoints << "'";
+ return false;
}
catch(const Ice::LocalException&)
{
@@ -300,11 +300,11 @@ RegistryI::start(bool nowarn)
registryTopicManagerId.category = _instanceName;
registryTopicManagerId.name = "RegistryTopicManager";
_iceStorm = IceStorm::Service::create(_communicator,
- registryAdapter,
- registryAdapter,
- "IceGrid.Registry",
- registryTopicManagerId,
- "Registry");
+ registryAdapter,
+ registryAdapter,
+ "IceGrid.Registry",
+ registryTopicManagerId,
+ "Registry");
const IceStorm::TopicManagerPrx topicManager = _iceStorm->getTopicManager();
//
@@ -324,14 +324,14 @@ RegistryI::start(bool nowarn)
proxies = _database->getInternalObjectsByType(Node::ice_staticId());
for(p = proxies.begin(); p != proxies.end(); ++p)
{
- nodes.push_back(NodePrx::uncheckedCast(*p));
+ nodes.push_back(NodePrx::uncheckedCast(*p));
}
InternalRegistryPrxSeq replicas;
proxies = _database->getObjectsByType(InternalRegistry::ice_staticId());
for(p = proxies.begin(); p != proxies.end(); ++p)
{
- replicas.push_back(InternalRegistryPrx::uncheckedCast(*p));
+ replicas.push_back(InternalRegistryPrx::uncheckedCast(*p));
}
//
@@ -343,14 +343,14 @@ RegistryI::start(bool nowarn)
InternalRegistryPrx internalRegistry = setupInternalRegistry(registryAdapter);
if(_master)
{
- nodes = registerReplicas(internalRegistry, replicas, nodes);
- registerNodes(internalRegistry, nodes);
+ nodes = registerReplicas(internalRegistry, replicas, nodes);
+ registerNodes(internalRegistry, nodes);
}
else
{
- InternalReplicaInfoPtr info = _platform.getInternalReplicaInfo();
- _session.create(_replicaName, info, _database, _wellKnownObjects, internalRegistry);
- registerNodes(internalRegistry, _session.getNodes(nodes));
+ InternalReplicaInfoPtr info = _platform.getInternalReplicaInfo();
+ _session.create(_replicaName, info, _database, _wellKnownObjects, internalRegistry);
+ registerNodes(internalRegistry, _session.getNodes(nodes));
}
ObjectAdapterPtr serverAdapter = _communicator->createObjectAdapter("IceGrid.Registry.Server");
@@ -362,7 +362,7 @@ RegistryI::start(bool nowarn)
if(!properties->getProperty("Ice.OA.IceGrid.Registry.SessionManager.Endpoints").empty() ||
!properties->getProperty("IceGrid.Registry.SessionManager.Endpoints").empty())
{
- sessionManagerAdapter = _communicator->createObjectAdapter("IceGrid.Registry.SessionManager");
+ sessionManagerAdapter = _communicator->createObjectAdapter("IceGrid.Registry.SessionManager");
}
Ice::Identity dummy;
@@ -371,14 +371,14 @@ RegistryI::start(bool nowarn)
_wellKnownObjects->addEndpoint("Server", serverAdapter->createDirectProxy(dummy));
if(sessionManagerAdapter)
{
- _wellKnownObjects->addEndpoint("SessionManager", sessionManagerAdapter->createDirectProxy(dummy));
+ _wellKnownObjects->addEndpoint("SessionManager", sessionManagerAdapter->createDirectProxy(dummy));
}
_wellKnownObjects->addEndpoint("Internal", registryAdapter->createDirectProxy(dummy));
setupNullPermissionsVerifier(registryAdapter);
if(!setupUserAccountMapper(registryAdapter))
{
- return false;
+ return false;
}
QueryPrx query = setupQuery(_clientAdapter);
@@ -401,11 +401,11 @@ RegistryI::start(bool nowarn)
_wellKnownObjects->finish();
if(_master)
{
- _wellKnownObjects->registerAll();
+ _wellKnownObjects->registerAll();
}
else
{
- _session.registerAllWellKnownObjects();
+ _session.registerAllWellKnownObjects();
}
//
@@ -415,7 +415,7 @@ RegistryI::start(bool nowarn)
_clientAdapter->activate();
if(sessionManagerAdapter)
{
- sessionManagerAdapter->activate();
+ sessionManagerAdapter->activate();
}
return true;
@@ -434,10 +434,10 @@ RegistryI::setupLocatorRegistry(const Ice::ObjectAdapterPtr& serverAdapter)
IceGrid::LocatorPrx
RegistryI::setupLocator(const Ice::ObjectAdapterPtr& clientAdapter,
- const Ice::ObjectAdapterPtr& registryAdapter,
- const Ice::LocatorRegistryPrx& locatorRegistry,
- const RegistryPrx& registry,
- const QueryPrx& query)
+ const Ice::ObjectAdapterPtr& registryAdapter,
+ const Ice::LocatorRegistryPrx& locatorRegistry,
+ const RegistryPrx& registry,
+ const QueryPrx& query)
{
LocatorPtr locator = new LocatorI(_communicator, _database, locatorRegistry, registry, query);
Identity locatorId;
@@ -469,7 +469,7 @@ RegistryI::setupRegistry(const Ice::ObjectAdapterPtr& clientAdapter)
registryId.name = "Registry";
if(!_master)
{
- registryId.name += "-" + _replicaName;
+ registryId.name += "-" + _replicaName;
}
RegistryPrx proxy = RegistryPrx::uncheckedCast(clientAdapter->add(this, registryId));
_wellKnownObjects->add(proxy, Registry::ice_staticId());
@@ -499,13 +499,13 @@ RegistryI::setupNullPermissionsVerifier(const Ice::ObjectAdapterPtr& registryAda
nullPermVerifId.category = _instanceName;
nullPermVerifId.name = "NullPermissionsVerifier";
_nullPermissionsVerifier = Glacier2::PermissionsVerifierPrx::uncheckedCast(
- registryAdapter->add(new NullPermissionsVerifierI(), nullPermVerifId)->ice_collocationOptimized(true));
+ registryAdapter->add(new NullPermissionsVerifierI(), nullPermVerifId)->ice_collocationOptimized(true));
Identity nullSSLPermVerifId;
nullSSLPermVerifId.category = _instanceName;
nullSSLPermVerifId.name = "NullSSLPermissionsVerifier";
_nullSSLPermissionsVerifier = Glacier2::SSLPermissionsVerifierPrx::uncheckedCast(
- registryAdapter->add(new NullSSLPermissionsVerifierI(), nullSSLPermVerifId)->ice_collocationOptimized(true));
+ registryAdapter->add(new NullSSLPermissionsVerifierI(), nullSSLPermVerifId)->ice_collocationOptimized(true));
}
bool
@@ -519,33 +519,33 @@ RegistryI::setupUserAccountMapper(const Ice::ObjectAdapterPtr& registryAdapter)
string userAccountFileProperty = properties->getProperty("IceGrid.Registry.UserAccounts");
if(!userAccountFileProperty.empty())
{
- try
- {
- Identity mapperId;
- mapperId.category = _instanceName;
- mapperId.name = "RegistryUserAccountMapper";
- if(!_master)
- {
- mapperId.name += "-" + _replicaName;
- }
- registryAdapter->add(new FileUserAccountMapperI(userAccountFileProperty), mapperId);
- _wellKnownObjects->add(registryAdapter->createProxy(mapperId), UserAccountMapper::ice_staticId());
- }
- catch(const std::string& msg)
- {
- Error out(_communicator->getLogger());
- out << msg;
- return false;
- }
+ try
+ {
+ Identity mapperId;
+ mapperId.category = _instanceName;
+ mapperId.name = "RegistryUserAccountMapper";
+ if(!_master)
+ {
+ mapperId.name += "-" + _replicaName;
+ }
+ registryAdapter->add(new FileUserAccountMapperI(userAccountFileProperty), mapperId);
+ _wellKnownObjects->add(registryAdapter->createProxy(mapperId), UserAccountMapper::ice_staticId());
+ }
+ catch(const std::string& msg)
+ {
+ Error out(_communicator->getLogger());
+ out << msg;
+ return false;
+ }
}
return true;
}
void
RegistryI::setupClientSessionFactory(const Ice::ObjectAdapterPtr& registryAdapter,
- const Ice::ObjectAdapterPtr& sessionManagerAdapter,
- const IceGrid::LocatorPrx& locator,
- bool nowarn)
+ const Ice::ObjectAdapterPtr& sessionManagerAdapter,
+ const IceGrid::LocatorPrx& locator,
+ bool nowarn)
{
_waitQueue = new WaitQueue(); // Used for for session allocation timeout.
_waitQueue->start();
@@ -555,80 +555,80 @@ RegistryI::setupClientSessionFactory(const Ice::ObjectAdapterPtr& registryAdapte
if(sessionManagerAdapter && _master) // Slaves don't support client session manager objects.
{
- Identity clientSessionMgrId;
- clientSessionMgrId.category = _instanceName;
- clientSessionMgrId.name = "SessionManager";
- Identity sslClientSessionMgrId;
- sslClientSessionMgrId.category = _instanceName;
- sslClientSessionMgrId.name = "SSLSessionManager";
+ Identity clientSessionMgrId;
+ clientSessionMgrId.category = _instanceName;
+ clientSessionMgrId.name = "SessionManager";
+ Identity sslClientSessionMgrId;
+ sslClientSessionMgrId.category = _instanceName;
+ sslClientSessionMgrId.name = "SSLSessionManager";
- sessionManagerAdapter->add(new ClientSessionManagerI(_clientSessionFactory), clientSessionMgrId);
- sessionManagerAdapter->add(new ClientSSLSessionManagerI(_clientSessionFactory), sslClientSessionMgrId);
+ sessionManagerAdapter->add(new ClientSessionManagerI(_clientSessionFactory), clientSessionMgrId);
+ sessionManagerAdapter->add(new ClientSSLSessionManagerI(_clientSessionFactory), sslClientSessionMgrId);
- _wellKnownObjects->add(sessionManagerAdapter->createProxy(clientSessionMgrId),
- Glacier2::SessionManager::ice_staticId());
-
- _wellKnownObjects->add(sessionManagerAdapter->createProxy(sslClientSessionMgrId),
- Glacier2::SSLSessionManager::ice_staticId());
+ _wellKnownObjects->add(sessionManagerAdapter->createProxy(clientSessionMgrId),
+ Glacier2::SessionManager::ice_staticId());
+
+ _wellKnownObjects->add(sessionManagerAdapter->createProxy(sslClientSessionMgrId),
+ Glacier2::SSLSessionManager::ice_staticId());
}
Ice::PropertiesPtr properties = _communicator->getProperties();
_clientVerifier = getPermissionsVerifier(registryAdapter,
- locator,
- "IceGrid.Registry.PermissionsVerifier",
- properties->getProperty("IceGrid.Registry.CryptPasswords"),
- nowarn);
+ locator,
+ "IceGrid.Registry.PermissionsVerifier",
+ properties->getProperty("IceGrid.Registry.CryptPasswords"),
+ nowarn);
_sslClientVerifier = getSSLPermissionsVerifier(locator,
- "IceGrid.Registry.SSLPermissionsVerifier",
- nowarn);
+ "IceGrid.Registry.SSLPermissionsVerifier",
+ nowarn);
}
void
RegistryI::setupAdminSessionFactory(const Ice::ObjectAdapterPtr& registryAdapter,
- const Ice::ObjectAdapterPtr& sessionManagerAdapter,
- const IceGrid::LocatorPrx& locator,
- bool nowarn)
+ const Ice::ObjectAdapterPtr& sessionManagerAdapter,
+ const IceGrid::LocatorPrx& locator,
+ bool nowarn)
{
assert(_reaper);
_adminSessionFactory = new AdminSessionFactory(sessionManagerAdapter, _database, _reaper, this);
if(sessionManagerAdapter)
{
- Identity adminSessionMgrId;
- adminSessionMgrId.category = _instanceName;
- adminSessionMgrId.name = "AdminSessionManager";
- Identity sslAdmSessionMgrId;
- sslAdmSessionMgrId.category = _instanceName;
- sslAdmSessionMgrId.name = "AdminSSLSessionManager";
- if(!_master)
- {
- adminSessionMgrId.name += "-" + _replicaName;
- sslAdmSessionMgrId.name += "-" + _replicaName;
- }
-
- sessionManagerAdapter->add(new AdminSessionManagerI(_adminSessionFactory), adminSessionMgrId);
- sessionManagerAdapter->add(new AdminSSLSessionManagerI(_adminSessionFactory), sslAdmSessionMgrId);
-
- _wellKnownObjects->add(sessionManagerAdapter->createProxy(adminSessionMgrId),
- Glacier2::SessionManager::ice_staticId());
- _wellKnownObjects->add(sessionManagerAdapter->createProxy(sslAdmSessionMgrId),
- Glacier2::SSLSessionManager::ice_staticId());
+ Identity adminSessionMgrId;
+ adminSessionMgrId.category = _instanceName;
+ adminSessionMgrId.name = "AdminSessionManager";
+ Identity sslAdmSessionMgrId;
+ sslAdmSessionMgrId.category = _instanceName;
+ sslAdmSessionMgrId.name = "AdminSSLSessionManager";
+ if(!_master)
+ {
+ adminSessionMgrId.name += "-" + _replicaName;
+ sslAdmSessionMgrId.name += "-" + _replicaName;
+ }
+
+ sessionManagerAdapter->add(new AdminSessionManagerI(_adminSessionFactory), adminSessionMgrId);
+ sessionManagerAdapter->add(new AdminSSLSessionManagerI(_adminSessionFactory), sslAdmSessionMgrId);
+
+ _wellKnownObjects->add(sessionManagerAdapter->createProxy(adminSessionMgrId),
+ Glacier2::SessionManager::ice_staticId());
+ _wellKnownObjects->add(sessionManagerAdapter->createProxy(sslAdmSessionMgrId),
+ Glacier2::SSLSessionManager::ice_staticId());
}
Ice::PropertiesPtr properties = _communicator->getProperties();
_adminVerifier = getPermissionsVerifier(registryAdapter,
- locator,
- "IceGrid.Registry.AdminPermissionsVerifier",
- properties->getProperty("IceGrid.Registry.AdminCryptPasswords"),
- nowarn);
+ locator,
+ "IceGrid.Registry.AdminPermissionsVerifier",
+ properties->getProperty("IceGrid.Registry.AdminCryptPasswords"),
+ nowarn);
_sslAdminVerifier =
- getSSLPermissionsVerifier(locator,
- "IceGrid.Registry.AdminSSLPermissionsVerifier",
- nowarn);
+ getSSLPermissionsVerifier(locator,
+ "IceGrid.Registry.AdminSSLPermissionsVerifier",
+ nowarn);
}
void
@@ -650,27 +650,27 @@ RegistryI::stop()
}
catch(const Ice::LocalException& ex)
{
- Warning out(_communicator->getLogger());
- out << "unexpected exception while shutting down registry communicator:\n" << ex;
+ Warning out(_communicator->getLogger());
+ out << "unexpected exception while shutting down registry communicator:\n" << ex;
}
if(_reaper)
{
- _reaper->terminate();
- _reaper->getThreadControl().join();
- _reaper = 0;
+ _reaper->terminate();
+ _reaper->getThreadControl().join();
+ _reaper = 0;
}
if(_waitQueue)
{
- _waitQueue->destroy();
- _waitQueue = 0;
+ _waitQueue->destroy();
+ _waitQueue = 0;
}
if(_iceStorm)
{
- _iceStorm->stop();
- _iceStorm = 0;
+ _iceStorm->stop();
+ _iceStorm = 0;
}
_wellKnownObjects = 0;
@@ -684,20 +684,20 @@ RegistryI::createSession(const string& user, const string& password, const Curre
{
if(!_master)
{
- PermissionDeniedException ex;
- ex.reason = "client session creation is only allowed with the master registry.";
- throw ex;
+ PermissionDeniedException ex;
+ ex.reason = "client session creation is only allowed with the master registry.";
+ throw ex;
}
assert(_reaper && _clientSessionFactory);
if(!_clientVerifier)
{
- PermissionDeniedException ex;
- ex.reason = "no permissions verifier configured, use the property\n";
- ex.reason += "`IceGrid.Registry.PermissionsVerifier' to configure\n";
- ex.reason += "a permissions verifier.";
- throw ex;
+ PermissionDeniedException ex;
+ ex.reason = "no permissions verifier configured, use the property\n";
+ ex.reason += "`IceGrid.Registry.PermissionsVerifier' to configure\n";
+ ex.reason += "a permissions verifier.";
+ throw ex;
}
if(user.empty())
@@ -709,32 +709,32 @@ RegistryI::createSession(const string& user, const string& password, const Curre
try
{
- string reason;
- if(!_clientVerifier->checkPermissions(user, password, reason, current.ctx))
- {
- PermissionDeniedException exc;
- exc.reason = reason;
- throw exc;
- }
+ string reason;
+ if(!_clientVerifier->checkPermissions(user, password, reason, current.ctx))
+ {
+ PermissionDeniedException exc;
+ exc.reason = reason;
+ throw exc;
+ }
}
catch(const LocalException& ex)
{
- if(_traceLevels && _traceLevels->session > 0)
- {
- Trace out(_traceLevels->logger, _traceLevels->sessionCat);
- out << "exception while verifying password with client permission verifier:\n" << ex;
- }
+ if(_traceLevels && _traceLevels->session > 0)
+ {
+ Trace out(_traceLevels->logger, _traceLevels->sessionCat);
+ out << "exception while verifying password with client permission verifier:\n" << ex;
+ }
- PermissionDeniedException exc;
- exc.reason = "internal server error";
- throw exc;
+ PermissionDeniedException exc;
+ exc.reason = "internal server error";
+ throw exc;
}
SessionIPtr session = _clientSessionFactory->createSessionServant(user, 0);
Ice::ObjectPrx proxy = session->registerWithServantLocator(_sessionServantLocator, current.con);
if(_sessionTimeout > 0)
{
- _reaper->add(new SessionReapable<SessionI>(_traceLevels->logger, session), _sessionTimeout);
+ _reaper->add(new SessionReapable<SessionI>(_traceLevels->logger, session), _sessionTimeout);
}
return SessionPrx::uncheckedCast(proxy);
}
@@ -746,11 +746,11 @@ RegistryI::createAdminSession(const string& user, const string& password, const
if(!_adminVerifier)
{
- PermissionDeniedException ex;
- ex.reason = "no admin permissions verifier configured, use the property\n";
- ex.reason += "`IceGrid.Registry.AdminPermissionsVerifier' to configure\n";
- ex.reason += "a permissions verifier.";
- throw ex;
+ PermissionDeniedException ex;
+ ex.reason = "no admin permissions verifier configured, use the property\n";
+ ex.reason += "`IceGrid.Registry.AdminPermissionsVerifier' to configure\n";
+ ex.reason += "a permissions verifier.";
+ throw ex;
}
if(user.empty())
@@ -762,32 +762,32 @@ RegistryI::createAdminSession(const string& user, const string& password, const
try
{
- string reason;
- if(!_adminVerifier->checkPermissions(user, password, reason, current.ctx))
- {
- PermissionDeniedException exc;
- exc.reason = reason;
- throw exc;
- }
+ string reason;
+ if(!_adminVerifier->checkPermissions(user, password, reason, current.ctx))
+ {
+ PermissionDeniedException exc;
+ exc.reason = reason;
+ throw exc;
+ }
}
catch(const LocalException& ex)
{
- if(_traceLevels && _traceLevels->session > 0)
- {
- Trace out(_traceLevels->logger, _traceLevels->sessionCat);
- out << "exception while verifying password with admin permission verifier:\n" << ex;
- }
+ if(_traceLevels && _traceLevels->session > 0)
+ {
+ Trace out(_traceLevels->logger, _traceLevels->sessionCat);
+ out << "exception while verifying password with admin permission verifier:\n" << ex;
+ }
- PermissionDeniedException exc;
- exc.reason = "internal server error";
- throw exc;
+ PermissionDeniedException exc;
+ exc.reason = "internal server error";
+ throw exc;
}
AdminSessionIPtr session = _adminSessionFactory->createSessionServant(user);
Ice::ObjectPrx proxy = session->registerWithServantLocator(_sessionServantLocator, current.con, this);
if(_sessionTimeout > 0)
{
- _reaper->add(new SessionReapable<AdminSessionI>(_traceLevels->logger, session), _sessionTimeout);
+ _reaper->add(new SessionReapable<AdminSessionI>(_traceLevels->logger, session), _sessionTimeout);
}
return AdminSessionPrx::uncheckedCast(proxy);
}
@@ -797,20 +797,20 @@ RegistryI::createSessionFromSecureConnection(const Current& current)
{
if(!_master)
{
- PermissionDeniedException ex;
- ex.reason = "client session creation is only allowed with the master registry.";
- throw ex;
+ PermissionDeniedException ex;
+ ex.reason = "client session creation is only allowed with the master registry.";
+ throw ex;
}
assert(_reaper && _clientSessionFactory);
if(!_sslClientVerifier)
{
- PermissionDeniedException ex;
- ex.reason = "no ssl permissions verifier configured, use the property\n";
- ex.reason += "`IceGrid.Registry.SSLPermissionsVerifier' to configure\n";
- ex.reason += "a permissions verifier.";
- throw ex;
+ PermissionDeniedException ex;
+ ex.reason = "no ssl permissions verifier configured, use the property\n";
+ ex.reason += "`IceGrid.Registry.SSLPermissionsVerifier' to configure\n";
+ ex.reason += "a permissions verifier.";
+ throw ex;
}
string userDN;
@@ -824,32 +824,32 @@ RegistryI::createSessionFromSecureConnection(const Current& current)
try
{
- string reason;
- if(!_sslClientVerifier->authorize(info, reason, current.ctx))
- {
- PermissionDeniedException exc;
- exc.reason = reason;
- throw exc;
- }
+ string reason;
+ if(!_sslClientVerifier->authorize(info, reason, current.ctx))
+ {
+ PermissionDeniedException exc;
+ exc.reason = reason;
+ throw exc;
+ }
}
catch(const LocalException& ex)
{
- if(_traceLevels && _traceLevels->session > 0)
- {
- Trace out(_traceLevels->logger, _traceLevels->sessionCat);
- out << "exception while verifying password with SSL client permission verifier:\n" << ex;
- }
+ if(_traceLevels && _traceLevels->session > 0)
+ {
+ Trace out(_traceLevels->logger, _traceLevels->sessionCat);
+ out << "exception while verifying password with SSL client permission verifier:\n" << ex;
+ }
- PermissionDeniedException exc;
- exc.reason = "internal server error";
- throw exc;
+ PermissionDeniedException exc;
+ exc.reason = "internal server error";
+ throw exc;
}
SessionIPtr session = _clientSessionFactory->createSessionServant(userDN, 0);
Ice::ObjectPrx proxy = session->registerWithServantLocator(_sessionServantLocator, current.con);
if(_sessionTimeout > 0)
{
- _reaper->add(new SessionReapable<SessionI>(_traceLevels->logger, session), _sessionTimeout);
+ _reaper->add(new SessionReapable<SessionI>(_traceLevels->logger, session), _sessionTimeout);
}
return SessionPrx::uncheckedCast(proxy);
}
@@ -861,36 +861,36 @@ RegistryI::createAdminSessionFromSecureConnection(const Current& current)
if(!_sslAdminVerifier)
{
- PermissionDeniedException ex;
- ex.reason = "no ssl admin permissions verifier configured, use the property\n";
- ex.reason += "`IceGrid.Registry.AdminSSLPermissionsVerifier' to configure\n";
- ex.reason += "a permissions verifier.";
- throw ex;
+ PermissionDeniedException ex;
+ ex.reason = "no ssl admin permissions verifier configured, use the property\n";
+ ex.reason += "`IceGrid.Registry.AdminSSLPermissionsVerifier' to configure\n";
+ ex.reason += "a permissions verifier.";
+ throw ex;
}
string userDN;
Glacier2::SSLInfo info = getSSLInfo(current.con, userDN);
try
{
- string reason;
- if(!_sslAdminVerifier->authorize(info, reason, current.ctx))
- {
- PermissionDeniedException exc;
- exc.reason = reason;
- throw exc;
- }
+ string reason;
+ if(!_sslAdminVerifier->authorize(info, reason, current.ctx))
+ {
+ PermissionDeniedException exc;
+ exc.reason = reason;
+ throw exc;
+ }
}
catch(const LocalException& ex)
{
- if(_traceLevels && _traceLevels->session > 0)
- {
- Trace out(_traceLevels->logger, _traceLevels->sessionCat);
- out << "exception while verifying password with SSL admin permission verifier:\n" << ex;
- }
+ if(_traceLevels && _traceLevels->session > 0)
+ {
+ Trace out(_traceLevels->logger, _traceLevels->sessionCat);
+ out << "exception while verifying password with SSL admin permission verifier:\n" << ex;
+ }
- PermissionDeniedException exc;
- exc.reason = "internal server error";
- throw exc;
+ PermissionDeniedException exc;
+ exc.reason = "internal server error";
+ throw exc;
}
//
@@ -900,7 +900,7 @@ RegistryI::createAdminSessionFromSecureConnection(const Current& current)
Ice::ObjectPrx proxy = session->registerWithServantLocator(_sessionServantLocator, current.con, this);
if(_sessionTimeout > 0)
{
- _reaper->add(new SessionReapable<AdminSessionI>(_traceLevels->logger, session), _sessionTimeout);
+ _reaper->add(new SessionReapable<AdminSessionI>(_traceLevels->logger, session), _sessionTimeout);
}
return AdminSessionPrx::uncheckedCast(proxy);
}
@@ -942,34 +942,34 @@ RegistryI::setupThreadPool(const PropertiesPtr& properties, const string& name,
{
if(properties->getPropertyAsIntWithDefault(name + ".Size", 0) < size)
{
- ostringstream os;
- os << size;
- properties->setProperty(name + ".Size", os.str());
+ ostringstream os;
+ os << size;
+ properties->setProperty(name + ".Size", os.str());
}
else
{
- size = properties->getPropertyAsInt(name + ".Size");
+ size = properties->getPropertyAsInt(name + ".Size");
}
if(sizeMax > 0 && properties->getPropertyAsIntWithDefault(name + ".SizeMax", 0) < sizeMax)
{
- if(size >= sizeMax)
- {
- sizeMax = size * 10;
- }
-
- ostringstream os;
- os << sizeMax;
- properties->setProperty(name + ".SizeMax", os.str());
+ if(size >= sizeMax)
+ {
+ sizeMax = size * 10;
+ }
+
+ ostringstream os;
+ os << sizeMax;
+ properties->setProperty(name + ".SizeMax", os.str());
}
}
Glacier2::PermissionsVerifierPrx
RegistryI::getPermissionsVerifier(const ObjectAdapterPtr& adapter,
- const IceGrid::LocatorPrx& locator,
- const string& verifierProperty,
- const string& passwordsProperty,
- bool nowarn)
+ const IceGrid::LocatorPrx& locator,
+ const string& verifierProperty,
+ const string& passwordsProperty,
+ bool nowarn)
{
//
// Get the permissions verifier, or create a default one if no
@@ -980,61 +980,61 @@ RegistryI::getPermissionsVerifier(const ObjectAdapterPtr& adapter,
string verifierPropertyValue = _communicator->getProperties()->getProperty(verifierProperty);
if(!verifierPropertyValue.empty())
{
- try
- {
- verifier = _communicator->propertyToProxy(verifierProperty);
- assert(_nullPermissionsVerifier);
- if(verifier->ice_getIdentity() == _nullPermissionsVerifier->ice_getIdentity())
- {
- verifier = _nullPermissionsVerifier;
- }
- }
- catch(const LocalException& ex)
- {
- Error out(_communicator->getLogger());
- out << "permissions verifier `" + verifierPropertyValue + "' is invalid:\n" << ex;
- return 0;
- }
+ try
+ {
+ verifier = _communicator->propertyToProxy(verifierProperty);
+ assert(_nullPermissionsVerifier);
+ if(verifier->ice_getIdentity() == _nullPermissionsVerifier->ice_getIdentity())
+ {
+ verifier = _nullPermissionsVerifier;
+ }
+ }
+ catch(const LocalException& ex)
+ {
+ Error out(_communicator->getLogger());
+ out << "permissions verifier `" + verifierPropertyValue + "' is invalid:\n" << ex;
+ return 0;
+ }
}
else if(!passwordsProperty.empty())
{
- ifstream passwordFile(passwordsProperty.c_str());
- if(!passwordFile)
- {
- Error out(_communicator->getLogger());
+ ifstream passwordFile(passwordsProperty.c_str());
+ if(!passwordFile)
+ {
+ Error out(_communicator->getLogger());
string err = strerror(errno);
- out << "cannot open `" + passwordsProperty + "' for reading: " + err;
- return 0;
- }
-
- map<string, string> passwords;
-
- while(true)
- {
- string userId;
- passwordFile >> userId;
- if(!passwordFile)
- {
- break;
- }
-
- string password;
- passwordFile >> password;
- if(!passwordFile)
- {
- break;
- }
-
- assert(!userId.empty());
- assert(!password.empty());
- passwords.insert(make_pair(userId, password));
- }
-
- verifier = adapter->addWithUUID(new CryptPermissionsVerifierI(passwords));
+ out << "cannot open `" + passwordsProperty + "' for reading: " + err;
+ return 0;
+ }
+
+ map<string, string> passwords;
+
+ while(true)
+ {
+ string userId;
+ passwordFile >> userId;
+ if(!passwordFile)
+ {
+ break;
+ }
+
+ string password;
+ passwordFile >> password;
+ if(!passwordFile)
+ {
+ break;
+ }
+
+ assert(!userId.empty());
+ assert(!password.empty());
+ passwords.insert(make_pair(userId, password));
+ }
+
+ verifier = adapter->addWithUUID(new CryptPermissionsVerifierI(passwords));
}
else
{
- return 0;
+ return 0;
}
assert(verifier);
@@ -1042,28 +1042,28 @@ RegistryI::getPermissionsVerifier(const ObjectAdapterPtr& adapter,
Glacier2::PermissionsVerifierPrx verifierPrx;
try
{
- //
- // Set the permission verifier proxy locator to the internal
- // locator. We can't use the "public" locator, this could lead
- // to deadlocks if there's not enough threads in the client
- // thread pool anymore.
- //
- verifierPrx = Glacier2::PermissionsVerifierPrx::checkedCast(verifier->ice_locator(locator));
- if(!verifierPrx)
- {
- Error out(_communicator->getLogger());
- out << "permissions verifier `" + verifierProperty + "' is invalid";
- return 0;
- }
+ //
+ // Set the permission verifier proxy locator to the internal
+ // locator. We can't use the "public" locator, this could lead
+ // to deadlocks if there's not enough threads in the client
+ // thread pool anymore.
+ //
+ verifierPrx = Glacier2::PermissionsVerifierPrx::checkedCast(verifier->ice_locator(locator));
+ if(!verifierPrx)
+ {
+ Error out(_communicator->getLogger());
+ out << "permissions verifier `" + verifierProperty + "' is invalid";
+ return 0;
+ }
}
catch(const LocalException& ex)
{
- if(!nowarn)
- {
- Warning out(_communicator->getLogger());
- out << "couldn't contact permissions verifier `" + verifierProperty + "':\n" << ex;
- }
- verifierPrx = Glacier2::PermissionsVerifierPrx::uncheckedCast(verifier->ice_locator(locator));
+ if(!nowarn)
+ {
+ Warning out(_communicator->getLogger());
+ out << "couldn't contact permissions verifier `" + verifierProperty + "':\n" << ex;
+ }
+ verifierPrx = Glacier2::PermissionsVerifierPrx::uncheckedCast(verifier->ice_locator(locator));
}
return verifierPrx;
}
@@ -1081,18 +1081,18 @@ RegistryI::getSSLPermissionsVerifier(const IceGrid::LocatorPrx& locator, const s
{
try
{
- verifier = _communicator->propertyToProxy(verifierProperty);
- assert(_nullSSLPermissionsVerifier);
- if(verifier->ice_getIdentity() == _nullSSLPermissionsVerifier->ice_getIdentity())
- {
- verifier = _nullSSLPermissionsVerifier;
- }
+ verifier = _communicator->propertyToProxy(verifierProperty);
+ assert(_nullSSLPermissionsVerifier);
+ if(verifier->ice_getIdentity() == _nullSSLPermissionsVerifier->ice_getIdentity())
+ {
+ verifier = _nullSSLPermissionsVerifier;
+ }
}
catch(const LocalException& ex)
{
- Error out(_communicator->getLogger());
- out << "permissions verifier `" + verifierPropertyValue + "' is invalid:\n" << ex;
- return 0;
+ Error out(_communicator->getLogger());
+ out << "permissions verifier `" + verifierPropertyValue + "' is invalid:\n" << ex;
+ return 0;
}
}
else
@@ -1103,28 +1103,28 @@ RegistryI::getSSLPermissionsVerifier(const IceGrid::LocatorPrx& locator, const s
Glacier2::SSLPermissionsVerifierPrx verifierPrx;
try
{
- //
- // Set the permission verifier proxy locator to the internal
- // locator. We can't use the "public" locator, this could lead
- // to deadlocks if there's not enough threads in the client
- // thread pool anymore.
- //
- verifierPrx = Glacier2::SSLPermissionsVerifierPrx::checkedCast(verifier->ice_locator(locator));
- if(!verifierPrx)
- {
- Error out(_communicator->getLogger());
- out << "permissions verifier `" + verifierProperty + "' is invalid";
- return 0;
- }
+ //
+ // Set the permission verifier proxy locator to the internal
+ // locator. We can't use the "public" locator, this could lead
+ // to deadlocks if there's not enough threads in the client
+ // thread pool anymore.
+ //
+ verifierPrx = Glacier2::SSLPermissionsVerifierPrx::checkedCast(verifier->ice_locator(locator));
+ if(!verifierPrx)
+ {
+ Error out(_communicator->getLogger());
+ out << "permissions verifier `" + verifierProperty + "' is invalid";
+ return 0;
+ }
}
catch(const LocalException& ex)
{
- if(!nowarn)
- {
- Warning out(_communicator->getLogger());
- out << "couldn't contact permissions verifier `" + verifierProperty + "':\n" << ex;
- }
- verifierPrx = Glacier2::SSLPermissionsVerifierPrx::uncheckedCast(verifier->ice_locator(locator));
+ if(!nowarn)
+ {
+ Warning out(_communicator->getLogger());
+ out << "couldn't contact permissions verifier `" + verifierProperty + "':\n" << ex;
+ }
+ verifierPrx = Glacier2::SSLPermissionsVerifierPrx::uncheckedCast(verifier->ice_locator(locator));
}
return verifierPrx;
}
@@ -1135,35 +1135,35 @@ RegistryI::getSSLInfo(const ConnectionPtr& connection, string& userDN)
Glacier2::SSLInfo sslinfo;
try
{
- IceSSL::ConnectionInfo info = IceSSL::getConnectionInfo(connection);
- sslinfo.remotePort = ntohs(info.remoteAddr.sin_port);
- sslinfo.remoteHost = IceInternal::inetAddrToString(info.remoteAddr.sin_addr);
- sslinfo.localPort = ntohs(info.localAddr.sin_port);
- sslinfo.localHost = IceInternal::inetAddrToString(info.localAddr.sin_addr);
+ IceSSL::ConnectionInfo info = IceSSL::getConnectionInfo(connection);
+ sslinfo.remotePort = ntohs(info.remoteAddr.sin_port);
+ sslinfo.remoteHost = IceInternal::inetAddrToString(info.remoteAddr.sin_addr);
+ sslinfo.localPort = ntohs(info.localAddr.sin_port);
+ sslinfo.localHost = IceInternal::inetAddrToString(info.localAddr.sin_addr);
- sslinfo.cipher = info.cipher;
+ sslinfo.cipher = info.cipher;
- if(!info.certs.empty())
- {
- sslinfo.certs.resize(info.certs.size());
- for(unsigned int i = 0; i < info.certs.size(); ++i)
- {
- sslinfo.certs[i] = info.certs[i]->encode();
- }
- userDN = info.certs[0]->getSubjectDN();
- }
+ if(!info.certs.empty())
+ {
+ sslinfo.certs.resize(info.certs.size());
+ for(unsigned int i = 0; i < info.certs.size(); ++i)
+ {
+ sslinfo.certs[i] = info.certs[i]->encode();
+ }
+ userDN = info.certs[0]->getSubjectDN();
+ }
}
catch(const IceSSL::ConnectionInvalidException&)
{
- PermissionDeniedException exc;
- exc.reason = "not ssl connection";
- throw exc;
+ PermissionDeniedException exc;
+ exc.reason = "not ssl connection";
+ throw exc;
}
catch(const IceSSL::CertificateEncodingException&)
{
- PermissionDeniedException exc;
- exc.reason = "certificate encoding exception";
- throw exc;
+ PermissionDeniedException exc;
+ exc.reason = "certificate encoding exception";
+ throw exc;
}
return sslinfo;
@@ -1171,71 +1171,71 @@ RegistryI::getSSLInfo(const ConnectionPtr& connection, string& userDN)
NodePrxSeq
RegistryI::registerReplicas(const InternalRegistryPrx& internalRegistry,
- const InternalRegistryPrxSeq& replicas,
- const NodePrxSeq& dbNodes)
+ const InternalRegistryPrxSeq& replicas,
+ const NodePrxSeq& dbNodes)
{
set<NodePrx> nodes;
nodes.insert(dbNodes.begin(), dbNodes.end());
for(InternalRegistryPrxSeq::const_iterator r = replicas.begin(); r != replicas.end(); ++r)
{
- if((*r)->ice_getIdentity() != internalRegistry->ice_getIdentity())
- {
- string replicaName;
- if(_traceLevels && _traceLevels->replica > 1)
- {
- replicaName = (*r)->ice_getIdentity().name;
- const string prefix("InternalRegistry-");
- string::size_type pos = replicaName.find(prefix);
- if(pos != string::npos)
- {
- replicaName = replicaName.substr(prefix.size());
- }
-
- Ice::Trace out(_traceLevels->logger, _traceLevels->replicaCat);
- out << "creating replica `" << replicaName << "' session";
- }
-
- try
- {
- (*r)->registerWithReplica(internalRegistry);
- NodePrxSeq nds = (*r)->getNodes();
- nodes.insert(nds.begin(), nds.end());
-
- if(_traceLevels && _traceLevels->replica > 1)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->replicaCat);
- out << "replica `" << replicaName << "' session created";
- }
- }
- catch(const Ice::LocalException& ex)
- {
- //
- // Clear the proxy from the database if we can't
- // contact the replica.
- //
- try
- {
- _database->removeObject((*r)->ice_getIdentity());
- }
- catch(const ObjectNotRegisteredException&)
- {
- }
-
- if(_traceLevels && _traceLevels->replica > 1)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->replicaCat);
- out << "replica `" << replicaName << "' session creation failed:\n" << ex;
- }
- }
- }
+ if((*r)->ice_getIdentity() != internalRegistry->ice_getIdentity())
+ {
+ string replicaName;
+ if(_traceLevels && _traceLevels->replica > 1)
+ {
+ replicaName = (*r)->ice_getIdentity().name;
+ const string prefix("InternalRegistry-");
+ string::size_type pos = replicaName.find(prefix);
+ if(pos != string::npos)
+ {
+ replicaName = replicaName.substr(prefix.size());
+ }
+
+ Ice::Trace out(_traceLevels->logger, _traceLevels->replicaCat);
+ out << "creating replica `" << replicaName << "' session";
+ }
+
+ try
+ {
+ (*r)->registerWithReplica(internalRegistry);
+ NodePrxSeq nds = (*r)->getNodes();
+ nodes.insert(nds.begin(), nds.end());
+
+ if(_traceLevels && _traceLevels->replica > 1)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->replicaCat);
+ out << "replica `" << replicaName << "' session created";
+ }
+ }
+ catch(const Ice::LocalException& ex)
+ {
+ //
+ // Clear the proxy from the database if we can't
+ // contact the replica.
+ //
+ try
+ {
+ _database->removeObject((*r)->ice_getIdentity());
+ }
+ catch(const ObjectNotRegisteredException&)
+ {
+ }
+
+ if(_traceLevels && _traceLevels->replica > 1)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->replicaCat);
+ out << "replica `" << replicaName << "' session creation failed:\n" << ex;
+ }
+ }
+ }
}
#ifdef _RWSTD_NO_MEMBER_TEMPLATES
NodePrxSeq result;
for(set<NodePrx>::iterator p = nodes.begin(); p != nodes.end(); ++p)
{
- result.push_back(*p);
+ result.push_back(*p);
}
return result;
#else
@@ -1250,25 +1250,25 @@ RegistryI::registerNodes(const InternalRegistryPrx& internalRegistry, const Node
for(NodePrxSeq::const_iterator p = nodes.begin(); p != nodes.end(); ++p)
{
- assert((*p)->ice_getIdentity().name.find(prefix) != string::npos);
- try
- {
- _database->getNode((*p)->ice_getIdentity().name.substr(prefix.size()))->setProxy(*p);
- }
- catch(const NodeNotExistException&)
- {
- //
- // Ignore, if nothing's deployed on the node we won't need
- // to contact it for locator requests so we don't need to
- // keep its proxy.
- //
- try
- {
- _database->removeInternalObject((*p)->ice_getIdentity());
- }
- catch(const ObjectNotRegisteredException&)
- {
- }
- }
+ assert((*p)->ice_getIdentity().name.find(prefix) != string::npos);
+ try
+ {
+ _database->getNode((*p)->ice_getIdentity().name.substr(prefix.size()))->setProxy(*p);
+ }
+ catch(const NodeNotExistException&)
+ {
+ //
+ // Ignore, if nothing's deployed on the node we won't need
+ // to contact it for locator requests so we don't need to
+ // keep its proxy.
+ //
+ try
+ {
+ _database->removeInternalObject((*p)->ice_getIdentity());
+ }
+ catch(const ObjectNotRegisteredException&)
+ {
+ }
+ }
}
}
diff --git a/cpp/src/IceGrid/RegistryI.h b/cpp/src/IceGrid/RegistryI.h
index 63958bc08ee..152944dc19c 100644
--- a/cpp/src/IceGrid/RegistryI.h
+++ b/cpp/src/IceGrid/RegistryI.h
@@ -74,20 +74,20 @@ private:
Ice::LocatorRegistryPrx setupLocatorRegistry(const Ice::ObjectAdapterPtr&);
LocatorPrx setupLocator(const Ice::ObjectAdapterPtr&, const Ice::ObjectAdapterPtr&, const Ice::LocatorRegistryPrx&,
- const RegistryPrx&, const QueryPrx&);
+ const RegistryPrx&, const QueryPrx&);
QueryPrx setupQuery(const Ice::ObjectAdapterPtr&);
RegistryPrx setupRegistry(const Ice::ObjectAdapterPtr&);
InternalRegistryPrx setupInternalRegistry(const Ice::ObjectAdapterPtr&);
void setupNullPermissionsVerifier(const Ice::ObjectAdapterPtr&);
bool setupUserAccountMapper(const Ice::ObjectAdapterPtr&);
void setupClientSessionFactory(const Ice::ObjectAdapterPtr&, const Ice::ObjectAdapterPtr&, const LocatorPrx&,
- bool);
+ bool);
void setupAdminSessionFactory(const Ice::ObjectAdapterPtr&, const Ice::ObjectAdapterPtr&, const LocatorPrx&,
- bool);
+ bool);
void setupThreadPool(const Ice::PropertiesPtr&, const std::string&, int, int = 0);
Glacier2::PermissionsVerifierPrx getPermissionsVerifier(const Ice::ObjectAdapterPtr&, const LocatorPrx&,
- const std::string&, const std::string&, bool);
+ const std::string&, const std::string&, bool);
Glacier2::SSLPermissionsVerifierPrx getSSLPermissionsVerifier(const LocatorPrx&, const std::string&, bool);
Glacier2::SSLInfo getSSLInfo(const Ice::ConnectionPtr&, std::string&);
diff --git a/cpp/src/IceGrid/ReplicaCache.cpp b/cpp/src/IceGrid/ReplicaCache.cpp
index fa5102a322c..a766f46c69e 100644
--- a/cpp/src/IceGrid/ReplicaCache.cpp
+++ b/cpp/src/IceGrid/ReplicaCache.cpp
@@ -23,11 +23,11 @@ ReplicaCache::ReplicaCache(const Ice::CommunicatorPtr& communicator, const IceSt
IceStorm::TopicPrx t;
try
{
- t = topicManager->create("ReplicaObserverTopic");
+ t = topicManager->create("ReplicaObserverTopic");
}
catch(const IceStorm::TopicExists&)
{
- t = topicManager->retrieve("ReplicaObserverTopic");
+ t = topicManager->retrieve("ReplicaObserverTopic");
}
const_cast<IceStorm::TopicPrx&>(_topic) = IceStorm::TopicPrx::uncheckedCast(t->ice_collocationOptimized(true));
@@ -42,59 +42,59 @@ ReplicaCache::add(const string& name, const ReplicaSessionIPtr& session)
ReplicaEntryPtr entry;
while(entry = getImpl(name))
{
- ReplicaSessionIPtr session = entry->getSession();
- if(session->isDestroyed())
- {
- wait(); // Wait for the session to be removed.
- }
- else
- {
- //
- // Check if the replica is still reachable, if not, we
- // destroy its session.
- //
- sync.release();
- try
- {
- session->getInternalRegistry()->ice_ping();
- throw ReplicaActiveException();
- }
- catch(const Ice::LocalException&)
- {
- try
- {
- session->destroy();
- }
- catch(const Ice::LocalException&)
- {
- }
- }
- sync.acquire();
- }
+ ReplicaSessionIPtr session = entry->getSession();
+ if(session->isDestroyed())
+ {
+ wait(); // Wait for the session to be removed.
+ }
+ else
+ {
+ //
+ // Check if the replica is still reachable, if not, we
+ // destroy its session.
+ //
+ sync.release();
+ try
+ {
+ session->getInternalRegistry()->ice_ping();
+ throw ReplicaActiveException();
+ }
+ catch(const Ice::LocalException&)
+ {
+ try
+ {
+ session->destroy();
+ }
+ catch(const Ice::LocalException&)
+ {
+ }
+ }
+ sync.acquire();
+ }
}
if(_traceLevels && _traceLevels->replica > 0)
{
- Ice::Trace out(_traceLevels->logger, _traceLevels->replicaCat);
- out << "replica `" << name << "' up";
+ Ice::Trace out(_traceLevels->logger, _traceLevels->replicaCat);
+ out << "replica `" << name << "' up";
}
try
{
- _observers->replicaAdded(session->getInternalRegistry());
+ _observers->replicaAdded(session->getInternalRegistry());
}
catch(const Ice::ConnectionRefusedException&)
{
- // Expected if the replica is being shutdown.
+ // Expected if the replica is being shutdown.
}
catch(const Ice::LocalException& ex)
{
- TraceLevelsPtr traceLevels = getTraceLevels();
- if(traceLevels)
- {
- Ice::Warning out(traceLevels->logger);
- out << "unexpected exception while publishing `replicaAdded' update:\n" << ex;
- }
+ TraceLevelsPtr traceLevels = getTraceLevels();
+ if(traceLevels)
+ {
+ Ice::Warning out(traceLevels->logger);
+ out << "unexpected exception while publishing `replicaAdded' update:\n" << ex;
+ }
}
return addImpl(name, new ReplicaEntry(name, session));
@@ -112,29 +112,29 @@ ReplicaCache::remove(const string& name, bool shutdown)
if(_traceLevels && _traceLevels->replica > 0)
{
- Ice::Trace out(_traceLevels->logger, _traceLevels->replicaCat);
- out << "replica `" << name << "' down";
+ Ice::Trace out(_traceLevels->logger, _traceLevels->replicaCat);
+ out << "replica `" << name << "' down";
}
if(!shutdown)
{
- try
- {
- _observers->replicaRemoved(entry->getProxy());
- }
- catch(const Ice::ConnectionRefusedException&)
- {
- // Expected if the replica is being shutdown.
- }
- catch(const Ice::LocalException& ex)
- {
- TraceLevelsPtr traceLevels = getTraceLevels();
- if(traceLevels)
- {
- Ice::Warning out(traceLevels->logger);
- out << "unexpected exception while publishing `replicaRemoved' update:\n" << ex;
- }
- }
+ try
+ {
+ _observers->replicaRemoved(entry->getProxy());
+ }
+ catch(const Ice::ConnectionRefusedException&)
+ {
+ // Expected if the replica is being shutdown.
+ }
+ catch(const Ice::LocalException& ex)
+ {
+ TraceLevelsPtr traceLevels = getTraceLevels();
+ if(traceLevels)
+ {
+ Ice::Warning out(traceLevels->logger);
+ out << "unexpected exception while publishing `replicaRemoved' update:\n" << ex;
+ }
+ }
}
return entry;
@@ -147,9 +147,9 @@ ReplicaCache::get(const string& name) const
ReplicaEntryPtr entry = getImpl(name);
if(!entry)
{
- RegistryNotExistException ex;
- ex.name = name;
- throw ex;
+ RegistryNotExistException ex;
+ ex.name = name;
+ throw ex;
}
return entry;
}
@@ -159,30 +159,30 @@ ReplicaCache::subscribe(const ReplicaObserverPrx& observer)
{
try
{
- Lock sync(*this);
- InternalRegistryPrxSeq replicas;
- for(map<string, ReplicaEntryPtr>::const_iterator p = _entries.begin(); p != _entries.end(); ++p)
- {
- replicas.push_back(p->second->getProxy());
- }
-
- IceStorm::QoS qos;
- qos["reliability"] = "ordered";
- Ice::ObjectPrx publisher = _topic->subscribeAndGetPublisher(qos, observer->ice_twoway());
- ReplicaObserverPrx::uncheckedCast(publisher)->replicaInit(replicas);
+ Lock sync(*this);
+ InternalRegistryPrxSeq replicas;
+ for(map<string, ReplicaEntryPtr>::const_iterator p = _entries.begin(); p != _entries.end(); ++p)
+ {
+ replicas.push_back(p->second->getProxy());
+ }
+
+ IceStorm::QoS qos;
+ qos["reliability"] = "ordered";
+ Ice::ObjectPrx publisher = _topic->subscribeAndGetPublisher(qos, observer->ice_twoway());
+ ReplicaObserverPrx::uncheckedCast(publisher)->replicaInit(replicas);
}
catch(const Ice::ConnectionRefusedException&)
{
- // The replica is being shutdown.
+ // The replica is being shutdown.
}
catch(const Ice::LocalException& ex)
{
- TraceLevelsPtr traceLevels = getTraceLevels();
- if(traceLevels)
- {
- Ice::Warning out(traceLevels->logger);
- out << "unexpected exception while subscribing observer from replica observer topic:\n" << ex;
- }
+ TraceLevelsPtr traceLevels = getTraceLevels();
+ if(traceLevels)
+ {
+ Ice::Warning out(traceLevels->logger);
+ out << "unexpected exception while subscribing observer from replica observer topic:\n" << ex;
+ }
}
}
@@ -191,20 +191,20 @@ ReplicaCache::unsubscribe(const ReplicaObserverPrx& observer)
{
try
{
- _topic->unsubscribe(observer);
+ _topic->unsubscribe(observer);
}
catch(const Ice::ConnectionRefusedException&)
{
- // The replica is being shutdown.
+ // The replica is being shutdown.
}
catch(const Ice::LocalException& ex)
{
- TraceLevelsPtr traceLevels = getTraceLevels();
- if(traceLevels)
- {
- Ice::Warning out(traceLevels->logger);
- out << "unexpected exception while unsubscribing observer from replica observer topic:\n" << ex;
- }
+ TraceLevelsPtr traceLevels = getTraceLevels();
+ if(traceLevels)
+ {
+ Ice::Warning out(traceLevels->logger);
+ out << "unexpected exception while unsubscribing observer from replica observer topic:\n" << ex;
+ }
}
}
@@ -215,19 +215,19 @@ ReplicaCache::getEndpoints(const string& name, const Ice::ObjectPrx& proxy) cons
if(proxy)
{
- Ice::EndpointSeq endpts = proxy->ice_getEndpoints();
- endpoints.insert(endpoints.end(), endpts.begin(), endpts.end());
+ Ice::EndpointSeq endpts = proxy->ice_getEndpoints();
+ endpoints.insert(endpoints.end(), endpts.begin(), endpts.end());
}
Lock sync(*this);
for(map<string, ReplicaEntryPtr>::const_iterator p = _entries.begin(); p != _entries.end(); ++p)
{
- Ice::ObjectPrx prx = p->second->getSession()->getEndpoint(name);
- if(prx)
- {
- Ice::EndpointSeq endpts = prx->ice_getEndpoints();
- endpoints.insert(endpoints.end(), endpts.begin(), endpts.end());
- }
+ Ice::ObjectPrx prx = p->second->getSession()->getEndpoint(name);
+ if(prx)
+ {
+ Ice::EndpointSeq endpts = prx->ice_getEndpoints();
+ endpoints.insert(endpoints.end(), endpts.begin(), endpts.end());
+ }
}
return _communicator->stringToProxy("dummy")->ice_endpoints(endpoints);
diff --git a/cpp/src/IceGrid/ReplicaSessionI.cpp b/cpp/src/IceGrid/ReplicaSessionI.cpp
index 67c633308ff..1fb589470a2 100644
--- a/cpp/src/IceGrid/ReplicaSessionI.cpp
+++ b/cpp/src/IceGrid/ReplicaSessionI.cpp
@@ -29,10 +29,10 @@ operator==(const ObjectInfo& info, const Ice::Identity& id)
}
ReplicaSessionI::ReplicaSessionI(const DatabasePtr& database,
- const WellKnownObjectsManagerPtr& wellKnownObjects,
- const InternalReplicaInfoPtr& info,
- const InternalRegistryPrx& proxy,
- int timeout) :
+ const WellKnownObjectsManagerPtr& wellKnownObjects,
+ const InternalReplicaInfoPtr& info,
+ const InternalRegistryPrx& proxy,
+ int timeout) :
_database(database),
_wellKnownObjects(wellKnownObjects),
_traceLevels(database->getTraceLevels()),
@@ -45,27 +45,27 @@ ReplicaSessionI::ReplicaSessionI(const DatabasePtr& database,
__setNoDelete(true);
try
{
- _database->getReplicaCache().add(info->name, this);
+ _database->getReplicaCache().add(info->name, this);
- ObserverTopicPtr obsv = _database->getObserverTopic(RegistryObserverTopicName);
- RegistryObserverTopicPtr::dynamicCast(obsv)->registryUp(toRegistryInfo(_info));
+ ObserverTopicPtr obsv = _database->getObserverTopic(RegistryObserverTopicName);
+ RegistryObserverTopicPtr::dynamicCast(obsv)->registryUp(toRegistryInfo(_info));
- _proxy = ReplicaSessionPrx::uncheckedCast(_database->getInternalAdapter()->addWithUUID(this));
+ _proxy = ReplicaSessionPrx::uncheckedCast(_database->getInternalAdapter()->addWithUUID(this));
}
catch(const ReplicaActiveException&)
{
- __setNoDelete(false);
- throw;
+ __setNoDelete(false);
+ throw;
}
catch(...)
{
- ObserverTopicPtr obsv = _database->getObserverTopic(RegistryObserverTopicName);
- RegistryObserverTopicPtr::dynamicCast(obsv)->registryDown(_info->name);
+ ObserverTopicPtr obsv = _database->getObserverTopic(RegistryObserverTopicName);
+ RegistryObserverTopicPtr::dynamicCast(obsv)->registryDown(_info->name);
- _database->getReplicaCache().remove(_info->name, false);
+ _database->getReplicaCache().remove(_info->name, false);
- __setNoDelete(false);
- throw;
+ __setNoDelete(false);
+ throw;
}
__setNoDelete(false);
}
@@ -76,15 +76,15 @@ ReplicaSessionI::keepAlive(const Ice::Current& current)
Lock sync(*this);
if(_destroy)
{
- throw Ice::ObjectNotExistException(__FILE__, __LINE__);
+ throw Ice::ObjectNotExistException(__FILE__, __LINE__);
}
_timestamp = IceUtil::Time::now();
if(_traceLevels->replica > 2)
{
- Ice::Trace out(_traceLevels->logger, _traceLevels->replicaCat);
- out << "replica `" << _info->name << "' keep alive ";
+ Ice::Trace out(_traceLevels->logger, _traceLevels->replicaCat);
+ out << "replica `" << _info->name << "' keep alive ";
}
}
@@ -100,8 +100,8 @@ ReplicaSessionI::setDatabaseObserver(const DatabaseObserverPrx& observer, const
Lock sync(*this);
if(_destroy)
{
- throw Ice::ObjectNotExistException(__FILE__, __LINE__);
- }
+ throw Ice::ObjectNotExistException(__FILE__, __LINE__);
+ }
_observer = observer;
_database->getObserverTopic(ApplicationObserverTopicName)->subscribe(_observer, _info->name);
_database->getObserverTopic(AdapterObserverTopicName)->subscribe(_observer, _info->name);
@@ -112,12 +112,12 @@ void
ReplicaSessionI::setEndpoints(const StringObjectProxyDict& endpoints, const Ice::Current& current)
{
{
- Lock sync(*this);
- if(_destroy)
- {
- throw Ice::ObjectNotExistException(__FILE__, __LINE__);
- }
- _replicaEndpoints = endpoints;
+ Lock sync(*this);
+ if(_destroy)
+ {
+ throw Ice::ObjectNotExistException(__FILE__, __LINE__);
+ }
+ _replicaEndpoints = endpoints;
}
_wellKnownObjects->updateReplicatedWellKnownObjects();
}
@@ -127,13 +127,13 @@ ReplicaSessionI::registerWellKnownObjects(const ObjectInfoSeq& objects, const Ic
{
int serial;
{
- Lock sync(*this);
- if(_destroy)
- {
- throw Ice::ObjectNotExistException(__FILE__, __LINE__);
- }
- _replicaWellKnownObjects = objects;
- serial = _database->addOrUpdateObjectsInDatabase(objects);
+ Lock sync(*this);
+ if(_destroy)
+ {
+ throw Ice::ObjectNotExistException(__FILE__, __LINE__);
+ }
+ _replicaWellKnownObjects = objects;
+ serial = _database->addOrUpdateObjectsInDatabase(objects);
}
//
@@ -147,13 +147,13 @@ ReplicaSessionI::registerWellKnownObjects(const ObjectInfoSeq& objects, const Ic
void
ReplicaSessionI::setAdapterDirectProxy(const string& adapterId,
- const string& replicaGroupId,
- const Ice::ObjectPrx& proxy,
- const Ice::Current&)
+ const string& replicaGroupId,
+ const Ice::ObjectPrx& proxy,
+ const Ice::Current&)
{
if(_database->getCommunicator()->getProperties()->getPropertyAsInt("IceGrid.Registry.DynamicRegistration") <= 0)
{
- throw AdapterNotExistException();
+ throw AdapterNotExistException();
}
_database->setAdapterDirectProxy(adapterId, replicaGroupId, proxy);
}
@@ -164,7 +164,7 @@ ReplicaSessionI::receivedUpdate(TopicName topicName, int serial, const string& f
ObserverTopicPtr topic = _database->getObserverTopic(topicName);
if(topic)
{
- topic->receivedUpdate(_info->name, serial, failure);
+ topic->receivedUpdate(_info->name, serial, failure);
}
}
@@ -180,7 +180,7 @@ ReplicaSessionI::timestamp() const
Lock sync(*this);
if(_destroy)
{
- throw Ice::ObjectNotExistException(__FILE__, __LINE__);
+ throw Ice::ObjectNotExistException(__FILE__, __LINE__);
}
return _timestamp;
}
@@ -215,7 +215,7 @@ ReplicaSessionI::getEndpoint(const std::string& name)
Lock sync(*this);
if(_destroy)
{
- return 0;
+ return 0;
}
return _replicaEndpoints[name];
}
@@ -231,38 +231,38 @@ void
ReplicaSessionI::destroyImpl(bool shutdown)
{
{
- Lock sync(*this);
- if(_destroy)
- {
- throw Ice::ObjectNotExistException(__FILE__, __LINE__);
- }
- _destroy = true;
+ Lock sync(*this);
+ if(_destroy)
+ {
+ throw Ice::ObjectNotExistException(__FILE__, __LINE__);
+ }
+ _destroy = true;
}
if(_observer)
{
- _database->getObserverTopic(ApplicationObserverTopicName)->unsubscribe(_observer, _info->name);
- _database->getObserverTopic(AdapterObserverTopicName)->unsubscribe(_observer, _info->name);
- _database->getObserverTopic(ObjectObserverTopicName)->unsubscribe(_observer, _info->name);
+ _database->getObserverTopic(ApplicationObserverTopicName)->unsubscribe(_observer, _info->name);
+ _database->getObserverTopic(AdapterObserverTopicName)->unsubscribe(_observer, _info->name);
+ _database->getObserverTopic(ObjectObserverTopicName)->unsubscribe(_observer, _info->name);
}
if(!_replicaWellKnownObjects.empty())
{
- if(shutdown) // Don't remove the replica proxy from the database if the registry is being shutdown.
- {
- ObjectInfoSeq::iterator p = find(_replicaWellKnownObjects.begin(), _replicaWellKnownObjects.end(),
- _internalRegistry->ice_getIdentity());
- if(p != _replicaWellKnownObjects.end())
- {
- _replicaWellKnownObjects.erase(p);
- }
- }
- _database->removeObjectsInDatabase(_replicaWellKnownObjects);
+ if(shutdown) // Don't remove the replica proxy from the database if the registry is being shutdown.
+ {
+ ObjectInfoSeq::iterator p = find(_replicaWellKnownObjects.begin(), _replicaWellKnownObjects.end(),
+ _internalRegistry->ice_getIdentity());
+ if(p != _replicaWellKnownObjects.end())
+ {
+ _replicaWellKnownObjects.erase(p);
+ }
+ }
+ _database->removeObjectsInDatabase(_replicaWellKnownObjects);
}
if(!shutdown)
{
- _wellKnownObjects->updateReplicatedWellKnownObjects(); // No need to update these if we're shutting down.
+ _wellKnownObjects->updateReplicatedWellKnownObjects(); // No need to update these if we're shutting down.
}
//
@@ -280,12 +280,12 @@ ReplicaSessionI::destroyImpl(bool shutdown)
if(!shutdown)
{
- try
- {
- _database->getInternalAdapter()->remove(_proxy->ice_getIdentity());
- }
- catch(const Ice::ObjectAdapterDeactivatedException&)
- {
- }
+ try
+ {
+ _database->getInternalAdapter()->remove(_proxy->ice_getIdentity());
+ }
+ catch(const Ice::ObjectAdapterDeactivatedException&)
+ {
+ }
}
}
diff --git a/cpp/src/IceGrid/ReplicaSessionI.h b/cpp/src/IceGrid/ReplicaSessionI.h
index 0f9e37b5e79..28701165ece 100644
--- a/cpp/src/IceGrid/ReplicaSessionI.h
+++ b/cpp/src/IceGrid/ReplicaSessionI.h
@@ -30,7 +30,7 @@ class ReplicaSessionI : public ReplicaSession, public IceUtil::Mutex
public:
ReplicaSessionI(const DatabasePtr&, const WellKnownObjectsManagerPtr&, const InternalReplicaInfoPtr&,
- const InternalRegistryPrx&, int);
+ const InternalRegistryPrx&, int);
virtual void keepAlive(const Ice::Current&);
virtual int getTimeout(const Ice::Current&) const;
@@ -38,7 +38,7 @@ public:
virtual void setEndpoints(const StringObjectProxyDict&, const Ice::Current&);
virtual void registerWellKnownObjects(const ObjectInfoSeq&, const Ice::Current&);
virtual void setAdapterDirectProxy(const std::string&, const std::string&, const Ice::ObjectPrx&,
- const Ice::Current&);
+ const Ice::Current&);
virtual void receivedUpdate(TopicName, int, const std::string&, const Ice::Current&);
virtual void destroy(const Ice::Current& = Ice::Current());
diff --git a/cpp/src/IceGrid/ReplicaSessionManager.cpp b/cpp/src/IceGrid/ReplicaSessionManager.cpp
index f241b51eb62..0dd232d5247 100644
--- a/cpp/src/IceGrid/ReplicaSessionManager.cpp
+++ b/cpp/src/IceGrid/ReplicaSessionManager.cpp
@@ -24,197 +24,197 @@ class MasterDatabaseObserverI : public DatabaseObserver, public IceUtil::Mutex
public:
MasterDatabaseObserverI(const ReplicaSessionManager::ThreadPtr& thread,
- const DatabasePtr& database,
- const ReplicaSessionPrx& session) :
- _thread(thread),
- _database(database),
- _session(session)
+ const DatabasePtr& database,
+ const ReplicaSessionPrx& session) :
+ _thread(thread),
+ _database(database),
+ _session(session)
{
}
virtual void
applicationInit(int, const ApplicationInfoSeq& applications, const Ice::Current& current)
{
- _database->syncApplications(applications);
- receivedUpdate(ApplicationObserverTopicName, getSerial(current.ctx));
+ _database->syncApplications(applications);
+ receivedUpdate(ApplicationObserverTopicName, getSerial(current.ctx));
}
virtual void
applicationAdded(int, const ApplicationInfo& application, const Ice::Current& current)
{
- string failure;
- try
- {
- _database->addApplication(application);
- }
- catch(const DeploymentException& ex)
- {
- ostringstream os;
- os << ex << ":\n" << ex.reason;
- failure = os.str();
- }
- receivedUpdate(ApplicationObserverTopicName, getSerial(current.ctx), failure);
+ string failure;
+ try
+ {
+ _database->addApplication(application);
+ }
+ catch(const DeploymentException& ex)
+ {
+ ostringstream os;
+ os << ex << ":\n" << ex.reason;
+ failure = os.str();
+ }
+ receivedUpdate(ApplicationObserverTopicName, getSerial(current.ctx), failure);
}
virtual void
applicationRemoved(int, const std::string& name, const Ice::Current& current)
{
- string failure;
- try
- {
- _database->removeApplication(name);
- }
- catch(const ApplicationNotExistException& ex)
- {
- ostringstream os;
- os << ex << ":\napplication: " << ex.name;
- failure = os.str();
- }
- receivedUpdate(ApplicationObserverTopicName, getSerial(current.ctx), failure);
+ string failure;
+ try
+ {
+ _database->removeApplication(name);
+ }
+ catch(const ApplicationNotExistException& ex)
+ {
+ ostringstream os;
+ os << ex << ":\napplication: " << ex.name;
+ failure = os.str();
+ }
+ receivedUpdate(ApplicationObserverTopicName, getSerial(current.ctx), failure);
}
virtual void
applicationUpdated(int, const ApplicationUpdateInfo& update, const Ice::Current& current)
{
- string failure;
- try
- {
- _database->updateApplication(update);
- }
- catch(const DeploymentException& ex)
- {
- ostringstream os;
- os << ex << ":\n" << ex.reason;
- failure = os.str();
- }
- catch(const ApplicationNotExistException& ex)
- {
- ostringstream os;
- os << ex << ":\napplication: " << ex.name;
- failure = os.str();
- }
- receivedUpdate(ApplicationObserverTopicName, getSerial(current.ctx), failure);
+ string failure;
+ try
+ {
+ _database->updateApplication(update);
+ }
+ catch(const DeploymentException& ex)
+ {
+ ostringstream os;
+ os << ex << ":\n" << ex.reason;
+ failure = os.str();
+ }
+ catch(const ApplicationNotExistException& ex)
+ {
+ ostringstream os;
+ os << ex << ":\napplication: " << ex.name;
+ failure = os.str();
+ }
+ receivedUpdate(ApplicationObserverTopicName, getSerial(current.ctx), failure);
}
virtual void
adapterInit(const AdapterInfoSeq& adapters, const Ice::Current& current)
{
- _database->syncAdapters(adapters);
- receivedUpdate(AdapterObserverTopicName, getSerial(current.ctx));
+ _database->syncAdapters(adapters);
+ receivedUpdate(AdapterObserverTopicName, getSerial(current.ctx));
}
virtual void
adapterAdded(const AdapterInfo& info, const Ice::Current& current)
{
- string failure;
- try
- {
- _database->setAdapterDirectProxy(info.id, info.replicaGroupId, info.proxy);
- }
- catch(const AdapterExistsException&)
- {
- failure = "adapter `" + info.id + "' already exists and belongs to an application";
- }
- receivedUpdate(AdapterObserverTopicName, getSerial(current.ctx), failure);
+ string failure;
+ try
+ {
+ _database->setAdapterDirectProxy(info.id, info.replicaGroupId, info.proxy);
+ }
+ catch(const AdapterExistsException&)
+ {
+ failure = "adapter `" + info.id + "' already exists and belongs to an application";
+ }
+ receivedUpdate(AdapterObserverTopicName, getSerial(current.ctx), failure);
}
virtual void
adapterUpdated(const AdapterInfo& info, const Ice::Current& current)
{
- string failure;
- try
- {
- _database->setAdapterDirectProxy(info.id, info.replicaGroupId, info.proxy);
- }
- catch(const AdapterExistsException&)
- {
- failure = "adapter `" + info.id + "' already exists and belongs to an application";
- }
- receivedUpdate(AdapterObserverTopicName, getSerial(current.ctx), failure);
+ string failure;
+ try
+ {
+ _database->setAdapterDirectProxy(info.id, info.replicaGroupId, info.proxy);
+ }
+ catch(const AdapterExistsException&)
+ {
+ failure = "adapter `" + info.id + "' already exists and belongs to an application";
+ }
+ receivedUpdate(AdapterObserverTopicName, getSerial(current.ctx), failure);
}
virtual void
adapterRemoved(const std::string& id, const Ice::Current& current)
{
- string failure;
- try
- {
- _database->setAdapterDirectProxy(id, "", 0);
- }
- catch(const AdapterExistsException&)
- {
- failure = "adapter `" + id + "' already exists and belongs to an application";
- }
- receivedUpdate(AdapterObserverTopicName, getSerial(current.ctx), failure);
+ string failure;
+ try
+ {
+ _database->setAdapterDirectProxy(id, "", 0);
+ }
+ catch(const AdapterExistsException&)
+ {
+ failure = "adapter `" + id + "' already exists and belongs to an application";
+ }
+ receivedUpdate(AdapterObserverTopicName, getSerial(current.ctx), failure);
}
virtual void
objectInit(const ObjectInfoSeq& objects, const Ice::Current& current)
{
- _database->syncObjects(objects);
- receivedUpdate(ObjectObserverTopicName, getSerial(current.ctx));
+ _database->syncObjects(objects);
+ receivedUpdate(ObjectObserverTopicName, getSerial(current.ctx));
}
virtual void
objectAdded(const ObjectInfo& info, const Ice::Current& current)
{
- string failure;
- try
- {
- _database->addOrUpdateObject(info);
- }
- catch(const ObjectExistsException& ex)
- {
- ostringstream os;
- os << ex << ":\n";
- os << "id: " << info.proxy->ice_getCommunicator()->identityToString(info.proxy->ice_getIdentity());
- failure = os.str();
- }
- receivedUpdate(ObjectObserverTopicName, getSerial(current.ctx), failure);
+ string failure;
+ try
+ {
+ _database->addOrUpdateObject(info);
+ }
+ catch(const ObjectExistsException& ex)
+ {
+ ostringstream os;
+ os << ex << ":\n";
+ os << "id: " << info.proxy->ice_getCommunicator()->identityToString(info.proxy->ice_getIdentity());
+ failure = os.str();
+ }
+ receivedUpdate(ObjectObserverTopicName, getSerial(current.ctx), failure);
}
virtual void
objectUpdated(const ObjectInfo& info, const Ice::Current& current)
{
- string failure;
- try
- {
- _database->addOrUpdateObject(info);
- }
- catch(const ObjectExistsException& ex)
- {
- ostringstream os;
- os << ex << ":\n";
- os << "id: " << info.proxy->ice_getCommunicator()->identityToString(info.proxy->ice_getIdentity());
- failure = os.str();
- }
- catch(const DeploymentException& ex)
- {
- ostringstream os;
- os << ex << ":\n" << ex.reason;
- failure = os.str();
- }
- receivedUpdate(ObjectObserverTopicName, getSerial(current.ctx), failure);
+ string failure;
+ try
+ {
+ _database->addOrUpdateObject(info);
+ }
+ catch(const ObjectExistsException& ex)
+ {
+ ostringstream os;
+ os << ex << ":\n";
+ os << "id: " << info.proxy->ice_getCommunicator()->identityToString(info.proxy->ice_getIdentity());
+ failure = os.str();
+ }
+ catch(const DeploymentException& ex)
+ {
+ ostringstream os;
+ os << ex << ":\n" << ex.reason;
+ failure = os.str();
+ }
+ receivedUpdate(ObjectObserverTopicName, getSerial(current.ctx), failure);
}
virtual void
objectRemoved(const Ice::Identity& id, const Ice::Current& current)
{
- string failure;
- try
- {
- _database->removeObject(id);
- }
- catch(const DeploymentException& ex)
- {
- ostringstream os;
- os << ex << ":\n" << ex.reason;
- failure = os.str();
- }
- catch(const ObjectNotRegisteredException&)
- {
- }
- receivedUpdate(ObjectObserverTopicName, getSerial(current.ctx), failure);
+ string failure;
+ try
+ {
+ _database->removeObject(id);
+ }
+ catch(const DeploymentException& ex)
+ {
+ ostringstream os;
+ os << ex << ":\n" << ex.reason;
+ failure = os.str();
+ }
+ catch(const ObjectNotRegisteredException&)
+ {
+ }
+ receivedUpdate(ObjectObserverTopicName, getSerial(current.ctx), failure);
}
private:
@@ -222,31 +222,31 @@ private:
int
getSerial(const Ice::Context& context)
{
- Ice::Context::const_iterator p = context.find("serial");
- if(p != context.end())
- {
- int serial;
- istringstream is(p->second);
- is >> serial;
- return serial;
- }
- return -1;
+ Ice::Context::const_iterator p = context.find("serial");
+ if(p != context.end())
+ {
+ int serial;
+ istringstream is(p->second);
+ is >> serial;
+ return serial;
+ }
+ return -1;
}
void
receivedUpdate(TopicName name, int serial, const string& failure = string())
{
- try
- {
- _session->receivedUpdate(name, serial, failure);
- }
- catch(const Ice::LocalException&)
- {
- }
- if(!failure.empty())
- {
- _thread->destroyActiveSession();
- }
+ try
+ {
+ _session->receivedUpdate(name, serial, failure);
+ }
+ catch(const Ice::LocalException&)
+ {
+ }
+ if(!failure.empty())
+ {
+ _thread->destroyActiveSession();
+ }
}
const ReplicaSessionManager::ThreadPtr _thread;
@@ -263,47 +263,47 @@ ReplicaSessionManager::ReplicaSessionManager()
void
ReplicaSessionManager::create(const string& name,
- const InternalReplicaInfoPtr& info,
- const DatabasePtr& database,
- const WellKnownObjectsManagerPtr& wellKnownObjects,
- const InternalRegistryPrx& internalRegistry)
+ const InternalReplicaInfoPtr& info,
+ const DatabasePtr& database,
+ const WellKnownObjectsManagerPtr& wellKnownObjects,
+ const InternalRegistryPrx& internalRegistry)
{
Ice::CommunicatorPtr comm = database->getCommunicator();
{
- Lock sync(*this);
-
- Ice::Identity id;
- id.category = comm->getDefaultLocator()->ice_getIdentity().category;
- id.name = "InternalRegistry-Master";
-
- _master = InternalRegistryPrx::uncheckedCast(comm->stringToProxy(comm->identityToString(id)));
- _name = name;
- _info = info;
- _internalRegistry = internalRegistry;
- _database = database;
- _wellKnownObjects = wellKnownObjects;
- _traceLevels = _database->getTraceLevels();
-
- //
- // Initialize the IceGrid::Query objects. The IceGrid::Query
- // interface is used to lookup the registry proxy in case it
- // becomes unavailable. Since replicas might not always have
- // an up to date registry proxy, we need to query all the
- // replicas.
- //
- Ice::EndpointSeq endpoints = comm->getDefaultLocator()->ice_getEndpoints();
- id.name = "Query";
- QueryPrx query = QueryPrx::uncheckedCast(comm->stringToProxy(comm->identityToString(id)));
- for(Ice::EndpointSeq::const_iterator p = endpoints.begin(); p != endpoints.end(); ++p)
- {
- Ice::EndpointSeq singleEndpoint;
- singleEndpoint.push_back(*p);
- _queryObjects.push_back(QueryPrx::uncheckedCast(query->ice_endpoints(singleEndpoint)));
- }
-
- _thread = new Thread(*this, _master);
- _thread->start();
- notifyAll();
+ Lock sync(*this);
+
+ Ice::Identity id;
+ id.category = comm->getDefaultLocator()->ice_getIdentity().category;
+ id.name = "InternalRegistry-Master";
+
+ _master = InternalRegistryPrx::uncheckedCast(comm->stringToProxy(comm->identityToString(id)));
+ _name = name;
+ _info = info;
+ _internalRegistry = internalRegistry;
+ _database = database;
+ _wellKnownObjects = wellKnownObjects;
+ _traceLevels = _database->getTraceLevels();
+
+ //
+ // Initialize the IceGrid::Query objects. The IceGrid::Query
+ // interface is used to lookup the registry proxy in case it
+ // becomes unavailable. Since replicas might not always have
+ // an up to date registry proxy, we need to query all the
+ // replicas.
+ //
+ Ice::EndpointSeq endpoints = comm->getDefaultLocator()->ice_getEndpoints();
+ id.name = "Query";
+ QueryPrx query = QueryPrx::uncheckedCast(comm->stringToProxy(comm->identityToString(id)));
+ for(Ice::EndpointSeq::const_iterator p = endpoints.begin(); p != endpoints.end(); ++p)
+ {
+ Ice::EndpointSeq singleEndpoint;
+ singleEndpoint.push_back(*p);
+ _queryObjects.push_back(QueryPrx::uncheckedCast(query->ice_endpoints(singleEndpoint)));
+ }
+
+ _thread = new Thread(*this, _master);
+ _thread->start();
+ notifyAll();
}
_thread->tryCreateSession();
@@ -313,17 +313,17 @@ void
ReplicaSessionManager::create(const InternalRegistryPrx& replica)
{
{
- Lock sync(*this);
- while(!_master) // Wait to be initialized.
- {
- wait();
- }
+ Lock sync(*this);
+ while(!_master) // Wait to be initialized.
+ {
+ wait();
+ }
}
if(replica->ice_getIdentity() != _master->ice_getIdentity())
{
- _database->getTraceLevels()->logger->error("can only create sessions with the master replica");
- return;
+ _database->getTraceLevels()->logger->error("can only create sessions with the master replica");
+ return;
}
_thread->setRegistry(replica);
@@ -336,11 +336,11 @@ ReplicaSessionManager::getNodes(const NodePrxSeq& nodes) const
assert(_thread && _thread->getRegistry());
try
{
- return _thread->getRegistry()->getNodes();
+ return _thread->getRegistry()->getNodes();
}
catch(const Ice::LocalException&)
{
- return nodes;
+ return nodes;
}
}
@@ -348,11 +348,11 @@ void
ReplicaSessionManager::destroy()
{
{
- Lock sync(*this);
- if(!_thread)
- {
- return;
- }
+ Lock sync(*this);
+ if(!_thread)
+ {
+ return;
+ }
}
_thread->terminate();
@@ -380,14 +380,14 @@ ReplicaSessionManager::registerAllWellKnownObjects()
ReplicaSessionPrx session = _thread->getSession();
if(session)
{
- try
- {
- _wellKnownObjects->registerAll(session);
- return;
- }
- catch(const Ice::LocalException&)
- {
- }
+ try
+ {
+ _wellKnownObjects->registerAll(session);
+ return;
+ }
+ catch(const Ice::LocalException&)
+ {
+ }
}
}
@@ -396,23 +396,23 @@ ReplicaSessionManager::keepAlive(const ReplicaSessionPrx& session)
{
try
{
- if(_traceLevels && _traceLevels->replica > 2)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->replicaCat);
- out << "sending keep alive message to master replica";
- }
+ if(_traceLevels && _traceLevels->replica > 2)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->replicaCat);
+ out << "sending keep alive message to master replica";
+ }
- session->keepAlive();
- return true;
+ session->keepAlive();
+ return true;
}
catch(const Ice::LocalException& ex)
{
- if(_traceLevels && _traceLevels->replica > 0)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->replicaCat);
- out << "lost session with master replica:\n" << ex;
- }
- return false;
+ if(_traceLevels && _traceLevels->replica > 0)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->replicaCat);
+ out << "lost session with master replica:\n" << ex;
+ }
+ return false;
}
}
@@ -423,141 +423,141 @@ ReplicaSessionManager::createSession(InternalRegistryPrx& registry, IceUtil::Tim
auto_ptr<Ice::Exception> exception;
try
{
- if(_traceLevels && _traceLevels->replica > 1)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->replicaCat);
- out << "trying to establish session with master replica";
- }
-
- set<InternalRegistryPrx> used;
- if(!registry->ice_getEndpoints().empty())
- {
- try
- {
- session = createSessionImpl(registry, timeout);
- }
- catch(const Ice::LocalException& ex)
- {
- exception.reset(ex.ice_clone());
- used.insert(registry);
- registry = InternalRegistryPrx::uncheckedCast(registry->ice_endpoints(Ice::EndpointSeq()));
- }
- }
-
- if(!session)
- {
- for(vector<QueryPrx>::const_iterator p = _queryObjects.begin(); p != _queryObjects.end(); ++p)
- {
- InternalRegistryPrx newRegistry;
- try
- {
- Ice::ObjectPrx obj = (*p)->findObjectById(registry->ice_getIdentity());
- newRegistry = InternalRegistryPrx::uncheckedCast(obj);
- if(newRegistry && used.find(newRegistry) == used.end())
- {
- session = createSessionImpl(newRegistry, timeout);
- registry = newRegistry;
- break;
- }
- }
- catch(const Ice::LocalException& ex)
- {
- exception.reset(ex.ice_clone());
- if(newRegistry)
- {
- used.insert(newRegistry);
- }
- }
- }
- }
+ if(_traceLevels && _traceLevels->replica > 1)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->replicaCat);
+ out << "trying to establish session with master replica";
+ }
+
+ set<InternalRegistryPrx> used;
+ if(!registry->ice_getEndpoints().empty())
+ {
+ try
+ {
+ session = createSessionImpl(registry, timeout);
+ }
+ catch(const Ice::LocalException& ex)
+ {
+ exception.reset(ex.ice_clone());
+ used.insert(registry);
+ registry = InternalRegistryPrx::uncheckedCast(registry->ice_endpoints(Ice::EndpointSeq()));
+ }
+ }
+
+ if(!session)
+ {
+ for(vector<QueryPrx>::const_iterator p = _queryObjects.begin(); p != _queryObjects.end(); ++p)
+ {
+ InternalRegistryPrx newRegistry;
+ try
+ {
+ Ice::ObjectPrx obj = (*p)->findObjectById(registry->ice_getIdentity());
+ newRegistry = InternalRegistryPrx::uncheckedCast(obj);
+ if(newRegistry && used.find(newRegistry) == used.end())
+ {
+ session = createSessionImpl(newRegistry, timeout);
+ registry = newRegistry;
+ break;
+ }
+ }
+ catch(const Ice::LocalException& ex)
+ {
+ exception.reset(ex.ice_clone());
+ if(newRegistry)
+ {
+ used.insert(newRegistry);
+ }
+ }
+ }
+ }
}
catch(const ReplicaActiveException& ex)
{
- if(_traceLevels)
- {
- _traceLevels->logger->error("a replica with the same name is already registered and active");
- }
- exception.reset(ex.ice_clone());
+ if(_traceLevels)
+ {
+ _traceLevels->logger->error("a replica with the same name is already registered and active");
+ }
+ exception.reset(ex.ice_clone());
}
catch(const Ice::Exception& ex)
{
- exception.reset(ex.ice_clone());
+ exception.reset(ex.ice_clone());
}
if(session)
{
- //
- // Register all the well-known objects with the replica session.
- //
- _wellKnownObjects->registerAll(session);
+ //
+ // Register all the well-known objects with the replica session.
+ //
+ _wellKnownObjects->registerAll(session);
}
else
{
- //
- // Re-register all the well known objects with the local database.
- //
- _wellKnownObjects->registerAll();
+ //
+ // Re-register all the well known objects with the local database.
+ //
+ _wellKnownObjects->registerAll();
}
if(_traceLevels && _traceLevels->replica > 0)
{
- Ice::Trace out(_traceLevels->logger, _traceLevels->replicaCat);
- if(session)
- {
- out << "established session with master replica";
- }
- else
- {
- out << "failed to establish session with master replica:\n";
- if(exception.get())
- {
- out << *exception.get();
- }
- else
- {
- out << "failed to get replica proxy";
- }
- }
+ Ice::Trace out(_traceLevels->logger, _traceLevels->replicaCat);
+ if(session)
+ {
+ out << "established session with master replica";
+ }
+ else
+ {
+ out << "failed to establish session with master replica:\n";
+ if(exception.get())
+ {
+ out << *exception.get();
+ }
+ else
+ {
+ out << "failed to get replica proxy";
+ }
+ }
}
return session;
}
ReplicaSessionPrx
ReplicaSessionManager::createSessionImpl(const InternalRegistryPrx& registry, IceUtil::Time& timeout)
-{
+{
try
{
- ReplicaSessionPrx session = registry->registerReplica(_info, _internalRegistry);
- int t = session->getTimeout();
- if(t > 0)
- {
- timeout = IceUtil::Time::seconds(t / 2);
- }
-
- //
- // Create a new database observer servant and give its proxy
- // to the session so that it can subscribe it. This call only
- // returns once the observer is subscribed and initialized.
- //
- DatabaseObserverPtr servant = new MasterDatabaseObserverI(_thread, _database, session);
- _observer = DatabaseObserverPrx::uncheckedCast(_database->getInternalAdapter()->addWithUUID(servant));
- session->setDatabaseObserver(_observer);
- return session;
+ ReplicaSessionPrx session = registry->registerReplica(_info, _internalRegistry);
+ int t = session->getTimeout();
+ if(t > 0)
+ {
+ timeout = IceUtil::Time::seconds(t / 2);
+ }
+
+ //
+ // Create a new database observer servant and give its proxy
+ // to the session so that it can subscribe it. This call only
+ // returns once the observer is subscribed and initialized.
+ //
+ DatabaseObserverPtr servant = new MasterDatabaseObserverI(_thread, _database, session);
+ _observer = DatabaseObserverPrx::uncheckedCast(_database->getInternalAdapter()->addWithUUID(servant));
+ session->setDatabaseObserver(_observer);
+ return session;
}
catch(const Ice::LocalException&)
{
- if(_observer)
- {
- try
- {
- _database->getInternalAdapter()->remove(_observer->ice_getIdentity());
- }
- catch(const Ice::LocalException&)
- {
- }
- _observer = 0;
- }
- throw;
+ if(_observer)
+ {
+ try
+ {
+ _database->getInternalAdapter()->remove(_observer->ice_getIdentity());
+ }
+ catch(const Ice::LocalException&)
+ {
+ }
+ _observer = 0;
+ }
+ throw;
}
}
@@ -566,33 +566,33 @@ ReplicaSessionManager::destroySession(const ReplicaSessionPrx& session)
{
try
{
- session->destroy();
+ session->destroy();
- if(_traceLevels && _traceLevels->replica > 0)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->replicaCat);
- out << "destroyed master replica session";
- }
+ if(_traceLevels && _traceLevels->replica > 0)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->replicaCat);
+ out << "destroyed master replica session";
+ }
}
catch(const Ice::LocalException& ex)
{
- if(_traceLevels && _traceLevels->replica > 1)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->replicaCat);
- out << "couldn't destroy master replica session:\n" << ex;
- }
+ if(_traceLevels && _traceLevels->replica > 1)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->replicaCat);
+ out << "couldn't destroy master replica session:\n" << ex;
+ }
}
if(_observer)
{
- try
- {
- _database->getInternalAdapter()->remove(_observer->ice_getIdentity());
- }
- catch(const Ice::LocalException&)
- {
- }
- _observer = 0;
+ try
+ {
+ _database->getInternalAdapter()->remove(_observer->ice_getIdentity());
+ }
+ catch(const Ice::LocalException&)
+ {
+ }
+ _observer = 0;
}
}
diff --git a/cpp/src/IceGrid/ReplicaSessionManager.h b/cpp/src/IceGrid/ReplicaSessionManager.h
index 32658fed0bf..21a1a261710 100644
--- a/cpp/src/IceGrid/ReplicaSessionManager.h
+++ b/cpp/src/IceGrid/ReplicaSessionManager.h
@@ -37,42 +37,42 @@ public:
{
public:
- Thread(ReplicaSessionManager& manager, const InternalRegistryPrx& master) :
- SessionKeepAliveThread<ReplicaSessionPrx>(master),
- _manager(manager)
+ Thread(ReplicaSessionManager& manager, const InternalRegistryPrx& master) :
+ SessionKeepAliveThread<ReplicaSessionPrx>(master),
+ _manager(manager)
{
- }
+ }
- virtual ReplicaSessionPrx
- createSession(InternalRegistryPrx& master, IceUtil::Time& timeout)
+ virtual ReplicaSessionPrx
+ createSession(InternalRegistryPrx& master, IceUtil::Time& timeout)
{
- return _manager.createSession(master, timeout);
- }
+ return _manager.createSession(master, timeout);
+ }
- virtual void
- destroySession(const ReplicaSessionPrx& session)
+ virtual void
+ destroySession(const ReplicaSessionPrx& session)
{
- _manager.destroySession(session);
- }
+ _manager.destroySession(session);
+ }
- virtual bool
- keepAlive(const ReplicaSessionPrx& session)
+ virtual bool
+ keepAlive(const ReplicaSessionPrx& session)
{
- return _manager.keepAlive(session);
- }
+ return _manager.keepAlive(session);
+ }
- void registerAllWellKnownObjects();
+ void registerAllWellKnownObjects();
private:
-
- ReplicaSessionManager& _manager;
+
+ ReplicaSessionManager& _manager;
};
typedef IceUtil::Handle<Thread> ThreadPtr;
ReplicaSessionManager();
void create(const std::string&, const InternalReplicaInfoPtr&, const DatabasePtr&,
- const WellKnownObjectsManagerPtr&, const InternalRegistryPrx&);
+ const WellKnownObjectsManagerPtr&, const InternalRegistryPrx&);
void create(const InternalRegistryPrx&);
NodePrxSeq getNodes(const NodePrxSeq&) const;
void destroy();
diff --git a/cpp/src/IceGrid/ServerAdapterI.cpp b/cpp/src/IceGrid/ServerAdapterI.cpp
index abf97e7ed12..52a63bb3de1 100644
--- a/cpp/src/IceGrid/ServerAdapterI.cpp
+++ b/cpp/src/IceGrid/ServerAdapterI.cpp
@@ -17,10 +17,10 @@ using namespace std;
using namespace IceGrid;
ServerAdapterI::ServerAdapterI(const NodeIPtr& node,
- ServerI* server,
- const string& serverName,
- const AdapterPrx& proxy,
- const string& id) :
+ ServerI* server,
+ const string& serverName,
+ const AdapterPrx& proxy,
+ const string& id) :
_node(node),
_this(proxy),
_serverId(serverName),
@@ -37,39 +37,39 @@ void
ServerAdapterI::activate_async(const AMD_Adapter_activatePtr& cb, const Ice::Current& current)
{
{
- Lock sync(*this);
- if(_proxy)
- {
- //
- // Return the adapter direct proxy.
- //
- cb->ice_response(_proxy);
- return;
- }
- else if(_activateCB.empty())
- {
- //
- // Nothing else waits for this adapter so we must make sure that this
- // adapter if still activatable.
- //
- if(!_server->isAdapterActivatable(_id))
- {
- cb->ice_response(0);
- return;
- }
- }
-
- if(_node->getTraceLevels()->adapter > 2)
- {
- Ice::Trace out(_node->getTraceLevels()->logger, _node->getTraceLevels()->adapterCat);
- out << "waiting for activation of server `" + _serverId + "' adapter `" << _id << "'";
- }
-
- _activateCB.push_back(cb);
- if(_activateCB.size() > 1)
- {
- return;
- }
+ Lock sync(*this);
+ if(_proxy)
+ {
+ //
+ // Return the adapter direct proxy.
+ //
+ cb->ice_response(_proxy);
+ return;
+ }
+ else if(_activateCB.empty())
+ {
+ //
+ // Nothing else waits for this adapter so we must make sure that this
+ // adapter if still activatable.
+ //
+ if(!_server->isAdapterActivatable(_id))
+ {
+ cb->ice_response(0);
+ return;
+ }
+ }
+
+ if(_node->getTraceLevels()->adapter > 2)
+ {
+ Ice::Trace out(_node->getTraceLevels()->logger, _node->getTraceLevels()->adapterCat);
+ out << "waiting for activation of server `" + _serverId + "' adapter `" << _id << "'";
+ }
+
+ _activateCB.push_back(cb);
+ if(_activateCB.size() > 1)
+ {
+ return;
+ }
}
//
@@ -79,21 +79,21 @@ ServerAdapterI::activate_async(const AMD_Adapter_activatePtr& cb, const Ice::Cur
//
try
{
- _server->start(ServerI::OnDemand);
- return;
+ _server->start(ServerI::OnDemand);
+ return;
}
catch(const ServerStartException& ex)
{
- activationFailed(ex.reason);
+ activationFailed(ex.reason);
}
catch(const Ice::ObjectNotExistException&)
{
- //
- // The server associated to this adapter doesn't exist anymore. Somehow the database is
- // inconsistent if this happens. The best thing to do is to destroy the adapter.
- //
- destroy();
- activationFailed("server destroyed");
+ //
+ // The server associated to this adapter doesn't exist anymore. Somehow the database is
+ // inconsistent if this happens. The best thing to do is to destroy the adapter.
+ //
+ destroy();
+ activationFailed("server destroyed");
}
}
@@ -108,13 +108,13 @@ ServerAdapterI::getDirectProxy(const Ice::Current& current) const
//
if(_proxy)
{
- return _proxy;
+ return _proxy;
}
else
{
- AdapterNotActiveException ex;
- ex.activatable = _server->isAdapterActivatable(_id);
- throw ex;
+ AdapterNotActiveException ex;
+ ex.activatable = _server->isAdapterActivatable(_id);
+ throw ex;
}
}
@@ -129,10 +129,10 @@ ServerAdapterI::setDirectProxy(const Ice::ObjectPrx& prx, const Ice::Current&)
//
if(prx && _proxy)
{
- if(_server->getState() == Active)
- {
- throw AdapterActiveException();
- }
+ if(_server->getState() == Active)
+ {
+ throw AdapterActiveException();
+ }
}
bool updated = _proxy != prx;
@@ -140,35 +140,35 @@ ServerAdapterI::setDirectProxy(const Ice::ObjectPrx& prx, const Ice::Current&)
for(vector<AMD_Adapter_activatePtr>::const_iterator p = _activateCB.begin(); p != _activateCB.end(); ++p)
{
- (*p)->ice_response(_proxy);
+ (*p)->ice_response(_proxy);
}
_activateCB.clear();
if(updated)
{
- AdapterDynamicInfo info;
- info.id = _id;
- info.proxy = _proxy;
- _node->observerUpdateAdapter(info);
+ AdapterDynamicInfo info;
+ info.id = _id;
+ info.proxy = _proxy;
+ _node->observerUpdateAdapter(info);
}
if(_proxy)
{
- _server->adapterActivated(_id);
+ _server->adapterActivated(_id);
}
else
{
- _server->adapterDeactivated(_id);
+ _server->adapterDeactivated(_id);
}
if(_node->getTraceLevels()->adapter > 1)
{
- Ice::Trace out(_node->getTraceLevels()->logger, _node->getTraceLevels()->adapterCat);
- out << "server `" + _serverId + "' adapter `" << _id << "' " << (_proxy ? "activated" : "deactivated");
- if(_proxy)
- {
- out << ": " << _node->getCommunicator()->proxyToString(_proxy);
- }
+ Ice::Trace out(_node->getTraceLevels()->logger, _node->getTraceLevels()->adapterCat);
+ out << "server `" + _serverId + "' adapter `" << _id << "' " << (_proxy ? "activated" : "deactivated");
+ if(_proxy)
+ {
+ out << ": " << _node->getCommunicator()->proxyToString(_proxy);
+ }
}
}
@@ -194,14 +194,14 @@ ServerAdapterI::activationFailed(const std::string& reason)
//
if(_node->getTraceLevels()->adapter > 1)
{
- Ice::Trace out(_node->getTraceLevels()->logger, _node->getTraceLevels()->adapterCat);
- out << "server `" + _serverId + "' adapter `" << _id << "' activation failed: " << reason;
+ Ice::Trace out(_node->getTraceLevels()->logger, _node->getTraceLevels()->adapterCat);
+ out << "server `" + _serverId + "' adapter `" << _id << "' activation failed: " << reason;
}
Lock sync(*this);
for(vector<AMD_Adapter_activatePtr>::const_iterator p = _activateCB.begin(); p != _activateCB.end(); ++p)
{
- (*p)->ice_response(0);
+ (*p)->ice_response(0);
}
_activateCB.clear();
}
diff --git a/cpp/src/IceGrid/ServerCache.cpp b/cpp/src/IceGrid/ServerCache.cpp
index 36c8a917717..14030eea69b 100644
--- a/cpp/src/IceGrid/ServerCache.cpp
+++ b/cpp/src/IceGrid/ServerCache.cpp
@@ -26,45 +26,45 @@ namespace IceGrid
struct AddCommunicator : std::unary_function<CommunicatorDescriptorPtr&, void>
{
- AddCommunicator(ServerCache& serverCache, const ServerEntryPtr& entry, const string& application) :
- _serverCache(serverCache), _entry(entry), _application(application)
- {
- }
-
- void
- operator()(const CommunicatorDescriptorPtr& desc)
- {
- _serverCache.addCommunicator(desc, _entry, _application);
- }
-
- ServerCache& _serverCache;
- const ServerEntryPtr _entry;
- const string _application;
+ AddCommunicator(ServerCache& serverCache, const ServerEntryPtr& entry, const string& application) :
+ _serverCache(serverCache), _entry(entry), _application(application)
+ {
+ }
+
+ void
+ operator()(const CommunicatorDescriptorPtr& desc)
+ {
+ _serverCache.addCommunicator(desc, _entry, _application);
+ }
+
+ ServerCache& _serverCache;
+ const ServerEntryPtr _entry;
+ const string _application;
};
struct RemoveCommunicator : std::unary_function<CommunicatorDescriptorPtr&, void>
{
- RemoveCommunicator(ServerCache& serverCache, const ServerEntryPtr& entry) :
- _serverCache(serverCache), _entry(entry)
- {
- }
+ RemoveCommunicator(ServerCache& serverCache, const ServerEntryPtr& entry) :
+ _serverCache(serverCache), _entry(entry)
+ {
+ }
- void
- operator()(const CommunicatorDescriptorPtr& desc)
- {
- _serverCache.removeCommunicator(desc, _entry);
- }
+ void
+ operator()(const CommunicatorDescriptorPtr& desc)
+ {
+ _serverCache.removeCommunicator(desc, _entry);
+ }
- ServerCache& _serverCache;
- const ServerEntryPtr _entry;
+ ServerCache& _serverCache;
+ const ServerEntryPtr _entry;
};
}
ServerCache::ServerCache(const Ice::CommunicatorPtr& communicator,
- NodeCache& nodeCache,
- AdapterCache& adapterCache,
- ObjectCache& objectCache,
- AllocatableObjectCache& allocatableObjectCache) :
+ NodeCache& nodeCache,
+ AdapterCache& adapterCache,
+ ObjectCache& objectCache,
+ AllocatableObjectCache& allocatableObjectCache) :
_communicator(communicator),
_nodeCache(nodeCache),
_adapterCache(adapterCache),
@@ -81,8 +81,8 @@ ServerCache::add(const ServerInfo& info)
ServerEntryPtr entry = getImpl(info.descriptor->id);
if(!entry)
{
- entry = new ServerEntry(*this, info.descriptor->id);
- addImpl(info.descriptor->id, entry);
+ entry = new ServerEntry(*this, info.descriptor->id);
+ addImpl(info.descriptor->id, entry);
}
entry->update(info);
_nodeCache.get(info.node, true)->addServer(entry);
@@ -91,9 +91,9 @@ ServerCache::add(const ServerInfo& info)
if(_traceLevels && _traceLevels->server > 0)
{
- Ice::Trace out(_traceLevels->logger, _traceLevels->serverCat);
+ Ice::Trace out(_traceLevels->logger, _traceLevels->serverCat);
- out << "added server `" << info.descriptor->id << "' (`" << info.uuid << "', `" << info.revision << "')";
+ out << "added server `" << info.descriptor->id << "' (`" << info.uuid << "', `" << info.revision << "')";
}
return entry;
@@ -106,9 +106,9 @@ ServerCache::get(const string& id) const
ServerEntryPtr entry = getImpl(id);
if(!entry)
{
- ServerNotExistException ex;
- ex.id = id;
- throw ex;
+ ServerNotExistException ex;
+ ex.id = id;
+ throw ex;
}
return entry;
}
@@ -134,14 +134,14 @@ ServerCache::remove(const string& id, bool destroy)
if(destroy)
{
- entry->destroy(); // This must be done after otherwise some allocatable objects
- // might allocate a destroyed server.
+ entry->destroy(); // This must be done after otherwise some allocatable objects
+ // might allocate a destroyed server.
}
if(_traceLevels && _traceLevels->server > 0)
{
- Ice::Trace out(_traceLevels->logger, _traceLevels->serverCat);
- out << "removed server `" << id << "'";
+ Ice::Trace out(_traceLevels->logger, _traceLevels->serverCat);
+ out << "removed server `" << id << "'";
}
return entry;
@@ -156,30 +156,30 @@ ServerCache::clear(const string& id)
void
ServerCache::addCommunicator(const CommunicatorDescriptorPtr& comm,
- const ServerEntryPtr& server,
- const string& application)
+ const ServerEntryPtr& server,
+ const string& application)
{
for(AdapterDescriptorSeq::const_iterator q = comm->adapters.begin() ; q != comm->adapters.end(); ++q)
{
- assert(!q->id.empty());
- _adapterCache.addServerAdapter(*q, server, application);
+ assert(!q->id.empty());
+ _adapterCache.addServerAdapter(*q, server, application);
- ObjectDescriptorSeq::const_iterator r;
- for(r = q->objects.begin(); r != q->objects.end(); ++r)
- {
- ObjectInfo info;
- info.type = r->type;
- info.proxy = _communicator->stringToProxy("\"" + _communicator->identityToString(r->id) + "\" @ " + q->id);
- _objectCache.add(info, application);
- }
+ ObjectDescriptorSeq::const_iterator r;
+ for(r = q->objects.begin(); r != q->objects.end(); ++r)
+ {
+ ObjectInfo info;
+ info.type = r->type;
+ info.proxy = _communicator->stringToProxy("\"" + _communicator->identityToString(r->id) + "\" @ " + q->id);
+ _objectCache.add(info, application);
+ }
- for(r = q->allocatables.begin(); r != q->allocatables.end(); ++r)
- {
- ObjectInfo info;
- info.type = r->type;
- info.proxy = _communicator->stringToProxy("\"" + _communicator->identityToString(r->id) + "\" @ " + q->id);
- _allocatableObjectCache.add(info, server);
- }
+ for(r = q->allocatables.begin(); r != q->allocatables.end(); ++r)
+ {
+ ObjectInfo info;
+ info.type = r->type;
+ info.proxy = _communicator->stringToProxy("\"" + _communicator->identityToString(r->id) + "\" @ " + q->id);
+ _allocatableObjectCache.add(info, server);
+ }
}
}
@@ -188,16 +188,16 @@ ServerCache::removeCommunicator(const CommunicatorDescriptorPtr& comm, const Ser
{
for(AdapterDescriptorSeq::const_iterator q = comm->adapters.begin() ; q != comm->adapters.end(); ++q)
{
- ObjectDescriptorSeq::const_iterator r;
- for(r = q->objects.begin(); r != q->objects.end(); ++r)
- {
- _objectCache.remove(r->id);
- }
- for(r = q->allocatables.begin(); r != q->allocatables.end(); ++r)
- {
- _allocatableObjectCache.remove(r->id);
- }
- _adapterCache.removeServerAdapter(q->id);
+ ObjectDescriptorSeq::const_iterator r;
+ for(r = q->objects.begin(); r != q->objects.end(); ++r)
+ {
+ _objectCache.remove(r->id);
+ }
+ for(r = q->allocatables.begin(); r != q->allocatables.end(); ++r)
+ {
+ _allocatableObjectCache.remove(r->id);
+ }
+ _adapterCache.removeServerAdapter(q->id);
}
}
@@ -224,14 +224,14 @@ ServerEntry::syncAndWait()
syncImpl();
try
{
- waitImpl();
+ waitImpl();
}
catch(const NodeUnreachableException&)
{
- //
- // The node being unreachable isn't considered as a failure to
- // synchronize the server.
- //
+ //
+ // The node being unreachable isn't considered as a failure to
+ // synchronize the server.
+ //
}
}
@@ -240,7 +240,7 @@ ServerEntry::waitNoThrow()
{
try
{
- waitImpl();
+ waitImpl();
}
catch(const Ice::Exception&)
{
@@ -253,7 +253,7 @@ ServerEntry::unsync()
Lock sync(*this);
if(_loaded.get())
{
- _load = _loaded;
+ _load = _loaded;
}
_proxy = 0;
_adapters.clear();
@@ -273,14 +273,14 @@ ServerEntry::update(const ServerInfo& info)
if(!_destroy.get())
{
- if(_loaded.get() && descriptor->node != _loaded->node)
- {
- _destroy = _loaded;
- }
- else if(_load.get() && descriptor->node != _load->node)
- {
- _destroy = _load;
- }
+ if(_loaded.get() && descriptor->node != _loaded->node)
+ {
+ _destroy = _loaded;
+ }
+ else if(_load.get() && descriptor->node != _load->node)
+ {
+ _destroy = _load;
+ }
}
_load = descriptor;
@@ -298,16 +298,16 @@ ServerEntry::destroy()
assert(_loaded.get() || _load.get());
if(!_destroy.get())
{
- if(_loaded.get())
- {
- assert(!_destroy.get());
- _destroy = _loaded;
- }
- else if(_load.get())
- {
- assert(!_destroy.get());
- _destroy = _load;
- }
+ if(_loaded.get())
+ {
+ assert(!_destroy.get());
+ _destroy = _loaded;
+ }
+ else if(_load.get())
+ {
+ assert(!_destroy.get());
+ _destroy = _load;
+ }
}
_load.reset(0);
@@ -321,30 +321,30 @@ ServerEntry::getInfo(bool resolve) const
ServerInfo info;
SessionIPtr session;
{
- Lock sync(*this);
- if(!_loaded.get() && !_load.get())
- {
- throw ServerNotExistException();
- }
- info = _loaded.get() ? *_loaded : *_load;
- session = _session;
+ Lock sync(*this);
+ if(!_loaded.get() && !_load.get())
+ {
+ throw ServerNotExistException();
+ }
+ info = _loaded.get() ? *_loaded : *_load;
+ session = _session;
}
assert(info.descriptor);
if(resolve)
{
- try
- {
- return _cache.getNodeCache().get(info.node)->getServerInfo(info, session);
- }
- catch(const DeploymentException&)
- {
- }
- catch(const NodeNotExistException&)
- {
- }
- catch(const NodeUnreachableException&)
- {
- }
+ try
+ {
+ return _cache.getNodeCache().get(info.node)->getServerInfo(info, session);
+ }
+ catch(const DeploymentException&)
+ {
+ }
+ catch(const NodeNotExistException&)
+ {
+ }
+ catch(const NodeUnreachableException&)
+ {
+ }
}
return info;
}
@@ -367,45 +367,45 @@ ServerPrx
ServerEntry::getProxy(int& activationTimeout, int& deactivationTimeout, string& node, bool upToDate)
{
{
- Lock sync(*this);
- if(_loaded.get() || _proxy && _synchronizing && !upToDate) // Synced or if not up to date is fine
- {
- assert(_loaded.get() || _load.get() || _destroy.get());
- activationTimeout = _activationTimeout;
- deactivationTimeout = _deactivationTimeout;
- node = _loaded.get() ? _loaded->node : (_load.get() ? _load->node : _destroy->node);
- return _proxy;
- }
+ Lock sync(*this);
+ if(_loaded.get() || _proxy && _synchronizing && !upToDate) // Synced or if not up to date is fine
+ {
+ assert(_loaded.get() || _load.get() || _destroy.get());
+ activationTimeout = _activationTimeout;
+ deactivationTimeout = _deactivationTimeout;
+ node = _loaded.get() ? _loaded->node : (_load.get() ? _load->node : _destroy->node);
+ return _proxy;
+ }
}
while(true)
{
- //
- // Note that we don't call syncAndWait() because we want
- // NodeUnreachableException exceptions to go through.
- //
- syncImpl();
- waitImpl();
-
- {
- Lock sync(*this);
- if(_loaded.get() || _proxy && _synchronizing && !upToDate) // Synced or if not up to date is fine
- {
- assert(_loaded.get() || _load.get() || _destroy.get());
- activationTimeout = _activationTimeout;
- deactivationTimeout = _deactivationTimeout;
- node = _loaded.get() ? _loaded->node : (_load.get() ? _load->node : _destroy->node);
- return _proxy;
- }
- else if(_load.get())
- {
- continue; // Retry
- }
- else
- {
- throw ServerNotExistException(_id);
- }
- }
+ //
+ // Note that we don't call syncAndWait() because we want
+ // NodeUnreachableException exceptions to go through.
+ //
+ syncImpl();
+ waitImpl();
+
+ {
+ Lock sync(*this);
+ if(_loaded.get() || _proxy && _synchronizing && !upToDate) // Synced or if not up to date is fine
+ {
+ assert(_loaded.get() || _load.get() || _destroy.get());
+ activationTimeout = _activationTimeout;
+ deactivationTimeout = _deactivationTimeout;
+ node = _loaded.get() ? _loaded->node : (_load.get() ? _load->node : _destroy->node);
+ return _proxy;
+ }
+ else if(_load.get())
+ {
+ continue; // Retry
+ }
+ else
+ {
+ throw ServerNotExistException(_id);
+ }
+ }
}
}
@@ -420,58 +420,58 @@ AdapterPrx
ServerEntry::getAdapter(int& activationTimeout, int& deactivationTimeout, const string& id, bool upToDate)
{
{
- Lock sync(*this);
- if(_loaded.get() || _proxy && _synchronizing && !upToDate) // Synced or if not up to date is fine
- {
- AdapterPrxDict::const_iterator p = _adapters.find(id);
- if(p != _adapters.end())
- {
- assert(p->second);
- activationTimeout = _activationTimeout;
- deactivationTimeout = _deactivationTimeout;
- return p->second;
- }
- else
- {
- throw AdapterNotExistException(id);
- }
- }
+ Lock sync(*this);
+ if(_loaded.get() || _proxy && _synchronizing && !upToDate) // Synced or if not up to date is fine
+ {
+ AdapterPrxDict::const_iterator p = _adapters.find(id);
+ if(p != _adapters.end())
+ {
+ assert(p->second);
+ activationTimeout = _activationTimeout;
+ deactivationTimeout = _deactivationTimeout;
+ return p->second;
+ }
+ else
+ {
+ throw AdapterNotExistException(id);
+ }
+ }
}
while(true)
{
- //
- // Note that we don't call syncAndWait() because we want
- // NodeUnreachableException exceptions to go through.
- //
- syncImpl();
- waitImpl();
-
- {
- Lock sync(*this);
- if(_loaded.get() || _proxy && _synchronizing && !upToDate) // Synced or if not up to date is fine
- {
- AdapterPrxDict::const_iterator p = _adapters.find(id);
- if(p != _adapters.end())
- {
- activationTimeout = _activationTimeout;
- deactivationTimeout = _deactivationTimeout;
- return p->second;
- }
- else
- {
- throw AdapterNotExistException(id);
- }
- }
- else if(_load.get())
- {
- continue; // Retry
- }
- else
- {
- throw AdapterNotExistException(id);
- }
- }
+ //
+ // Note that we don't call syncAndWait() because we want
+ // NodeUnreachableException exceptions to go through.
+ //
+ syncImpl();
+ waitImpl();
+
+ {
+ Lock sync(*this);
+ if(_loaded.get() || _proxy && _synchronizing && !upToDate) // Synced or if not up to date is fine
+ {
+ AdapterPrxDict::const_iterator p = _adapters.find(id);
+ if(p != _adapters.end())
+ {
+ activationTimeout = _activationTimeout;
+ deactivationTimeout = _deactivationTimeout;
+ return p->second;
+ }
+ else
+ {
+ throw AdapterNotExistException(id);
+ }
+ }
+ else if(_load.get())
+ {
+ continue; // Retry
+ }
+ else
+ {
+ throw AdapterNotExistException(id);
+ }
+ }
}
}
@@ -481,21 +481,21 @@ ServerEntry::getLoad(LoadSample sample) const
string application;
string node;
{
- Lock sync(*this);
- if(_loaded.get())
- {
- application = _loaded->application;
- node = _loaded->node;
- }
- else if(_load.get())
- {
- application = _load->application;
- node = _load->node;
- }
- else
- {
- throw ServerNotExistException();
- }
+ Lock sync(*this);
+ if(_loaded.get())
+ {
+ application = _loaded->application;
+ node = _loaded->node;
+ }
+ else if(_load.get())
+ {
+ application = _load->application;
+ node = _load->node;
+ }
+ else
+ {
+ throw ServerNotExistException();
+ }
}
float factor;
@@ -503,14 +503,14 @@ ServerEntry::getLoad(LoadSample sample) const
switch(sample)
{
case LoadSample1:
- return load.avg1 < 0.f ? 1.0f : load.avg1 * factor;
+ return load.avg1 < 0.f ? 1.0f : load.avg1 * factor;
case LoadSample5:
- return load.avg5 < 0.f ? 1.0f : load.avg5 * factor;
+ return load.avg5 < 0.f ? 1.0f : load.avg5 * factor;
case LoadSample15:
- return load.avg15 < 0.f ? 1.0f : load.avg15 * factor;
+ return load.avg15 < 0.f ? 1.0f : load.avg15 * factor;
default:
- assert(false);
- return 1.0f;
+ assert(false);
+ return 1.0f;
}
}
@@ -523,60 +523,60 @@ ServerEntry::syncImpl()
int timeout = -1;
{
- Lock sync(*this);
- if(_synchronizing)
- {
- return;
- }
-
- if(!_load.get() && !_destroy.get())
- {
- _load = _loaded; // Re-load the current server.
- }
-
- _updated = false;
- _exception.reset(0);
-
- if(_destroy.get())
- {
- destroy = *_destroy;
- timeout = _deactivationTimeout;
- }
- else if(_load.get())
- {
- load = *_load;
- session = _session;
- timeout = _deactivationTimeout; // loadServer might block to deactivate the previous server.
- }
- else
- {
- return;
- }
-
- _synchronizing = true;
+ Lock sync(*this);
+ if(_synchronizing)
+ {
+ return;
+ }
+
+ if(!_load.get() && !_destroy.get())
+ {
+ _load = _loaded; // Re-load the current server.
+ }
+
+ _updated = false;
+ _exception.reset(0);
+
+ if(_destroy.get())
+ {
+ destroy = *_destroy;
+ timeout = _deactivationTimeout;
+ }
+ else if(_load.get())
+ {
+ load = *_load;
+ session = _session;
+ timeout = _deactivationTimeout; // loadServer might block to deactivate the previous server.
+ }
+ else
+ {
+ return;
+ }
+
+ _synchronizing = true;
}
if(destroy.descriptor)
{
- try
- {
- _cache.getNodeCache().get(destroy.node)->destroyServer(this, destroy, timeout);
- }
- catch(NodeNotExistException&)
- {
- exception(NodeUnreachableException(destroy.node, "node is not active"));
- }
+ try
+ {
+ _cache.getNodeCache().get(destroy.node)->destroyServer(this, destroy, timeout);
+ }
+ catch(NodeNotExistException&)
+ {
+ exception(NodeUnreachableException(destroy.node, "node is not active"));
+ }
}
else if(load.descriptor)
{
- try
- {
- _cache.getNodeCache().get(load.node)->loadServer(this, load, session, timeout);
- }
- catch(NodeNotExistException&)
- {
- exception(NodeUnreachableException(load.node, "node is not active"));
- }
+ try
+ {
+ _cache.getNodeCache().get(load.node)->loadServer(this, load, session, timeout);
+ }
+ catch(NodeNotExistException&)
+ {
+ exception(NodeUnreachableException(load.node, "node is not active"));
+ }
}
}
@@ -586,35 +586,35 @@ ServerEntry::waitImpl()
Lock sync(*this);
while(_synchronizing)
{
- wait();
+ wait();
}
if(_exception.get())
{
- try
- {
- _exception->ice_throw();
- }
- catch(const DeploymentException&)
- {
- throw;
- }
- catch(const NodeUnreachableException&)
- {
- throw;
- }
- catch(const Ice::Exception& ex) // This shouln't happen.
- {
- ostringstream os;
- os << "unexpected exception while synchronizing server `" + _id + "':\n" << ex;
- TraceLevelsPtr traceLevels = _cache.getTraceLevels();
- if(traceLevels)
- {
- Ice::Error err(traceLevels->logger);
- err << os.str();
- }
- throw DeploymentException(os.str());
- }
+ try
+ {
+ _exception->ice_throw();
+ }
+ catch(const DeploymentException&)
+ {
+ throw;
+ }
+ catch(const NodeUnreachableException&)
+ {
+ throw;
+ }
+ catch(const Ice::Exception& ex) // This shouln't happen.
+ {
+ ostringstream os;
+ os << "unexpected exception while synchronizing server `" + _id + "':\n" << ex;
+ TraceLevelsPtr traceLevels = _cache.getTraceLevels();
+ if(traceLevels)
+ {
+ Ice::Error err(traceLevels->logger);
+ err << os.str();
+ }
+ throw DeploymentException(os.str());
+ }
}
}
@@ -627,66 +627,66 @@ ServerEntry::loadCallback(const ServerPrx& proxy, const AdapterPrxDict& adpts, i
int timeout = -1;
{
- Lock sync(*this);
- if(!_updated)
- {
- //
- // Set timeout on server and adapter proxies. Most of the
- // calls on the proxies shouldn't block for longer than the
- // node session timeout. Calls that might block for a longer
- // time should set the correct timeout before invoking on the
- // proxy (e.g.: server start/stop, adapter activate).
- //
- _loaded = _load;
- assert(_loaded.get());
- _proxy = proxy;
- _adapters = adpts;
- _activationTimeout = at;
- _deactivationTimeout = dt;
-
- assert(!_destroy.get() && !_load.get());
- _synchronizing = false;
- notifyAll();
- return;
- }
- else
- {
- _updated = false;
- if(_destroy.get())
- {
- destroy = *_destroy;
- }
- else if(_load.get())
- {
- load = *_load;
- session = _session;
- timeout = _deactivationTimeout; // loadServer might block to deactivate the previous server.
- }
- }
+ Lock sync(*this);
+ if(!_updated)
+ {
+ //
+ // Set timeout on server and adapter proxies. Most of the
+ // calls on the proxies shouldn't block for longer than the
+ // node session timeout. Calls that might block for a longer
+ // time should set the correct timeout before invoking on the
+ // proxy (e.g.: server start/stop, adapter activate).
+ //
+ _loaded = _load;
+ assert(_loaded.get());
+ _proxy = proxy;
+ _adapters = adpts;
+ _activationTimeout = at;
+ _deactivationTimeout = dt;
+
+ assert(!_destroy.get() && !_load.get());
+ _synchronizing = false;
+ notifyAll();
+ return;
+ }
+ else
+ {
+ _updated = false;
+ if(_destroy.get())
+ {
+ destroy = *_destroy;
+ }
+ else if(_load.get())
+ {
+ load = *_load;
+ session = _session;
+ timeout = _deactivationTimeout; // loadServer might block to deactivate the previous server.
+ }
+ }
}
assert(destroy.descriptor || load.descriptor);
if(destroy.descriptor)
{
- try
- {
- _cache.getNodeCache().get(destroy.node)->destroyServer(this, destroy, timeout);
- }
- catch(NodeNotExistException&)
- {
- exception(NodeUnreachableException(destroy.node, "node is not active"));
- }
+ try
+ {
+ _cache.getNodeCache().get(destroy.node)->destroyServer(this, destroy, timeout);
+ }
+ catch(NodeNotExistException&)
+ {
+ exception(NodeUnreachableException(destroy.node, "node is not active"));
+ }
}
else if(load.descriptor)
{
- try
- {
- _cache.getNodeCache().get(load.node)->loadServer(this, load, session, timeout);
- }
- catch(NodeNotExistException&)
- {
- exception(NodeUnreachableException(load.node, "node is not active"));
- }
+ try
+ {
+ _cache.getNodeCache().get(load.node)->loadServer(this, load, session, timeout);
+ }
+ catch(NodeNotExistException&)
+ {
+ exception(NodeUnreachableException(load.node, "node is not active"));
+ }
}
}
@@ -697,41 +697,41 @@ ServerEntry::destroyCallback()
SessionIPtr session;
{
- Lock sync(*this);
- _destroy.reset(0);
- _proxy = 0;
- _adapters.clear();
- _activationTimeout = -1;
- _deactivationTimeout = -1;
+ Lock sync(*this);
+ _destroy.reset(0);
+ _proxy = 0;
+ _adapters.clear();
+ _activationTimeout = -1;
+ _deactivationTimeout = -1;
- if(!_load.get())
- {
- assert(!_load.get() && !_loaded.get());
- _synchronizing = false;
- notifyAll();
- }
- else
- {
- _updated = false;
- load = *_load;
- session = _session;
- }
+ if(!_load.get())
+ {
+ assert(!_load.get() && !_loaded.get());
+ _synchronizing = false;
+ notifyAll();
+ }
+ else
+ {
+ _updated = false;
+ load = *_load;
+ session = _session;
+ }
}
if(load.descriptor)
{
- try
- {
- _cache.getNodeCache().get(load.node)->loadServer(this, load, session, -1);
- }
- catch(NodeNotExistException&)
- {
- exception(NodeUnreachableException(load.node, "node is not active"));
- }
+ try
+ {
+ _cache.getNodeCache().get(load.node)->loadServer(this, load, session, -1);
+ }
+ catch(NodeNotExistException&)
+ {
+ exception(NodeUnreachableException(load.node, "node is not active"));
+ }
}
else
{
- _cache.clear(_id);
+ _cache.clear(_id);
}
}
@@ -744,43 +744,43 @@ ServerEntry::exception(const Ice::Exception& ex)
int timeout = -1;
{
- Lock sync(*this);
- if((_destroy.get() && !_load.get()) || (!_destroy.get() && !_updated))
- {
- remove = _destroy.get();
- _destroy.reset(0);
- _exception.reset(ex.ice_clone());
- _proxy = 0;
- _adapters.clear();
- _activationTimeout = -1;
- _deactivationTimeout = -1;
- _synchronizing = false;
- notifyAll();
- }
- else
- {
- _destroy.reset(0);
- _updated = false;
- load = *_load.get();
- session = _session;
- timeout = _deactivationTimeout; // loadServer might block to deactivate the previous server.
- }
+ Lock sync(*this);
+ if((_destroy.get() && !_load.get()) || (!_destroy.get() && !_updated))
+ {
+ remove = _destroy.get();
+ _destroy.reset(0);
+ _exception.reset(ex.ice_clone());
+ _proxy = 0;
+ _adapters.clear();
+ _activationTimeout = -1;
+ _deactivationTimeout = -1;
+ _synchronizing = false;
+ notifyAll();
+ }
+ else
+ {
+ _destroy.reset(0);
+ _updated = false;
+ load = *_load.get();
+ session = _session;
+ timeout = _deactivationTimeout; // loadServer might block to deactivate the previous server.
+ }
}
if(load.descriptor)
{
- try
- {
- _cache.getNodeCache().get(load.node)->loadServer(this, load, session, timeout);
- }
- catch(NodeNotExistException&)
- {
- exception(NodeUnreachableException(load.node, "node is not active"));
- }
+ try
+ {
+ _cache.getNodeCache().get(load.node)->loadServer(this, load, session, timeout);
+ }
+ catch(NodeNotExistException&)
+ {
+ exception(NodeUnreachableException(load.node, "node is not active"));
+ }
}
else if(remove)
{
- _cache.clear(_id);
+ _cache.clear(_id);
}
}
@@ -804,14 +804,14 @@ ServerEntry::allocated(const SessionIPtr& session)
{
if(!_loaded.get() && !_load.get())
{
- return;
+ return;
}
TraceLevelsPtr traceLevels = _cache.getTraceLevels();
if(traceLevels && traceLevels->server > 1)
{
- Ice::Trace out(traceLevels->logger, traceLevels->serverCat);
- out << "server `" << _id << "' allocated by `" << session->getId() << "' (" << _count << ")";
+ Ice::Trace out(traceLevels->logger, traceLevels->serverCat);
+ out << "server `" << _id << "' allocated by `" << session->getId() << "' (" << _count << ")";
}
ServerDescriptorPtr desc = _loaded.get() ? _loaded->descriptor : _load->descriptor;
@@ -824,52 +824,52 @@ ServerEntry::allocated(const SessionIPtr& session)
//
if(desc->activation == "session")
{
- _updated = true;
- if(!_load.get())
- {
- _load = _loaded;
- }
- _session = session;
- _load->sessionId = session->getId();
+ _updated = true;
+ if(!_load.get())
+ {
+ _load = _loaded;
+ }
+ _session = session;
+ _load->sessionId = session->getId();
}
Glacier2::SessionControlPrx ctl = session->getSessionControl();
if(ctl)
{
- ServerHelperPtr helper = createHelper(desc);
- multiset<string> adapterIds;
- multiset<Ice::Identity> identities;
- helper->getIds(adapterIds, identities);
- try
- {
- //
- // SunCC won't accept the following:
- //
- // ctl->adapterIds()->add(Ice::StringSeq(adapterIds.begin(), adapterIds.end()));
- // ctl->identities()->add(Ice::IdentitySeq(identities.begin(), identities.end()));
- //
- Ice::StringSeq adapterIdSeq;
- for(multiset<string>::iterator p = adapterIds.begin(); p != adapterIds.end(); ++p)
- {
- adapterIdSeq.push_back(*p);
- }
- Ice::IdentitySeq identitySeq;
- for(multiset<Ice::Identity>::iterator q = identities.begin(); q != identities.end(); ++q)
- {
- identitySeq.push_back(*q);
- }
- ctl->adapterIds()->add(adapterIdSeq);
- ctl->identities()->add(identitySeq);
- }
- catch(const Ice::LocalException& ex)
- {
- if(traceLevels && traceLevels->server > 0)
- {
- Ice::Trace out(traceLevels->logger, traceLevels->serverCat);
- out << "couldn't add Glacier2 filters for server `" << _id << "' allocated by `" << session->getId();
- out << ":\n" << ex;
- }
- }
+ ServerHelperPtr helper = createHelper(desc);
+ multiset<string> adapterIds;
+ multiset<Ice::Identity> identities;
+ helper->getIds(adapterIds, identities);
+ try
+ {
+ //
+ // SunCC won't accept the following:
+ //
+ // ctl->adapterIds()->add(Ice::StringSeq(adapterIds.begin(), adapterIds.end()));
+ // ctl->identities()->add(Ice::IdentitySeq(identities.begin(), identities.end()));
+ //
+ Ice::StringSeq adapterIdSeq;
+ for(multiset<string>::iterator p = adapterIds.begin(); p != adapterIds.end(); ++p)
+ {
+ adapterIdSeq.push_back(*p);
+ }
+ Ice::IdentitySeq identitySeq;
+ for(multiset<Ice::Identity>::iterator q = identities.begin(); q != identities.end(); ++q)
+ {
+ identitySeq.push_back(*q);
+ }
+ ctl->adapterIds()->add(adapterIdSeq);
+ ctl->identities()->add(identitySeq);
+ }
+ catch(const Ice::LocalException& ex)
+ {
+ if(traceLevels && traceLevels->server > 0)
+ {
+ Ice::Trace out(traceLevels->logger, traceLevels->serverCat);
+ out << "couldn't add Glacier2 filters for server `" << _id << "' allocated by `" << session->getId();
+ out << ":\n" << ex;
+ }
+ }
}
}
@@ -877,13 +877,13 @@ void
ServerEntry::allocatedNoSync(const SessionIPtr& session)
{
{
- Lock sync(*this);
- if(!_updated ||
- _loaded.get() && _loaded->descriptor->activation != "session" ||
- _load.get() && _load->descriptor->activation != "session")
- {
- return;
- }
+ Lock sync(*this);
+ if(!_updated ||
+ _loaded.get() && _loaded->descriptor->activation != "session" ||
+ _load.get() && _load->descriptor->activation != "session")
+ {
+ return;
+ }
}
sync();
@@ -895,7 +895,7 @@ ServerEntry::released(const SessionIPtr& session)
{
if(!_loaded.get() && !_load.get())
{
- return;
+ return;
}
ServerDescriptorPtr desc = _loaded.get() ? _loaded->descriptor : _load->descriptor;
@@ -909,13 +909,13 @@ ServerEntry::released(const SessionIPtr& session)
//
if(desc->activation == "session")
{
- _updated = true;
- if(!_load.get())
- {
- _load = _loaded;
- }
- _load->sessionId = "";
- _session = 0;
+ _updated = true;
+ if(!_load.get())
+ {
+ _load = _loaded;
+ }
+ _load->sessionId = "";
+ _session = 0;
}
TraceLevelsPtr traceLevels = _cache.getTraceLevels();
@@ -923,46 +923,46 @@ ServerEntry::released(const SessionIPtr& session)
Glacier2::SessionControlPrx ctl = session->getSessionControl();
if(ctl)
{
- ServerHelperPtr helper = createHelper(desc);
- multiset<string> adapterIds;
- multiset<Ice::Identity> identities;
- helper->getIds(adapterIds, identities);
- try
- {
- //
- // SunCC won't accept the following:
- //
- // ctl->adapterIds()->remove(Ice::StringSeq(adapterIds.begin(), adapterIds.end()));
- // ctl->identities()->remove(Ice::IdentitySeq(identities.begin(), identities.end()));
- //
- Ice::StringSeq adapterIdSeq;
- for(multiset<string>::iterator p = adapterIds.begin(); p != adapterIds.end(); ++p)
- {
- adapterIdSeq.push_back(*p);
- }
- Ice::IdentitySeq identitySeq;
- for(multiset<Ice::Identity>::iterator q = identities.begin(); q != identities.end(); ++q)
- {
- identitySeq.push_back(*q);
- }
- ctl->adapterIds()->remove(adapterIdSeq);
- ctl->identities()->remove(identitySeq);
- }
- catch(const Ice::LocalException& ex)
- {
- if(traceLevels && traceLevels->server > 0)
- {
- Ice::Trace out(traceLevels->logger, traceLevels->serverCat);
- out << "couldn't remove Glacier2 filters for server `" << _id << "' allocated by `";
- out << session->getId() << ":\n" << ex;
- }
- }
+ ServerHelperPtr helper = createHelper(desc);
+ multiset<string> adapterIds;
+ multiset<Ice::Identity> identities;
+ helper->getIds(adapterIds, identities);
+ try
+ {
+ //
+ // SunCC won't accept the following:
+ //
+ // ctl->adapterIds()->remove(Ice::StringSeq(adapterIds.begin(), adapterIds.end()));
+ // ctl->identities()->remove(Ice::IdentitySeq(identities.begin(), identities.end()));
+ //
+ Ice::StringSeq adapterIdSeq;
+ for(multiset<string>::iterator p = adapterIds.begin(); p != adapterIds.end(); ++p)
+ {
+ adapterIdSeq.push_back(*p);
+ }
+ Ice::IdentitySeq identitySeq;
+ for(multiset<Ice::Identity>::iterator q = identities.begin(); q != identities.end(); ++q)
+ {
+ identitySeq.push_back(*q);
+ }
+ ctl->adapterIds()->remove(adapterIdSeq);
+ ctl->identities()->remove(identitySeq);
+ }
+ catch(const Ice::LocalException& ex)
+ {
+ if(traceLevels && traceLevels->server > 0)
+ {
+ Ice::Trace out(traceLevels->logger, traceLevels->serverCat);
+ out << "couldn't remove Glacier2 filters for server `" << _id << "' allocated by `";
+ out << session->getId() << ":\n" << ex;
+ }
+ }
}
if(traceLevels && traceLevels->server > 1)
{
- Ice::Trace out(traceLevels->logger, traceLevels->serverCat);
- out << "server `" << _id << "' released by `" << session->getId() << "' (" << _count << ")";
+ Ice::Trace out(traceLevels->logger, traceLevels->serverCat);
+ out << "server `" << _id << "' released by `" << session->getId() << "' (" << _count << ")";
}
}
@@ -970,13 +970,13 @@ void
ServerEntry::releasedNoSync(const SessionIPtr& session)
{
{
- Lock sync(*this);
- if(!_updated ||
- _loaded.get() && _loaded->descriptor->activation != "session" ||
- _load.get() && _load->descriptor->activation != "session")
- {
- return;
- }
+ Lock sync(*this);
+ if(!_updated ||
+ _loaded.get() && _loaded->descriptor->activation != "session" ||
+ _load.get() && _load->descriptor->activation != "session")
+ {
+ return;
+ }
}
sync();
diff --git a/cpp/src/IceGrid/ServerI.cpp b/cpp/src/IceGrid/ServerI.cpp
index 2d25e742b74..4142e53fe91 100644
--- a/cpp/src/IceGrid/ServerI.cpp
+++ b/cpp/src/IceGrid/ServerI.cpp
@@ -50,7 +50,7 @@ chownRecursive(const string& path, uid_t uid, gid_t gid)
DIR* d;
if((d = opendir(path.c_str())) == 0)
{
- throw "cannot read directory `" + path + "':\n" + IcePatch2::lastError();
+ throw "cannot read directory `" + path + "':\n" + IcePatch2::lastError();
}
struct dirent* entry;
@@ -60,16 +60,16 @@ chownRecursive(const string& path, uid_t uid, gid_t gid)
namelist = (struct dirent**)realloc((void*)namelist, (size_t)((n + 1) * sizeof(struct dirent*)));
if(namelist == 0)
{
- closedir(d);
- throw "cannot read directory `" + path + "':\n" + IcePatch2::lastError();
+ closedir(d);
+ throw "cannot read directory `" + path + "':\n" + IcePatch2::lastError();
}
size_t entrysize = sizeof(struct dirent) - sizeof(entry->d_name) + strlen(entry->d_name) + 1;
namelist[n] = (struct dirent*)malloc(entrysize);
if(namelist[n] == 0)
{
- closedir(d);
- throw "cannot read directory `" + path + "':\n" + IcePatch2::lastError();
+ closedir(d);
+ throw "cannot read directory `" + path + "':\n" + IcePatch2::lastError();
}
memcpy(namelist[n], entry, entrysize);
++n;
@@ -77,34 +77,34 @@ chownRecursive(const string& path, uid_t uid, gid_t gid)
if(closedir(d))
{
- throw "cannot read directory `" + path + "':\n" + IcePatch2::lastError();
+ throw "cannot read directory `" + path + "':\n" + IcePatch2::lastError();
}
for(int i = 0; i < n; ++i)
{
- string name = namelist[i]->d_name;
- assert(!name.empty());
- free(namelist[i]);
-
- if(name != ".." && name != ".")
- {
- name = path + "/" + name;
- if(chown(name.c_str(), uid, gid) != 0)
- {
- throw "can't change permissions on `" + name + "':\n" + IcePatch2::lastError();
- }
-
- OS::structstat buf;
- if(OS::osstat(name, &buf) == -1)
- {
- throw "cannot stat `" + name + "':\n" + IcePatch2::lastError();
- }
-
- if(S_ISDIR(buf.st_mode))
- {
- chownRecursive(name, uid, gid);
- }
- }
+ string name = namelist[i]->d_name;
+ assert(!name.empty());
+ free(namelist[i]);
+
+ if(name != ".." && name != ".")
+ {
+ name = path + "/" + name;
+ if(chown(name.c_str(), uid, gid) != 0)
+ {
+ throw "can't change permissions on `" + name + "':\n" + IcePatch2::lastError();
+ }
+
+ OS::structstat buf;
+ if(OS::osstat(name, &buf) == -1)
+ {
+ throw "cannot stat `" + name + "':\n" + IcePatch2::lastError();
+ }
+
+ if(S_ISDIR(buf.st_mode))
+ {
+ chownRecursive(name, uid, gid);
+ }
+ }
}
free(namelist);
@@ -132,57 +132,57 @@ descriptorWithoutRevisionEqual(const InternalServerDescriptorPtr& lhs, const Int
lhs->envs != rhs->envs ||
lhs->logs != rhs->logs)
{
- return false;
+ return false;
}
if(!lhs->distrib && rhs->distrib || lhs->distrib && !rhs->distrib)
{
- return false;
+ return false;
}
else if(lhs->distrib && rhs->distrib)
{
- if(lhs->distrib->icepatch != rhs->distrib->icepatch ||
- lhs->distrib->directories != rhs->distrib->directories)
- {
- return false;
- }
+ if(lhs->distrib->icepatch != rhs->distrib->icepatch ||
+ lhs->distrib->directories != rhs->distrib->directories)
+ {
+ return false;
+ }
}
if(lhs->adapters.size() != rhs->adapters.size())
{
- return false;
+ return false;
}
else
{
- InternalAdapterDescriptorSeq::const_iterator q = rhs->adapters.begin();
- for(InternalAdapterDescriptorSeq::const_iterator p = lhs->adapters.begin(); p != lhs->adapters.end(); ++p, ++q)
- {
- if((*p)->id != (*q)->id || (*p)->serverLifetime != (*q)->serverLifetime)
- {
- return false;
- }
- }
+ InternalAdapterDescriptorSeq::const_iterator q = rhs->adapters.begin();
+ for(InternalAdapterDescriptorSeq::const_iterator p = lhs->adapters.begin(); p != lhs->adapters.end(); ++p, ++q)
+ {
+ if((*p)->id != (*q)->id || (*p)->serverLifetime != (*q)->serverLifetime)
+ {
+ return false;
+ }
+ }
}
if(lhs->dbEnvs.size() != rhs->dbEnvs.size())
{
- return false;
+ return false;
}
else
{
- InternalDbEnvDescriptorSeq::const_iterator q = rhs->dbEnvs.begin();
- for(InternalDbEnvDescriptorSeq::const_iterator p = lhs->dbEnvs.begin(); p != lhs->dbEnvs.end(); ++p, ++q)
- {
- if((*p)->name != (*q)->name || (*p)->properties != (*q)->properties)
- {
- return false;
- }
- }
+ InternalDbEnvDescriptorSeq::const_iterator q = rhs->dbEnvs.begin();
+ for(InternalDbEnvDescriptorSeq::const_iterator p = lhs->dbEnvs.begin(); p != lhs->dbEnvs.end(); ++p, ++q)
+ {
+ if((*p)->name != (*q)->name || (*p)->properties != (*q)->properties)
+ {
+ return false;
+ }
+ }
}
if(lhs->properties != rhs->properties)
{
- return false;
+ return false;
}
return true;
@@ -193,13 +193,13 @@ class CommandTimeoutItem : public WaitItem
public:
CommandTimeoutItem(const TimedServerCommandPtr& command) :
- WaitItem(), _command(command)
+ WaitItem(), _command(command)
{
}
virtual void expired(bool destroyed)
{
- _command->timeout(destroyed);
+ _command->timeout(destroyed);
}
private:
@@ -212,30 +212,30 @@ class DelayedStart : public WaitItem
public:
DelayedStart(const ServerIPtr& server, const TraceLevelsPtr& traceLevels) :
- _server(server),
- _traceLevels(traceLevels)
+ _server(server),
+ _traceLevels(traceLevels)
{
}
virtual void expired(bool destroyed)
{
- if(!destroyed)
- {
- try
- {
- _server->start(ServerI::Always);
- }
- catch(const ServerStartException& ex)
- {
- Ice::Error out(_traceLevels->logger);
- out << "couldn't reactivate server `" << _server->getId()
- << "' with `always' activation mode after failure:\n"
- << ex.reason;
- }
- catch(const Ice::ObjectNotExistException&)
- {
- }
- }
+ if(!destroyed)
+ {
+ try
+ {
+ _server->start(ServerI::Always);
+ }
+ catch(const ServerStartException& ex)
+ {
+ Ice::Error out(_traceLevels->logger);
+ out << "couldn't reactivate server `" << _server->getId()
+ << "' with `always' activation mode after failure:\n"
+ << ex.reason;
+ }
+ catch(const Ice::ObjectNotExistException&)
+ {
+ }
+ }
}
private:
@@ -255,13 +255,13 @@ public:
virtual void
ice_response()
{
- _server->activate();
+ _server->activate();
}
virtual void
ice_exception(const Ice::Exception&)
{
- _server->activate();
+ _server->activate();
}
private:
@@ -274,62 +274,62 @@ struct EnvironmentEval : std::unary_function<string, string>
string
operator()(const std::string& value)
{
- string::size_type assignment = value.find("=");
- if(assignment == string::npos || assignment >= value.size() - 1)
- {
- return value;
- }
+ string::size_type assignment = value.find("=");
+ if(assignment == string::npos || assignment >= value.size() - 1)
+ {
+ return value;
+ }
- string v = value.substr(assignment + 1);
- assert(v.size());
- string::size_type beg = 0;
- string::size_type end;
+ string v = value.substr(assignment + 1);
+ assert(v.size());
+ string::size_type beg = 0;
+ string::size_type end;
#ifdef _WIN32
- char buf[32767];
- while((beg = v.find("%", beg)) != string::npos && beg < v.size() - 1)
- {
- end = v.find("%", beg + 1);
- if(end == string::npos)
- {
- break;
- }
- string variable = v.substr(beg + 1, end - beg - 1);
- int ret = GetEnvironmentVariable(variable.c_str(), buf, sizeof(buf));
- string valstr = (ret > 0 && ret < sizeof(buf)) ? string(buf) : string("");
- v.replace(beg, end - beg + 1, valstr);
- beg += valstr.size();
- }
+ char buf[32767];
+ while((beg = v.find("%", beg)) != string::npos && beg < v.size() - 1)
+ {
+ end = v.find("%", beg + 1);
+ if(end == string::npos)
+ {
+ break;
+ }
+ string variable = v.substr(beg + 1, end - beg - 1);
+ int ret = GetEnvironmentVariable(variable.c_str(), buf, sizeof(buf));
+ string valstr = (ret > 0 && ret < sizeof(buf)) ? string(buf) : string("");
+ v.replace(beg, end - beg + 1, valstr);
+ beg += valstr.size();
+ }
#else
- while((beg = v.find("$", beg)) != string::npos && beg < v.size() - 1)
- {
- string variable;
- if(v[beg + 1] == '{')
- {
- end = v.find("}");
- if(end == string::npos)
- {
- break;
- }
- variable = v.substr(beg + 2, end - beg - 2);
- }
- else
- {
- end = beg + 1;
- while((isalnum(v[end]) || v[end] == '_') && end < v.size())
- {
- ++end;
- }
- variable = v.substr(beg + 1, end - beg - 1);
- --end;
- }
-
- char* val = getenv(variable.c_str());
- string valstr = val ? string(val) : "";
- v.replace(beg, end - beg + 1, valstr);
- beg += valstr.size();
- }
+ while((beg = v.find("$", beg)) != string::npos && beg < v.size() - 1)
+ {
+ string variable;
+ if(v[beg + 1] == '{')
+ {
+ end = v.find("}");
+ if(end == string::npos)
+ {
+ break;
+ }
+ variable = v.substr(beg + 2, end - beg - 2);
+ }
+ else
+ {
+ end = beg + 1;
+ while((isalnum(v[end]) || v[end] == '_') && end < v.size())
+ {
+ ++end;
+ }
+ variable = v.substr(beg + 1, end - beg - 1);
+ --end;
+ }
+
+ char* val = getenv(variable.c_str());
+ string valstr = val ? string(val) : "";
+ v.replace(beg, end - beg + 1, valstr);
+ beg += valstr.size();
+ }
#endif
- return value.substr(0, assignment) + "=" + v;
+ return value.substr(0, assignment) + "=" + v;
}
};
@@ -360,8 +360,8 @@ TimedServerCommand::stopTimer()
{
if(_timer)
{
- _waitQueue->remove(_timer);
- _timer = 0;
+ _waitQueue->remove(_timer);
+ _timer = 0;
}
}
@@ -419,7 +419,7 @@ LoadCommand::failed(const Ice::Exception& ex)
for(vector<AMD_Node_loadServerPtr>::const_iterator p = _loadCB.begin(); p != _loadCB.end(); ++p)
{
(*p)->ice_exception(ex);
- }
+ }
}
void
@@ -571,7 +571,7 @@ StartCommand::failed(const string& reason)
for(vector<AMD_Server_startPtr>::const_iterator p = _startCB.begin(); p != _startCB.end(); ++p)
{
(*p)->ice_exception(ex);
- }
+ }
_startCB.clear();
}
@@ -636,7 +636,7 @@ StopCommand::failed(const string& reason)
for(vector<AMD_Server_stopPtr>::const_iterator p = _stopCB.begin(); p != _stopCB.end(); ++p)
{
(*p)->ice_exception(ex);
- }
+ }
_stopCB.clear();
}
@@ -665,7 +665,7 @@ ServerI::ServerI(const NodeIPtr& node, const ServerPrx& proxy, const string& ser
{
assert(_node->getActivator());
const_cast<int&>(_disableOnFailure) =
- _node->getCommunicator()->getProperties()->getPropertyAsIntWithDefault("IceGrid.Node.DisableOnFailure", 0);
+ _node->getCommunicator()->getProperties()->getPropertyAsIntWithDefault("IceGrid.Node.DisableOnFailure", 0);
}
ServerI::~ServerI()
@@ -683,31 +683,31 @@ ServerI::stop_async(const AMD_Server_stopPtr& amdCB, const Ice::Current&)
{
ServerCommandPtr command;
{
- Lock sync(*this);
- checkDestroyed();
-
- if(StopCommand::isStopped(_state))
- {
- throw ServerStopException(_id, "The server is already inactive.");
- }
- else if(_state == Destroying)
- {
- throw ServerStopException(_id, "The server is being destroyed.");
- }
-
- if(!_stop)
- {
- _stop = new StopCommand(this, _node->getWaitQueue(), _deactivationTimeout);
- }
- if(amdCB)
- {
- _stop->addCallback(amdCB);
- }
- command = nextCommand();
+ Lock sync(*this);
+ checkDestroyed();
+
+ if(StopCommand::isStopped(_state))
+ {
+ throw ServerStopException(_id, "The server is already inactive.");
+ }
+ else if(_state == Destroying)
+ {
+ throw ServerStopException(_id, "The server is being destroyed.");
+ }
+
+ if(!_stop)
+ {
+ _stop = new StopCommand(this, _node->getWaitQueue(), _deactivationTimeout);
+ }
+ if(amdCB)
+ {
+ _stop->addCallback(amdCB);
+ }
+ command = nextCommand();
}
if(command)
{
- command->execute();
+ command->execute();
}
}
@@ -724,13 +724,13 @@ ServerI::writeMessage(const string& message, Ice::Int fd, const Ice::Current& cu
checkDestroyed();
if(_process != 0)
{
- try
- {
- _process->writeMessage(message, fd);
- }
- catch(const Ice::LocalException&)
- {
- }
+ try
+ {
+ _process->writeMessage(message, fd);
+ }
+ catch(const Ice::LocalException&)
+ {
+ }
}
}
@@ -753,49 +753,49 @@ ServerI::setEnabled(bool enabled, const ::Ice::Current&)
{
bool activate = false;
{
- Lock sync(*this);
- checkDestroyed();
- assert(_desc);
-
- if(enabled && _activation == Disabled)
- {
- _failureTime = IceUtil::Time();
- _activation = toServerActivation(_desc->activation);
- activate = _state == Inactive && _activation == Always;
- }
- else if(!enabled && (_activation != Disabled || _failureTime != IceUtil::Time()))
- {
- _failureTime = IceUtil::Time();
- _activation = Disabled;
- if(_timer)
- {
- _node->getWaitQueue()->remove(_timer);
- _timer = 0;
- }
- }
- else
- {
- return; // Nothing to change!
- }
-
- _node->observerUpdateServer(getDynamicInfo());
+ Lock sync(*this);
+ checkDestroyed();
+ assert(_desc);
+
+ if(enabled && _activation == Disabled)
+ {
+ _failureTime = IceUtil::Time();
+ _activation = toServerActivation(_desc->activation);
+ activate = _state == Inactive && _activation == Always;
+ }
+ else if(!enabled && (_activation != Disabled || _failureTime != IceUtil::Time()))
+ {
+ _failureTime = IceUtil::Time();
+ _activation = Disabled;
+ if(_timer)
+ {
+ _node->getWaitQueue()->remove(_timer);
+ _timer = 0;
+ }
+ }
+ else
+ {
+ return; // Nothing to change!
+ }
+
+ _node->observerUpdateServer(getDynamicInfo());
}
if(activate)
{
- try
- {
- start(Always);
- }
- catch(const ServerStartException& ex)
- {
- Ice::Error out(_node->getTraceLevels()->logger);
- out << "couldn't reactivate server `" << _id << "' with `always' activation mode:\n"
- << ex.reason;
- }
- catch(const Ice::ObjectNotExistException&)
- {
- }
+ try
+ {
+ start(Always);
+ }
+ catch(const ServerStartException& ex)
+ {
+ Ice::Error out(_node->getTraceLevels()->logger);
+ out << "couldn't reactivate server `" << _id << "' with `always' activation mode:\n"
+ << ex.reason;
+ }
+ catch(const Ice::ObjectNotExistException&)
+ {
+ }
}
}
@@ -812,15 +812,15 @@ ServerI::setProcess_async(const AMD_Server_setProcessPtr& amdCB, const Ice::Proc
{
bool deact = false;
{
- Lock sync(*this);
- checkDestroyed();
- _process = process;
- deact = _state == DeactivatingWaitForProcess;
+ Lock sync(*this);
+ checkDestroyed();
+ _process = process;
+ deact = _state == DeactivatingWaitForProcess;
}
amdCB->ice_response();
if(deact)
{
- deactivate();
+ deactivate();
}
}
@@ -832,7 +832,7 @@ ServerI::getOffsetFromEnd(const string& filename, int count, const Ice::Current&
bool
ServerI::read(const string& filename, Ice::Long pos, int size, Ice::Long& newPos, Ice::StringSeq& lines,
- const Ice::Current&) const
+ const Ice::Current&) const
{
return _node->getFileCache()->read(getFilePath(filename), pos, size, newPos, lines);
}
@@ -843,34 +843,34 @@ ServerI::isAdapterActivatable(const string& id) const
Lock sync(*this);
if(!_desc || _activation == Disabled)
{
- return false;
+ return false;
}
if(_desc->activation == "manual" ||
_desc->activation == "session" && _desc->sessionId.empty())
{
- return false;
+ return false;
}
if(_state <= WaitForActivation)
{
- if(_activatedAdapters.find(id) != _activatedAdapters.end())
- {
- return false; // The adapter was already activated once.
- }
- return true;
+ if(_activatedAdapters.find(id) != _activatedAdapters.end())
+ {
+ return false; // The adapter was already activated once.
+ }
+ return true;
}
else if(_state < Deactivating)
{
- return false; // The server is active or its activation timed out.
+ return false; // The server is active or its activation timed out.
}
else if(_state < Destroying)
{
- return true; // The server is being deactivated.
+ return true; // The server is being deactivated.
}
else
{
- return false;
+ return false;
}
}
@@ -892,84 +892,84 @@ ServerI::start(ServerActivation activation, const AMD_Server_startPtr& amdCB)
{
ServerCommandPtr command;
{
- Lock sync(*this);
- checkDestroyed();
-
- //
- // Eventually re-enable the server if it's disabled because of a failure.
- //
- if(_disableOnFailure > 0 && _failureTime != IceUtil::Time())
- {
- if(activation == Manual ||
- (_failureTime + IceUtil::Time::seconds(_disableOnFailure) < IceUtil::Time::now()))
- {
- _activation = _previousActivation;
- _failureTime = IceUtil::Time();
- }
- }
-
- //
- // Check the current activation mode and the requested activation.
- //
- if(_activation == Disabled)
- {
- throw ServerStartException(_id, "The server is disabled.");
- }
- else if(_activation != Always && activation == Always)
- {
- assert(!amdCB);
- return; // Nothing to do.
- }
- else if(_activation == Manual && activation != Manual)
- {
- throw ServerStartException(_id, "The server activation doesn't allow this activation mode.");
- }
- else if(_activation == Session && _desc->sessionId.empty())
- {
- throw ServerStartException(_id, "The server is not owned by a session.");
- }
-
- //
- // Check the current state.
- //
- if(_state == ActivationTimeout)
- {
- throw ServerStartException(_id, "The server activation timed out.");
- }
- else if(_state == Active)
- {
- if(activation == Always)
- {
- return; // Nothing to do, it's already active (and we
- // don't want to throw because it would be
- // considered as an error.)
- }
- throw ServerStartException(_id, "The server is already active.");
- }
- else if(_state == Destroying)
- {
- throw ServerStartException(_id, "The server is being destroyed.");
- }
-
- if(_timer)
- {
- _node->getWaitQueue()->remove(_timer);
- _timer = 0;
- }
-
- if(!_start)
- {
- _start = new StartCommand(this, _node->getWaitQueue(), _activationTimeout);
- }
- if(amdCB)
- {
- _start->addCallback(amdCB);
- }
- command = nextCommand();
+ Lock sync(*this);
+ checkDestroyed();
+
+ //
+ // Eventually re-enable the server if it's disabled because of a failure.
+ //
+ if(_disableOnFailure > 0 && _failureTime != IceUtil::Time())
+ {
+ if(activation == Manual ||
+ (_failureTime + IceUtil::Time::seconds(_disableOnFailure) < IceUtil::Time::now()))
+ {
+ _activation = _previousActivation;
+ _failureTime = IceUtil::Time();
+ }
+ }
+
+ //
+ // Check the current activation mode and the requested activation.
+ //
+ if(_activation == Disabled)
+ {
+ throw ServerStartException(_id, "The server is disabled.");
+ }
+ else if(_activation != Always && activation == Always)
+ {
+ assert(!amdCB);
+ return; // Nothing to do.
+ }
+ else if(_activation == Manual && activation != Manual)
+ {
+ throw ServerStartException(_id, "The server activation doesn't allow this activation mode.");
+ }
+ else if(_activation == Session && _desc->sessionId.empty())
+ {
+ throw ServerStartException(_id, "The server is not owned by a session.");
+ }
+
+ //
+ // Check the current state.
+ //
+ if(_state == ActivationTimeout)
+ {
+ throw ServerStartException(_id, "The server activation timed out.");
+ }
+ else if(_state == Active)
+ {
+ if(activation == Always)
+ {
+ return; // Nothing to do, it's already active (and we
+ // don't want to throw because it would be
+ // considered as an error.)
+ }
+ throw ServerStartException(_id, "The server is already active.");
+ }
+ else if(_state == Destroying)
+ {
+ throw ServerStartException(_id, "The server is being destroyed.");
+ }
+
+ if(_timer)
+ {
+ _node->getWaitQueue()->remove(_timer);
+ _timer = 0;
+ }
+
+ if(!_start)
+ {
+ _start = new StartCommand(this, _node->getWaitQueue(), _activationTimeout);
+ }
+ if(amdCB)
+ {
+ _start->addCallback(amdCB);
+ }
+ command = nextCommand();
}
if(command)
{
- command->execute();
+ command->execute();
}
}
@@ -994,40 +994,40 @@ ServerI::load(const AMD_Node_loadServerPtr& amdCB, const InternalServerDescripto
(replicaName != "Master" || _desc->sessionId == desc->sessionId) &&
(_desc->uuid == desc->uuid && _desc->revision == desc->revision || descriptorWithoutRevisionEqual(_desc, desc)))
{
- if(_desc->revision != desc->revision)
- {
- updateRevision(desc->uuid, desc->revision);
- }
-
- if(amdCB)
- {
- AdapterPrxDict adapters;
- for(ServerAdapterDict::const_iterator p = _adapters.begin(); p != _adapters.end(); ++p)
- {
- adapters.insert(make_pair(p->first, p->second->getProxy()));
- }
- amdCB->ice_response(_this, adapters, _activationTimeout, _deactivationTimeout);
- }
- return 0;
+ if(_desc->revision != desc->revision)
+ {
+ updateRevision(desc->uuid, desc->revision);
+ }
+
+ if(amdCB)
+ {
+ AdapterPrxDict adapters;
+ for(ServerAdapterDict::const_iterator p = _adapters.begin(); p != _adapters.end(); ++p)
+ {
+ adapters.insert(make_pair(p->first, p->second->getProxy()));
+ }
+ amdCB->ice_response(_this, adapters, _activationTimeout, _deactivationTimeout);
+ }
+ return 0;
}
if(!StopCommand::isStopped(_state) && !_stop)
{
- _stop = new StopCommand(this, _node->getWaitQueue(), _deactivationTimeout);
+ _stop = new StopCommand(this, _node->getWaitQueue(), _deactivationTimeout);
}
if(!_load)
{
- _load = new LoadCommand(this);
+ _load = new LoadCommand(this);
}
_load->setUpdate(desc, _destroy);
if(_destroy && _state != Destroying)
{
- _destroy->finished();
- _destroy = 0;
+ _destroy->finished();
+ _destroy = 0;
}
if(amdCB)
{
- _load->addCallback(amdCB);
+ _load->addCallback(amdCB);
}
return nextCommand();
}
@@ -1041,21 +1041,21 @@ ServerI::destroy(const AMD_Node_destroyServerPtr& amdCB, const string& uuid, int
if(!_desc)
{
- amdCB->ice_response();
- return 0; // Server is already destroyed.
+ amdCB->ice_response();
+ return 0; // Server is already destroyed.
}
if(!StopCommand::isStopped(_state) && !_stop)
{
- _stop = new StopCommand(this, _node->getWaitQueue(), _deactivationTimeout);
+ _stop = new StopCommand(this, _node->getWaitQueue(), _deactivationTimeout);
}
if(!_destroy)
{
- _destroy = new DestroyCommand(this);
+ _destroy = new DestroyCommand(this);
}
if(amdCB)
{
- _destroy->addCallback(amdCB);
+ _destroy->addCallback(amdCB);
}
return nextCommand();
}
@@ -1065,28 +1065,28 @@ ServerI::startPatch(bool shutdown)
{
ServerCommandPtr command;
{
- Lock sync(*this);
- checkDestroyed();
- if(!StopCommand::isStopped(_state))
- {
- if(!shutdown)
- {
- return false;
- }
- else if(!_stop)
- {
- _stop = new StopCommand(this, _node->getWaitQueue(), _deactivationTimeout);
- }
- }
- if(!_patch)
- {
- _patch = new PatchCommand(this);
- }
- command = nextCommand();
+ Lock sync(*this);
+ checkDestroyed();
+ if(!StopCommand::isStopped(_state))
+ {
+ if(!shutdown)
+ {
+ return false;
+ }
+ else if(!_stop)
+ {
+ _stop = new StopCommand(this, _node->getWaitQueue(), _deactivationTimeout);
+ }
+ }
+ if(!_patch)
+ {
+ _patch = new PatchCommand(this);
+ }
+ command = nextCommand();
}
if(command)
{
- command->execute();
+ command->execute();
}
return true;
}
@@ -1096,12 +1096,12 @@ ServerI::waitForPatch()
{
PatchCommandPtr patch;
{
- Lock sync(*this);
- if(!_patch)
- {
- return true;
- }
- patch = _patch;
+ Lock sync(*this);
+ if(!_patch)
+ {
+ return true;
+ }
+ patch = _patch;
}
return patch->waitForPatch();
}
@@ -1111,16 +1111,16 @@ ServerI::finishPatch()
{
#ifndef _WIN32
{
- Lock sync(*this);
- try
- {
- chownRecursive(_serverDir + "/distrib", _uid, _gid);
- }
- catch(const string& msg)
- {
- Ice::Warning out(_node->getTraceLevels()->logger);
- out << msg;
- }
+ Lock sync(*this);
+ try
+ {
+ chownRecursive(_serverDir + "/distrib", _uid, _gid);
+ }
+ catch(const string& msg)
+ {
+ Ice::Warning out(_node->getTraceLevels()->logger);
+ out << msg;
+ }
}
#endif
setState(Inactive);
@@ -1131,20 +1131,20 @@ ServerI::adapterActivated(const string& id)
{
ServerCommandPtr command;
{
- Lock sync(*this);
- if(_state != ServerI::Activating &&
- _state != ServerI::WaitForActivation &&
- _state != ServerI::ActivationTimeout)
- {
- return;
- }
- _activatedAdapters.insert(id);
- checkActivation();
- command = nextCommand();
+ Lock sync(*this);
+ if(_state != ServerI::Activating &&
+ _state != ServerI::WaitForActivation &&
+ _state != ServerI::ActivationTimeout)
+ {
+ return;
+ }
+ _activatedAdapters.insert(id);
+ checkActivation();
+ command = nextCommand();
}
if(command)
{
- command->execute();
+ command->execute();
}
}
@@ -1153,16 +1153,16 @@ ServerI::adapterDeactivated(const string& id)
{
ServerCommandPtr command;
{
- Lock sync(*this);
- if(_state == Active && _serverLifetimeAdapters.find(id) != _serverLifetimeAdapters.end())
- {
- setStateNoSync(Deactivating);
- }
- command = nextCommand();
+ Lock sync(*this);
+ if(_state == Active && _serverLifetimeAdapters.find(id) != _serverLifetimeAdapters.end())
+ {
+ setStateNoSync(Deactivating);
+ }
+ command = nextCommand();
}
if(command)
{
- command->execute();
+ command->execute();
}
}
@@ -1171,9 +1171,9 @@ ServerI::checkDestroyed() const
{
if(_state == Destroyed)
{
- Ice::ObjectNotExistException ex(__FILE__, __LINE__);
- ex.id = _this->ice_getIdentity();
- throw ex;
+ Ice::ObjectNotExistException ex(__FILE__, __LINE__);
+ ex.id = _this->ice_getIdentity();
+ throw ex;
}
}
@@ -1185,7 +1185,7 @@ ServerI::disableOnFailure()
//
if(_activation == Disabled)
{
- return;
+ return;
}
//
@@ -1195,9 +1195,9 @@ ServerI::disableOnFailure()
//
if(_disableOnFailure != 0 || _activation == Always && (_state == Activating || _state == WaitForActivation))
{
- _previousActivation = _activation;
- _activation = Disabled;
- _failureTime = IceUtil::Time::now();
+ _previousActivation = _activation;
+ _activation = Disabled;
+ _failureTime = IceUtil::Time::now();
}
}
@@ -1206,20 +1206,20 @@ ServerI::enableAfterFailure(bool force)
{
if(_disableOnFailure == 0 || _failureTime == IceUtil::Time())
{
- return;
+ return;
}
if(force ||
_disableOnFailure > 0 && (_failureTime + IceUtil::Time::seconds(_disableOnFailure) < IceUtil::Time::now()))
{
- _activation = _previousActivation;
- _failureTime = IceUtil::Time();
+ _activation = _previousActivation;
+ _failureTime = IceUtil::Time();
}
if(_timer)
{
- _node->getWaitQueue()->remove(_timer);
- _timer = 0;
+ _node->getWaitQueue()->remove(_timer);
+ _timer = 0;
}
}
@@ -1229,51 +1229,51 @@ ServerI::activationFailed(bool destroyed)
ServerCommandPtr command;
ServerAdapterDict adapters;
{
- Lock sync(*this);
- if(_state != ServerI::WaitForActivation)
- {
- return;
- }
-
- if(!destroyed)
- {
- setStateNoSync(ServerI::ActivationTimeout, "The server activation timed out.");
- }
- else
- {
- setStateNoSync(ServerI::ActivationTimeout, "The node is being shutdown.");
- }
-
- if(_node->getTraceLevels()->server > 1)
- {
- Ice::Trace out(_node->getTraceLevels()->logger, _node->getTraceLevels()->serverCat);
- if(!destroyed)
- {
- out << "server `" << _id << "' activation timed out";
- }
- else
- {
- out << "server `" << _id << "' activation failed";
- }
- }
- adapters = _adapters;
- command = nextCommand();
+ Lock sync(*this);
+ if(_state != ServerI::WaitForActivation)
+ {
+ return;
+ }
+
+ if(!destroyed)
+ {
+ setStateNoSync(ServerI::ActivationTimeout, "The server activation timed out.");
+ }
+ else
+ {
+ setStateNoSync(ServerI::ActivationTimeout, "The node is being shutdown.");
+ }
+
+ if(_node->getTraceLevels()->server > 1)
+ {
+ Ice::Trace out(_node->getTraceLevels()->logger, _node->getTraceLevels()->serverCat);
+ if(!destroyed)
+ {
+ out << "server `" << _id << "' activation timed out";
+ }
+ else
+ {
+ out << "server `" << _id << "' activation failed";
+ }
+ }
+ adapters = _adapters;
+ command = nextCommand();
}
for(ServerAdapterDict::const_iterator p = adapters.begin(); p != adapters.end(); ++p)
{
- try
- {
- p->second->activationFailed(destroyed ? "server destroyed" : "server activation timed out");
- }
- catch(const Ice::ObjectNotExistException&)
- {
- }
+ try
+ {
+ p->second->activationFailed(destroyed ? "server destroyed" : "server activation timed out");
+ }
+ catch(const Ice::ObjectNotExistException&)
+ {
+ }
}
if(command)
{
- command->execute();
+ command->execute();
}
}
@@ -1289,25 +1289,25 @@ ServerI::activate()
gid_t gid;
#endif
{
- Lock sync(*this);
- assert(_state == Activating && _desc);
- desc = _desc;
- adpts = _adapters;
-
- //
- // The first time the server is started, we ensure that the
- // replication of its descriptor is completed. This is to make
- // sure all the replicas are up to date when the server
- // starts for the first time with a given descriptor.
- //
- waitForReplication = _waitForReplication;
- _waitForReplication = false;
-
- _process = 0;
-
+ Lock sync(*this);
+ assert(_state == Activating && _desc);
+ desc = _desc;
+ adpts = _adapters;
+
+ //
+ // The first time the server is started, we ensure that the
+ // replication of its descriptor is completed. This is to make
+ // sure all the replicas are up to date when the server
+ // starts for the first time with a given descriptor.
+ //
+ waitForReplication = _waitForReplication;
+ _waitForReplication = false;
+
+ _process = 0;
+
#ifndef _WIN32
- uid = _uid;
- gid = _gid;
+ uid = _uid;
+ gid = _gid;
#endif
}
@@ -1318,13 +1318,13 @@ ServerI::activate()
//
if(waitForReplication)
{
- NodeSessionPrx session = _node->getMasterNodeSession();
- if(session)
- {
- AMI_NodeSession_waitForApplicationUpdatePtr cb = new WaitForApplicationUpdateCB(this);
- _node->getMasterNodeSession()->waitForApplicationUpdate_async(cb, desc->uuid, desc->revision);
- return;
- }
+ NodeSessionPrx session = _node->getMasterNodeSession();
+ if(session)
+ {
+ AMI_NodeSession_waitForApplicationUpdatePtr cb = new WaitForApplicationUpdateCB(this);
+ _node->getMasterNodeSession()->waitForApplicationUpdate_async(cb, desc->uuid, desc->revision);
+ return;
+ }
}
//
@@ -1343,69 +1343,69 @@ ServerI::activate()
//
for(ServerAdapterDict::iterator p = adpts.begin(); p != adpts.end(); ++p)
{
- try
- {
- p->second->clear();
- }
- catch(const Ice::ObjectNotExistException&)
- {
- }
+ try
+ {
+ p->second->clear();
+ }
+ catch(const Ice::ObjectNotExistException&)
+ {
+ }
}
string failure;
try
{
#ifndef _WIN32
- int pid = _node->getActivator()->activate(desc->id, desc->exe, desc->pwd, uid, gid, options, envs, this);
+ int pid = _node->getActivator()->activate(desc->id, desc->exe, desc->pwd, uid, gid, options, envs, this);
#else
- int pid = _node->getActivator()->activate(desc->id, desc->exe, desc->pwd, options, envs, this);
+ int pid = _node->getActivator()->activate(desc->id, desc->exe, desc->pwd, options, envs, this);
#endif
- ServerCommandPtr command;
- {
- Lock sync(*this);
- assert(_state == Activating);
- _pid = pid;
- setStateNoSync(ServerI::WaitForActivation);
- checkActivation();
- command = nextCommand();
- notifyAll(); // Terminated might be waiting for the state change.
- }
- if(command)
- {
- command->execute();
- }
- return;
+ ServerCommandPtr command;
+ {
+ Lock sync(*this);
+ assert(_state == Activating);
+ _pid = pid;
+ setStateNoSync(ServerI::WaitForActivation);
+ checkActivation();
+ command = nextCommand();
+ notifyAll(); // Terminated might be waiting for the state change.
+ }
+ if(command)
+ {
+ command->execute();
+ }
+ return;
}
catch(const std::string& ex)
{
- failure = ex;
+ failure = ex;
}
catch(const Ice::SyscallException& ex)
{
- Ice::Warning out(_node->getTraceLevels()->logger);
- out << "activation failed for server `" << _id << "':\n";
- out << ex;
+ Ice::Warning out(_node->getTraceLevels()->logger);
+ out << "activation failed for server `" << _id << "':\n";
+ out << ex;
- ostringstream os;
- os << ex;
- failure = os.str();
+ ostringstream os;
+ os << ex;
+ failure = os.str();
}
{
- Lock sync(*this);
- disableOnFailure();
- setStateNoSync(ServerI::Deactivating, failure);
+ Lock sync(*this);
+ disableOnFailure();
+ setStateNoSync(ServerI::Deactivating, failure);
}
for(ServerAdapterDict::iterator r = adpts.begin(); r != adpts.end(); ++r)
{
- try
- {
- r->second->activationFailed(failure);
- }
- catch(const Ice::ObjectNotExistException&)
- {
- }
+ try
+ {
+ r->second->activationFailed(failure);
+ }
+ catch(const Ice::ObjectNotExistException&)
+ {
+ }
}
setState(ServerI::Inactive);
@@ -1415,23 +1415,23 @@ void
ServerI::kill()
{
{
- Lock sync(*this);
- if(_state != Destroying && _state != Deactivating && _state != DeactivatingWaitForProcess)
- {
- return;
- }
+ Lock sync(*this);
+ if(_state != Destroying && _state != Deactivating && _state != DeactivatingWaitForProcess)
+ {
+ return;
+ }
}
try
{
- _node->getActivator()->kill(_id);
+ _node->getActivator()->kill(_id);
}
catch(const Ice::SyscallException& ex)
{
- Ice::Warning out(_node->getTraceLevels()->logger);
- out << "deactivation failed for server `" << _id << "':\n";
- out << ex;
- setState(ServerI::Inactive); // TODO: Is this really correct?
+ Ice::Warning out(_node->getTraceLevels()->logger);
+ out << "deactivation failed for server `" << _id << "':\n";
+ out << ex;
+ setState(ServerI::Inactive); // TODO: Is this really correct?
}
}
@@ -1440,55 +1440,55 @@ ServerI::deactivate()
{
Ice::ProcessPrx process;
{
- Lock sync(*this);
- assert(_desc);
- if(_state != Deactivating && _state != DeactivatingWaitForProcess)
- {
- return;
- }
-
- //
- // If a process object is supposed to be registered and it's
- // not set yet, we wait for the server to set this process
- // object before attempting to deactivate the server again.
- //
- if(_desc->processRegistered && !_process)
- {
- setStateNoSync(ServerI::DeactivatingWaitForProcess);
- return;
- }
- process = _process;
+ Lock sync(*this);
+ assert(_desc);
+ if(_state != Deactivating && _state != DeactivatingWaitForProcess)
+ {
+ return;
+ }
+
+ //
+ // If a process object is supposed to be registered and it's
+ // not set yet, we wait for the server to set this process
+ // object before attempting to deactivate the server again.
+ //
+ if(_desc->processRegistered && !_process)
+ {
+ setStateNoSync(ServerI::DeactivatingWaitForProcess);
+ return;
+ }
+ process = _process;
}
try
{
- //
- // Deactivate the server and for the termination of the server.
- //
- _node->getActivator()->deactivate(_id, process);
- return;
+ //
+ // Deactivate the server and for the termination of the server.
+ //
+ _node->getActivator()->deactivate(_id, process);
+ return;
}
catch(const Ice::Exception& ex)
{
- Ice::Warning out(_node->getTraceLevels()->logger);
- out << "graceful server shutdown failed, killing server `" << _id << "':\n";
- out << ex;
+ Ice::Warning out(_node->getTraceLevels()->logger);
+ out << "graceful server shutdown failed, killing server `" << _id << "':\n";
+ out << ex;
}
try
{
- //
- // If we couldn't deactivate it we kill it.
- //
- _node->getActivator()->kill(_id);
- return;
+ //
+ // If we couldn't deactivate it we kill it.
+ //
+ _node->getActivator()->kill(_id);
+ return;
}
catch(const Ice::SyscallException& ex)
{
- Ice::Warning out(_node->getTraceLevels()->logger);
- out << "deactivation failed for server `" << _id << "':\n";
- out << ex;
- setState(ServerI::Inactive); // TODO: Is this really correct?
+ Ice::Warning out(_node->getTraceLevels()->logger);
+ out << "deactivation failed for server `" << _id << "':\n";
+ out << ex;
+ setState(ServerI::Inactive); // TODO: Is this really correct?
}
}
@@ -1497,25 +1497,25 @@ ServerI::destroy()
{
ServerAdapterDict adpts;
{
- Lock sync(*this);
- assert(_desc);
- assert(_state == Destroying);
- adpts = _adapters;
+ Lock sync(*this);
+ assert(_desc);
+ assert(_state == Destroying);
+ adpts = _adapters;
}
_node->removeServer(this, _desc->application, _desc->applicationDistrib);
try
{
- IcePatch2::removeRecursive(_serverDir);
+ IcePatch2::removeRecursive(_serverDir);
}
catch(const string& msg)
{
- if(!_destroy->loadFailure())
- {
- Ice::Warning out(_node->getTraceLevels()->logger);
- out << "removing server directory `" << _serverDir << "' failed: " << msg;
- }
+ if(!_destroy->loadFailure())
+ {
+ Ice::Warning out(_node->getTraceLevels()->logger);
+ out << "removing server directory `" << _serverDir << "' failed: " << msg;
+ }
}
//
@@ -1523,13 +1523,13 @@ ServerI::destroy()
//
for(ServerAdapterDict::const_iterator p = adpts.begin(); p != adpts.end(); ++p)
{
- try
- {
- p->second->destroy();
- }
- catch(const Ice::LocalException&)
- {
- }
+ try
+ {
+ p->second->destroy();
+ }
+ catch(const Ice::LocalException&)
+ {
+ }
}
setState(Destroyed);
@@ -1540,53 +1540,53 @@ ServerI::terminated(const string& msg, int status)
{
ServerAdapterDict adpts;
{
- Lock sync(*this);
- while(_state == ServerI::Activating)
- {
- wait(); // Wait for activate() to set the state to WaitForActivation
- }
+ Lock sync(*this);
+ while(_state == ServerI::Activating)
+ {
+ wait(); // Wait for activate() to set the state to WaitForActivation
+ }
- adpts = _adapters;
- _activatedAdapters.clear();
- _pid = 0;
+ adpts = _adapters;
+ _activatedAdapters.clear();
+ _pid = 0;
- bool failed = false;
+ bool failed = false;
#ifndef _WIN32
- failed = WIFEXITED(status) && WEXITSTATUS(status) != 0;
- if(WIFSIGNALED(status))
- {
- int s = WTERMSIG(status);
- failed = s == SIGABRT || s == SIGILL || s == SIGBUS || s == SIGFPE || s == SIGSEGV;
- }
+ failed = WIFEXITED(status) && WEXITSTATUS(status) != 0;
+ if(WIFSIGNALED(status))
+ {
+ int s = WTERMSIG(status);
+ failed = s == SIGABRT || s == SIGILL || s == SIGBUS || s == SIGFPE || s == SIGSEGV;
+ }
#else
- failed = status != 0;
+ failed = status != 0;
#endif
- if(failed)
- {
- disableOnFailure();
- }
-
- if(_state != ServerI::Deactivating &&
- _state != ServerI::DeactivatingWaitForProcess &&
- _state != ServerI::Destroying)
- {
- ostringstream os;
- os << "The server terminated unexpectedly";
+ if(failed)
+ {
+ disableOnFailure();
+ }
+
+ if(_state != ServerI::Deactivating &&
+ _state != ServerI::DeactivatingWaitForProcess &&
+ _state != ServerI::Destroying)
+ {
+ ostringstream os;
+ os << "The server terminated unexpectedly";
#ifndef _WIN32
- if(WIFEXITED(status))
- {
- os << " with exit code " << WEXITSTATUS(status);
- }
- else if(WIFSIGNALED(status))
- {
- os << " with signal " << signalToString(WTERMSIG(status));
- }
+ if(WIFEXITED(status))
+ {
+ os << " with exit code " << WEXITSTATUS(status);
+ }
+ else if(WIFSIGNALED(status))
+ {
+ os << " with signal " << signalToString(WTERMSIG(status));
+ }
#else
- os << " with exit code " << status;
+ os << " with exit code " << status;
#endif
- os << (msg.empty() ? string(".") : ":\n" + msg);
- setStateNoSync(ServerI::Deactivating, os.str());
- }
+ os << (msg.empty() ? string(".") : ":\n" + msg);
+ setStateNoSync(ServerI::Deactivating, os.str());
+ }
}
//
@@ -1596,36 +1596,36 @@ ServerI::terminated(const string& msg, int status)
//
for(ServerAdapterDict::iterator p = adpts.begin(); p != adpts.end(); ++p)
{
- try
- {
- p->second->setDirectProxy(0);
- }
- catch(const Ice::ObjectNotExistException&)
- {
- }
+ try
+ {
+ p->second->setDirectProxy(0);
+ }
+ catch(const Ice::ObjectNotExistException&)
+ {
+ }
}
bool doDestroy = false;
ServerCommandPtr command;
{
- Lock sync(*this);
- if(_state == ServerI::Destroying)
- {
- doDestroy = true;
- }
- else
- {
- setStateNoSync(ServerI::Inactive);
- command = nextCommand();
- }
+ Lock sync(*this);
+ if(_state == ServerI::Destroying)
+ {
+ doDestroy = true;
+ }
+ else
+ {
+ setStateNoSync(ServerI::Inactive);
+ command = nextCommand();
+ }
}
if(doDestroy)
{
- destroy();
+ destroy();
}
else if(command)
{
- command->execute();
+ command->execute();
}
}
@@ -1634,104 +1634,104 @@ ServerI::update()
{
ServerCommandPtr command;
{
- Lock sync(*this);
- if(_state != ServerI::Loading)
- {
- return;
- }
-
- InternalServerDescriptorPtr oldDescriptor = _desc;
- try
- {
- if(_load->clearDir())
- {
- //
- // The server was explicitely destroyed then updated,
- // we first need to cleanup the directory to remove
- // any user created files.
- //
- try
- {
- IcePatch2::removeRecursive(_serverDir);
- }
- catch(const string&)
- {
- }
- }
-
- try
- {
- updateImpl(_load->getInternalServerDescriptor());
- }
- catch(const Ice::Exception& ex)
- {
- ostringstream os;
- os << ex;
- throw DeploymentException(os.str());
- }
- catch(const string& msg)
- {
- throw DeploymentException(msg);
- }
- catch(const char* msg)
- {
- throw DeploymentException(msg);
- }
-
- if(oldDescriptor)
- {
- _node->removeServer(this, oldDescriptor->application, oldDescriptor->applicationDistrib);
- }
- _node->addServer(this, _desc->application, _desc->applicationDistrib);
-
- AdapterPrxDict adapters;
- for(ServerAdapterDict::const_iterator p = _adapters.begin(); p != _adapters.end(); ++p)
- {
- adapters.insert(make_pair(p->first, p->second->getProxy()));
- }
- _load->finished(_this, adapters, _activationTimeout, _deactivationTimeout);
- }
- catch(const DeploymentException& ex)
- {
- //
- // Rollback old descriptor.
- //
- if(oldDescriptor)
- {
- try
- {
- updateImpl(oldDescriptor);
- }
- catch(const Ice::Exception& e)
- {
- Ice::Warning out(_node->getTraceLevels()->logger);
- out << "update failed:\n" << ex.reason << "\nand couldn't rollback old descriptor:\n" << e;
- }
- catch(const string& msg)
- {
- Ice::Warning out(_node->getTraceLevels()->logger);
- out << "update failed:\n" << ex.reason << "\nand couldn't rollback old descriptor:\n" << msg;
- }
- catch(const char* msg)
- {
- Ice::Warning out(_node->getTraceLevels()->logger);
- out << "update failed:\n" << ex.reason << "\nand couldn't rollback old descriptor:\n" << msg;
- }
- }
- else if(!_destroy)
- {
- _destroy = new DestroyCommand(this, true);
- }
-
- _load->failed(ex);
- }
-
- setStateNoSync(Inactive);
- command = nextCommand();
+ Lock sync(*this);
+ if(_state != ServerI::Loading)
+ {
+ return;
+ }
+
+ InternalServerDescriptorPtr oldDescriptor = _desc;
+ try
+ {
+ if(_load->clearDir())
+ {
+ //
+ // The server was explicitely destroyed then updated,
+ // we first need to cleanup the directory to remove
+ // any user created files.
+ //
+ try
+ {
+ IcePatch2::removeRecursive(_serverDir);
+ }
+ catch(const string&)
+ {
+ }
+ }
+
+ try
+ {
+ updateImpl(_load->getInternalServerDescriptor());
+ }
+ catch(const Ice::Exception& ex)
+ {
+ ostringstream os;
+ os << ex;
+ throw DeploymentException(os.str());
+ }
+ catch(const string& msg)
+ {
+ throw DeploymentException(msg);
+ }
+ catch(const char* msg)
+ {
+ throw DeploymentException(msg);
+ }
+
+ if(oldDescriptor)
+ {
+ _node->removeServer(this, oldDescriptor->application, oldDescriptor->applicationDistrib);
+ }
+ _node->addServer(this, _desc->application, _desc->applicationDistrib);
+
+ AdapterPrxDict adapters;
+ for(ServerAdapterDict::const_iterator p = _adapters.begin(); p != _adapters.end(); ++p)
+ {
+ adapters.insert(make_pair(p->first, p->second->getProxy()));
+ }
+ _load->finished(_this, adapters, _activationTimeout, _deactivationTimeout);
+ }
+ catch(const DeploymentException& ex)
+ {
+ //
+ // Rollback old descriptor.
+ //
+ if(oldDescriptor)
+ {
+ try
+ {
+ updateImpl(oldDescriptor);
+ }
+ catch(const Ice::Exception& e)
+ {
+ Ice::Warning out(_node->getTraceLevels()->logger);
+ out << "update failed:\n" << ex.reason << "\nand couldn't rollback old descriptor:\n" << e;
+ }
+ catch(const string& msg)
+ {
+ Ice::Warning out(_node->getTraceLevels()->logger);
+ out << "update failed:\n" << ex.reason << "\nand couldn't rollback old descriptor:\n" << msg;
+ }
+ catch(const char* msg)
+ {
+ Ice::Warning out(_node->getTraceLevels()->logger);
+ out << "update failed:\n" << ex.reason << "\nand couldn't rollback old descriptor:\n" << msg;
+ }
+ }
+ else if(!_destroy)
+ {
+ _destroy = new DestroyCommand(this, true);
+ }
+
+ _load->failed(ex);
+ }
+
+ setStateNoSync(Inactive);
+ command = nextCommand();
}
if(command)
{
- command->execute();
+ command->execute();
}
}
@@ -1752,69 +1752,69 @@ ServerI::updateImpl(const InternalServerDescriptorPtr& descriptor)
// can't start).
//
bool serverSessionReleased = _desc && _desc->activation == "session" &&
- _desc->revision == descriptor->revision && !_desc->sessionId.empty() && descriptor->sessionId.empty();
+ _desc->revision == descriptor->revision && !_desc->sessionId.empty() && descriptor->sessionId.empty();
//
// Go through the adapters and create the object adapter Ice
// objects if necessary, also remove the old ones.
//
{
- ServerAdapterDict oldAdapters;
- oldAdapters.swap(_adapters);
- _serverLifetimeAdapters.clear();
- Ice::ObjectAdapterPtr adapter = _node->getAdapter();
- for(InternalAdapterDescriptorSeq::const_iterator r = _desc->adapters.begin(); r != _desc->adapters.end(); ++r)
- {
- try
- {
- Ice::Identity id;
- id.category = _this->ice_getIdentity().category + "Adapter";
- id.name = _id + "-" + (*r)->id;
- ServerAdapterIPtr servant = ServerAdapterIPtr::dynamicCast(adapter->find(id));
- if(!servant)
- {
- AdapterPrx proxy = AdapterPrx::uncheckedCast(adapter->createProxy(id));
- servant = new ServerAdapterI(_node, this, _id, proxy, (*r)->id);
- adapter->add(servant, id);
- }
- _adapters.insert(make_pair((*r)->id, servant));
-
- if((*r)->serverLifetime)
- {
- _serverLifetimeAdapters.insert((*r)->id);
- }
- }
- catch(const Ice::ObjectAdapterDeactivatedException&)
- {
- // IGNORE
- }
- catch(const Ice::LocalException& ex)
- {
- Ice::Error out(_node->getTraceLevels()->logger);
- out << "couldn't add adapter `" << (*r)->id << "':\n" << ex;
- }
- oldAdapters.erase((*r)->id);
- }
-
- //
- // Remove old object adapters.
- //
- for(ServerAdapterDict::const_iterator t = oldAdapters.begin(); t != oldAdapters.end(); ++t)
- {
- try
- {
- t->second->destroy();
- }
- catch(const Ice::ObjectAdapterDeactivatedException&)
- {
- // IGNORE
- }
- catch(const Ice::LocalException& ex)
- {
- Ice::Error out(_node->getTraceLevels()->logger);
- out << "couldn't destroy adapter `" << t->first << "':\n" << ex;
- }
- }
+ ServerAdapterDict oldAdapters;
+ oldAdapters.swap(_adapters);
+ _serverLifetimeAdapters.clear();
+ Ice::ObjectAdapterPtr adapter = _node->getAdapter();
+ for(InternalAdapterDescriptorSeq::const_iterator r = _desc->adapters.begin(); r != _desc->adapters.end(); ++r)
+ {
+ try
+ {
+ Ice::Identity id;
+ id.category = _this->ice_getIdentity().category + "Adapter";
+ id.name = _id + "-" + (*r)->id;
+ ServerAdapterIPtr servant = ServerAdapterIPtr::dynamicCast(adapter->find(id));
+ if(!servant)
+ {
+ AdapterPrx proxy = AdapterPrx::uncheckedCast(adapter->createProxy(id));
+ servant = new ServerAdapterI(_node, this, _id, proxy, (*r)->id);
+ adapter->add(servant, id);
+ }
+ _adapters.insert(make_pair((*r)->id, servant));
+
+ if((*r)->serverLifetime)
+ {
+ _serverLifetimeAdapters.insert((*r)->id);
+ }
+ }
+ catch(const Ice::ObjectAdapterDeactivatedException&)
+ {
+ // IGNORE
+ }
+ catch(const Ice::LocalException& ex)
+ {
+ Ice::Error out(_node->getTraceLevels()->logger);
+ out << "couldn't add adapter `" << (*r)->id << "':\n" << ex;
+ }
+ oldAdapters.erase((*r)->id);
+ }
+
+ //
+ // Remove old object adapters.
+ //
+ for(ServerAdapterDict::const_iterator t = oldAdapters.begin(); t != oldAdapters.end(); ++t)
+ {
+ try
+ {
+ t->second->destroy();
+ }
+ catch(const Ice::ObjectAdapterDeactivatedException&)
+ {
+ // IGNORE
+ }
+ catch(const Ice::LocalException& ex)
+ {
+ Ice::Error out(_node->getTraceLevels()->logger);
+ out << "couldn't destroy adapter `" << t->first << "':\n" << ex;
+ }
+ }
}
//
@@ -1826,15 +1826,15 @@ ServerI::updateImpl(const InternalServerDescriptorPtr& descriptor)
//
if(_activation != Disabled || _failureTime != IceUtil::Time())
{
- _activation = toServerActivation(_desc->activation);
- _failureTime = IceUtil::Time();
+ _activation = toServerActivation(_desc->activation);
+ _failureTime = IceUtil::Time();
}
if(_timer)
{
- _node->getWaitQueue()->remove(_timer);
- _timer = 0;
- }
+ _node->getWaitQueue()->remove(_timer);
+ _timer = 0;
+ }
//
// Don't change the user if the server has the session activation
@@ -1843,21 +1843,21 @@ ServerI::updateImpl(const InternalServerDescriptorPtr& descriptor)
string user;
if(_desc->activation != "session" || !_desc->sessionId.empty())
{
- user = _desc->user;
+ user = _desc->user;
#ifndef _WIN32
- //
- // Check if the node is running as root, if that's the case we
- // make sure that a user is set for the process.
- //
- if(getuid() == 0 && user.empty())
- {
- //
- // If no user is configured and if this server is owned by
- // a session we set the user to the session id, otherwise
- // we set it to "nobody".
- //
- user = !_desc->sessionId.empty() ? _desc->sessionId : "nobody";
- }
+ //
+ // Check if the node is running as root, if that's the case we
+ // make sure that a user is set for the process.
+ //
+ if(getuid() == 0 && user.empty())
+ {
+ //
+ // If no user is configured and if this server is owned by
+ // a session we set the user to the session id, otherwise
+ // we set it to "nobody".
+ //
+ user = !_desc->sessionId.empty() ? _desc->sessionId : "nobody";
+ }
#endif
}
@@ -1867,108 +1867,108 @@ ServerI::updateImpl(const InternalServerDescriptorPtr& descriptor)
if(!user.empty())
{
- UserAccountMapperPrx mapper = _node->getUserAccountMapper();
- if(mapper)
- {
- try
- {
- user = mapper->getUserAccount(user);
- }
- catch(const UserAccountNotFoundException&)
- {
- throw "couldn't find user account for user `" + user + "'";
- }
- catch(const Ice::LocalException& ex)
- {
- ostringstream os;
- os << "unexpected exception while trying to find user account for user `" << user << "':\n" << ex;
- throw os.str();
- }
- }
+ UserAccountMapperPrx mapper = _node->getUserAccountMapper();
+ if(mapper)
+ {
+ try
+ {
+ user = mapper->getUserAccount(user);
+ }
+ catch(const UserAccountNotFoundException&)
+ {
+ throw "couldn't find user account for user `" + user + "'";
+ }
+ catch(const Ice::LocalException& ex)
+ {
+ ostringstream os;
+ os << "unexpected exception while trying to find user account for user `" << user << "':\n" << ex;
+ throw os.str();
+ }
+ }
#ifdef _WIN32
- //
- // Windows doesn't support running processes under another
- // account (at least not easily, see the CreateProcessAsUser
- // documentation). So if a user is specified, we just check
- // that the node is running under the same user account as the
- // one which is specified.
- //
- vector<char> buf(256);
- buf.resize(256);
- DWORD size = static_cast<DWORD>(buf.size());
- bool success = GetUserName(&buf[0], &size);
- if(!success && GetLastError() == ERROR_INSUFFICIENT_BUFFER)
- {
- buf.resize(size);
- success = GetUserName(&buf[0], &size);
- }
- if(!success)
- {
- Ice::SyscallException ex(__FILE__, __LINE__);
- ex.error = getSystemErrno();
- throw ex;
- }
- if(user != string(&buf[0]))
- {
- throw "couldn't load server under user account `" + user + "': feature not supported on Windows";
- }
+ //
+ // Windows doesn't support running processes under another
+ // account (at least not easily, see the CreateProcessAsUser
+ // documentation). So if a user is specified, we just check
+ // that the node is running under the same user account as the
+ // one which is specified.
+ //
+ vector<char> buf(256);
+ buf.resize(256);
+ DWORD size = static_cast<DWORD>(buf.size());
+ bool success = GetUserName(&buf[0], &size);
+ if(!success && GetLastError() == ERROR_INSUFFICIENT_BUFFER)
+ {
+ buf.resize(size);
+ success = GetUserName(&buf[0], &size);
+ }
+ if(!success)
+ {
+ Ice::SyscallException ex(__FILE__, __LINE__);
+ ex.error = getSystemErrno();
+ throw ex;
+ }
+ if(user != string(&buf[0]))
+ {
+ throw "couldn't load server under user account `" + user + "': feature not supported on Windows";
+ }
#else
- //
- // Get the uid/gid associated with the given user.
- //
- struct passwd* pw = getpwnam(user.c_str());
- if(!pw)
- {
- throw "unknown user account `" + user + "'";
- }
-
- //
- // If the node isn't running as root and if the uid of the
- // configured user is different from the uid of the userr
- // running the node we throw, a regular user can't run a
- // process as another user.
- //
- uid_t uid = getuid();
- if(uid != 0 && pw->pw_uid != uid)
- {
- throw "node has insufficient privileges to load server under user account `" + user + "'";
- }
-
- if(pw->pw_uid == 0) // Don't allow running proccesses as "root"
- {
- throw "running server as `root' is not allowed";
- }
-
- newUser = _uid != pw->pw_uid || _gid != pw->pw_gid;
- _uid = pw->pw_uid;
- _gid = pw->pw_gid;
+ //
+ // Get the uid/gid associated with the given user.
+ //
+ struct passwd* pw = getpwnam(user.c_str());
+ if(!pw)
+ {
+ throw "unknown user account `" + user + "'";
+ }
+
+ //
+ // If the node isn't running as root and if the uid of the
+ // configured user is different from the uid of the userr
+ // running the node we throw, a regular user can't run a
+ // process as another user.
+ //
+ uid_t uid = getuid();
+ if(uid != 0 && pw->pw_uid != uid)
+ {
+ throw "node has insufficient privileges to load server under user account `" + user + "'";
+ }
+
+ if(pw->pw_uid == 0) // Don't allow running proccesses as "root"
+ {
+ throw "running server as `root' is not allowed";
+ }
+
+ newUser = _uid != pw->pw_uid || _gid != pw->pw_gid;
+ _uid = pw->pw_uid;
+ _gid = pw->pw_gid;
#endif
}
#ifndef _WIN32
else
- {
- //
- // If no user is specified, we'll run the process as the
- // current user.
- //
- uid_t uid = getuid();
- uid_t gid = getgid();
- newUser = _uid != uid || _gid != gid;
- _uid = uid;
- _gid = gid;
+ {
+ //
+ // If no user is specified, we'll run the process as the
+ // current user.
+ //
+ uid_t uid = getuid();
+ uid_t gid = getgid();
+ newUser = _uid != uid || _gid != gid;
+ _uid = uid;
+ _gid = gid;
}
#endif
istringstream at(_desc->activationTimeout);
if(!(at >> _activationTimeout) || !at.eof() || _activationTimeout == 0)
{
- _activationTimeout = _waitTime;
+ _activationTimeout = _waitTime;
}
istringstream dt(_desc->deactivationTimeout);
if(!(dt >> _deactivationTimeout) || !dt.eof() || _deactivationTimeout == 0)
{
- _deactivationTimeout = _waitTime;
+ _deactivationTimeout = _waitTime;
}
//
@@ -2008,16 +2008,16 @@ ServerI::updateImpl(const InternalServerDescriptorPtr& descriptor)
string outputDir = _node->getOutputDir();
if(!outputDir.empty())
{
- if(_stdErrFile.empty())
- {
- _stdErrFile = outputDir + "/" + _id + (_node->getRedirectErrToOut() ? ".out" : ".err");
- props.push_back(createProperty("Ice.StdErr", _stdErrFile));
- }
- if(_stdOutFile.empty())
- {
- _stdOutFile = outputDir + "/" + _id + ".out";
- props.push_back(createProperty("Ice.StdOut", _stdOutFile));
- }
+ if(_stdErrFile.empty())
+ {
+ _stdErrFile = outputDir + "/" + _id + (_node->getRedirectErrToOut() ? ".out" : ".err");
+ props.push_back(createProperty("Ice.StdErr", _stdErrFile));
+ }
+ if(_stdOutFile.empty())
+ {
+ _stdOutFile = outputDir + "/" + _id + ".out";
+ props.push_back(createProperty("Ice.StdOut", _stdOutFile));
+ }
}
//
@@ -2025,21 +2025,21 @@ ServerI::updateImpl(const InternalServerDescriptorPtr& descriptor)
//
{
const PropertyDescriptorSeq& overrides = _node->getPropertiesOverride();
- for(PropertyDescriptorSeqDict::iterator p = properties.begin(); p != properties.end(); ++p)
- {
- if(getProperty(p->second, "Ice.Default.Locator").empty())
- {
- p->second.push_back(
- createProperty("Ice.Default.Locator",
- _node->getCommunicator()->getProperties()->getProperty("Ice.Default.Locator")));
- }
+ for(PropertyDescriptorSeqDict::iterator p = properties.begin(); p != properties.end(); ++p)
+ {
+ if(getProperty(p->second, "Ice.Default.Locator").empty())
+ {
+ p->second.push_back(
+ createProperty("Ice.Default.Locator",
+ _node->getCommunicator()->getProperties()->getProperty("Ice.Default.Locator")));
+ }
if(!overrides.empty())
{
p->second.push_back(createProperty("# Node properties override"));
p->second.insert(p->second.end(), overrides.begin(), overrides.end());
}
- }
+ }
}
//
@@ -2049,7 +2049,7 @@ ServerI::updateImpl(const InternalServerDescriptorPtr& descriptor)
//
if(serverSessionReleased)
{
- return;
+ return;
}
//
@@ -2069,55 +2069,55 @@ ServerI::updateImpl(const InternalServerDescriptorPtr& descriptor)
// Create the configuration files, remove the old ones.
//
{
- Ice::StringSeq knownFiles;
- for(PropertyDescriptorSeqDict::const_iterator p = properties.begin(); p != properties.end(); ++p)
- {
- knownFiles.push_back(p->first);
-
- const string configFilePath = _serverDir + "/config/" + p->first;
- ofstream configfile(configFilePath.c_str());
- if(!configfile.good())
- {
- throw "couldn't create configuration file: " + configFilePath;
- }
- configfile << "# Configuration file (" << IceUtil::Time::now().toDateTime();
- configfile << ", " << _desc->iceVersion << ")" << endl << endl;
- for(PropertyDescriptorSeq::const_iterator r = p->second.begin(); r != p->second.end(); ++r)
- {
- if(r->value.empty() && r->name.find('#') == 0)
- {
- configfile << r->name << endl;
- }
- else
- {
- configfile << r->name << "=" << r->value << endl;
- }
- }
- configfile.close();
- }
- sort(knownFiles.begin(), knownFiles.end());
-
- //
- // Remove old configuration files.
- //
- Ice::StringSeq files = IcePatch2::readDirectory(_serverDir + "/config");
- Ice::StringSeq toDel;
- set_difference(files.begin(), files.end(), knownFiles.begin(), knownFiles.end(), back_inserter(toDel));
- for(Ice::StringSeq::const_iterator q = toDel.begin(); q != toDel.end(); ++q)
- {
- if(q->find("config_") == 0)
- {
- try
- {
- IcePatch2::remove(_serverDir + "/config/" + *q);
- }
- catch(const string& msg)
- {
- Ice::Warning out(_node->getTraceLevels()->logger);
- out << "couldn't remove file `" + _serverDir + "/config/" + *q + "':\n" + msg;
- }
- }
- }
+ Ice::StringSeq knownFiles;
+ for(PropertyDescriptorSeqDict::const_iterator p = properties.begin(); p != properties.end(); ++p)
+ {
+ knownFiles.push_back(p->first);
+
+ const string configFilePath = _serverDir + "/config/" + p->first;
+ ofstream configfile(configFilePath.c_str());
+ if(!configfile.good())
+ {
+ throw "couldn't create configuration file: " + configFilePath;
+ }
+ configfile << "# Configuration file (" << IceUtil::Time::now().toDateTime();
+ configfile << ", " << _desc->iceVersion << ")" << endl << endl;
+ for(PropertyDescriptorSeq::const_iterator r = p->second.begin(); r != p->second.end(); ++r)
+ {
+ if(r->value.empty() && r->name.find('#') == 0)
+ {
+ configfile << r->name << endl;
+ }
+ else
+ {
+ configfile << r->name << "=" << r->value << endl;
+ }
+ }
+ configfile.close();
+ }
+ sort(knownFiles.begin(), knownFiles.end());
+
+ //
+ // Remove old configuration files.
+ //
+ Ice::StringSeq files = IcePatch2::readDirectory(_serverDir + "/config");
+ Ice::StringSeq toDel;
+ set_difference(files.begin(), files.end(), knownFiles.begin(), knownFiles.end(), back_inserter(toDel));
+ for(Ice::StringSeq::const_iterator q = toDel.begin(); q != toDel.end(); ++q)
+ {
+ if(q->find("config_") == 0)
+ {
+ try
+ {
+ IcePatch2::remove(_serverDir + "/config/" + *q);
+ }
+ catch(const string& msg)
+ {
+ Ice::Warning out(_node->getTraceLevels()->logger);
+ out << "couldn't remove file `" + _serverDir + "/config/" + *q + "':\n" + msg;
+ }
+ }
+ }
}
//
@@ -2125,67 +2125,67 @@ ServerI::updateImpl(const InternalServerDescriptorPtr& descriptor)
// old ones.
//
{
- Ice::StringSeq knownDbEnvs;
- for(InternalDbEnvDescriptorSeq::const_iterator q = _desc->dbEnvs.begin(); q != _desc->dbEnvs.end(); ++q)
- {
- knownDbEnvs.push_back((*q)->name);
-
- string dbEnvHome = _serverDir + "/dbs/" + (*q)->name;
- createOrUpdateDirectory(dbEnvHome);
-
- if(!(*q)->properties.empty())
- {
- string file = dbEnvHome + "/DB_CONFIG";
- ofstream configfile(file.c_str());
- if(!configfile.good())
- {
- throw "couldn't create configuration file `" + file + "'";
- }
-
- PropertyDescriptorSeq::const_iterator p;
- for(p = (*q)->properties.begin(); p != (*q)->properties.end(); ++p)
- {
- if(!p->name.empty())
- {
- configfile << p->name;
- if(!p->value.empty())
- {
- configfile << " " << p->value;
- }
- configfile << endl;
- }
- }
- configfile.close();
- }
- }
- sort(knownDbEnvs.begin(), knownDbEnvs.end());
-
- //
- // Remove old database environments.
- //
- Ice::StringSeq dbEnvs = IcePatch2::readDirectory(_serverDir + "/dbs");
- Ice::StringSeq toDel;
- set_difference(dbEnvs.begin(), dbEnvs.end(), knownDbEnvs.begin(), knownDbEnvs.end(), back_inserter(toDel));
- for(Ice::StringSeq::const_iterator p = toDel.begin(); p != toDel.end(); ++p)
- {
- try
- {
- IcePatch2::removeRecursive(_serverDir + "/dbs/" + *p);
- }
- catch(const string& msg)
- {
- Ice::Warning out(_node->getTraceLevels()->logger);
- out << "couldn't remove directory `" + _serverDir + "/dbs/" + *p + "':\n" + msg;
- }
- }
+ Ice::StringSeq knownDbEnvs;
+ for(InternalDbEnvDescriptorSeq::const_iterator q = _desc->dbEnvs.begin(); q != _desc->dbEnvs.end(); ++q)
+ {
+ knownDbEnvs.push_back((*q)->name);
+
+ string dbEnvHome = _serverDir + "/dbs/" + (*q)->name;
+ createOrUpdateDirectory(dbEnvHome);
+
+ if(!(*q)->properties.empty())
+ {
+ string file = dbEnvHome + "/DB_CONFIG";
+ ofstream configfile(file.c_str());
+ if(!configfile.good())
+ {
+ throw "couldn't create configuration file `" + file + "'";
+ }
+
+ PropertyDescriptorSeq::const_iterator p;
+ for(p = (*q)->properties.begin(); p != (*q)->properties.end(); ++p)
+ {
+ if(!p->name.empty())
+ {
+ configfile << p->name;
+ if(!p->value.empty())
+ {
+ configfile << " " << p->value;
+ }
+ configfile << endl;
+ }
+ }
+ configfile.close();
+ }
+ }
+ sort(knownDbEnvs.begin(), knownDbEnvs.end());
+
+ //
+ // Remove old database environments.
+ //
+ Ice::StringSeq dbEnvs = IcePatch2::readDirectory(_serverDir + "/dbs");
+ Ice::StringSeq toDel;
+ set_difference(dbEnvs.begin(), dbEnvs.end(), knownDbEnvs.begin(), knownDbEnvs.end(), back_inserter(toDel));
+ for(Ice::StringSeq::const_iterator p = toDel.begin(); p != toDel.end(); ++p)
+ {
+ try
+ {
+ IcePatch2::removeRecursive(_serverDir + "/dbs/" + *p);
+ }
+ catch(const string& msg)
+ {
+ Ice::Warning out(_node->getTraceLevels()->logger);
+ out << "couldn't remove directory `" + _serverDir + "/dbs/" + *p + "':\n" + msg;
+ }
+ }
}
#ifndef _WIN32
if(newUser)
{
- chownRecursive(_serverDir + "/config", _uid, _gid);
- chownRecursive(_serverDir + "/dbs", _uid, _gid);
- chownRecursive(_serverDir + "/distrib", _uid, _gid);
+ chownRecursive(_serverDir + "/config", _uid, _gid);
+ chownRecursive(_serverDir + "/dbs", _uid, _gid);
+ chownRecursive(_serverDir + "/distrib", _uid, _gid);
}
#endif
}
@@ -2195,47 +2195,47 @@ ServerI::checkRevision(const string& replicaName, const string& uuid, int revisi
{
if(replicaName == "Master")
{
- return;
+ return;
}
string descUUID;
int descRevision;
if(_desc)
{
- descUUID = _desc->uuid;
- descRevision = _desc->revision;
+ descUUID = _desc->uuid;
+ descRevision = _desc->revision;
}
else
{
- string idFilePath = _serverDir + "/revision";
- ifstream is(idFilePath.c_str());
- if(!is.good())
- {
- return;
- }
-
- char line[1024];
- is.getline(line, 1024); // Ignore comments
- is.getline(line, 1024);
- is.getline(line, 1024);
- string ignore;
- is >> ignore >> descUUID;
- is >> ignore >> descRevision;
+ string idFilePath = _serverDir + "/revision";
+ ifstream is(idFilePath.c_str());
+ if(!is.good())
+ {
+ return;
+ }
+
+ char line[1024];
+ is.getline(line, 1024); // Ignore comments
+ is.getline(line, 1024);
+ is.getline(line, 1024);
+ string ignore;
+ is >> ignore >> descUUID;
+ is >> ignore >> descRevision;
}
if(uuid != descUUID)
{
- DeploymentException ex;
- ex.reason = "server from replica `" + replicaName + "' is from another application (`" + uuid + "')";
- throw ex;
+ DeploymentException ex;
+ ex.reason = "server from replica `" + replicaName + "' is from another application (`" + uuid + "')";
+ throw ex;
}
else if(revision != descRevision)
{
- ostringstream os;
- os << "server from replica `" + replicaName + "' has a different version:\n";
- os << "current revision: " << descRevision << "\n";
- os << "replica revision: " << revision;
- throw DeploymentException(os.str());
+ ostringstream os;
+ os << "server from replica `" + replicaName + "' has a different version:\n";
+ os << "current revision: " << descRevision << "\n";
+ os << "replica revision: " << revision;
+ throw DeploymentException(os.str());
}
}
@@ -2249,11 +2249,11 @@ ServerI::updateRevision(const string& uuid, int revision)
ofstream os(idFilePath.c_str());
if(os.good())
{
- os << "#" << endl;
- os << "# This server belongs to the application `" << _desc->application << "'" << endl;
- os << "#" << endl;
- os << "uuid: " << _desc->uuid << endl;
- os << "revision: " << _desc->revision << endl;
+ os << "#" << endl;
+ os << "# This server belongs to the application `" << _desc->application << "'" << endl;
+ os << "#" << endl;
+ os << "uuid: " << _desc->uuid << endl;
+ os << "revision: " << _desc->revision << endl;
}
}
@@ -2263,11 +2263,11 @@ ServerI::checkActivation()
//assert(locked());
if(_state == ServerI::WaitForActivation || _state == ServerI::ActivationTimeout)
{
- if(includes(_activatedAdapters.begin(), _activatedAdapters.end(),
- _serverLifetimeAdapters.begin(), _serverLifetimeAdapters.end()))
- {
- setStateNoSync(ServerI::Active);
- }
+ if(includes(_activatedAdapters.begin(), _activatedAdapters.end(),
+ _serverLifetimeAdapters.begin(), _serverLifetimeAdapters.end()))
+ {
+ setStateNoSync(ServerI::Active);
+ }
}
}
@@ -2276,13 +2276,13 @@ ServerI::setState(InternalServerState st, const std::string& reason)
{
ServerCommandPtr command;
{
- Lock sync(*this);
- setStateNoSync(st, reason);
- command = nextCommand();
+ Lock sync(*this);
+ setStateNoSync(st, reason);
+ command = nextCommand();
}
if(command)
{
- command->execute();
+ command->execute();
}
}
@@ -2292,27 +2292,27 @@ ServerI::nextCommand()
ServerCommandPtr command;
if(_stop && _stop->canExecute(_state))
{
- command = _stop;
+ command = _stop;
}
else if(_destroy && _destroy->canExecute(_state))
{
- command = _destroy;
+ command = _destroy;
}
else if(_load && _load->canExecute(_state))
{
- command = _load;
+ command = _load;
}
else if(_patch && _patch->canExecute(_state))
{
- command = _patch;
+ command = _patch;
}
else if(_start && _start->canExecute(_state))
{
- command = _start;
+ command = _start;
}
if(command)
{
- setStateNoSync(command->nextState());
+ setStateNoSync(command->nextState());
}
return command;
}
@@ -2326,37 +2326,37 @@ ServerI::setStateNoSync(InternalServerState st, const std::string& reason)
switch(st)
{
case Inactive:
- break;
+ break;
case Patching:
- assert(_patch && _patch->canExecute(_state));
- break;
+ assert(_patch && _patch->canExecute(_state));
+ break;
case Loading:
- assert(_load && _load->canExecute(_state));
- break;
+ assert(_load && _load->canExecute(_state));
+ break;
case Activating:
- assert(_start && _start->canExecute(_state));
- break;
+ assert(_start && _start->canExecute(_state));
+ break;
case WaitForActivation:
- assert(_state == Activating);
- break;
+ assert(_state == Activating);
+ break;
case ActivationTimeout:
- assert(_state == WaitForActivation);
- break;
+ assert(_state == WaitForActivation);
+ break;
case Active:
- assert(_state == WaitForActivation || _state == ActivationTimeout);
- break;
+ assert(_state == WaitForActivation || _state == ActivationTimeout);
+ break;
case Deactivating:
- //assert(_stop && _stop->canExecute(_state));
- break;
+ //assert(_stop && _stop->canExecute(_state));
+ break;
case DeactivatingWaitForProcess:
- assert(_state == Deactivating);
- break;
+ assert(_state == Deactivating);
+ break;
case Destroying:
- assert(_state == Inactive && _destroy && _destroy->canExecute(_state));
- break;
+ assert(_state == Inactive && _destroy && _destroy->canExecute(_state));
+ break;
case Destroyed:
- assert(_destroy);
- break;
+ assert(_destroy);
+ break;
}
//
@@ -2372,112 +2372,112 @@ ServerI::setStateNoSync(InternalServerState st, const std::string& reason)
switch(_state)
{
case Inactive:
- if(previous == Loading)
- {
- _load = 0;
- }
- if(previous == Patching)
- {
- _patch = 0;
- }
- if(_stop)
- {
- _stop->finished();
- _stop = 0;
- }
- break;
+ if(previous == Loading)
+ {
+ _load = 0;
+ }
+ if(previous == Patching)
+ {
+ _patch = 0;
+ }
+ if(_stop)
+ {
+ _stop->finished();
+ _stop = 0;
+ }
+ break;
case Active:
- if(_start)
- {
- _start->finished();
- _start = 0;
- }
- break;
+ if(_start)
+ {
+ _start->finished();
+ _start = 0;
+ }
+ break;
case ActivationTimeout:
- if(_start)
- {
- _start->failed(reason);
- _start = 0;
- }
- break;
+ if(_start)
+ {
+ _start->failed(reason);
+ _start = 0;
+ }
+ break;
case Deactivating:
- if(_start)
- {
- _start->failed(reason.empty() ? string("The server is being deactivated.") : reason);
- _start = 0;
- }
- break;
+ if(_start)
+ {
+ _start->failed(reason.empty() ? string("The server is being deactivated.") : reason);
+ _start = 0;
+ }
+ break;
case Destroying:
- loadFailure = _destroy->loadFailure();
- if(_patch)
- {
- _patch->destroyed();
- _patch = 0;
- }
- if(_load)
- {
- _load->failed(DeploymentException("The server is being destroyed."));
- _load = 0;
- }
- if(_start)
- {
- _start->failed("The server is being destroyed.");
- _start = 0;
- }
- if(_stop)
- {
- _stop->failed("The server is being destroyed.");
- _stop = 0;
- }
- break;
+ loadFailure = _destroy->loadFailure();
+ if(_patch)
+ {
+ _patch->destroyed();
+ _patch = 0;
+ }
+ if(_load)
+ {
+ _load->failed(DeploymentException("The server is being destroyed."));
+ _load = 0;
+ }
+ if(_start)
+ {
+ _start->failed("The server is being destroyed.");
+ _start = 0;
+ }
+ if(_stop)
+ {
+ _stop->failed("The server is being destroyed.");
+ _stop = 0;
+ }
+ break;
case Destroyed:
- if(_destroy)
- {
- loadFailure = _destroy->loadFailure();
- _destroy->finished();
- _destroy = 0;
- }
- break;
+ if(_destroy)
+ {
+ loadFailure = _destroy->loadFailure();
+ _destroy->finished();
+ _destroy = 0;
+ }
+ break;
default:
- break;
+ break;
}
if(_state == Destroyed && !_load)
{
- //
- // If the server is destroyed and there's no load command, we
- // remove the servant from the ASM.
- //
- try
- {
- _node->getAdapter()->remove(_this->ice_getIdentity());
- }
- catch(const Ice::ObjectAdapterDeactivatedException&)
- {
- // IGNORE
- }
- _desc = 0;
+ //
+ // If the server is destroyed and there's no load command, we
+ // remove the servant from the ASM.
+ //
+ try
+ {
+ _node->getAdapter()->remove(_this->ice_getIdentity());
+ }
+ catch(const Ice::ObjectAdapterDeactivatedException&)
+ {
+ // IGNORE
+ }
+ _desc = 0;
}
else if(_state == Inactive)
{
- if(_activation == Always)
- {
- _timer = new DelayedStart(this, _node->getTraceLevels());
- _node->getWaitQueue()->add(_timer, IceUtil::Time::milliSeconds(500));
- }
- else if(_activation == Disabled && _disableOnFailure > 0 && _failureTime != IceUtil::Time())
- {
- //
- // If the server was disabled because it failed, we
- // schedule a callback to re-enable it. We add 500ms to
- // the disable on failure duration to make sure that the
- // server will be ready to be reactivated when the
- // callback is executed.
- //
- _timer = new DelayedStart(this, _node->getTraceLevels());
- _node->getWaitQueue()->add(_timer,
- IceUtil::Time::seconds(_disableOnFailure) + IceUtil::Time::milliSeconds(500));
- }
+ if(_activation == Always)
+ {
+ _timer = new DelayedStart(this, _node->getTraceLevels());
+ _node->getWaitQueue()->add(_timer, IceUtil::Time::milliSeconds(500));
+ }
+ else if(_activation == Disabled && _disableOnFailure > 0 && _failureTime != IceUtil::Time())
+ {
+ //
+ // If the server was disabled because it failed, we
+ // schedule a callback to re-enable it. We add 500ms to
+ // the disable on failure duration to make sure that the
+ // server will be ready to be reactivated when the
+ // callback is executed.
+ //
+ _timer = new DelayedStart(this, _node->getTraceLevels());
+ _node->getWaitQueue()->add(_timer,
+ IceUtil::Time::seconds(_disableOnFailure) + IceUtil::Time::milliSeconds(500));
+ }
}
//
@@ -2491,69 +2491,69 @@ ServerI::setStateNoSync(InternalServerState st, const std::string& reason)
!(previous == Inactive && _state == Deactivating) &&
!loadFailure)
{
- _node->observerUpdateServer(getDynamicInfo());
+ _node->observerUpdateServer(getDynamicInfo());
}
if(_node->getTraceLevels()->server > 1)
{
- if(_state == ServerI::Active)
- {
- Ice::Trace out(_node->getTraceLevels()->logger, _node->getTraceLevels()->serverCat);
- out << "changed server `" << _id << "' state to `Active'";
- }
- else if(_state == ServerI::Inactive)
- {
- Ice::Trace out(_node->getTraceLevels()->logger, _node->getTraceLevels()->serverCat);
- out << "changed server `" << _id << "' state to `Inactive'";
- }
- else if(_state == ServerI::Destroyed)
- {
- Ice::Trace out(_node->getTraceLevels()->logger, _node->getTraceLevels()->serverCat);
- out << "changed server `" << _id << "' state to `Destroyed'";
- }
- else if(_node->getTraceLevels()->server > 2)
- {
- if(_state == ServerI::WaitForActivation)
- {
- Ice::Trace out(_node->getTraceLevels()->logger, _node->getTraceLevels()->serverCat);
- out << "changed server `" << _id << "' state to `WaitForActivation'";
- }
- else if(_state == ServerI::ActivationTimeout)
- {
- Ice::Trace out(_node->getTraceLevels()->logger, _node->getTraceLevels()->serverCat);
- out << "changed server `" << _id << "' state to `ActivationTimeout'";
- }
- else if(_state == ServerI::Activating)
- {
- Ice::Trace out(_node->getTraceLevels()->logger, _node->getTraceLevels()->serverCat);
- out << "changed server `" << _id << "' state to `Activating'";
- }
- else if(_state == ServerI::Deactivating)
- {
- Ice::Trace out(_node->getTraceLevels()->logger, _node->getTraceLevels()->serverCat);
- out << "changed server `" << _id << "' state to `Deactivating'";
- }
- else if(_state == ServerI::DeactivatingWaitForProcess)
- {
- Ice::Trace out(_node->getTraceLevels()->logger, _node->getTraceLevels()->serverCat);
- out << "changed server `" << _id << "' state to `DeactivatingWaitForProcess'";
- }
- else if(_state == ServerI::Destroying)
- {
- Ice::Trace out(_node->getTraceLevels()->logger, _node->getTraceLevels()->serverCat);
- out << "changed server `" << _id << "' state to `Destroying'";
- }
- else if(_state == ServerI::Loading)
- {
- Ice::Trace out(_node->getTraceLevels()->logger, _node->getTraceLevels()->serverCat);
- out << "changed server `" << _id << "' state to `Loading'";
- }
- else if(_state == ServerI::Patching)
- {
- Ice::Trace out(_node->getTraceLevels()->logger, _node->getTraceLevels()->serverCat);
- out << "changed server `" << _id << "' state to `Loading'";
- }
- }
+ if(_state == ServerI::Active)
+ {
+ Ice::Trace out(_node->getTraceLevels()->logger, _node->getTraceLevels()->serverCat);
+ out << "changed server `" << _id << "' state to `Active'";
+ }
+ else if(_state == ServerI::Inactive)
+ {
+ Ice::Trace out(_node->getTraceLevels()->logger, _node->getTraceLevels()->serverCat);
+ out << "changed server `" << _id << "' state to `Inactive'";
+ }
+ else if(_state == ServerI::Destroyed)
+ {
+ Ice::Trace out(_node->getTraceLevels()->logger, _node->getTraceLevels()->serverCat);
+ out << "changed server `" << _id << "' state to `Destroyed'";
+ }
+ else if(_node->getTraceLevels()->server > 2)
+ {
+ if(_state == ServerI::WaitForActivation)
+ {
+ Ice::Trace out(_node->getTraceLevels()->logger, _node->getTraceLevels()->serverCat);
+ out << "changed server `" << _id << "' state to `WaitForActivation'";
+ }
+ else if(_state == ServerI::ActivationTimeout)
+ {
+ Ice::Trace out(_node->getTraceLevels()->logger, _node->getTraceLevels()->serverCat);
+ out << "changed server `" << _id << "' state to `ActivationTimeout'";
+ }
+ else if(_state == ServerI::Activating)
+ {
+ Ice::Trace out(_node->getTraceLevels()->logger, _node->getTraceLevels()->serverCat);
+ out << "changed server `" << _id << "' state to `Activating'";
+ }
+ else if(_state == ServerI::Deactivating)
+ {
+ Ice::Trace out(_node->getTraceLevels()->logger, _node->getTraceLevels()->serverCat);
+ out << "changed server `" << _id << "' state to `Deactivating'";
+ }
+ else if(_state == ServerI::DeactivatingWaitForProcess)
+ {
+ Ice::Trace out(_node->getTraceLevels()->logger, _node->getTraceLevels()->serverCat);
+ out << "changed server `" << _id << "' state to `DeactivatingWaitForProcess'";
+ }
+ else if(_state == ServerI::Destroying)
+ {
+ Ice::Trace out(_node->getTraceLevels()->logger, _node->getTraceLevels()->serverCat);
+ out << "changed server `" << _id << "' state to `Destroying'";
+ }
+ else if(_state == ServerI::Loading)
+ {
+ Ice::Trace out(_node->getTraceLevels()->logger, _node->getTraceLevels()->serverCat);
+ out << "changed server `" << _id << "' state to `Loading'";
+ }
+ else if(_state == ServerI::Patching)
+ {
+ Ice::Trace out(_node->getTraceLevels()->logger, _node->getTraceLevels()->serverCat);
+ out << "changed server `" << _id << "' state to `Loading'";
+ }
+ }
}
}
@@ -2562,7 +2562,7 @@ ServerI::createOrUpdateDirectory(const string& dir)
{
try
{
- IcePatch2::createDirectory(dir);
+ IcePatch2::createDirectory(dir);
}
catch(const string&)
{
@@ -2570,7 +2570,7 @@ ServerI::createOrUpdateDirectory(const string& dir)
#ifndef _WIN32
if(chown(dir.c_str(), _uid, _gid) != 0)
{
- throw "can't set permissions on directory `" + dir + "'";
+ throw "can't set permissions on directory `" + dir + "'";
}
#endif
}
@@ -2584,23 +2584,23 @@ ServerI::toServerState(InternalServerState st) const
case ServerI::Activating:
case ServerI::Patching:
case ServerI::Loading:
- return IceGrid::Inactive;
+ return IceGrid::Inactive;
case ServerI::WaitForActivation:
- return IceGrid::Activating;
+ return IceGrid::Activating;
case ServerI::ActivationTimeout:
- return IceGrid::ActivationTimedOut;
+ return IceGrid::ActivationTimedOut;
case ServerI::Active:
- return IceGrid::Active;
+ return IceGrid::Active;
case ServerI::Deactivating:
case ServerI::DeactivatingWaitForProcess:
- return IceGrid::Deactivating;
+ return IceGrid::Deactivating;
case ServerI::Destroying:
- return IceGrid::Destroying;
+ return IceGrid::Destroying;
case ServerI::Destroyed:
- return IceGrid::Destroyed;
+ return IceGrid::Destroyed;
default:
- assert(false);
- return IceGrid::Destroyed;
+ assert(false);
+ return IceGrid::Destroyed;
}
}
@@ -2609,25 +2609,25 @@ ServerI::toServerActivation(const string& activation) const
{
if(activation == "on-demand")
{
- return OnDemand;
+ return OnDemand;
}
else if(activation == "session")
{
- return Session;
+ return Session;
}
else if(activation == "always")
{
- return Always;
+ return Always;
}
else if(activation == "manual" || activation.empty())
{
- return Manual;
+ return Manual;
}
else
{
- Ice::Warning out(_node->getTraceLevels()->logger);
- out << "unknown activation mode `" << activation << "' for server `" << _id << "'";
- return Manual;
+ Ice::Warning out(_node->getTraceLevels()->logger);
+ out << "unknown activation mode `" << activation << "' for server `" << _id << "'";
+ return Manual;
}
}
@@ -2653,36 +2653,36 @@ ServerI::getFilePath(const string& filename) const
{
if(filename == "stderr")
{
- if(_stdErrFile.empty())
- {
- throw FileNotAvailableException("Ice.StdErr configuration property is not set");
- }
- return _stdErrFile;
+ if(_stdErrFile.empty())
+ {
+ throw FileNotAvailableException("Ice.StdErr configuration property is not set");
+ }
+ return _stdErrFile;
}
else if(filename == "stdout")
{
- if(_stdOutFile.empty())
- {
- throw FileNotAvailableException("Ice.StdOut configuration property is not set");
- }
- return _stdOutFile;
+ if(_stdOutFile.empty())
+ {
+ throw FileNotAvailableException("Ice.StdOut configuration property is not set");
+ }
+ return _stdOutFile;
}
else if(!filename.empty() && filename[0] == '#')
{
- string path = IcePatch2::simplify(filename.substr(1));
+ string path = IcePatch2::simplify(filename.substr(1));
if(!IcePatch2::isAbsolute(path))
{
path = _node->getPlatformInfo().getCwd() + "/" + path;
}
- if(find(_logs.begin(), _logs.end(), path) == _logs.end())
- {
- throw FileNotAvailableException("unknown log file `" + path + "'");
- }
- return path;
+ if(find(_logs.begin(), _logs.end(), path) == _logs.end())
+ {
+ throw FileNotAvailableException("unknown log file `" + path + "'");
+ }
+ return path;
}
else
{
- throw FileNotAvailableException("unknown file");
+ throw FileNotAvailableException("unknown file");
return ""; // Keep the compiler happy.
}
}
diff --git a/cpp/src/IceGrid/ServerI.h b/cpp/src/IceGrid/ServerI.h
index e0dcf3e7cf6..2e0ef5b9afa 100644
--- a/cpp/src/IceGrid/ServerI.h
+++ b/cpp/src/IceGrid/ServerI.h
@@ -47,26 +47,26 @@ public:
enum InternalServerState
{
- Loading,
- Patching,
- Inactive,
- Activating,
- WaitForActivation,
- ActivationTimeout,
- Active,
- Deactivating,
- DeactivatingWaitForProcess,
- Destroying,
- Destroyed
+ Loading,
+ Patching,
+ Inactive,
+ Activating,
+ WaitForActivation,
+ ActivationTimeout,
+ Active,
+ Deactivating,
+ DeactivatingWaitForProcess,
+ Destroying,
+ Destroyed
};
enum ServerActivation
{
- Always,
- Session,
- OnDemand,
- Manual,
- Disabled
+ Always,
+ Session,
+ OnDemand,
+ Manual,
+ Disabled
};
ServerI(const NodeIPtr&, const ServerPrx&, const std::string&, const std::string&, int);
diff --git a/cpp/src/IceGrid/SessionI.cpp b/cpp/src/IceGrid/SessionI.cpp
index daa64ddb7d7..f27ded104d5 100644
--- a/cpp/src/IceGrid/SessionI.cpp
+++ b/cpp/src/IceGrid/SessionI.cpp
@@ -31,24 +31,24 @@ class AllocateObject : public ObjectAllocationRequest
public:
AllocateObject(const SessionIPtr& session, const TPtr& cb) :
- ObjectAllocationRequest(session), _cb(cb)
+ ObjectAllocationRequest(session), _cb(cb)
{
}
virtual void
response(const Ice::ObjectPrx& proxy)
{
- assert(_cb);
- _cb->ice_response(proxy);
- _cb = 0;
+ assert(_cb);
+ _cb->ice_response(proxy);
+ _cb = 0;
}
virtual void
exception(const AllocationException& ex)
{
- assert(_cb);
- _cb->ice_exception(ex);
- _cb = 0;
+ assert(_cb);
+ _cb->ice_exception(ex);
+ _cb = 0;
}
private:
@@ -65,8 +65,8 @@ newAllocateObject(const SessionIPtr& session, const IceUtil::Handle<T>& cb)
}
BaseSessionI::BaseSessionI(const string& id,
- const string& prefix,
- const DatabasePtr& database) :
+ const string& prefix,
+ const DatabasePtr& database) :
_id(id),
_prefix(prefix),
_traceLevels(database->getTraceLevels()),
@@ -76,8 +76,8 @@ BaseSessionI::BaseSessionI(const string& id,
{
if(_traceLevels && _traceLevels->session > 0)
{
- Ice::Trace out(_traceLevels->logger, _traceLevels->sessionCat);
- out << _prefix << " session `" << _id << "' created";
+ Ice::Trace out(_traceLevels->logger, _traceLevels->sessionCat);
+ out << _prefix << " session `" << _id << "' created";
}
}
@@ -91,17 +91,17 @@ BaseSessionI::keepAlive(const Ice::Current& current)
Lock sync(*this);
if(_destroyed)
{
- Ice::ObjectNotExistException ex(__FILE__, __LINE__);
- ex.id = current.id;
- throw ex;
+ Ice::ObjectNotExistException ex(__FILE__, __LINE__);
+ ex.id = current.id;
+ throw ex;
}
_timestamp = IceUtil::Time::now();
if(_traceLevels->session > 1)
{
- Ice::Trace out(_traceLevels->logger, _traceLevels->sessionCat);
- out << _prefix << " session `" << _id << "' keep alive";
+ Ice::Trace out(_traceLevels->logger, _traceLevels->sessionCat);
+ out << _prefix << " session `" << _id << "' keep alive";
}
}
@@ -111,34 +111,34 @@ BaseSessionI::destroyImpl(bool shutdown)
Lock sync(*this);
if(_destroyed)
{
- Ice::ObjectNotExistException ex(__FILE__, __LINE__);
- ex.id = _identity;
- throw ex;
+ Ice::ObjectNotExistException ex(__FILE__, __LINE__);
+ ex.id = _identity;
+ throw ex;
}
_destroyed = true;
if(!shutdown)
{
- if(_servantLocator)
- {
- _servantLocator->remove(_identity);
- }
- else if(_adapter)
- {
- try
- {
- _adapter->remove(_identity);
- }
- catch(const Ice::ObjectAdapterDeactivatedException&)
- {
- }
- }
+ if(_servantLocator)
+ {
+ _servantLocator->remove(_identity);
+ }
+ else if(_adapter)
+ {
+ try
+ {
+ _adapter->remove(_identity);
+ }
+ catch(const Ice::ObjectAdapterDeactivatedException&)
+ {
+ }
+ }
}
-
+
if(_traceLevels && _traceLevels->session > 0)
{
- Ice::Trace out(_traceLevels->logger, _traceLevels->sessionCat);
- out << _prefix << " session `" << _id << "' destroyed";
+ Ice::Trace out(_traceLevels->logger, _traceLevels->sessionCat);
+ out << _prefix << " session `" << _id << "' destroyed";
}
}
@@ -180,9 +180,9 @@ BaseSessionI::registerWithObjectAdapter(const Ice::ObjectAdapterPtr& adapter)
}
SessionI::SessionI(const string& id,
- const DatabasePtr& database,
- const WaitQueuePtr& waitQueue,
- const Glacier2::SessionControlPrx& sessionControl) :
+ const DatabasePtr& database,
+ const WaitQueuePtr& waitQueue,
+ const Glacier2::SessionControlPrx& sessionControl) :
BaseSessionI(id, "client", database),
_waitQueue(waitQueue),
_sessionControl(sessionControl),
@@ -196,16 +196,16 @@ SessionI::~SessionI()
void
SessionI::allocateObjectById_async(const AMD_Session_allocateObjectByIdPtr& cb,
- const Ice::Identity& id,
- const Ice::Current&)
+ const Ice::Identity& id,
+ const Ice::Current&)
{
_database->getAllocatableObject(id)->allocate(newAllocateObject(this, cb));
}
void
SessionI::allocateObjectByType_async(const AMD_Session_allocateObjectByTypePtr& cb,
- const string& type,
- const Ice::Current&)
+ const string& type,
+ const Ice::Current&)
{
_database->getAllocatableObjectCache().allocateByType(type, newAllocateObject(this, cb));
}
@@ -242,7 +242,7 @@ SessionI::addAllocationRequest(const AllocationRequestPtr& request)
Lock sync(*this);
if(_destroyed)
{
- return false;
+ return false;
}
_requests.insert(request);
return true;
@@ -254,7 +254,7 @@ SessionI::removeAllocationRequest(const AllocationRequestPtr& request)
Lock sync(*this);
if(_destroyed)
{
- return;
+ return;
}
_requests.erase(request);
}
@@ -265,7 +265,7 @@ SessionI::addAllocation(const AllocatablePtr& allocatable)
Lock sync(*this);
if(_destroyed)
{
- throw SessionDestroyedException();
+ throw SessionDestroyedException();
}
_allocations.insert(allocatable);
}
@@ -276,7 +276,7 @@ SessionI::removeAllocation(const AllocatablePtr& allocatable)
Lock sync(*this);
if(_destroyed)
{
- return;
+ return;
}
_allocations.erase(allocatable);
}
@@ -294,27 +294,27 @@ SessionI::destroyImpl(bool shutdown)
for(set<AllocationRequestPtr>::const_iterator p = _requests.begin(); p != _requests.end(); ++p)
{
- (*p)->cancel(AllocationException("session destroyed"));
+ (*p)->cancel(AllocationException("session destroyed"));
}
_requests.clear();
for(set<AllocatablePtr>::const_iterator q = _allocations.begin(); q != _allocations.end(); ++q)
{
- try
- {
- (*q)->release(this);
- }
- catch(const AllocationException&)
- {
- }
+ try
+ {
+ (*q)->release(this);
+ }
+ catch(const AllocationException&)
+ {
+ }
}
_allocations.clear();
}
ClientSessionFactory::ClientSessionFactory(const Ice::ObjectAdapterPtr& adapter,
- const DatabasePtr& database,
- const WaitQueuePtr& waitQueue,
- const ReapThreadPtr& reaper) :
+ const DatabasePtr& database,
+ const WaitQueuePtr& waitQueue,
+ const ReapThreadPtr& reaper) :
_adapter(adapter),
_database(database),
_waitQueue(waitQueue),
@@ -341,21 +341,21 @@ ClientSessionFactory::createGlacier2Session(const string& sessionId, const Glaci
int timeout = 0;
if(ctl)
{
- try
- {
- ctl->identities()->add(ids);
- }
- catch(const Ice::LocalException&)
- {
- session->destroy(Ice::Current());
- return 0;
- }
- timeout = ctl->getSessionTimeout();
+ try
+ {
+ ctl->identities()->add(ids);
+ }
+ catch(const Ice::LocalException&)
+ {
+ session->destroy(Ice::Current());
+ return 0;
+ }
+ timeout = ctl->getSessionTimeout();
}
if(timeout > 0)
{
- _reaper->add(new SessionReapable<SessionI>(_database->getTraceLevels()->logger, session), timeout);
+ _reaper->add(new SessionReapable<SessionI>(_database->getTraceLevels()->logger, session), timeout);
}
return Glacier2::SessionPrx::uncheckedCast(proxy);
@@ -389,26 +389,26 @@ ClientSSLSessionManagerI::ClientSSLSessionManagerI(const ClientSessionFactoryPtr
Glacier2::SessionPrx
ClientSSLSessionManagerI::create(const Glacier2::SSLInfo& info,
- const Glacier2::SessionControlPrx& ctl,
- const Ice::Current& current)
+ const Glacier2::SessionControlPrx& ctl,
+ const Ice::Current& current)
{
string userDN;
if(!info.certs.empty()) // TODO: Require userDN?
{
- try
- {
- IceSSL::CertificatePtr cert = IceSSL::Certificate::decode(info.certs[0]);
- userDN = cert->getSubjectDN();
- }
- catch(const Ice::Exception& ex)
- {
- // This shouldn't happen, the SSLInfo is supposed to be encoded by Glacier2.
- Ice::Error out(_factory->getTraceLevels()->logger);
- out << "SSL session manager couldn't decode SSL certificates:\n" << ex;
- return 0;
- }
+ try
+ {
+ IceSSL::CertificatePtr cert = IceSSL::Certificate::decode(info.certs[0]);
+ userDN = cert->getSubjectDN();
+ }
+ catch(const Ice::Exception& ex)
+ {
+ // This shouldn't happen, the SSLInfo is supposed to be encoded by Glacier2.
+ Ice::Error out(_factory->getTraceLevels()->logger);
+ out << "SSL session manager couldn't decode SSL certificates:\n" << ex;
+ return 0;
+ }
}
-
+
return _factory->createGlacier2Session(userDN, ctl);
}
diff --git a/cpp/src/IceGrid/SessionI.h b/cpp/src/IceGrid/SessionI.h
index 8d6d702ec91..9dbb5666b83 100644
--- a/cpp/src/IceGrid/SessionI.h
+++ b/cpp/src/IceGrid/SessionI.h
@@ -86,9 +86,9 @@ public:
virtual void keepAlive(const Ice::Current& current) { BaseSessionI::keepAlive(current); }
virtual void allocateObjectById_async(const AMD_Session_allocateObjectByIdPtr&, const Ice::Identity&,
- const Ice::Current&);
+ const Ice::Current&);
virtual void allocateObjectByType_async(const AMD_Session_allocateObjectByTypePtr&, const std::string&,
- const Ice::Current&);
+ const Ice::Current&);
virtual void releaseObject(const Ice::Identity&, const Ice::Current&);
virtual void setAllocationTimeout(int, const Ice::Current&);
virtual void destroy(const Ice::Current&);
@@ -154,7 +154,7 @@ public:
ClientSSLSessionManagerI(const ClientSessionFactoryPtr&);
virtual Glacier2::SessionPrx create(const Glacier2::SSLInfo&, const Glacier2::SessionControlPrx&,
- const Ice::Current&);
+ const Ice::Current&);
private:
diff --git a/cpp/src/IceGrid/SessionManager.h b/cpp/src/IceGrid/SessionManager.h
index c72924dbc53..7ce8ba23b0b 100644
--- a/cpp/src/IceGrid/SessionManager.h
+++ b/cpp/src/IceGrid/SessionManager.h
@@ -26,245 +26,245 @@ class SessionKeepAliveThread : public IceUtil::Thread, public IceUtil::Monitor<I
{
enum State
{
- Disconnected,
- Connected,
- InProgress,
- Destroyed
+ Disconnected,
+ Connected,
+ InProgress,
+ Destroyed
};
enum Action
{
- Connect,
- Disconnect,
- KeepAlive,
- None
+ Connect,
+ Disconnect,
+ KeepAlive,
+ None
};
public:
SessionKeepAliveThread(const InternalRegistryPrx& registry) :
- _registry(registry),
- _state(InProgress),
- _nextAction(None)
+ _registry(registry),
+ _state(InProgress),
+ _nextAction(None)
{
}
virtual void
run()
{
- TPrx session;
- InternalRegistryPrx registry;
- IceUtil::Time timeout = IceUtil::Time::seconds(15);
- Action action = Connect;
+ TPrx session;
+ InternalRegistryPrx registry;
+ IceUtil::Time timeout = IceUtil::Time::seconds(15);
+ Action action = Connect;
- while(true)
- {
- {
- Lock sync(*this);
- if(_state == Destroyed)
- {
- break;
- }
+ while(true)
+ {
+ {
+ Lock sync(*this);
+ if(_state == Destroyed)
+ {
+ break;
+ }
- //
- // Update the current state.
- //
- assert(_state == InProgress);
- _state = session ? Connected : Disconnected;
- _session = session;
- if(_session)
- {
- _registry = registry;
- }
+ //
+ // Update the current state.
+ //
+ assert(_state == InProgress);
+ _state = session ? Connected : Disconnected;
+ _session = session;
+ if(_session)
+ {
+ _registry = registry;
+ }
- if(_nextAction == Connect && _state == Connected)
- {
- _nextAction = KeepAlive;
- }
- else if(_nextAction == Disconnect && _state == Disconnected)
- {
- _nextAction = None;
- }
- else if(_nextAction == KeepAlive && _state == Disconnected)
- {
- _nextAction = Connect;
- }
- notifyAll();
+ if(_nextAction == Connect && _state == Connected)
+ {
+ _nextAction = KeepAlive;
+ }
+ else if(_nextAction == Disconnect && _state == Disconnected)
+ {
+ _nextAction = None;
+ }
+ else if(_nextAction == KeepAlive && _state == Disconnected)
+ {
+ _nextAction = Connect;
+ }
+ notifyAll();
- //
- // Wait if there's nothing to do and if we are
- // connected or if we've just tried to connect.
- //
- if(_nextAction == None)
- {
- if(_state == Connected || action == Connect || action == KeepAlive)
- {
- IceUtil::Time wakeTime = IceUtil::Time::now() + timeout;
- while(_state != Destroyed && _nextAction == None)
- {
- if(!timedWait(wakeTime - IceUtil::Time::now()))
- {
- break;
- }
- }
- }
- if(_nextAction == None)
- {
- _nextAction = session ? KeepAlive : Connect;
- }
- }
+ //
+ // Wait if there's nothing to do and if we are
+ // connected or if we've just tried to connect.
+ //
+ if(_nextAction == None)
+ {
+ if(_state == Connected || action == Connect || action == KeepAlive)
+ {
+ IceUtil::Time wakeTime = IceUtil::Time::now() + timeout;
+ while(_state != Destroyed && _nextAction == None)
+ {
+ if(!timedWait(wakeTime - IceUtil::Time::now()))
+ {
+ break;
+ }
+ }
+ }
+ if(_nextAction == None)
+ {
+ _nextAction = session ? KeepAlive : Connect;
+ }
+ }
- if(_state == Destroyed)
- {
- break;
- }
-
- assert(_nextAction != None);
-
- action = _nextAction;
- registry = InternalRegistryPrx::uncheckedCast(
- _registry->ice_timeout(static_cast<int>(timeout.toMilliSeconds())));
- _nextAction = None;
- _state = InProgress;
- notifyAll();
- }
+ if(_state == Destroyed)
+ {
+ break;
+ }
+
+ assert(_nextAction != None);
+
+ action = _nextAction;
+ registry = InternalRegistryPrx::uncheckedCast(
+ _registry->ice_timeout(static_cast<int>(timeout.toMilliSeconds())));
+ _nextAction = None;
+ _state = InProgress;
+ notifyAll();
+ }
- switch(action)
- {
- case Connect:
- assert(!session);
- session = createSession(registry, timeout);
- break;
- case Disconnect:
- assert(session);
- destroySession(session);
- session = 0;
- break;
- case KeepAlive:
- assert(session);
- if(!keepAlive(session))
- {
- session = createSession(registry, timeout);
- }
- break;
- case None:
- default:
- assert(false);
- }
- }
-
- //
- // Destroy the session.
- //
- if(_nextAction == Disconnect && session)
- {
- destroySession(session);
- }
+ switch(action)
+ {
+ case Connect:
+ assert(!session);
+ session = createSession(registry, timeout);
+ break;
+ case Disconnect:
+ assert(session);
+ destroySession(session);
+ session = 0;
+ break;
+ case KeepAlive:
+ assert(session);
+ if(!keepAlive(session))
+ {
+ session = createSession(registry, timeout);
+ }
+ break;
+ case None:
+ default:
+ assert(false);
+ }
+ }
+
+ //
+ // Destroy the session.
+ //
+ if(_nextAction == Disconnect && session)
+ {
+ destroySession(session);
+ }
}
virtual bool
waitForCreate()
{
- Lock sync(*this);
- while(_state != Destroyed && _state != Connected)
- {
- wait();
- }
- return _state != Destroyed;
+ Lock sync(*this);
+ while(_state != Destroyed && _state != Connected)
+ {
+ wait();
+ }
+ return _state != Destroyed;
}
virtual void
tryCreateSession(bool waitForTry = true)
{
- {
- Lock sync(*this);
- if(_state == Destroyed)
- {
- return;
- }
+ {
+ Lock sync(*this);
+ if(_state == Destroyed)
+ {
+ return;
+ }
- if(_state == Connected)
- {
- _nextAction = KeepAlive;
- }
- else
- {
- _nextAction = Connect;
- }
- notifyAll();
- }
+ if(_state == Connected)
+ {
+ _nextAction = KeepAlive;
+ }
+ else
+ {
+ _nextAction = Connect;
+ }
+ notifyAll();
+ }
- if(waitForTry)
- {
- Lock sync(*this);
- // Wait until the action is executed and the state changes.
- while(_nextAction == Connect || _nextAction == KeepAlive || _state == InProgress)
- {
- wait();
- }
- }
+ if(waitForTry)
+ {
+ Lock sync(*this);
+ // Wait until the action is executed and the state changes.
+ while(_nextAction == Connect || _nextAction == KeepAlive || _state == InProgress)
+ {
+ wait();
+ }
+ }
}
void
destroyActiveSession()
{
- Lock sync(*this);
- if(_state == Destroyed || _state == Disconnected)
- {
- return;
- }
- _nextAction = Disconnect;
- notifyAll();
+ Lock sync(*this);
+ if(_state == Destroyed || _state == Disconnected)
+ {
+ return;
+ }
+ _nextAction = Disconnect;
+ notifyAll();
}
bool
terminateIfDisconnected()
{
- Lock sync(*this);
- if(_state != Disconnected)
- {
- return false; // Nothing we can do for now.
- }
- assert(_state != Destroyed);
- _state = Destroyed;
- _nextAction = None;
- notifyAll();
- return true;
+ Lock sync(*this);
+ if(_state != Disconnected)
+ {
+ return false; // Nothing we can do for now.
+ }
+ assert(_state != Destroyed);
+ _state = Destroyed;
+ _nextAction = None;
+ notifyAll();
+ return true;
}
void
terminate(bool destroySession = true)
{
- Lock sync(*this);
- if(_state == Destroyed)
- {
- return;
- }
- assert(_state != Destroyed);
- _state = Destroyed;
- _nextAction = destroySession ? Disconnect : None;
- notifyAll();
+ Lock sync(*this);
+ if(_state == Destroyed)
+ {
+ return;
+ }
+ assert(_state != Destroyed);
+ _state = Destroyed;
+ _nextAction = destroySession ? Disconnect : None;
+ notifyAll();
}
TPrx
getSession()
{
- Lock sync(*this);
- return _session;
+ Lock sync(*this);
+ return _session;
}
void
setRegistry(const InternalRegistryPrx& registry)
{
- Lock sync(*this);
- _registry = registry;
+ Lock sync(*this);
+ _registry = registry;
}
InternalRegistryPrx
getRegistry() const
{
- Lock sync(*this);
- return _registry;
+ Lock sync(*this);
+ return _registry;
}
virtual TPrx createSession(InternalRegistryPrx&, IceUtil::Time&) = 0;
diff --git a/cpp/src/IceGrid/SessionServantLocatorI.cpp b/cpp/src/IceGrid/SessionServantLocatorI.cpp
index caebd2890a8..3e37cda4802 100644
--- a/cpp/src/IceGrid/SessionServantLocatorI.cpp
+++ b/cpp/src/IceGrid/SessionServantLocatorI.cpp
@@ -28,7 +28,7 @@ SessionServantLocatorI::locate(const Ice::Current& current, Ice::LocalObjectPtr&
map<Ice::Identity, SessionServant>::const_iterator p = _servants.find(current.id);
if(p == _servants.end() || p->second.connection != current.con)
{
- return 0;
+ return 0;
}
return p->second.servant;
}
@@ -54,7 +54,7 @@ SessionServantLocatorI::add(const Ice::ObjectPtr& servant, const Ice::Connection
id.category = _instanceName;
if(!_servants.insert(make_pair(id, SessionServant(servant, con))).second)
{
- throw Ice::AlreadyRegisteredException(__FILE__, __LINE__, "servant", id.name);
+ throw Ice::AlreadyRegisteredException(__FILE__, __LINE__, "servant", id.name);
}
return _adapter->createProxy(id);
}
diff --git a/cpp/src/IceGrid/SessionServantLocatorI.h b/cpp/src/IceGrid/SessionServantLocatorI.h
index 5dd51f1a2c6..3385a1233db 100644
--- a/cpp/src/IceGrid/SessionServantLocatorI.h
+++ b/cpp/src/IceGrid/SessionServantLocatorI.h
@@ -33,10 +33,10 @@ private:
struct SessionServant
{
- SessionServant(const Ice::ObjectPtr& s, const Ice::ConnectionPtr& con) : servant(s), connection(con) { }
+ SessionServant(const Ice::ObjectPtr& s, const Ice::ConnectionPtr& con) : servant(s), connection(con) { }
- const Ice::ObjectPtr servant;
- const Ice::ConnectionPtr connection;
+ const Ice::ObjectPtr servant;
+ const Ice::ConnectionPtr connection;
};
const Ice::ObjectAdapterPtr _adapter;
diff --git a/cpp/src/IceGrid/Topics.cpp b/cpp/src/IceGrid/Topics.cpp
index 546729cf464..51da20ee1ad 100644
--- a/cpp/src/IceGrid/Topics.cpp
+++ b/cpp/src/IceGrid/Topics.cpp
@@ -22,11 +22,11 @@ ObserverTopic::ObserverTopic(const IceStorm::TopicManagerPrx& topicManager, cons
IceStorm::TopicPrx t;
try
{
- t = topicManager->create(name);
+ t = topicManager->create(name);
}
catch(const IceStorm::TopicExists&)
{
- t = topicManager->retrieve(name);
+ t = topicManager->retrieve(name);
}
//
@@ -48,7 +48,7 @@ ObserverTopic::subscribe(const Ice::ObjectPrx& obsv, const string& name)
Lock sync(*this);
if(!_topic)
{
- return;
+ return;
}
assert(obsv);
@@ -60,15 +60,15 @@ ObserverTopic::subscribe(const Ice::ObjectPrx& obsv, const string& name)
}
catch(const IceStorm::AlreadySubscribed&)
{
- throw ObserverAlreadyRegisteredException(obsv->ice_getIdentity());
+ throw ObserverAlreadyRegisteredException(obsv->ice_getIdentity());
}
if(!name.empty())
{
- assert(_syncSubscribers.find(name) == _syncSubscribers.end());
- _syncSubscribers.insert(name);
- addExpectedUpdate(_serial, name);
- waitForSyncedSubscribersNoSync(_serial, name);
+ assert(_syncSubscribers.find(name) == _syncSubscribers.end());
+ _syncSubscribers.insert(name);
+ addExpectedUpdate(_serial, name);
+ waitForSyncedSubscribersNoSync(_serial, name);
}
}
@@ -78,36 +78,36 @@ ObserverTopic::unsubscribe(const Ice::ObjectPrx& observer, const string& name)
Lock sync(*this);
if(_topic)
{
- _topic->unsubscribe(observer);
+ _topic->unsubscribe(observer);
}
assert(observer);
if(!name.empty())
{
- assert(_syncSubscribers.find(name) != _syncSubscribers.end());
- _syncSubscribers.erase(name);
-
- map<int, set<string> >::iterator p = _waitForUpdates.begin();
- bool notifyMonitor = false;
- while(p != _waitForUpdates.end())
- {
- p->second.erase(name);
- if(p->second.empty())
- {
- _waitForUpdates.erase(p++);
- notifyMonitor = true;
- }
- else
- {
- ++p;
- }
- }
+ assert(_syncSubscribers.find(name) != _syncSubscribers.end());
+ _syncSubscribers.erase(name);
+
+ map<int, set<string> >::iterator p = _waitForUpdates.begin();
+ bool notifyMonitor = false;
+ while(p != _waitForUpdates.end())
+ {
+ p->second.erase(name);
+ if(p->second.empty())
+ {
+ _waitForUpdates.erase(p++);
+ notifyMonitor = true;
+ }
+ else
+ {
+ ++p;
+ }
+ }
- if(notifyMonitor)
- {
- notifyAll();
- }
+ if(notifyMonitor)
+ {
+ notifyAll();
+ }
}
}
@@ -126,24 +126,24 @@ ObserverTopic::receivedUpdate(const string& name, int serial, const string& fail
map<int, set<string> >::iterator p = _waitForUpdates.find(serial);
if(p != _waitForUpdates.end())
{
- p->second.erase(name);
-
- if(!failure.empty())
- {
- map<int, map<string, string> >::iterator q = _updateFailures.find(serial);
- if(q == _updateFailures.end())
- {
- q = _updateFailures.insert(make_pair(serial, map<string ,string>())).first;
- }
- q->second.insert(make_pair(name, failure));
- }
+ p->second.erase(name);
+
+ if(!failure.empty())
+ {
+ map<int, map<string, string> >::iterator q = _updateFailures.find(serial);
+ if(q == _updateFailures.end())
+ {
+ q = _updateFailures.insert(make_pair(serial, map<string ,string>())).first;
+ }
+ q->second.insert(make_pair(name, failure));
+ }
- if(p->second.empty())
- {
- _waitForUpdates.erase(p);
- }
+ if(p->second.empty())
+ {
+ _waitForUpdates.erase(p);
+ }
- notifyAll();
+ notifyAll();
}
}
@@ -159,18 +159,18 @@ ObserverTopic::addExpectedUpdate(int serial, const string& name)
{
if(_syncSubscribers.empty() && name.empty())
{
- return;
+ return;
}
// Must be called with the lock held.
if(name.empty())
{
- assert(_waitForUpdates[serial].empty());
- _waitForUpdates[serial] = _syncSubscribers;
+ assert(_waitForUpdates[serial].empty());
+ _waitForUpdates[serial] = _syncSubscribers;
}
else
{
- _waitForUpdates[serial].insert(name);
+ _waitForUpdates[serial].insert(name);
}
}
@@ -179,7 +179,7 @@ ObserverTopic::waitForSyncedSubscribersNoSync(int serial, const string& name)
{
if(serial < 0)
{
- return;
+ return;
}
//
@@ -187,33 +187,33 @@ ObserverTopic::waitForSyncedSubscribersNoSync(int serial, const string& name)
//
while(true)
{
- map<int, set<string> >::const_iterator p = _waitForUpdates.find(serial);
- if(p == _waitForUpdates.end())
- {
- map<int, map<string, string> >::iterator q = _updateFailures.find(serial);
- if(q != _updateFailures.end())
- {
- map<string, string> failures = q->second;
- _updateFailures.erase(q);
- ostringstream os;
- for(map<string, string>::const_iterator r = failures.begin(); r != failures.end(); ++r)
- {
- os << "replication failed on replica `" << r->first << "':\n" << r->second << "\n";
- }
-
- Ice::Error err(_logger);
- err << os.str();
- }
- return;
- }
- else
- {
- if(!name.empty() && p->second.find(name) == p->second.end())
- {
- return;
- }
- wait();
- }
+ map<int, set<string> >::const_iterator p = _waitForUpdates.find(serial);
+ if(p == _waitForUpdates.end())
+ {
+ map<int, map<string, string> >::iterator q = _updateFailures.find(serial);
+ if(q != _updateFailures.end())
+ {
+ map<string, string> failures = q->second;
+ _updateFailures.erase(q);
+ ostringstream os;
+ for(map<string, string>::const_iterator r = failures.begin(); r != failures.end(); ++r)
+ {
+ os << "replication failed on replica `" << r->first << "':\n" << r->second << "\n";
+ }
+
+ Ice::Error err(_logger);
+ err << os.str();
+ }
+ return;
+ }
+ else
+ {
+ if(!name.empty() && p->second.find(name) == p->second.end())
+ {
+ return;
+ }
+ wait();
+ }
}
}
@@ -247,18 +247,18 @@ RegistryObserverTopic::registryUp(const RegistryInfo& info)
Lock sync(*this);
if(!_topic)
{
- return;
+ return;
}
updateSerial(_serial + 1);
_registries.insert(make_pair(info.name, info));
try
{
- _publisher->registryUp(info);
+ _publisher->registryUp(info);
}
catch(const Ice::LocalException& ex)
{
- Ice::Warning out(_logger);
- out << "unexpected exception while publishing `registryUp' update:\n" << ex;
+ Ice::Warning out(_logger);
+ out << "unexpected exception while publishing `registryUp' update:\n" << ex;
}
}
@@ -268,24 +268,24 @@ RegistryObserverTopic::registryDown(const string& name)
Lock sync(*this);
if(!_topic)
{
- return;
+ return;
}
if(_registries.find(name) == _registries.end())
{
- return;
+ return;
}
updateSerial(_serial + 1);
_registries.erase(name);
try
{
- _publisher->registryDown(name);
+ _publisher->registryDown(name);
}
catch(const Ice::LocalException& ex)
{
- Ice::Warning out(_logger);
- out << "unexpected exception while publishing `registryDown' update:\n" << ex;
+ Ice::Warning out(_logger);
+ out << "unexpected exception while publishing `registryDown' update:\n" << ex;
}
}
@@ -297,19 +297,19 @@ RegistryObserverTopic::initObserver(const Ice::ObjectPrx& obsv)
registries.reserve(_registries.size());
for(map<string, RegistryInfo>::const_iterator p = _registries.begin(); p != _registries.end(); ++p)
{
- registries.push_back(p->second);
+ registries.push_back(p->second);
}
observer->registryInit(registries, getContext(_serial));
}
NodeObserverTopic::NodeObserverTopic(const IceStorm::TopicManagerPrx& topicManager,
- const Ice::ObjectAdapterPtr& adapter) :
+ const Ice::ObjectAdapterPtr& adapter) :
ObserverTopic(topicManager, "NodeObserver")
{
const_cast<NodeObserverPrx&>(_publisher) = NodeObserverPrx::uncheckedCast(_basePublisher);
try
{
- const_cast<NodeObserverPrx&>(_externalPublisher) = NodeObserverPrx::uncheckedCast(adapter->addWithUUID(this));
+ const_cast<NodeObserverPrx&>(_externalPublisher) = NodeObserverPrx::uncheckedCast(adapter->addWithUUID(this));
}
catch(const Ice::LocalException&)
{
@@ -328,18 +328,18 @@ NodeObserverTopic::nodeUp(const NodeDynamicInfo& info, const Ice::Current& curre
Lock sync(*this);
if(!_topic)
{
- return;
+ return;
}
updateSerial(_serial + 1);
_nodes.insert(make_pair(info.info.name, info));
try
{
- _publisher->nodeUp(info);
+ _publisher->nodeUp(info);
}
catch(const Ice::LocalException& ex)
{
- Ice::Warning out(_logger);
- out << "unexpected exception while publishing 'nodeUp' update:\n" << ex;
+ Ice::Warning out(_logger);
+ out << "unexpected exception while publishing 'nodeUp' update:\n" << ex;
}
}
@@ -355,15 +355,15 @@ NodeObserverTopic::updateServer(const string& node, const ServerDynamicInfo& ser
Lock sync(*this);
if(!_topic)
{
- return;
+ return;
}
if(_nodes.find(node) == _nodes.end())
{
- //
- // If the node isn't known anymore, we ignore the update.
- //
- return;
+ //
+ // If the node isn't known anymore, we ignore the update.
+ //
+ return;
}
updateSerial(_serial + 1);
@@ -372,33 +372,33 @@ NodeObserverTopic::updateServer(const string& node, const ServerDynamicInfo& ser
ServerDynamicInfoSeq::iterator p = servers.begin();
while(p != servers.end())
{
- if(p->id == server.id)
- {
- if(server.state == Destroyed || (server.state == Inactive && server.enabled))
- {
- servers.erase(p);
- }
- else
- {
- *p = server;
- }
- break;
- }
- ++p;
+ if(p->id == server.id)
+ {
+ if(server.state == Destroyed || (server.state == Inactive && server.enabled))
+ {
+ servers.erase(p);
+ }
+ else
+ {
+ *p = server;
+ }
+ break;
+ }
+ ++p;
}
if(server.state != Destroyed && (server.state != Inactive || !server.enabled) && p == servers.end())
{
- servers.push_back(server);
+ servers.push_back(server);
}
try
{
- _publisher->updateServer(node, server);
+ _publisher->updateServer(node, server);
}
catch(const Ice::LocalException& ex)
{
- Ice::Warning out(_logger);
- out << "unexpected exception while publishing `updateServer' update:\n" << ex;
+ Ice::Warning out(_logger);
+ out << "unexpected exception while publishing `updateServer' update:\n" << ex;
}
}
@@ -408,15 +408,15 @@ NodeObserverTopic::updateAdapter(const string& node, const AdapterDynamicInfo& a
Lock sync(*this);
if(!_topic)
{
- return;
+ return;
}
if(_nodes.find(node) == _nodes.end())
{
- //
- // If the node isn't known anymore, we ignore the update.
- //
- return;
+ //
+ // If the node isn't known anymore, we ignore the update.
+ //
+ return;
}
updateSerial(_serial + 1);
@@ -425,33 +425,33 @@ NodeObserverTopic::updateAdapter(const string& node, const AdapterDynamicInfo& a
AdapterDynamicInfoSeq::iterator p = adapters.begin();
while(p != adapters.end())
{
- if(p->id == adapter.id)
- {
- if(adapter.proxy)
- {
- *p = adapter;
- }
- else
- {
- adapters.erase(p);
- }
- break;
- }
- ++p;
+ if(p->id == adapter.id)
+ {
+ if(adapter.proxy)
+ {
+ *p = adapter;
+ }
+ else
+ {
+ adapters.erase(p);
+ }
+ break;
+ }
+ ++p;
}
if(adapter.proxy && p == adapters.end())
{
- adapters.push_back(adapter);
+ adapters.push_back(adapter);
}
try
{
- _publisher->updateAdapter(node, adapter);
+ _publisher->updateAdapter(node, adapter);
}
catch(const Ice::LocalException& ex)
{
- Ice::Warning out(_logger);
- out << "unexpected exception while publishing `updateAdapter' update:\n" << ex;
+ Ice::Warning out(_logger);
+ out << "unexpected exception while publishing `updateAdapter' update:\n" << ex;
}
}
@@ -461,23 +461,23 @@ NodeObserverTopic::nodeDown(const string& name)
Lock sync(*this);
if(!_topic)
{
- return;
+ return;
}
updateSerial(_serial + 1);
if(_nodes.find(name) != _nodes.end())
{
- _nodes.erase(name);
- try
- {
- _publisher->nodeDown(name);
- }
- catch(const Ice::LocalException& ex)
- {
- Ice::Warning out(_logger);
- out << "unexpected exception while publishing `nodeDown' update:\n" << ex;
- }
+ _nodes.erase(name);
+ try
+ {
+ _publisher->nodeDown(name);
+ }
+ catch(const Ice::LocalException& ex)
+ {
+ Ice::Warning out(_logger);
+ out << "unexpected exception while publishing `nodeDown' update:\n" << ex;
+ }
}
}
@@ -489,13 +489,13 @@ NodeObserverTopic::initObserver(const Ice::ObjectPrx& obsv)
nodes.reserve(_nodes.size());
for(map<string, NodeDynamicInfo>::const_iterator p = _nodes.begin(); p != _nodes.end(); ++p)
{
- nodes.push_back(p->second);
+ nodes.push_back(p->second);
}
observer->nodeInit(nodes, getContext(_serial));
}
ApplicationObserverTopic::ApplicationObserverTopic(const IceStorm::TopicManagerPrx& topicManager,
- const StringApplicationInfoDict& applications) :
+ const StringApplicationInfoDict& applications) :
ObserverTopic(topicManager, "ApplicationObserver")
#ifndef _RWSTD_NO_MEMBER_TEMPLATES
,_applications(applications.begin(), applications.end())
@@ -504,7 +504,7 @@ ApplicationObserverTopic::ApplicationObserverTopic(const IceStorm::TopicManagerP
#ifdef _RWSTD_NO_MEMBER_TEMPLATES
for(StringApplicationInfoDict::const_iterator p = applications.begin(); p != applications.end(); ++p)
{
- _applications[p->first] = p->second;
+ _applications[p->first] = p->second;
}
#endif
@@ -517,22 +517,22 @@ ApplicationObserverTopic::applicationInit(int serial, const ApplicationInfoSeq&
Lock sync(*this);
if(!_topic)
{
- return -1;
+ return -1;
}
updateSerial(serial);
_applications.clear();
for(ApplicationInfoSeq::const_iterator p = apps.begin(); p != apps.end(); ++p)
{
- _applications.insert(make_pair(p->descriptor.name, *p));
+ _applications.insert(make_pair(p->descriptor.name, *p));
}
try
{
- _publisher->applicationInit(serial, apps, getContext(serial));
+ _publisher->applicationInit(serial, apps, getContext(serial));
}
catch(const Ice::LocalException& ex)
{
- Ice::Warning out(_logger);
- out << "unexpected exception while publishing `applicationInit' update:\n" << ex;
+ Ice::Warning out(_logger);
+ out << "unexpected exception while publishing `applicationInit' update:\n" << ex;
}
addExpectedUpdate(serial);
return serial;
@@ -544,19 +544,19 @@ ApplicationObserverTopic::applicationAdded(int serial, const ApplicationInfo& in
Lock sync(*this);
if(!_topic)
{
- return -1;
+ return -1;
}
updateSerial(serial);
_applications.insert(make_pair(info.descriptor.name, info));
try
{
- _publisher->applicationAdded(serial, info, getContext(serial));
+ _publisher->applicationAdded(serial, info, getContext(serial));
}
catch(const Ice::LocalException& ex)
{
- Ice::Warning out(_logger);
- out << "unexpected exception while publishing `applicationAdded' update:\n" << ex;
+ Ice::Warning out(_logger);
+ out << "unexpected exception while publishing `applicationAdded' update:\n" << ex;
}
addExpectedUpdate(serial);
return serial;
@@ -568,18 +568,18 @@ ApplicationObserverTopic::applicationRemoved(int serial, const string& name)
Lock sync(*this);
if(!_topic)
{
- return -1;
+ return -1;
}
updateSerial(serial);
_applications.erase(name);
try
{
- _publisher->applicationRemoved(serial, name, getContext(serial));
+ _publisher->applicationRemoved(serial, name, getContext(serial));
}
catch(const Ice::LocalException& ex)
{
- Ice::Warning out(_logger);
- out << "unexpected exception while publishing `applicationRemoved' update:\n" << ex;
+ Ice::Warning out(_logger);
+ out << "unexpected exception while publishing `applicationRemoved' update:\n" << ex;
}
addExpectedUpdate(serial);
return serial;
@@ -591,49 +591,49 @@ ApplicationObserverTopic::applicationUpdated(int serial, const ApplicationUpdate
Lock sync(*this);
if(!_topic)
{
- return -1;
+ return -1;
}
updateSerial(serial);
try
{
- map<string, ApplicationInfo>::iterator p = _applications.find(info.descriptor.name);
- if(p != _applications.end())
- {
- ApplicationHelper helper(_publisher->ice_getCommunicator(), p->second.descriptor);
- p->second.descriptor = helper.update(info.descriptor);
- p->second.updateTime = info.updateTime;
- p->second.updateUser = info.updateUser;
- p->second.revision = info.revision;
- }
+ map<string, ApplicationInfo>::iterator p = _applications.find(info.descriptor.name);
+ if(p != _applications.end())
+ {
+ ApplicationHelper helper(_publisher->ice_getCommunicator(), p->second.descriptor);
+ p->second.descriptor = helper.update(info.descriptor);
+ p->second.updateTime = info.updateTime;
+ p->second.updateUser = info.updateUser;
+ p->second.revision = info.revision;
+ }
}
catch(const DeploymentException& ex)
{
- cerr << ex.reason << endl;
- assert(false);
+ cerr << ex.reason << endl;
+ assert(false);
}
catch(const std::string& msg)
{
- cerr << msg << endl;
- assert(false);
+ cerr << msg << endl;
+ assert(false);
}
catch(const char* msg)
{
- cerr << msg << endl;
- assert(false);
+ cerr << msg << endl;
+ assert(false);
}
catch(...)
{
- assert(false);
+ assert(false);
}
try
{
- _publisher->applicationUpdated(serial, info, getContext(serial));
+ _publisher->applicationUpdated(serial, info, getContext(serial));
}
catch(const Ice::LocalException& ex)
{
- Ice::Warning out(_logger);
- out << "unexpected exception while publishing `applicationUpdated' update:\n" << ex;
+ Ice::Warning out(_logger);
+ out << "unexpected exception while publishing `applicationUpdated' update:\n" << ex;
}
addExpectedUpdate(serial);
return serial;
@@ -646,13 +646,13 @@ ApplicationObserverTopic::initObserver(const Ice::ObjectPrx& obsv)
ApplicationInfoSeq applications;
for(map<string, ApplicationInfo>::const_iterator p = _applications.begin(); p != _applications.end(); ++p)
{
- applications.push_back(p->second);
+ applications.push_back(p->second);
}
observer->applicationInit(_serial, applications, getContext(_serial));
}
AdapterObserverTopic::AdapterObserverTopic(const IceStorm::TopicManagerPrx& topicManager,
- const StringAdapterInfoDict& adapters) :
+ const StringAdapterInfoDict& adapters) :
ObserverTopic(topicManager, "AdapterObserver")
#ifndef _RWSTD_NO_MEMBER_TEMPLATES
, _adapters(adapters.begin(), adapters.end())
@@ -674,22 +674,22 @@ AdapterObserverTopic::adapterInit(const AdapterInfoSeq& adpts)
Lock sync(*this);
if(!_topic)
{
- return -1;
+ return -1;
}
updateSerial(_serial + 1);
_adapters.clear();
for(AdapterInfoSeq::const_iterator q = adpts.begin(); q != adpts.end(); ++q)
{
- _adapters.insert(make_pair(q->id, *q));
+ _adapters.insert(make_pair(q->id, *q));
}
try
{
- _publisher->adapterInit(adpts, getContext(_serial));
+ _publisher->adapterInit(adpts, getContext(_serial));
}
catch(const Ice::LocalException& ex)
{
- Ice::Warning out(_logger);
- out << "unexpected exception while publishing `adapterInit' update:\n" << ex;
+ Ice::Warning out(_logger);
+ out << "unexpected exception while publishing `adapterInit' update:\n" << ex;
}
addExpectedUpdate(_serial);
return _serial;
@@ -701,18 +701,18 @@ AdapterObserverTopic::adapterAdded(const AdapterInfo& info)
Lock sync(*this);
if(!_topic)
{
- return -1;
+ return -1;
}
updateSerial(_serial + 1);
_adapters.insert(make_pair(info.id, info));
try
{
- _publisher->adapterAdded(info, getContext(_serial));
+ _publisher->adapterAdded(info, getContext(_serial));
}
catch(const Ice::LocalException& ex)
{
- Ice::Warning out(_logger);
- out << "unexpected exception while publishing `adapterAdded' update:\n" << ex;
+ Ice::Warning out(_logger);
+ out << "unexpected exception while publishing `adapterAdded' update:\n" << ex;
}
addExpectedUpdate(_serial);
return _serial;
@@ -724,18 +724,18 @@ AdapterObserverTopic::adapterUpdated(const AdapterInfo& info)
Lock sync(*this);
if(!_topic)
{
- return -1;
+ return -1;
}
updateSerial(_serial + 1);
_adapters[info.id] = info;
try
{
- _publisher->adapterUpdated(info, getContext(_serial));
+ _publisher->adapterUpdated(info, getContext(_serial));
}
catch(const Ice::LocalException& ex)
{
- Ice::Warning out(_logger);
- out << "unexpected exception while publishing `adapterUpdated' update:\n" << ex;
+ Ice::Warning out(_logger);
+ out << "unexpected exception while publishing `adapterUpdated' update:\n" << ex;
}
addExpectedUpdate(_serial);
return _serial;
@@ -747,18 +747,18 @@ AdapterObserverTopic::adapterRemoved(const string& id)
Lock sync(*this);
if(!_topic)
{
- return -1;
+ return -1;
}
updateSerial(_serial + 1);
_adapters.erase(id);
try
{
- _publisher->adapterRemoved(id, getContext(_serial));
+ _publisher->adapterRemoved(id, getContext(_serial));
}
catch(const Ice::LocalException& ex)
{
- Ice::Warning out(_logger);
- out << "unexpected exception while publishing `adapterRemoved' update:\n" << ex;
+ Ice::Warning out(_logger);
+ out << "unexpected exception while publishing `adapterRemoved' update:\n" << ex;
}
addExpectedUpdate(_serial);
return _serial;
@@ -771,13 +771,13 @@ AdapterObserverTopic::initObserver(const Ice::ObjectPrx& obsv)
AdapterInfoSeq adapters;
for(map<string, AdapterInfo>::const_iterator p = _adapters.begin(); p != _adapters.end(); ++p)
{
- adapters.push_back(p->second);
- }
+ adapters.push_back(p->second);
+ }
observer->adapterInit(adapters, getContext(_serial));
}
ObjectObserverTopic::ObjectObserverTopic(const IceStorm::TopicManagerPrx& topicManager,
- const IdentityObjectInfoDict& objects) :
+ const IdentityObjectInfoDict& objects) :
ObserverTopic(topicManager, "ObjectObserver")
#ifndef _RWSTD_NO_MEMBER_TEMPLATES
, _objects(objects.begin(), objects.end())
@@ -799,22 +799,22 @@ ObjectObserverTopic::objectInit(const ObjectInfoSeq& objects)
Lock sync(*this);
if(!_topic)
{
- return -1;
+ return -1;
}
updateSerial(_serial + 1);
_objects.clear();
for(ObjectInfoSeq::const_iterator r = objects.begin(); r != objects.end(); ++r)
{
- _objects.insert(make_pair(r->proxy->ice_getIdentity(), *r));
+ _objects.insert(make_pair(r->proxy->ice_getIdentity(), *r));
}
try
{
- _publisher->objectInit(objects, getContext(_serial));
+ _publisher->objectInit(objects, getContext(_serial));
}
catch(const Ice::LocalException& ex)
{
- Ice::Warning out(_logger);
- out << "unexpected exception while publishing `objectInit' update:\n" << ex;
+ Ice::Warning out(_logger);
+ out << "unexpected exception while publishing `objectInit' update:\n" << ex;
}
addExpectedUpdate(_serial);
return _serial;
@@ -826,18 +826,18 @@ ObjectObserverTopic::objectAdded(const ObjectInfo& info)
Lock sync(*this);
if(!_topic)
{
- return -1;
+ return -1;
}
updateSerial(_serial + 1);
_objects.insert(make_pair(info.proxy->ice_getIdentity(), info));
try
{
- _publisher->objectAdded(info, getContext(_serial));
+ _publisher->objectAdded(info, getContext(_serial));
}
catch(const Ice::LocalException& ex)
{
- Ice::Warning out(_logger);
- out << "unexpected exception while publishing `objectAdded' update:\n" << ex;
+ Ice::Warning out(_logger);
+ out << "unexpected exception while publishing `objectAdded' update:\n" << ex;
}
addExpectedUpdate(_serial);
return _serial;
@@ -849,18 +849,18 @@ ObjectObserverTopic::objectUpdated(const ObjectInfo& info)
Lock sync(*this);
if(!_topic)
{
- return -1;
+ return -1;
}
updateSerial(_serial + 1);
_objects[info.proxy->ice_getIdentity()] = info;
try
{
- _publisher->objectUpdated(info, getContext(_serial));
+ _publisher->objectUpdated(info, getContext(_serial));
}
catch(const Ice::LocalException& ex)
{
- Ice::Warning out(_logger);
- out << "unexpected exception while publishing `objectUpdated' update:\n" << ex;
+ Ice::Warning out(_logger);
+ out << "unexpected exception while publishing `objectUpdated' update:\n" << ex;
}
addExpectedUpdate(_serial);
return _serial;
@@ -872,18 +872,18 @@ ObjectObserverTopic::objectRemoved(const Ice::Identity& id)
Lock sync(*this);
if(!_topic)
{
- return -1;
+ return -1;
}
updateSerial(_serial + 1);
_objects.erase(id);
try
{
- _publisher->objectRemoved(id, getContext(_serial));
+ _publisher->objectRemoved(id, getContext(_serial));
}
catch(const Ice::LocalException& ex)
{
- Ice::Warning out(_logger);
- out << "unexpected exception while publishing `objectRemoved' update:\n" << ex;
+ Ice::Warning out(_logger);
+ out << "unexpected exception while publishing `objectRemoved' update:\n" << ex;
}
addExpectedUpdate(_serial);
return _serial;
@@ -895,39 +895,39 @@ ObjectObserverTopic::objectsAddedOrUpdated(const ObjectInfoSeq& infos)
Lock sync(*this);
if(!_topic)
{
- return -1;
+ return -1;
}
updateSerial(_serial + 1);
for(ObjectInfoSeq::const_iterator p = infos.begin(); p != infos.end(); ++p)
{
- map<Ice::Identity, ObjectInfo>::iterator q = _objects.find(p->proxy->ice_getIdentity());
- if(q != _objects.end())
- {
- q->second = *p;
- try
- {
- _publisher->objectUpdated(*p, getContext(_serial));
- }
- catch(const Ice::LocalException& ex)
- {
- Ice::Warning out(_logger);
- out << "unexpected exception while publishing `objectUpdated' update:\n" << ex;
- }
- }
- else
- {
- _objects.insert(make_pair(p->proxy->ice_getIdentity(), *p));
- try
- {
- _publisher->objectAdded(*p, getContext(_serial));
- }
- catch(const Ice::LocalException& ex)
- {
- Ice::Warning out(_logger);
- out << "unexpected exception while publishing `objectAdded' update:\n" << ex;
- }
- }
+ map<Ice::Identity, ObjectInfo>::iterator q = _objects.find(p->proxy->ice_getIdentity());
+ if(q != _objects.end())
+ {
+ q->second = *p;
+ try
+ {
+ _publisher->objectUpdated(*p, getContext(_serial));
+ }
+ catch(const Ice::LocalException& ex)
+ {
+ Ice::Warning out(_logger);
+ out << "unexpected exception while publishing `objectUpdated' update:\n" << ex;
+ }
+ }
+ else
+ {
+ _objects.insert(make_pair(p->proxy->ice_getIdentity(), *p));
+ try
+ {
+ _publisher->objectAdded(*p, getContext(_serial));
+ }
+ catch(const Ice::LocalException& ex)
+ {
+ Ice::Warning out(_logger);
+ out << "unexpected exception while publishing `objectAdded' update:\n" << ex;
+ }
+ }
}
//
@@ -945,22 +945,22 @@ ObjectObserverTopic::objectsRemoved(const ObjectInfoSeq& infos)
Lock sync(*this);
if(!_topic)
{
- return -1;
+ return -1;
}
updateSerial(_serial + 1);
for(ObjectInfoSeq::const_iterator p = infos.begin(); p != infos.end(); ++p)
{
- _objects.erase(p->proxy->ice_getIdentity());
- try
- {
- _publisher->objectRemoved(p->proxy->ice_getIdentity(), getContext(_serial));
- }
- catch(const Ice::LocalException& ex)
- {
- Ice::Warning out(_logger);
- out << "unexpected exception while publishing `objectUpdated' update:\n" << ex;
- }
+ _objects.erase(p->proxy->ice_getIdentity());
+ try
+ {
+ _publisher->objectRemoved(p->proxy->ice_getIdentity(), getContext(_serial));
+ }
+ catch(const Ice::LocalException& ex)
+ {
+ Ice::Warning out(_logger);
+ out << "unexpected exception while publishing `objectUpdated' update:\n" << ex;
+ }
}
//
@@ -980,7 +980,7 @@ ObjectObserverTopic::initObserver(const Ice::ObjectPrx& obsv)
ObjectInfoSeq objects;
for(map<Ice::Identity, ObjectInfo>::const_iterator p = _objects.begin(); p != _objects.end(); ++p)
{
- objects.push_back(p->second);
+ objects.push_back(p->second);
}
observer->objectInit(objects, getContext(_serial));
}
diff --git a/cpp/src/IceGrid/Util.cpp b/cpp/src/IceGrid/Util.cpp
index 2a36351e916..f955fe69e4c 100644
--- a/cpp/src/IceGrid/Util.cpp
+++ b/cpp/src/IceGrid/Util.cpp
@@ -24,12 +24,12 @@ IceGrid::toString(const vector<string>& v, const string& sep)
Ice::StringSeq::const_iterator p = v.begin();
while(p != v.end())
{
- os << *p;
- ++p;
- if(p != v.end())
- {
- os << sep;
- }
+ os << *p;
+ ++p;
+ if(p != v.end())
+ {
+ os << sep;
+ }
}
return os.str();
}
@@ -40,22 +40,22 @@ IceGrid::toString(const Ice::Exception& exception)
std::ostringstream os;
try
{
- exception.ice_throw();
+ exception.ice_throw();
}
catch(const NodeUnreachableException& ex)
{
- os << ex << ":";
- os << "\nnode: " << ex.name;
- os << "\nreason: " << ex.reason;
+ os << ex << ":";
+ os << "\nnode: " << ex.name;
+ os << "\nreason: " << ex.reason;
}
catch(const DeploymentException& ex)
{
- os << ex << ":";
- os << "\nreason: " << ex.reason;
+ os << ex << ":";
+ os << "\nreason: " << ex.reason;
}
catch(const Ice::Exception& ex)
{
- os << ex;
+ os << ex;
}
return os.str();
}
@@ -65,10 +65,10 @@ IceGrid::getProperty(const PropertyDescriptorSeq& properties, const string& name
{
for(PropertyDescriptorSeq::const_iterator q = properties.begin(); q != properties.end(); ++q)
{
- if(q->name == name)
- {
- return q->value;
- }
+ if(q->name == name)
+ {
+ return q->value;
+ }
}
return def;
}
@@ -97,23 +97,23 @@ IceGrid::getMMVersion(const string& o)
if(minorPos != 1 && minorPos != 2)
{
- return -1;
+ return -1;
}
if(patchPos != string::npos)
{
- if((minorPos == 1 && patchPos != 3 && patchPos != 4) || (minorPos == 2 && patchPos != 4 && patchPos != 5))
- {
- return -1;
- }
- else if((version.size() - patchPos - 1) > 2)
- {
- return -1;
- }
+ if((minorPos == 1 && patchPos != 3 && patchPos != 4) || (minorPos == 2 && patchPos != 4 && patchPos != 5))
+ {
+ return -1;
+ }
+ else if((version.size() - patchPos - 1) > 2)
+ {
+ return -1;
+ }
}
else if((version.size() - minorPos - 1) > 2)
{
- return -1;
+ return -1;
}
int v, ver;
@@ -122,7 +122,7 @@ IceGrid::getMMVersion(const string& o)
major >> v;
if(major.fail() || v > 99 || v < 1)
{
- return -1;
+ return -1;
}
ver = v;
ver *= 100;
@@ -131,7 +131,7 @@ IceGrid::getMMVersion(const string& o)
minor >> v;
if(minor.fail() || v > 99 || v < 0)
{
- return -1;
+ return -1;
}
ver += v;
ver *= 100;
@@ -142,13 +142,13 @@ IceGrid::getMMVersion(const string& o)
//
// if(patchPos != string::npos)
// {
-// istringstream patch(version.substr(patchPos + 1));
-// patch >> v;
-// if(patch.fail() || v > 99 || v < 0)
-// {
-// return -1;
-// }
-// ver += v;
+// istringstream patch(version.substr(patchPos + 1));
+// patch >> v;
+// if(patch.fail() || v > 99 || v < 0)
+// {
+// return -1;
+// }
+// ver += v;
// }
return ver;
diff --git a/cpp/src/IceGrid/Util.h b/cpp/src/IceGrid/Util.h
index b3a2d7839dd..918ac4011a9 100644
--- a/cpp/src/IceGrid/Util.h
+++ b/cpp/src/IceGrid/Util.h
@@ -56,19 +56,19 @@ struct ForEachCommunicator : std::unary_function<CommunicatorDescriptorPtr&, voi
void
operator()(const ServiceInstanceDescriptor& descriptor)
{
- assert(descriptor.descriptor);
- operator()(descriptor.descriptor);
+ assert(descriptor.descriptor);
+ operator()(descriptor.descriptor);
}
void
operator()(const CommunicatorDescriptorPtr& descriptor)
{
- _function(descriptor);
- IceBoxDescriptorPtr iceBox = IceBoxDescriptorPtr::dynamicCast(descriptor);
- if(iceBox)
- {
- for_each(iceBox->services.begin(), iceBox->services.end(), forEachCommunicator(_function));
- }
+ _function(descriptor);
+ IceBoxDescriptorPtr iceBox = IceBoxDescriptorPtr::dynamicCast(descriptor);
+ if(iceBox)
+ {
+ for_each(iceBox->services.begin(), iceBox->services.end(), forEachCommunicator(_function));
+ }
}
Function _function;
@@ -92,7 +92,7 @@ public:
explicit ObjFunc(T& obj, void (T::*f)(A)) : _obj(obj), _mfn(f) { }
void operator()(A arg) const
{
- (_obj.*_mfn)(arg);
+ (_obj.*_mfn)(arg);
}
};
@@ -108,10 +108,10 @@ inline getMatchingKeys(const T& m, const std::string& expression)
std::vector<std::string> keys;
for(typename T::const_iterator p = m.begin(); p != m.end(); ++p)
{
- if(expression.empty() || IceUtil::match(p->first, expression, true))
- {
- keys.push_back(p->first);
- }
+ if(expression.empty() || IceUtil::match(p->first, expression, true))
+ {
+ keys.push_back(p->first);
+ }
}
return keys;
}
diff --git a/cpp/src/IceGrid/WaitQueue.cpp b/cpp/src/IceGrid/WaitQueue.cpp
index 24b7d9ccfba..06e18766558 100644
--- a/cpp/src/IceGrid/WaitQueue.cpp
+++ b/cpp/src/IceGrid/WaitQueue.cpp
@@ -42,74 +42,74 @@ WaitQueue::run()
{
while(true)
{
- list<WaitItemPtr> expired;
- {
- Lock sync(*this);
- if(_waitQueue.empty() && !_destroyed)
- {
- wait();
- }
-
- if(_destroyed)
- {
- break;
- }
-
- //
- // Notify expired items.
- //
- while(!_waitQueue.empty() && !_destroyed)
- {
- WaitItemPtr item = _waitQueue.front();
- if(item->getExpirationTime() <= IceUtil::Time::now())
- {
- expired.push_back(item);
- _waitQueue.pop_front();
- }
- else if(!expired.empty())
- {
- break;
- }
- else
- {
- //
- // Wait until the next item expire or a notification. Note: in any case we
- // get out of this loop to get a chance to execute the work queue.
- //
- timedWait(item->getExpirationTime() - IceUtil::Time::now());
- }
- }
- }
-
- if(!expired.empty())
- {
- for(list<WaitItemPtr>::iterator p = expired.begin(); p != expired.end(); ++p)
- {
- try
- {
- (*p)->expired(false);
- }
- catch(const Ice::LocalException&)
- {
- //
- // TODO: Add some tracing.
- //
- }
- }
- }
-
- if(_destroyed)
- {
- break;
- }
+ list<WaitItemPtr> expired;
+ {
+ Lock sync(*this);
+ if(_waitQueue.empty() && !_destroyed)
+ {
+ wait();
+ }
+
+ if(_destroyed)
+ {
+ break;
+ }
+
+ //
+ // Notify expired items.
+ //
+ while(!_waitQueue.empty() && !_destroyed)
+ {
+ WaitItemPtr item = _waitQueue.front();
+ if(item->getExpirationTime() <= IceUtil::Time::now())
+ {
+ expired.push_back(item);
+ _waitQueue.pop_front();
+ }
+ else if(!expired.empty())
+ {
+ break;
+ }
+ else
+ {
+ //
+ // Wait until the next item expire or a notification. Note: in any case we
+ // get out of this loop to get a chance to execute the work queue.
+ //
+ timedWait(item->getExpirationTime() - IceUtil::Time::now());
+ }
+ }
+ }
+
+ if(!expired.empty())
+ {
+ for(list<WaitItemPtr>::iterator p = expired.begin(); p != expired.end(); ++p)
+ {
+ try
+ {
+ (*p)->expired(false);
+ }
+ catch(const Ice::LocalException&)
+ {
+ //
+ // TODO: Add some tracing.
+ //
+ }
+ }
+ }
+
+ if(_destroyed)
+ {
+ break;
+ }
}
if(!_waitQueue.empty())
{
- for(list<WaitItemPtr>::iterator p = _waitQueue.begin(); p != _waitQueue.end(); ++p)
- {
- (*p)->expired(true);
- }
+ for(list<WaitItemPtr>::iterator p = _waitQueue.begin(); p != _waitQueue.end(); ++p)
+ {
+ (*p)->expired(true);
+ }
}
_waitQueue.clear(); // Break cyclic reference counts.
}
@@ -118,9 +118,9 @@ void
WaitQueue::destroy()
{
{
- Lock sync(*this);
- _destroyed = true;
- notify();
+ Lock sync(*this);
+ _destroyed = true;
+ notify();
}
getThreadControl().join();
@@ -132,7 +132,7 @@ WaitQueue::add(const WaitItemPtr& item, const IceUtil::Time& wait)
Lock sync(*this);
if(_destroyed)
{
- return;
+ return;
}
//
@@ -146,17 +146,17 @@ WaitQueue::add(const WaitItemPtr& item, const IceUtil::Time& wait)
list<WaitItemPtr>::iterator p = _waitQueue.begin();
while(p != _waitQueue.end())
{
- if((*p)->getExpirationTime() >= expire)
- {
- break;
- }
- ++p;
+ if((*p)->getExpirationTime() >= expire)
+ {
+ break;
+ }
+ ++p;
}
_waitQueue.insert(p, item);
if(notifyThread)
{
- notify();
+ notify();
}
}
@@ -167,12 +167,12 @@ WaitQueue::remove(const WaitItemPtr& item)
list<WaitItemPtr>::iterator p = _waitQueue.begin();
while(p != _waitQueue.end())
{
- if((*p).get() == item.get())
- {
- _waitQueue.erase(p);
- return true;
- }
- ++p;
+ if((*p).get() == item.get())
+ {
+ _waitQueue.erase(p);
+ return true;
+ }
+ ++p;
}
return false;
}
diff --git a/cpp/src/IceGrid/WellKnownObjectsManager.cpp b/cpp/src/IceGrid/WellKnownObjectsManager.cpp
index 44cd4adc872..c3aae53a5a2 100644
--- a/cpp/src/IceGrid/WellKnownObjectsManager.cpp
+++ b/cpp/src/IceGrid/WellKnownObjectsManager.cpp
@@ -48,7 +48,7 @@ WellKnownObjectsManager::registerAll(const ReplicaSessionPrx& session)
{
if(!initialized())
{
- return;
+ return;
}
assert(session);
@@ -65,7 +65,7 @@ WellKnownObjectsManager::registerAll()
{
if(!initialized())
{
- return;
+ return;
}
//
@@ -80,7 +80,7 @@ WellKnownObjectsManager::updateReplicatedWellKnownObjects()
{
if(!initialized())
{
- return;
+ return;
}
//