colinmjj commented on code in PR #72:
URL: https://github.com/apache/incubator-uniffle/pull/72#discussion_r929659644
##########
server/src/main/java/org/apache/uniffle/server/storage/LocalStorageManager.java:
##########
@@ -63,18 +65,43 @@ public class LocalStorageManager extends
SingleStorageManager {
if (highWaterMarkOfWrite < lowWaterMarkOfWrite) {
throw new IllegalArgumentException("highWaterMarkOfWrite must be larger
than lowWaterMarkOfWrite");
}
+
+ CountDownLatch countDownLatch = new
CountDownLatch(storageBasePaths.length);
+ AtomicInteger successCount = new AtomicInteger();
for (String storagePath : storageBasePaths) {
- localStorages.add(LocalStorage.newBuilder()
- .basePath(storagePath)
- .capacity(capacity)
- .lowWaterMarkOfWrite(lowWaterMarkOfWrite)
- .highWaterMarkOfWrite(highWaterMarkOfWrite)
- .shuffleExpiredTimeoutMs(shuffleExpiredTimeoutMs)
- .build());
+ new Thread(() -> {
+ try {
+ addLocalStorage(LocalStorage.newBuilder()
+ .basePath(storagePath)
+ .capacity(capacity)
+ .lowWaterMarkOfWrite(lowWaterMarkOfWrite)
+ .highWaterMarkOfWrite(highWaterMarkOfWrite)
+ .shuffleExpiredTimeoutMs(shuffleExpiredTimeoutMs)
+ .build());
+ successCount.incrementAndGet();
+ } finally {
+ countDownLatch.countDown();
+ }
+ }).start();
+ }
+ try {
+ countDownLatch.await();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+
+ int failedCount = storageBasePaths.length - successCount.get();
+ if (failedCount > 0) {
+ throw new RuntimeException(String.format("[%s] local storage init
failed!", failedCount));
}
+
this.checker = new LocalStorageChecker(conf, localStorages);
}
+ private synchronized void addLocalStorage(LocalStorage localStorage) {
Review Comment:
Does it do the clean concurrently with synchronized?
--
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]