You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by jb...@apache.org on 2019/06/06 21:01:22 UTC

[geode-native] 02/02: GEODE-2484: Removes uname functions

This is an automated email from the ASF dual-hosted git repository.

jbarrett pushed a commit to branch wip/no-ace-headers
in repository https://gitbox.apache.org/repos/asf/geode-native.git

commit 192559575cd2c73c4ecefff92d5ff2e134a57c9f
Author: Jacob Barrett <jb...@pivotal.io>
AuthorDate: Thu Jun 6 14:01:07 2019 -0700

    GEODE-2484: Removes uname functions
    
    * Replaces uname with macros and boost.
---
 cppcache/src/config.h.in                      |  3 +++
 cppcache/src/statistics/StatArchiveWriter.cpp | 32 +++++++++------------------
 2 files changed, 13 insertions(+), 22 deletions(-)

diff --git a/cppcache/src/config.h.in b/cppcache/src/config.h.in
index c2a283f..f29d506 100644
--- a/cppcache/src/config.h.in
+++ b/cppcache/src/config.h.in
@@ -55,4 +55,7 @@
 #define ACE_Thread_NULL 0
 #endif
 
+#define GEODE_SYSTEM_NAME "@CMAKE_SYSTEM_NAME@"
+#define GEODE_SYSTEM_PROCESSOR "@CMAKE_SYSTEM_PROCESSOR@"
+
 #endif  // GEODE_CONFIG_H_
diff --git a/cppcache/src/statistics/StatArchiveWriter.cpp b/cppcache/src/statistics/StatArchiveWriter.cpp
index 0140045..e98df9e 100644
--- a/cppcache/src/statistics/StatArchiveWriter.cpp
+++ b/cppcache/src/statistics/StatArchiveWriter.cpp
@@ -21,7 +21,7 @@
 #include <ctime>
 #include <sstream>
 
-#include <ace/OS_NS_sys_utsname.h>
+#include <boost/asio/ip/host_name.hpp>
 #include <boost/date_time.hpp>
 #include <boost/date_time/c_local_time_adjustor.hpp>
 
@@ -31,6 +31,7 @@
 #include "../util/chrono/time_point.hpp"
 #include "GeodeStatisticsFactory.hpp"
 #include "HostStatSampler.hpp"
+#include "config.h"
 
 namespace apache {
 namespace geode {
@@ -331,6 +332,8 @@ std::string getTimeZoneName() {
   return buf.str();
 }
 
+std::string getHostName() { return boost::asio::ip::host_name(); }
+
 // Constructor and Member functions of StatArchiveWriter class
 StatArchiveWriter::StatArchiveWriter(std::string outfile,
                                      HostStatSampler *samplerArg,
@@ -354,8 +357,7 @@ StatArchiveWriter::StatArchiveWriter(std::string outfile,
   this->dataBuffer->writeLong(
       duration_cast<milliseconds>(system_clock::now().time_since_epoch())
           .count());
-  int64_t sysId = sampler->getSystemId();
-  this->dataBuffer->writeLong(sysId);
+  this->dataBuffer->writeLong(sampler->getSystemId());
   this->dataBuffer->writeLong(
       duration_cast<milliseconds>(
           sampler->getSystemStartTime().time_since_epoch())
@@ -365,26 +367,12 @@ StatArchiveWriter::StatArchiveWriter(std::string outfile,
       duration_cast<milliseconds>(getTimeZoneOffset()).count());
   this->dataBuffer->writeUTF(getTimeZoneName());
 
-  std::string sysDirPath = sampler->getSystemDirectoryPath();
-  this->dataBuffer->writeUTF(sysDirPath);
-  std::string prodDesc = sampler->getProductDescription();
-
-  this->dataBuffer->writeUTF(prodDesc);
-  ACE_utsname u;
-  ACE_OS::uname(&u);
-  std::string os(u.sysname);
-  os += " ";
-  /* This version name returns date of release of the version which
-   creates confusion about the creation time of the vsd file. Hence
-   removing it now. Later I'll change it to just show version without
-   date. For now only name of the OS will be displayed.
-   */
-  // os += u.version;
-
-  this->dataBuffer->writeUTF(os);
-  std::string machineInfo(u.machine);
+  this->dataBuffer->writeUTF(sampler->getSystemDirectoryPath());
+  this->dataBuffer->writeUTF(sampler->getProductDescription());
+  this->dataBuffer->writeUTF(GEODE_SYSTEM_NAME);
+  std::string machineInfo(GEODE_SYSTEM_PROCESSOR);
   machineInfo += " ";
-  machineInfo += u.nodename;
+  machineInfo += getHostName();
   this->dataBuffer->writeUTF(machineInfo);
 
   resampleResources();