com.marklogic.hub.provenance.ProvenanceManager Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of marklogic-data-hub Show documentation
Show all versions of marklogic-data-hub Show documentation
Library for Creating an Operational Data Hub on MarkLogic
package com.marklogic.hub.provenance;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.marklogic.client.DatabaseClient;
import com.marklogic.hub.DatabaseKind;
import com.marklogic.hub.HubClient;
import com.marklogic.hub.dataservices.BulkUtil;
public class ProvenanceManager {
private static final ObjectMapper objectMapper = new ObjectMapper();
private final HubClient hubClient;
public ProvenanceManager(HubClient hubClient) {
this.hubClient = hubClient;
}
public void deleteProvenanceRecords(String retainDuration) {
deleteProvenanceRecords(retainDuration, DatabaseKind.JOB.name());
}
public void deleteProvenanceRecords(String retainDuration, String database) {
String apiPath = "ml-modules/root/data-hub/data-services/provenance/deleteProvenance.api";
DatabaseKind databaseKind = DatabaseKind.valueOf(database);
DatabaseClient client;
switch (databaseKind) {
case JOB: client = hubClient.getJobsClient();
break;
case STAGING: client = hubClient.getStagingClient();
break;
case FINAL: client = hubClient.getFinalClient();
break;
default: throw new RuntimeException("Invalid provenance database: " + database);
}
BulkUtil.deleteData(client, apiPath, retainDuration);
}
public void migrateProvenanceRecords() {
String apiPath = "ml-modules/root/data-hub/data-services/provenance/migrateProvenance.api";
ObjectNode endpointConstants = objectMapper.createObjectNode().put("batchSize", 250);
BulkUtil.runExecCaller(hubClient.getJobsClient(), apiPath, endpointConstants, "Unable to migrate provenance, cause: ");
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy