forked from apache/nifi
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce async post processing of uploaded NARs
- Return NarUpload object from upload - Add NarManager methods to get an upload and delete an upload - Add REST APIs for getting an upload and deleting an upload - Update CLI command for uploading to submit and poll/delete
- Loading branch information
Showing
25 changed files
with
881 additions
and
151 deletions.
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
...framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/NarCoordinateDTO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* 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.v3.oas.annotations.media.Schema; | ||
import jakarta.xml.bind.annotation.XmlType; | ||
|
||
@XmlType(name = "narCoordinate") | ||
public class NarCoordinateDTO { | ||
|
||
private String group; | ||
private String id; | ||
private String version; | ||
|
||
@Schema(description = "The group of the NAR.") | ||
public String getGroup() { | ||
return group; | ||
} | ||
|
||
public void setGroup(final String group) { | ||
this.group = group; | ||
} | ||
|
||
@Schema(description = "The identifier of the NAR.") | ||
public String getId() { | ||
return id; | ||
} | ||
|
||
public void setId(final String id) { | ||
this.id = id; | ||
} | ||
|
||
@Schema(description = "The version of the NAR.") | ||
public String getVersion() { | ||
return version; | ||
} | ||
|
||
public void setVersion(final String version) { | ||
this.version = version; | ||
} | ||
} |
94 changes: 94 additions & 0 deletions
94
...ifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/NarUploadDTO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
/* | ||
* 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.v3.oas.annotations.media.Schema; | ||
import jakarta.xml.bind.annotation.XmlType; | ||
|
||
@XmlType(name = "narUpload") | ||
public class NarUploadDTO { | ||
|
||
private String identifier; | ||
private NarCoordinateDTO coordinate; | ||
private NarCoordinateDTO dependencyCoordinate; | ||
|
||
private boolean processingComplete; | ||
private String processingStatus; | ||
private String processingResult; | ||
|
||
public NarUploadDTO() { | ||
} | ||
|
||
public NarUploadDTO(final String identifier) { | ||
this.identifier = identifier; | ||
} | ||
|
||
@Schema(description = "The identifier for the upload.") | ||
public String getIdentifier() { | ||
return identifier; | ||
} | ||
|
||
public void setIdentifier(final String identifier) { | ||
this.identifier = identifier; | ||
} | ||
|
||
@Schema(description = "The coordinate of the uploaded NAR.") | ||
public NarCoordinateDTO getCoordinate() { | ||
return coordinate; | ||
} | ||
|
||
public void setCoordinate(final NarCoordinateDTO coordinate) { | ||
this.coordinate = coordinate; | ||
} | ||
|
||
@Schema(description = "The coordinate of another NAR that the uploaded NAR is dependent on, or null if not dependent on another NAR.") | ||
public NarCoordinateDTO getDependencyCoordinate() { | ||
return dependencyCoordinate; | ||
} | ||
|
||
public void setDependencyCoordinate(final NarCoordinateDTO dependencyCoordinate) { | ||
this.dependencyCoordinate = dependencyCoordinate; | ||
} | ||
|
||
@Schema(description = "Indicates if processing of the uploaded NAR has completed.") | ||
public boolean isProcessingComplete() { | ||
return processingComplete; | ||
} | ||
|
||
public void setProcessingComplete(final boolean processingComplete) { | ||
this.processingComplete = processingComplete; | ||
} | ||
|
||
@Schema(description = "Status indicating the phase of processing the uploaded NAR.") | ||
public String getProcessingStatus() { | ||
return processingStatus; | ||
} | ||
|
||
public void setProcessingStatus(final String processingStatus) { | ||
this.processingStatus = processingStatus; | ||
} | ||
|
||
@Schema(description = "Result of processing the uploaded NAR, or null if processing is not complete.") | ||
public String getProcessingResult() { | ||
return processingResult; | ||
} | ||
|
||
public void setProcessingResult(final String processingResult) { | ||
this.processingResult = processingResult; | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
...amework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/NarUploadEntity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* 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 jakarta.xml.bind.annotation.XmlType; | ||
import org.apache.nifi.web.api.dto.NarUploadDTO; | ||
|
||
@XmlType(name = "narUploadEntity") | ||
public class NarUploadEntity extends Entity { | ||
|
||
private NarUploadDTO narUpload; | ||
|
||
public NarUploadEntity() { | ||
} | ||
|
||
public NarUploadEntity(final NarUploadDTO narUpload) { | ||
this.narUpload = narUpload; | ||
} | ||
|
||
public NarUploadDTO getNarUpload() { | ||
return narUpload; | ||
} | ||
|
||
public void setNarUpload(final NarUploadDTO narUpload) { | ||
this.narUpload = narUpload; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
...ramework-cluster/src/main/java/org/apache/nifi/cluster/manager/NarUploadEntityMerger.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* 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.manager; | ||
|
||
import org.apache.nifi.cluster.coordination.http.endpoints.AbstractSingleDTOEndpoint; | ||
import org.apache.nifi.cluster.protocol.NodeIdentifier; | ||
import org.apache.nifi.web.api.dto.NarUploadDTO; | ||
import org.apache.nifi.web.api.entity.NarUploadEntity; | ||
|
||
import java.net.URI; | ||
import java.util.Map; | ||
import java.util.Set; | ||
import java.util.regex.Pattern; | ||
|
||
public class NarUploadEntityMerger extends AbstractSingleDTOEndpoint<NarUploadEntity, NarUploadDTO> { | ||
|
||
private static final String NAR_UPLOAD_PATH = "/nifi-api/controller/nar-manager/uploads"; | ||
public static final Pattern NAR_UPLOAD_URI_PATTERN = Pattern.compile(NAR_UPLOAD_PATH + "/[a-f0-9\\-]{36}"); | ||
|
||
@Override | ||
public boolean canHandle(final URI uri, final String method) { | ||
if ("POST".equals(method) && NAR_UPLOAD_PATH.equals(uri.getPath())) { | ||
return true; | ||
} else { | ||
return ("GET".equals(method) || "DELETE".equals(method)) && NAR_UPLOAD_URI_PATTERN.matcher(uri.getPath()).matches(); | ||
} | ||
} | ||
|
||
@Override | ||
protected Class<NarUploadEntity> getEntityClass() { | ||
return NarUploadEntity.class; | ||
} | ||
|
||
@Override | ||
protected NarUploadDTO getDto(final NarUploadEntity entity) { | ||
return entity.getNarUpload(); | ||
} | ||
|
||
@Override | ||
protected void mergeResponses(final NarUploadDTO clientDto, final Map<NodeIdentifier, NarUploadDTO> dtoMap, final Set<NodeResponse> successfulResponses, | ||
final Set<NodeResponse> problematicResponses) { | ||
for (final NarUploadDTO narUploadDTO : dtoMap.values()) { | ||
if (!narUploadDTO.isProcessingComplete()) { | ||
clientDto.setProcessingComplete(narUploadDTO.isProcessingComplete()); | ||
clientDto.setProcessingStatus(narUploadDTO.getProcessingStatus()); | ||
clientDto.setProcessingResult(narUploadDTO.getProcessingResult()); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
...le/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/nar/NarState.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* 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.nar; | ||
|
||
public enum NarState { | ||
LOADED, | ||
MISSING_DEPENDENCY | ||
} |
Oops, something went wrong.