mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 13:16:45 +01:00
do a second attempt at fetching uuid batches even if it errors
This commit is contained in:
parent
f01b242e4a
commit
3b7057ad4f
@ -425,18 +425,40 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
|||||||
PlotSquared.log(Captions.PREFIX.getTranslated() + "(UUID) PlotSquared will fetch UUIDs in groups of "
|
PlotSquared.log(Captions.PREFIX.getTranslated() + "(UUID) PlotSquared will fetch UUIDs in groups of "
|
||||||
+ Settings.UUID.BACKGROUND_LIMIT);
|
+ Settings.UUID.BACKGROUND_LIMIT);
|
||||||
final List<UUID> uuidList = new ArrayList<>(Settings.UUID.BACKGROUND_LIMIT);
|
final List<UUID> uuidList = new ArrayList<>(Settings.UUID.BACKGROUND_LIMIT);
|
||||||
while (!uuidQueue.isEmpty()) {
|
|
||||||
for (int i = 0; i < Settings.UUID.BACKGROUND_LIMIT && !uuidQueue.isEmpty(); i++) {
|
// Used to indicate that the second retrieval has been attempted
|
||||||
uuidList.add(uuidQueue.poll());
|
boolean secondRun = false;
|
||||||
read++;
|
|
||||||
|
while (!uuidQueue.isEmpty() || !uuidList.isEmpty()) {
|
||||||
|
if (!uuidList.isEmpty() && secondRun) {
|
||||||
|
PlotSquared.log("Giving up on last batch. Fetching new batch instead.");
|
||||||
|
uuidList.clear();
|
||||||
|
}
|
||||||
|
if (uuidList.isEmpty()) {
|
||||||
|
// Retrieve the secondRun variable to indicate that we're retrieving a
|
||||||
|
// fresh batch
|
||||||
|
secondRun = false;
|
||||||
|
// Populate the request list
|
||||||
|
for (int i = 0; i < Settings.UUID.BACKGROUND_LIMIT && !uuidQueue.isEmpty(); i++) {
|
||||||
|
uuidList.add(uuidQueue.poll());
|
||||||
|
read++;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// If the list isn't empty then this is a second run for
|
||||||
|
// an old batch, so we re-use the patch
|
||||||
|
secondRun = true;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
PlotSquared.get().getBackgroundUUIDPipeline().getNames(uuidList).get();
|
PlotSquared.get().getBackgroundUUIDPipeline().getNames(uuidList).get();
|
||||||
|
// Clear the list if we successfully index all the names
|
||||||
|
uuidList.clear();
|
||||||
|
// Print progress
|
||||||
|
final double percentage = ((double) read / (double) totalSize) * 100.0D;
|
||||||
|
PlotSquared.log(Captions.PREFIX.getTranslated() + String.format("(UUID) PlotSquared has cached %.1f%% of UUIDs", percentage));
|
||||||
} catch (final InterruptedException | ExecutionException e) {
|
} catch (final InterruptedException | ExecutionException e) {
|
||||||
|
PlotSquared.log("Failed to retrieve that batch. Will try again.");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
final double percentage = ((double) read / (double) totalSize) * 100.0D;
|
|
||||||
PlotSquared.log(Captions.PREFIX.getTranslated() + String.format("(UUID) PlotSquared has cached %.1f%% of UUIDs", percentage));
|
|
||||||
}
|
}
|
||||||
PlotSquared.log(Captions.PREFIX.getTranslated() + "(UUID) PlotSquared has cached all UUIDs");
|
PlotSquared.log(Captions.PREFIX.getTranslated() + "(UUID) PlotSquared has cached all UUIDs");
|
||||||
}, 10, TimeUnit.SECONDS);
|
}, 10, TimeUnit.SECONDS);
|
||||||
|
Loading…
Reference in New Issue
Block a user