pan3793 commented on code in PR #3625:
URL: https://github.com/apache/celeborn/pull/3625#discussion_r2923502512


##########
common/src/main/java/org/apache/celeborn/common/network/util/NettyUtils.java:
##########
@@ -141,23 +142,32 @@ public static String getRemoteAddress(Channel channel) {
    *     effect for PooledByteBufAllocator.
    */
   private static ByteBufAllocator createByteBufAllocator(
-      boolean pooled, boolean allowDirectBufs, boolean allowCache, int 
numCores) {
-    if (pooled) {
-      if (numCores == 0) {
-        numCores = Runtime.getRuntime().availableProcessors();
-      }
-      return new PooledByteBufAllocator(
-          allowDirectBufs && PlatformDependent.directBufferPreferred(),
-          Math.min(PooledByteBufAllocator.defaultNumHeapArena(), numCores),
-          Math.min(PooledByteBufAllocator.defaultNumDirectArena(), 
allowDirectBufs ? numCores : 0),
-          PooledByteBufAllocator.defaultPageSize(),
-          PooledByteBufAllocator.defaultMaxOrder(),
-          allowCache ? PooledByteBufAllocator.defaultSmallCacheSize() : 0,
-          allowCache ? PooledByteBufAllocator.defaultNormalCacheSize() : 0,
-          allowCache && PooledByteBufAllocator.defaultUseCacheForAllThreads());
-    } else {
-      return new UnpooledByteBufAllocator(
-          allowDirectBufs && PlatformDependent.directBufferPreferred());
+      NettyMemoryAllocatorType allocatorType,
+      boolean allowDirectBufs,
+      boolean allowCache,
+      int numCores) {
+    boolean preferDirect = allowDirectBufs && 
PlatformDependent.directBufferPreferred();
+    switch (allocatorType) {
+      case POOLED:
+        if (numCores == 0) {
+          numCores = Runtime.getRuntime().availableProcessors();
+        }
+        return new PooledByteBufAllocator(
+            preferDirect,
+            Math.min(PooledByteBufAllocator.defaultNumHeapArena(), numCores),
+            Math.min(
+                PooledByteBufAllocator.defaultNumDirectArena(), 
allowDirectBufs ? numCores : 0),
+            PooledByteBufAllocator.defaultPageSize(),
+            PooledByteBufAllocator.defaultMaxOrder(),
+            allowCache ? PooledByteBufAllocator.defaultSmallCacheSize() : 0,
+            allowCache ? PooledByteBufAllocator.defaultNormalCacheSize() : 0,
+            allowCache && 
PooledByteBufAllocator.defaultUseCacheForAllThreads());
+      case UNPOOLED:
+        return new UnpooledByteBufAllocator(preferDirect);
+      case ADAPTIVE:
+        return new AdaptiveByteBufAllocator(preferDirect);

Review Comment:
   does it support any args?



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

Reply via email to