kfaraz commented on a change in pull request #12298:
URL: https://github.com/apache/druid/pull/12298#discussion_r820388229



##########
File path: 
core/src/main/java/org/apache/druid/java/util/http/client/pool/ResourcePool.java
##########
@@ -189,6 +191,46 @@ private ImmediateCreationResourceHolder(
         );
       }
     }
+  }
+
+  private static class LazyCreationResourceHolder<K, V> extends 
ResourceHolderPerKey<K, V>
+  {
+    private LazyCreationResourceHolder(
+        int maxSize,
+        long unusedResourceTimeoutMillis,
+        K key,
+        ResourceFactory<K, V> factory
+    )
+    {
+      super(maxSize, unusedResourceTimeoutMillis, key, factory);

Review comment:
       Are we not initializing even a single connection here?

##########
File path: 
core/src/main/java/org/apache/druid/java/util/http/client/pool/ResourcePool.java
##########
@@ -154,30 +167,19 @@ public void close()
     }
   }
 
-  private static class ImmediateCreationResourceHolder<K, V> implements 
Closeable
+  private static class EagerCreationResourceHolder<K, V> extends 
ResourceHolderPerKey<K, V>
   {
-    private final int maxSize;
-    private final K key;
-    private final ResourceFactory<K, V> factory;
-    private final ArrayDeque<ResourceHolder<V>> resourceHolderList;
-    private int deficit = 0;
-    private boolean closed = false;
-    private final long unusedResourceTimeoutMillis;
-
-    private ImmediateCreationResourceHolder(
+    private EagerCreationResourceHolder(
         int maxSize,
         long unusedResourceTimeoutMillis,
         K key,
         ResourceFactory<K, V> factory
     )
     {
-      this.maxSize = maxSize;
-      this.key = key;
-      this.factory = factory;
-      this.unusedResourceTimeoutMillis = unusedResourceTimeoutMillis;
-      this.resourceHolderList = new ArrayDeque<>();
-
-      for (int i = 0; i < maxSize; ++i) {
+      super(maxSize, unusedResourceTimeoutMillis, key, factory);
+      eagerInstantiation = true;

Review comment:
       It seems that `eagerInstantiation` is a field of the super class 
`ResourceHolderPerKey`. If this is the case, it must be taken as a constructor 
arg for that super class.

##########
File path: 
core/src/main/java/org/apache/druid/java/util/http/client/pool/ResourcePool.java
##########
@@ -199,7 +241,7 @@ V get()
       // resourceHolderList can't have nulls, so we'll use a null to signal 
that we need to create a new resource.
       final V poolVal;
       synchronized (this) {
-        while (!closed && resourceHolderList.size() == 0 && deficit == 0) {
+        while (!closed && (numLentResources == maxSize)) {

Review comment:
       I am not sure but it seems that the new field `numLentResources` is not 
really needed. You could probably use the `deficit` variable to achieve similar 
behaviour?




-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to