Skip to content

Commit f72c49a

Browse files
committed
fixup! GH-4952 - Introduce FedXConfig overrides for FedXRepositoryConfig
1 parent 5a160df commit f72c49a

3 files changed

Lines changed: 182 additions & 17 deletions

File tree

tools/federation/src/main/java/org/eclipse/rdf4j/federated/repository/FedXRepositoryConfig.java

Lines changed: 90 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,36 @@ public class FedXRepositoryConfig extends AbstractRepositoryImplConfig {
105105
*/
106106
public static final IRI MEMBER = vf.createIRI(NAMESPACE, "member");
107107

108+
/**
109+
* IRI of the property populating {@link FedXConfig#getJoinWorkerThreads()}
110+
*/
111+
public static final IRI CONFIG_JOIN_WORKER_THREADS = vf.createIRI(NAMESPACE, "joinWorkerThreads");
112+
113+
/**
114+
* IRI of the property populating {@link FedXConfig#getUnionWorkerThreads()}
115+
*/
116+
public static final IRI CONFIG_UNION_WORKER_THREADS = vf.createIRI(NAMESPACE, "unionWorkerThreads");
117+
118+
/**
119+
* IRI of the property populating {@link FedXConfig#getLeftJoinWorkerThreads()}
120+
*/
121+
public static final IRI CONFIG_LEFT_JOIN_WORKER_THREADS = vf.createIRI(NAMESPACE, "leftJoinWorkerThreads");
122+
123+
/**
124+
* IRI of the property populating {@link FedXConfig#getBoundJoinBlockSize()}
125+
*/
126+
public static final IRI CONFIG_BOUND_JOIN_BLOCK_SIZE = vf.createIRI(NAMESPACE, "boundJoinBlockSize");
127+
108128
/**
109129
* IRI of the property populating {@link FedXConfig#getEnforceMaxQueryTime()}
110130
*/
111131
public static final IRI CONFIG_ENFORCE_MAX_QUERY_TIME = vf.createIRI(NAMESPACE, "enforceMaxQueryTime");
112132

133+
/**
134+
* IRI of the property populating {@link FedXConfig#getEnableServiceAsBoundJoin()}
135+
*/
136+
public static final IRI CONFIG_ENABLE_SERVICE_AS_BOUND_JOIN = vf.createIRI(NAMESPACE, "enableServiceAsBoundJoin");
137+
113138
/**
114139
* IRI of the property populating {@link FedXConfig#isEnableMonitoring()}
115140
*/
@@ -120,21 +145,36 @@ public class FedXRepositoryConfig extends AbstractRepositoryImplConfig {
120145
*/
121146
public static final IRI CONFIG_LOG_QUERY_PLAN = vf.createIRI(NAMESPACE, "logQueryPlan");
122147

148+
/**
149+
* IRI of the property populating {@link FedXConfig#isLogQueries()}
150+
*/
151+
public static final IRI CONFIG_LOG_QUERIES = vf.createIRI(NAMESPACE, "logQueries");
152+
123153
/**
124154
* IRI of the property populating {@link FedXConfig#isDebugQueryPlan()}
125155
*/
126156
public static final IRI CONFIG_DEBUG_QUERY_PLAN = vf.createIRI(NAMESPACE, "debugQueryPlan");
127157

128158
/**
129-
* IRI of the property populating {@link FedXConfig#isLogQueries()}
159+
* IRI of the property populating {@link FedXConfig#getIncludeInferredDefault()}
130160
*/
131-
public static final IRI CONFIG_LOG_QUERIES = vf.createIRI(NAMESPACE, "logQueries");
161+
public static final IRI CONFIG_INCLUDE_INFERRED_DEFAULT = vf.createIRI(NAMESPACE, "includeInferredDefault");
132162

133163
/**
134164
* IRI of the property populating {@link FedXConfig#getSourceSelectionCacheSpec()}
135165
*/
136166
public static final IRI CONFIG_SOURCE_SELECTION_CACHE_SPEC = vf.createIRI(NAMESPACE, "sourceSelectionCacheSpec");
137167

168+
/**
169+
* IRI of the property populating {@link FedXConfig#getPrefixDeclarations()}
170+
*/
171+
public static final IRI CONFIG_PREFIX_DECLARATIONS = vf.createIRI(NAMESPACE, "prefixDeclarations");
172+
173+
/**
174+
* IRI of the property populating {@link FedXConfig#getConsumingIterationMax()}
175+
*/
176+
public static final IRI CONFIG_CONSUMING_ITERATION_MAX = vf.createIRI(NAMESPACE, "consumingIterationMax");
177+
138178
/**
139179
* the location of the data configuration
140180
*/
@@ -273,23 +313,48 @@ private void parseFedXConfigInternal(Model m, Resource confNode) throws Reposito
273313
setConfig(new FedXConfig());
274314
}
275315

316+
Models.objectLiteral(m.getStatements(confNode, CONFIG_JOIN_WORKER_THREADS, null))
317+
.ifPresent(value -> config.withJoinWorkerThreads(value.intValue()));
318+
319+
Models.objectLiteral(m.getStatements(confNode, CONFIG_UNION_WORKER_THREADS, null))
320+
.ifPresent(value -> config.withUnionWorkerThreads(value.intValue()));
321+
322+
Models.objectLiteral(m.getStatements(confNode, CONFIG_LEFT_JOIN_WORKER_THREADS, null))
323+
.ifPresent(value -> config.withLeftJoinWorkerThreads(value.intValue()));
324+
325+
Models.objectLiteral(m.getStatements(confNode, CONFIG_BOUND_JOIN_BLOCK_SIZE, null))
326+
.ifPresent(value -> config.withBoundJoinBlockSize(value.intValue()));
327+
276328
Models.objectLiteral(m.getStatements(confNode, CONFIG_ENFORCE_MAX_QUERY_TIME, null))
277329
.ifPresent(value -> config.withEnforceMaxQueryTime(value.intValue()));
278330

331+
Models.objectLiteral(m.getStatements(confNode, CONFIG_ENABLE_SERVICE_AS_BOUND_JOIN, null))
332+
.ifPresent(value -> config.withEnableServiceAsBoundJoin(value.booleanValue()));
333+
279334
Models.objectLiteral(m.getStatements(confNode, CONFIG_ENABLE_MONITORING, null))
280335
.ifPresent(value -> config.withEnableMonitoring(value.booleanValue()));
281336

282337
Models.objectLiteral(m.getStatements(confNode, CONFIG_LOG_QUERY_PLAN, null))
283338
.ifPresent(value -> config.withLogQueryPlan(value.booleanValue()));
284339

340+
Models.objectLiteral(m.getStatements(confNode, CONFIG_LOG_QUERIES, null))
341+
.ifPresent(value -> config.withLogQueries(value.booleanValue()));
342+
285343
Models.objectLiteral(m.getStatements(confNode, CONFIG_DEBUG_QUERY_PLAN, null))
286344
.ifPresent(value -> config.withDebugQueryPlan(value.booleanValue()));
287345

288-
Models.objectLiteral(m.getStatements(confNode, CONFIG_LOG_QUERIES, null))
289-
.ifPresent(value -> config.withLogQueries(value.booleanValue()));
346+
Models.objectLiteral(m.getStatements(confNode, CONFIG_INCLUDE_INFERRED_DEFAULT, null))
347+
.ifPresent(value -> config.withIncludeInferredDefault(value.booleanValue()));
290348

291349
Models.objectLiteral(m.getStatements(confNode, CONFIG_SOURCE_SELECTION_CACHE_SPEC, null))
292350
.ifPresent(value -> config.withSourceSelectionCacheSpec(value.stringValue()));
351+
352+
Models.objectLiteral(m.getStatements(confNode, CONFIG_PREFIX_DECLARATIONS, null))
353+
.ifPresent(value -> config.withPrefixDeclarations(value.stringValue()));
354+
355+
Models.objectLiteral(m.getStatements(confNode, CONFIG_CONSUMING_ITERATION_MAX, null))
356+
.ifPresent(value -> config.withConsumingIterationMax(value.intValue()));
357+
293358
}
294359

295360
/**
@@ -306,21 +371,41 @@ protected void exportFedXConfig(Model model, Resource implNode) {
306371

307372
BNode confNode = Values.bnode();
308373

374+
model.add(confNode, CONFIG_JOIN_WORKER_THREADS, vf.createLiteral(config.getJoinWorkerThreads()));
375+
376+
model.add(confNode, CONFIG_UNION_WORKER_THREADS, vf.createLiteral(config.getUnionWorkerThreads()));
377+
378+
model.add(confNode, CONFIG_LEFT_JOIN_WORKER_THREADS, vf.createLiteral(config.getLeftJoinWorkerThreads()));
379+
380+
model.add(confNode, CONFIG_BOUND_JOIN_BLOCK_SIZE, vf.createLiteral(config.getBoundJoinBlockSize()));
381+
309382
model.add(confNode, CONFIG_ENFORCE_MAX_QUERY_TIME, vf.createLiteral(config.getEnforceMaxQueryTime()));
310383

384+
model.add(confNode, CONFIG_ENABLE_SERVICE_AS_BOUND_JOIN,
385+
vf.createLiteral(config.getEnableServiceAsBoundJoin()));
386+
311387
model.add(confNode, CONFIG_ENABLE_MONITORING, vf.createLiteral(config.isEnableMonitoring()));
312388

313389
model.add(confNode, CONFIG_LOG_QUERY_PLAN, vf.createLiteral(config.isLogQueryPlan()));
314390

391+
model.add(confNode, CONFIG_LOG_QUERIES, vf.createLiteral(config.isLogQueries()));
392+
315393
model.add(confNode, CONFIG_DEBUG_QUERY_PLAN, vf.createLiteral(config.isDebugQueryPlan()));
316394

317-
model.add(confNode, CONFIG_LOG_QUERIES, vf.createLiteral(config.isLogQueries()));
395+
model.add(confNode, CONFIG_INCLUDE_INFERRED_DEFAULT, vf.createLiteral(config.getIncludeInferredDefault()));
318396

319397
if (config.getSourceSelectionCacheSpec() != null) {
320398
model.add(confNode, CONFIG_SOURCE_SELECTION_CACHE_SPEC,
321399
vf.createLiteral(config.getSourceSelectionCacheSpec()));
322400
}
323401

402+
if (config.getPrefixDeclarations() != null) {
403+
model.add(confNode, CONFIG_PREFIX_DECLARATIONS,
404+
vf.createLiteral(config.getPrefixDeclarations()));
405+
}
406+
407+
model.add(confNode, CONFIG_CONSUMING_ITERATION_MAX, vf.createLiteral(config.getConsumingIterationMax()));
408+
324409
model.add(implNode, FEDX_CONFIG, confNode);
325410
}
326411
}

tools/federation/src/test/java/org/eclipse/rdf4j/federated/repository/FedXRepositoryConfigTest.java

Lines changed: 81 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public void testParse() throws Exception {
103103
repoConfig.parse(model, implNode(model));
104104
FedXConfig config = repoConfig.getConfig();
105105

106-
assertThat(config.getEnforceMaxQueryTime()).isEqualTo(1234);
106+
assertThat(config.getEnforceMaxQueryTime()).isEqualTo(105);
107107
assertThat(config.isEnableMonitoring()).isTrue();
108108
assertThat(config.isLogQueryPlan()).isTrue();
109109
assertThat(config.isDebugQueryPlan()).isTrue();
@@ -120,7 +120,7 @@ public void testParseConfigOverridesExistingConfig() throws Exception {
120120
repoConfig.parse(model, implNode(model));
121121
FedXConfig config = repoConfig.getConfig();
122122

123-
assertThat(config.getEnforceMaxQueryTime()).isEqualTo(1234);
123+
assertThat(config.getEnforceMaxQueryTime()).isEqualTo(105);
124124
assertThat(config.isEnableMonitoring()).isTrue();
125125
assertThat(config.isLogQueryPlan()).isTrue();
126126
assertThat(config.isDebugQueryPlan()).isTrue();
@@ -161,12 +161,34 @@ public void testExport() throws Exception {
161161
.orElse(null);
162162
assertThat(configNode).isNotNull();
163163

164-
assertThat(export.filter(configNode, null, null)).hasSize(6);
164+
assertThat(export.filter(configNode, null, null)).hasSize(14);
165165

166+
assertThat(
167+
Models.objectLiteral(
168+
export.getStatements(configNode, FedXRepositoryConfig.CONFIG_JOIN_WORKER_THREADS, null)))
169+
.hasValueSatisfying(v -> assertThat(v.intValue()).isEqualTo(101));
170+
assertThat(
171+
Models.objectLiteral(
172+
export.getStatements(configNode, FedXRepositoryConfig.CONFIG_UNION_WORKER_THREADS, null)))
173+
.hasValueSatisfying(v -> assertThat(v.intValue()).isEqualTo(102));
174+
assertThat(
175+
Models.objectLiteral(
176+
export.getStatements(configNode, FedXRepositoryConfig.CONFIG_LEFT_JOIN_WORKER_THREADS,
177+
null)))
178+
.hasValueSatisfying(v -> assertThat(v.intValue()).isEqualTo(103));
179+
assertThat(
180+
Models.objectLiteral(
181+
export.getStatements(configNode, FedXRepositoryConfig.CONFIG_BOUND_JOIN_BLOCK_SIZE, null)))
182+
.hasValueSatisfying(v -> assertThat(v.intValue()).isEqualTo(104));
166183
assertThat(
167184
Models.objectLiteral(
168185
export.getStatements(configNode, FedXRepositoryConfig.CONFIG_ENFORCE_MAX_QUERY_TIME, null)))
169-
.hasValueSatisfying(v -> assertThat(v.intValue()).isEqualTo(1234));
186+
.hasValueSatisfying(v -> assertThat(v.intValue()).isEqualTo(105));
187+
assertThat(
188+
Models.objectLiteral(
189+
export.getStatements(configNode, FedXRepositoryConfig.CONFIG_ENABLE_SERVICE_AS_BOUND_JOIN,
190+
null)))
191+
.hasValueSatisfying(v -> assertThat(v.booleanValue()).isFalse());
170192
assertThat(
171193
Models.objectLiteral(
172194
export.getStatements(configNode, FedXRepositoryConfig.CONFIG_ENABLE_MONITORING, null)))
@@ -177,17 +199,33 @@ public void testExport() throws Exception {
177199
.hasValueSatisfying(v -> assertThat(v.booleanValue()).isTrue());
178200
assertThat(
179201
Models.objectLiteral(
180-
export.getStatements(configNode, FedXRepositoryConfig.CONFIG_DEBUG_QUERY_PLAN, null)))
202+
export.getStatements(configNode, FedXRepositoryConfig.CONFIG_LOG_QUERIES, null)))
181203
.hasValueSatisfying(v -> assertThat(v.booleanValue()).isTrue());
182204
assertThat(
183205
Models.objectLiteral(
184-
export.getStatements(configNode, FedXRepositoryConfig.CONFIG_LOG_QUERIES, null)))
206+
export.getStatements(configNode, FedXRepositoryConfig.CONFIG_DEBUG_QUERY_PLAN, null)))
185207
.hasValueSatisfying(v -> assertThat(v.booleanValue()).isTrue());
208+
assertThat(
209+
Models.objectLiteral(
210+
export.getStatements(configNode, FedXRepositoryConfig.CONFIG_INCLUDE_INFERRED_DEFAULT,
211+
null)))
212+
.hasValueSatisfying(v -> assertThat(v.booleanValue()).isFalse());
186213
assertThat(
187214
Models.objectLiteral(
188215
export.getStatements(configNode, FedXRepositoryConfig.CONFIG_SOURCE_SELECTION_CACHE_SPEC,
189216
null)))
190217
.hasValueSatisfying(v -> assertThat(v.stringValue()).isEqualTo("spec-goes-here"));
218+
assertThat(
219+
Models.objectLiteral(
220+
export.getStatements(configNode, FedXRepositoryConfig.CONFIG_PREFIX_DECLARATIONS,
221+
null)))
222+
.hasValueSatisfying(v -> assertThat(v.stringValue()).isEqualTo("prefixes-go-here"));
223+
224+
assertThat(
225+
Models.objectLiteral(
226+
export.getStatements(configNode, FedXRepositoryConfig.CONFIG_CONSUMING_ITERATION_MAX,
227+
null)))
228+
.hasValueSatisfying(v -> assertThat(v.intValue()).isEqualTo(106));
191229
}
192230

193231
@Test
@@ -204,13 +242,36 @@ public void testExportWithEmptyConfig() throws Exception {
204242
.orElse(null);
205243
assertThat(configNode).isNotNull();
206244

207-
// Note: 5 instead of 6 since CONFIG_SOURCE_SELECTION_CACHE_SPEC is null and thus should not be populated
208-
assertThat(export.filter(configNode, null, null)).hasSize(5);
245+
// Note: 14 instead of 12 since CONFIG_SOURCE_SELECTION_CACHE_SPEC & CONFIG_PREFIX_DECLARATIONS are null
246+
// and thus should not be populated
247+
assertThat(export.filter(configNode, null, null)).hasSize(12);
209248

249+
assertThat(
250+
Models.objectLiteral(
251+
export.getStatements(configNode, FedXRepositoryConfig.CONFIG_JOIN_WORKER_THREADS, null)))
252+
.hasValueSatisfying(v -> assertThat(v.intValue()).isEqualTo(20));
253+
assertThat(
254+
Models.objectLiteral(
255+
export.getStatements(configNode, FedXRepositoryConfig.CONFIG_UNION_WORKER_THREADS, null)))
256+
.hasValueSatisfying(v -> assertThat(v.intValue()).isEqualTo(20));
257+
assertThat(
258+
Models.objectLiteral(
259+
export.getStatements(configNode, FedXRepositoryConfig.CONFIG_LEFT_JOIN_WORKER_THREADS,
260+
null)))
261+
.hasValueSatisfying(v -> assertThat(v.intValue()).isEqualTo(10));
262+
assertThat(
263+
Models.objectLiteral(
264+
export.getStatements(configNode, FedXRepositoryConfig.CONFIG_BOUND_JOIN_BLOCK_SIZE, null)))
265+
.hasValueSatisfying(v -> assertThat(v.intValue()).isEqualTo(15));
210266
assertThat(
211267
Models.objectLiteral(
212268
export.getStatements(configNode, FedXRepositoryConfig.CONFIG_ENFORCE_MAX_QUERY_TIME, null)))
213269
.hasValueSatisfying(v -> assertThat(v.intValue()).isEqualTo(30));
270+
assertThat(
271+
Models.objectLiteral(
272+
export.getStatements(configNode, FedXRepositoryConfig.CONFIG_ENABLE_SERVICE_AS_BOUND_JOIN,
273+
null)))
274+
.hasValueSatisfying(v -> assertThat(v.booleanValue()).isTrue());
214275
assertThat(
215276
Models.objectLiteral(
216277
export.getStatements(configNode, FedXRepositoryConfig.CONFIG_ENABLE_MONITORING, null)))
@@ -221,12 +282,22 @@ public void testExportWithEmptyConfig() throws Exception {
221282
.hasValueSatisfying(v -> assertThat(v.booleanValue()).isFalse());
222283
assertThat(
223284
Models.objectLiteral(
224-
export.getStatements(configNode, FedXRepositoryConfig.CONFIG_DEBUG_QUERY_PLAN, null)))
285+
export.getStatements(configNode, FedXRepositoryConfig.CONFIG_LOG_QUERIES, null)))
225286
.hasValueSatisfying(v -> assertThat(v.booleanValue()).isFalse());
226287
assertThat(
227288
Models.objectLiteral(
228-
export.getStatements(configNode, FedXRepositoryConfig.CONFIG_LOG_QUERIES, null)))
289+
export.getStatements(configNode, FedXRepositoryConfig.CONFIG_DEBUG_QUERY_PLAN, null)))
229290
.hasValueSatisfying(v -> assertThat(v.booleanValue()).isFalse());
291+
assertThat(
292+
Models.objectLiteral(
293+
export.getStatements(configNode, FedXRepositoryConfig.CONFIG_INCLUDE_INFERRED_DEFAULT,
294+
null)))
295+
.hasValueSatisfying(v -> assertThat(v.booleanValue()).isTrue());
296+
assertThat(
297+
Models.objectLiteral(
298+
export.getStatements(configNode, FedXRepositoryConfig.CONFIG_CONSUMING_ITERATION_MAX,
299+
null)))
300+
.hasValueSatisfying(v -> assertThat(v.intValue()).isEqualTo(1000));
230301
}
231302
}
232303
}

tools/federation/src/test/resources/tests/rdf4jserver/config-withFedXConfig.ttl

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,22 @@
88
[] a rep:Repository ;
99
rep:repositoryImpl [
1010
rep:repositoryType "fedx:FedXRepository" ;
11+
# All options herein should be set to non-default values
1112
fedx:config [
12-
fedx:enforceMaxQueryTime 1234 ;
13+
fedx:joinWorkerThreads 101 ;
14+
fedx:unionWorkerThreads 102 ;
15+
fedx:leftJoinWorkerThreads 103 ;
16+
fedx:boundJoinBlockSize 104 ;
17+
fedx:enforceMaxQueryTime 105 ;
18+
fedx:enableServiceAsBoundJoin false ;
1319
fedx:enableMonitoring true ;
1420
fedx:logQueryPlan true ;
15-
fedx:debugQueryPlan true ;
1621
fedx:logQueries true ;
22+
fedx:debugQueryPlan true ;
23+
fedx:includeInferredDefault false ;
1724
fedx:sourceSelectionCacheSpec "spec-goes-here" ;
25+
fedx:prefixDeclarations "prefixes-go-here" ;
26+
fedx:consumingIterationMax 106 ;
1827
];
1928
];
2029
rep:repositoryID "my-federation" ;

0 commit comments

Comments
 (0)