diff options
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/IceGrid/Activator.cpp | 68 | ||||
-rw-r--r-- | cpp/src/IceGrid/NodeI.cpp | 39 | ||||
-rw-r--r-- | cpp/src/IceGrid/NodeI.h | 10 | ||||
-rwxr-xr-x | cpp/src/IceGrid/icegridnode.dsp | 4 |
4 files changed, 71 insertions, 50 deletions
diff --git a/cpp/src/IceGrid/Activator.cpp b/cpp/src/IceGrid/Activator.cpp index 3b246ed95f1..92c1d218ef3 100644 --- a/cpp/src/IceGrid/Activator.cpp +++ b/cpp/src/IceGrid/Activator.cpp @@ -14,6 +14,8 @@ #include <IceGrid/TraceLevels.h> #include <IceGrid/Util.h> +#include <IcePatch2/Util.h> + #include <sys/types.h> #include <sys/stat.h> #include <signal.h> @@ -342,29 +344,36 @@ Activator::activate(const string& name, return false; } - string path = exePath; + string path = IcePatch2::simplify(exePath); if(path.empty()) { return false; } - string pwd = pwdPath; + string pwd = IcePatch2::simplify(pwdPath); #ifdef _WIN32 - if(path[0] != '.' && path[0] != '\\' && path[0] != '/' && !(path.size() > 1 && isalpha(path[0]) && path[1] == ':')) + if(!IcePatch2::isAbsolute(path)) { - // - // 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(path.find('/') == string::npos) { - Error out(_traceLevels->logger); - out << "cannot convert `" << path << "' into an absolute path"; - return false; + // + // 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) + { + Error out(_traceLevels->logger); + out << "cannot convert `" << path << "' into an absolute path"; + return false; + } + path = absbuf; + } + else + { + path = pwd + "/" + path; } - path = absbuf; } // @@ -381,37 +390,6 @@ Activator::activate(const string& name, } pwd = absbuf; } -#else - // - // Normalize the pathname a bit. - // - { - string::size_type pos; - while((pos = path.find("//")) != string::npos) - { - path.erase(pos, 1); - } - while((pos = path.find("/./")) != string::npos) - { - path.erase(pos, 2); - } - } - - // - // Normalize the path to the working directory. - // - if(!pwd.empty()) - { - string::size_type pos; - while((pos = pwd.find("//")) != string::npos) - { - pwd.erase(pos, 1); - } - while((pos = pwd.find("/./")) != string::npos) - { - pwd.erase(pos, 2); - } - } #endif // diff --git a/cpp/src/IceGrid/NodeI.cpp b/cpp/src/IceGrid/NodeI.cpp index 1067282fc26..8cfd5d9ec0d 100644 --- a/cpp/src/IceGrid/NodeI.cpp +++ b/cpp/src/IceGrid/NodeI.cpp @@ -220,7 +220,24 @@ NodeI::NodeI(const Ice::ObjectAdapterPtr& adapter, Ice::ObjectPrx registry = getCommunicator()->stringToProxy("IceGrid/Registry@IceGrid.Registry.Internal"); _observer = RegistryPrx::uncheckedCast(registry)->getNodeObserver(); -#ifndef _WIN32 +#if defined(_WIN32) + 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; + } + err = PdhAddCounter(_query, "\\Processor(_Total)\\% Processor Time", 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:\n" << ex; + } +#else #if defined(__linux) _nproc = static_cast<int>(sysconf(_SC_NPROCESSORS_ONLN)); #elif defined(__APPLE__) @@ -239,6 +256,13 @@ NodeI::NodeI(const Ice::ObjectAdapterPtr& adapter, #endif } +NodeI::~NodeI() +{ +#ifdef _WIN32 + PdhCloseQuery(_query); +#endif +} + ServerPrx NodeI::loadServer(const ServerDescriptorPtr& desc, StringAdapterPrxDict& adapters, @@ -535,7 +559,18 @@ NodeI::keepAlive() // // TODO: Use CPU utilization // - info.load = 1.0f; + if(PdhCollectQueryData(_query) != ERROR_SUCCESS) + { + // TODO: WARNING + info.load = 1.0f; + } + else + { + DWORD type; + PDH_FMT_COUNTERVALUE value; + PdhGetFormattedCounterValue(_counter, PDH_FMT_LONG, &type, &value); + info.load = static_cast<float>(value.longValue) / 100.0f; + } #elif defined(__sun) || defined(__linux) || defined(__APPLE__) // // We use the load average divided by the number of diff --git a/cpp/src/IceGrid/NodeI.h b/cpp/src/IceGrid/NodeI.h index 84cfa84815c..30555e66860 100644 --- a/cpp/src/IceGrid/NodeI.h +++ b/cpp/src/IceGrid/NodeI.h @@ -13,6 +13,10 @@ #include <IceGrid/Internal.h> #include <IceGrid/WaitQueue.h> +#ifdef _WIN32 +# include <pdh.h> // Performance data helper API +#endif + namespace IceGrid { @@ -31,6 +35,7 @@ public: NodeI(const Ice::ObjectAdapterPtr&, const ActivatorPtr&, const WaitQueuePtr&, const TraceLevelsPtr&, const NodePrx&, const std::string&); + virtual ~NodeI(); virtual ServerPrx loadServer(const ServerDescriptorPtr&, StringAdapterPrxDict&, int&, int&, const Ice::Current&); virtual void destroyServer(const std::string&, const Ice::Current&); @@ -73,7 +78,10 @@ private: NodeObserverPrx _observer; IceUtil::Mutex _sessionMutex; NodeSessionPrx _session; -#ifndef _WIN32 +#ifdef _WIN32 + HQUERY _query; + HCOUNTER _counter; +#else int _nproc; #endif diff --git a/cpp/src/IceGrid/icegridnode.dsp b/cpp/src/IceGrid/icegridnode.dsp index 5bf7fc9612f..894924006bf 100755 --- a/cpp/src/IceGrid/icegridnode.dsp +++ b/cpp/src/IceGrid/icegridnode.dsp @@ -51,7 +51,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
-# ADD LINK32 ws2_32.lib setargv.obj /nologo /subsystem:console /incremental:yes /machine:I386 /libpath:"../../../lib" /FIXED:no
+# ADD LINK32 pdh.lib ws2_32.lib setargv.obj /nologo /subsystem:console /incremental:yes /machine:I386 /libpath:"../../../lib" /FIXED:no
# SUBTRACT LINK32 /debug /nodefaultlib
# Begin Special Build Tool
OutDir=.\Release
@@ -83,7 +83,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 ws2_32.lib setargv.obj /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"../../../lib" /FIXED:no
+# ADD LINK32 pdh.lib ws2_32.lib setargv.obj /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"../../../lib" /FIXED:no
# SUBTRACT LINK32 /pdb:none
# Begin Special Build Tool
OutDir=.\Debug
|