use of org.apache.nifi.controller.ReportingTaskNode in project nifi by apache.
the class ReportingTaskAuditor method createReportingTaskAdvice.
/**
* Audits the creation of reporting task via createReportingTask().
*
* This method only needs to be run 'after returning'. However, in Java 7 the order in which these methods are returned from Class.getDeclaredMethods (even though there is no order guaranteed)
* seems to differ from Java 6. SpringAOP depends on this ordering to determine advice precedence. By normalizing all advice into Around advice we can alleviate this issue.
*
* @param proceedingJoinPoint joinpoint
* @return node
* @throws java.lang.Throwable ex
*/
@Around("within(org.apache.nifi.web.dao.ReportingTaskDAO+) && " + "execution(org.apache.nifi.controller.ReportingTaskNode createReportingTask(org.apache.nifi.web.api.dto.ReportingTaskDTO))")
public ReportingTaskNode createReportingTaskAdvice(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
// update the reporting task state
ReportingTaskNode reportingTask = (ReportingTaskNode) proceedingJoinPoint.proceed();
// if no exceptions were thrown, add the reporting task action...
final Action action = generateAuditRecord(reportingTask, Operation.Add);
// save the actions
if (action != null) {
saveAction(action, logger);
}
return reportingTask;
}
use of org.apache.nifi.controller.ReportingTaskNode in project nifi by apache.
the class ReportingTaskAuditor method removeReportingTaskAdvice.
/**
* Audits the removal of a reporting task via deleteReportingTask().
*
* @param proceedingJoinPoint join point
* @param reportingTaskId task id
* @param reportingTaskDAO task dao
* @throws Throwable ex
*/
@Around("within(org.apache.nifi.web.dao.ReportingTaskDAO+) && " + "execution(void deleteReportingTask(java.lang.String)) && " + "args(reportingTaskId) && " + "target(reportingTaskDAO)")
public void removeReportingTaskAdvice(ProceedingJoinPoint proceedingJoinPoint, String reportingTaskId, ReportingTaskDAO reportingTaskDAO) throws Throwable {
// get the reporting task before removing it
ReportingTaskNode reportingTask = reportingTaskDAO.getReportingTask(reportingTaskId);
// remove the reporting task
proceedingJoinPoint.proceed();
// if no exceptions were thrown, add removal actions...
// audit the reporting task removal
final Action action = generateAuditRecord(reportingTask, Operation.Remove);
// save the actions
if (action != null) {
saveAction(action, logger);
}
}
use of org.apache.nifi.controller.ReportingTaskNode in project nifi by apache.
the class StandardFlowSerializer method serialize.
@Override
public void serialize(final FlowController controller, final OutputStream os, final ScheduledStateLookup scheduledStateLookup) throws FlowSerializationException {
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");
rootNode.setAttribute("encoding-version", MAX_ENCODING_VERSION);
doc.appendChild(rootNode);
addTextElement(rootNode, "maxTimerDrivenThreadCount", controller.getMaxTimerDrivenThreadCount());
addTextElement(rootNode, "maxEventDrivenThreadCount", controller.getMaxEventDrivenThreadCount());
final Element registriesElement = doc.createElement("registries");
rootNode.appendChild(registriesElement);
addFlowRegistries(registriesElement, controller.getFlowRegistryClient());
addProcessGroup(rootNode, controller.getGroup(controller.getRootGroupId()), "rootGroup", scheduledStateLookup);
// Add root-level controller services
final Element controllerServicesNode = doc.createElement("controllerServices");
rootNode.appendChild(controllerServicesNode);
for (final ControllerServiceNode serviceNode : controller.getRootControllerServices()) {
addControllerService(controllerServicesNode, serviceNode);
}
final Element reportingTasksNode = doc.createElement("reportingTasks");
rootNode.appendChild(reportingTasksNode);
for (final ReportingTaskNode taskNode : controller.getAllReportingTasks()) {
addReportingTask(reportingTasksNode, taskNode, encryptor);
}
final DOMSource domSource = new DOMSource(doc);
final StreamResult streamResult = new StreamResult(new BufferedOutputStream(os));
// configure the transformer and convert the DOM
final TransformerFactory transformFactory = TransformerFactory.newInstance();
final Transformer transformer = transformFactory.newTransformer();
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
// transform the document to byte stream
transformer.transform(domSource, streamResult);
} catch (final ParserConfigurationException | DOMException | TransformerFactoryConfigurationError | IllegalArgumentException | TransformerException e) {
throw new FlowSerializationException(e);
}
}
use of org.apache.nifi.controller.ReportingTaskNode in project nifi by apache.
the class StandardControllerServiceProvider method verifyCanScheduleReferencingComponents.
@Override
public void verifyCanScheduleReferencingComponents(final ControllerServiceNode serviceNode) {
final List<ControllerServiceNode> referencingServices = serviceNode.getReferences().findRecursiveReferences(ControllerServiceNode.class);
final List<ReportingTaskNode> referencingReportingTasks = serviceNode.getReferences().findRecursiveReferences(ReportingTaskNode.class);
final List<ProcessorNode> referencingProcessors = serviceNode.getReferences().findRecursiveReferences(ProcessorNode.class);
final Set<ControllerServiceNode> referencingServiceSet = new HashSet<>(referencingServices);
for (final ReportingTaskNode taskNode : referencingReportingTasks) {
if (taskNode.getScheduledState() != ScheduledState.DISABLED) {
taskNode.verifyCanStart(referencingServiceSet);
}
}
for (final ProcessorNode procNode : referencingProcessors) {
if (procNode.getScheduledState() != ScheduledState.DISABLED) {
procNode.verifyCanStart(referencingServiceSet);
}
}
}
use of org.apache.nifi.controller.ReportingTaskNode in project nifi by apache.
the class StandardControllerServiceProvider method scheduleReferencingComponents.
@Override
public Set<ConfiguredComponent> scheduleReferencingComponents(final ControllerServiceNode serviceNode) {
// find all of the schedulable components (processors, reporting tasks) that refer to this Controller Service,
// or a service that references this controller service, etc.
final List<ProcessorNode> processors = serviceNode.getReferences().findRecursiveReferences(ProcessorNode.class);
final List<ReportingTaskNode> reportingTasks = serviceNode.getReferences().findRecursiveReferences(ReportingTaskNode.class);
final Set<ConfiguredComponent> updated = new HashSet<>();
// verify that we can start all components (that are not disabled) before doing anything
for (final ProcessorNode node : processors) {
if (node.getScheduledState() != ScheduledState.DISABLED) {
node.verifyCanStart();
updated.add(node);
}
}
for (final ReportingTaskNode node : reportingTasks) {
if (node.getScheduledState() != ScheduledState.DISABLED) {
node.verifyCanStart();
updated.add(node);
}
}
// start all of the components that are not disabled
for (final ProcessorNode node : processors) {
if (node.getScheduledState() != ScheduledState.DISABLED) {
node.getProcessGroup().startProcessor(node, true);
updated.add(node);
}
}
for (final ReportingTaskNode node : reportingTasks) {
if (node.getScheduledState() != ScheduledState.DISABLED) {
processScheduler.schedule(node);
updated.add(node);
}
}
return updated;
}
Aggregations