use of org.apache.nifi.controller.ConfiguredComponent in project nifi by apache.
the class StandardControllerServiceProvider method unscheduleReferencingComponents.
@Override
public Set<ConfiguredComponent> unscheduleReferencingComponents(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 stop all components (that are running) before doing anything
for (final ProcessorNode node : processors) {
if (node.getScheduledState() == ScheduledState.RUNNING) {
node.verifyCanStop();
}
}
for (final ReportingTaskNode node : reportingTasks) {
if (node.getScheduledState() == ScheduledState.RUNNING) {
node.verifyCanStop();
}
}
// stop all of the components that are running
for (final ProcessorNode node : processors) {
if (node.getScheduledState() == ScheduledState.RUNNING) {
node.getProcessGroup().stopProcessor(node);
updated.add(node);
}
}
for (final ReportingTaskNode node : reportingTasks) {
if (node.getScheduledState() == ScheduledState.RUNNING) {
processScheduler.unschedule(node);
updated.add(node);
}
}
return updated;
}
use of org.apache.nifi.controller.ConfiguredComponent in project nifi by apache.
the class StandardControllerServiceReference method getActiveReferences.
@Override
public Set<ConfiguredComponent> getActiveReferences() {
final Set<ConfiguredComponent> activeReferences = new HashSet<>();
final Set<ControllerServiceNode> serviceNodes = new HashSet<>();
for (final ConfiguredComponent component : components) {
if (component instanceof ControllerServiceNode) {
serviceNodes.add((ControllerServiceNode) component);
if (((ControllerServiceNode) component).isActive()) {
activeReferences.add(component);
}
} else if (isRunning(component)) {
activeReferences.add(component);
}
}
activeReferences.addAll(getActiveIndirectReferences(serviceNodes));
return activeReferences;
}
use of org.apache.nifi.controller.ConfiguredComponent in project nifi by apache.
the class StandardNiFiServiceFacade method findControllerServiceReferencingComponentIdentifiers.
/**
* Finds the identifiers for all components referencing a ControllerService.
*
* @param reference ControllerServiceReference
* @param visited ControllerServices we've already visited
*/
private void findControllerServiceReferencingComponentIdentifiers(final ControllerServiceReference reference, final Set<ControllerServiceNode> visited) {
for (final ConfiguredComponent component : reference.getReferencingComponents()) {
// if this is a ControllerService consider it's referencing components
if (component instanceof ControllerServiceNode) {
final ControllerServiceNode node = (ControllerServiceNode) component;
if (!visited.contains(node)) {
findControllerServiceReferencingComponentIdentifiers(node.getReferences(), visited);
}
visited.add(node);
}
}
}
use of org.apache.nifi.controller.ConfiguredComponent in project nifi by apache.
the class StandardNiFiServiceFacade method getComponentsAffectedByVariableRegistryUpdate.
@Override
public Set<AffectedComponentEntity> getComponentsAffectedByVariableRegistryUpdate(final VariableRegistryDTO variableRegistryDto) {
final ProcessGroup group = processGroupDAO.getProcessGroup(variableRegistryDto.getProcessGroupId());
if (group == null) {
throw new ResourceNotFoundException("Could not find Process Group with ID " + variableRegistryDto.getProcessGroupId());
}
final Map<String, String> variableMap = new HashMap<>();
// have to use forEach here instead of using Collectors.toMap because value may be null
variableRegistryDto.getVariables().stream().map(VariableEntity::getVariable).forEach(var -> variableMap.put(var.getName(), var.getValue()));
final Set<AffectedComponentEntity> affectedComponentEntities = new HashSet<>();
final Set<String> updatedVariableNames = getUpdatedVariables(group, variableMap);
for (final String variableName : updatedVariableNames) {
final Set<ConfiguredComponent> affectedComponents = group.getComponentsAffectedByVariable(variableName);
affectedComponentEntities.addAll(dtoFactory.createAffectedComponentEntities(affectedComponents, revisionManager));
}
return affectedComponentEntities;
}
Aggregations