首先,您可以通过检查Apache Nifi的日志来查找详细信息。在Nifi UI中,转到'安全”选项卡并单击'查看日志”链接。此链接将带您进入Nifi的日志视图。您可以搜索'ERROR”关键字以及与无效处理器相关的任何其他关键字以查找详细信息。
您还可以尝试删除最近更改的处理器属性。首先转到无效处理器的配置页面,然后单击'更改历史记录”。在此页面上,您可以查看处理器属性的更改历史记录。您可以选择删除最近更改的属性,然后重试运行处理器。
以下是一个示例更新Nifi的处理器代码,以实现更好的属性验证和错误处理。这个示例展示了在一些常见用例中如何验证并处理属性错误。
@Override
public void onPropertyModified(final PropertyDescriptor descriptor, final String oldValue, final String newValue) {
super.onPropertyModified(descriptor, oldValue, newValue);
if (descriptor.equals(MY_PROPERTY)) {
try {
// Attempt to parse the new property value to ensure it is valid
final Integer value = Integer.parseInt(newValue);
// Handle any other validation criteria based on the new property value here
} catch (NumberFormatException nfe) {
// If the new property value is not a valid integer, set the processor to invalid state
getLogger().error("New property value is not a valid integer: " + newValue, nfe);
setErrorState("New property value is not a valid integer: " + newValue, nfe);
}
}
}
@Override
protected Collection customValidate(final ValidationContext context) {
final List results = new ArrayList<>();
// Verify that the processor properties are valid here based on any additional validation criteria
if (context.getProperty(MY_PROPERTY).isSet()) {
try {
// Attempt to parse the configured property value to ensure it is valid
final Integer value = context.getProperty(MY_PROPERTY).asInteger();
// Handle any other validation criteria based on the configured property value here
} catch (NumberFormatException nfe) {
// If the configured property value is not a valid integer, add a validation error
results.add(new ValidationResult.Builder()
.subject(MY_PROPERTY.getName())
.valid(false)
.explanation("Configured property value