fabriziofortino commented on code in PR #2607:
URL: https://github.com/apache/jackrabbit-oak/pull/2607#discussion_r2495718234


##########
oak-run/src/main/java/org/apache/jackrabbit/oak/run/Downloader.java:
##########
@@ -101,16 +107,21 @@ public Downloader(int concurrency, int connectTimeoutMs, 
int readTimeoutMs, int
         this.bufferSize = bufferSize;
 
         this.executorService = new ThreadPoolExecutor(
-                (int) Math.ceil(concurrency * .1), concurrency, 60L, 
TimeUnit.SECONDS,
+                corePoolSize, concurrency, 60L, TimeUnit.SECONDS,
                 new LinkedBlockingQueue<>(),
                 
BasicThreadFactory.builder().namingPattern("downloader-%d").daemon().build()
         );
+        this.executorServiceForParts = new ThreadPoolExecutor(
+                corePoolSize, concurrency, 60L, TimeUnit.SECONDS,
+                new LinkedBlockingQueue<>(),
+                
BasicThreadFactory.builder().namingPattern("partDownloader-%d").daemon().build()
+        );

Review Comment:
   by adding this thread pool executor, we are actually doubling the number of 
concurrent requests the downloader does. This might be confusing since 
`concurrency` is an option defined as you can see here.
   
   ```
   OptionSpec<Integer> concurrencyOpt = parser.accepts("concurrency",
                           "Max number of concurrent requests that can occur 
(the default value is equal to 16 multiplied by the number of cores)")
                   .withRequiredArg().ofType(Integer.class).defaultsTo(16 * 
Runtime.getRuntime().availableProcessors());
   ```



##########
oak-run/src/main/java/org/apache/jackrabbit/oak/run/DataStoreCommand.java:
##########
@@ -687,6 +683,28 @@ public void log() throws IOException {
         }
     }
 
+    /**
+     * Try to read the blob length from the blobId. It is typically after the 
'#'.
+     * It never throws an exception.
+     *
+     * @param blobId the blob id, which may contain a '#'
+     * @return the length, or 0 if unknown.
+     */
+    public static long getBlobLengthOrZero(String blobId) {
+        if (blobId == null) {
+            return 0;
+        }
+        int hashIndex = blobId.indexOf('#');
+        if (hashIndex < 0) {
+            return 0;
+        }
+        try {
+            return Long.parseLong(blobId.substring(hashIndex + 1));
+        } catch (NumberFormatException e) {
+            return 0;

Review Comment:
   perhaps this never happens but should we log the exception just in case?



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