Skip to content

v0.2.53..v0.2.54 changeset OsmApiWriter.h

Garret Voltz edited this page Mar 31, 2020 · 1 revision
diff --git a/hoot-core/src/main/cpp/hoot/core/io/OsmApiWriter.h b/hoot-core/src/main/cpp/hoot/core/io/OsmApiWriter.h
index e59010e..67c1f6b 100644
--- a/hoot-core/src/main/cpp/hoot/core/io/OsmApiWriter.h
+++ b/hoot-core/src/main/cpp/hoot/core/io/OsmApiWriter.h
@@ -37,6 +37,9 @@
 #include <hoot/core/util/Configurable.h>
 #include <hoot/core/util/ProgressReporter.h>
 
+//  Tgs
+#include <tgs/System/Timer.h>
+
 //  Standard
 #include <mutex>
 #include <queue>
@@ -55,26 +58,12 @@ class OsmApiWriterTest;
 class OsmApiWriter : public Configurable, public ProgressReporter
 {
 public:
-  /** OSM API URL paths */
-  const static char* API_PATH_CAPABILITIES;
-  const static char* API_PATH_PERMISSIONS;
-  const static char* API_PATH_CREATE_CHANGESET;
-  const static char* API_PATH_CLOSE_CHANGESET;
-  const static char* API_PATH_UPLOAD_CHANGESET;
-  const static char* API_PATH_GET_ELEMENT;
-  /** Default content type */
-  const static char* CONTENT_TYPE_XML;
   /**
    *  Max number of jobs waiting in the work queue = multiplier * number of threads,
    *  this keeps the producer thread from creating too many sub-changesets too early
    *  that only consist of nodes after ways are blocked.
    */
   const int QUEUE_SIZE_MULTIPLIER = 2;
-  /** Constructor with one or multiple files consisting of one large changeset to run
-   *  the test apply
-   */
-  OsmApiWriter(const QString& output_file, const QString& changeset);
-  OsmApiWriter(const QString& output_file, const QList<QString>& changesets);
   /** Constructors with one or multiple files consisting of one large changeset */
   OsmApiWriter(const QUrl& url, const QString& changeset);
   OsmApiWriter(const QUrl& url, const QList<QString>& changesets);
@@ -95,11 +84,6 @@ public:
    */
   bool apply();
   /**
-   * @brief testApply Actually load, divide, and write the changesets to files instead of OSM API
-   * @return list of filepaths for output files
-   */
-  QStringList testApply();
-  /**
    * @brief containsFailed
    * @return true if there are failed changes in the changeset
    */
@@ -276,6 +260,20 @@ private:
    * @return True if the changeset was split
    */
   bool _splitChangeset(const ChangesetInfoPtr& workInfo, const QString& response);
+  /**
+   * @brief _writeDebugFile Write out the request or response file for debugging uploads
+   * @param type "request" or "response" output file
+   * @param data Contents of the file to write
+   * @param file_id File ID for unique filenames
+   * @param changeset_id Changeset ID that is currently open
+   * @param status HTTP status code returned for response, 000 for request
+   */
+  void _writeDebugFile(const QString& type, const QString& data, int file_id, long changeset_id, int status = 0);
+  /**
+   * @brief _getNextApiId Get the next API ID from the counter for unique debug filenames
+   * @return next ID
+   */
+  int _getNextApiId();
   /** Changeset processing thread pool */
   std::vector<std::thread> _threadPool;
   /** Queue for producer/consumer work model */
@@ -296,6 +294,8 @@ private:
   std::vector<ThreadStatus> _threadStatus;
   /** Mutex protecting status vector */
   std::mutex _threadStatusMutex;
+  /** Vector of idle times for thread monitoring */
+  std::vector<Tgs::Timer> _threadIdle;
   /** Base URL for the target OSM API, including authentication information */
   QUrl _url;
   /** List of pathnames for changeset divided across files */
@@ -336,14 +336,18 @@ private:
   QString _accessToken;
   /** OAuth 1.0 secret token granted through OAuth authorization */
   QString _secretToken;
-  /** Full pathname of the error file changeset, if any errors occur */
-  QString _errorPathname;
   /** Number of changesets written to API */
   int _changesetCount;
   /** Mutex for changeset count */
   std::mutex _changesetCountMutex;
-  /** Full pathname of the output file created during --test-apply */
-  QString _testApplyPathname;
+  /** Output requests and responses for debugging  */
+  bool _debugOutput;
+  /** Path for the output requests and responses */
+  QString _debugOutputPath;
+  /** API ID counter used in debug output */
+  int _apiId;
+  /** Mutex for API ID counter */
+  std::mutex _apiIdMutex;
   /** For white box testing */
   friend class OsmApiWriterTest;
   /** Default constructor for testing purposes only */
Clone this wiki locally