Jonathan Hart
Committed by Gerrit Code Review

Delay loading startup applications.

We need to ensure ApplicationService is fully activated before we try
to load any applications that may depend on it.

Change-Id: I77bcf2534cc43056facb5dca5b6947ab52e61dcc
...@@ -62,6 +62,7 @@ import java.util.concurrent.CountDownLatch; ...@@ -62,6 +62,7 @@ import java.util.concurrent.CountDownLatch;
62 import java.util.concurrent.ExecutorService; 62 import java.util.concurrent.ExecutorService;
63 import java.util.concurrent.Executors; 63 import java.util.concurrent.Executors;
64 import java.util.concurrent.ScheduledExecutorService; 64 import java.util.concurrent.ScheduledExecutorService;
65 +import java.util.concurrent.TimeUnit;
65 import java.util.function.Function; 66 import java.util.function.Function;
66 67
67 import static com.google.common.collect.Multimaps.newSetMultimap; 68 import static com.google.common.collect.Multimaps.newSetMultimap;
...@@ -94,6 +95,8 @@ public class GossipApplicationStore extends ApplicationArchive ...@@ -94,6 +95,8 @@ public class GossipApplicationStore extends ApplicationArchive
94 95
95 private static final int FETCH_TIMEOUT_MS = 10_000; 96 private static final int FETCH_TIMEOUT_MS = 10_000;
96 97
98 + private static final int APP_LOAD_DELAY_MS = 500;
99 +
97 public enum InternalState { 100 public enum InternalState {
98 INSTALLED, ACTIVATED, DEACTIVATED 101 INSTALLED, ACTIVATED, DEACTIVATED
99 } 102 }
...@@ -230,7 +233,7 @@ public class GossipApplicationStore extends ApplicationArchive ...@@ -230,7 +233,7 @@ public class GossipApplicationStore extends ApplicationArchive
230 @Override 233 @Override
231 public void setDelegate(ApplicationStoreDelegate delegate) { 234 public void setDelegate(ApplicationStoreDelegate delegate) {
232 super.setDelegate(delegate); 235 super.setDelegate(delegate);
233 - loadFromDisk(); 236 + executor.schedule(() -> loadFromDisk(), APP_LOAD_DELAY_MS, TimeUnit.MILLISECONDS);
234 } 237 }
235 238
236 @Override 239 @Override
......