Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.locks.LockSupport;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
* This class provide a basic {@link LookupExtractorFactory} references manager.
Expand Down Expand Up @@ -472,37 +471,30 @@ private List<LookupBean> getLookupBeanList(Map<String, LookupExtractorFactoryCon

private void startLookups(final List<LookupBean> lookupBeanList)
{
ImmutableMap.Builder<String, LookupExtractorFactoryContainer> builder = ImmutableMap.builder();
ExecutorService executorService = Execs.multiThreaded(
final ImmutableMap.Builder<String, LookupExtractorFactoryContainer> builder = ImmutableMap.builder();
final ExecutorService executorService = Execs.multiThreaded(
lookupConfig.getNumLookupLoadingThreads(),
"LookupReferencesManager-Startup-%s"
);
CompletionService<Map.Entry<String, LookupExtractorFactoryContainer>> completionService =
final CompletionService<Map.Entry<String, LookupExtractorFactoryContainer>> completionService =
new ExecutorCompletionService<>(executorService);
final List<LookupBean> remainingLookups = new ArrayList<>(lookupBeanList);
try {
LOG.info("Starting lookup loading process");
List<LookupBean> remainingLookups = lookupBeanList;
for (int i = 0; i < lookupConfig.getLookupStartRetries(); i++) {
for (int i = 0; i < lookupConfig.getLookupStartRetries() && !remainingLookups.isEmpty(); i++) {
LOG.info("Round of attempts #%d, [%d] lookups", i + 1, remainingLookups.size());
Map<String, LookupExtractorFactoryContainer> successfulLookups =
final Map<String, LookupExtractorFactoryContainer> successfulLookups =
startLookups(remainingLookups, completionService);
builder.putAll(successfulLookups);
List<LookupBean> failedLookups = remainingLookups
.stream()
.filter(l -> !successfulLookups.containsKey(l.getName()))
.collect(Collectors.toList());
if (failedLookups.isEmpty()) {
break;
} else {
// next round
remainingLookups = failedLookups;
}
remainingLookups.removeIf(l -> successfulLookups.containsKey(l.getName()));
}
if (!remainingLookups.isEmpty()) {
LOG.warn(
"Failed to start the following lookups after [%d] attempts: [%s]",
lookupConfig.getLookupStartRetries(),
remainingLookups
);
}
LOG.info(
"Failed to start the following lookups after [%d] attempts: [%s]",
lookupConfig.getLookupStartRetries(),
remainingLookups
);
stateRef.set(new LookupUpdateState(builder.build(), ImmutableList.of(), ImmutableList.of()));
}
catch (InterruptedException | RuntimeException e) {
Expand Down