[ 
https://issues.apache.org/jira/browse/GEODE-8553?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17206286#comment-17206286
 ] 

ASF GitHub Bot commented on GEODE-8553:
---------------------------------------

gaussianrecurrence commented on a change in pull request #660:
URL: https://github.com/apache/geode-native/pull/660#discussion_r498903573



##########
File path: cppcache/src/ThinClientLocatorHelper.hpp
##########
@@ -42,38 +43,95 @@ class Connector;
 
 class ThinClientLocatorHelper {
  public:
-  ThinClientLocatorHelper(const std::vector<std::string>& locatorAddresses,
+  ThinClientLocatorHelper(const ThinClientLocatorHelper&) = delete;
+  ThinClientLocatorHelper& operator=(const ThinClientLocatorHelper&) = delete;
+
+  ThinClientLocatorHelper(const std::vector<std::string>& locators,
                           const ThinClientPoolDM* poolDM);
-  ThinClientLocatorHelper(const std::vector<std::string>& locatorAddresses,
+  ThinClientLocatorHelper(const std::vector<std::string>& locators,
                           const std::string& sniProxyHost, int sniProxyPort,
                           const ThinClientPoolDM* poolDM);
   GfErrType getEndpointForNewFwdConn(
       ServerLocation& outEndpoint, std::string& additionalLoc,
       const std::set<ServerLocation>& exclEndPts,
       const std::string& serverGrp = "",
-      const TcrConnection* currentServer = nullptr);
+      const TcrConnection* currentServer = nullptr) const;
   GfErrType getEndpointForNewCallBackConn(
       ClientProxyMembershipID& memId, std::list<ServerLocation>& outEndpoint,
       std::string& additionalLoc, int redundancy,
-      const std::set<ServerLocation>& exclEndPts, const std::string& 
serverGrp);
+      const std::set<ServerLocation>& exclEndPts,
+      const std::string& serverGrp) const;
   GfErrType getAllServers(
       std::vector<std::shared_ptr<ServerLocation> >& servers,
-      const std::string& serverGrp);
-  int32_t getCurLocatorsNum() {
-    return static_cast<int32_t>(m_locHostPort.size());
+      const std::string& serverGrp) const;
+  int32_t getCurLocatorsNum() const {
+    return static_cast<int32_t>(locators_.size());
   }
   GfErrType updateLocators(const std::string& serverGrp = "");
 
  private:
-  Connector* createConnection(Connector*& conn, const char* hostname,
-                              int32_t port,
-                              std::chrono::microseconds waitSeconds,
-                              int32_t maxBuffSizePool = 0);
-  std::mutex m_locatorLock;
-  std::vector<ServerLocation> m_locHostPort;
+  /**
+   * Auxiliary types
+   */
+
+  class ConnectionWrapper {
+   private:
+    Connector* conn_;
+
+   public:
+    ConnectionWrapper(const ConnectionWrapper&) = delete;
+    ConnectionWrapper& operator=(const ConnectionWrapper&) = delete;
+
+    explicit ConnectionWrapper(Connector* conn) : conn_(conn) {}
+    ConnectionWrapper(ConnectionWrapper&& other)
+        : conn_(std::move(other.conn_)) {}
+
+    ~ConnectionWrapper();
+
+    Connector* operator->() { return conn_; }
+  };
+
+  /**
+   * Returns the number of connections retries per request
+   * @return Number of connection retries towards locators
+   */
+  int getConnRetries() const;

Review comment:
       Indeed 👍 




----------------------------------------------------------------
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:
us...@infra.apache.org


> Reduce ThinClientLocatorHelper lock time
> ----------------------------------------
>
>                 Key: GEODE-8553
>                 URL: https://issues.apache.org/jira/browse/GEODE-8553
>             Project: Geode
>          Issue Type: Improvement
>          Components: native client
>    Affects Versions: 1.12.0, 1.13.0
>            Reporter: Mario Salazar de Torres
>            Assignee: Mario Salazar de Torres
>            Priority: Major
>              Labels: pull-request-available
>
> During my troublshootings, I've seen that locking m_locatorLock for the whole 
> scope of the class function members might cause some inter-locks.
> Problem here and in many other places of the NC is that networking operations 
> are performed while a mutex is locked. Therefore if *thread A* takes longer 
> than expected in performing its network operation, it might block another one 
> which does not requires any resource of the first *thread A*. Hence, the 
> inter-lock.
> This improvement is the first one of a series regarding to lock scope 
> reduction when it comes with code regarding networking in NC.
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to