hkeebler opened a new pull request #1198: Fix #1122 Added concurrent structures 
to ThriftTransportPool and sugg…
URL: https://github.com/apache/accumulo/pull/1198
 
 
   …estions for removing syncrhonized blocks
   
   Syncrhronized blocks of text are commented out in the diffs below.  These 
may not be necessary if the object constructs handle write/delete concurrency. 
But maybe they are not that costly.
   Additionally - I have a question on the section of code below.  The 
connections are closed specifically after the sync block.  It seems that since 
the "unreserved" is read and not deleted from then someone could use one that 
is designated to close by the sync blck.
    ```
        synchronized (pool) {
             for (CachedConnections cachedConns : pool.getCache().values()) {
               Iterator<CachedConnection> iter = 
cachedConns.unreserved.iterator();
               while (iter.hasNext()) {
                 CachedConnection cachedConnection = iter.next();
   
                 if (System.currentTimeMillis() - 
cachedConnection.lastReturnTime > pool.killTime) {
                   connectionsToClose.add(cachedConnection);
                   iter.remove();
                 }
               }
   
               for (CachedConnection cachedConnection : 
cachedConns.reserved.values()) {
                 cachedConnection.transport.checkForStuckIO(STUCK_THRESHOLD);
               }
             }
   
             Iterator<Entry<ThriftTransportKey,Long>> iter = 
pool.errorTime.entrySet().iterator();
             while (iter.hasNext()) {
               Entry<ThriftTransportKey,Long> entry = iter.next();
               long delta = System.currentTimeMillis() - entry.getValue();
               if (delta >= STUCK_THRESHOLD) {
                 pool.errorCount.remove(entry.getKey());
                 iter.remove();
               }
             }
           }
   
           // close connections outside of sync block
           for (CachedConnection cachedConnection : connectionsToClose) {
             cachedConnection.transport.close();
           }
   ```

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to