You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@geode.apache.org by GitBox <gi...@apache.org> on 2021/04/29 13:24:52 UTC

[GitHub] [geode-native] gaussianrecurrence opened a new pull request #797: GEODE-9214: Remove ACE time library references

gaussianrecurrence opened a new pull request #797:
URL: https://github.com/apache/geode-native/pull/797


    - Replaced all references to ACE time library by boost/STL functions.
    - Also replaced old ITs logging function implementation so it doesn't
      use ACE.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [geode-native] pivotal-jbarrett commented on a change in pull request #797: GEODE-9214: Remove ACE time library references

Posted by GitBox <gi...@apache.org>.
pivotal-jbarrett commented on a change in pull request #797:
URL: https://github.com/apache/geode-native/pull/797#discussion_r624283170



##########
File path: tests/cpp/fwklib/FwkLog.cpp
##########
@@ -54,32 +55,24 @@ const char* dirAndFile(const char* str) {
 }
 
 void plog(const char* l, const char* s, const char* filename, int32_t lineno) {

Review comment:
       If it simlifies things, the only callers to this method are macros that are converting a `std::ostringstream` to a `char *` so you could just pass a `std::ostringstream &` or `const std::string &` here.
   
   ```c++
   void plog(const std::string& level,  const std::string& message, const std::string& filename, size_t lineNumber);
   ```

##########
File path: tests/cpp/fwklib/FwkLog.cpp
##########
@@ -54,32 +55,24 @@ const char* dirAndFile(const char* str) {
 }
 
 void plog(const char* l, const char* s, const char* filename, int32_t lineno) {
-  // ACE_TCHAR tstamp[64];
-  // ACE::timestamp( tstamp, 64, 1 );
-  // tstamp is like "Tue May 17 2005 12:54:22.546780"
-  // for our purpose we just want "12:54:22.546780"
-  char buf[256] = {0};
-  const size_t MINBUFSIZE = 128;
-  ACE_Time_Value clock = ACE_OS::gettimeofday();
-  time_t secs = clock.sec();
-  struct tm* tm_val = ACE_OS::localtime(&secs);
-  char* pbuf = buf;
-  pbuf += ACE_OS::strftime(pbuf, MINBUFSIZE, "%Y/%m/%d %H:%M:%S", tm_val);
-  pbuf += ACE_OS::snprintf(pbuf, 15, ".%06" PRId64 " ",
-                           static_cast<int64_t>(clock.usec()));
-  ACE_OS::strftime(pbuf, MINBUFSIZE, "%Z ", tm_val);
-  static bool needInit = true;
-  if (needInit) {
-    ACE_OS::uname(&u);
-    needInit = false;
-  }
+  using std::chrono::duration_cast;
+  using std::chrono::microseconds;
+  using std::chrono::system_clock;
 
-  const char* fil = dirAndFile(filename);
+  auto now = system_clock::now();
+  auto in_time_t = system_clock::to_time_t(now);
+  auto localtime = std::localtime(&in_time_t);
+  auto usec =
+      duration_cast<microseconds>(now.time_since_epoch()).count() % 1000;
 
-  fprintf(stdout, "[%s %s %s:P%d:T%" PRIu64 "]::%s::%d  %s  %s\n", buf,
-          u.sysname, u.nodename, ACE_OS::getpid(),
-          hacks::aceThreadId(ACE_OS::thr_self()), fil, lineno, l, s);
-  fflush(stdout);
+  const char* fil = dirAndFile(filename);
+  std::cout << '[' << std::put_time(localtime, "%Y/%m/%d %H:%M:%S") << '.'
+            << std::setfill('0') << std::setw(6) << usec << std::setw(0)
+            << std::put_time(localtime, " %Z ") << boost::asio::ip::host_name()

Review comment:
       If it simplifies anything to drop the hostname, change the formatting, and/or switch to boost::log like the new test framework I don't think it will matter any.
   
   The old framework used to support running the child processes remotely, so logging the hostnames was useful in debugging. It can't run remotely anymore so hostname Is not so useful.
   
   I don't think anyone is tied to the log format either.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [geode-native] pivotal-jbarrett commented on a change in pull request #797: GEODE-9214: Remove ACE time library references

Posted by GitBox <gi...@apache.org>.
pivotal-jbarrett commented on a change in pull request #797:
URL: https://github.com/apache/geode-native/pull/797#discussion_r625870077



##########
File path: cppcache/integration-test/fw_dunit.cpp
##########
@@ -688,36 +680,63 @@ void sleep(int millis) {
 }
 
 void logCoordinator(std::string s, int lineno, const char * /*filename*/) {
-  char buf[128] = {0};
-  dunit::getTimeStr(buf, sizeof(buf));
-
-  fprintf(stdout, "[TEST coordinator:pid(%d)] %s at line: %d\n",
-          boost::this_process::get_id(), s.c_str(), lineno);
-  fflush(stdout);
+  using std::chrono::duration_cast;
+  using std::chrono::microseconds;
+  using std::chrono::system_clock;
+
+  auto now = system_clock::now();
+  auto in_time_t = system_clock::to_time_t(now);
+  auto localtime = std::localtime(&in_time_t);
+  auto usec =
+      duration_cast<microseconds>(now.time_since_epoch()).count() % 1000;
+
+  std::cout << "[TEST " << std::put_time(localtime, "%Y/%m/%d %H:%M:%S") << '.'
+            << std::setfill('0') << std::setw(6) << usec << std::setw(0)
+            << " coordinator:pid(" << boost::this_process::get_id() << ")] "
+            << s << " at line: " << lineno << std::endl
+            << std::flush;
 }
 
 // log a message and print the worker id as well.. used by fw_helper with no
 // worker id.
 void log(std::string s, int lineno, const char * /*filename*/, int /*id*/) {
-  char buf[128] = {0};
-  dunit::getTimeStr(buf, sizeof(buf));
-
-  fprintf(stdout, "[TEST 0:pid(%d)] %s at line: %d\n",
-          boost::this_process::get_id(), s.c_str(), lineno);
-  fflush(stdout);
+  using std::chrono::duration_cast;

Review comment:
       No. If it's big change it isn't worth it. It was only worth it if it made refactoring this crusty log code easier. 




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [geode-native] pivotal-jbarrett commented on pull request #797: GEODE-9214: Remove ACE time library references

Posted by GitBox <gi...@apache.org>.
pivotal-jbarrett commented on pull request #797:
URL: https://github.com/apache/geode-native/pull/797#issuecomment-830444894


   @gaussianrecurrence you are on a roll at getting ACE out of here! Thanks!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [geode-native] gaussianrecurrence commented on a change in pull request #797: GEODE-9214: Remove ACE time library references

Posted by GitBox <gi...@apache.org>.
gaussianrecurrence commented on a change in pull request #797:
URL: https://github.com/apache/geode-native/pull/797#discussion_r624719632



##########
File path: tests/cpp/fwklib/FwkLog.cpp
##########
@@ -54,32 +55,24 @@ const char* dirAndFile(const char* str) {
 }
 
 void plog(const char* l, const char* s, const char* filename, int32_t lineno) {
-  // ACE_TCHAR tstamp[64];
-  // ACE::timestamp( tstamp, 64, 1 );
-  // tstamp is like "Tue May 17 2005 12:54:22.546780"
-  // for our purpose we just want "12:54:22.546780"
-  char buf[256] = {0};
-  const size_t MINBUFSIZE = 128;
-  ACE_Time_Value clock = ACE_OS::gettimeofday();
-  time_t secs = clock.sec();
-  struct tm* tm_val = ACE_OS::localtime(&secs);
-  char* pbuf = buf;
-  pbuf += ACE_OS::strftime(pbuf, MINBUFSIZE, "%Y/%m/%d %H:%M:%S", tm_val);
-  pbuf += ACE_OS::snprintf(pbuf, 15, ".%06" PRId64 " ",
-                           static_cast<int64_t>(clock.usec()));
-  ACE_OS::strftime(pbuf, MINBUFSIZE, "%Z ", tm_val);
-  static bool needInit = true;
-  if (needInit) {
-    ACE_OS::uname(&u);
-    needInit = false;
-  }
+  using std::chrono::duration_cast;
+  using std::chrono::microseconds;
+  using std::chrono::system_clock;
 
-  const char* fil = dirAndFile(filename);
+  auto now = system_clock::now();
+  auto in_time_t = system_clock::to_time_t(now);
+  auto localtime = std::localtime(&in_time_t);
+  auto usec =
+      duration_cast<microseconds>(now.time_since_epoch()).count() % 1000;
 
-  fprintf(stdout, "[%s %s %s:P%d:T%" PRIu64 "]::%s::%d  %s  %s\n", buf,
-          u.sysname, u.nodename, ACE_OS::getpid(),
-          hacks::aceThreadId(ACE_OS::thr_self()), fil, lineno, l, s);
-  fflush(stdout);
+  const char* fil = dirAndFile(filename);
+  std::cout << '[' << std::put_time(localtime, "%Y/%m/%d %H:%M:%S") << '.'
+            << std::setfill('0') << std::setw(6) << usec << std::setw(0)
+            << std::put_time(localtime, " %Z ") << boost::asio::ip::host_name()

Review comment:
       I think I'll go for boost log. Thanks for pointing it out.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [geode-native] pivotal-jbarrett commented on a change in pull request #797: GEODE-9214: Remove ACE time library references

Posted by GitBox <gi...@apache.org>.
pivotal-jbarrett commented on a change in pull request #797:
URL: https://github.com/apache/geode-native/pull/797#discussion_r625859597



##########
File path: cppcache/integration-test/fw_dunit.cpp
##########
@@ -688,36 +680,63 @@ void sleep(int millis) {
 }
 
 void logCoordinator(std::string s, int lineno, const char * /*filename*/) {
-  char buf[128] = {0};
-  dunit::getTimeStr(buf, sizeof(buf));
-
-  fprintf(stdout, "[TEST coordinator:pid(%d)] %s at line: %d\n",
-          boost::this_process::get_id(), s.c_str(), lineno);
-  fflush(stdout);
+  using std::chrono::duration_cast;
+  using std::chrono::microseconds;
+  using std::chrono::system_clock;
+
+  auto now = system_clock::now();
+  auto in_time_t = system_clock::to_time_t(now);
+  auto localtime = std::localtime(&in_time_t);
+  auto usec =
+      duration_cast<microseconds>(now.time_since_epoch()).count() % 1000;
+
+  std::cout << "[TEST " << std::put_time(localtime, "%Y/%m/%d %H:%M:%S") << '.'
+            << std::setfill('0') << std::setw(6) << usec << std::setw(0)
+            << " coordinator:pid(" << boost::this_process::get_id() << ")] "
+            << s << " at line: " << lineno << std::endl
+            << std::flush;
 }
 
 // log a message and print the worker id as well.. used by fw_helper with no
 // worker id.
 void log(std::string s, int lineno, const char * /*filename*/, int /*id*/) {
-  char buf[128] = {0};
-  dunit::getTimeStr(buf, sizeof(buf));
-
-  fprintf(stdout, "[TEST 0:pid(%d)] %s at line: %d\n",
-          boost::this_process::get_id(), s.c_str(), lineno);
-  fflush(stdout);
+  using std::chrono::duration_cast;

Review comment:
       With the transition to boost::log for the test framework, what is still using this logger?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [geode-native] pdxcodemonkey merged pull request #797: GEODE-9214: Remove ACE time library references

Posted by GitBox <gi...@apache.org>.
pdxcodemonkey merged pull request #797:
URL: https://github.com/apache/geode-native/pull/797


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [geode-native] gaussianrecurrence commented on a change in pull request #797: GEODE-9214: Remove ACE time library references

Posted by GitBox <gi...@apache.org>.
gaussianrecurrence commented on a change in pull request #797:
URL: https://github.com/apache/geode-native/pull/797#discussion_r625865822



##########
File path: cppcache/integration-test/fw_dunit.cpp
##########
@@ -688,36 +680,63 @@ void sleep(int millis) {
 }
 
 void logCoordinator(std::string s, int lineno, const char * /*filename*/) {
-  char buf[128] = {0};
-  dunit::getTimeStr(buf, sizeof(buf));
-
-  fprintf(stdout, "[TEST coordinator:pid(%d)] %s at line: %d\n",
-          boost::this_process::get_id(), s.c_str(), lineno);
-  fflush(stdout);
+  using std::chrono::duration_cast;
+  using std::chrono::microseconds;
+  using std::chrono::system_clock;
+
+  auto now = system_clock::now();
+  auto in_time_t = system_clock::to_time_t(now);
+  auto localtime = std::localtime(&in_time_t);
+  auto usec =
+      duration_cast<microseconds>(now.time_since_epoch()).count() % 1000;
+
+  std::cout << "[TEST " << std::put_time(localtime, "%Y/%m/%d %H:%M:%S") << '.'
+            << std::setfill('0') << std::setw(6) << usec << std::setw(0)
+            << " coordinator:pid(" << boost::this_process::get_id() << ")] "
+            << s << " at line: " << lineno << std::endl
+            << std::flush;
 }
 
 // log a message and print the worker id as well.. used by fw_helper with no
 // worker id.
 void log(std::string s, int lineno, const char * /*filename*/, int /*id*/) {
-  char buf[128] = {0};
-  dunit::getTimeStr(buf, sizeof(buf));
-
-  fprintf(stdout, "[TEST 0:pid(%d)] %s at line: %d\n",
-          boost::this_process::get_id(), s.c_str(), lineno);
-  fflush(stdout);
+  using std::chrono::duration_cast;

Review comment:
       Sadly I only changed tests/cpp/security code to log with Boost.Log
   Thing is in theory this PR is supposed to be focused remove references for ACE time library.
   Also, I tried to replace logging for Boost.Log on the old ITs, and the changes were huge.
   So what do you think if a open a separate PR to adress this?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org