keith-turner commented on code in PR #35:
URL: 
https://github.com/apache/accumulo-classloaders/pull/35#discussion_r2627946154


##########
modules/local-caching-classloader/src/main/java/org/apache/accumulo/classloader/lcc/cache/CacheUtils.java:
##########
@@ -126,4 +146,101 @@ public static LockInfo lockContextCacheDir(final Path 
contextCacheDir)
     }
   }
 
+  public static URLClassLoaderHelper stageContext(final Path baseCacheDir,
+      final ContextDefinition contextDefinition)
+      throws IOException, ContextClassLoaderException, InterruptedException, 
URISyntaxException {
+    final RetryFactory retryFactory =
+        Retry.builder().infiniteRetries().retryAfter(1, TimeUnit.SECONDS)
+            .incrementBy(1, TimeUnit.SECONDS).maxWait(5, 
TimeUnit.MINUTES).backOffFactor(2)
+            .logInterval(1, TimeUnit.SECONDS).createFactory();
+    requireNonNull(contextDefinition, "definition must be supplied");
+    CacheUtils.createBaseDirs(baseCacheDir);
+    Path contextsDir = CacheUtils.contextsDir(baseCacheDir);
+    final Set<File> localFiles = new LinkedHashSet<>();
+    try {
+      LockInfo lockInfo = CacheUtils.lockContextCacheDir(contextsDir);
+      Files.write(
+          contextsDir
+              .resolve(contextDefinition.getContextName() + "_" + 
contextDefinition.getChecksum()),
+          contextDefinition.toJson().getBytes(UTF_8));

Review Comment:
   Would be good to minimize the amount of code between getting the lock and 
the try/finally that unlocks.  Any exception that happens after getting the 
code and before starting the try could leave it locked.



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