Made the package indexing more slow.
This commit is contained in:
parent
f4195e2ccc
commit
1d0df6ccaa
|
@ -26,9 +26,17 @@ public class DPackageSearch {
|
||||||
private static void startIndexerThread(IndexGenerator indexGenerator) {
|
private static void startIndexerThread(IndexGenerator indexGenerator) {
|
||||||
Thread.ofVirtual().start(() -> {
|
Thread.ofVirtual().start(() -> {
|
||||||
while (true) {
|
while (true) {
|
||||||
|
System.out.println("Will re-index packages in 10 seconds");
|
||||||
|
try {
|
||||||
|
Thread.sleep(Duration.ofSeconds(10));
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
System.err.println("Indexing thread interrupted: " + e.getMessage());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
System.out.println("Re-indexing packages now.");
|
||||||
indexGenerator.run();
|
indexGenerator.run();
|
||||||
try {
|
try {
|
||||||
Thread.sleep(Duration.ofMinutes(5));
|
Thread.sleep(Duration.ofMinutes(60));
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
System.err.println("Indexing thread interrupted: " + e.getMessage());
|
System.err.println("Indexing thread interrupted: " + e.getMessage());
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -25,13 +25,14 @@ public record IndexGenerator(
|
||||||
Collection<PackageInfo> packages;
|
Collection<PackageInfo> packages;
|
||||||
try {
|
try {
|
||||||
packages = fetcher.fetch();
|
packages = fetcher.fetch();
|
||||||
|
dur = Duration.between(start, Instant.now());
|
||||||
|
System.out.println("Fetched " + packages.size() + " in " + dur.toMillis() + " ms.");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
System.err.println("Failed to fetch packages: " + e.getMessage());
|
System.err.println("Failed to fetch packages: " + e.getMessage());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try (PackageIndexer indexer = indexerSupplier.get()) {
|
try (PackageIndexer indexer = indexerSupplier.get()) {
|
||||||
dur = Duration.between(start, Instant.now());
|
|
||||||
System.out.println("Fetched " + packages.size() + " in " + dur.toMillis() + " ms.");
|
|
||||||
start = Instant.now();
|
start = Instant.now();
|
||||||
for (var pkg : packages) {
|
for (var pkg : packages) {
|
||||||
indexer.addToIndex(pkg);
|
indexer.addToIndex(pkg);
|
||||||
|
|
Loading…
Reference in New Issue