Skip to content

Commit c5f1f69

Browse files
committed
NIFI-14571: Add VerifiableFlowRegistryClient interface to verify Flow Registry Client implementations
1 parent 0a62eb1 commit c5f1f69

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.nifi.controller;
19+
20+
import org.apache.nifi.components.ConfigVerificationResult;
21+
import org.apache.nifi.logging.ComponentLog;
22+
import org.apache.nifi.registry.flow.FlowRegistryClientConfigurationContext;
23+
24+
import java.util.List;
25+
import java.util.Map;
26+
27+
/**
28+
* <p>
29+
* Any Flow Registry Client that implements this interface will be provided the opportunity to verify
30+
* a given configuration of the Flow Registry Client. This allows the Flow Registry Client to provide meaningful feedback
31+
* to users when configuring the dataflow.
32+
* </p>
33+
*
34+
* <p>
35+
* Generally speaking, verification differs from validation in that validation is expected to be very
36+
* quick and run often. If a Flow Registry Client is not valid, it cannot be started. However, verification may be
37+
* more expensive or time-consuming to complete. For example, validation may ensure that a username is
38+
* provided for connecting to an external service but should not perform any sort of network connection
39+
* in order to verify that the username is accurate. Verification, on the other hand, may create resources
40+
* such as network connections, may be more expensive to complete, and may be run only when a user invokes
41+
* the action (though verification may later occur at other stages, such as when starting a component).
42+
* </p>
43+
*
44+
* <p>
45+
* Verification is allowed to be run only when a Flow Registry Client is fully disabled.
46+
* Therefore, any initialization logic that may need to be performed
47+
* before the Flow Registry Client is triggered may also be required for verification. However, the framework is not responsible
48+
* for triggering the Lifecycle management stages, such as @OnScheduled before triggering the verification. Such
49+
* methods should be handled by the {@link #verify(FlowRegistryClientConfigurationContext, ComponentLog, Map)} itself.
50+
* The {@link #verify(FlowRegistryClientConfigurationContext, ComponentLog, Map)} method will only be called if the configuration is valid according to the
51+
* validation rules (i.e., all Property Descriptors' validators and customValidate methods have indicated that the configuration is valid).
52+
* </p>
53+
*/
54+
public interface VerifiableFlowRegistryClientService {
55+
56+
/**
57+
* Verifies that the configuration defined by the given FlowRegistryClientConfigurationContext is valid.
58+
* @param context the FlowRegistryClientConfigurationContext that contains the necessary configuration
59+
* @param verificationLogger a logger that can be used during verification. While the typical logger can be used, doing so may result
60+
* in producing bulletins, which can be confusing.
61+
* @param variables a Map of key/value pairs that can be used to resolve variables referenced in property values via Expression Language
62+
*
63+
* @return a List of ConfigVerificationResults, each illustrating one step of the verification process that was completed
64+
*/
65+
List<ConfigVerificationResult> verify(FlowRegistryClientConfigurationContext context, ComponentLog verificationLogger, Map<String, String> variables);
66+
67+
}

0 commit comments

Comments
 (0)