Skip to content

Commit bbf6593

Browse files
committed
Merge branch 'feature/typenormalization' of github.com:libris/librisxl into feature/typenormalization
2 parents c6b477c + 26c647d commit bbf6593

File tree

73 files changed

+3763
-2947
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+3763
-2947
lines changed

gradle.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ httpComponentsCoreVersion = 5.3.6
1212
httpComponentsClientVersion = 5.5
1313
systemProp.https.protocols=TLSv1.1,TLSv1.2
1414
guavaVersion=33.5.0-jre
15-
jacocoVersion=0.8.11
15+
jacocoVersion=0.8.11
16+
jacksonVersion=2.20.1

housekeeping/src/main/groovy/whelk/housekeeping/NotificationGenerator.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package whelk.housekeeping
22

3-
import org.codehaus.jackson.map.JsonMappingException
3+
import com.fasterxml.jackson.databind.JsonMappingException
44
import whelk.Document
55
import whelk.IdGenerator
66
import whelk.JsonLd

importers/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ dependencies {
7171

7272
// Common tools
7373
implementation "org.apache.groovy:groovy-all:${groovyVersion}"
74-
implementation 'org.codehaus.jackson:jackson-mapper-asl:1.9.12'
74+
implementation "com.fasterxml.jackson.core:jackson-databind:${jacksonVersion}"
7575

7676
// Integration
7777
implementation 'mysql:mysql-connector-java:8.0.17'

importers/src/main/groovy/whelk/reindexer/ElasticReindexer.groovy

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ import whelk.util.BlockingThreadPool
77

88
@Log
99
class ElasticReindexer {
10-
1110
static final int BATCH_SIZE = 300
1211
static final int MAX_RETRIES = 5
13-
static final int RETRY_WAIT_MS = 3000
12+
static final int INITIAL_RETRY_WAIT_MS = 3000
13+
static final int MAX_RETRY_WAIT_MS = 60000
1414

1515
Whelk whelk
1616

@@ -106,12 +106,14 @@ class ElasticReindexer {
106106

107107
private void bulkIndexWithRetries(List<Document> docs, Whelk whelk) {
108108
int retriesLeft = MAX_RETRIES
109+
int retryCount = 0
109110

110111
Exception error
111112
while(error = tryBulkIndex(docs, whelk)) {
112113
if (retriesLeft-- > 0) {
113-
log.warn("Failed to index batch: [${error}], retrying after ${RETRY_WAIT_MS} ms")
114-
sleep()
114+
int waitMs = calculateBackoffMs(retryCount++)
115+
log.warn("Failed to index batch: [${error}], retrying after ${waitMs} ms")
116+
sleep(waitMs)
115117
} else {
116118
log.warn("Failed to index batch: [${error}], max retries exceeded")
117119
throw error
@@ -129,9 +131,16 @@ class ElasticReindexer {
129131
}
130132
}
131133

132-
private void sleep() {
134+
private int calculateBackoffMs(int retryCount) {
135+
int backoffMs = (int) (Math.pow(2, retryCount) * INITIAL_RETRY_WAIT_MS)
136+
int cappedBackoffMs = Math.min(backoffMs, MAX_RETRY_WAIT_MS)
137+
int jitter = (int) (Math.random() * cappedBackoffMs * 0.2)
138+
return cappedBackoffMs + jitter
139+
}
140+
141+
private void sleep(int ms) {
133142
try {
134-
Thread.sleep(RETRY_WAIT_MS)
143+
Thread.sleep(ms)
135144
}
136145
catch (InterruptedException e) {
137146
log.warn("Woke up early", e)

librisxl-tools/examples/OaiPmhToJsonLdDataset.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import groovy.xml.XmlUtil
2-
import org.codehaus.jackson.map.ObjectMapper
2+
import com.fasterxml.jackson.databind.ObjectMapper
33
import whelk.importer.BasicOaiPmhImporter
44
import whelk.converter.MarcJSONConverter
55
import whelk.plugin.JsonLdToTurtle

rest/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ dependencies {
7878
implementation "org.apache.httpcomponents.core5:httpcore5:${httpComponentsCoreVersion}"
7979
implementation 'commons-cli:commons-cli:1.2'
8080
implementation 'commons-io:commons-io:2.20.0'
81-
implementation 'org.codehaus.jackson:jackson-core-asl:1.9.13'
82-
implementation 'org.codehaus.jackson:jackson-mapper-asl:1.9.13'
81+
implementation "com.fasterxml.jackson.core:jackson-core:${jacksonVersion}"
82+
implementation "com.fasterxml.jackson.core:jackson-databind:${jacksonVersion}"
8383
implementation 'xml-apis:xml-apis:1.4.01'
8484

8585
// metrics

rest/src/main/groovy/se/kb/libris/digi/DigitalReproductionAPI.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ package se.kb.libris.digi
22

33
import groovy.transform.MapConstructor
44
import groovy.util.logging.Log4j2 as Log
5-
import org.codehaus.jackson.JsonParseException
6-
import org.codehaus.jackson.map.ObjectMapper
5+
import com.fasterxml.jackson.core.JsonParseException
6+
import com.fasterxml.jackson.databind.ObjectMapper
77
import whelk.Configuration
88

99
import javax.servlet.ServletException

rest/src/main/groovy/whelk/rest/api/ConverterAPI.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import org.apache.hc.core5.http.ContentType;
44
import org.apache.logging.log4j.LogManager;
55
import org.apache.logging.log4j.Logger;
6-
import org.codehaus.jackson.map.ObjectMapper;
6+
import com.fasterxml.jackson.databind.ObjectMapper;
77
import whelk.Document;
88
import whelk.Whelk;
99
import whelk.converter.marc.MarcFrameConverter;

rest/src/main/groovy/whelk/rest/api/Crud.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,8 @@
1010
import whelk.JsonLdValidator;
1111
import whelk.TargetVocabMapper;
1212
import whelk.Whelk;
13-
import whelk.component.PostgreSQLComponent;
1413
import whelk.exception.ElasticIOException;
1514
import whelk.exception.InvalidQueryException;
16-
import whelk.exception.StaleUpdateException;
1715
import whelk.exception.UnexpectedHttpStatusException;
1816
import whelk.exception.WhelkRuntimeException;
1917
import whelk.history.History;
@@ -35,8 +33,6 @@
3533
import java.lang.management.ManagementFactory;
3634
import java.net.URI;
3735
import java.util.*;
38-
import java.util.concurrent.ConcurrentHashMap;
39-
import java.util.stream.Collectors;
4036

4137
import static whelk.rest.api.CrudUtils.ETag;
4238
import static whelk.util.Jackson.mapper;
@@ -160,6 +156,9 @@ public void handleQuery(HttpServletRequest request, HttpServletResponse response
160156
} catch (InvalidQueryException e) {
161157
log.info("Invalid query: {}", queryParameters);
162158
throw new BadRequestException("Invalid query, please check the documentation. " + e.getMessage());
159+
} catch (IOException e) {
160+
log.error("IOException during query: {}", e.toString(), e);
161+
throw new WhelkRuntimeException("IOException during query.", e);
163162
}
164163
}
165164

rest/src/main/groovy/whelk/rest/api/CrudGetRequest.groovy

Lines changed: 0 additions & 181 deletions
This file was deleted.

0 commit comments

Comments
 (0)