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:20 UTC

[geode-native] branch wip/no-ace-headers created (now 1925595)

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

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


      at 1925595  GEODE-2484: Removes uname functions

This branch includes the following new commits:

     new 9a7a05f  GEODE-2484: Removes time functions
     new 1925595  GEODE-2484: Removes uname functions

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



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

Posted by jb...@apache.org.
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 9a7a05f2331b3a5312e3c6b79e605f66cf7380eb
Author: Jacob Barrett <jb...@pivotal.io>
AuthorDate: Thu Jun 6 12:48:06 2019 -0700

    GEODE-2484: Removes time functions
    
    * Replaces with Boost Date Time library.
---
 cppcache/src/statistics/StatArchiveWriter.cpp | 48 ++++++++++++++++-----------
 1 file changed, 28 insertions(+), 20 deletions(-)

diff --git a/cppcache/src/statistics/StatArchiveWriter.cpp b/cppcache/src/statistics/StatArchiveWriter.cpp
index d3362e7..0140045 100644
--- a/cppcache/src/statistics/StatArchiveWriter.cpp
+++ b/cppcache/src/statistics/StatArchiveWriter.cpp
@@ -19,13 +19,11 @@
 
 #include <chrono>
 #include <ctime>
+#include <sstream>
 
-#include <ace/ACE.h>
-#include <ace/OS_NS_sys_time.h>
 #include <ace/OS_NS_sys_utsname.h>
-#include <ace/OS_NS_time.h>
-#include <ace/Task.h>
-#include <ace/Thread_Mutex.h>
+#include <boost/date_time.hpp>
+#include <boost/date_time/c_local_time_adjustor.hpp>
 
 #include <geode/internal/geode_globals.hpp>
 
@@ -312,6 +310,27 @@ void ResourceInst::writeResourceInst(StatDataOutput *dataOutArg,
   }
 }
 
+std::chrono::milliseconds getTimeZoneOffset() {
+  using boost::date_time::c_local_adjustor;
+  using boost::posix_time::ptime;
+  using boost::posix_time::second_clock;
+  using std::chrono::milliseconds;
+
+  const auto utc = second_clock::universal_time();
+  const auto local = c_local_adjustor<decltype(utc)>::utc_to_local(utc);
+
+  return milliseconds((local - utc).total_milliseconds());
+}
+
+std::string getTimeZoneName() {
+  const auto now = std::chrono::system_clock::now();
+  const auto tm_val = apache::geode::util::chrono::localtime(now);
+
+  std::stringstream buf;
+  buf << std::put_time(&tm_val, "%Z");
+  return buf.str();
+}
+
 // Constructor and Member functions of StatArchiveWriter class
 StatArchiveWriter::StatArchiveWriter(std::string outfile,
                                      HostStatSampler *samplerArg,
@@ -319,13 +338,9 @@ StatArchiveWriter::StatArchiveWriter(std::string outfile,
     : cache(cache) {
   resourceTypeId = 0;
   resourceInstId = 0;
-  statResourcesModCount = 0;
   archiveFile = outfile;
   bytesWrittenToFile = 0;
 
-  /* adongre
-   * CID 28982: Uninitialized scalar field (UNINIT_CTOR)
-   */
   m_samplesize = 0;
 
   dataBuffer = new StatDataOutput(archiveFile, cache);
@@ -345,17 +360,10 @@ StatArchiveWriter::StatArchiveWriter(std::string outfile,
       duration_cast<milliseconds>(
           sampler->getSystemStartTime().time_since_epoch())
           .count());
-  int32_t tzOffset = ACE_OS::timezone();
-  // offset in milli seconds
-  tzOffset = tzOffset * -1 * 1000;
-  this->dataBuffer->writeInt(tzOffset);
-
-  auto now = std::chrono::system_clock::now();
-  auto tm_val = apache::geode::util::chrono::localtime(now);
-  char buf[512] = {0};
-  std::strftime(buf, sizeof(buf), "%Z", &tm_val);
-  std::string tzId(buf);
-  this->dataBuffer->writeUTF(tzId);
+
+  this->dataBuffer->writeInt(
+      duration_cast<milliseconds>(getTimeZoneOffset()).count());
+  this->dataBuffer->writeUTF(getTimeZoneName());
 
   std::string sysDirPath = sampler->getSystemDirectoryPath();
   this->dataBuffer->writeUTF(sysDirPath);


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

Posted by jb...@apache.org.
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();