Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NIFI-12245: Removed deprecations around flow registry clients #7899

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
public class VersionedFlowCoordinates {
private String registryId;
private String storageLocation;
private String registryUrl;
private String bucketId;
private String flowId;
private int version;
Expand All @@ -48,17 +47,6 @@ public void setStorageLocation(String storageLocation) {
this.storageLocation = storageLocation;
}

@Deprecated
@ApiModelProperty("The URL of the Flow Registry that contains the flow")
public String getRegistryUrl() {
return registryUrl;
}

@Deprecated
public void setRegistryUrl(String registryUrl) {
this.registryUrl = registryUrl;
}

@ApiModelProperty("The UUID of the bucket that the flow resides in")
public String getBucketId() {
return bucketId;
Expand Down Expand Up @@ -97,7 +85,7 @@ public void setLatest(Boolean latest) {

@Override
public int hashCode() {
return Objects.hash(registryId, storageLocation, registryUrl, bucketId, flowId, version);
return Objects.hash(registryId, storageLocation, bucketId, flowId, version);
}

@Override
Expand All @@ -108,16 +96,15 @@ public boolean equals(final Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof VersionedFlowCoordinates)) {
if (!(obj instanceof final VersionedFlowCoordinates other)) {
return false;
}

final VersionedFlowCoordinates other = (VersionedFlowCoordinates) obj;
return Objects.equals(registryUrl, other.registryUrl) && Objects.equals(bucketId, other.bucketId) && Objects.equals(flowId, other.flowId) && Objects.equals(version, other.version);
return Objects.equals(storageLocation, other.storageLocation) && Objects.equals(bucketId, other.bucketId) && Objects.equals(flowId, other.flowId) && Objects.equals(version, other.version);
}

@Override
public String toString() {
return "VersionedFlowCoordinates[bucketId=" + bucketId + ", flowId=" + flowId + ", version=" + version + ", registryUrl=" + registryUrl + "]";
return "VersionedFlowCoordinates[bucketId=" + bucketId + ", flowId=" + flowId + ", version=" + version + ", storageLocation=" + storageLocation + "]";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@
import io.swagger.annotations.ApiModelProperty;

public class VersionedFlowRegistryClient extends VersionedConfigurableExtension {
@Deprecated
private String id;
@Deprecated
private String url;
private String description;
private String annotationData;

Expand All @@ -32,30 +28,6 @@ public ComponentType getComponentType() {
return ComponentType.FLOW_REGISTRY_CLIENT;
}

/**
* @deprecated use {@link #getIdentifier()} instead.
*/
@Deprecated
@ApiModelProperty("The ID of the Registry. This method is deprecated. Use #getIdentifier instead.")
public String getId() {
return id;
}

public void setId(final String id) {
this.id = id;
}

@Deprecated
@ApiModelProperty("The URL for interacting with the registry")
public String getUrl() {
return url;
}

@Deprecated
public void setUrl(final String url) {
this.url = url;
}

@ApiModelProperty("The description of the registry")
public String getDescription() {
return description;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ public class TestFormatUtils {
private static final String KIEV_TIME_ZONE_ID = "Europe/Kiev";
private static final String UTC_TIME_ZONE_ID = ZoneOffset.UTC.getId();

@SuppressWarnings("deprecation")
@ParameterizedTest
@MethodSource("getParse")
public void testParse(String value, TimeUnit desiredUnit, Long expected) {
Expand All @@ -63,14 +62,13 @@ private static Stream<Arguments> getParse() {
Arguments.of("1 Hrs", TimeUnit.MINUTES, 60L));
}

@SuppressWarnings("deprecation")
@ParameterizedTest
@ValueSource(strings = {"1 week", "1 wk", "1 w", "1 wks", "1 weeks"})
public void testGetTimeDurationShouldConvertWeeks(String week) {
assertEquals(7L, FormatUtils.getTimeDuration(week, TimeUnit.DAYS));
}

@SuppressWarnings("deprecation")

@ParameterizedTest
@ValueSource(strings = {"-1 week", "-1 wk", "-1 w", "-1 weeks", "- 1 week"})
public void testGetTimeDurationShouldHandleNegativeWeeks(String week) {
Expand All @@ -82,7 +80,7 @@ public void testGetTimeDurationShouldHandleNegativeWeeks(String week) {
/**
* Regression test
*/
@SuppressWarnings("deprecation")

@ParameterizedTest
@ValueSource(strings = {"1 work", "1 wek", "1 k"})
public void testGetTimeDurationShouldHandleInvalidAbbreviations(String week) {
Expand All @@ -94,7 +92,7 @@ public void testGetTimeDurationShouldHandleInvalidAbbreviations(String week) {
/**
* New feature test
*/
@SuppressWarnings("deprecation")

@ParameterizedTest
@ValueSource(strings={"1week", "1wk", "1w", "1wks", "1weeks"})
public void testGetTimeDurationShouldHandleNoSpaceInInput(String week) {
Expand All @@ -104,7 +102,7 @@ public void testGetTimeDurationShouldHandleNoSpaceInInput(String week) {
/**
* New feature test
*/
@SuppressWarnings("deprecation")

@ParameterizedTest
@ValueSource(strings={"10 ms", "10 millis", "10 milliseconds"})
public void testGetTimeDurationWithWholeNumbers(String whole){
Expand All @@ -114,7 +112,7 @@ public void testGetTimeDurationWithWholeNumbers(String whole){
/**
* New feature test
*/
@SuppressWarnings("deprecation")

@ParameterizedTest
@ValueSource(strings={"0.010 s", "0.010 seconds"})
public void testGetTimeDurationWithDecimalNumbers(String decimal){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -198,8 +199,11 @@ public RegisteredFlow registerFlow(final FlowRegistryClientConfigurationContext
try {
final FlowClient flowClient = getFlowClient(context);

if (flowClient.getByBucket(flow.getBucketIdentifier()).stream().map(f -> f.getName()).collect(Collectors.toSet()).contains(flow.getName())) {
throw new FlowAlreadyExistsException(String.format("Flow %s within bucket %s already exists", flow.getName(), flow.getBucketIdentifier()));
final List<VersionedFlow> versionedFlows = flowClient.getByBucket(flow.getBucketIdentifier());
final boolean matched = versionedFlows.stream()
.anyMatch(versionedFlow -> Objects.equals(versionedFlow.getName(), flow.getName()));
if (matched) {
throw new FlowAlreadyExistsException("Flow %s within bucket %s already exists".formatted(flow.getName(), flow.getBucketIdentifier()));
}

return NifiRegistryUtil.convert(flowClient.create(NifiRegistryUtil.convert(flow)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ public class FlowRegistryClientDTO {
private String name;
private String description;

@Deprecated // URI is kept for handling legacy calls, but FlowRegistryClient implementations should depend on the properties.
private String uri;

private String type;
private BundleDTO bundle;

Expand Down Expand Up @@ -83,17 +80,7 @@ public void setDescription(String description) {
this.description = description;
}

@Deprecated
public String getUri() {
return uri;
}

@Deprecated
public void setUri(String uri) {
this.uri = uri;
}

@ApiModelProperty(value = "The type of the controller service.")
@ApiModelProperty(value = "The type of the registry client.")
public String getType() {
return type;
}
Expand All @@ -102,7 +89,7 @@ public void setType(String type) {
this.type = type;
}

@ApiModelProperty(value = "The details of the artifact that bundled this processor type.")
@ApiModelProperty(value = "The details of the artifact that bundled this registry client type.")
public BundleDTO getBundle() {
return bundle;
}
Expand All @@ -111,7 +98,7 @@ public void setBundle(BundleDTO bundle) {
this.bundle = bundle;
}

@ApiModelProperty(value = "The properties of the controller service.")
@ApiModelProperty(value = "The properties of the registry client.")
public Map<String, String> getProperties() {
return properties;
}
Expand All @@ -120,7 +107,7 @@ public void setProperties(Map<String, String> properties) {
this.properties = properties;
}

@ApiModelProperty(value = "The descriptors for the controller service properties.")
@ApiModelProperty(value = "The descriptors for the registry client properties.")
public Map<String, PropertyDescriptorDTO> getDescriptors() {
return descriptors;
}
Expand All @@ -138,11 +125,8 @@ public void setSensitiveDynamicPropertyNames(final Set<String> sensitiveDynamicP
this.sensitiveDynamicPropertyNames = sensitiveDynamicPropertyNames;
}

/**
* @return whether this reporting task supports sensitive dynamic properties
*/
@ApiModelProperty(
value = "Whether the reporting task supports sensitive dynamic properties."
value = "Whether the registry client supports sensitive dynamic properties."
)
public Boolean getSupportsSensitiveDynamicProperties() {
return supportsSensitiveDynamicProperties;
Expand All @@ -152,11 +136,8 @@ public void setSupportsSensitiveDynamicProperties(final Boolean supportsSensitiv
this.supportsSensitiveDynamicProperties = supportsSensitiveDynamicProperties;
}

/**
* @return whether this reporting task requires elevated privileges
*/
@ApiModelProperty(
value = "Whether the reporting task requires elevated privileges."
value = "Whether the registry client requires elevated privileges."
)
public Boolean getRestricted() {
return restricted;
Expand All @@ -166,11 +147,8 @@ public void setRestricted(Boolean restricted) {
this.restricted = restricted;
}

/**
* @return Whether the reporting task has been deprecated.
*/
@ApiModelProperty(
value = "Whether the reporting task has been deprecated."
value = "Whether the registry client has been deprecated."
)
public Boolean getDeprecated() {
return deprecated;
Expand Down Expand Up @@ -208,11 +186,8 @@ public void setMultipleVersionsAvailable(Boolean setMultipleVersionsAvailable) {
this.setMultipleVersionsAvailable = setMultipleVersionsAvailable;
}

/**
* @return currently configured annotation data for the reporting task
*/
@ApiModelProperty(
value = "The annotation data for the repoting task. This is how the custom UI relays configuration to the reporting task."
value = "The annotation data for the registry client. This is how the custom UI relays configuration to the registry client."
)
public String getAnnotationData() {
return annotationData;
Expand All @@ -222,14 +197,9 @@ public void setAnnotationData(String annotationData) {
this.annotationData = annotationData;
}

/**
* Gets the validation errors from this reporting task. These validation errors represent the problems with the reporting task that must be resolved before it can be scheduled to run.
*
* @return The validation errors
*/
@ApiModelProperty(
value = "Gets the validation errors from the reporting task. These validation errors represent the problems with the reporting task that must be resolved before "
+ "it can be scheduled to run."
value = "Gets the validation errors from the registry client. These validation errors represent the problems with the registry client that must be resolved before "
+ "it can be used for interacting with the flow registry."
)
public Collection<String> getValidationErrors() {
return validationErrors;
Expand All @@ -239,7 +209,7 @@ public void setValidationErrors(Collection<String> validationErrors) {
this.validationErrors = validationErrors;
}

@ApiModelProperty(value = "Indicates whether the Processor is valid, invalid, or still in the process of validating (i.e., it is unknown whether or not the Processor is valid)",
@ApiModelProperty(value = "Indicates whether the Registry Client is valid, invalid, or still in the process of validating (i.e., it is unknown whether or not the Registry Client is valid)",
accessMode = ApiModelProperty.AccessMode.READ_ONLY,
allowableValues = VALID + ", " + INVALID + ", " + VALIDATING)
public String getValidationStatus() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,6 @@ public FlowRegistryClientDTO getComponent() {
return registry;
}

// Note: this duplication is needed for the {@code org.apache.nifi.web.api.FlowResource} to maintain backward compatibility}
@Deprecated
public FlowRegistryClientDTO getRegistry() {
return registry;
}

public void setComponent(FlowRegistryClientDTO component) {
this.registry = component;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,6 @@
*/
package org.apache.nifi.documentation.html;

import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import javax.xml.stream.FactoryConfigurationError;
import javax.xml.stream.XMLOutputFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;
import org.apache.nifi.annotation.behavior.DynamicProperties;
import org.apache.nifi.annotation.behavior.DynamicProperty;
import org.apache.nifi.annotation.behavior.InputRequirement;
Expand Down Expand Up @@ -63,6 +49,21 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.xml.stream.FactoryConfigurationError;
import javax.xml.stream.XMLOutputFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

/**
* Generates HTML documentation for a ConfigurableComponent. This class is used
* to generate documentation for ControllerService, ParameterProvider, and ReportingTask because
Expand Down Expand Up @@ -831,7 +832,8 @@ private boolean containsExpressionLanguage(final ConfigurableComponent component
}
return false;
}
@SuppressWarnings("deprecation")


private void writeDynamicProperties(final ConfigurableComponent configurableComponent,
final XMLStreamWriter xmlStreamWriter) throws XMLStreamException {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,6 @@ public boolean isLossTolerant() {
}

@Override
@SuppressWarnings("deprecation")
public boolean isIsolated() {
return executionNode == ExecutionNode.PRIMARY;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -502,11 +502,7 @@ private String determineRegistryId(final VersionedFlowCoordinates coordinates) {
}
}

final String location = coordinates.getStorageLocation() == null ? coordinates.getRegistryUrl() : coordinates.getStorageLocation();
if (location == null) {
return null;
}

final String location = coordinates.getStorageLocation();
for (final FlowRegistryClientNode flowRegistryClientNode : context.getFlowManager().getAllFlowRegistryClients()) {
final boolean locationApplicable;
try {
Expand Down
Loading