Skip to content

Commit

Permalink
NIFI-6873: Added support for replacing a process group
Browse files Browse the repository at this point in the history
 - decoupled flow update request behavior from VersionsResource into new abstract FlowUpdateResource
 - added replace process group functionality in ProcessGroupResource
 - parameterized FlowUpdateResource and created entity hierarchies to allow for maximum code sharing across different update types
 - refactored flow update methods to make use of commonality across different update types whenever possible
 - fixed issues in StandardProcessGroup verify update methods where same components existed in different ancestry chains but were considered a match when they shouldn't be
 - improved StandardProcessGroup to properly match up components on update using generated versioned component ids, when necessary to allow for update flow to efficiently match common components on flow import

This closes apache#4023.

Signed-off-by: Mark Payne <[email protected]>
  • Loading branch information
jsferner authored and markap14 committed Feb 11, 2020
1 parent a80b247 commit 62606ff
Show file tree
Hide file tree
Showing 25 changed files with 1,757 additions and 1,110 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ public interface VersionedComponent {

/**
* @return the unique identifier that maps this component to a component that is versioned
* in a Flow Registry, or <code>Optional.empty</code> if this component has not been saved to a Flow Registry.
* in a Flow Registry or has been imported, or <code>Optional.empty</code> if this component has not
* been saved to a Flow Registry or imported.
*/
Optional<String> getVersionedComponentId();

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
/*
* 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 org.apache.nifi.web.api.dto.util.TimestampAdapter;

import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import java.util.Date;

public abstract class FlowUpdateRequestDTO {
protected String requestId;
protected String processGroupId;
protected String uri;
protected Date lastUpdated;
protected boolean complete = false;
protected String failureReason;
protected int percentCompleted;
protected String state;

@ApiModelProperty("The unique ID of the Process Group being updated")
public String getProcessGroupId() {
return processGroupId;
}

public void setProcessGroupId(String processGroupId) {
this.processGroupId = processGroupId;
}

@ApiModelProperty(value = "The unique ID of this request.", readOnly = true)
public String getRequestId() {
return requestId;
}

public void setRequestId(String requestId) {
this.requestId = requestId;
}

@ApiModelProperty(value = "The URI for future requests to this drop request.", readOnly = true)
public String getUri() {
return uri;
}

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

@XmlJavaTypeAdapter(TimestampAdapter.class)
@ApiModelProperty(value = "The last time this request was updated.", dataType = "string", readOnly = true)
public Date getLastUpdated() {
return lastUpdated;
}

public void setLastUpdated(Date lastUpdated) {
this.lastUpdated = lastUpdated;
}

@ApiModelProperty(value = "Whether or not this request has completed", readOnly = true)
public boolean isComplete() {
return complete;
}

public void setComplete(boolean complete) {
this.complete = complete;
}

@ApiModelProperty(value = "An explanation of why this request failed, or null if this request has not failed", readOnly = true)
public String getFailureReason() {
return failureReason;
}

public void setFailureReason(String reason) {
this.failureReason = reason;
}

@ApiModelProperty(value = "The state of the request", readOnly = true)
public String getState() {
return state;
}

public void setState(String state) {
this.state = state;
}

@ApiModelProperty(value = "The percentage complete for the request, between 0 and 100", readOnly = true)
public int getPercentCompleted() {
return percentCompleted;
}

public void setPercentCompleted(int percentCompleted) {
this.percentCompleted = percentCompleted;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* 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 javax.xml.bind.annotation.XmlType;

@XmlType(name = "processGroupReplaceRequest")
public class ProcessGroupReplaceRequestDTO extends FlowUpdateRequestDTO {

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,79 +18,13 @@
package org.apache.nifi.web.api.dto;

import io.swagger.annotations.ApiModelProperty;
import org.apache.nifi.web.api.dto.util.TimestampAdapter;

import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import java.util.Date;

@XmlType(name = "versionedFlowUpdateRequest")
public class VersionedFlowUpdateRequestDTO {
private String requestId;
private String processGroupId;
private String uri;
private Date lastUpdated;
private boolean complete = false;
private String failureReason;
private int percentCompleted;
private String state;
public class VersionedFlowUpdateRequestDTO extends FlowUpdateRequestDTO {
private VersionControlInformationDTO versionControlInformation;

@ApiModelProperty("The unique ID of the Process Group that the variable registry belongs to")
public String getProcessGroupId() {
return processGroupId;
}

public void setProcessGroupId(String processGroupId) {
this.processGroupId = processGroupId;
}

@ApiModelProperty(value = "The unique ID of this request.", readOnly = true)
public String getRequestId() {
return requestId;
}

public void setRequestId(String requestId) {
this.requestId = requestId;
}

@ApiModelProperty(value = "The URI for future requests to this drop request.", readOnly = true)
public String getUri() {
return uri;
}

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

@XmlJavaTypeAdapter(TimestampAdapter.class)
@ApiModelProperty(value = "The last time this request was updated.", dataType = "string", readOnly = true)
public Date getLastUpdated() {
return lastUpdated;
}

public void setLastUpdated(Date lastUpdated) {
this.lastUpdated = lastUpdated;
}

@ApiModelProperty(value = "Whether or not this request has completed", readOnly = true)
public boolean isComplete() {
return complete;
}

public void setComplete(boolean complete) {
this.complete = complete;
}

@ApiModelProperty(value = "An explanation of why this request failed, or null if this request has not failed", readOnly = true)
public String getFailureReason() {
return failureReason;
}

public void setFailureReason(String reason) {
this.failureReason = reason;
}

@ApiModelProperty(value = "The VersionControlInformation that describes where the Versioned Flow is located; this may not be populated until the request is completed.", readOnly = true)
public VersionControlInformationDTO getVersionControlInformation() {
return versionControlInformation;
Expand All @@ -99,22 +33,4 @@ public VersionControlInformationDTO getVersionControlInformation() {
public void setVersionControlInformation(VersionControlInformationDTO versionControlInformation) {
this.versionControlInformation = versionControlInformation;
}

@ApiModelProperty(value = "The state of the request", readOnly = true)
public String getState() {
return state;
}

public void setState(String state) {
this.state = state;
}

@ApiModelProperty(value = "The percentage complete for the request, between 0 and 100", readOnly = true)
public int getPercentCompleted() {
return percentCompleted;
}

public void setPercentCompleted(int percentCompleted) {
this.percentCompleted = percentCompleted;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* 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.FlowUpdateRequestDTO;
import org.apache.nifi.web.api.dto.RevisionDTO;

public abstract class FlowUpdateRequestEntity<T extends FlowUpdateRequestDTO> extends Entity {
protected RevisionDTO processGroupRevision;
protected T request;

@ApiModelProperty("The revision for the Process Group being updated.")
public RevisionDTO getProcessGroupRevision() {
return processGroupRevision;
}

public void setProcessGroupRevision(RevisionDTO revision) {
this.processGroupRevision = revision;
}

@ApiModelProperty("The Process Group Update Request")
public abstract T getRequest();

public abstract void setRequest(T request);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* 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.RevisionDTO;

/**
* Common abstract entity shared by VersionControlInformationEntity and ProcessGroupImportEntity for
* generically processing/replicating process group update requests
*/
public abstract class ProcessGroupDescriptorEntity extends Entity {
private RevisionDTO processGroupRevision;
private Boolean disconnectedNodeAcknowledged;

@ApiModelProperty("The Revision for the Process Group")
public RevisionDTO getProcessGroupRevision() {
return processGroupRevision;
}

public void setProcessGroupRevision(RevisionDTO revision) {
this.processGroupRevision = revision;
}

@ApiModelProperty(
value = "Acknowledges that this node is disconnected to allow for mutable requests to proceed."
)
public Boolean isDisconnectedNodeAcknowledged() {
return disconnectedNodeAcknowledged;
}

public void setDisconnectedNodeAcknowledged(Boolean disconnectedNodeAcknowledged) {
this.disconnectedNodeAcknowledged = disconnectedNodeAcknowledged;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* 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.registry.flow.VersionedFlowSnapshot;

import javax.xml.bind.annotation.XmlRootElement;

/**
* Entity for importing a process group that has been previously downloaded
*/
@XmlRootElement(name = "processGroupImportEntity")
public class ProcessGroupImportEntity extends ProcessGroupDescriptorEntity {
private VersionedFlowSnapshot versionedFlowSnapshot;

@ApiModelProperty("The Versioned Flow Snapshot to import")
public VersionedFlowSnapshot getVersionedFlowSnapshot() {
return versionedFlowSnapshot;
}

public void setVersionedFlowSnapshot(VersionedFlowSnapshot versionedFlowSnapshot) {
this.versionedFlowSnapshot = versionedFlowSnapshot;
}
}
Loading

0 comments on commit 62606ff

Please sign in to comment.