use of org.apache.nifi.controller.ReportingTaskNode in project nifi by apache.
the class StandardControllerServiceProvider method getControllerServiceForComponent.
@Override
public ControllerService getControllerServiceForComponent(final String serviceIdentifier, final String componentId) {
// Find the Process Group that owns the component.
ProcessGroup groupOfInterest = null;
final ProcessorNode procNode = flowController.getProcessorNode(componentId);
if (procNode == null) {
final ControllerServiceNode serviceNode = getControllerServiceNode(componentId);
if (serviceNode == null) {
final ReportingTaskNode taskNode = flowController.getReportingTaskNode(componentId);
if (taskNode == null) {
throw new IllegalStateException("Could not find any Processor, Reporting Task, or Controller Service with identifier " + componentId);
}
// we have confirmed that the component is a reporting task. We can only reference Controller Services
// that are scoped at the FlowController level in this case.
final ControllerServiceNode rootServiceNode = flowController.getRootControllerService(serviceIdentifier);
return (rootServiceNode == null) ? null : rootServiceNode.getProxiedControllerService();
} else {
groupOfInterest = serviceNode.getProcessGroup();
}
} else {
groupOfInterest = procNode.getProcessGroup();
}
if (groupOfInterest == null) {
final ControllerServiceNode rootServiceNode = flowController.getRootControllerService(serviceIdentifier);
return (rootServiceNode == null) ? null : rootServiceNode.getProxiedControllerService();
}
final Set<ControllerServiceNode> servicesForGroup = groupOfInterest.getControllerServices(true);
for (final ControllerServiceNode serviceNode : servicesForGroup) {
if (serviceIdentifier.equals(serviceNode.getIdentifier())) {
return serviceNode.getProxiedControllerService();
}
}
return null;
}
use of org.apache.nifi.controller.ReportingTaskNode in project nifi-minifi by apache.
the class StatusConfigReporterTest method populateReportingTask.
private void populateReportingTask(boolean addBulletins, boolean validationErrors) {
if (addBulletins) {
addBulletins("Bulletin message", "ReportProvenance");
}
ReportingTaskNode reportingTaskNode = mock(ReportingTaskNode.class);
addReportingTaskNodeVariables(reportingTaskNode);
HashSet<ReportingTaskNode> reportingTaskNodes = new HashSet<>();
reportingTaskNodes.add(reportingTaskNode);
when(mockFlowController.getAllReportingTasks()).thenReturn(reportingTaskNodes);
if (validationErrors) {
ValidationResult validationResult = new ValidationResult.Builder().input("input").subject("subject").explanation("is not valid").build();
ValidationResult validationResult2 = new ValidationResult.Builder().input("input2").subject("subject2").explanation("is not valid too").build();
List<ValidationResult> validationResultList = new ArrayList<>();
validationResultList.add(validationResult);
validationResultList.add(validationResult2);
when(reportingTaskNode.getValidationErrors()).thenReturn(validationResultList);
} else {
when(reportingTaskNode.getValidationErrors()).thenReturn(Collections.EMPTY_LIST);
}
}
use of org.apache.nifi.controller.ReportingTaskNode in project nifi by apache.
the class StandardNiFiServiceFacade method createReportingTask.
@Override
public ReportingTaskEntity createReportingTask(final Revision revision, final ReportingTaskDTO reportingTaskDTO) {
final NiFiUser user = NiFiUserUtils.getNiFiUser();
// request claim for component to be created... revision already verified (version == 0)
final RevisionClaim claim = new StandardRevisionClaim(revision);
// update revision through revision manager
final RevisionUpdate<ReportingTaskDTO> snapshot = revisionManager.updateRevision(claim, user, () -> {
// create the reporting task
final ReportingTaskNode reportingTask = reportingTaskDAO.createReportingTask(reportingTaskDTO);
// save the update
controllerFacade.save();
final ReportingTaskDTO dto = dtoFactory.createReportingTaskDto(reportingTask);
final FlowModification lastMod = new FlowModification(revision.incrementRevision(revision.getClientId()), user.getIdentity());
return new StandardRevisionUpdate<>(dto, lastMod);
});
final ReportingTaskNode reportingTask = reportingTaskDAO.getReportingTask(reportingTaskDTO.getId());
final PermissionsDTO permissions = dtoFactory.createPermissionsDto(reportingTask);
final List<BulletinDTO> bulletins = dtoFactory.createBulletinDtos(bulletinRepository.findBulletinsForSource(reportingTask.getIdentifier()));
final List<BulletinEntity> bulletinEntities = bulletins.stream().map(bulletin -> entityFactory.createBulletinEntity(bulletin, permissions.getCanRead())).collect(Collectors.toList());
return entityFactory.createReportingTaskEntity(snapshot.getComponent(), dtoFactory.createRevisionDTO(snapshot.getLastModification()), permissions, bulletinEntities);
}
use of org.apache.nifi.controller.ReportingTaskNode in project nifi by apache.
the class StandardNiFiServiceFacade method deleteReportingTask.
@Override
public ReportingTaskEntity deleteReportingTask(final Revision revision, final String reportingTaskId) {
final ReportingTaskNode reportingTask = reportingTaskDAO.getReportingTask(reportingTaskId);
final PermissionsDTO permissions = dtoFactory.createPermissionsDto(reportingTask);
final ReportingTaskDTO snapshot = deleteComponent(revision, reportingTask.getResource(), () -> reportingTaskDAO.deleteReportingTask(reportingTaskId), true, dtoFactory.createReportingTaskDto(reportingTask));
return entityFactory.createReportingTaskEntity(snapshot, null, permissions, null);
}
use of org.apache.nifi.controller.ReportingTaskNode in project nifi by apache.
the class TestStandardReportingContext method testGetPropertyReportingTask.
@Test
public void testGetPropertyReportingTask() throws ReportingTaskInstantiationException {
ReportingTaskNode reportingTask = controller.createReportingTask(DummyScheduledReportingTask.class.getName(), systemBundle.getBundleDetails().getCoordinate());
PropertyDescriptor TEST_WITHOUT_DEFAULT_VALUE = new PropertyDescriptor.Builder().name("Test without default value").build();
PropertyDescriptor TEST_WITH_DEFAULT_VALUE = new PropertyDescriptor.Builder().name("Test with default value").build();
PropertyValue defaultValue = reportingTask.getReportingContext().getProperty(TEST_WITH_DEFAULT_VALUE);
assertEquals("nifi", defaultValue.getValue());
PropertyValue value = reportingTask.getReportingContext().getProperty(TEST_WITHOUT_DEFAULT_VALUE);
assertEquals(null, value.getValue());
}
Aggregations