-
Notifications
You must be signed in to change notification settings - Fork 2k
fix(rdf): ensure Fuseki dataset before indexing and report failures correctly #27630
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -142,6 +142,19 @@ public void execute(JobExecutionContext jobExecutionContext) { | |
| return; | ||
| } | ||
|
|
||
| try { | ||
| rdfRepository.ensureStorageReady(); | ||
| } catch (Exception e) { | ||
| LOG.error("RDF storage is not ready; aborting indexing job", e); | ||
| updateJobStatus(EventPublisherJob.Status.FAILED); | ||
| jobData.setFailure( | ||
| new IndexingError() | ||
| .withErrorSource(IndexingError.ErrorSource.JOB) | ||
| .withMessage("RDF storage is not ready: " + e.getMessage())); | ||
| sendUpdates(jobExecutionContext, true); | ||
| return; | ||
| } | ||
|
Comment on lines
+145
to
+156
|
||
|
|
||
| String jobName = jobExecutionContext.getJobDetail().getKey().getName(); | ||
| if (jobName.equals(ON_DEMAND_JOB)) { | ||
| Map<String, Object> jsonAppConfig = JsonUtils.convertValue(jobData, Map.class); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,20 +39,26 @@ public class JenaFusekiStorage implements RdfStorageInterface { | |
|
|
||
| private final RDFConnection connection; | ||
| private final String baseUri; | ||
| private final String endpoint; | ||
| private final String username; | ||
| private final String password; | ||
|
|
||
| public JenaFusekiStorage(RdfConfiguration config) { | ||
| this.baseUri = | ||
| config.getBaseUri() != null ? config.getBaseUri().toString() : "https://open-metadata.org/"; | ||
|
|
||
| String endpoint = | ||
| this.endpoint = | ||
| config.getRemoteEndpoint() != null && !config.getRemoteEndpoint().toString().isEmpty() | ||
| ? config.getRemoteEndpoint().toString() | ||
| : "http://openmetadata-fuseki:3030/openmetadata"; | ||
| this.username = config.getUsername(); | ||
| this.password = config.getPassword(); | ||
|
|
||
| // Ensure the dataset exists before connecting | ||
| ensureDatasetExists(endpoint, config.getUsername(), config.getPassword()); | ||
| // Best-effort attempt to create the dataset at startup; callers should invoke | ||
| // ensureStorageReady() before running work to recover from later restarts of the RDF server. | ||
| ensureDatasetExists(endpoint, username, password); | ||
|
|
||
| if (config.getUsername() != null && config.getPassword() != null) { | ||
| if (username != null && password != null) { | ||
| java.net.http.HttpClient httpClient = | ||
| java.net.http.HttpClient.newBuilder() | ||
| .authenticator( | ||
|
|
@@ -74,6 +80,30 @@ protected java.net.PasswordAuthentication getPasswordAuthentication() { | |
| loadOntology(); | ||
| } | ||
|
|
||
| @Override | ||
| public void ensureStorageReady() { | ||
| if (testConnection()) { | ||
| LOG.debug("Fuseki dataset at {} is accessible", endpoint); | ||
| return; | ||
| } | ||
|
Comment on lines
+84
to
+88
|
||
|
|
||
| LOG.warn( | ||
| "Fuseki dataset at {} is not accessible; attempting to (re)create it before running", | ||
| endpoint); | ||
| ensureDatasetExists(endpoint, username, password); | ||
|
|
||
| if (!testConnection()) { | ||
|
Comment on lines
+84
to
+95
|
||
| throw new IllegalStateException( | ||
| String.format( | ||
| "RDF storage is not accessible at %s after attempting dataset creation. " | ||
| + "Verify the configured RDF endpoint URL, credentials, that the Fuseki dataset " | ||
| + "exists, and that the configured user has permission to create it.", | ||
| endpoint)); | ||
| } | ||
| LOG.info("Fuseki dataset at {} is now ready", endpoint); | ||
| loadOntology(); | ||
| } | ||
|
|
||
| /** | ||
| * Ensures the Fuseki dataset exists, creating it if necessary. | ||
| * Parses the endpoint URL to extract the server base URL and dataset name, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This adds a new failure path where the job aborts early if
rdfRepository.ensureStorageReady()throws. Since there are existing unit tests coveringexecute()behavior inRdfIndexAppTest, it would be good to add/adjust tests to assert that (1) job status becomes FAILED and (2)jobData.failureis populated with anIndexingErrormessage when storage readiness checks fail.