Java Code Examples for org.apache.nifi.controller.service.ControllerServiceNode#getProcessGroup()

The following examples show how to use org.apache.nifi.controller.service.ControllerServiceNode#getProcessGroup() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StandardNiFiServiceFacade.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
@Override
public PropertyDescriptorDTO getControllerServicePropertyDescriptor(final String id, final String property) {
    final ControllerServiceNode controllerService = controllerServiceDAO.getControllerService(id);
    PropertyDescriptor descriptor = controllerService.getControllerServiceImplementation().getPropertyDescriptor(property);

    // return an invalid descriptor if the controller service doesn't support this property
    if (descriptor == null) {
        descriptor = new PropertyDescriptor.Builder().name(property).addValidator(Validator.INVALID).dynamic(true).build();
    }

    final String groupId = controllerService.getProcessGroup() == null ? null : controllerService.getProcessGroup().getIdentifier();
    return dtoFactory.createPropertyDescriptorDto(descriptor, groupId);
}
 
Example 2
Source File: StandardValidationContext.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
@Override
public ValidationContext getControllerServiceValidationContext(final ControllerService controllerService) {
    final ControllerServiceNode serviceNode = controllerServiceProvider.getControllerServiceNode(controllerService.getIdentifier());
    final ProcessGroup serviceGroup = serviceNode.getProcessGroup();
    final String serviceGroupId = serviceGroup == null ? null : serviceGroup.getIdentifier();
    return new StandardValidationContext(controllerServiceProvider, serviceNode.getProperties(), serviceNode.getAnnotationData(), serviceGroupId, serviceNode.getIdentifier(),variableRegistry);
}
 
Example 3
Source File: StandardValidationContext.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Override
public ValidationContext getControllerServiceValidationContext(final ControllerService controllerService) {
    final ControllerServiceNode serviceNode = controllerServiceProvider.getControllerServiceNode(controllerService.getIdentifier());
    final ProcessGroup serviceGroup = serviceNode.getProcessGroup();
    final String serviceGroupId = serviceGroup == null ? null : serviceGroup.getIdentifier();
    return new StandardValidationContext(controllerServiceProvider, serviceNode.getProperties(), serviceNode.getAnnotationData(), serviceGroupId,
        serviceNode.getIdentifier(), variableRegistry, serviceNode.getProcessGroup().getParameterContext());
}
 
Example 4
Source File: StandardControllerServiceDAO.java    From nifi with Apache License 2.0 4 votes vote down vote up
@Override
public ControllerServiceNode updateControllerService(final ControllerServiceDTO controllerServiceDTO) {
    // get the controller service
    final ControllerServiceNode controllerService = locateControllerService(controllerServiceDTO.getId());

    // ensure we can perform the update
    verifyUpdate(controllerService, controllerServiceDTO);

    // perform the update
    configureControllerService(controllerService, controllerServiceDTO);

    // attempt to change the underlying controller service if an updated bundle is specified
    // updating the bundle must happen after configuring so that any additional classpath resources are set first
    updateBundle(controllerService, controllerServiceDTO);

    // enable or disable as appropriate
    if (isNotNull(controllerServiceDTO.getState())) {
        final ControllerServiceState purposedControllerServiceState = ControllerServiceState.valueOf(controllerServiceDTO.getState());

        // only attempt an action if it is changing
        if (!purposedControllerServiceState.equals(controllerService.getState())) {
            if (ControllerServiceState.ENABLED.equals(purposedControllerServiceState)) {
                serviceProvider.enableControllerService(controllerService);
            } else if (ControllerServiceState.DISABLED.equals(purposedControllerServiceState)) {
                serviceProvider.disableControllerService(controllerService);
            }
        }
    }

    final ProcessGroup group = controllerService.getProcessGroup();
    if (group != null) {
        group.onComponentModified();

        // For any component that references this Controller Service, find the component's Process Group
        // and notify the Process Group that a component has been modified. This way, we know to re-calculate
        // whether or not the Process Group has local modifications.
        controllerService.getReferences().getReferencingComponents().stream()
            .map(ComponentNode::getProcessGroupIdentifier)
            .filter(id -> !id.equals(group.getIdentifier()))
            .forEach(groupId -> {
                final ProcessGroup descendant = group.findProcessGroup(groupId);
                if (descendant != null) {
                    descendant.onComponentModified();
                }
            });
    }

    return controllerService;
}