NIFI-9806 Introduce ConfigurableExtensionDefinition and VersionedConfigurableExtension (#5875)

This commit is contained in:
Bryan Bende 2022-03-18 08:43:17 -04:00 committed by GitHub
parent ab0d2c2f72
commit 193bcbe33a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 135 additions and 237 deletions

View File

@ -0,0 +1,52 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.nifi.c2.protocol.component.api;
import io.swagger.annotations.ApiModelProperty;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
public abstract class ConfigurableExtensionDefinition extends ExtensionComponent implements ConfigurableComponentDefinition {
private Map<String, PropertyDescriptor> propertyDescriptors;
private boolean supportsDynamicProperties;
@Override
@ApiModelProperty("Descriptions of configuration properties applicable to this component.")
public Map<String, PropertyDescriptor> getPropertyDescriptors() {
return (propertyDescriptors != null ? Collections.unmodifiableMap(propertyDescriptors) : null);
}
@Override
public void setPropertyDescriptors(LinkedHashMap<String, PropertyDescriptor> propertyDescriptors) {
this.propertyDescriptors = propertyDescriptors;
}
@Override
@ApiModelProperty("Whether or not this component makes use of dynamic (user-set) properties.")
public boolean getSupportsDynamicProperties() {
return supportsDynamicProperties;
}
@Override
public void setSupportsDynamicProperties(boolean supportsDynamicProperties) {
this.supportsDynamicProperties = supportsDynamicProperties;
}
}

View File

@ -18,39 +18,9 @@
package org.apache.nifi.c2.protocol.component.api;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
@ApiModel
public class ControllerServiceDefinition extends ExtensionComponent implements ConfigurableComponentDefinition {
public class ControllerServiceDefinition extends ConfigurableExtensionDefinition {
private static final long serialVersionUID = 1L;
private Map<String, PropertyDescriptor> propertyDescriptors;
private boolean supportsDynamicProperties;
@Override
@ApiModelProperty("Descriptions of configuration properties applicable to this controller service")
public Map<String, PropertyDescriptor> getPropertyDescriptors() {
return (propertyDescriptors != null ? Collections.unmodifiableMap(propertyDescriptors) : null);
}
@Override
public void setPropertyDescriptors(LinkedHashMap<String, PropertyDescriptor> propertyDescriptors) {
this.propertyDescriptors = propertyDescriptors;
}
@Override
@ApiModelProperty("Whether or not this processor makes use of dynamic (user-set) properties")
public boolean getSupportsDynamicProperties() {
return supportsDynamicProperties;
}
@Override
public void setSupportsDynamicProperties(boolean supportsDynamicProperties) {
this.supportsDynamicProperties = supportsDynamicProperties;
}
}

View File

@ -22,18 +22,14 @@ import io.swagger.annotations.ApiModelProperty;
import org.apache.nifi.annotation.behavior.InputRequirement;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@ApiModel
public class ProcessorDefinition extends ExtensionComponent implements ConfigurableComponentDefinition {
public class ProcessorDefinition extends ConfigurableExtensionDefinition {
private static final long serialVersionUID = 1L;
private Map<String, PropertyDescriptor> propertyDescriptors;
private boolean supportsDynamicProperties;
private InputRequirement.Requirement inputRequirement;
private List<Relationship> supportedRelationships;
private boolean supportsDynamicRelationships;
@ -54,28 +50,6 @@ public class ProcessorDefinition extends ExtensionComponent implements Configura
private String defaultYieldDuration;
private String defaultBulletinLevel;
@Override
@ApiModelProperty("Descriptions of configuration properties applicable to this processor.")
public Map<String, PropertyDescriptor> getPropertyDescriptors() {
return (propertyDescriptors != null ? Collections.unmodifiableMap(propertyDescriptors) : null);
}
@Override
public void setPropertyDescriptors(LinkedHashMap<String, PropertyDescriptor> propertyDescriptors) {
this.propertyDescriptors = propertyDescriptors;
}
@Override
@ApiModelProperty("Whether or not this processor makes use of dynamic (user-set) properties.")
public boolean getSupportsDynamicProperties() {
return supportsDynamicProperties;
}
@Override
public void setSupportsDynamicProperties(boolean supportsDynamicProperties) {
this.supportsDynamicProperties = supportsDynamicProperties;
}
@ApiModelProperty("Any input requirements this processor has.")
public InputRequirement.Requirement getInputRequirement() {
return inputRequirement;

View File

@ -21,41 +21,16 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@ApiModel
public class ReportingTaskDefinition extends ExtensionComponent implements ConfigurableComponentDefinition {
public class ReportingTaskDefinition extends ConfigurableExtensionDefinition {
private static final long serialVersionUID = 1L;
private Map<String, PropertyDescriptor> propertyDescriptors;
private List<String> supportedSchedulingStrategies;
private String defaultSchedulingStrategy;
private Map<String, String> defaultSchedulingPeriodBySchedulingStrategy;
private boolean supportsDynamicProperties;
@Override
@ApiModelProperty("Descriptions of configuration properties applicable to this reporting task")
public Map<String, PropertyDescriptor> getPropertyDescriptors() {
return (propertyDescriptors != null ? Collections.unmodifiableMap(propertyDescriptors) : null);
}
@Override
public void setPropertyDescriptors(LinkedHashMap<String, PropertyDescriptor> propertyDescriptors) {
this.propertyDescriptors = propertyDescriptors;
}
@Override
@ApiModelProperty("Whether or not this reporting task makes use of dynamic (user-set) properties")
public boolean getSupportsDynamicProperties() {
return supportsDynamicProperties;
}
@Override
public void setSupportsDynamicProperties(boolean supportsDynamicProperties) {
this.supportsDynamicProperties = supportsDynamicProperties;
}
@ApiModelProperty("The supported scheduling strategies, such as TIME_DRIVER or CRON.")
public List<String> getSupportedSchedulingStrategies() {

View File

@ -0,0 +1,77 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.nifi.flow;
import io.swagger.annotations.ApiModelProperty;
import java.util.Map;
public abstract class VersionedConfigurableExtension extends VersionedComponent
implements VersionedExtensionComponent, VersionedConfigurableComponent {
private String type;
private Bundle bundle;
private Map<String, String> properties;
private Map<String, VersionedPropertyDescriptor> propertyDescriptors;
@Override
@ApiModelProperty("The type of the extension component")
public String getType() {
return type;
}
@Override
public void setType(final String type) {
this.type = type;
}
@Override
@ApiModelProperty("Information about the bundle from which the component came")
public Bundle getBundle() {
return bundle;
}
@Override
public void setBundle(Bundle bundle) {
this.bundle = bundle;
}
@Override
@ApiModelProperty("The properties for the component. Properties whose value is not set will only contain the property name.")
public Map<String, String> getProperties() {
return properties;
}
@Override
public void setProperties(Map<String, String> properties) {
this.properties = properties;
}
@Override
@ApiModelProperty("The property descriptors for the component.")
public Map<String, VersionedPropertyDescriptor> getPropertyDescriptors() {
return propertyDescriptors;
}
@Override
public void setPropertyDescriptors(Map<String, VersionedPropertyDescriptor> propertyDescriptors) {
this.propertyDescriptors = propertyDescriptors;
}
}

View File

@ -20,42 +20,14 @@ package org.apache.nifi.flow;
import io.swagger.annotations.ApiModelProperty;
import java.util.List;
import java.util.Map;
public class VersionedControllerService extends VersionedComponent
implements VersionedConfigurableComponent, VersionedExtensionComponent {
public class VersionedControllerService extends VersionedConfigurableExtension {
private String type;
private Bundle bundle;
private List<ControllerServiceAPI> controllerServiceApis;
private Map<String, String> properties;
private Map<String, VersionedPropertyDescriptor> propertyDescriptors;
private String annotationData;
private ScheduledState scheduledState;
@Override
@ApiModelProperty(value = "The type of the controller service.")
public String getType() {
return type;
}
@Override
public void setType(String type) {
this.type = type;
}
@Override
@ApiModelProperty(value = "The details of the artifact that bundled this controller service type.")
public Bundle getBundle() {
return bundle;
}
@Override
public void setBundle(Bundle bundle) {
this.bundle = bundle;
}
@ApiModelProperty(value = "Lists the APIs this Controller Service implements.")
public List<ControllerServiceAPI> getControllerServiceApis() {
return controllerServiceApis;
@ -65,28 +37,6 @@ public class VersionedControllerService extends VersionedComponent
this.controllerServiceApis = controllerServiceApis;
}
@Override
@ApiModelProperty(value = "The properties of the controller service.")
public Map<String, String> getProperties() {
return properties;
}
@Override
public void setProperties(Map<String, String> properties) {
this.properties = properties;
}
@Override
@ApiModelProperty("The property descriptors for the controller service.")
public Map<String, VersionedPropertyDescriptor> getPropertyDescriptors() {
return propertyDescriptors;
}
@Override
public void setPropertyDescriptors(Map<String, VersionedPropertyDescriptor> propertyDescriptors) {
this.propertyDescriptors = propertyDescriptors;
}
@ApiModelProperty(value = "The annotation for the controller service. This is how the custom UI relays configuration to the controller service.")
public String getAnnotationData() {
return annotationData;

View File

@ -22,15 +22,9 @@ import io.swagger.annotations.ApiModelProperty;
import java.util.Map;
import java.util.Set;
public class VersionedProcessor extends VersionedComponent
implements VersionedConfigurableComponent, VersionedExtensionComponent {
public class VersionedProcessor extends VersionedConfigurableExtension {
private Bundle bundle;
private Map<String, String> style;
private String type;
private Map<String, String> properties;
private Map<String, VersionedPropertyDescriptor> propertyDescriptors;
private String annotationData;
private String schedulingPeriod;
@ -67,17 +61,6 @@ public class VersionedProcessor extends VersionedComponent
this.schedulingStrategy = schedulingStrategy;
}
@Override
@ApiModelProperty("The type of Processor")
public String getType() {
return type;
}
@Override
public void setType(final String type) {
this.type = type;
}
@ApiModelProperty("Indicates the node where the process will execute.")
public String getExecutionNode() {
return executionNode;
@ -123,28 +106,6 @@ public class VersionedProcessor extends VersionedComponent
this.concurrentlySchedulableTaskCount = concurrentlySchedulableTaskCount;
}
@Override
@ApiModelProperty("The properties for the processor. Properties whose value is not set will only contain the property name.")
public Map<String, String> getProperties() {
return properties;
}
@Override
public void setProperties(Map<String, String> properties) {
this.properties = properties;
}
@Override
@ApiModelProperty("The property descriptors for the processor.")
public Map<String, VersionedPropertyDescriptor> getPropertyDescriptors() {
return propertyDescriptors;
}
@Override
public void setPropertyDescriptors(Map<String, VersionedPropertyDescriptor> propertyDescriptors) {
this.propertyDescriptors = propertyDescriptors;
}
@ApiModelProperty("The annotation data for the processor used to relay configuration between a custom UI and the procesosr.")
public String getAnnotationData() {
return annotationData;
@ -175,17 +136,6 @@ public class VersionedProcessor extends VersionedComponent
this.runDurationMillis = runDurationMillis;
}
@Override
@ApiModelProperty("Information about the bundle from which the component came")
public Bundle getBundle() {
return bundle;
}
@Override
public void setBundle(Bundle bundle) {
this.bundle = bundle;
}
@ApiModelProperty("Stylistic data for rendering in a UI")
public Map<String, String> getStyle() {
return style;

View File

@ -19,63 +19,13 @@ package org.apache.nifi.flow;
import io.swagger.annotations.ApiModelProperty;
import java.util.Map;
public class VersionedReportingTask extends VersionedConfigurableExtension {
public class VersionedReportingTask extends VersionedComponent implements VersionedConfigurableComponent, VersionedExtensionComponent {
private String type;
private Bundle bundle;
private Map<String, String> properties;
private Map<String, VersionedPropertyDescriptor> propertyDescriptors;
private String annotationData;
private ScheduledState scheduledState;
private String schedulingPeriod;
private String schedulingStrategy;
@Override
@ApiModelProperty(value = "The type of the reporting task.")
public String getType() {
return type;
}
@Override
public void setType(final String type) {
this.type = type;
}
@Override
@ApiModelProperty(value = "The details of the artifact that bundled this reporting task type.")
public Bundle getBundle() {
return bundle;
}
@Override
public void setBundle(Bundle bundle) {
this.bundle = bundle;
}
@Override
@ApiModelProperty(value = "The properties of the reporting task.")
public Map<String, String> getProperties() {
return properties;
}
@Override
public void setProperties(Map<String, String> properties) {
this.properties = properties;
}
@Override
@ApiModelProperty("The property descriptors for the reporting task.")
public Map<String, VersionedPropertyDescriptor> getPropertyDescriptors() {
return propertyDescriptors;
}
@Override
public void setPropertyDescriptors(Map<String, VersionedPropertyDescriptor> propertyDescriptors) {
this.propertyDescriptors = propertyDescriptors;
}
@ApiModelProperty(value = "The annotation for the reporting task. This is how the custom UI relays configuration to the reporting task.")
public String getAnnotationData() {
return annotationData;