forked from apache/nifi
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NIFI-12220 Added ability to create Controller Services from migratePr…
…operties - Added ability to get raw property values from PropertyConfiguration instead of just effective values - Updated TestRunner to allow for testing these migration methods - Auto-enable newly created controller services if they are valid - Eliminated Proxy properties in all AWS processors and instead just make use of the Proxy Configuration controller service - Eliminated authentication properties from AWS processors and migrated all processors to using Controller Service or authentication This closes apache#7874 Signed-off-by: David Handermann <[email protected]>
- Loading branch information
1 parent
07b35e0
commit a44b633
Showing
95 changed files
with
2,493 additions
and
2,636 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
138 changes: 138 additions & 0 deletions
138
nifi-mock/src/main/java/org/apache/nifi/util/MockPropertyConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
/* | ||
* 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.util; | ||
|
||
import org.apache.nifi.migration.PropertyConfiguration; | ||
|
||
import java.util.Collections; | ||
import java.util.HashMap; | ||
import java.util.HashSet; | ||
import java.util.Map; | ||
import java.util.Optional; | ||
import java.util.Set; | ||
import java.util.UUID; | ||
|
||
public class MockPropertyConfiguration implements PropertyConfiguration { | ||
private final Map<String, String> propertyRenames = new HashMap<>(); | ||
private final Set<String> propertiesRemoved = new HashSet<>(); | ||
private final Set<String> propertiesUpdated = new HashSet<>(); | ||
private final Map<String, String> rawProperties; | ||
private final Set<CreatedControllerService> createdControllerServices = new HashSet<>(); | ||
|
||
|
||
public MockPropertyConfiguration(final Map<String, String> propertyValues) { | ||
this.rawProperties = new HashMap<>(propertyValues); | ||
} | ||
|
||
public PropertyMigrationResult toPropertyMigrationResult() { | ||
return new PropertyMigrationResult() { | ||
|
||
@Override | ||
public Set<String> getPropertiesRemoved() { | ||
return Collections.unmodifiableSet(propertiesRemoved); | ||
} | ||
|
||
@Override | ||
public Map<String, String> getPropertiesRenamed() { | ||
return Collections.unmodifiableMap(propertyRenames); | ||
} | ||
|
||
@Override | ||
public Set<CreatedControllerService> getCreatedControllerServices() { | ||
return Collections.unmodifiableSet(createdControllerServices); | ||
} | ||
|
||
@Override | ||
public Set<String> getPropertiesUpdated() { | ||
return Collections.unmodifiableSet(propertiesUpdated); | ||
} | ||
}; | ||
} | ||
|
||
@Override | ||
public boolean renameProperty(final String propertyName, final String newName) { | ||
propertyRenames.put(propertyName, newName); | ||
|
||
final boolean hasProperty = hasProperty(propertyName); | ||
if (!hasProperty) { | ||
return false; | ||
} | ||
|
||
final String value = rawProperties.remove(propertyName); | ||
rawProperties.put(newName, value); | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean removeProperty(final String propertyName) { | ||
propertiesRemoved.add(propertyName); | ||
|
||
if (!hasProperty(propertyName)) { | ||
return false; | ||
} | ||
|
||
rawProperties.remove(propertyName); | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean hasProperty(final String propertyName) { | ||
return rawProperties.containsKey(propertyName); | ||
} | ||
|
||
@Override | ||
public boolean isPropertySet(final String propertyName) { | ||
return rawProperties.get(propertyName) != null; | ||
} | ||
|
||
@Override | ||
public void setProperty(final String propertyName, final String propertyValue) { | ||
propertiesUpdated.add(propertyName); | ||
rawProperties.put(propertyName, propertyValue); | ||
} | ||
|
||
@Override | ||
public Optional<String> getPropertyValue(final String propertyName) { | ||
return getRawPropertyValue(propertyName); | ||
} | ||
|
||
@Override | ||
public Optional<String> getRawPropertyValue(final String propertyName) { | ||
return Optional.ofNullable(rawProperties.get(propertyName)); | ||
} | ||
|
||
@Override | ||
public Map<String, String> getProperties() { | ||
return getRawProperties(); | ||
} | ||
|
||
@Override | ||
public Map<String, String> getRawProperties() { | ||
return Collections.unmodifiableMap(rawProperties); | ||
} | ||
|
||
@Override | ||
public String createControllerService(final String implementationClassName, final Map<String, String> serviceProperties) { | ||
final String serviceId = UUID.randomUUID().toString(); | ||
createdControllerServices.add(new CreatedControllerService(serviceId, implementationClassName, serviceProperties)); | ||
return serviceId; | ||
} | ||
|
||
public record CreatedControllerService(String id, String implementationClassName, Map<String, String> serviceProperties) { | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
nifi-mock/src/main/java/org/apache/nifi/util/PropertyMigrationResult.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* 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.util; | ||
|
||
import org.apache.nifi.components.PropertyDescriptor; | ||
|
||
import java.util.Map; | ||
import java.util.Set; | ||
|
||
public interface PropertyMigrationResult { | ||
|
||
/** | ||
* @return a set containing the names of all properties that were removed | ||
*/ | ||
Set<String> getPropertiesRemoved(); | ||
|
||
/** | ||
* @return a mapping of previous property names to the new names of those properties | ||
*/ | ||
Map<String, String> getPropertiesRenamed(); | ||
|
||
/** | ||
* @return a set of all controller services that were added | ||
*/ | ||
Set<MockPropertyConfiguration.CreatedControllerService> getCreatedControllerServices(); | ||
|
||
/** | ||
* @return a set of all properties whose values were updated via calls to {@link org.apache.nifi.migration.PropertyConfiguration#setProperty(String, String)} or | ||
* {@link org.apache.nifi.migration.PropertyConfiguration#setProperty(PropertyDescriptor, String)}. | ||
*/ | ||
Set<String> getPropertiesUpdated(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.