mirror of
https://github.com/MarginaliaSearch/MarginaliaSearch.git
synced 2025-10-05 21:22:39 +02:00
(ndp) Refresh the ndp queue on restart
This commit is contained in:
@@ -38,6 +38,7 @@ public class DomainTestingQueue {
|
|||||||
this.dataSource = dataSource;
|
this.dataSource = dataSource;
|
||||||
this.linkGraphClient = linkGraphClient;
|
this.linkGraphClient = linkGraphClient;
|
||||||
|
|
||||||
|
|
||||||
Thread.ofPlatform()
|
Thread.ofPlatform()
|
||||||
.name("DomainTestingQueue::fetch()")
|
.name("DomainTestingQueue::fetch()")
|
||||||
.start(this::fetch);
|
.start(this::fetch);
|
||||||
@@ -92,6 +93,13 @@ public class DomainTestingQueue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void fetch() {
|
public void fetch() {
|
||||||
|
try (var conn = dataSource.getConnection()) {
|
||||||
|
refreshQueue(conn);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("Error refreshing the ndp queue");
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
List<DomainToTest> domains = new ArrayList<>(2000);
|
List<DomainToTest> domains = new ArrayList<>(2000);
|
||||||
try (var conn = dataSource.getConnection();
|
try (var conn = dataSource.getConnection();
|
||||||
@@ -126,6 +134,7 @@ public class DomainTestingQueue {
|
|||||||
throw e; // Rethrow runtime exceptions to avoid wrapping them in another runtime exception
|
throw e; // Rethrow runtime exceptions to avoid wrapping them in another runtime exception
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
|
logger.error("Error in ndp process");
|
||||||
throw new RuntimeException("Failed to fetch domains from database", e);
|
throw new RuntimeException("Failed to fetch domains from database", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -193,7 +202,8 @@ public class DomainTestingQueue {
|
|||||||
|
|
||||||
/* Insert new domains into NDP_NEW_DOMAINS table */
|
/* Insert new domains into NDP_NEW_DOMAINS table */
|
||||||
try (var insertStmt = conn.prepareStatement("""
|
try (var insertStmt = conn.prepareStatement("""
|
||||||
INSERT IGNORE INTO NDP_NEW_DOMAINS (DOMAIN_ID, PRIORITY) VALUES (?, ?)
|
INSERT INTO NDP_NEW_DOMAINS (DOMAIN_ID, PRIORITY) VALUES (?, ?)
|
||||||
|
ON CONFLICT(DOMAIN_ID) DO UPDATE SET PRIORITY = excluded.PRIORITY
|
||||||
""")) {
|
""")) {
|
||||||
conn.setAutoCommit(false);
|
conn.setAutoCommit(false);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user