NIFI-9288: Updated data model to use for cnofig verification requests so that only properties are necessary not the full component/config dtos. Also added endpoint necessary for determining which attributes are referenced by a component's properties and removed the referencedAttributes field from the compnoents themselves, since there's now a new endpoint for it. Also fixed a bug that was encountered where the VerifyConfigRequestDTO's complete flag was incorrect in case of failures

Signed-off-by: Joe Gresock <jgresock@gmail.com>

This closes #5452.
This commit is contained in:
Mark Payne 2021-10-11 11:18:42 -04:00 committed by Joe Gresock
parent 207894ebe0
commit 151a9361fa
No known key found for this signature in database
GPG Key ID: 37F5B9B6E258C8B7
35 changed files with 578 additions and 579 deletions

View File

@ -0,0 +1,57 @@
/*
* 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.web.api.dto;
import io.swagger.annotations.ApiModelProperty;
import javax.xml.bind.annotation.XmlType;
import java.util.Map;
@XmlType(name = "configurationAnalysis")
public class ConfigurationAnalysisDTO {
private String componentId;
private Map<String, String> properties;
private Map<String, String> referencedAttributes;
@ApiModelProperty("The ID of the component")
public String getComponentId() {
return componentId;
}
public void setComponentId(final String componentId) {
this.componentId = componentId;
}
@ApiModelProperty("The configured properties for the component")
public Map<String, String> getProperties() {
return properties;
}
public void setProperties(final Map<String, String> properties) {
this.properties = properties;
}
@ApiModelProperty("The attributes that are referenced by the properties, mapped to recently used values")
public Map<String, String> getReferencedAttributes() {
return referencedAttributes;
}
public void setReferencedAttributes(final Map<String, String> referencedAttributes) {
this.referencedAttributes = referencedAttributes;
}
}

View File

@ -17,7 +17,6 @@
package org.apache.nifi.web.api.dto;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiModelProperty.AccessMode;
import org.apache.nifi.web.api.entity.ControllerServiceReferencingComponentEntity;
import javax.xml.bind.annotation.XmlType;
@ -46,7 +45,6 @@ public class ControllerServiceDTO extends ComponentDTO {
private Boolean deprecated;
private Boolean isExtensionMissing;
private Boolean multipleVersionsAvailable;
private Set<String> referencedAttributes;
private Map<String, String> properties;
private Map<String, PropertyDescriptorDTO> descriptors;
@ -315,15 +313,6 @@ public class ControllerServiceDTO extends ComponentDTO {
this.validationStatus = validationStatus;
}
@ApiModelProperty(value = "The set of FlowFile Attributes that are referenced via Expression Language by the configured properties", accessMode = AccessMode.READ_ONLY)
public Set<String> getReferencedAttributes() {
return referencedAttributes;
}
public void setReferencedAttributes(final Set<String> referencedAttributes) {
this.referencedAttributes = referencedAttributes;
}
@Override
public int hashCode() {
final String id = getId();

View File

@ -17,7 +17,6 @@
package org.apache.nifi.web.api.dto;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiModelProperty.AccessMode;
import javax.xml.bind.annotation.XmlType;
import java.util.Map;
@ -51,7 +50,6 @@ public class ProcessorConfigDTO {
private Map<String, String> defaultConcurrentTasks;
private Map<String, String> defaultSchedulingPeriod;
private Set<String> referencedAttributes;
public ProcessorConfigDTO() {
@ -310,12 +308,4 @@ public class ProcessorConfigDTO {
this.defaultSchedulingPeriod = defaultSchedulingPeriod;
}
@ApiModelProperty(value = "The set of FlowFile Attributes that are referenced via Expression Language by the configured properties", accessMode = AccessMode.READ_ONLY)
public Set<String> getReferencedAttributes() {
return referencedAttributes;
}
public void setReferencedAttributes(final Set<String> referencedAttributes) {
this.referencedAttributes = referencedAttributes;
}
}

View File

@ -24,29 +24,29 @@ import javax.xml.bind.annotation.XmlType;
import java.util.List;
import java.util.Map;
@XmlType(name = "verifyProcessorConfigRequest")
public class VerifyProcessorConfigRequestDTO extends AsynchronousRequestDTO<VerifyConfigUpdateStepDTO> {
private String processorId;
private ProcessorConfigDTO processorConfigDTO;
@XmlType(name = "verifyConfigRequest")
public class VerifyConfigRequestDTO extends AsynchronousRequestDTO<VerifyConfigUpdateStepDTO> {
private String componentId;
private Map<String, String> properties;
private Map<String, String> attributes;
private List<ConfigVerificationResultDTO> results;
@ApiModelProperty("The ID of the Processor whose configuration was verified")
public String getProcessorId() {
return processorId;
@ApiModelProperty("The ID of the component whose configuration was verified")
public String getComponentId() {
return componentId;
}
public void setProcessorId(final String processorId) {
this.processorId = processorId;
public void setComponentId(final String componentId) {
this.componentId = componentId;
}
@ApiModelProperty("The configuration for the Processor")
public ProcessorConfigDTO getProcessorConfig() {
return processorConfigDTO;
@ApiModelProperty("The configured component properties")
public Map<String, String> getProperties() {
return properties;
}
public void setProcessorConfig(final ProcessorConfigDTO processorConfigDTO) {
this.processorConfigDTO = processorConfigDTO;
public void setProperties(final Map<String, String> properties) {
this.properties = properties;
}
@ApiModelProperty("FlowFile Attributes that should be used to evaluate Expression Language for resolving property values")

View File

@ -1,69 +0,0 @@
/*
* 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.web.api.dto;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiModelProperty.AccessMode;
import javax.xml.bind.annotation.XmlType;
import java.util.List;
import java.util.Map;
@XmlType(name = "verifyControllerServiceConfigRequest")
public class VerifyControllerServiceConfigRequestDTO extends AsynchronousRequestDTO<VerifyConfigUpdateStepDTO> {
private String controllerServiceId;
private ControllerServiceDTO controllerService;
private Map<String, String> attributes;
private List<ConfigVerificationResultDTO> results;
@ApiModelProperty("The ID of the Controller Service whose configuration was verified")
public String getControllerServiceId() {
return controllerServiceId;
}
public void setControllerServiceId(final String controllerServiceId) {
this.controllerServiceId = controllerServiceId;
}
@ApiModelProperty("The Controller Service")
public ControllerServiceDTO getControllerService() {
return controllerService;
}
public void setControllerService(final ControllerServiceDTO controllerService) {
this.controllerService = controllerService;
}
@ApiModelProperty("FlowFile Attributes that should be used to evaluate Expression Language for resolving property values")
public Map<String, String> getAttributes() {
return attributes;
}
public void setAttributes(final Map<String, String> attributes) {
this.attributes = attributes;
}
@ApiModelProperty(value="The Results of the verification", accessMode = AccessMode.READ_ONLY)
public List<ConfigVerificationResultDTO> getResults() {
return results;
}
public void setResults(final List<ConfigVerificationResultDTO> results) {
this.results = results;
}
}

View File

@ -1,58 +0,0 @@
/*
* 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.web.api.dto;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiModelProperty.AccessMode;
import javax.xml.bind.annotation.XmlType;
import java.util.List;
@XmlType(name = "verifyReportingTaskConfigRequest")
public class VerifyReportingTaskConfigRequestDTO extends AsynchronousRequestDTO<VerifyConfigUpdateStepDTO> {
private String reportingTaskId;
private ReportingTaskDTO reportingTask;
private List<ConfigVerificationResultDTO> results;
@ApiModelProperty("The ID of the Controller Service whose configuration was verified")
public String getReportingTaskId() {
return reportingTaskId;
}
public void setReportingTaskId(final String reportingTaskId) {
this.reportingTaskId = reportingTaskId;
}
@ApiModelProperty("The Controller Service")
public ReportingTaskDTO getReportingTask() {
return reportingTask;
}
public void setReportingTask(final ReportingTaskDTO reportingTask) {
this.reportingTask = reportingTask;
}
@ApiModelProperty(value="The Results of the verification", accessMode = AccessMode.READ_ONLY)
public List<ConfigVerificationResultDTO> getResults() {
return results;
}
public void setResults(final List<ConfigVerificationResultDTO> results) {
this.results = results;
}
}

View File

@ -18,20 +18,20 @@
package org.apache.nifi.web.api.entity;
import io.swagger.annotations.ApiModelProperty;
import org.apache.nifi.web.api.dto.VerifyReportingTaskConfigRequestDTO;
import org.apache.nifi.web.api.dto.ConfigurationAnalysisDTO;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name="verifyReportingTaskConfigRequest")
public class VerifyReportingTaskConfigRequestEntity extends Entity {
private VerifyReportingTaskConfigRequestDTO request;
@XmlRootElement(name = "configurationAnalysis")
public class ConfigurationAnalysisEntity extends Entity {
private ConfigurationAnalysisDTO configurationAnalysis;
@ApiModelProperty("The request")
public VerifyReportingTaskConfigRequestDTO getRequest() {
return request;
@ApiModelProperty("The configuration analysis")
public ConfigurationAnalysisDTO getConfigurationAnalysis() {
return configurationAnalysis;
}
public void setRequest(final VerifyReportingTaskConfigRequestDTO request) {
this.request = request;
public void setConfigurationAnalysis(final ConfigurationAnalysisDTO configurationAnalysis) {
this.configurationAnalysis = configurationAnalysis;
}
}

View File

@ -18,20 +18,20 @@
package org.apache.nifi.web.api.entity;
import io.swagger.annotations.ApiModelProperty;
import org.apache.nifi.web.api.dto.VerifyProcessorConfigRequestDTO;
import org.apache.nifi.web.api.dto.VerifyConfigRequestDTO;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name="verifyProcessorConfigRequest")
public class VerifyProcessorConfigRequestEntity extends Entity {
private VerifyProcessorConfigRequestDTO request;
@XmlRootElement(name="verifyConfigRequest")
public class VerifyConfigRequestEntity extends Entity {
private VerifyConfigRequestDTO request;
@ApiModelProperty("The request")
public VerifyProcessorConfigRequestDTO getRequest() {
public VerifyConfigRequestDTO getRequest() {
return request;
}
public void setRequest(final VerifyProcessorConfigRequestDTO request) {
public void setRequest(final VerifyConfigRequestDTO request) {
this.request = request;
}
}

View File

@ -1,37 +0,0 @@
/*
* 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.web.api.entity;
import io.swagger.annotations.ApiModelProperty;
import org.apache.nifi.web.api.dto.VerifyControllerServiceConfigRequestDTO;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name="verifyControllerServiceConfigRequest")
public class VerifyControllerServiceConfigRequestEntity extends Entity {
private VerifyControllerServiceConfigRequestDTO request;
@ApiModelProperty("The request")
public VerifyControllerServiceConfigRequestDTO getRequest() {
return request;
}
public void setRequest(final VerifyControllerServiceConfigRequestDTO request) {
this.request = request;
}
}

View File

@ -77,9 +77,7 @@ import org.apache.nifi.cluster.coordination.http.endpoints.UserGroupEndpointMerg
import org.apache.nifi.cluster.coordination.http.endpoints.UserGroupsEndpointMerger;
import org.apache.nifi.cluster.coordination.http.endpoints.UsersEndpointMerger;
import org.apache.nifi.cluster.coordination.http.endpoints.VariableRegistryEndpointMerger;
import org.apache.nifi.cluster.coordination.http.endpoints.VerifyControllerServiceConfigEndpointMerger;
import org.apache.nifi.cluster.coordination.http.endpoints.VerifyProcessorConfigEndpointMerger;
import org.apache.nifi.cluster.coordination.http.endpoints.VerifyReportingTaskConfigEndpointMerger;
import org.apache.nifi.cluster.coordination.http.endpoints.VerifyConfigEndpointMerger;
import org.apache.nifi.cluster.coordination.http.replication.RequestReplicator;
import org.apache.nifi.cluster.manager.NodeResponse;
import org.apache.nifi.stream.io.NullOutputStream;
@ -172,9 +170,7 @@ public class StandardHttpResponseMapper implements HttpResponseMapper {
endpointMergers.add(new ParameterContextsEndpointMerger());
endpointMergers.add(new ParameterContextEndpointMerger());
endpointMergers.add(new ParameterContextUpdateEndpointMerger());
endpointMergers.add(new VerifyProcessorConfigEndpointMerger());
endpointMergers.add(new VerifyControllerServiceConfigEndpointMerger());
endpointMergers.add(new VerifyReportingTaskConfigEndpointMerger());
endpointMergers.add(new VerifyConfigEndpointMerger());
}
@Override

View File

@ -20,8 +20,8 @@ package org.apache.nifi.cluster.coordination.http.endpoints;
import org.apache.nifi.cluster.manager.NodeResponse;
import org.apache.nifi.cluster.protocol.NodeIdentifier;
import org.apache.nifi.web.api.dto.ConfigVerificationResultDTO;
import org.apache.nifi.web.api.dto.VerifyProcessorConfigRequestDTO;
import org.apache.nifi.web.api.entity.VerifyProcessorConfigRequestEntity;
import org.apache.nifi.web.api.dto.VerifyConfigRequestDTO;
import org.apache.nifi.web.api.entity.VerifyConfigRequestEntity;
import java.net.URI;
import java.util.List;
@ -29,24 +29,28 @@ import java.util.Map;
import java.util.Set;
import java.util.regex.Pattern;
public class VerifyProcessorConfigEndpointMerger extends AbstractSingleEntityEndpoint<VerifyProcessorConfigRequestEntity> {
public class VerifyConfigEndpointMerger extends AbstractSingleEntityEndpoint<VerifyConfigRequestEntity> {
public static final Pattern VERIFY_PROCESSOR_CONFIG_URI_PATTERN = Pattern.compile("/nifi-api/processors/[a-f0-9\\-]{36}/config/verification-requests(/[a-f0-9\\-]{36})?");
public static final Pattern VERIFY_CONTROLLER_SERVICE_CONFIG_URI_PATTERN = Pattern.compile("/nifi-api/controller-services/[a-f0-9\\-]{36}/config/verification-requests(/[a-f0-9\\-]{36})?");
public static final Pattern VERIFY_REPORTING_TASK_CONFIG_URI_PATTERN = Pattern.compile("/nifi-api/reporting-tasks/[a-f0-9\\-]{36}/config/verification-requests(/[a-f0-9\\-]{36})?");
@Override
protected Class<VerifyProcessorConfigRequestEntity> getEntityClass() {
return VerifyProcessorConfigRequestEntity.class;
protected Class<VerifyConfigRequestEntity> getEntityClass() {
return VerifyConfigRequestEntity.class;
}
@Override
public boolean canHandle(final URI uri, final String method) {
return VERIFY_PROCESSOR_CONFIG_URI_PATTERN.matcher(uri.getPath()).matches();
return VERIFY_PROCESSOR_CONFIG_URI_PATTERN.matcher(uri.getPath()).matches()
|| VERIFY_CONTROLLER_SERVICE_CONFIG_URI_PATTERN.matcher(uri.getPath()).matches()
|| VERIFY_REPORTING_TASK_CONFIG_URI_PATTERN.matcher(uri.getPath()).matches();
}
@Override
protected void mergeResponses(final VerifyProcessorConfigRequestEntity clientEntity, final Map<NodeIdentifier, VerifyProcessorConfigRequestEntity> entityMap,
protected void mergeResponses(final VerifyConfigRequestEntity clientEntity, final Map<NodeIdentifier, VerifyConfigRequestEntity> entityMap,
final Set<NodeResponse> successfulResponses, final Set<NodeResponse> problematicResponses) {
final VerifyProcessorConfigRequestDTO requestDto = clientEntity.getRequest();
final VerifyConfigRequestDTO requestDto = clientEntity.getRequest();
final List<ConfigVerificationResultDTO> results = requestDto.getResults();
// If the result hasn't been set, the task is not yet complete, so we don't have to bother merging the results.
@ -56,9 +60,9 @@ public class VerifyProcessorConfigEndpointMerger extends AbstractSingleEntityEnd
// Aggregate the Config Verification Results across all nodes into a single List
final ConfigVerificationResultMerger resultMerger = new ConfigVerificationResultMerger();
for (final Map.Entry<NodeIdentifier, VerifyProcessorConfigRequestEntity> entry : entityMap.entrySet()) {
for (final Map.Entry<NodeIdentifier, VerifyConfigRequestEntity> entry : entityMap.entrySet()) {
final NodeIdentifier nodeId = entry.getKey();
final VerifyProcessorConfigRequestEntity entity = entry.getValue();
final VerifyConfigRequestEntity entity = entry.getValue();
final List<ConfigVerificationResultDTO> nodeResults = entity.getRequest().getResults();
resultMerger.addNodeResults(nodeId, nodeResults);

View File

@ -1,73 +0,0 @@
/*
* 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.cluster.coordination.http.endpoints;
import org.apache.nifi.cluster.manager.NodeResponse;
import org.apache.nifi.cluster.protocol.NodeIdentifier;
import org.apache.nifi.web.api.dto.ConfigVerificationResultDTO;
import org.apache.nifi.web.api.dto.VerifyControllerServiceConfigRequestDTO;
import org.apache.nifi.web.api.entity.VerifyControllerServiceConfigRequestEntity;
import java.net.URI;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.regex.Pattern;
public class VerifyControllerServiceConfigEndpointMerger extends AbstractSingleEntityEndpoint<VerifyControllerServiceConfigRequestEntity> {
public static final Pattern VERIFY_PROCESSOR_CONFIG_URI_PATTERN = Pattern.compile("/nifi-api/controller-services/[a-f0-9\\-]{36}/config/verification-requests(/[a-f0-9\\-]{36})?");
@Override
protected Class<VerifyControllerServiceConfigRequestEntity> getEntityClass() {
return VerifyControllerServiceConfigRequestEntity.class;
}
@Override
public boolean canHandle(final URI uri, final String method) {
return VERIFY_PROCESSOR_CONFIG_URI_PATTERN.matcher(uri.getPath()).matches();
}
@Override
protected void mergeResponses(final VerifyControllerServiceConfigRequestEntity clientEntity, final Map<NodeIdentifier, VerifyControllerServiceConfigRequestEntity> entityMap,
final Set<NodeResponse> successfulResponses, final Set<NodeResponse> problematicResponses) {
final VerifyControllerServiceConfigRequestDTO requestDto = clientEntity.getRequest();
final List<ConfigVerificationResultDTO> results = requestDto.getResults();
// If the result hasn't been set, the task is not yet complete, so we don't have to bother merging the results.
if (results == null) {
return;
}
// Aggregate the Config Verification Results across all nodes into a single List
final ConfigVerificationResultMerger resultMerger = new ConfigVerificationResultMerger();
for (final Map.Entry<NodeIdentifier, VerifyControllerServiceConfigRequestEntity> entry : entityMap.entrySet()) {
final NodeIdentifier nodeId = entry.getKey();
final VerifyControllerServiceConfigRequestEntity entity = entry.getValue();
final List<ConfigVerificationResultDTO> nodeResults = entity.getRequest().getResults();
resultMerger.addNodeResults(nodeId, nodeResults);
}
final List<ConfigVerificationResultDTO> aggregateResults = resultMerger.computeAggregateResults();
clientEntity.getRequest().setResults(aggregateResults);
}
}

View File

@ -1,71 +0,0 @@
/*
* 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.cluster.coordination.http.endpoints;
import org.apache.nifi.cluster.manager.NodeResponse;
import org.apache.nifi.cluster.protocol.NodeIdentifier;
import org.apache.nifi.web.api.dto.ConfigVerificationResultDTO;
import org.apache.nifi.web.api.dto.VerifyReportingTaskConfigRequestDTO;
import org.apache.nifi.web.api.entity.VerifyReportingTaskConfigRequestEntity;
import java.net.URI;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.regex.Pattern;
public class VerifyReportingTaskConfigEndpointMerger extends AbstractSingleEntityEndpoint<VerifyReportingTaskConfigRequestEntity> {
public static final Pattern VERIFY_REPORTING_TASK_CONFIG_URI_PATTERN = Pattern.compile("/nifi-api/reporting-tasks/[a-f0-9\\-]{36}/config/verification-requests(/[a-f0-9\\-]{36})?");
@Override
protected Class<VerifyReportingTaskConfigRequestEntity> getEntityClass() {
return VerifyReportingTaskConfigRequestEntity.class;
}
@Override
public boolean canHandle(final URI uri, final String method) {
return VERIFY_REPORTING_TASK_CONFIG_URI_PATTERN.matcher(uri.getPath()).matches();
}
@Override
protected void mergeResponses(final VerifyReportingTaskConfigRequestEntity clientEntity, final Map<NodeIdentifier, VerifyReportingTaskConfigRequestEntity> entityMap,
final Set<NodeResponse> successfulResponses, final Set<NodeResponse> problematicResponses) {
final VerifyReportingTaskConfigRequestDTO requestDto = clientEntity.getRequest();
final List<ConfigVerificationResultDTO> results = requestDto.getResults();
// If the result hasn't been set, the task is not yet complete, so we don't have to bother merging the results.
if (results == null) {
return;
}
// Aggregate the Config Verification Results across all nodes into a single List
final ConfigVerificationResultMerger resultMerger = new ConfigVerificationResultMerger();
for (final Map.Entry<NodeIdentifier, VerifyReportingTaskConfigRequestEntity> entry : entityMap.entrySet()) {
final NodeIdentifier nodeId = entry.getKey();
final VerifyReportingTaskConfigRequestEntity entity = entry.getValue();
final List<ConfigVerificationResultDTO> nodeResults = entity.getRequest().getResults();
resultMerger.addNodeResults(nodeId, nodeResults);
}
final List<ConfigVerificationResultDTO> aggregateResults = resultMerger.computeAggregateResults();
clientEntity.getRequest().setResults(aggregateResults);
}
}

View File

@ -563,7 +563,9 @@ public abstract class AbstractComponentNode implements ComponentNode {
final Map<PropertyDescriptor, String> props = new LinkedHashMap<>();
for (final PropertyDescriptor descriptor : supported) {
props.put(descriptor, null);
if (descriptor != null) {
props.put(descriptor, descriptor.getDefaultValue());
}
}
properties.forEach((descriptor, config) -> props.put(descriptor, valueFunction.apply(config)));

View File

@ -238,7 +238,6 @@ public class TemplateUtils {
processorConfig.setCustomUiUrl(null);
processorConfig.setDefaultConcurrentTasks(null);
processorConfig.setDefaultSchedulingPeriod(null);
processorConfig.setReferencedAttributes(null);
processorConfig.setAutoTerminatedRelationships(null);
}
@ -307,7 +306,6 @@ public class TemplateUtils {
serviceDTO.setCustomUiUrl(null);
serviceDTO.setValidationErrors(null);
serviceDTO.setValidationStatus(null);
serviceDTO.setReferencedAttributes(null);
}
}

View File

@ -25,13 +25,13 @@ import org.apache.nifi.components.ConfigurableComponent;
import org.apache.nifi.controller.ScheduledState;
import org.apache.nifi.controller.repository.claim.ContentDirection;
import org.apache.nifi.controller.service.ControllerServiceState;
import org.apache.nifi.flow.VersionedProcessGroup;
import org.apache.nifi.groups.ProcessGroup;
import org.apache.nifi.parameter.ParameterContext;
import org.apache.nifi.registry.flow.ExternalControllerServiceReference;
import org.apache.nifi.registry.flow.VersionedFlow;
import org.apache.nifi.registry.flow.VersionedFlowSnapshot;
import org.apache.nifi.registry.flow.VersionedParameterContext;
import org.apache.nifi.flow.VersionedProcessGroup;
import org.apache.nifi.web.api.dto.AccessPolicyDTO;
import org.apache.nifi.web.api.dto.AffectedComponentDTO;
import org.apache.nifi.web.api.dto.BulletinBoardDTO;
@ -59,7 +59,6 @@ import org.apache.nifi.web.api.dto.NodeDTO;
import org.apache.nifi.web.api.dto.ParameterContextDTO;
import org.apache.nifi.web.api.dto.PortDTO;
import org.apache.nifi.web.api.dto.ProcessGroupDTO;
import org.apache.nifi.web.api.dto.ProcessorConfigDTO;
import org.apache.nifi.web.api.dto.ProcessorDTO;
import org.apache.nifi.web.api.dto.PropertyDescriptorDTO;
import org.apache.nifi.web.api.dto.RegistryDTO;
@ -89,6 +88,7 @@ import org.apache.nifi.web.api.entity.AffectedComponentEntity;
import org.apache.nifi.web.api.entity.BucketEntity;
import org.apache.nifi.web.api.entity.BulletinEntity;
import org.apache.nifi.web.api.entity.ComponentValidationResultEntity;
import org.apache.nifi.web.api.entity.ConfigurationAnalysisEntity;
import org.apache.nifi.web.api.entity.ConnectionEntity;
import org.apache.nifi.web.api.entity.ConnectionStatisticsEntity;
import org.apache.nifi.web.api.entity.ConnectionStatusEntity;
@ -638,11 +638,19 @@ public interface NiFiServiceFacade {
/**
* Performs verification of the given Processor Configuration for the Processor with the given ID
* @param processorId the id of the processor
* @param processorConfig the configuration to verify
* @param properties the configured properties to verify
* @param attributes a map of values that can be used for resolving FlowFile attributes for Expression Language
* @return verification results
*/
List<ConfigVerificationResultDTO> verifyProcessorConfiguration(String processorId, ProcessorConfigDTO processorConfig, Map<String, String> attributes);
List<ConfigVerificationResultDTO> verifyProcessorConfiguration(String processorId, Map<String, String> properties, Map<String, String> attributes);
/**
* Performs analysis of the given properties, determining which attributes are referenced by properties
* @param processorId the ID of the processor
* @param properties the properties
* @return analysis results
*/
ConfigurationAnalysisEntity analyzeProcessorConfiguration(String processorId, Map<String, String> properties);
/**
* Verifies the specified processor can be removed.
@ -2046,12 +2054,19 @@ public interface NiFiServiceFacade {
/**
* Performs verification of the given Configuration for the Controller Service with the given ID
* @param controllerServiceId the id of the controller service
* @param controllerService the configuration to verify
* @param properties the configured properties to verify
* @param variables a map of values that can be used for resolving FlowFile attributes for Expression Language
* @return verification results
*/
List<ConfigVerificationResultDTO> verifyControllerServiceConfiguration(String controllerServiceId, ControllerServiceDTO controllerService, Map<String, String> variables);
List<ConfigVerificationResultDTO> verifyControllerServiceConfiguration(String controllerServiceId, Map<String, String> properties, Map<String, String> variables);
/**
* Performs analysis of the given properties, determining which attributes are referenced by properties
* @param controllerServiceId the ID of the Controller Service
* @param properties the properties
* @return analysis results
*/
ConfigurationAnalysisEntity analyzeControllerServiceConfiguration(String controllerServiceId, Map<String, String> properties);
/**
* Deletes the specified label.
@ -2141,10 +2156,18 @@ public interface NiFiServiceFacade {
/**
* Performs verification of the given Configuration for the Reporting Task with the given ID
* @param reportingTaskId the id of the reporting task
* @param reportingTask the configuration to verify
* @param properties the configured properties to verify
* @return verification results
*/
List<ConfigVerificationResultDTO> verifyReportingTaskConfiguration(String reportingTaskId, ReportingTaskDTO reportingTask);
List<ConfigVerificationResultDTO> verifyReportingTaskConfiguration(String reportingTaskId, Map<String, String> properties);
/**
* Performs analysis of the given properties, determining which attributes are referenced by properties
* @param reportingTaskId the ID of the Reporting Task
* @param properties the properties
* @return analysis results
*/
ConfigurationAnalysisEntity analyzeReportingTaskConfiguration(String reportingTaskId, Map<String, String> properties);
/**
* Deletes the specified reporting task.

View File

@ -25,6 +25,7 @@ import org.apache.nifi.action.FlowChangeAction;
import org.apache.nifi.action.Operation;
import org.apache.nifi.action.details.FlowChangePurgeDetails;
import org.apache.nifi.admin.service.AuditService;
import org.apache.nifi.attribute.expression.language.Query;
import org.apache.nifi.authorization.AccessDeniedException;
import org.apache.nifi.authorization.AccessPolicy;
import org.apache.nifi.authorization.AuthorizableLookup;
@ -74,6 +75,8 @@ import org.apache.nifi.controller.ControllerService;
import org.apache.nifi.controller.Counter;
import org.apache.nifi.controller.FlowController;
import org.apache.nifi.controller.ProcessorNode;
import org.apache.nifi.controller.PropertyConfiguration;
import org.apache.nifi.controller.PropertyConfigurationMapper;
import org.apache.nifi.controller.ReportingTaskNode;
import org.apache.nifi.controller.ScheduledState;
import org.apache.nifi.controller.Snippet;
@ -91,6 +94,7 @@ import org.apache.nifi.controller.status.ProcessGroupStatus;
import org.apache.nifi.controller.status.ProcessorStatus;
import org.apache.nifi.diagnostics.SystemDiagnostics;
import org.apache.nifi.events.BulletinFactory;
import org.apache.nifi.expression.ExpressionLanguageScope;
import org.apache.nifi.flow.VersionedComponent;
import org.apache.nifi.flow.VersionedConfigurableComponent;
import org.apache.nifi.flow.VersionedConnection;
@ -111,6 +115,7 @@ import org.apache.nifi.parameter.Parameter;
import org.apache.nifi.parameter.ParameterContext;
import org.apache.nifi.parameter.ParameterContextLookup;
import org.apache.nifi.parameter.ParameterDescriptor;
import org.apache.nifi.parameter.ParameterLookup;
import org.apache.nifi.parameter.ParameterReferenceManager;
import org.apache.nifi.parameter.StandardParameterContext;
import org.apache.nifi.prometheus.util.BulletinMetricsRegistry;
@ -174,6 +179,7 @@ import org.apache.nifi.web.api.dto.ComponentRestrictionPermissionDTO;
import org.apache.nifi.web.api.dto.ComponentStateDTO;
import org.apache.nifi.web.api.dto.ComponentValidationResultDTO;
import org.apache.nifi.web.api.dto.ConfigVerificationResultDTO;
import org.apache.nifi.web.api.dto.ConfigurationAnalysisDTO;
import org.apache.nifi.web.api.dto.ConnectionDTO;
import org.apache.nifi.web.api.dto.ControllerConfigurationDTO;
import org.apache.nifi.web.api.dto.ControllerDTO;
@ -251,6 +257,7 @@ import org.apache.nifi.web.api.entity.BucketEntity;
import org.apache.nifi.web.api.entity.BulletinEntity;
import org.apache.nifi.web.api.entity.ComponentReferenceEntity;
import org.apache.nifi.web.api.entity.ComponentValidationResultEntity;
import org.apache.nifi.web.api.entity.ConfigurationAnalysisEntity;
import org.apache.nifi.web.api.entity.ConnectionEntity;
import org.apache.nifi.web.api.entity.ConnectionStatisticsEntity;
import org.apache.nifi.web.api.entity.ConnectionStatusEntity;
@ -765,8 +772,59 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade {
}
@Override
public List<ConfigVerificationResultDTO> verifyProcessorConfiguration(final String processorId, final ProcessorConfigDTO processorConfig, final Map<String, String> attributes) {
return processorDAO.verifyProcessorConfiguration(processorId, processorConfig, attributes);
public List<ConfigVerificationResultDTO> verifyProcessorConfiguration(final String processorId, final Map<String, String> properties, final Map<String, String> attributes) {
return processorDAO.verifyProcessorConfiguration(processorId, properties, attributes);
}
@Override
public ConfigurationAnalysisEntity analyzeProcessorConfiguration(final String processorId, final Map<String, String> properties) {
final ProcessorNode processorNode = processorDAO.getProcessor(processorId);
final ProcessGroup processGroup = processorNode.getProcessGroup();
final ParameterContext parameterContext = processGroup.getParameterContext();
final ConfigurationAnalysisEntity configurationAnalysisEntity = analyzeConfiguration(processorNode, properties, parameterContext);
return configurationAnalysisEntity;
}
private ConfigurationAnalysisEntity analyzeConfiguration(final ComponentNode componentNode, final Map<String, String> properties, final ParameterContext parameterContext) {
final Map<String, String> referencedAttributes = determineReferencedAttributes(properties, componentNode, parameterContext);
final ConfigurationAnalysisDTO dto = new ConfigurationAnalysisDTO();
dto.setComponentId(componentNode.getIdentifier());
dto.setProperties(properties);
dto.setReferencedAttributes(referencedAttributes);
final ConfigurationAnalysisEntity entity = new ConfigurationAnalysisEntity();
entity.setConfigurationAnalysis(dto);
return entity;
}
private Map<String, String> determineReferencedAttributes(final Map<String, String> properties, final ComponentNode componentNode, final ParameterContext parameterContext) {
final Map<String, String> mergedProperties = new LinkedHashMap<>();
componentNode.getRawPropertyValues().forEach((desc, value) -> mergedProperties.put(desc.getName(), value));
mergedProperties.putAll(properties);
final Set<String> propertiesNotSupportingEL = new HashSet<>();
for (final String propertyName : mergedProperties.keySet()) {
final PropertyDescriptor descriptor = componentNode.getPropertyDescriptor(propertyName);
final boolean allowsAttributes = descriptor.isExpressionLanguageSupported() || descriptor.getExpressionLanguageScope() == ExpressionLanguageScope.FLOWFILE_ATTRIBUTES;
if (descriptor.isSensitive() || !allowsAttributes) {
propertiesNotSupportingEL.add(propertyName);
}
}
propertiesNotSupportingEL.forEach(mergedProperties::remove);
final PropertyConfigurationMapper configurationMapper = new PropertyConfigurationMapper();
final Map<String, PropertyConfiguration> configurationMap = configurationMapper.mapRawPropertyValuesToPropertyConfiguration(componentNode, mergedProperties);
final Map<String, String> referencedAttributes = new HashMap<>();
for (final PropertyConfiguration propertyConfiguration : configurationMap.values()) {
final String effectiveValue = propertyConfiguration.getEffectiveValue(parameterContext == null ? ParameterLookup.EMPTY : parameterContext);
final Set<String> attributes = Query.prepareWithParametersPreEvaluated(effectiveValue).getExplicitlyReferencedAttributes();
attributes.forEach(attr -> referencedAttributes.put(attr, null));
}
return referencedAttributes;
}
private void awaitValidationCompletion(final ComponentNode component) {
@ -2776,8 +2834,18 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade {
}
@Override
public List<ConfigVerificationResultDTO> verifyControllerServiceConfiguration(final String controllerServiceId, final ControllerServiceDTO controllerService, final Map<String, String> variables) {
return controllerServiceDAO.verifyConfiguration(controllerServiceId, controllerService, variables);
public List<ConfigVerificationResultDTO> verifyControllerServiceConfiguration(final String controllerServiceId, final Map<String, String> properties, final Map<String, String> variables) {
return controllerServiceDAO.verifyConfiguration(controllerServiceId, properties, variables);
}
@Override
public ConfigurationAnalysisEntity analyzeControllerServiceConfiguration(final String controllerServiceId, final Map<String, String> properties) {
final ControllerServiceNode serviceNode = controllerServiceDAO.getControllerService(controllerServiceId);
final ProcessGroup processGroup = serviceNode.getProcessGroup();
final ParameterContext parameterContext = processGroup == null ? null : processGroup.getParameterContext();
final ConfigurationAnalysisEntity configurationAnalysisEntity = analyzeConfiguration(serviceNode, properties, parameterContext);
return configurationAnalysisEntity;
}
@Override
@ -3159,8 +3227,15 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade {
}
@Override
public List<ConfigVerificationResultDTO> verifyReportingTaskConfiguration(final String reportingTaskId, final ReportingTaskDTO reportingTask) {
return reportingTaskDAO.verifyConfiguration(reportingTaskId, reportingTask);
public List<ConfigVerificationResultDTO> verifyReportingTaskConfiguration(final String reportingTaskId, final Map<String, String> properties) {
return reportingTaskDAO.verifyConfiguration(reportingTaskId, properties);
}
@Override
public ConfigurationAnalysisEntity analyzeReportingTaskConfiguration(final String reportingTaskId, final Map<String, String> properties) {
final ReportingTaskNode taskNode = reportingTaskDAO.getReportingTask(reportingTaskId);
final ConfigurationAnalysisEntity configurationAnalysisEntity = analyzeConfiguration(taskNode, properties, null);
return configurationAnalysisEntity;
}
@Override

View File

@ -49,17 +49,19 @@ import org.apache.nifi.web.api.concurrent.UpdateStep;
import org.apache.nifi.web.api.dto.BundleDTO;
import org.apache.nifi.web.api.dto.ComponentStateDTO;
import org.apache.nifi.web.api.dto.ConfigVerificationResultDTO;
import org.apache.nifi.web.api.dto.ConfigurationAnalysisDTO;
import org.apache.nifi.web.api.dto.ControllerServiceDTO;
import org.apache.nifi.web.api.dto.PropertyDescriptorDTO;
import org.apache.nifi.web.api.dto.RevisionDTO;
import org.apache.nifi.web.api.dto.VerifyControllerServiceConfigRequestDTO;
import org.apache.nifi.web.api.dto.VerifyConfigRequestDTO;
import org.apache.nifi.web.api.entity.ComponentStateEntity;
import org.apache.nifi.web.api.entity.ConfigurationAnalysisEntity;
import org.apache.nifi.web.api.entity.ControllerServiceEntity;
import org.apache.nifi.web.api.entity.ControllerServiceReferencingComponentsEntity;
import org.apache.nifi.web.api.entity.ControllerServiceRunStatusEntity;
import org.apache.nifi.web.api.entity.PropertyDescriptorEntity;
import org.apache.nifi.web.api.entity.UpdateControllerServiceReferenceRequestEntity;
import org.apache.nifi.web.api.entity.VerifyControllerServiceConfigRequestEntity;
import org.apache.nifi.web.api.entity.VerifyConfigRequestEntity;
import org.apache.nifi.web.api.request.ClientIdParameter;
import org.apache.nifi.web.api.request.LongParameter;
import org.slf4j.Logger;
@ -102,7 +104,7 @@ public class ControllerServiceResource extends ApplicationResource {
private static final Logger logger = LoggerFactory.getLogger(ControllerServiceResource.class);
private static final String VERIFICATION_REQUEST_TYPE = "verification-request";
private RequestManager<VerifyControllerServiceConfigRequestEntity, List<ConfigVerificationResultDTO>> updateRequestManager =
private RequestManager<VerifyConfigRequestEntity, List<ConfigVerificationResultDTO>> updateRequestManager =
new AsyncRequestManager<>(100, TimeUnit.MINUTES.toMillis(1L), "Verify Controller Service Config Thread");
private NiFiServiceFacade serviceFacade;
@ -841,6 +843,66 @@ public class ControllerServiceResource extends ApplicationResource {
);
}
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Path("/{id}/config/analysis")
@ApiOperation(
value = "Performs analysis of the component's configuration, providing information about which attributes are referenced.",
response = ConfigurationAnalysisEntity.class,
authorizations = {
@Authorization(value = "Read - /controller-services/{uuid}")
}
)
@ApiResponses(
value = {
@ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."),
@ApiResponse(code = 401, message = "Client could not be authenticated."),
@ApiResponse(code = 403, message = "Client is not authorized to make this request."),
@ApiResponse(code = 404, message = "The specified resource could not be found."),
@ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.")
}
)
public Response analyzeConfiguration(
@ApiParam(value = "The controller service id.", required = true) @PathParam("id") final String controllerServiceId,
@ApiParam(value = "The configuration analysis request.", required = true) final ConfigurationAnalysisEntity configurationAnalysis) {
if (configurationAnalysis == null || configurationAnalysis.getConfigurationAnalysis() == null) {
throw new IllegalArgumentException("Controller Service's configuration must be specified");
}
final ConfigurationAnalysisDTO dto = configurationAnalysis.getConfigurationAnalysis();
if (dto.getComponentId() == null) {
throw new IllegalArgumentException("Controller Service's identifier must be specified in the request");
}
if (!dto.getComponentId().equals(controllerServiceId)) {
throw new IllegalArgumentException("Controller Service's identifier in the request must match the identifier provided in the URL");
}
if (dto.getProperties() == null) {
throw new IllegalArgumentException("Controller Service's properties must be specified in the request");
}
if (isReplicateRequest()) {
return replicate(HttpMethod.POST, configurationAnalysis);
}
return withWriteLock(
serviceFacade,
configurationAnalysis,
lookup -> {
final ComponentAuthorizable controllerService = lookup.getControllerService(controllerServiceId);
controllerService.getAuthorizable().authorize(authorizer, RequestAction.READ, NiFiUserUtils.getNiFiUser());
},
() -> { },
entity -> {
final ConfigurationAnalysisDTO analysis = entity.getConfigurationAnalysis();
final ConfigurationAnalysisEntity resultsEntity = serviceFacade.analyzeControllerServiceConfiguration(analysis.getComponentId(), analysis.getProperties());
return generateOkResponse(resultsEntity).build();
}
);
}
@POST
@Consumes(MediaType.APPLICATION_JSON)
@ -848,7 +910,7 @@ public class ControllerServiceResource extends ApplicationResource {
@Path("/{id}/config/verification-requests")
@ApiOperation(
value = "Performs verification of the Controller Service's configuration",
response = VerifyControllerServiceConfigRequestEntity.class,
response = VerifyConfigRequestEntity.class,
notes = "This will initiate the process of verifying a given Controller Service configuration. This may be a long-running task. As a result, this endpoint will immediately return a " +
"ControllerServiceConfigVerificationRequestEntity, and the process of performing the verification will occur asynchronously in the background. " +
"The client may then periodically poll the status of the request by " +
@ -869,22 +931,22 @@ public class ControllerServiceResource extends ApplicationResource {
)
public Response submitConfigVerificationRequest(
@ApiParam(value = "The controller service id.", required = true) @PathParam("id") final String controllerServiceId,
@ApiParam(value = "The controller service configuration verification request.", required = true) final VerifyControllerServiceConfigRequestEntity controllerServiceConfigRequest) {
@ApiParam(value = "The controller service configuration verification request.", required = true) final VerifyConfigRequestEntity controllerServiceConfigRequest) {
if (controllerServiceConfigRequest == null) {
throw new IllegalArgumentException("Controller Service's configuration must be specified");
}
final VerifyControllerServiceConfigRequestDTO requestDto = controllerServiceConfigRequest.getRequest();
if (requestDto == null || requestDto.getControllerService() == null) {
throw new IllegalArgumentException("Controller Service must be specified");
final VerifyConfigRequestDTO requestDto = controllerServiceConfigRequest.getRequest();
if (requestDto == null || requestDto.getProperties() == null) {
throw new IllegalArgumentException("Controller Service properties must be specified");
}
if (requestDto.getControllerServiceId() == null) {
if (requestDto.getComponentId() == null) {
throw new IllegalArgumentException("Controller Service's identifier must be specified in the request");
}
if (!requestDto.getControllerServiceId().equals(controllerServiceId)) {
if (!requestDto.getComponentId().equals(controllerServiceId)) {
throw new IllegalArgumentException("Controller Service's identifier in the request must match the identifier provided in the URL");
}
@ -914,7 +976,7 @@ public class ControllerServiceResource extends ApplicationResource {
@Path("{id}/config/verification-requests/{requestId}")
@ApiOperation(
value = "Returns the Verification Request with the given ID",
response = VerifyControllerServiceConfigRequestEntity.class,
response = VerifyConfigRequestEntity.class,
notes = "Returns the Verification Request with the given ID. Once an Verification Request has been created, "
+ "that request can subsequently be retrieved via this endpoint, and the request that is fetched will contain the updated state, such as percent complete, the "
+ "current state of the request, and any failures. ",
@ -939,10 +1001,10 @@ public class ControllerServiceResource extends ApplicationResource {
final NiFiUser user = NiFiUserUtils.getNiFiUser();
// request manager will ensure that the current is the user that submitted this request
final AsynchronousWebRequest<VerifyControllerServiceConfigRequestEntity, List<ConfigVerificationResultDTO>> asyncRequest =
final AsynchronousWebRequest<VerifyConfigRequestEntity, List<ConfigVerificationResultDTO>> asyncRequest =
updateRequestManager.getRequest(VERIFICATION_REQUEST_TYPE, requestId, user);
final VerifyControllerServiceConfigRequestEntity updateRequestEntity = createVerifyControllerServiceConfigRequestEntity(asyncRequest, requestId);
final VerifyConfigRequestEntity updateRequestEntity = createVerifyControllerServiceConfigRequestEntity(asyncRequest, requestId);
return generateOkResponse(updateRequestEntity).build();
}
@ -953,7 +1015,7 @@ public class ControllerServiceResource extends ApplicationResource {
@Path("{id}/config/verification-requests/{requestId}")
@ApiOperation(
value = "Deletes the Verification Request with the given ID",
response = VerifyControllerServiceConfigRequestEntity.class,
response = VerifyConfigRequestEntity.class,
notes = "Deletes the Verification Request with the given ID. After a request is created, it is expected "
+ "that the client will properly clean up the request by DELETE'ing it, once the Verification process has completed. If the request is deleted before the request "
+ "completes, then the Verification request will finish the step that it is currently performing and then will cancel any subsequent steps.",
@ -982,7 +1044,7 @@ public class ControllerServiceResource extends ApplicationResource {
// If this is a standalone node, or if this is the execution phase of the request, perform the actual request.
if (!twoPhaseRequest || executionPhase) {
// request manager will ensure that the current is the user that submitted this request
final AsynchronousWebRequest<VerifyControllerServiceConfigRequestEntity, List<ConfigVerificationResultDTO>> asyncRequest =
final AsynchronousWebRequest<VerifyConfigRequestEntity, List<ConfigVerificationResultDTO>> asyncRequest =
updateRequestManager.removeRequest(VERIFICATION_REQUEST_TYPE, requestId, user);
if (asyncRequest == null) {
@ -993,7 +1055,7 @@ public class ControllerServiceResource extends ApplicationResource {
asyncRequest.cancel();
}
final VerifyControllerServiceConfigRequestEntity updateRequestEntity = createVerifyControllerServiceConfigRequestEntity(asyncRequest, requestId);
final VerifyConfigRequestEntity updateRequestEntity = createVerifyControllerServiceConfigRequestEntity(asyncRequest, requestId);
return generateOkResponse(updateRequestEntity).build();
}
@ -1009,22 +1071,22 @@ public class ControllerServiceResource extends ApplicationResource {
}
public Response performAsyncConfigVerification(final VerifyControllerServiceConfigRequestEntity configRequest, final NiFiUser user) {
public Response performAsyncConfigVerification(final VerifyConfigRequestEntity configRequest, final NiFiUser user) {
// Create an asynchronous request that will occur in the background, because this request may take an indeterminate amount of time.
final String requestId = generateUuid();
final VerifyControllerServiceConfigRequestDTO requestDto = configRequest.getRequest();
final String serviceId = requestDto.getControllerServiceId();
final VerifyConfigRequestDTO requestDto = configRequest.getRequest();
final String serviceId = requestDto.getComponentId();
final List<UpdateStep> updateSteps = Collections.singletonList(new StandardUpdateStep("Verify Controller Service Configuration"));
final AsynchronousWebRequest<VerifyControllerServiceConfigRequestEntity, List<ConfigVerificationResultDTO>> request =
final AsynchronousWebRequest<VerifyConfigRequestEntity, List<ConfigVerificationResultDTO>> request =
new StandardAsynchronousWebRequest<>(requestId, configRequest, serviceId, user, updateSteps);
// Submit the request to be performed in the background
final Consumer<AsynchronousWebRequest<VerifyControllerServiceConfigRequestEntity, List<ConfigVerificationResultDTO>>> updateTask = asyncRequest -> {
final Consumer<AsynchronousWebRequest<VerifyConfigRequestEntity, List<ConfigVerificationResultDTO>>> updateTask = asyncRequest -> {
try {
final Map<String, String> attributes = requestDto.getAttributes() == null ? Collections.emptyMap() : requestDto.getAttributes();
final List<ConfigVerificationResultDTO> results = serviceFacade.verifyControllerServiceConfiguration(serviceId, requestDto.getControllerService(), attributes);
final List<ConfigVerificationResultDTO> results = serviceFacade.verifyControllerServiceConfiguration(serviceId, requestDto.getProperties(), attributes);
asyncRequest.markStepComplete(results);
} catch (final Exception e) {
logger.error("Failed to verify Controller Service configuration", e);
@ -1035,30 +1097,30 @@ public class ControllerServiceResource extends ApplicationResource {
updateRequestManager.submitRequest(VERIFICATION_REQUEST_TYPE, requestId, request, updateTask);
// Generate the response
final VerifyControllerServiceConfigRequestEntity resultsEntity = createVerifyControllerServiceConfigRequestEntity(request, requestId);
final VerifyConfigRequestEntity resultsEntity = createVerifyControllerServiceConfigRequestEntity(request, requestId);
return generateOkResponse(resultsEntity).build();
}
private VerifyControllerServiceConfigRequestEntity createVerifyControllerServiceConfigRequestEntity(
final AsynchronousWebRequest<VerifyControllerServiceConfigRequestEntity, List<ConfigVerificationResultDTO>> asyncRequest, final String requestId) {
private VerifyConfigRequestEntity createVerifyControllerServiceConfigRequestEntity(
final AsynchronousWebRequest<VerifyConfigRequestEntity, List<ConfigVerificationResultDTO>> asyncRequest, final String requestId) {
final VerifyControllerServiceConfigRequestDTO requestDto = asyncRequest.getRequest().getRequest();
final VerifyConfigRequestDTO requestDto = asyncRequest.getRequest().getRequest();
final List<ConfigVerificationResultDTO> resultsList = asyncRequest.getResults();
final VerifyControllerServiceConfigRequestDTO dto = new VerifyControllerServiceConfigRequestDTO();
dto.setControllerServiceId(requestDto.getControllerServiceId());
dto.setControllerService(requestDto.getControllerService());
final VerifyConfigRequestDTO dto = new VerifyConfigRequestDTO();
dto.setComponentId(requestDto.getComponentId());
dto.setProperties(requestDto.getProperties());
dto.setResults(resultsList);
dto.setComplete(resultsList != null);
dto.setComplete(asyncRequest.isComplete());
dto.setFailureReason(asyncRequest.getFailureReason());
dto.setLastUpdated(asyncRequest.getLastUpdated());
dto.setPercentCompleted(asyncRequest.getPercentComplete());
dto.setRequestId(requestId);
dto.setState(asyncRequest.getState());
dto.setUri(generateResourceUri("controller-services", requestDto.getControllerServiceId(), "config", "verification-requests", requestId));
dto.setUri(generateResourceUri("controller-services", requestDto.getComponentId(), "config", "verification-requests", requestId));
final VerifyControllerServiceConfigRequestEntity entity = new VerifyControllerServiceConfigRequestEntity();
final VerifyConfigRequestEntity entity = new VerifyConfigRequestEntity();
entity.setRequest(dto);
return entity;
}

View File

@ -46,19 +46,21 @@ import org.apache.nifi.web.api.concurrent.UpdateStep;
import org.apache.nifi.web.api.dto.BundleDTO;
import org.apache.nifi.web.api.dto.ComponentStateDTO;
import org.apache.nifi.web.api.dto.ConfigVerificationResultDTO;
import org.apache.nifi.web.api.dto.ConfigurationAnalysisDTO;
import org.apache.nifi.web.api.dto.PositionDTO;
import org.apache.nifi.web.api.dto.ProcessorConfigDTO;
import org.apache.nifi.web.api.dto.ProcessorDTO;
import org.apache.nifi.web.api.dto.PropertyDescriptorDTO;
import org.apache.nifi.web.api.dto.VerifyProcessorConfigRequestDTO;
import org.apache.nifi.web.api.dto.VerifyConfigRequestDTO;
import org.apache.nifi.web.api.entity.ComponentStateEntity;
import org.apache.nifi.web.api.entity.ConfigurationAnalysisEntity;
import org.apache.nifi.web.api.entity.ProcessorDiagnosticsEntity;
import org.apache.nifi.web.api.entity.ProcessorEntity;
import org.apache.nifi.web.api.entity.ProcessorRunStatusEntity;
import org.apache.nifi.web.api.entity.ProcessorsRunStatusDetailsEntity;
import org.apache.nifi.web.api.entity.PropertyDescriptorEntity;
import org.apache.nifi.web.api.entity.RunStatusDetailsRequestEntity;
import org.apache.nifi.web.api.entity.VerifyProcessorConfigRequestEntity;
import org.apache.nifi.web.api.entity.VerifyConfigRequestEntity;
import org.apache.nifi.web.api.request.ClientIdParameter;
import org.apache.nifi.web.api.request.LongParameter;
import org.slf4j.Logger;
@ -99,7 +101,7 @@ public class ProcessorResource extends ApplicationResource {
private static final Logger logger = LoggerFactory.getLogger(ProcessorResource.class);
private static final String VERIFICATION_REQUEST_TYPE = "verification-request";
private RequestManager<VerifyProcessorConfigRequestEntity, List<ConfigVerificationResultDTO>> updateRequestManager =
private RequestManager<VerifyConfigRequestEntity, List<ConfigVerificationResultDTO>> updateRequestManager =
new AsyncRequestManager<>(100, TimeUnit.MINUTES.toMillis(1L), "Verify Processor Config Thread");
private NiFiServiceFacade serviceFacade;
@ -547,13 +549,75 @@ public class ProcessorResource extends ApplicationResource {
}
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Path("/{id}/config/analysis")
@ApiOperation(
value = "Performs analysis of the component's configuration, providing information about which attributes are referenced.",
response = ConfigurationAnalysisEntity.class,
authorizations = {
@Authorization(value = "Read - /processors/{uuid}")
}
)
@ApiResponses(
value = {
@ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."),
@ApiResponse(code = 401, message = "Client could not be authenticated."),
@ApiResponse(code = 403, message = "Client is not authorized to make this request."),
@ApiResponse(code = 404, message = "The specified resource could not be found."),
@ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.")
}
)
public Response analyzeConfiguration(
@ApiParam(value = "The processor id.", required = true) @PathParam("id") final String processorId,
@ApiParam(value = "The processor configuration analysis request.", required = true) final ConfigurationAnalysisEntity configurationAnalysis) {
if (configurationAnalysis == null || configurationAnalysis.getConfigurationAnalysis() == null) {
throw new IllegalArgumentException("Processor's configuration must be specified");
}
final ConfigurationAnalysisDTO dto = configurationAnalysis.getConfigurationAnalysis();
if (dto.getComponentId() == null) {
throw new IllegalArgumentException("Processor's identifier must be specified in the request");
}
if (!dto.getComponentId().equals(processorId)) {
throw new IllegalArgumentException("Processor's identifier in the request must match the identifier provided in the URL");
}
if (dto.getProperties() == null) {
throw new IllegalArgumentException("Processor's properties must be specified in the request");
}
if (isReplicateRequest()) {
return replicate(HttpMethod.POST, configurationAnalysis);
}
return withWriteLock(
serviceFacade,
configurationAnalysis,
lookup -> {
final ComponentAuthorizable processor = lookup.getProcessor(processorId);
processor.getAuthorizable().authorize(authorizer, RequestAction.READ, NiFiUserUtils.getNiFiUser());
},
() -> { },
entity -> {
final ConfigurationAnalysisDTO analysis = entity.getConfigurationAnalysis();
final ConfigurationAnalysisEntity resultsEntity = serviceFacade.analyzeProcessorConfiguration(analysis.getComponentId(), analysis.getProperties());
return generateOkResponse(resultsEntity).build();
}
);
}
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Path("/{id}/config/verification-requests")
@ApiOperation(
value = "Performs verification of the Processor's configuration",
response = VerifyProcessorConfigRequestEntity.class,
response = VerifyConfigRequestEntity.class,
notes = "This will initiate the process of verifying a given Processor configuration. This may be a long-running task. As a result, this endpoint will immediately return a " +
"ProcessorConfigVerificationRequestEntity, and the process of performing the verification will occur asynchronously in the background. " +
"The client may then periodically poll the status of the request by " +
@ -574,22 +638,22 @@ public class ProcessorResource extends ApplicationResource {
)
public Response submitProcessorVerificationRequest(
@ApiParam(value = "The processor id.", required = true) @PathParam("id") final String processorId,
@ApiParam(value = "The processor configuration verification request.", required = true) final VerifyProcessorConfigRequestEntity processorConfigRequest) {
@ApiParam(value = "The processor configuration verification request.", required = true) final VerifyConfigRequestEntity processorConfigRequest) {
if (processorConfigRequest == null) {
throw new IllegalArgumentException("Processor's configuration must be specified");
}
final VerifyProcessorConfigRequestDTO requestDto = processorConfigRequest.getRequest();
if (requestDto == null || requestDto.getProcessorConfig() == null) {
throw new IllegalArgumentException("Processor's configuration must be specified");
final VerifyConfigRequestDTO requestDto = processorConfigRequest.getRequest();
if (requestDto == null || requestDto.getProperties() == null) {
throw new IllegalArgumentException("Processor's properties must be specified");
}
if (requestDto.getProcessorId() == null) {
if (requestDto.getComponentId() == null) {
throw new IllegalArgumentException("Processor's identifier must be specified in the request");
}
if (!requestDto.getProcessorId().equals(processorId)) {
if (!requestDto.getComponentId().equals(processorId)) {
throw new IllegalArgumentException("Processor's identifier in the request must match the identifier provided in the URL");
}
@ -619,7 +683,7 @@ public class ProcessorResource extends ApplicationResource {
@Path("{id}/config/verification-requests/{requestId}")
@ApiOperation(
value = "Returns the Verification Request with the given ID",
response = VerifyProcessorConfigRequestEntity.class,
response = VerifyConfigRequestEntity.class,
notes = "Returns the Verification Request with the given ID. Once an Verification Request has been created, "
+ "that request can subsequently be retrieved via this endpoint, and the request that is fetched will contain the updated state, such as percent complete, the "
+ "current state of the request, and any failures. ",
@ -644,8 +708,8 @@ public class ProcessorResource extends ApplicationResource {
final NiFiUser user = NiFiUserUtils.getNiFiUser();
// request manager will ensure that the current is the user that submitted this request
final AsynchronousWebRequest<VerifyProcessorConfigRequestEntity, List<ConfigVerificationResultDTO>> asyncRequest = updateRequestManager.getRequest(VERIFICATION_REQUEST_TYPE, requestId, user);
final VerifyProcessorConfigRequestEntity updateRequestEntity = createVerifyProcessorConfigRequestEntity(asyncRequest, requestId);
final AsynchronousWebRequest<VerifyConfigRequestEntity, List<ConfigVerificationResultDTO>> asyncRequest = updateRequestManager.getRequest(VERIFICATION_REQUEST_TYPE, requestId, user);
final VerifyConfigRequestEntity updateRequestEntity = createVerifyProcessorConfigRequestEntity(asyncRequest, requestId);
return generateOkResponse(updateRequestEntity).build();
}
@ -656,7 +720,7 @@ public class ProcessorResource extends ApplicationResource {
@Path("{id}/config/verification-requests/{requestId}")
@ApiOperation(
value = "Deletes the Verification Request with the given ID",
response = VerifyProcessorConfigRequestEntity.class,
response = VerifyConfigRequestEntity.class,
notes = "Deletes the Verification Request with the given ID. After a request is created, it is expected "
+ "that the client will properly clean up the request by DELETE'ing it, once the Verification process has completed. If the request is deleted before the request "
+ "completes, then the Verification request will finish the step that it is currently performing and then will cancel any subsequent steps.",
@ -685,14 +749,14 @@ public class ProcessorResource extends ApplicationResource {
// If this is a standalone node, or if this is the execution phase of the request, perform the actual request.
if (!twoPhaseRequest || executionPhase) {
// request manager will ensure that the current is the user that submitted this request
final AsynchronousWebRequest<VerifyProcessorConfigRequestEntity, List<ConfigVerificationResultDTO>> asyncRequest =
final AsynchronousWebRequest<VerifyConfigRequestEntity, List<ConfigVerificationResultDTO>> asyncRequest =
updateRequestManager.removeRequest(VERIFICATION_REQUEST_TYPE, requestId, user);
if (!asyncRequest.isComplete()) {
asyncRequest.cancel();
}
final VerifyProcessorConfigRequestEntity updateRequestEntity = createVerifyProcessorConfigRequestEntity(asyncRequest, requestId);
final VerifyConfigRequestEntity updateRequestEntity = createVerifyProcessorConfigRequestEntity(asyncRequest, requestId);
return generateOkResponse(updateRequestEntity).build();
}
@ -986,23 +1050,23 @@ public class ProcessorResource extends ApplicationResource {
return dto;
}
public Response performAsyncConfigVerification(final VerifyProcessorConfigRequestEntity processorConfigRequest, final NiFiUser user) {
public Response performAsyncConfigVerification(final VerifyConfigRequestEntity processorConfigRequest, final NiFiUser user) {
// Create an asynchronous request that will occur in the background, because this request may take an indeterminate amount of time.
final String requestId = generateUuid();
logger.debug("Generated Config Verification Request with ID {} for Processor {}", requestId, processorConfigRequest.getRequest().getProcessorId());
logger.debug("Generated Config Verification Request with ID {} for Processor {}", requestId, processorConfigRequest.getRequest().getComponentId());
final VerifyProcessorConfigRequestDTO requestDto = processorConfigRequest.getRequest();
final String processorId = requestDto.getProcessorId();
final VerifyConfigRequestDTO requestDto = processorConfigRequest.getRequest();
final String processorId = requestDto.getComponentId();
final List<UpdateStep> updateSteps = Collections.singletonList(new StandardUpdateStep("Verify Processor Configuration"));
final AsynchronousWebRequest<VerifyProcessorConfigRequestEntity, List<ConfigVerificationResultDTO>> request =
final AsynchronousWebRequest<VerifyConfigRequestEntity, List<ConfigVerificationResultDTO>> request =
new StandardAsynchronousWebRequest<>(requestId, processorConfigRequest, processorId, user, updateSteps);
// Submit the request to be performed in the background
final Consumer<AsynchronousWebRequest<VerifyProcessorConfigRequestEntity, List<ConfigVerificationResultDTO>>> updateTask = asyncRequest -> {
final Consumer<AsynchronousWebRequest<VerifyConfigRequestEntity, List<ConfigVerificationResultDTO>>> updateTask = asyncRequest -> {
try {
final Map<String, String> attributes = requestDto.getAttributes() == null ? Collections.emptyMap() : requestDto.getAttributes();
final List<ConfigVerificationResultDTO> results = serviceFacade.verifyProcessorConfiguration(processorId, requestDto.getProcessorConfig(), attributes);
final List<ConfigVerificationResultDTO> results = serviceFacade.verifyProcessorConfiguration(processorId, requestDto.getProperties(), attributes);
asyncRequest.markStepComplete(results);
} catch (final Exception e) {
logger.error("Failed to verify Processor configuration", e);
@ -1013,30 +1077,30 @@ public class ProcessorResource extends ApplicationResource {
updateRequestManager.submitRequest(VERIFICATION_REQUEST_TYPE, requestId, request, updateTask);
// Generate the response
final VerifyProcessorConfigRequestEntity resultsEntity = createVerifyProcessorConfigRequestEntity(request, requestId);
final VerifyConfigRequestEntity resultsEntity = createVerifyProcessorConfigRequestEntity(request, requestId);
return generateOkResponse(resultsEntity).build();
}
private VerifyProcessorConfigRequestEntity createVerifyProcessorConfigRequestEntity(
final AsynchronousWebRequest<VerifyProcessorConfigRequestEntity, List<ConfigVerificationResultDTO>> asyncRequest,
private VerifyConfigRequestEntity createVerifyProcessorConfigRequestEntity(
final AsynchronousWebRequest<VerifyConfigRequestEntity, List<ConfigVerificationResultDTO>> asyncRequest,
final String requestId) {
final VerifyProcessorConfigRequestDTO requestDto = asyncRequest.getRequest().getRequest();
final VerifyConfigRequestDTO requestDto = asyncRequest.getRequest().getRequest();
final List<ConfigVerificationResultDTO> resultsList = asyncRequest.getResults();
final VerifyProcessorConfigRequestDTO dto = new VerifyProcessorConfigRequestDTO();
dto.setProcessorId(requestDto.getProcessorId());
dto.setProcessorConfig(requestDto.getProcessorConfig());
final VerifyConfigRequestDTO dto = new VerifyConfigRequestDTO();
dto.setComponentId(requestDto.getComponentId());
dto.setProperties(requestDto.getProperties());
dto.setResults(resultsList);
dto.setComplete(resultsList != null);
dto.setComplete(asyncRequest.isComplete());
dto.setFailureReason(asyncRequest.getFailureReason());
dto.setLastUpdated(asyncRequest.getLastUpdated());
dto.setPercentCompleted(asyncRequest.getPercentComplete());
dto.setRequestId(requestId);
dto.setState(asyncRequest.getState());
dto.setUri(generateResourceUri("processors", requestDto.getProcessorId(), "config", "verification-requests", requestId));
dto.setUri(generateResourceUri("processors", requestDto.getComponentId(), "config", "verification-requests", requestId));
final VerifyProcessorConfigRequestEntity entity = new VerifyProcessorConfigRequestEntity();
final VerifyConfigRequestEntity entity = new VerifyConfigRequestEntity();
entity.setRequest(dto);
return entity;
}

View File

@ -46,14 +46,16 @@ import org.apache.nifi.web.api.concurrent.UpdateStep;
import org.apache.nifi.web.api.dto.BundleDTO;
import org.apache.nifi.web.api.dto.ComponentStateDTO;
import org.apache.nifi.web.api.dto.ConfigVerificationResultDTO;
import org.apache.nifi.web.api.dto.ConfigurationAnalysisDTO;
import org.apache.nifi.web.api.dto.PropertyDescriptorDTO;
import org.apache.nifi.web.api.dto.ReportingTaskDTO;
import org.apache.nifi.web.api.dto.VerifyReportingTaskConfigRequestDTO;
import org.apache.nifi.web.api.dto.VerifyConfigRequestDTO;
import org.apache.nifi.web.api.entity.ComponentStateEntity;
import org.apache.nifi.web.api.entity.ConfigurationAnalysisEntity;
import org.apache.nifi.web.api.entity.PropertyDescriptorEntity;
import org.apache.nifi.web.api.entity.ReportingTaskEntity;
import org.apache.nifi.web.api.entity.ReportingTaskRunStatusEntity;
import org.apache.nifi.web.api.entity.VerifyReportingTaskConfigRequestEntity;
import org.apache.nifi.web.api.entity.VerifyConfigRequestEntity;
import org.apache.nifi.web.api.request.ClientIdParameter;
import org.apache.nifi.web.api.request.LongParameter;
import org.slf4j.Logger;
@ -93,7 +95,7 @@ public class ReportingTaskResource extends ApplicationResource {
private static final Logger logger = LoggerFactory.getLogger(ReportingTaskResource.class);
private static final String VERIFICATION_REQUEST_TYPE = "verification-request";
private RequestManager<VerifyReportingTaskConfigRequestEntity, List<ConfigVerificationResultDTO>> updateRequestManager =
private RequestManager<VerifyConfigRequestEntity, List<ConfigVerificationResultDTO>> updateRequestManager =
new AsyncRequestManager<>(100, TimeUnit.MINUTES.toMillis(1L), "Verify Reporting Task Config Thread");
private NiFiServiceFacade serviceFacade;
@ -646,6 +648,66 @@ public class ReportingTaskResource extends ApplicationResource {
);
}
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Path("/{id}/config/analysis")
@ApiOperation(
value = "Performs analysis of the component's configuration, providing information about which attributes are referenced.",
response = ConfigurationAnalysisEntity.class,
authorizations = {
@Authorization(value = "Read - /reporting-tasks/{uuid}")
}
)
@ApiResponses(
value = {
@ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."),
@ApiResponse(code = 401, message = "Client could not be authenticated."),
@ApiResponse(code = 403, message = "Client is not authorized to make this request."),
@ApiResponse(code = 404, message = "The specified resource could not be found."),
@ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.")
}
)
public Response analyzeConfiguration(
@ApiParam(value = "The reporting task id.", required = true) @PathParam("id") final String reportingTaskId,
@ApiParam(value = "The configuration analysis request.", required = true) final ConfigurationAnalysisEntity configurationAnalysis) {
if (configurationAnalysis == null || configurationAnalysis.getConfigurationAnalysis() == null) {
throw new IllegalArgumentException("Reporting Tasks's configuration must be specified");
}
final ConfigurationAnalysisDTO dto = configurationAnalysis.getConfigurationAnalysis();
if (dto.getComponentId() == null) {
throw new IllegalArgumentException("Reporting Tasks's identifier must be specified in the request");
}
if (!dto.getComponentId().equals(reportingTaskId)) {
throw new IllegalArgumentException("Reporting Tasks's identifier in the request must match the identifier provided in the URL");
}
if (dto.getProperties() == null) {
throw new IllegalArgumentException("Reporting Tasks's properties must be specified in the request");
}
if (isReplicateRequest()) {
return replicate(HttpMethod.POST, configurationAnalysis);
}
return withWriteLock(
serviceFacade,
configurationAnalysis,
lookup -> {
final ComponentAuthorizable reportingTask = lookup.getReportingTask(reportingTaskId);
reportingTask.getAuthorizable().authorize(authorizer, RequestAction.READ, NiFiUserUtils.getNiFiUser());
},
() -> { },
entity -> {
final ConfigurationAnalysisDTO analysis = entity.getConfigurationAnalysis();
final ConfigurationAnalysisEntity resultsEntity = serviceFacade.analyzeReportingTaskConfiguration(analysis.getComponentId(), analysis.getProperties());
return generateOkResponse(resultsEntity).build();
}
);
}
@POST
@Consumes(MediaType.APPLICATION_JSON)
@ -653,7 +715,7 @@ public class ReportingTaskResource extends ApplicationResource {
@Path("/{id}/config/verification-requests")
@ApiOperation(
value = "Performs verification of the Reporting Task's configuration",
response = VerifyReportingTaskConfigRequestEntity.class,
response = VerifyConfigRequestEntity.class,
notes = "This will initiate the process of verifying a given Reporting Task configuration. This may be a long-running task. As a result, this endpoint will immediately return a " +
"ReportingTaskConfigVerificationRequestEntity, and the process of performing the verification will occur asynchronously in the background. " +
"The client may then periodically poll the status of the request by " +
@ -674,22 +736,22 @@ public class ReportingTaskResource extends ApplicationResource {
)
public Response submitConfigVerificationRequest(
@ApiParam(value = "The reporting task id.", required = true) @PathParam("id") final String reportingTaskId,
@ApiParam(value = "The reporting task configuration verification request.", required = true) final VerifyReportingTaskConfigRequestEntity reportingTaskConfigRequest) {
@ApiParam(value = "The reporting task configuration verification request.", required = true) final VerifyConfigRequestEntity reportingTaskConfigRequest) {
if (reportingTaskConfigRequest == null) {
throw new IllegalArgumentException("Reporting Task's configuration must be specified");
}
final VerifyReportingTaskConfigRequestDTO requestDto = reportingTaskConfigRequest.getRequest();
if (requestDto == null || requestDto.getReportingTask() == null) {
throw new IllegalArgumentException("Reporting Task must be specified");
final VerifyConfigRequestDTO requestDto = reportingTaskConfigRequest.getRequest();
if (requestDto == null || requestDto.getProperties() == null) {
throw new IllegalArgumentException("Reporting Task Properties must be specified");
}
if (requestDto.getReportingTaskId() == null) {
if (requestDto.getComponentId() == null) {
throw new IllegalArgumentException("Reporting Task's identifier must be specified in the request");
}
if (!requestDto.getReportingTaskId().equals(reportingTaskId)) {
if (!requestDto.getComponentId().equals(reportingTaskId)) {
throw new IllegalArgumentException("Reporting Task's identifier in the request must match the identifier provided in the URL");
}
@ -719,7 +781,7 @@ public class ReportingTaskResource extends ApplicationResource {
@Path("{id}/config/verification-requests/{requestId}")
@ApiOperation(
value = "Returns the Verification Request with the given ID",
response = VerifyReportingTaskConfigRequestEntity.class,
response = VerifyConfigRequestEntity.class,
notes = "Returns the Verification Request with the given ID. Once an Verification Request has been created, "
+ "that request can subsequently be retrieved via this endpoint, and the request that is fetched will contain the updated state, such as percent complete, the "
+ "current state of the request, and any failures. ",
@ -744,10 +806,10 @@ public class ReportingTaskResource extends ApplicationResource {
final NiFiUser user = NiFiUserUtils.getNiFiUser();
// request manager will ensure that the current is the user that submitted this request
final AsynchronousWebRequest<VerifyReportingTaskConfigRequestEntity, List<ConfigVerificationResultDTO>> asyncRequest =
final AsynchronousWebRequest<VerifyConfigRequestEntity, List<ConfigVerificationResultDTO>> asyncRequest =
updateRequestManager.getRequest(VERIFICATION_REQUEST_TYPE, requestId, user);
final VerifyReportingTaskConfigRequestEntity updateRequestEntity = createVerifyReportingTaskConfigRequestEntity(asyncRequest, requestId);
final VerifyConfigRequestEntity updateRequestEntity = createVerifyReportingTaskConfigRequestEntity(asyncRequest, requestId);
return generateOkResponse(updateRequestEntity).build();
}
@ -758,7 +820,7 @@ public class ReportingTaskResource extends ApplicationResource {
@Path("{id}/config/verification-requests/{requestId}")
@ApiOperation(
value = "Deletes the Verification Request with the given ID",
response = VerifyReportingTaskConfigRequestEntity.class,
response = VerifyConfigRequestEntity.class,
notes = "Deletes the Verification Request with the given ID. After a request is created, it is expected "
+ "that the client will properly clean up the request by DELETE'ing it, once the Verification process has completed. If the request is deleted before the request "
+ "completes, then the Verification request will finish the step that it is currently performing and then will cancel any subsequent steps.",
@ -787,7 +849,7 @@ public class ReportingTaskResource extends ApplicationResource {
// If this is a standalone node, or if this is the execution phase of the request, perform the actual request.
if (!twoPhaseRequest || executionPhase) {
// request manager will ensure that the current is the user that submitted this request
final AsynchronousWebRequest<VerifyReportingTaskConfigRequestEntity, List<ConfigVerificationResultDTO>> asyncRequest =
final AsynchronousWebRequest<VerifyConfigRequestEntity, List<ConfigVerificationResultDTO>> asyncRequest =
updateRequestManager.removeRequest(VERIFICATION_REQUEST_TYPE, requestId, user);
if (asyncRequest == null) {
@ -798,7 +860,7 @@ public class ReportingTaskResource extends ApplicationResource {
asyncRequest.cancel();
}
final VerifyReportingTaskConfigRequestEntity updateRequestEntity = createVerifyReportingTaskConfigRequestEntity(asyncRequest, requestId);
final VerifyConfigRequestEntity updateRequestEntity = createVerifyReportingTaskConfigRequestEntity(asyncRequest, requestId);
return generateOkResponse(updateRequestEntity).build();
}
@ -815,21 +877,21 @@ public class ReportingTaskResource extends ApplicationResource {
public Response performAsyncConfigVerification(final VerifyReportingTaskConfigRequestEntity configRequest, final NiFiUser user) {
public Response performAsyncConfigVerification(final VerifyConfigRequestEntity configRequest, final NiFiUser user) {
// Create an asynchronous request that will occur in the background, because this request may take an indeterminate amount of time.
final String requestId = generateUuid();
final VerifyReportingTaskConfigRequestDTO requestDto = configRequest.getRequest();
final String taskId = requestDto.getReportingTaskId();
final VerifyConfigRequestDTO requestDto = configRequest.getRequest();
final String taskId = requestDto.getComponentId();
final List<UpdateStep> updateSteps = Collections.singletonList(new StandardUpdateStep("Verify Reporting Task Configuration"));
final AsynchronousWebRequest<VerifyReportingTaskConfigRequestEntity, List<ConfigVerificationResultDTO>> request =
final AsynchronousWebRequest<VerifyConfigRequestEntity, List<ConfigVerificationResultDTO>> request =
new StandardAsynchronousWebRequest<>(requestId, configRequest, taskId, user, updateSteps);
// Submit the request to be performed in the background
final Consumer<AsynchronousWebRequest<VerifyReportingTaskConfigRequestEntity, List<ConfigVerificationResultDTO>>> updateTask = asyncRequest -> {
final Consumer<AsynchronousWebRequest<VerifyConfigRequestEntity, List<ConfigVerificationResultDTO>>> updateTask = asyncRequest -> {
try {
final List<ConfigVerificationResultDTO> results = serviceFacade.verifyReportingTaskConfiguration(taskId, requestDto.getReportingTask());
final List<ConfigVerificationResultDTO> results = serviceFacade.verifyReportingTaskConfiguration(taskId, requestDto.getProperties());
asyncRequest.markStepComplete(results);
} catch (final Exception e) {
logger.error("Failed to verify Reporting Task configuration", e);
@ -840,30 +902,30 @@ public class ReportingTaskResource extends ApplicationResource {
updateRequestManager.submitRequest(VERIFICATION_REQUEST_TYPE, requestId, request, updateTask);
// Generate the response
final VerifyReportingTaskConfigRequestEntity resultsEntity = createVerifyReportingTaskConfigRequestEntity(request, requestId);
final VerifyConfigRequestEntity resultsEntity = createVerifyReportingTaskConfigRequestEntity(request, requestId);
return generateOkResponse(resultsEntity).build();
}
private VerifyReportingTaskConfigRequestEntity createVerifyReportingTaskConfigRequestEntity(
final AsynchronousWebRequest<VerifyReportingTaskConfigRequestEntity, List<ConfigVerificationResultDTO>> asyncRequest, final String requestId) {
private VerifyConfigRequestEntity createVerifyReportingTaskConfigRequestEntity(
final AsynchronousWebRequest<VerifyConfigRequestEntity, List<ConfigVerificationResultDTO>> asyncRequest, final String requestId) {
final VerifyReportingTaskConfigRequestDTO requestDto = asyncRequest.getRequest().getRequest();
final VerifyConfigRequestDTO requestDto = asyncRequest.getRequest().getRequest();
final List<ConfigVerificationResultDTO> resultsList = asyncRequest.getResults();
final VerifyReportingTaskConfigRequestDTO dto = new VerifyReportingTaskConfigRequestDTO();
dto.setReportingTaskId(requestDto.getReportingTaskId());
dto.setReportingTask(requestDto.getReportingTask());
final VerifyConfigRequestDTO dto = new VerifyConfigRequestDTO();
dto.setComponentId(requestDto.getComponentId());
dto.setProperties(requestDto.getProperties());
dto.setResults(resultsList);
dto.setComplete(resultsList != null);
dto.setComplete(asyncRequest.isComplete());
dto.setFailureReason(asyncRequest.getFailureReason());
dto.setLastUpdated(asyncRequest.getLastUpdated());
dto.setPercentCompleted(asyncRequest.getPercentComplete());
dto.setRequestId(requestId);
dto.setState(asyncRequest.getState());
dto.setUri(generateResourceUri("reporting-tasks", requestDto.getReportingTaskId(), "config", "verification-requests", requestId));
dto.setUri(generateResourceUri("reporting-tasks", requestDto.getComponentId(), "config", "verification-requests", requestId));
final VerifyReportingTaskConfigRequestEntity entity = new VerifyReportingTaskConfigRequestEntity();
final VerifyConfigRequestEntity entity = new VerifyConfigRequestEntity();
entity.setRequest(dto);
return entity;
}

View File

@ -37,7 +37,7 @@ public class StandardUpdateStep implements UpdateStep {
@Override
public synchronized String getFailureReason() {
return null;
return failureReason;
}
@Override

View File

@ -1679,7 +1679,6 @@ public final class DtoFactory {
dto.getProperties().put(descriptor.getName(), propertyValue);
}
dto.setReferencedAttributes(controllerServiceNode.getReferencedAttributeNames());
dto.setValidationStatus(controllerServiceNode.getValidationStatus(1, TimeUnit.MILLISECONDS).name());
// add the validation errors
@ -4014,7 +4013,6 @@ public final class DtoFactory {
dto.setSchedulingStrategy(procNode.getSchedulingStrategy().name());
dto.setExecutionNode(procNode.getExecutionNode().name());
dto.setAnnotationData(procNode.getAnnotationData());
dto.setReferencedAttributes(procNode.getReferencedAttributeNames());
// set up the default values for concurrent tasks and scheduling period
final Map<String, String> defaultConcurrentTasks = new HashMap<>();
@ -4145,7 +4143,6 @@ public final class DtoFactory {
copy.setParentGroupId(original.getParentGroupId());
copy.setName(original.getName());
copy.setProperties(copy(original.getProperties()));
copy.setReferencedAttributes(copy(original.getReferencedAttributes()));
copy.setReferencingComponents(copy(original.getReferencingComponents()));
copy.setState(original.getState());
copy.setType(original.getType());
@ -4258,7 +4255,6 @@ public final class DtoFactory {
copy.setBulletinLevel(original.getBulletinLevel());
copy.setDefaultConcurrentTasks(original.getDefaultConcurrentTasks());
copy.setDefaultSchedulingPeriod(original.getDefaultSchedulingPeriod());
copy.setReferencedAttributes(original.getReferencedAttributes());
copy.setLossTolerant(original.isLossTolerant());
return copy;

View File

@ -140,11 +140,11 @@ public interface ControllerServiceDAO {
/**
* Performs verification of the Configuration for the Controller Service with the given ID
* @param controllerServiceId the id of the controller service
* @param controllerService the configuration to verify
* @param properties the configured properties to verify
* @param variables a map of values that can be used for resolving FlowFile attributes for Expression Language
* @return verification results
*/
List<ConfigVerificationResultDTO> verifyConfiguration(String controllerServiceId, ControllerServiceDTO controllerService, Map<String, String> variables);
List<ConfigVerificationResultDTO> verifyConfiguration(String controllerServiceId, Map<String, String> properties, Map<String, String> variables);
/**
* Clears the state of the specified controller service.

View File

@ -20,7 +20,6 @@ import org.apache.nifi.components.state.Scope;
import org.apache.nifi.components.state.StateMap;
import org.apache.nifi.controller.ProcessorNode;
import org.apache.nifi.web.api.dto.ConfigVerificationResultDTO;
import org.apache.nifi.web.api.dto.ProcessorConfigDTO;
import org.apache.nifi.web.api.dto.ProcessorDTO;
import java.util.List;
@ -106,11 +105,11 @@ public interface ProcessorDAO {
/**
* Performs verification of the given Processor Configuration for the Processor with the given ID
* @param processorId the id of the processor
* @param processorConfig the configuration to verify
* @param properties the property configuration to verify
* @param attributes a map of values that can be used for resolving FlowFile attributes for Expression Language
* @return verification results
*/
List<ConfigVerificationResultDTO> verifyProcessorConfiguration(String processorId, ProcessorConfigDTO processorConfig, Map<String, String> attributes);
List<ConfigVerificationResultDTO> verifyProcessorConfiguration(String processorId, Map<String, String> properties, Map<String, String> attributes);
/**
* Verifies the specified processor can be removed.

View File

@ -23,6 +23,7 @@ import org.apache.nifi.web.api.dto.ConfigVerificationResultDTO;
import org.apache.nifi.web.api.dto.ReportingTaskDTO;
import java.util.List;
import java.util.Map;
import java.util.Set;
public interface ReportingTaskDAO {
@ -89,10 +90,10 @@ public interface ReportingTaskDAO {
/**
* Performs verification of the Configuration for the Reporting Task with the given ID
* @param reportingTaskId the id of the Reporting Task
* @param reportingTask the configuration to verify
* @param properties the configured properties to verify
* @return verification results
*/
List<ConfigVerificationResultDTO> verifyConfiguration(String reportingTaskId, ReportingTaskDTO reportingTask);
List<ConfigVerificationResultDTO> verifyConfiguration(String reportingTaskId, Map<String, String> properties);
/**
* Determines whether this reporting task can be removed.

View File

@ -401,7 +401,7 @@ public class StandardControllerServiceDAO extends ComponentDAO implements Contro
}
@Override
public List<ConfigVerificationResultDTO> verifyConfiguration(final String controllerServiceId, final ControllerServiceDTO controllerService, final Map<String, String> variables) {
public List<ConfigVerificationResultDTO> verifyConfiguration(final String controllerServiceId, final Map<String, String> properties, final Map<String, String> variables) {
final ControllerServiceNode serviceNode = locateControllerService(controllerServiceId);
final LogRepository logRepository = new NopLogRepository();
@ -409,7 +409,7 @@ public class StandardControllerServiceDAO extends ComponentDAO implements Contro
final ExtensionManager extensionManager = flowController.getExtensionManager();
final ParameterLookup parameterLookup = serviceNode.getProcessGroup() == null ? ParameterLookup.EMPTY : serviceNode.getProcessGroup().getParameterContext();
final ConfigurationContext configurationContext = new StandardConfigurationContext(serviceNode, controllerService.getProperties(), controllerService.getAnnotationData(),
final ConfigurationContext configurationContext = new StandardConfigurationContext(serviceNode, properties, serviceNode.getAnnotationData(),
parameterLookup, flowController.getControllerServiceProvider(), null, flowController.getVariableRegistry());
final List<ConfigVerificationResult> verificationResults = serviceNode.verifyConfiguration(configurationContext, configVerificationLog, variables, extensionManager);

View File

@ -442,10 +442,10 @@ public class StandardProcessorDAO extends ComponentDAO implements ProcessorDAO {
}
@Override
public List<ConfigVerificationResultDTO> verifyProcessorConfiguration(final String processorId, final ProcessorConfigDTO processorConfig, final Map<String, String> attributes) {
public List<ConfigVerificationResultDTO> verifyProcessorConfiguration(final String processorId, final Map<String, String> properties, final Map<String, String> attributes) {
final ProcessorNode processor = locateProcessor(processorId);
final ProcessContext processContext = new StandardProcessContext(processor, processorConfig.getProperties(), processorConfig.getAnnotationData(),
final ProcessContext processContext = new StandardProcessContext(processor, properties, processor.getAnnotationData(),
processor.getProcessGroup().getParameterContext(), flowController.getControllerServiceProvider(), flowController.getEncryptor(),
new NopStateManager(), () -> false, flowController);

View File

@ -261,7 +261,7 @@ public class StandardReportingTaskDAO extends ComponentDAO implements ReportingT
}
@Override
public List<ConfigVerificationResultDTO> verifyConfiguration(final String reportingTaskId, final ReportingTaskDTO reportingTask) {
public List<ConfigVerificationResultDTO> verifyConfiguration(final String reportingTaskId, final Map<String, String> properties) {
final ReportingTaskNode taskNode = locateReportingTask(reportingTaskId);
final LogRepository logRepository = new NopLogRepository();
@ -269,7 +269,7 @@ public class StandardReportingTaskDAO extends ComponentDAO implements ReportingT
final ExtensionManager extensionManager = flowController.getExtensionManager();
final ParameterLookup parameterLookup = ParameterLookup.EMPTY;
final ConfigurationContext configurationContext = new StandardConfigurationContext(taskNode, reportingTask.getProperties(), reportingTask.getAnnotationData(),
final ConfigurationContext configurationContext = new StandardConfigurationContext(taskNode, properties, taskNode.getAnnotationData(),
parameterLookup, flowController.getControllerServiceProvider(), null, flowController.getVariableRegistry());
final List<ConfigVerificationResult> verificationResults = taskNode.verifyConfiguration(configurationContext, configVerificationLog, extensionManager);

View File

@ -50,9 +50,7 @@ import org.apache.nifi.web.api.dto.ReportingTaskDTO;
import org.apache.nifi.web.api.dto.RevisionDTO;
import org.apache.nifi.web.api.dto.VariableDTO;
import org.apache.nifi.web.api.dto.VariableRegistryDTO;
import org.apache.nifi.web.api.dto.VerifyControllerServiceConfigRequestDTO;
import org.apache.nifi.web.api.dto.VerifyProcessorConfigRequestDTO;
import org.apache.nifi.web.api.dto.VerifyReportingTaskConfigRequestDTO;
import org.apache.nifi.web.api.dto.VerifyConfigRequestDTO;
import org.apache.nifi.web.api.dto.flow.FlowDTO;
import org.apache.nifi.web.api.dto.flow.ProcessGroupFlowDTO;
import org.apache.nifi.web.api.dto.provenance.ProvenanceDTO;
@ -85,9 +83,7 @@ import org.apache.nifi.web.api.entity.ScheduleComponentsEntity;
import org.apache.nifi.web.api.entity.VariableEntity;
import org.apache.nifi.web.api.entity.VariableRegistryEntity;
import org.apache.nifi.web.api.entity.VariableRegistryUpdateRequestEntity;
import org.apache.nifi.web.api.entity.VerifyControllerServiceConfigRequestEntity;
import org.apache.nifi.web.api.entity.VerifyProcessorConfigRequestEntity;
import org.apache.nifi.web.api.entity.VerifyReportingTaskConfigRequestEntity;
import org.apache.nifi.web.api.entity.VerifyConfigRequestEntity;
import org.junit.Assert;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -985,18 +981,15 @@ public class NiFiClientUtil {
public List<ConfigVerificationResultDTO> verifyProcessorConfig(final String processorId, final Map<String, String> properties, final Map<String, String> attributes)
throws NiFiClientException, IOException, InterruptedException {
final ProcessorConfigDTO processorConfig = new ProcessorConfigDTO();
processorConfig.setProperties(properties);
final VerifyProcessorConfigRequestDTO requestDto = new VerifyProcessorConfigRequestDTO();
requestDto.setProcessorId(processorId);
requestDto.setProcessorConfig(processorConfig);
final VerifyConfigRequestDTO requestDto = new VerifyConfigRequestDTO();
requestDto.setComponentId(processorId);
requestDto.setProperties(properties);
requestDto.setAttributes(attributes);
final VerifyProcessorConfigRequestEntity verificationRequest = new VerifyProcessorConfigRequestEntity();
final VerifyConfigRequestEntity verificationRequest = new VerifyConfigRequestEntity();
verificationRequest.setRequest(requestDto);
VerifyProcessorConfigRequestEntity results = nifiClient.getProcessorClient().submitConfigVerificationRequest(verificationRequest);
VerifyConfigRequestEntity results = nifiClient.getProcessorClient().submitConfigVerificationRequest(verificationRequest);
while (!results.getRequest().isComplete()) {
Thread.sleep(50L);
results = nifiClient.getProcessorClient().getConfigVerificationRequest(processorId, results.getRequest().getRequestId());
@ -1019,15 +1012,15 @@ public class NiFiClientUtil {
serviceDto.setProperties(properties);
serviceDto.setId(serviceId);
final VerifyControllerServiceConfigRequestDTO requestDto = new VerifyControllerServiceConfigRequestDTO();
requestDto.setControllerService(serviceDto);
final VerifyConfigRequestDTO requestDto = new VerifyConfigRequestDTO();
requestDto.setComponentId(serviceId);
requestDto.setAttributes(attributes);
requestDto.setControllerServiceId(serviceId);
requestDto.setProperties(properties);
final VerifyControllerServiceConfigRequestEntity verificationRequest = new VerifyControllerServiceConfigRequestEntity();
final VerifyConfigRequestEntity verificationRequest = new VerifyConfigRequestEntity();
verificationRequest.setRequest(requestDto);
VerifyControllerServiceConfigRequestEntity results = nifiClient.getControllerServicesClient().submitConfigVerificationRequest(verificationRequest);
VerifyConfigRequestEntity results = nifiClient.getControllerServicesClient().submitConfigVerificationRequest(verificationRequest);
while (!results.getRequest().isComplete()) {
Thread.sleep(50L);
results = nifiClient.getControllerServicesClient().getConfigVerificationRequest(serviceId, results.getRequest().getRequestId());
@ -1041,18 +1034,14 @@ public class NiFiClientUtil {
public List<ConfigVerificationResultDTO> verifyReportingTaskConfig(final String taskId, final Map<String, String> properties)
throws InterruptedException, IOException,NiFiClientException {
final ReportingTaskDTO taskDto = new ReportingTaskDTO();
taskDto.setProperties(properties);
taskDto.setId(taskId);
final VerifyConfigRequestDTO requestDto = new VerifyConfigRequestDTO();
requestDto.setComponentId(taskId);
requestDto.setProperties(properties);
final VerifyReportingTaskConfigRequestDTO requestDto = new VerifyReportingTaskConfigRequestDTO();
requestDto.setReportingTaskId(taskId);
requestDto.setReportingTask(taskDto);
final VerifyReportingTaskConfigRequestEntity verificationRequest = new VerifyReportingTaskConfigRequestEntity();
final VerifyConfigRequestEntity verificationRequest = new VerifyConfigRequestEntity();
verificationRequest.setRequest(requestDto);
VerifyReportingTaskConfigRequestEntity results = nifiClient.getReportingTasksClient().submitConfigVerificationRequest(verificationRequest);
VerifyConfigRequestEntity results = nifiClient.getReportingTasksClient().submitConfigVerificationRequest(verificationRequest);
while (!results.getRequest().isComplete()) {
Thread.sleep(50L);
results = nifiClient.getReportingTasksClient().getConfigVerificationRequest(taskId, results.getRequest().getRequestId());

View File

@ -20,7 +20,7 @@ import org.apache.nifi.web.api.entity.ControllerServiceEntity;
import org.apache.nifi.web.api.entity.ControllerServiceReferencingComponentsEntity;
import org.apache.nifi.web.api.entity.ControllerServiceRunStatusEntity;
import org.apache.nifi.web.api.entity.UpdateControllerServiceReferenceRequestEntity;
import org.apache.nifi.web.api.entity.VerifyControllerServiceConfigRequestEntity;
import org.apache.nifi.web.api.entity.VerifyConfigRequestEntity;
import java.io.IOException;
@ -43,10 +43,10 @@ public interface ControllerServicesClient {
ControllerServiceReferencingComponentsEntity updateControllerServiceReferences(UpdateControllerServiceReferenceRequestEntity referencesEntity) throws NiFiClientException, IOException;
VerifyControllerServiceConfigRequestEntity submitConfigVerificationRequest(VerifyControllerServiceConfigRequestEntity configRequestEntity) throws NiFiClientException, IOException;
VerifyConfigRequestEntity submitConfigVerificationRequest(VerifyConfigRequestEntity configRequestEntity) throws NiFiClientException, IOException;
VerifyControllerServiceConfigRequestEntity getConfigVerificationRequest(String serviceId, String verificationRequestId) throws NiFiClientException, IOException;
VerifyConfigRequestEntity getConfigVerificationRequest(String serviceId, String verificationRequestId) throws NiFiClientException, IOException;
VerifyControllerServiceConfigRequestEntity deleteConfigVerificationRequest(String serviceId, String verificationRequestId) throws NiFiClientException, IOException;
VerifyConfigRequestEntity deleteConfigVerificationRequest(String serviceId, String verificationRequestId) throws NiFiClientException, IOException;
}

View File

@ -17,7 +17,7 @@
package org.apache.nifi.toolkit.cli.impl.client.nifi;
import org.apache.nifi.web.api.entity.ProcessorEntity;
import org.apache.nifi.web.api.entity.VerifyProcessorConfigRequestEntity;
import org.apache.nifi.web.api.entity.VerifyConfigRequestEntity;
import java.io.IOException;
@ -48,10 +48,10 @@ public interface ProcessorClient {
ProcessorEntity deleteProcessor(ProcessorEntity processorEntity) throws NiFiClientException, IOException;
VerifyProcessorConfigRequestEntity submitConfigVerificationRequest(VerifyProcessorConfigRequestEntity configRequestEntity) throws NiFiClientException, IOException;
VerifyConfigRequestEntity submitConfigVerificationRequest(VerifyConfigRequestEntity configRequestEntity) throws NiFiClientException, IOException;
VerifyProcessorConfigRequestEntity getConfigVerificationRequest(String processorId, String verificationRequestId) throws NiFiClientException, IOException;
VerifyConfigRequestEntity getConfigVerificationRequest(String processorId, String verificationRequestId) throws NiFiClientException, IOException;
VerifyProcessorConfigRequestEntity deleteConfigVerificationRequest(String processorId, String verificationRequestId) throws NiFiClientException, IOException;
VerifyConfigRequestEntity deleteConfigVerificationRequest(String processorId, String verificationRequestId) throws NiFiClientException, IOException;
}

View File

@ -19,7 +19,7 @@ package org.apache.nifi.toolkit.cli.impl.client.nifi;
import org.apache.nifi.web.api.entity.ReportingTaskEntity;
import org.apache.nifi.web.api.entity.ReportingTaskRunStatusEntity;
import org.apache.nifi.web.api.entity.VerifyReportingTaskConfigRequestEntity;
import org.apache.nifi.web.api.entity.VerifyConfigRequestEntity;
import java.io.IOException;
@ -34,10 +34,10 @@ public interface ReportingTasksClient {
ReportingTaskEntity activateReportingTask(String id, ReportingTaskRunStatusEntity runStatusEntity) throws NiFiClientException, IOException;
VerifyReportingTaskConfigRequestEntity submitConfigVerificationRequest(VerifyReportingTaskConfigRequestEntity configRequestEntity) throws NiFiClientException, IOException;
VerifyConfigRequestEntity submitConfigVerificationRequest(VerifyConfigRequestEntity configRequestEntity) throws NiFiClientException, IOException;
VerifyReportingTaskConfigRequestEntity getConfigVerificationRequest(String taskId, String verificationRequestId) throws NiFiClientException, IOException;
VerifyConfigRequestEntity getConfigVerificationRequest(String taskId, String verificationRequestId) throws NiFiClientException, IOException;
VerifyReportingTaskConfigRequestEntity deleteConfigVerificationRequest(String taskId, String verificationRequestId) throws NiFiClientException, IOException;
VerifyConfigRequestEntity deleteConfigVerificationRequest(String taskId, String verificationRequestId) throws NiFiClientException, IOException;
}

View File

@ -25,7 +25,7 @@ import org.apache.nifi.web.api.entity.ControllerServiceEntity;
import org.apache.nifi.web.api.entity.ControllerServiceReferencingComponentsEntity;
import org.apache.nifi.web.api.entity.ControllerServiceRunStatusEntity;
import org.apache.nifi.web.api.entity.UpdateControllerServiceReferenceRequestEntity;
import org.apache.nifi.web.api.entity.VerifyControllerServiceConfigRequestEntity;
import org.apache.nifi.web.api.entity.VerifyConfigRequestEntity;
import javax.ws.rs.client.Entity;
import javax.ws.rs.client.WebTarget;
@ -178,35 +178,35 @@ public class JerseyControllerServicesClient extends AbstractJerseyClient impleme
}
@Override
public VerifyControllerServiceConfigRequestEntity submitConfigVerificationRequest(final VerifyControllerServiceConfigRequestEntity configRequestEntity) throws NiFiClientException, IOException {
public VerifyConfigRequestEntity submitConfigVerificationRequest(final VerifyConfigRequestEntity configRequestEntity) throws NiFiClientException, IOException {
if (configRequestEntity == null) {
throw new IllegalArgumentException("Config Request Entity cannot be null");
}
if (configRequestEntity.getRequest() == null) {
throw new IllegalArgumentException("Config Request DTO cannot be null");
}
if (configRequestEntity.getRequest().getControllerServiceId() == null) {
if (configRequestEntity.getRequest().getComponentId() == null) {
throw new IllegalArgumentException("Controller Service ID cannot be null");
}
if (configRequestEntity.getRequest().getControllerService() == null) {
throw new IllegalArgumentException("Controller Service cannot be null");
if (configRequestEntity.getRequest().getProperties() == null) {
throw new IllegalArgumentException("Controller Service properties cannot be null");
}
return executeAction("Error submitting Config Verification Request", () -> {
final WebTarget target = controllerServicesTarget
.path("{id}/config/verification-requests")
.resolveTemplate("id", configRequestEntity.getRequest().getControllerServiceId());
.resolveTemplate("id", configRequestEntity.getRequest().getComponentId());
return getRequestBuilder(target).post(
Entity.entity(configRequestEntity, MediaType.APPLICATION_JSON_TYPE),
VerifyControllerServiceConfigRequestEntity.class
VerifyConfigRequestEntity.class
);
});
}
@Override
public VerifyControllerServiceConfigRequestEntity getConfigVerificationRequest(final String serviceId, final String verificationRequestId) throws NiFiClientException, IOException {
public VerifyConfigRequestEntity getConfigVerificationRequest(final String serviceId, final String verificationRequestId) throws NiFiClientException, IOException {
if (verificationRequestId == null) {
throw new IllegalArgumentException("Verification Request ID cannot be null");
}
@ -217,12 +217,12 @@ public class JerseyControllerServicesClient extends AbstractJerseyClient impleme
.resolveTemplate("id", serviceId)
.resolveTemplate("requestId", verificationRequestId);
return getRequestBuilder(target).get(VerifyControllerServiceConfigRequestEntity.class);
return getRequestBuilder(target).get(VerifyConfigRequestEntity.class);
});
}
@Override
public VerifyControllerServiceConfigRequestEntity deleteConfigVerificationRequest(final String serviceId, final String verificationRequestId) throws NiFiClientException, IOException {
public VerifyConfigRequestEntity deleteConfigVerificationRequest(final String serviceId, final String verificationRequestId) throws NiFiClientException, IOException {
if (verificationRequestId == null) {
throw new IllegalArgumentException("Verification Request ID cannot be null");
}
@ -233,7 +233,7 @@ public class JerseyControllerServicesClient extends AbstractJerseyClient impleme
.resolveTemplate("id", serviceId)
.resolveTemplate("requestId", verificationRequestId);
return getRequestBuilder(target).delete(VerifyControllerServiceConfigRequestEntity.class);
return getRequestBuilder(target).delete(VerifyConfigRequestEntity.class);
});
}
}

View File

@ -23,7 +23,7 @@ import org.apache.nifi.toolkit.cli.impl.client.nifi.RequestConfig;
import org.apache.nifi.web.api.dto.RevisionDTO;
import org.apache.nifi.web.api.entity.ProcessorEntity;
import org.apache.nifi.web.api.entity.ProcessorRunStatusEntity;
import org.apache.nifi.web.api.entity.VerifyProcessorConfigRequestEntity;
import org.apache.nifi.web.api.entity.VerifyConfigRequestEntity;
import javax.ws.rs.client.Entity;
import javax.ws.rs.client.WebTarget;
@ -181,34 +181,34 @@ public class JerseyProcessorClient extends AbstractJerseyClient implements Proce
}
@Override
public VerifyProcessorConfigRequestEntity submitConfigVerificationRequest(final VerifyProcessorConfigRequestEntity configRequestEntity) throws NiFiClientException, IOException {
public VerifyConfigRequestEntity submitConfigVerificationRequest(final VerifyConfigRequestEntity configRequestEntity) throws NiFiClientException, IOException {
if (configRequestEntity == null) {
throw new IllegalArgumentException("Config Request Entity cannot be null");
}
if (configRequestEntity.getRequest() == null) {
throw new IllegalArgumentException("Config Request DTO cannot be null");
}
if (configRequestEntity.getRequest().getProcessorId() == null) {
if (configRequestEntity.getRequest().getComponentId() == null) {
throw new IllegalArgumentException("Processor ID cannot be null");
}
if (configRequestEntity.getRequest().getProcessorConfig() == null) {
throw new IllegalArgumentException("Processor Config cannot be null");
if (configRequestEntity.getRequest().getProperties() == null) {
throw new IllegalArgumentException("Processor properties cannot be null");
}
return executeAction("Error submitting Config Verification Request", () -> {
final WebTarget target = processorTarget
.path("/config/verification-requests")
.resolveTemplate("id", configRequestEntity.getRequest().getProcessorId());
.resolveTemplate("id", configRequestEntity.getRequest().getComponentId());
return getRequestBuilder(target).post(
Entity.entity(configRequestEntity, MediaType.APPLICATION_JSON_TYPE),
VerifyProcessorConfigRequestEntity.class
VerifyConfigRequestEntity.class
);
});
}
@Override
public VerifyProcessorConfigRequestEntity getConfigVerificationRequest(final String processorId, final String verificationRequestId) throws NiFiClientException, IOException {
public VerifyConfigRequestEntity getConfigVerificationRequest(final String processorId, final String verificationRequestId) throws NiFiClientException, IOException {
if (verificationRequestId == null) {
throw new IllegalArgumentException("Verification Request ID cannot be null");
}
@ -219,12 +219,12 @@ public class JerseyProcessorClient extends AbstractJerseyClient implements Proce
.resolveTemplate("id", processorId)
.resolveTemplate("requestId", verificationRequestId);
return getRequestBuilder(target).get(VerifyProcessorConfigRequestEntity.class);
return getRequestBuilder(target).get(VerifyConfigRequestEntity.class);
});
}
@Override
public VerifyProcessorConfigRequestEntity deleteConfigVerificationRequest(final String processorId, final String verificationRequestId) throws NiFiClientException, IOException {
public VerifyConfigRequestEntity deleteConfigVerificationRequest(final String processorId, final String verificationRequestId) throws NiFiClientException, IOException {
if (verificationRequestId == null) {
throw new IllegalArgumentException("Verification Request ID cannot be null");
}
@ -235,7 +235,7 @@ public class JerseyProcessorClient extends AbstractJerseyClient implements Proce
.resolveTemplate("id", processorId)
.resolveTemplate("requestId", verificationRequestId);
return getRequestBuilder(target).delete(VerifyProcessorConfigRequestEntity.class);
return getRequestBuilder(target).delete(VerifyConfigRequestEntity.class);
});
}
}

View File

@ -23,7 +23,7 @@ import org.apache.nifi.toolkit.cli.impl.client.nifi.ReportingTasksClient;
import org.apache.nifi.toolkit.cli.impl.client.nifi.RequestConfig;
import org.apache.nifi.web.api.entity.ReportingTaskEntity;
import org.apache.nifi.web.api.entity.ReportingTaskRunStatusEntity;
import org.apache.nifi.web.api.entity.VerifyReportingTaskConfigRequestEntity;
import org.apache.nifi.web.api.entity.VerifyConfigRequestEntity;
import javax.ws.rs.client.Entity;
import javax.ws.rs.client.WebTarget;
@ -96,34 +96,34 @@ public class JerseyReportingTasksClient extends AbstractJerseyClient implements
}
@Override
public VerifyReportingTaskConfigRequestEntity submitConfigVerificationRequest(final VerifyReportingTaskConfigRequestEntity configRequestEntity) throws NiFiClientException, IOException {
public VerifyConfigRequestEntity submitConfigVerificationRequest(final VerifyConfigRequestEntity configRequestEntity) throws NiFiClientException, IOException {
if (configRequestEntity == null) {
throw new IllegalArgumentException("Config Request Entity cannot be null");
}
if (configRequestEntity.getRequest() == null) {
throw new IllegalArgumentException("Config Request DTO cannot be null");
}
if (configRequestEntity.getRequest().getReportingTaskId() == null) {
if (configRequestEntity.getRequest().getComponentId() == null) {
throw new IllegalArgumentException("Reporting Task ID cannot be null");
}
if (configRequestEntity.getRequest().getReportingTask() == null) {
throw new IllegalArgumentException("Reporting Task cannot be null");
if (configRequestEntity.getRequest().getProperties() == null) {
throw new IllegalArgumentException("Reporting Task properties cannot be null");
}
return executeAction("Error submitting Config Verification Request", () -> {
final WebTarget target = reportingTasksTarget
.path("{id}/config/verification-requests")
.resolveTemplate("id", configRequestEntity.getRequest().getReportingTaskId());
.resolveTemplate("id", configRequestEntity.getRequest().getComponentId());
return getRequestBuilder(target).post(
Entity.entity(configRequestEntity, MediaType.APPLICATION_JSON_TYPE),
VerifyReportingTaskConfigRequestEntity.class
VerifyConfigRequestEntity.class
);
});
}
@Override
public VerifyReportingTaskConfigRequestEntity getConfigVerificationRequest(final String taskId, final String verificationRequestId) throws NiFiClientException, IOException {
public VerifyConfigRequestEntity getConfigVerificationRequest(final String taskId, final String verificationRequestId) throws NiFiClientException, IOException {
if (verificationRequestId == null) {
throw new IllegalArgumentException("Verification Request ID cannot be null");
}
@ -134,12 +134,12 @@ public class JerseyReportingTasksClient extends AbstractJerseyClient implements
.resolveTemplate("id", taskId)
.resolveTemplate("requestId", verificationRequestId);
return getRequestBuilder(target).get(VerifyReportingTaskConfigRequestEntity.class);
return getRequestBuilder(target).get(VerifyConfigRequestEntity.class);
});
}
@Override
public VerifyReportingTaskConfigRequestEntity deleteConfigVerificationRequest(final String taskId, final String verificationRequestId) throws NiFiClientException, IOException {
public VerifyConfigRequestEntity deleteConfigVerificationRequest(final String taskId, final String verificationRequestId) throws NiFiClientException, IOException {
if (verificationRequestId == null) {
throw new IllegalArgumentException("Verification Request ID cannot be null");
}
@ -150,7 +150,7 @@ public class JerseyReportingTasksClient extends AbstractJerseyClient implements
.resolveTemplate("id", taskId)
.resolveTemplate("requestId", verificationRequestId);
return getRequestBuilder(target).delete(VerifyReportingTaskConfigRequestEntity.class);
return getRequestBuilder(target).delete(VerifyConfigRequestEntity.class);
});
}
}