NIFI-4: Updates to provide proper lifecycle support via annotations for controller services and reporting tasks

This commit is contained in:
Mark Payne 2015-01-18 20:25:32 -05:00
parent d8e1f570a6
commit 850396cc97
5 changed files with 19 additions and 1 deletions

View File

@ -68,5 +68,9 @@ public interface ReportingTaskNode extends ConfiguredComponent {
void setScheduledState(ScheduledState state);
void verifyCanStart();
void verifyCanStop();
void verifyCanDisable();
void verifyCanEnable();
void verifyCanDelete();
}

View File

@ -40,5 +40,7 @@ public interface ControllerServiceNode extends ConfiguredComponent {
void removeReference(ConfiguredComponent referringComponent);
void verifyCanEnable();
void verifyCanDisable();
void verifyCanDelete();
}

View File

@ -2522,6 +2522,8 @@ public class FlowController implements EventAccess, ControllerServiceProvider, H
throw new IllegalStateException("Cannot start reporting task " + reportingTaskNode + " because the controller is terminated");
}
reportingTaskNode.verifyCanStart();
processScheduler.schedule(reportingTaskNode);
}
@ -2530,6 +2532,8 @@ public class FlowController implements EventAccess, ControllerServiceProvider, H
return;
}
reportingTaskNode.verifyCanStop();
processScheduler.unschedule(reportingTaskNode);
}
@ -2554,18 +2558,26 @@ public class FlowController implements EventAccess, ControllerServiceProvider, H
public void enableReportingTask(final ReportingTaskNode reportingTaskNode) {
reportingTaskNode.verifyCanEnable();
processScheduler.enableReportingTask(reportingTaskNode);
}
public void disableReportingTask(final ReportingTaskNode reportingTaskNode) {
reportingTaskNode.verifyCanDisable();
processScheduler.disableReportingTask(reportingTaskNode);
}
public void enableControllerService(final ControllerServiceNode serviceNode) {
serviceNode.verifyCanEnable();
processScheduler.enableControllerService(serviceNode);
}
public void disableControllerService(final ControllerServiceNode serviceNode) {
serviceNode.verifyCanDisable();
processScheduler.disableControllerService(serviceNode);
}

View File

@ -159,4 +159,5 @@ public abstract class AbstractReportingTaskNode extends AbstractConfiguredCompon
throw new IllegalStateException(this + " is running");
}
}
}

View File

@ -34,7 +34,6 @@ import org.apache.nifi.annotation.lifecycle.OnAdded;
import org.apache.nifi.annotation.lifecycle.OnRemoved;
import org.apache.nifi.controller.ConfigurationContext;
import org.apache.nifi.controller.ControllerService;
import org.apache.nifi.controller.ReportingTaskNode;
import org.apache.nifi.controller.ValidationContextFactory;
import org.apache.nifi.controller.exception.ControllerServiceAlreadyExistsException;
import org.apache.nifi.controller.exception.ControllerServiceNotFoundException;