mirror of https://github.com/apache/nifi.git
NIFI-3309 ensures that CS are deleted when a process group is deleted
This closes #1411. Signed-off-by: Bryan Bende <bbende@apache.org>
This commit is contained in:
parent
c8f437e833
commit
2fbeabb95f
|
@ -211,7 +211,7 @@ public class StandardControllerServiceNode extends AbstractConfiguredComponent i
|
|||
@Override
|
||||
public void verifyCanDelete() {
|
||||
if (getState() != ControllerServiceState.DISABLED) {
|
||||
throw new IllegalStateException(implementation.getIdentifier() + " cannot be deleted because it is not disabled");
|
||||
throw new IllegalStateException("Controller Service " + implementation.getIdentifier() + " cannot be deleted because it is not disabled");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -619,6 +619,10 @@ public final class StandardProcessGroup implements ProcessGroup {
|
|||
group.removeLabel(label);
|
||||
}
|
||||
|
||||
for (final ControllerServiceNode cs : group.getControllerServices(false)) {
|
||||
group.removeControllerService(cs);
|
||||
}
|
||||
|
||||
for (final ProcessGroup childGroup : new ArrayList<>(group.getProcessGroups())) {
|
||||
group.removeProcessGroup(childGroup);
|
||||
}
|
||||
|
@ -2324,6 +2328,10 @@ public final class StandardProcessGroup implements ProcessGroup {
|
|||
connection.verifyCanDelete();
|
||||
}
|
||||
|
||||
for(final ControllerServiceNode cs : controllerServices.values()) {
|
||||
cs.verifyCanDelete();
|
||||
}
|
||||
|
||||
for (final ProcessGroup childGroup : processGroups.values()) {
|
||||
// For nested child groups we can ignore the input/output port
|
||||
// connections as they will be being deleted anyway.
|
||||
|
|
|
@ -31,6 +31,7 @@ import java.util.HashMap;
|
|||
import java.util.LinkedHashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.nifi.admin.service.AuditService;
|
||||
import org.apache.nifi.authorization.AbstractPolicyBasedAuthorizer;
|
||||
|
@ -46,6 +47,7 @@ import org.apache.nifi.controller.reporting.ReportingTaskInstantiationException;
|
|||
import org.apache.nifi.controller.repository.FlowFileEventRepository;
|
||||
import org.apache.nifi.controller.service.ControllerServiceNode;
|
||||
import org.apache.nifi.encrypt.StringEncryptor;
|
||||
import org.apache.nifi.groups.ProcessGroup;
|
||||
import org.apache.nifi.logging.LogLevel;
|
||||
import org.apache.nifi.processor.Relationship;
|
||||
import org.apache.nifi.provenance.MockProvenanceRepository;
|
||||
|
@ -353,8 +355,16 @@ public class TestFlowController {
|
|||
assertEquals("0 sec",p_settings.getSchedulingPeriod());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void testDeleteProcessGroup() {
|
||||
ProcessGroup pg = controller.createProcessGroup("my-process-group");
|
||||
pg.setName("my-process-group");
|
||||
ControllerServiceNode cs = controller.createControllerService("org.apache.nifi.NonExistingControllerService", "my-controller-service", false);
|
||||
pg.addControllerService(cs);
|
||||
controller.getRootGroup().addProcessGroup(pg);
|
||||
controller.getRootGroup().removeProcessGroup(pg);
|
||||
pg.getControllerServices(true);
|
||||
assertTrue(pg.getControllerServices(true).isEmpty());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue