Apache Nifi 简明教程
Apache NiFi - Templates
Apache NiFi 提供了模板的概念,可以更轻松地重用和分发 NiFi 流程。这些流程可由其他开发人员或在其他 NiFi 集群中使用。它还有助于 NiFi 开发人员在 GitHub 等存储库中共享他们的工作。
Apache NiFi offers the concept of Templates, which makes it easier to reuse and distribute the NiFi flows. The flows can be used by other developers or in other NiFi clusters. It also helps NiFi developers to share their work in repositories like GitHub.
Create Template
让我们为在章节 15 “Apache NiFi - 创建流程” 中创建的流程创建一个模板。
Let us create a template for the flow, which we created in chapter no 15 “Apache NiFi - Creating Flows”.
使用 Shift 键选择流程的所有组件,然后单击 NiFi 画布左侧的 “创建模板” 图标。您还可以看到一个工具箱,如下图所示。单击如下图中用蓝色标记的图标 create template 。输入模板的名称。开发人员还可以添加说明,这是可选的。
Select all the components of the flow using shift key and then click on the create template icon at the left hand side of the NiFi canvas. You can also see a tool box as shown in the above image. Click on the icon create template marked in blue as in the above picture. Enter the name for the template. A developer can also add description, which is optional.
Download Template
然后转到 NiFi UI 右上角的菜单中的 NiFi 模板选项,如下图所示。
Then go to the NiFi templates option in the menu present at the top right hand corner of NiFi UI as show in the picture below.
现在,单击您要下载的模板的下载图标(位于列表右侧)。将下载带有模板名称的 XML 文件。
Now click the download icon (present at the right hand side in the list) of the template, you want to download. An XML file with the template name will get downloaded.
Upload Template
要在 NiFi 中使用模板,开发人员必须使用 UI 将其 XML 文件上传到 NiFi。在 “创建模板” 图标旁边有一个 “上传模板” 图标(在下图中用蓝色标记),单击它并浏览 XML。
To use a template in NiFi, a developer will have to upload its xml file to NiFi using UI. There is an Upload Template icon (marked with blue in below image) beside Create Template icon click on that and browse the xml.
Add Template
在 NiFi UI 的顶部工具栏中,模板图标位于标签图标之前。该图标如下图中所示用蓝色标记。
In the top toolbar of NiFi UI, the template icon is before the label icon. The icon is marked in blue as shown in the picture below.
拖动模板图标,从下拉列表中选择模板,然后单击 “添加”。它将把模板添加到 NiFi 画布。
Drag the template icon and choose the template from the drop down list and click add. It will add the template to NiFi canvas.