Skip to content

Commit

Permalink
NIFI-14149 Fix invalid MiNiFi flow json by setting the default value …
Browse files Browse the repository at this point in the history
…of maxTimerDrivenThreadCount and update minifi-toolkit command set with examples

Signed-off-by: Ferenc Kis <briansolo1985@gmail.com>

This closes #9628.
  • Loading branch information
pkedvessy authored and briansolo1985 committed Jan 13, 2025
1 parent 7899874 commit 25ca4b4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
7 changes: 6 additions & 1 deletion minifi/minifi-toolkit/minifi-toolkit-assembly/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ After downloading the binary and extracting it, to run the MiNiFi Toolkit Conver
java org.apache.nifi.minifi.toolkit.configuration.ConfigMain <command> options

Valid commands include:
transform-yml: Transforms legacy MiNiFi flow config YAML into MiNiFi flow config JSON
- transform-nifi: Transform NiFi2 flow JSON format into MiNifi flow JSON format
- transform-yml: Transforms legacy MiNiFi flow config YAML into MiNiFi flow config JSON

## Example
- You have an older version of MiNiFi located in <legacy_minifi_directory>.
Expand All @@ -57,6 +58,10 @@ After downloading the binary and extracting it, to run the MiNiFi Toolkit Conver
```
./config.sh transform-yml <legacy_minifi_directory>/conf/config.yml <legacy_minifi_directory>/conf/bootstrap.conf <latest_minifi_directory>/conf/flow.json.raw <latest_minifi_directory>/conf/bootstrap.conf
```
- Run the following command to transform NiFi flow JSON format into MiNifi flow JSON format
```
./config.sh transform-nifi <downloaded_nifi2_flow_json_file> <minifi_flow_json_file>
```

## Note
It's not guaranteed in all circumstances that the migration will result in a correct flow. For example if a processor's configuration has changed between version, the conversion tool won't be aware of this, and will use the deprecated property names. You will need to fix such issues manually.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.apache.nifi.minifi.toolkit.configuration.ConfigTransformException;
import org.apache.nifi.minifi.toolkit.configuration.PathInputStreamFactory;
import org.apache.nifi.minifi.toolkit.configuration.PathOutputStreamFactory;
import org.apache.nifi.minifi.toolkit.schema.CorePropertiesSchema;
import org.apache.nifi.registry.flow.RegisteredFlowSnapshot;

import com.fasterxml.jackson.databind.ObjectMapper;
Expand Down Expand Up @@ -63,8 +64,9 @@ private int transformNifiToJson(String[] args) {
RegisteredFlowSnapshot registeredFlowSnapshot = readNifiFlow(sourceNiFiJsonPath);
VersionedDataflow versionedDataflow = new VersionedDataflow();
versionedDataflow.setRootGroup(registeredFlowSnapshot.getFlowContents());
versionedDataflow
.setParameterContexts(new ArrayList<>(registeredFlowSnapshot.getParameterContexts().values()));
versionedDataflow.setParameterContexts(new ArrayList<>(registeredFlowSnapshot.getParameterContexts().values()));
versionedDataflow.setMaxTimerDrivenThreadCount(CorePropertiesSchema.DEFAULT_MAX_CONCURRENT_THREADS);

persistFlowJson(versionedDataflow, targetMiNiFiJsonPath);
} catch (ConfigTransformException e) {
System.out.println("Unable to convert NiFi JSON to MiNiFi flow JSON: " + e);
Expand Down

0 comments on commit 25ca4b4

Please sign in to comment.