geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From echobr...@apache.org
Subject [geode-native] branch develop updated: GEODE-4667 remove host stats files from the project and update the HostStatHelper class accordingly.
Date Thu, 15 Feb 2018 16:00:53 GMT
This is an automated email from the ASF dual-hosted git repository.

echobravo pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode-native.git


The following commit(s) were added to refs/heads/develop by this push:
     new ac55480  GEODE-4667 remove host stats files from the project and update the HostStatHelper class accordingly.
ac55480 is described below

commit ac554806402974dd0119da78bec3b0c9b541a90e
Author: Mike Martell <mmartell@pivotal.io>
AuthorDate: Wed Feb 14 09:30:13 2018 -0800

    GEODE-4667 remove host stats files from the project and update the HostStatHelper class accordingly.
---
 cppcache/src/statistics/HostStatHelper.cpp        |  28 +-
 cppcache/src/statistics/HostStatHelper.hpp        |   6 +-
 cppcache/src/statistics/HostStatHelperLinux.cpp   | 192 ------
 cppcache/src/statistics/HostStatHelperSolaris.cpp | 236 -------
 cppcache/src/statistics/HostStatHelperWin.cpp     | 794 ----------------------
 cppcache/src/statistics/LinuxProcessStats.cpp     | 125 ----
 cppcache/src/statistics/LinuxProcessStats.hpp     |  90 ---
 cppcache/src/statistics/SolarisProcessStats.cpp   | 133 ----
 cppcache/src/statistics/SolarisProcessStats.hpp   |  91 ---
 cppcache/src/statistics/WindowsProcessStats.cpp   | 242 -------
 cppcache/src/statistics/WindowsProcessStats.hpp   |  94 ---
 11 files changed, 4 insertions(+), 2027 deletions(-)

diff --git a/cppcache/src/statistics/HostStatHelper.cpp b/cppcache/src/statistics/HostStatHelper.cpp
index 65e05b7..df76a14 100644
--- a/cppcache/src/statistics/HostStatHelper.cpp
+++ b/cppcache/src/statistics/HostStatHelper.cpp
@@ -58,13 +58,7 @@ void HostStatHelper::initOSCode() {
 
 void HostStatHelper::refresh() {
   if (processStats != nullptr) {
-#if defined(_SOLARIS)
-    HostStatHelperSolaris::refreshProcess(processStats);
-#elif defined(_LINUX)
-    HostStatHelperLinux::refreshProcess(processStats);
-#else
     HostStatHelperNull::refreshProcess(processStats);
-#endif
   }
 }
 
@@ -73,24 +67,7 @@ void HostStatHelper::newProcessStats(GeodeStatisticsFactory* statisticsFactory,
   // Init OsCode
   initOSCode();
 
-  // Create processStats , Internally they will create own stats
-  switch (osCode) {
-    case GFS_OSTYPE_SOLARIS:
-      processStats = new SolarisProcessStats(statisticsFactory, pid, name);
-      break;
-    case GFS_OSTYPE_LINUX:
-      processStats = new LinuxProcessStats(statisticsFactory, pid, name);
-      break;
-    case GFS_OSTYPE_WINDOWS:
-      processStats = new WindowsProcessStats(statisticsFactory, pid, name);
-      break;
-    case GFS_OSTYPE_MACOSX:
-      processStats = new NullProcessStats(pid, name);
-      break;
-    default:
-      throw IllegalArgumentException(
-          "HostStatHelper::newProcess:unhandled osCodem");
-  }
+  processStats = new NullProcessStats(pid, name);
   GF_D_ASSERT(processStats != nullptr);
 }
 
@@ -101,9 +78,6 @@ void HostStatHelper::close() {
 }
 
 void HostStatHelper::cleanup() {
-#if defined(_SOLARIS)
-  HostStatHelperSolaris::closeHostStatHelperSolaris();  // close kstats
-#endif
   if (processStats) {
     delete processStats;
     processStats = nullptr;
diff --git a/cppcache/src/statistics/HostStatHelper.hpp b/cppcache/src/statistics/HostStatHelper.hpp
index e4bbe29..0522244 100644
--- a/cppcache/src/statistics/HostStatHelper.hpp
+++ b/cppcache/src/statistics/HostStatHelper.hpp
@@ -31,14 +31,11 @@
 #include "ProcessStats.hpp"
 #include "StatisticsFactory.hpp"
 #include "OsStatisticsImpl.hpp"
-#include "LinuxProcessStats.hpp"
-#include "SolarisProcessStats.hpp"
 #include "StatsDef.hpp"
 #include "HostStatHelperWin.hpp"
 #include "HostStatHelperLinux.hpp"
 #include "HostStatHelperSolaris.hpp"
 #include "HostStatHelperNull.hpp"
-#include "WindowsProcessStats.hpp"
 #include "NullProcessStats.hpp"
 
 // TODO refactor - conditionally include os specific impl headers.
@@ -49,6 +46,9 @@
 namespace apache {
 namespace geode {
 namespace statistics {
+
+class GeodeStatisticsFactory;
+
 /**
  * Provides native methods which fetch operating system statistics.
  * accessed by calling {@link #getInstance()}.
diff --git a/cppcache/src/statistics/HostStatHelperLinux.cpp b/cppcache/src/statistics/HostStatHelperLinux.cpp
deleted file mode 100644
index acf6d25..0000000
--- a/cppcache/src/statistics/HostStatHelperLinux.cpp
+++ /dev/null
@@ -1,192 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "config.h"
-
-#if defined(_LINUX)
-
-#define __STDC_FORMAT_MACROS
-#include <inttypes.h>
-
-#include <glob.h>
-
-#include <ace/OS_NS_sys_utsname.h>
-#include <ace/OS_NS_errno.h>
-#include <ace/OS.h>
-
-#include "HostStatHelperLinux.hpp"
-#include "LinuxProcessStats.hpp"
-
-using namespace apache::geode::statistics;
-
-namespace apache {
-namespace geode {
-namespace statistics {
-double lastIdle = 0;
-double lastUptime = 0;
-}  // namespace statistics
-}  // namespace geode
-}  // namespace apache
-
-uint8_t HostStatHelperLinux::m_logStatErrorCountDown = 5;
-
-void HostStatHelperLinux::refreshProcess(ProcessStats* processStats) {
-  static bool threadCountMissingWarning = false;
-  // Get pid, LinuxProcessStats
-  LinuxProcessStats* linProcessStat =
-      dynamic_cast<LinuxProcessStats*>(processStats);
-  if (linProcessStat == nullptr) {
-    LOGFINE(
-        "HostStatHelperLinux::refreshProcess failed due to null processStat");
-    return;
-  }
-  Statistics* stats = linProcessStat->stats;
-  int32_t thePid = (int32_t)stats->getNumericId();  // int64 is converted to int
-
-  int32_t pid = 0;
-  char commandLine[100];
-  commandLine[0] = '\0';
-  commandLine[sizeof(commandLine) - 1] = '\0';
-  char state = 0;
-  uint32_t userTime = 0;
-  uint32_t sysTime = 0;
-  uint32_t vsize = 0;
-  int32_t rss = 0;
-  uint32_t tempimageSize = 0;
-  uint32_t temprssSize = 0;
-  int32_t cpuUsage = 0;
-  char procFileName[64];
-
-  FILE* fPtr;
-  ACE_OS::snprintf(procFileName, 64, "/proc/%" PRIu32 "/stat",
-                   (uint32_t)thePid);
-  fPtr = fopen(procFileName, "r"); /* read only */
-  if (fPtr != nullptr) {
-    int32_t status = fscanf(
-        fPtr,
-        "%d %100s %c %*d %*d %*d %*d %*d %*u %*u \
-%*u %*u %*u %u %u %*d %*d %*d %*d %*d %*d %*u %u %d ",
-        &pid, &commandLine[0], &state,
-        // ppid,
-        // pgrp,
-        // session,
-        // tty_nr,
-        // tty_pgrp,
-        // flags,
-        // min_flt,   // end first line of format string
-
-        // cmin_flt,
-        // maj_flt,
-        // cmaj_flt,
-        &userTime,  // task->times.tms_utime,
-        &sysTime,   // task->times.tms_stime,
-        // deadChildUtime, // task->times.tms_cutime,
-        // deadChildSysTime, // task->times.tms_cstime,
-        // priority,
-        // nice,
-        // unused1, // 0UL /* removed */,
-        // it_real_value,
-        // start_time,
-        &vsize,
-        &rss  //  mm ? mm->rss : 0, /* you might want to shift this left 3 */
-    );
-
-    if (status != 7 && status != EOF) {
-      int32_t errNum = errno;  // for debugging
-      if (m_logStatErrorCountDown-- > 0) {
-        LOGFINE("Error reading procFileName %s, status %d errno %d pid %lu",
-                procFileName, status, errNum, (uint32_t)thePid);
-      }
-      //  UTL_ASSERT(status == 7);
-    }
-    status = fclose(fPtr);
-    if (status) {
-      /*
-      int32_t errNum = errno; // for debugging
-      errNum = errNum; // lint
-      */
-    }
-  }
-  tempimageSize = vsize / (1024 * 1024);  // assume linux units = Kbytes
-
-  uint32_t pageSize = 1;
-  struct sysinfo info;
-  int32_t status = sysinfo(&info);
-  if (status == 0) {
-    pageSize = info.mem_unit;
-  }
-  if (pageSize != 1) {
-    temprssSize = (rss * pageSize) / (1024 * 1024);
-  }
-
-  if (temprssSize == 0) {
-    // Assuming 4096 pageSize
-    temprssSize = (4 * rss) / 1024;
-  }
-  fPtr = fopen("/proc/uptime", "r");
-  if (fPtr != nullptr) {
-    double newUptime = 0;
-    double newIdle = 0;
-    int32_t status = fscanf(fPtr, "%lf %lf", &newUptime, &newIdle);
-    if (status != 2 && status != EOF) {
-      int32_t errNum = errno;  // for debugging
-      if (m_logStatErrorCountDown-- > 0) {
-        LOGFINE("Error reading procFileName %s, status %d errno %d pid %lu",
-                procFileName, status, errNum, (uint32_t)thePid);
-      }
-    }
-    fclose(fPtr);
-    if (lastUptime != 0) {
-      double idleDelta = newIdle - lastIdle;
-      double uptimeDelta = newUptime - lastUptime;
-      if (uptimeDelta > 0) {
-        double percentIdle = idleDelta / uptimeDelta;
-        if (percentIdle < 0) {
-          percentIdle *= -1.0;
-        }
-        cpuUsage = (int)(1.0 - percentIdle) * 100;
-      }
-    }
-    lastIdle = newIdle;
-    lastUptime = newUptime;
-  }
-  // thread count
-  int threadCount = 0;
-  glob_t g;
-  if (glob("/proc/self/task/*", GLOB_ONLYDIR, nullptr, &g) == 0) {
-    threadCount = g.gl_pathc;
-    // LOGDEBUG("gl_pathc: %d",g.gl_pathc);
-    // for( unsigned int i =0; i < g.gl_pathc; i++ ) {
-    //  LOGDEBUG(" Task: %s ",g.gl_pathv[i]);
-    //}
-  } else {
-    if (threadCountMissingWarning == false) {
-      threadCountMissingWarning = true;
-      LOGWARN("Stats: Number of threads in process are not available.");
-    }
-  }
-  globfree(&g);
-
-  stats->setInt(linProcessStat->imageSizeINT, tempimageSize);
-  stats->setInt(linProcessStat->rssSizeINT, temprssSize);
-  stats->setInt(linProcessStat->userTimeINT, userTime);
-  stats->setInt(linProcessStat->systemTimeINT, sysTime);
-  stats->setInt(linProcessStat->hostCpuUsageINT, cpuUsage);
-  stats->setInt(linProcessStat->threadsINT, threadCount);
-}
-
-#endif  // if defined(_LINUX)
diff --git a/cppcache/src/statistics/HostStatHelperSolaris.cpp b/cppcache/src/statistics/HostStatHelperSolaris.cpp
deleted file mode 100644
index e9e327b..0000000
--- a/cppcache/src/statistics/HostStatHelperSolaris.cpp
+++ /dev/null
@@ -1,236 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "config.h"
-
-#if defined(_SOLARIS)
-
-#include <procfs.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <sys/systeminfo.h>
-#include <sys/proc.h>
-#include <sys/kstat.h>
-#include <glob.h>
-
-#include <ace/OS_NS_sys_utsname.h>
-#include <ace/OS_NS_errno.h>
-#include <ace/OS.h>
-
-#include <geode/internal/geode_globals.hpp>
-#include <geode/ExceptionTypes.hpp>
-
-#include "HostStatHelperSolaris.hpp"
-#include "SolarisProcessStats.hpp"
-
-using namespace apache::geode::statistics;
-
-uint8_t HostStatHelperSolaris::m_logStatErrorCountDown = 5;
-uint32_t HostStatHelperSolaris::m_cpuUtilPrev[CPU_STATES] = {0};
-bool HostStatHelperSolaris::m_initialized = false;
-kstat_ctl_t* HostStatHelperSolaris::m_kstat = nullptr;
-
-void HostStatHelperSolaris::refreshProcess(ProcessStats* processStats) {
-  static bool threadCountMissingWarning = false;
-  // Get pid, SolarisProcessStats
-  SolarisProcessStats* solProcessStat =
-      dynamic_cast<SolarisProcessStats*>(processStats);
-  if (solProcessStat == nullptr) {
-    LOGFINE(
-        "HostStatHelperSolaris::refreshProcess failed due to null processStat");
-    return;
-  }
-  Statistics* stats = solProcessStat->stats;
-  // int64 is converted to int
-  int32_t thePid = static_cast<int32_t>(stats->getNumericId());
-
-  int32_t pid = 0;
-  uint32_t userTime = 0;
-  uint32_t sysTime = 0;
-  uint32_t vsize = 0;
-  int32_t rss = 0;
-  uint32_t tempimageSize = 0;
-  uint32_t temprssSize = 0;
-  int32_t cpuUsage = 0;
-  int32_t processCpuUsage = 0;
-  char procFileName[64];
-  int fPtr;
-  prusage_t currentUsage;
-  psinfo_t currentInfo;
-
-  ACE_OS::snprintf(procFileName, 64, "/proc/%lu/psinfo",
-                   static_cast<uint32_t>(thePid));
-  // fread was returning errno 2 FILENOTFOUND so it was switched to read
-  // This matches what was done in the Geode Project also
-  fPtr = open(procFileName, O_RDONLY, 0); /* read only */
-  if (fPtr != -1) {
-    if (read(fPtr, &currentInfo, sizeof(currentInfo)) != sizeof(currentInfo)) {
-      int32_t errNum = errno;  // for debugging
-      if (m_logStatErrorCountDown-- > 0) {
-        LOGFINE("Error reading procFileName %s, errno %d pid %lu", procFileName,
-                errNum, static_cast<uint32_t>(thePid));
-      }
-    } else {
-      tempimageSize = currentInfo.pr_size / 1024UL;
-      temprssSize = currentInfo.pr_rssize / 1024UL;
-      processCpuUsage = (int)((currentInfo.pr_pctcpu / 32768.0) * 100);
-    }
-    close(fPtr);
-  }
-  ACE_OS::snprintf(procFileName, 64, "/proc/%u/usage",
-                   static_cast<uint32_t>(thePid));
-  fPtr = open(procFileName, O_RDONLY, 0);
-  if (fPtr != -1) {
-    if (read(fPtr, &currentUsage, sizeof(currentUsage)) !=
-        sizeof(currentUsage)) {
-      int32_t errNum = errno;  // for debugging
-      if (m_logStatErrorCountDown-- > 0) {
-        LOGFINE("Error reading procFileName %s, errno %d pid %lu", procFileName,
-                errNum, static_cast<uint32_t>(thePid));
-      }
-    } else {
-      uint32_t usrTimeSecs = currentUsage.pr_utime.tv_sec;
-      uint32_t usrTimeNanos = currentUsage.pr_utime.tv_nsec;
-      userTime = (usrTimeSecs * 1000 * 1000) + (usrTimeNanos / (1000));
-
-      uint32_t sysTimeSecs = currentUsage.pr_stime.tv_sec;
-      uint32_t sysTimeNanos = currentUsage.pr_stime.tv_nsec;
-      sysTime = (sysTimeSecs * 1000 * 1000) + (sysTimeNanos / (1000));
-    }
-    close(fPtr);
-  }
-  uint32_t cpuUtil[CPU_STATES] = {0};
-  try {
-    getKernelStats(cpuUtil);
-    if (m_initialized) {
-      uint32_t idleDelta = cpuUtil[CPU_IDLE] - m_cpuUtilPrev[CPU_IDLE];
-      double timeDelta = idleDelta;
-      timeDelta += (cpuUtil[CPU_USER] - m_cpuUtilPrev[CPU_USER]);
-      timeDelta += (cpuUtil[CPU_KERNEL] - m_cpuUtilPrev[CPU_KERNEL]);
-      timeDelta += (cpuUtil[CPU_WAIT] - m_cpuUtilPrev[CPU_WAIT]);
-      if (timeDelta > CPU_USAGE_STAT_THRESHOLD) {
-        // Math is equivalent to 100*(timeDelta-idleDelta)/timeDelta, rounding
-        // aside
-        cpuUsage = 100 - 100 * (idleDelta) / timeDelta;
-        // Update the previous copy
-        memcpy(m_cpuUtilPrev, cpuUtil, sizeof(uint32_t[CPU_STATES]));
-      } else {
-        if (m_logStatErrorCountDown-- > 0) {
-          LOGFINE(
-              "Kernel stat sampling failed to meet CPU_USAGE_THRESHOLD, "
-              "reporting 100%% cpu load");
-        }
-        cpuUsage = 100;
-      }
-    } else {
-      // Update the previous copy
-      memcpy(m_cpuUtilPrev, cpuUtil, sizeof(uint32_t[CPU_STATES]));
-      m_initialized = true;
-    }
-  } catch (NullPointerException npe) {
-    if (m_logStatErrorCountDown-- > 0) {
-      LOGERROR(npe.what());
-    }
-  }
-  // thread count
-  int threadCount = 0;
-  glob_t g;
-  if (glob("/proc/self/lwp/*", 0, nullptr, &g) == 0) {
-    threadCount = g.gl_pathc;
-    // LOGDEBUG("gl_pathc: %d",g.gl_pathc);
-    // for( unsigned int i =0; i < g.gl_pathc; i++ ) {
-    //  LOGDEBUG(" LWP: %s ",g.gl_pathv[i]);
-    //}
-  } else {
-    if (threadCountMissingWarning == false) {
-      threadCountMissingWarning = true;
-      LOGWARN("Stats: Number of threads in process are not available.");
-    }
-  }
-  globfree(&g);
-
-  stats->setInt(solProcessStat->imageSizeINT, tempimageSize);
-  stats->setInt(solProcessStat->rssSizeINT, temprssSize);
-  stats->setInt(solProcessStat->userTimeINT, userTime);
-  stats->setInt(solProcessStat->systemTimeINT, sysTime);
-  stats->setInt(solProcessStat->hostCpuUsageINT, cpuUsage);
-  stats->setInt(solProcessStat->processCpuUsageINT, processCpuUsage);
-  stats->setInt(solProcessStat->threadsINT, threadCount);
-}
-
-void HostStatHelperSolaris::getKernelStats(uint32_t* cpuUtil) {
-  if (m_kstat == nullptr) {
-    m_kstat = kstat_open();
-    if (m_kstat == nullptr) {
-      char buf[128];
-      ACE_OS::snprintf(buf, 128, "Unable to obtain kstat data, errno %d",
-                       errno);
-      throw NullPointerException(buf);
-    }
-  }
-  kstat_ctl_t wkc;
-  kstat_t* ksp;
-  kstat_t* wksp;
-  cpu_stat_t rcw_cpu_stat_t;
-  char module[KSTAT_STRLEN + 1];
-  kid_t kcid;
-
-  // Make a copy of it.
-  memcpy(&wkc, m_kstat, sizeof(kstat_ctl_t));
-  // Walk the chain.
-  for (ksp = wkc.kc_chain; ksp != nullptr; ksp = ksp->ks_next) {
-    // Header information
-    // kstats are identified by module, instance, class, and name.
-    strncpy(module, ksp->ks_module, KSTAT_STRLEN);
-    module[KSTAT_STRLEN] = '\0';
-    // With raw data you must know what to expect.
-    if (ksp->ks_type == KSTAT_TYPE_RAW) {
-      if (strcmp(module, "cpu_stat") == 0) {
-        wksp = ksp;
-        // Read the data corresponding to the pointer. cpu_stat modules deliver
-        // cpu_stat_t data.
-        kcid = kstat_read(&wkc, wksp, &rcw_cpu_stat_t);
-        if (kcid == -1) {
-          LOGERROR("Error reading stats, errno \"%d\"", errno);
-          throw NullPointerException(
-              "Error reading cpu_stat struct from kernal stats");
-        }
-        /*
-        LOGDEBUG("rcw_cpu_stat_t cpu idle= %u, user= %u, sys=%u, wait=%u, \n",
-                    rcw_cpu_stat_t.cpu_sysinfo.cpu[CPU_IDLE],
-                    rcw_cpu_stat_t.cpu_sysinfo.cpu[CPU_USER],
-                    rcw_cpu_stat_t.cpu_sysinfo.cpu[CPU_KERNEL],
-                    rcw_cpu_stat_t.cpu_sysinfo.cpu[CPU_WAIT] );
-        */
-        cpuUtil[CPU_IDLE] = rcw_cpu_stat_t.cpu_sysinfo.cpu[CPU_IDLE];
-        cpuUtil[CPU_USER] = rcw_cpu_stat_t.cpu_sysinfo.cpu[CPU_USER];
-        cpuUtil[CPU_KERNEL] = rcw_cpu_stat_t.cpu_sysinfo.cpu[CPU_KERNEL];
-        cpuUtil[CPU_WAIT] = rcw_cpu_stat_t.cpu_sysinfo.cpu[CPU_WAIT];
-      }
-    }
-  }
-}
-
-void HostStatHelperSolaris::closeHostStatHelperSolaris() {
-  if (m_kstat != nullptr) {
-    kstat_close(m_kstat);
-    m_kstat = nullptr;
-  }
-}
-#endif /* SOLARIS */
diff --git a/cppcache/src/statistics/HostStatHelperWin.cpp b/cppcache/src/statistics/HostStatHelperWin.cpp
deleted file mode 100644
index 573e124..0000000
--- a/cppcache/src/statistics/HostStatHelperWin.cpp
+++ /dev/null
@@ -1,794 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <ace/OS.h>
-#include <geode/internal/geode_globals.hpp>
-
-#include "HostStatHelperWin.hpp"
-
-#include "ProcessStats.hpp"
-#include "WindowsProcessStats.hpp"
-
-/**
- * Windows2000 Implementation of code to fetch operating system stats.
- *
- */
-
-#if defined(_WIN32)
-using namespace apache::geode::statistics;
-
-PPERF_DATA_BLOCK HostStatHelperWin::PerfData = nullptr;
-PPERF_OBJECT_TYPE HostStatHelperWin::ProcessObj = nullptr;
-PPERF_OBJECT_TYPE HostStatHelperWin::ProcessorObj = nullptr;
-PPERF_OBJECT_TYPE HostStatHelperWin::MemoryObj = nullptr;
-PPERF_OBJECT_TYPE HostStatHelperWin::SystemObj = nullptr;
-PPERF_OBJECT_TYPE HostStatHelperWin::ObjectsObj = nullptr;
-DWORD HostStatHelperWin::BufferSize = 65536;
-int32_t HostStatHelperWin::pidCtrOffset = -1;
-
-PERF_COUNTER_DEFINITION
-HostStatHelperWin::processCtrCache[MAX_PROCESS_CTRS_COLLECTED];
-
-PERF_COUNTER_DEFINITION
-HostStatHelperWin::processorCtrCache[MAX_PROCESSOR_CTRS_COLLECTED];
-
-PERF_COUNTER_DEFINITION
-HostStatHelperWin::systemCtrCache[MAX_SYSTEM_CTRS_COLLECTED];
-
-PERF_COUNTER_DEFINITION
-HostStatHelperWin::memoryCtrCache[MAX_MEMORY_CTRS_COLLECTED];
-
-PERF_COUNTER_DEFINITION
-HostStatHelperWin::objectsCtrCache[MAX_OBJECTS_CTRS_COLLECTED];
-
-struct HostStatHelperWin::FetchDataSType HostStatHelperWin::lastFetchData;
-struct HostStatHelperWin::FetchDataSType HostStatHelperWin::currentFetchData;
-
-PPERF_OBJECT_TYPE HostStatHelperWin::FirstObject(PPERF_DATA_BLOCK PerfData) {
-  return ((PPERF_OBJECT_TYPE)((PBYTE)PerfData + PerfData->HeaderLength));
-}
-
-PPERF_OBJECT_TYPE HostStatHelperWin::NextObject(PPERF_OBJECT_TYPE PerfObj) {
-  return ((PPERF_OBJECT_TYPE)((PBYTE)PerfObj + PerfObj->TotalByteLength));
-}
-
-PPERF_INSTANCE_DEFINITION HostStatHelperWin::FirstInstance(
-    PPERF_OBJECT_TYPE PerfObj) {
-  return (
-      (PPERF_INSTANCE_DEFINITION)((PBYTE)PerfObj + PerfObj->DefinitionLength));
-}
-
-PPERF_INSTANCE_DEFINITION HostStatHelperWin::NextInstance(
-    PPERF_COUNTER_BLOCK PerfCntrBlk) {
-  return ((PPERF_INSTANCE_DEFINITION)((PBYTE)PerfCntrBlk +
-                                      PerfCntrBlk->ByteLength));
-}
-
-char* HostStatHelperWin::getInstIdStr(PPERF_INSTANCE_DEFINITION PerfInst,
-                                      char* prefix) {
-  static char resbuff[132];
-  if (PerfInst->UniqueID == PERF_NO_UNIQUE_ID) {
-    short* unicodePtr = (short*)((PBYTE)PerfInst + PerfInst->NameOffset);
-    ACE_OS::snprintf(resbuff, 132, "%S length=%d unicode[0]=%d",
-                     (char*)((PBYTE)PerfInst + PerfInst->NameOffset),
-                     PerfInst->NameLength, unicodePtr[0]);
-  } else {
-    ACE_OS::snprintf(resbuff, 132, "%s%d", prefix, PerfInst->UniqueID);
-  }
-  return resbuff;
-}
-
-PPERF_COUNTER_DEFINITION HostStatHelperWin::FirstCounter(
-    PPERF_OBJECT_TYPE PerfObj) {
-  return ((PPERF_COUNTER_DEFINITION)((PBYTE)PerfObj + PerfObj->HeaderLength));
-}
-
-PPERF_COUNTER_DEFINITION HostStatHelperWin::NextCounter(
-    PPERF_COUNTER_DEFINITION PerfCntr) {
-  return ((PPERF_COUNTER_DEFINITION)((PBYTE)PerfCntr + PerfCntr->ByteLength));
-}
-
-void HostStatHelperWin::HostStatsFetchData() {
-  DWORD o;
-  PPERF_OBJECT_TYPE objPtr = nullptr;
-  DWORD res;
-  PPERF_COUNTER_DEFINITION PerfCntr;
-  DWORD oldBufferSize = BufferSize;
-  const char* qstr;
-  qstr = LEVEL1_QUERY_STRING;
-
-  while ((res = RegQueryValueEx(HKEY_PERFORMANCE_DATA, qstr, nullptr, nullptr,
-                                (LPBYTE)PerfData, &BufferSize)) ==
-         ERROR_MORE_DATA) {
-    oldBufferSize += 4096;
-    BufferSize = oldBufferSize;
-    PerfData = (PPERF_DATA_BLOCK)realloc(PerfData, BufferSize);
-  }
-
-#ifdef NTDBG
-  LOGDEBUG("HostStatHeleperWin: buffersize is %ld\n", BufferSize);
-#endif
-  ProcessObj = nullptr;
-  ProcessorObj = nullptr;
-  MemoryObj = nullptr;
-  SystemObj = nullptr;
-  ObjectsObj = nullptr;
-
-  if (res != ERROR_SUCCESS) {
-    LOGDEBUG(
-        "HostStatHeleperWin: Can't get Windows performance data. "
-        "RegQueryValueEx returned %ld\n",
-        res);
-    return;
-  }
-
-  objPtr = FirstObject(PerfData);
-  for (o = 0; o < PerfData->NumObjectTypes; o++) {
-#ifdef NTDBG
-    LOGDEBUG("HostStatHeleperWin: Object %ld\n", objPtr->ObjectNameTitleIndex);
-#endif
-    switch (objPtr->ObjectNameTitleIndex) {
-      case PROCESS_OBJ_ID:
-        ProcessObj = objPtr;
-        break;
-      case PROCESSOR_OBJ_ID:
-        ProcessorObj = objPtr;
-        break;
-      case MEMORY_OBJ_ID:
-        MemoryObj = objPtr;
-        break;
-      case SYSTEM_OBJ_ID:
-        SystemObj = objPtr;
-        break;
-      case OBJECTS_OBJ_ID:
-        ObjectsObj = objPtr;
-        break;
-    }
-    objPtr = NextObject(objPtr);
-  }
-  if (pidCtrOffset == -1) {
-    if (ProcessObj) {
-      DWORD c;
-      PerfCntr = FirstCounter(ProcessObj);
-      for (c = 0; c < ProcessObj->NumCounters; c++) {
-        switch (PerfCntr->CounterNameTitleIndex) {
-          case PID_ID:
-            pidCtrOffset = PerfCntr->CounterOffset;
-            break;
-          case PROCESSORTIME_ID:
-            processCtrCache[PROCESSORTIME_IDX] = *PerfCntr;
-            break;
-          case USERTIME_ID:
-            processCtrCache[USERTIME_IDX] = *PerfCntr;
-            break;
-          case PRIVILEGEDTIME_ID:
-            processCtrCache[PRIVILEGEDTIME_IDX] = *PerfCntr;
-            break;
-          case VIRTUALBYTESPEAK_ID:
-            processCtrCache[VIRTUALBYTESPEAK_IDX] = *PerfCntr;
-            break;
-          case VIRTUALBYTES_ID:
-            processCtrCache[VIRTUALBYTES_IDX] = *PerfCntr;
-            break;
-          case PAGEFAULTS_ID:
-            processCtrCache[PAGEFAULTS_IDX] = *PerfCntr;
-            break;
-          case WORKINGSETPEAK_ID:
-            processCtrCache[WORKINGSETPEAK_IDX] = *PerfCntr;
-            break;
-          case WORKINGSET_ID:
-            processCtrCache[WORKINGSET_IDX] = *PerfCntr;
-            break;
-          case PAGEFILEBYTESPEAK_ID:
-            processCtrCache[PAGEFILEBYTESPEAK_IDX] = *PerfCntr;
-            break;
-          case PAGEFILEBYTES_ID:
-            processCtrCache[PAGEFILEBYTES_IDX] = *PerfCntr;
-            break;
-          case PRIVATEBYTES_ID:
-            processCtrCache[PRIVATEBYTES_IDX] = *PerfCntr;
-            break;
-          case THREADCOUNT_ID:
-            processCtrCache[THREADCOUNT_IDX] = *PerfCntr;
-            break;
-          case PRIORITYBASE_ID:
-            processCtrCache[PRIORITYBASE_IDX] = *PerfCntr;
-            break;
-          case POOLPAGEDBYTES_ID:
-            processCtrCache[POOLPAGEDBYTES_IDX] = *PerfCntr;
-            break;
-          case POOLNONPAGEDBYTES_ID:
-            processCtrCache[POOLNONPAGEDBYTES_IDX] = *PerfCntr;
-            break;
-          case HANDLECOUNT_ID:
-            processCtrCache[HANDLECOUNT_IDX] = *PerfCntr;
-            break;
-          default:
-            /* unknown counter. just skip it. */
-            break;
-        }
-        PerfCntr = NextCounter(PerfCntr);
-      }
-#if GF_DEBUG_ASSERTS == 1
-      for (c = 0; c < MAX_PROCESS_CTRS_COLLECTED; c++) {
-        if (processCtrCache[c].CounterNameTitleIndex == 0) {
-          LOGDEBUG("HostStatHeleperWin: bad processCtr at idx=%d\n", c);
-        }
-      }
-#endif
-    }
-    if (ProcessorObj) {
-      DWORD c;
-      PerfCntr = FirstCounter(ProcessorObj);
-#if 0
-      LOGDEBUG("HostStatHeleperWin: ProcessorObj->NumCounters=%d\n", ProcessorObj->NumCounters);
-#endif
-      for (c = 0; c < ProcessorObj->NumCounters; c++) {
-#if 0
-        LOGDEBUG("HostStatHeleperWin: PerfCntr->CounterNameTitleIndex=%d\n", PerfCntr->CounterNameTitleIndex);
-#endif
-        switch (PerfCntr->CounterNameTitleIndex) {
-          case PROCESSORTIME_ID:
-            processorCtrCache[TOTALPROCESSORTIME_IDX] = *PerfCntr;
-            break;
-          case USERTIME_ID:
-            processorCtrCache[TOTALUSERTIME_IDX] = *PerfCntr;
-            break;
-          case PRIVILEGEDTIME_ID:
-            processorCtrCache[TOTALPRIVILEGEDTIME_IDX] = *PerfCntr;
-            break;
-          case INTERRUPTTIME_ID:
-            processorCtrCache[INTERRUPTTIME_IDX] = *PerfCntr;
-            break;
-          case INTERRUPTS_ID:
-            processorCtrCache[INTERRUPTS_IDX] = *PerfCntr;
-            break;
-          default:
-            /* unknown counter. just skip it. */
-            break;
-        }
-        PerfCntr = NextCounter(PerfCntr);
-      }
-#ifdef FLG_DEBUG
-      for (c = 0; c < MAX_PROCESSOR_CTRS_COLLECTED; c++) {
-        if (processorCtrCache[c].CounterNameTitleIndex == 0) {
-          LOGDEBUG("HostStatHeleperWin: bad processorCtr at idx=%d\n",
-                   c);  // fflush(stderr);
-        }
-      }
-#endif
-    }
-
-    if (SystemObj) {
-      DWORD c;
-      PerfCntr = FirstCounter(SystemObj);
-      for (c = 0; c < SystemObj->NumCounters; c++) {
-        switch (PerfCntr->CounterNameTitleIndex) {
-          case TOTALFILEREADOPS_ID:
-            systemCtrCache[TOTALFILEREADOPS_IDX] = *PerfCntr;
-            break;
-          case TOTALFILEWRITEOPS_ID:
-            systemCtrCache[TOTALFILEWRITEOPS_IDX] = *PerfCntr;
-            break;
-          case TOTALFILECONTROLOPS_ID:
-            systemCtrCache[TOTALFILECONTROLOPS_IDX] = *PerfCntr;
-            break;
-          case TOTALFILEREADKBYTES_ID:
-            systemCtrCache[TOTALFILEREADKBYTES_IDX] = *PerfCntr;
-            break;
-          case TOTALFILEWRITEKBYTES_ID:
-            systemCtrCache[TOTALFILEWRITEKBYTES_IDX] = *PerfCntr;
-            break;
-          case TOTALFILECONTROLKBYTES_ID:
-            systemCtrCache[TOTALFILECONTROLKBYTES_IDX] = *PerfCntr;
-            break;
-          case TOTALCONTEXTSWITCHES_ID:
-            systemCtrCache[TOTALCONTEXTSWITCHES_IDX] = *PerfCntr;
-            break;
-          case TOTALSYSTEMCALLS_ID:
-            systemCtrCache[TOTALSYSTEMCALLS_IDX] = *PerfCntr;
-            break;
-          case TOTALFILEDATAOPS_ID:
-            systemCtrCache[TOTALFILEDATAOPS_IDX] = *PerfCntr;
-            break;
-          case PROCESSORQUEUELENGTH_ID:
-            systemCtrCache[PROCESSORQUEUELENGTH_IDX] = *PerfCntr;
-            break;
-          case ALIGNMENTFIXUPS_ID:
-            systemCtrCache[ALIGNMENTFIXUPS_IDX] = *PerfCntr;
-            break;
-          case EXCEPTIONDISPATCHES_ID:
-            systemCtrCache[EXCEPTIONDISPATCHES_IDX] = *PerfCntr;
-            break;
-          case FLOATINGEMULATIONS_ID:
-            systemCtrCache[FLOATINGEMULATIONS_IDX] = *PerfCntr;
-            break;
-          case REGISTRYQUOTAINUSE_ID:
-            systemCtrCache[REGISTRYQUOTAINUSE_IDX] = *PerfCntr;
-            break;
-          default:
-            /* unknown counter. just skip it. */
-            break;
-        }
-        PerfCntr = NextCounter(PerfCntr);
-      }
-#ifdef FLG_DEBUG
-      for (c = 0; c < MAX_SYSTEM_CTRS_COLLECTED; c++) {
-        if (systemCtrCache[c].CounterNameTitleIndex == 0) {
-          LOGDEBUG("HostStatHeleperWin: bad systemCtr at idx=%d\n", c);
-        }
-      }
-#endif
-    }
-
-    if (MemoryObj) {
-      DWORD c;
-      PerfCntr = FirstCounter(MemoryObj);
-      for (c = 0; c < MemoryObj->NumCounters; c++) {
-        switch (PerfCntr->CounterNameTitleIndex) {
-          case AVAILABLEBYTES_ID:
-            memoryCtrCache[AVAILABLEBYTES_IDX] = *PerfCntr;
-            break;
-          case COMMITTEDBYTES_ID:
-            memoryCtrCache[COMMITTEDBYTES_IDX] = *PerfCntr;
-            break;
-          case COMMITLIMIT_ID:
-            memoryCtrCache[COMMITLIMIT_IDX] = *PerfCntr;
-            break;
-          case TOTALPAGEFAULTS_ID:
-            memoryCtrCache[TOTALPAGEFAULTS_IDX] = *PerfCntr;
-            break;
-          case WRITECOPIES_ID:
-            memoryCtrCache[WRITECOPIES_IDX] = *PerfCntr;
-            break;
-          case TRANSITIONFAULTS_ID:
-            memoryCtrCache[TRANSITIONFAULTS_IDX] = *PerfCntr;
-            break;
-          case CACHEFAULTS_ID:
-            memoryCtrCache[CACHEFAULTS_IDX] = *PerfCntr;
-            break;
-          case DEMANDZEROFAULTS_ID:
-            memoryCtrCache[DEMANDZEROFAULTS_IDX] = *PerfCntr;
-            break;
-          case PAGES_ID:
-            memoryCtrCache[PAGES_IDX] = *PerfCntr;
-            break;
-          case PAGESINPUT_ID:
-            memoryCtrCache[PAGESINPUT_IDX] = *PerfCntr;
-            break;
-          case PAGEREADS_ID:
-            memoryCtrCache[PAGEREADS_IDX] = *PerfCntr;
-            break;
-          case PAGESOUTPUT_ID:
-            memoryCtrCache[PAGESOUTPUT_IDX] = *PerfCntr;
-            break;
-          case PAGEWRITES_ID:
-            memoryCtrCache[PAGEWRITES_IDX] = *PerfCntr;
-            break;
-          case TOTALPOOLPAGEDBYTES_ID:
-            memoryCtrCache[TOTALPOOLPAGEDBYTES_IDX] = *PerfCntr;
-            break;
-          case TOTALPOOLNONPAGEDBYTES_ID:
-            memoryCtrCache[TOTALPOOLNONPAGEDBYTES_IDX] = *PerfCntr;
-            break;
-          case POOLPAGEDALLOCS_ID:
-            memoryCtrCache[POOLPAGEDALLOCS_IDX] = *PerfCntr;
-            break;
-          case POOLNONPAGEDALLOCS_ID:
-            memoryCtrCache[POOLNONPAGEDALLOCS_IDX] = *PerfCntr;
-            break;
-          case FREESYSTEMPAGETABLEENTRIES_ID:
-            memoryCtrCache[FREESYSTEMPAGETABLEENTRIES_IDX] = *PerfCntr;
-            break;
-          case CACHEBYTES_ID:
-            memoryCtrCache[CACHEBYTES_IDX] = *PerfCntr;
-            break;
-          case CACHEBYTESPEAK_ID:
-            memoryCtrCache[CACHEBYTESPEAK_IDX] = *PerfCntr;
-            break;
-          case POOLPAGEDRESIDENTBYTES_ID:
-            memoryCtrCache[POOLPAGEDRESIDENTBYTES_IDX] = *PerfCntr;
-            break;
-          case SYSTEMCODETOTALBYTES_ID:
-            memoryCtrCache[SYSTEMCODETOTALBYTES_IDX] = *PerfCntr;
-            break;
-          case SYSTEMCODERESIDENTBYTES_ID:
-            memoryCtrCache[SYSTEMCODERESIDENTBYTES_IDX] = *PerfCntr;
-            break;
-          case SYSTEMDRIVERTOTALBYTES_ID:
-            memoryCtrCache[SYSTEMDRIVERTOTALBYTES_IDX] = *PerfCntr;
-            break;
-          case SYSTEMDRIVERRESIDENTBYTES_ID:
-            memoryCtrCache[SYSTEMDRIVERRESIDENTBYTES_IDX] = *PerfCntr;
-            break;
-          case SYSTEMCACHERESIDENTBYTES_ID:
-            memoryCtrCache[SYSTEMCACHERESIDENTBYTES_IDX] = *PerfCntr;
-            break;
-          case COMMITTEDBYTESINUSE_ID:
-            memoryCtrCache[COMMITTEDBYTESINUSE_IDX] = *PerfCntr;
-            break;
-          default:
-            /* unknown counter. just skip it. */
-            break;
-        }
-        PerfCntr = NextCounter(PerfCntr);
-      }
-#ifdef FLG_DEBUG
-      for (c = 0; c < MAX_MEMORY_CTRS_COLLECTED; c++) {
-        if (memoryCtrCache[c].CounterNameTitleIndex == 0) {
-          LOGDEBUG("HostStatHeleperWin: bad memoryCtr at idx=%d\n", c);
-        }
-      }
-#endif
-    }
-    if (ObjectsObj) {
-      DWORD c;
-      PerfCntr = FirstCounter(ObjectsObj);
-      for (c = 0; c < ObjectsObj->NumCounters; c++) {
-        switch (PerfCntr->CounterNameTitleIndex) {
-          case PROCESSES_ID:
-            objectsCtrCache[PROCESSES_IDX] = *PerfCntr;
-            break;
-          case THREADS_ID:
-            objectsCtrCache[THREADS_IDX] = *PerfCntr;
-            break;
-          case EVENTS_ID:
-            objectsCtrCache[EVENTS_IDX] = *PerfCntr;
-            break;
-          case SEMAPHORES_ID:
-            objectsCtrCache[SEMAPHORES_IDX] = *PerfCntr;
-            break;
-          case MUTEXES_ID:
-            objectsCtrCache[MUTEXES_IDX] = *PerfCntr;
-            break;
-          case SECTIONS_ID:
-            objectsCtrCache[SECTIONS_IDX] = *PerfCntr;
-            break;
-          default:
-            /* unknown counter. just skip it. */
-            break;
-        }
-        PerfCntr = NextCounter(PerfCntr);
-      }
-#ifdef FLG_DEBUG
-      for (c = 0; c < MAX_OBJECTS_CTRS_COLLECTED; c++) {
-        if (objectsCtrCache[c].CounterNameTitleIndex == 0) {
-          LOGDEBUG("HostStatHeleperWin: bad objectsCtr at idx=%d\n", c);
-        }
-      }
-#endif
-    }
-  }
-  lastFetchData = currentFetchData;
-  currentFetchData.perfTimeMs =
-      (uint32_t)(((int64_t)PerfData->PerfTime100nSec.QuadPart) / 10000);
-  if (ProcessorObj) {
-    int32_t i;
-    PPERF_INSTANCE_DEFINITION PerfInst;
-
-    if (ProcessorObj->NumInstances > 0) {
-      bool foundIt = FALSE;
-      PerfInst = FirstInstance(ProcessorObj);
-      for (i = 0; i < (int32_t)ProcessorObj->NumInstances; i++) {
-        PPERF_COUNTER_BLOCK PerfCntrBlk =
-            (PPERF_COUNTER_BLOCK)((PBYTE)PerfInst + PerfInst->ByteLength);
-        short* unicodePtr = (short*)((PBYTE)PerfInst + PerfInst->NameOffset);
-        if (PerfInst->UniqueID == PERF_NO_UNIQUE_ID && unicodePtr[0] == '_') {
-          /* starts with "_" must be "_Total" */
-
-          currentFetchData.usertime =
-              getInt64Value(&processorCtrCache[TOTALUSERTIME_IDX], PerfCntrBlk);
-          currentFetchData.systime = getInt64Value(
-              &processorCtrCache[TOTALPRIVILEGEDTIME_IDX], PerfCntrBlk);
-          currentFetchData.idletime = getInt64Value(
-              &processorCtrCache[TOTALPROCESSORTIME_IDX], PerfCntrBlk);
-          currentFetchData.inttime =
-              getInt64Value(&processorCtrCache[INTERRUPTTIME_IDX], PerfCntrBlk);
-          currentFetchData.interrupts =
-              getInt32Value(&processorCtrCache[INTERRUPTS_IDX], PerfCntrBlk);
-          foundIt = TRUE;
-          break;
-        }
-        PerfInst = NextInstance(PerfCntrBlk);
-      }
-#ifdef FLG_DEBUG
-      if (!foundIt) {
-        LOGDEBUG("HostStatHeleperWin: did not find processor named _Total!\n");
-      }
-#endif
-    } else {
-#ifdef FLG_DEBUG
-      LOGDEBUG("HostStatHeleperWin: unexpected 0 instances!\n");
-#endif
-    }
-  }
-}
-
-int32_t HostStatHelperWin::getPid(int32_t pidCtrOffset,
-                                  PPERF_COUNTER_BLOCK PerfCntrBlk) {
-  int32_t* result = (int32_t*)((char*)PerfCntrBlk + pidCtrOffset);
-  return *result;
-}
-
-uint32_t HostStatHelperWin::getInt32Value(PPERF_COUNTER_DEFINITION PerfCntr,
-                                          PPERF_COUNTER_BLOCK PerfCntrBlk) {
-  if (PerfCntr->CounterOffset == 0) {
-#ifdef FLG_DEBUG
-    LOGDEBUG("HostStatHeleperWin: missing counter id=%d\n",
-             PerfCntr->CounterNameTitleIndex);
-#endif
-    return 0;
-  }
-
-  if (PerfCntr->CounterSize == 4) {
-    uint32_t* lptr;
-    lptr = reinterpret_cast<uint32_t*>(reinterpret_cast<char*>(PerfCntrBlk) +
-                                       PerfCntr->CounterOffset);
-    if (PerfCntr->CounterType == PERF_RAW_FRACTION) {
-      double fraction = (double)*lptr++;
-      double base = (double)*lptr;
-      if (base != 0) {
-        return (uint32_t)((fraction / base) * 100.0);
-      } else {
-        return 0;
-      }
-    } else if (PerfCntr->CounterType == PERF_RAW_BASE) {
-      double base = (double)*lptr--;
-      double fraction = (double)*lptr;
-      if (base != 0) {
-        return (uint32_t)((fraction / base) * 100.0);
-      } else {
-        return 0;
-      }
-    } else {
-      return *lptr;
-    }
-  } else {
-#ifdef FLG_DEBUG
-    LOGDEBUG("HostStatHeleperWin: unexpected CounterSize of %ld\n",
-             PerfCntr->CounterSize);  // fflush(stderr);
-#endif
-    return 0;
-  }
-}
-
-int64_t HostStatHelperWin::getInt64Value(PPERF_COUNTER_DEFINITION PerfCntr,
-                                         PPERF_COUNTER_BLOCK PerfCntrBlk,
-                                         bool convertMS) {
-  if (PerfCntr->CounterOffset == 0) {
-#ifdef FLG_DEBUG
-    LOGDEBUG("HostStatHeleperWin: missing counter id=%d\n",
-             PerfCntr->CounterNameTitleIndex);
-#endif
-    return 0;
-  }
-  if (PerfCntr->CounterSize == 8) {
-    int64_t* i64ptr;
-    int64_t iValue;
-    int64_t result;
-
-    i64ptr = (int64_t*)((char*)PerfCntrBlk + PerfCntr->CounterOffset);
-    iValue = *i64ptr;
-
-/* #define I64_TRACE */
-#ifdef I64_TRACE
-    LOGDEBUG("HostStatHeleperWin: %x %I64x", PerfCntr->CounterType, iValue);
-#endif
-    if (iValue != 0) {
-      switch (PerfCntr->CounterType) {
-        case PERF_COUNTER_LARGE_RAWCOUNT:
-        case PERF_COUNTER_BULK_COUNT:
-          break;
-#if 0
-      case PERF_COUNTER_TIMER:
-  /* convert to milliseconds */
-  /* PerfFreq is number of times per seconds so adjust by 1000 for ms */
-  iValue /=  (((int64_t)PerfData->PerfFreq.QuadPart) / 1000);
-  break;
-#endif
-        case PERF_100NSEC_TIMER_INV:
-        case PERF_100NSEC_TIMER:
-          if (convertMS) {
-            /* convert to milliseconds */
-            iValue /= 10000;
-          }
-          break;
-        default:
-#ifdef FLG_DEBUG
-          LOGDEBUG("HostStatHeleperWin: unexpected CounterType %lx\n",
-                   PerfCntr->CounterType);
-#endif
-          break;
-      }
-    }
-    result = iValue;
-    return result;
-  } else {
-#ifdef FLG_DEBUG
-    LOGDEBUG(
-        "HostStatHeleperWin: unexpected CounterSize of %ld NameOffset=%d\n",
-        PerfCntr->CounterSize,
-        PerfCntr->CounterNameTitleIndex);  // fflush(stderr);
-#endif
-    return 0;
-  }
-}
-
-void HostStatHelperWin::initHostStatHelperWin() {
-  /* Initialize registry data structures */
-  int32_t counter;
-  if (!PerfData) {
-    PerfData = (PPERF_DATA_BLOCK)malloc(BufferSize);
-  }
-  for (counter = 0; counter < MAX_PROCESS_CTRS_COLLECTED; counter++) {
-    processCtrCache[counter].CounterOffset = 0;
-  }
-  for (counter = 0; counter < MAX_SYSTEM_CTRS_COLLECTED; counter++) {
-    systemCtrCache[counter].CounterOffset = 0;
-  }
-  for (counter = 0; counter < MAX_MEMORY_CTRS_COLLECTED; counter++) {
-    memoryCtrCache[counter].CounterOffset = 0;
-  }
-  for (counter = 0; counter < MAX_OBJECTS_CTRS_COLLECTED; counter++) {
-    objectsCtrCache[counter].CounterOffset = 0;
-  }
-  lastFetchData.perfTimeMs = 0;
-  currentFetchData.perfTimeMs = 0;
-  pidCtrOffset = -1;
-  HostStatsFetchData();
-}
-
-void HostStatHelperWin::refreshProcess(ProcessStats* processStats) {
-  // Get pid, WindowsProcessStats
-  WindowsProcessStats* winProcessStat =
-      dynamic_cast<WindowsProcessStats*>(processStats);
-  if (winProcessStat == nullptr) {
-    LOGFINE("HostStatHelperWin::refreshProcess failed due to null processStat");
-    return;
-  }
-  Statistics* stats = winProcessStat->stats;
-  int32_t pid = (int32_t)stats->getNumericId();  // int64 is converted to int
-
-  int32_t i;
-
-  // Fetch new data
-  HostStatsFetchData();
-
-  if (ProcessObj) {
-    PPERF_INSTANCE_DEFINITION PerfInst;
-
-    if (ProcessObj->NumInstances > 0) {
-#if 0
-      static int32_t done = 0;
-      if (!done) {
-  done = 1;
-  PerfInst = FirstInstance(ProcessObj);
-  for (i=0; i < (int32_t)ProcessObj->NumInstances; i++) {
-    PPERF_COUNTER_BLOCK PerfCntrBlk;
-    PerfCntrBlk = (PPERF_COUNTER_BLOCK)((PBYTE)PerfInst +
-                PerfInst->ByteLength);
-    LOGDEBUG("HostStatHeleperWin: process: %s\n", getInstIdStr(PerfInst, "proc-"));
-    PerfInst = NextInstance(PerfCntrBlk);
-  }
-      }
-#endif
-      PerfInst = FirstInstance(ProcessObj);
-      for (i = 0; i < (int32_t)ProcessObj->NumInstances; i++) {
-        PPERF_COUNTER_BLOCK PerfCntrBlk;
-        PerfCntrBlk =
-            (PPERF_COUNTER_BLOCK)((PBYTE)PerfInst + PerfInst->ByteLength);
-
-        if (pid == getPid(pidCtrOffset, PerfCntrBlk)) {
-          stats->setInt(
-              winProcessStat->handlesINT,
-              getInt32Value(&processCtrCache[HANDLECOUNT_IDX], PerfCntrBlk));
-          stats->setInt(
-              winProcessStat->priorityBaseINT,
-              getInt32Value(&processCtrCache[PRIORITYBASE_IDX], PerfCntrBlk));
-          stats->setInt(
-              winProcessStat->threadsINT,
-              getInt32Value(&processCtrCache[THREADCOUNT_IDX], PerfCntrBlk));
-          stats->setLong(winProcessStat->activeTimeLONG,
-                         getInt64Value(&processCtrCache[PROCESSORTIME_IDX],
-                                       PerfCntrBlk, false));
-          stats->setLong(
-              winProcessStat->pageFaultsLONG,
-              getInt32Value(&processCtrCache[PAGEFAULTS_IDX], PerfCntrBlk));
-          stats->setLong(
-              winProcessStat->pageFileSizeLONG,
-              getInt64Value(&processCtrCache[PAGEFILEBYTES_IDX], PerfCntrBlk));
-          stats->setLong(winProcessStat->pageFileSizePeakLONG,
-                         getInt64Value(&processCtrCache[PAGEFILEBYTESPEAK_IDX],
-                                       PerfCntrBlk));
-          stats->setLong(
-              winProcessStat->privateSizeLONG,
-              getInt64Value(&processCtrCache[PRIVATEBYTES_IDX], PerfCntrBlk));
-          stats->setLong(
-              winProcessStat->systemTimeLONG,
-              getInt64Value(&processCtrCache[PRIVILEGEDTIME_IDX], PerfCntrBlk));
-          stats->setLong(
-              winProcessStat->userTimeLONG,
-              getInt64Value(&processCtrCache[USERTIME_IDX], PerfCntrBlk));
-          stats->setLong(
-              winProcessStat->virtualSizeLONG,
-              getInt64Value(&processCtrCache[VIRTUALBYTES_IDX], PerfCntrBlk));
-          stats->setLong(winProcessStat->virtualSizePeakLONG,
-                         getInt64Value(&processCtrCache[VIRTUALBYTESPEAK_IDX],
-                                       PerfCntrBlk));
-          stats->setLong(
-              winProcessStat->workingSetSizeLONG,
-              getInt64Value(&processCtrCache[WORKINGSET_IDX], PerfCntrBlk));
-          stats->setLong(
-              winProcessStat->workingSetSizePeakLONG,
-              getInt64Value(&processCtrCache[WORKINGSETPEAK_IDX], PerfCntrBlk));
-
-          int cpuUsage = calculateCpuUsage(PerfCntrBlk);
-          stats->setInt(winProcessStat->cpuUsageINT, cpuUsage);
-          return;
-        }  // if
-        PerfInst = NextInstance(PerfCntrBlk);
-      }  // for
-    } else {
-#ifdef FLG_DEBUG
-      LOGDEBUG("HostStatHeleperWin: unexpected 0 instances!\n");
-#endif
-    }  // else
-  }
-
-}  // refreshProcess
-
-static bool firstTime = true;
-// Formula for CPUUsage  =  ( X1 - X0 ) / ( Y1- Y0 )
-//  X = Value of PROCESSORTIME_ID Counter ( in 100 nsec unit )
-//  Y = Value of Sampling time ( in 100n sec unit )
-int HostStatHelperWin::calculateCpuUsage(PPERF_COUNTER_BLOCK& ctrBlk) {
-  static int64_t oldPerfTime100nSec = 0;
-  static int64_t oldProcessorTime = 0;
-  int32_t cpuUsage = 0;
-
-  int64_t newProcessorTime =
-      getInt64Value(&processCtrCache[PROCESSORTIME_IDX], ctrBlk, false);
-  int64_t newPerfTime100nSec = PerfData->PerfTime100nSec.QuadPart;
-
-  if (firstTime) {
-    firstTime = false;
-    oldProcessorTime = newProcessorTime;
-    oldPerfTime100nSec = newPerfTime100nSec;
-  } else {
-    int64_t pTimeDelta = newProcessorTime - oldProcessorTime;
-    int64_t delta100Sec = (newPerfTime100nSec - oldPerfTime100nSec);
-
-    oldProcessorTime = newProcessorTime;
-    oldPerfTime100nSec = newPerfTime100nSec;
-
-    double a = (double)pTimeDelta / (double)delta100Sec;
-    cpuUsage = (int)(a * 100);
-    cpuUsage = cpuUsage > 0 ? cpuUsage : 0;
-  }
-  return cpuUsage;
-}
-
-void HostStatHelperWin::closeHostStatHelperWin() {
-  if (PerfData) {
-    free((char*)PerfData);
-    PerfData = nullptr;
-  }
-  RegCloseKey(HKEY_PERFORMANCE_DATA);
-  firstTime = true;
-}
-
-#endif
diff --git a/cppcache/src/statistics/LinuxProcessStats.cpp b/cppcache/src/statistics/LinuxProcessStats.cpp
deleted file mode 100644
index 22a401b..0000000
--- a/cppcache/src/statistics/LinuxProcessStats.cpp
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <ace/Thread_Mutex.h>
-#include <ace/Singleton.h>
-
-#include <geode/internal/geode_globals.hpp>
-
-#include "LinuxProcessStats.hpp"
-#include "HostStatHelperLinux.hpp"
-#include "../Assert.hpp"
-#include "config.h"
-
-namespace apache {
-namespace geode {
-namespace statistics {
-
-LinuxProcessStats::LinuxProcessStats(GeodeStatisticsFactory* statFactory,
-                                     int64_t pid, const char* name) {
-  // Create Statistics Type
-  createType(statFactory);
-
-  // Create Statistics
-  this->stats = statFactory->createOsStatistics(m_statsType, name, pid);
-  GF_D_ASSERT(this->stats != nullptr);
-
-// Refresh Stats Values
-#if defined(_LINUX)
-  HostStatHelperLinux::refreshProcess(this);
-#endif  // if defined(_LINUX)
-}
-
-void LinuxProcessStats::createType(StatisticsFactory* statFactory) {
-  try {
-    StatisticDescriptor** statDescriptorArr = new StatisticDescriptor*[6];
-    statDescriptorArr[0] = statFactory->createIntGauge(
-        "imageSize", "The size of the process's image in megabytes.",
-        "megabytes");
-
-    statDescriptorArr[1] = statFactory->createIntGauge(
-        "rssSize", "The size of the process's resident set size in megabytes.",
-        "megabytes");
-
-    statDescriptorArr[2] = statFactory->createIntCounter(
-        "userTime", "The os statistic for the process cpu usage in user time",
-        "jiffies");
-
-    statDescriptorArr[3] = statFactory->createIntCounter(
-        "systemTime",
-        "The os statistic for the process cpu usage in system time", "jiffies");
-
-    statDescriptorArr[4] = statFactory->createIntGauge(
-        "hostCpuUsage", "The os statistic for the host cpu usage",
-        "percent cpu");
-
-    statDescriptorArr[5] = statFactory->createIntGauge(
-        "threads", "Number of threads currently active in this process.",
-        "threads");
-
-    try {
-      m_statsType = statFactory->createType("LinuxProcessStats",
-                                            "Statistics for a Linux process.",
-                                            statDescriptorArr, 6);
-    } catch (Exception&) {
-      m_statsType = statFactory->findType("LinuxProcessStats");
-    }
-    if (m_statsType == nullptr) {
-      throw OutOfMemoryException("LinuxProcessStats::createType: out memory");
-    }
-    imageSizeINT = m_statsType->nameToId("imageSize");
-    rssSizeINT = m_statsType->nameToId("rssSize");
-    userTimeINT = m_statsType->nameToId("userTime");
-    systemTimeINT = m_statsType->nameToId("systemTime");
-    hostCpuUsageINT = m_statsType->nameToId("hostCpuUsage");
-    threadsINT = m_statsType->nameToId("threads");
-  } catch (IllegalArgumentException&) {
-    GF_D_ASSERT(false);
-    throw;
-  }
-}
-
-int64_t LinuxProcessStats::getProcessSize() {
-  return static_cast<int64_t>(stats->getInt(rssSizeINT));
-}
-
-int32_t LinuxProcessStats::getCpuUsage() {
-  return stats->getInt(hostCpuUsageINT);
-}
-
-int64_t LinuxProcessStats::getCPUTime() { return stats->getInt(userTimeINT); }
-
-int32_t LinuxProcessStats::getNumThreads() { return stats->getInt(threadsINT); }
-
-int64_t LinuxProcessStats::getAllCpuTime() {
-  return ((stats->getInt(userTimeINT)) + (stats->getInt(systemTimeINT)));
-}
-
-void LinuxProcessStats::close() {
-  if (stats != nullptr) {
-    stats->close();
-  }
-}
-
-LinuxProcessStats::~LinuxProcessStats() {
-  m_statsType = nullptr;
-  stats = nullptr;
-}
-
-}  // namespace statistics
-}  // namespace geode
-}  // namespace apache
diff --git a/cppcache/src/statistics/LinuxProcessStats.hpp b/cppcache/src/statistics/LinuxProcessStats.hpp
deleted file mode 100644
index 1900623..0000000
--- a/cppcache/src/statistics/LinuxProcessStats.hpp
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#pragma once
-
-#ifndef GEODE_STATISTICS_LINUXPROCESSSTATS_H_
-#define GEODE_STATISTICS_LINUXPROCESSSTATS_H_
-
-#include <geode/internal/geode_globals.hpp>
-
-#include "Statistics.hpp"
-#include "StatisticsType.hpp"
-#include "StatisticDescriptor.hpp"
-#include "ProcessStats.hpp"
-#include "HostStatHelper.hpp"
-#include "GeodeStatisticsFactory.hpp"
-#include "config.h"
-
-using namespace apache::geode::client;
-
-/** @file
- */
-
-namespace apache {
-namespace geode {
-namespace statistics {
-/**
- * <P>This class provides the interface for statistics about a
- * Linux operating system process that is using a Geode system.
- *
- */
-
-class _GEODE_EXPORT LinuxProcessStats : public ProcessStats {
- private:
-  /** The Static Type for Linux Process Stats */
-  StatisticsType* m_statsType;
-
-  /** Ids of All Stats Desciptors for seting new values */
-  int32_t rssSizeINT;
-  int32_t imageSizeINT;
-  int32_t userTimeINT;
-  int32_t systemTimeINT;
-  int32_t hostCpuUsageINT;
-  int32_t threadsINT;
-
-  /** The underlying statistics */
-  Statistics* stats;
-
-  void createType(StatisticsFactory* statFactory);
-
- public:
-  LinuxProcessStats(GeodeStatisticsFactory* statFactory, int64_t pid,
-                    const char* name);
-  ~LinuxProcessStats();
-
-  int64_t getProcessSize();
-  int32_t getCpuUsage();
-  int32_t getNumThreads();
-  int64_t getCPUTime();
-  int64_t getAllCpuTime();
-  /**
-   * Close Underline Statistics
-   */
-  void close();
-
-#if defined(_LINUX)
-  friend class HostStatHelperLinux;
-#endif  // if defined(_LINUX)
-
-};  // Class LinuxProcessStats
-
-}  // namespace statistics
-}  // namespace geode
-}  // namespace apache
-
-#endif  // GEODE_STATISTICS_LINUXPROCESSSTATS_H_
diff --git a/cppcache/src/statistics/SolarisProcessStats.cpp b/cppcache/src/statistics/SolarisProcessStats.cpp
deleted file mode 100644
index d6e4457..0000000
--- a/cppcache/src/statistics/SolarisProcessStats.cpp
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <ace/Thread_Mutex.h>
-#include <ace/Singleton.h>
-
-#include <geode/internal/geode_globals.hpp>
-
-#include "SolarisProcessStats.hpp"
-#include "HostStatHelperSolaris.hpp"
-#include "../Assert.hpp"
-#include "config.h"
-
-namespace apache {
-namespace geode {
-namespace statistics {
-
-SolarisProcessStats::SolarisProcessStats(GeodeStatisticsFactory* statFactory,
-                                         int64_t pid, const char* name) {
-  // Create Statistics Type
-  createType(statFactory);
-
-  // Create Statistics
-  this->stats = statFactory->createOsStatistics(m_statsType, name, pid);
-  GF_D_ASSERT(this->stats != nullptr);
-
-// Refresh Stats Values
-#if defined(_SOLARIS)
-  HostStatHelperSolaris::refreshProcess(this);
-#endif  // if def(_SOLARIS)
-}
-
-void SolarisProcessStats::createType(StatisticsFactory* statFactory) {
-  try {
-    StatisticDescriptor** statDescriptorArr = new StatisticDescriptor*[7];
-    statDescriptorArr[0] = statFactory->createIntGauge(
-        "imageSize", "The size of the process's image in megabytes.",
-        "megabytes");
-
-    statDescriptorArr[1] = statFactory->createIntGauge(
-        "rssSize", "The size of the process's resident set size in megabytes.",
-        "megabytes");
-
-    statDescriptorArr[2] = statFactory->createIntCounter(
-        "userTime", "The os statistic for the process cpu usage in user time",
-        "microseconds");
-
-    statDescriptorArr[3] = statFactory->createIntCounter(
-        "systemTime",
-        "The os statistic for the process cpu usage in system time",
-        "microseconds");
-
-    statDescriptorArr[4] = statFactory->createIntGauge(
-        "processCpuUsage", "The os statistic for the cpu usage of this process",
-        "percent cpu");
-
-    statDescriptorArr[5] = statFactory->createIntGauge(
-        "hostCpuUsage", "The os statistic for the host cpu usage",
-        "percent cpu");
-
-    statDescriptorArr[6] = statFactory->createIntGauge(
-        "threads", "Number of threads currently active in this process.",
-        "threads");
-
-    try {
-      m_statsType = statFactory->createType("SolarisProcessStats",
-                                            "Statistics for a Solaris process.",
-                                            statDescriptorArr, 7);
-    } catch (Exception&) {
-      m_statsType = statFactory->findType("SolarisProcessStats");
-    }
-    if (m_statsType == nullptr) {
-      throw OutOfMemoryException("SolarisProcessStats::createType: out memory");
-    }
-    imageSizeINT = m_statsType->nameToId("imageSize");
-    rssSizeINT = m_statsType->nameToId("rssSize");
-    userTimeINT = m_statsType->nameToId("userTime");
-    systemTimeINT = m_statsType->nameToId("systemTime");
-    processCpuUsageINT = m_statsType->nameToId("processCpuUsage");
-    hostCpuUsageINT = m_statsType->nameToId("hostCpuUsage");
-    threadsINT = m_statsType->nameToId("threads");
-  } catch (IllegalArgumentException&) {
-    GF_D_ASSERT(false);
-    throw;
-  }
-}
-
-int64_t SolarisProcessStats::getProcessSize() {
-  return static_cast<int64_t>(stats->getInt(rssSizeINT));
-}
-
-int32_t SolarisProcessStats::getCpuUsage() {
-  return stats->getInt(hostCpuUsageINT);
-}
-
-int64_t SolarisProcessStats::getCPUTime() { return stats->getInt(userTimeINT); }
-
-int32_t SolarisProcessStats::getNumThreads() {
-  return stats->getInt(threadsINT);
-}
-
-int64_t SolarisProcessStats::getAllCpuTime() {
-  return ((stats->getInt(userTimeINT)) + (stats->getInt(systemTimeINT)));
-}
-
-void SolarisProcessStats::close() {
-  if (stats != nullptr) {
-    stats->close();
-  }
-}
-
-SolarisProcessStats::~SolarisProcessStats() {
-  m_statsType = nullptr;
-  stats = nullptr;
-}
-
-}  // namespace statistics
-}  // namespace geode
-}  // namespace apache
diff --git a/cppcache/src/statistics/SolarisProcessStats.hpp b/cppcache/src/statistics/SolarisProcessStats.hpp
deleted file mode 100644
index b023fca..0000000
--- a/cppcache/src/statistics/SolarisProcessStats.hpp
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#pragma once
-
-#ifndef GEODE_STATISTICS_SOLARISPROCESSSTATS_H_
-#define GEODE_STATISTICS_SOLARISPROCESSSTATS_H_
-
-#include <geode/internal/geode_globals.hpp>
-
-#include "Statistics.hpp"
-#include "StatisticsType.hpp"
-#include "StatisticDescriptor.hpp"
-#include "ProcessStats.hpp"
-#include "HostStatHelper.hpp"
-#include "GeodeStatisticsFactory.hpp"
-#include "config.h"
-
-/** @file
- */
-
-namespace apache {
-namespace geode {
-namespace statistics {
-
-using namespace apache::geode::client;
-
-/**
- * <P>This class provides the interface for statistics about a
- * Solaris operating system process that is using a Geode system.
- *
- */
-class _GEODE_EXPORT SolarisProcessStats : public ProcessStats {
- private:
-  /** The Static Type for Solaris Process Stats */
-  StatisticsType* m_statsType;
-
-  /** Ids of All Stats Desciptors for seting new values */
-  int32_t rssSizeINT;
-  int32_t imageSizeINT;
-  int32_t userTimeINT;
-  int32_t systemTimeINT;
-  int32_t processCpuUsageINT;
-  int32_t hostCpuUsageINT;
-  int32_t threadsINT;
-
-  /** The underlying statistics */
-  Statistics* stats;
-
-  void createType(StatisticsFactory* statFactory);
-
- public:
-  SolarisProcessStats(GeodeStatisticsFactory* statisticsFactory, int64_t pid,
-                      const char* name);
-  ~SolarisProcessStats();
-
-  int64_t getProcessSize();
-  int32_t getCpuUsage();
-  int64_t getCPUTime();
-  int32_t getNumThreads();
-  int64_t getAllCpuTime();
-
-  /**
-   * Close Underline Statistics
-   */
-  void close();
-
-#if defined(_SOLARIS)
-  friend class HostStatHelperSolaris;
-#endif  // if def(_SOLARIS)
-
-};  // Class SolarisProcessStats
-
-}  // namespace statistics
-}  // namespace geode
-}  // namespace apache
-
-#endif  // GEODE_STATISTICS_SOLARISPROCESSSTATS_H_
diff --git a/cppcache/src/statistics/WindowsProcessStats.cpp b/cppcache/src/statistics/WindowsProcessStats.cpp
deleted file mode 100644
index f6d999f..0000000
--- a/cppcache/src/statistics/WindowsProcessStats.cpp
+++ /dev/null
@@ -1,242 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <ace/Thread_Mutex.h>
-#include <ace/Singleton.h>
-
-#include <geode/internal/geode_globals.hpp>
-
-#include "WindowsProcessStats.hpp"
-#include "HostStatHelperWin.hpp"
-#include "HostStatHelper.hpp"
-#include "../Assert.hpp"
-
-namespace apache {
-namespace geode {
-namespace statistics {
-
-WindowsProcessStats::WindowsProcessStats(
-    GeodeStatisticsFactory* statisticsFactory, int64_t pid, const char* name) {
-  // Create for Statistics Type
-  createType(statisticsFactory);
-
-  // Create Statistics
-  this->stats = statisticsFactory->createOsStatistics(m_statsType, name, pid);
-  GF_D_ASSERT(this->stats != nullptr);
-
-// Refresh Stats Values
-#if defined(_WIN32)
-  HostStatHelperWin::initHostStatHelperWin();
-  HostStatHelperWin::refreshProcess(this);
-#endif
-}
-
-void WindowsProcessStats::createType(StatisticsFactory* statFactory) {
-  StatisticDescriptor** statDescriptorArr = new StatisticDescriptor*[15];
-  statDescriptorArr[0] = statFactory->createIntGauge(
-      "handles",
-      "The total number of handles currently open by this process. This number "
-      "is the sum of the handles currently open by each thread in this "
-      "process.",
-      "items");
-  statDescriptorArr[1] = statFactory->createIntGauge(
-      "priorityBase",
-      "The current base priority of the process. Threads within a process can "
-      "raise and lower their own base priority relative to the process's base "
-      "priority",
-      "priority");
-  statDescriptorArr[2] = statFactory->createIntGauge(
-      "threads",
-      "Number of threads currently active in this process. An instruction is "
-      "the basic unit of execution in a processor, and a thread is the object "
-      "that executes instructions. Every running process has at least one "
-      "thread.",
-      "threads");
-
-  statDescriptorArr[3] = statFactory->createLongCounter(
-      "activeTime",
-      "The elapsed time in milliseconds that all of the threads of this "
-      "process used the processor to execute instructions. An instruction is "
-      "the basic unit of execution in a computer, a thread is the object that "
-      "executes instructions, and a process is the object created when a "
-      "program is run. Code executed to handle some hardware interrupts and "
-      "trap conditions are included in this count.",
-      "milliseconds", false);
-
-  statDescriptorArr[4] = statFactory->createLongCounter(
-      "pageFaults",
-      "The total number of Page Faults by the threads executing in this "
-      "process. A page fault occurs when a thread refers to a virtual memory "
-      "page that is not in its working set in main memory. This will not cause "
-      "the page to be fetched from disk if it is on the standby list and hence "
-      "already in main memory, or if it is in use by another process with whom "
-      "the page is shared.",
-      "operations", false);
-  statDescriptorArr[5] = statFactory->createLongGauge(
-      "pageFileSize",
-      "The current number of bytes this process has used in the paging "
-      "file(s). Paging files are used to store pages of memory used by the "
-      "process that are not contained in other files. Paging files are shared "
-      "by all processes, and lack of space in paging files can prevent other "
-      "processes from allocating memory.",
-      "bytes");
-  statDescriptorArr[6] = statFactory->createLongGauge(
-      "pageFileSizePeak",
-      "The maximum number of bytes this process has used in the paging "
-      "file(s). Paging files are used to store pages of memory used by the "
-      "process that are not contained in other files. Paging files are shared "
-      "by all processes, and lack of space in paging files can prevent other "
-      "processes from allocating memory.",
-      "bytes");
-  statDescriptorArr[7] = statFactory->createLongGauge(
-      "privateSize",
-      "The current number of bytes this process has allocated that cannot be "
-      "shared with other processes.",
-      "bytes");
-  statDescriptorArr[8] = statFactory->createLongCounter(
-      "systemTime",
-      "The elapsed time in milliseconds that the threads of the process have "
-      "spent executing code in privileged mode. When a Windows system service "
-      "is called, the service will often run in Privileged Mode to gain access "
-      "to system-private data. Such data is protected from access by threads "
-      "executing in user mode. Calls to the system can be explicit or "
-      "implicit, such as page faults or interrupts. Unlike some early "
-      "operating systems, Windows uses process boundaries for subsystem "
-      "protection in addition to the traditional protection of user and "
-      "privileged modes. These subsystem processes provide additional "
-      "protection. Therefore, some work done by Windows on behalf of your "
-      "application might appear in other subsystem processes in addition to "
-      "the privileged time in your process.",
-      "milliseconds", false);
-  statDescriptorArr[9] = statFactory->createLongCounter(
-      "userTime",
-      "The elapsed time in milliseconds that this process's threads have spent "
-      "executing code in user mode. Applications, environment subsystems, and "
-      "integral subsystems execute in user mode. Code executing in User Mode "
-      "cannot damage the integrity of the Windows Executive, Kernel, and "
-      "device drivers. Unlike some early operating systems, Windows uses "
-      "process boundaries for subsystem protection in addition to the "
-      "traditional protection of user and privileged modes. These subsystem "
-      "processes provide additional protection. Therefore, some work done by "
-      "Windows on behalf of your application might appear in other subsystem "
-      "processes in addition to the privileged time in your process.",
-      "milliseconds", false);
-  statDescriptorArr[10] = statFactory->createLongGauge(
-      "virtualSize",
-      "Virtual Bytes is the current size in bytes of the virtual address space "
-      "the process is using. Use of virtual address space does not necessarily "
-      "imply corresponding use of either disk or main memory pages. Virtual "
-      "space is finite, and by using too much, the process can limit its "
-      "ability to load libraries.",
-      "bytes");
-  statDescriptorArr[11] = statFactory->createLongGauge(
-      "virtualSizePeak",
-      "The maximum number of bytes of virtual address space the process has "
-      "used at any one time. Use of virtual address space does not necessarily "
-      "imply corresponding use of either disk or main memory pages. Virtual "
-      "space is however finite, and by using too much, the process might limit "
-      "its ability to load libraries.",
-      "bytes");
-  statDescriptorArr[12] = statFactory->createLongGauge(
-      "workingSetSize",
-      "The current number of bytes in the Working Set of this process. The "
-      "Working Set is the set of memory pages touched recently by the threads "
-      "in the process. If free memory in the computer is above a threshold, "
-      "pages are left in the Working Set of a process even if they are not in "
-      "use. When free memory falls below a threshold, pages are trimmed from "
-      "Working Sets. If they are needed they will then be soft-faulted back "
-      "into the Working Set before they are paged out out to disk.",
-      "bytes");
-  statDescriptorArr[13] = statFactory->createLongGauge(
-      "workingSetSizePeak",
-      "The maximum number of bytes in the Working Set of this process at any "
-      "point in time. The Working Set is the set of memory pages touched "
-      "recently by the threads in the process. If free memory in the computer "
-      "is above a threshold, pages are left in the Working Set of a process "
-      "even if they are not in use. When free memory falls below a threshold, "
-      "pages are trimmed from Working Sets. If they are needed they will then "
-      "be soft-faulted back into the Working Set before they leave main "
-      "memory.",
-      "bytes");
-
-  statDescriptorArr[14] = statFactory->createIntGauge(
-      "cpuUsage", "Percentage cpu used by this process", "%");
-
-  try {
-    m_statsType = statFactory->createType(
-        "WindowsProcessStats", "Statistics for a Microsoft Windows process.",
-        statDescriptorArr, 15);
-  } catch (Exception&) {
-    m_statsType = statFactory->findType("WindowsProcessStats");
-  }
-
-  if (m_statsType == nullptr) {
-    throw OutOfMemoryException("WindowsProcessStats::createType: out memory");
-  }
-
-  handlesINT = m_statsType->nameToId("handles");
-  priorityBaseINT = m_statsType->nameToId("priorityBase");
-  threadsINT = m_statsType->nameToId("threads");
-  activeTimeLONG = m_statsType->nameToId("activeTime");
-  pageFaultsLONG = m_statsType->nameToId("pageFaults");
-  pageFileSizeLONG = m_statsType->nameToId("pageFileSize");
-  pageFileSizePeakLONG = m_statsType->nameToId("pageFileSizePeak");
-
-  privateSizeLONG = m_statsType->nameToId("privateSize");
-  systemTimeLONG = m_statsType->nameToId("systemTime");
-  userTimeLONG = m_statsType->nameToId("userTime");
-  virtualSizeLONG = m_statsType->nameToId("virtualSize");
-  virtualSizePeakLONG = m_statsType->nameToId("virtualSizePeak");
-  workingSetSizeLONG = m_statsType->nameToId("workingSetSize");
-  workingSetSizePeakLONG = m_statsType->nameToId("workingSetSizePeak");
-  cpuUsageINT = m_statsType->nameToId("cpuUsage");
-}
-
-int64_t WindowsProcessStats::getProcessSize() {
-  return stats->getLong(cpuUsageINT);
-}
-
-int32_t WindowsProcessStats::getCpuUsage() {
-  // throw UnsupportedOperationException( "getCpuUsage is unsupported on
-  // Windows." );
-  return stats->getInt(activeTimeLONG);
-}
-
-int64_t WindowsProcessStats::getCPUTime() {
-  return stats->getLong(activeTimeLONG);
-}
-int32_t WindowsProcessStats::getNumThreads() {
-  return stats->getInt(threadsINT);
-}
-int64_t WindowsProcessStats::getAllCpuTime() {
-  return ((stats->getLong(userTimeLONG)) + (stats->getLong(systemTimeLONG)));
-}
-
-void WindowsProcessStats::close() {
-  if (stats != nullptr) {
-    stats->close();
-  }
-}
-
-WindowsProcessStats::~WindowsProcessStats() {
-  m_statsType = nullptr;
-  stats = nullptr;
-}
-
-}  // namespace statistics
-}  // namespace geode
-}  // namespace apache
diff --git a/cppcache/src/statistics/WindowsProcessStats.hpp b/cppcache/src/statistics/WindowsProcessStats.hpp
deleted file mode 100644
index 61a577a..0000000
--- a/cppcache/src/statistics/WindowsProcessStats.hpp
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#pragma once
-
-#ifndef GEODE_STATISTICS_WINDOWSPROCESSSTATS_H_
-#define GEODE_STATISTICS_WINDOWSPROCESSSTATS_H_
-
-#include <geode/internal/geode_globals.hpp>
-#include <geode/ExceptionTypes.hpp>
-
-#include "Statistics.hpp"
-#include "StatisticsType.hpp"
-#include "StatisticDescriptor.hpp"
-#include "StatisticsFactory.hpp"
-#include "ProcessStats.hpp"
-#include "GeodeStatisticsFactory.hpp"
-
-/** @file
- */
-
-namespace apache {
-namespace geode {
-namespace statistics {
-
-using namespace apache::geode::client;
-
-/**
- * <P>This class provides the interface for statistics about a
- * Windows operating system process that is using a Geode system.
- */
-class _GEODE_EXPORT WindowsProcessStats : public ProcessStats {
- private:
-  /** The Static Type for Windows Process Stats */
-  StatisticsType* m_statsType;
-
-  /** Ids of All Stats Desciptors for seting new values */
-  int32_t handlesINT;
-  int32_t priorityBaseINT;
-  int32_t threadsINT;
-  int32_t activeTimeLONG;
-  int32_t pageFaultsLONG;
-  int32_t pageFileSizeLONG;
-  int32_t pageFileSizePeakLONG;
-  int32_t privateSizeLONG;
-  int32_t systemTimeLONG;
-  int32_t userTimeLONG;
-  int32_t virtualSizeLONG;
-  int32_t virtualSizePeakLONG;
-  int32_t workingSetSizeLONG;
-  int32_t workingSetSizePeakLONG;
-  int32_t cpuUsageINT;
-
-  /** The underlying statistics */
-  Statistics* stats;
-
-  void createType(StatisticsFactory* statFactory);
-
- public:
-  WindowsProcessStats(GeodeStatisticsFactory* statisticsFactory, int64_t pid,
-                      const char* name);
-  ~WindowsProcessStats();
-
-  int64_t getProcessSize();
-  int32_t getCpuUsage();
-  int64_t getCPUTime();
-  int32_t getNumThreads();
-  int64_t getAllCpuTime();
-  /**
-   * Close Underline Statistics
-   */
-  void close();
-
-  friend class HostStatHelperWin;
-};
-}  // namespace statistics
-}  // namespace geode
-}  // namespace apache
-
-#endif  // GEODE_STATISTICS_WINDOWSPROCESSSTATS_H_

-- 
To stop receiving notification emails like this one, please contact
echobravo@apache.org.

Mime
View raw message