mirror of
https://github.com/apache/nifi.git
synced 2025-03-04 00:19:44 +00:00
NIFI-12321 Avoid Exceptions when removing Python Processors (#7984)
- Updated StandardPythonBridge.onProcessorRemoved to avoid throwing exceptions when called with a Processor Type and Version that is not registered - Updated system-tests workflow to run on changes in the nifi-py4j-bundle
This commit is contained in:
parent
b24249c850
commit
b50557b854
2
.github/workflows/system-tests.yml
vendored
2
.github/workflows/system-tests.yml
vendored
@ -26,6 +26,7 @@ on:
|
|||||||
- 'nifi-api/**'
|
- 'nifi-api/**'
|
||||||
- 'nifi-framework-api/**'
|
- 'nifi-framework-api/**'
|
||||||
- 'nifi-nar-bundles/nifi-framework-bundle/**'
|
- 'nifi-nar-bundles/nifi-framework-bundle/**'
|
||||||
|
- 'nifi-nar-bundles/nifi-py4j-bundle/**'
|
||||||
- 'nifi-stateless/**'
|
- 'nifi-stateless/**'
|
||||||
pull_request:
|
pull_request:
|
||||||
paths:
|
paths:
|
||||||
@ -34,6 +35,7 @@ on:
|
|||||||
- 'nifi-api/**'
|
- 'nifi-api/**'
|
||||||
- 'nifi-framework-api/**'
|
- 'nifi-framework-api/**'
|
||||||
- 'nifi-nar-bundles/nifi-framework-bundle/**'
|
- 'nifi-nar-bundles/nifi-framework-bundle/**'
|
||||||
|
- 'nifi-nar-bundles/nifi-py4j-bundle/**'
|
||||||
- 'nifi-stateless/**'
|
- 'nifi-stateless/**'
|
||||||
|
|
||||||
env:
|
env:
|
||||||
|
@ -96,7 +96,8 @@ public class StandardPythonBridge implements PythonBridge {
|
|||||||
private PythonProcessorBridge createProcessorBridge(final String identifier, final String type, final String version, final boolean preferIsolatedProcess) {
|
private PythonProcessorBridge createProcessorBridge(final String identifier, final String type, final String version, final boolean preferIsolatedProcess) {
|
||||||
ensureStarted();
|
ensureStarted();
|
||||||
|
|
||||||
final ExtensionId extensionId = getExtensionId(type, version);
|
final Optional<ExtensionId> extensionIdFound = findExtensionId(type, version);
|
||||||
|
final ExtensionId extensionId = extensionIdFound.orElseThrow(() -> new IllegalArgumentException("Processor Type [%s] Version [%s] not found".formatted(type, version)));
|
||||||
logger.debug("Creating Python Processor Type [{}] Version [{}]", extensionId.type(), extensionId.version());
|
logger.debug("Creating Python Processor Type [{}] Version [{}]", extensionId.type(), extensionId.version());
|
||||||
|
|
||||||
final PythonProcess pythonProcess = getProcessForNextComponent(extensionId, identifier, preferIsolatedProcess);
|
final PythonProcess pythonProcess = getProcessForNextComponent(extensionId, identifier, preferIsolatedProcess);
|
||||||
@ -151,7 +152,10 @@ public class StandardPythonBridge implements PythonBridge {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void onProcessorRemoved(final String identifier, final String type, final String version) {
|
public synchronized void onProcessorRemoved(final String identifier, final String type, final String version) {
|
||||||
final ExtensionId extensionId = getExtensionId(type, version);
|
final Optional<ExtensionId> extensionIdFound = findExtensionId(type, version);
|
||||||
|
|
||||||
|
if (extensionIdFound.isPresent()) {
|
||||||
|
final ExtensionId extensionId = extensionIdFound.get();
|
||||||
final List<PythonProcess> processes = processesByProcessorType.get(extensionId);
|
final List<PythonProcess> processes = processesByProcessorType.get(extensionId);
|
||||||
if (processes == null) {
|
if (processes == null) {
|
||||||
return;
|
return;
|
||||||
@ -171,6 +175,9 @@ public class StandardPythonBridge implements PythonBridge {
|
|||||||
}
|
}
|
||||||
|
|
||||||
processorCountByType.merge(extensionId, -1, Integer::sum);
|
processorCountByType.merge(extensionId, -1, Integer::sum);
|
||||||
|
} else {
|
||||||
|
logger.debug("Processor Type [{}] Version [{}] not found", type, version);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getTotalProcessCount() {
|
public int getTotalProcessCount() {
|
||||||
@ -310,15 +317,13 @@ public class StandardPythonBridge implements PythonBridge {
|
|||||||
return "StandardPythonBridge";
|
return "StandardPythonBridge";
|
||||||
}
|
}
|
||||||
|
|
||||||
private ExtensionId getExtensionId(final String type, final String version) {
|
private Optional<ExtensionId> findExtensionId(final String type, final String version) {
|
||||||
final List<PythonProcessorDetails> processorTypes = controllerProcess.getController().getProcessorTypes();
|
final List<PythonProcessorDetails> processorTypes = controllerProcess.getController().getProcessorTypes();
|
||||||
final Optional<PythonProcessorDetails> processorTypeFound = processorTypes.stream()
|
return processorTypes.stream()
|
||||||
.filter(details -> details.getProcessorType().equals(type))
|
.filter(details -> details.getProcessorType().equals(type))
|
||||||
.filter(details -> details.getProcessorVersion().equals(version))
|
.filter(details -> details.getProcessorVersion().equals(version))
|
||||||
|
.map(details -> new ExtensionId(details.getProcessorType(), details.getProcessorVersion()))
|
||||||
.findFirst();
|
.findFirst();
|
||||||
|
|
||||||
return processorTypeFound.map(details -> new ExtensionId(details.getProcessorType(), details.getProcessorVersion()))
|
|
||||||
.orElseThrow(() -> new IllegalArgumentException(String.format("Processor Type [%s] Version [%s] not found", type, version)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private record ExtensionId(String type, String version) {
|
private record ExtensionId(String type, String version) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user