use of org.apache.nifi.minifi.commons.schema.ProvenanceReportingSchema in project nifi-minifi by apache.
the class ConfigTransformer method addProvenanceReportingTask.
protected static void addProvenanceReportingTask(final Element element, ConfigSchema configSchema) throws ConfigurationChangeException {
try {
ProvenanceReportingSchema provenanceProperties = configSchema.getProvenanceReportingProperties();
final Element taskElement = element.getOwnerDocument().createElement("reportingTask");
addTextElement(taskElement, "id", "Provenance-Reporting");
addTextElement(taskElement, "name", "Site-To-Site-Provenance-Reporting");
addTextElement(taskElement, "comment", provenanceProperties.getComment());
addTextElement(taskElement, "class", DEFAULT_PROV_REPORTING_TASK_CLASS);
addTextElement(taskElement, "schedulingPeriod", provenanceProperties.getSchedulingPeriod());
addTextElement(taskElement, "scheduledState", "RUNNING");
addTextElement(taskElement, "schedulingStrategy", provenanceProperties.getSchedulingStrategy());
Map<String, Object> attributes = new HashMap<>();
attributes.put("Destination URL", provenanceProperties.getDestinationUrl());
attributes.put("Input Port Name", provenanceProperties.getPortName());
attributes.put("Instance URL", provenanceProperties.getOriginatingUrl());
attributes.put("Compress Events", provenanceProperties.getUseCompression());
attributes.put("Batch Size", provenanceProperties.getBatchSize());
attributes.put("Communications Timeout", provenanceProperties.getTimeout());
SecurityPropertiesSchema securityProps = configSchema.getSecurityProperties();
if (securityProps.useSSL()) {
attributes.put("SSL Context Service", "SSL-Context-Service");
}
addConfiguration(taskElement, attributes);
element.appendChild(taskElement);
} catch (Exception e) {
throw new ConfigurationChangeException("Failed to parse the config YAML while trying to add the Provenance Reporting Task", e);
}
}
use of org.apache.nifi.minifi.commons.schema.ProvenanceReportingSchema in project nifi-minifi by apache.
the class ConfigTransformer method createFlowXml.
protected static DOMSource createFlowXml(ConfigSchema configSchema) throws IOException, ConfigurationChangeException, ConfigTransformerException {
try {
// create a new, empty document
final DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
docFactory.setNamespaceAware(true);
final DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
final Document doc = docBuilder.newDocument();
// populate document with controller state
final Element rootNode = doc.createElement("flowController");
doc.appendChild(rootNode);
CorePropertiesSchema coreProperties = configSchema.getCoreProperties();
addTextElement(rootNode, "maxTimerDrivenThreadCount", String.valueOf(coreProperties.getMaxConcurrentThreads()));
addTextElement(rootNode, "maxEventDrivenThreadCount", String.valueOf(coreProperties.getMaxConcurrentThreads()));
FlowControllerSchema flowControllerProperties = configSchema.getFlowControllerProperties();
final Element element = doc.createElement("rootGroup");
rootNode.appendChild(element);
ProcessGroupSchema processGroupSchema = configSchema.getProcessGroupSchema();
processGroupSchema.setId(ROOT_GROUP);
processGroupSchema.setName(flowControllerProperties.getName());
processGroupSchema.setComment(flowControllerProperties.getComment());
addProcessGroup(doc, element, processGroupSchema, new ParentGroupIdResolver(processGroupSchema));
SecurityPropertiesSchema securityProperties = configSchema.getSecurityProperties();
if (securityProperties.useSSL()) {
Element controllerServicesNode = doc.getElementById("controllerServices");
if (controllerServicesNode == null) {
controllerServicesNode = doc.createElement("controllerServices");
}
rootNode.appendChild(controllerServicesNode);
addSSLControllerService(controllerServicesNode, securityProperties);
}
ProvenanceReportingSchema provenanceProperties = configSchema.getProvenanceReportingProperties();
if (provenanceProperties != null) {
final Element reportingTasksNode = doc.createElement("reportingTasks");
rootNode.appendChild(reportingTasksNode);
addProvenanceReportingTask(reportingTasksNode, configSchema);
}
return new DOMSource(doc);
} catch (final ParserConfigurationException | DOMException | TransformerFactoryConfigurationError | IllegalArgumentException e) {
throw new ConfigTransformerException(e);
} catch (Exception e) {
throw new ConfigTransformerException("Failed to parse the config YAML while writing the top level of the flow xml", e);
}
}
Aggregations