use of org.apache.nifi.controller.service.ControllerServiceNode in project nifi by apache.
the class StandardControllerServiceDAO method updateControllerService.
@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(ConfiguredComponent::getProcessGroupIdentifier).filter(id -> !id.equals(group.getIdentifier())).forEach(groupId -> {
final ProcessGroup descendant = group.findProcessGroup(groupId);
if (descendant != null) {
descendant.onComponentModified();
}
});
}
return controllerService;
}
use of org.apache.nifi.controller.service.ControllerServiceNode in project nifi by apache.
the class StandardControllerServiceDAO method deleteControllerService.
@Override
public void deleteControllerService(final String controllerServiceId) {
final ControllerServiceNode controllerService = locateControllerService(controllerServiceId);
serviceProvider.removeControllerService(controllerService);
}
use of org.apache.nifi.controller.service.ControllerServiceNode in project nifi by apache.
the class StandardControllerServiceDAO method createControllerService.
@Override
public ControllerServiceNode createControllerService(final ControllerServiceDTO controllerServiceDTO) {
// ensure the type is specified
if (controllerServiceDTO.getType() == null) {
throw new IllegalArgumentException("The controller service type must be specified.");
}
try {
// create the controller service
final ControllerServiceNode controllerService = serviceProvider.createControllerService(controllerServiceDTO.getType(), controllerServiceDTO.getId(), BundleUtils.getBundle(controllerServiceDTO.getType(), controllerServiceDTO.getBundle()), Collections.emptySet(), true);
// ensure we can perform the update
verifyUpdate(controllerService, controllerServiceDTO);
// perform the update
configureControllerService(controllerService, controllerServiceDTO);
final String groupId = controllerServiceDTO.getParentGroupId();
if (groupId == null) {
flowController.addRootControllerService(controllerService);
} else {
final ProcessGroup group;
if (groupId.equals(ROOT_GROUP_ID_ALIAS)) {
group = flowController.getGroup(flowController.getRootGroupId());
} else {
group = flowController.getGroup(flowController.getRootGroupId()).findProcessGroup(groupId);
}
if (group == null) {
throw new ResourceNotFoundException(String.format("Unable to locate group with id '%s'.", groupId));
}
group.addControllerService(controllerService);
}
return controllerService;
} catch (final ControllerServiceInstantiationException csie) {
throw new NiFiCoreException(csie.getMessage(), csie);
}
}
use of org.apache.nifi.controller.service.ControllerServiceNode in project nifi by apache.
the class StandardControllerServiceDAO method verifyUpdate.
@Override
public void verifyUpdate(final ControllerServiceDTO controllerServiceDTO) {
final ControllerServiceNode controllerService = locateControllerService(controllerServiceDTO.getId());
verifyUpdate(controllerService, controllerServiceDTO);
}
use of org.apache.nifi.controller.service.ControllerServiceNode in project nifi by apache.
the class StandardControllerServiceDAO method clearState.
@Override
public void clearState(final String controllerServiceId) {
final ControllerServiceNode controllerService = locateControllerService(controllerServiceId);
componentStateDAO.clearState(controllerService);
}
Aggregations