You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by ma...@apache.org on 2015/02/19 21:04:14 UTC
[1/2] incubator-nifi git commit: NIFI-368: generate bulletins when
there are problems communicating with reporting tasks and controller services
Repository: incubator-nifi
Updated Branches:
refs/heads/NIFI-250 ee63a10b8 -> f246565f7
NIFI-368: generate bulletins when there are problems communicating with reporting tasks and controller services
Project: http://git-wip-us.apache.org/repos/asf/incubator-nifi/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-nifi/commit/852cc607
Tree: http://git-wip-us.apache.org/repos/asf/incubator-nifi/tree/852cc607
Diff: http://git-wip-us.apache.org/repos/asf/incubator-nifi/diff/852cc607
Branch: refs/heads/NIFI-250
Commit: 852cc607f6fad61178f7c9d3a26807c24eee4e0e
Parents: ee63a10
Author: Mark Payne <ma...@hotmail.com>
Authored: Thu Feb 19 15:03:54 2015 -0500
Committer: Mark Payne <ma...@hotmail.com>
Committed: Thu Feb 19 15:03:54 2015 -0500
----------------------------------------------------------------------
.../scheduling/StandardProcessScheduler.java | 31 ++++++++++++--------
1 file changed, 18 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/852cc607/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/scheduling/StandardProcessScheduler.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/scheduling/StandardProcessScheduler.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/scheduling/StandardProcessScheduler.java
index 0e181c5..955f6b1 100644
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/scheduling/StandardProcessScheduler.java
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/scheduling/StandardProcessScheduler.java
@@ -49,6 +49,7 @@ import org.apache.nifi.controller.service.ControllerServiceState;
import org.apache.nifi.controller.service.StandardConfigurationContext;
import org.apache.nifi.encrypt.StringEncryptor;
import org.apache.nifi.engine.FlowEngine;
+import org.apache.nifi.logging.ComponentLog;
import org.apache.nifi.logging.ProcessorLog;
import org.apache.nifi.nar.NarCloseable;
import org.apache.nifi.processor.SchedulingContext;
@@ -181,16 +182,11 @@ public final class StandardProcessScheduler implements ProcessScheduler {
}
break;
- } catch (final InvocationTargetException ite) {
- LOG.error("Failed to invoke the On-Scheduled Lifecycle methods of {} due to {}; administratively yielding this ReportingTask and will attempt to schedule it again after {}",
- new Object[]{reportingTask, ite.getTargetException(), administrativeYieldDuration});
- LOG.error("", ite.getTargetException());
-
- try {
- Thread.sleep(administrativeYieldMillis);
- } catch (final InterruptedException ie) {
- }
} catch (final Exception e) {
+ final Throwable cause = (e instanceof InvocationTargetException) ? e.getCause() : e;
+ final ComponentLog componentLog = new SimpleProcessLogger(reportingTask.getIdentifier(), reportingTask);
+ componentLog.error("Failed to invoke @OnEnabled method due to {}", cause);
+
LOG.error("Failed to invoke the On-Scheduled Lifecycle methods of {} due to {}; administratively yielding this ReportingTask and will attempt to schedule it again after {}",
new Object[]{reportingTask, e.toString(), administrativeYieldDuration}, e);
try {
@@ -232,7 +228,10 @@ public final class StandardProcessScheduler implements ProcessScheduler {
}
} catch (final Exception e) {
final Throwable cause = (e instanceof InvocationTargetException) ? e.getCause() : e;
- LOG.error("Failed to invoke the @OnConfigured methods of {} due to {}; administratively yielding this ReportingTask and will attempt to schedule it again after {}",
+ final ComponentLog componentLog = new SimpleProcessLogger(reportingTask.getIdentifier(), reportingTask);
+ componentLog.error("Failed to invoke @OnUnscheduled method due to {}", cause);
+
+ LOG.error("Failed to invoke the @OnUnscheduled methods of {} due to {}; administratively yielding this ReportingTask and will attempt to schedule it again after {}",
reportingTask, cause.toString(), administrativeYieldDuration);
LOG.error("", cause);
@@ -624,8 +623,10 @@ public final class StandardProcessScheduler implements ProcessScheduler {
return;
}
} catch (final Exception e) {
- // TODO: Generate a bulletin just like in startProcessor
final Throwable cause = (e instanceof InvocationTargetException) ? e.getCause() : e;
+
+ final ComponentLog componentLog = new SimpleProcessLogger(service.getIdentifier(), service);
+ componentLog.error("Failed to invoke @OnEnabled method due to {}", cause);
LOG.error("Failed to invoke @OnEnabled method of {} due to {}", service.getControllerServiceImplementation(), cause.toString());
if ( LOG.isDebugEnabled() ) {
LOG.error("", cause);
@@ -637,8 +638,10 @@ public final class StandardProcessScheduler implements ProcessScheduler {
}
}
} catch (final Throwable t) {
- // TODO: Generate a bulletin just like in startProcessor
final Throwable cause = (t instanceof InvocationTargetException) ? t.getCause() : t;
+ final ComponentLog componentLog = new SimpleProcessLogger(service.getIdentifier(), service);
+ componentLog.error("Failed to invoke @OnEnabled method due to {}", cause);
+
LOG.error("Failed to invoke @OnEnabled method on {} due to {}", service.getControllerServiceImplementation(), cause.toString());
if ( LOG.isDebugEnabled() ) {
LOG.error("", cause);
@@ -673,8 +676,10 @@ public final class StandardProcessScheduler implements ProcessScheduler {
service.setState(ControllerServiceState.DISABLED);
return;
} catch (final Exception e) {
- // TODO: Generate a bulletin just like in startProcessor
final Throwable cause = (e instanceof InvocationTargetException) ? e.getCause() : e;
+ final ComponentLog componentLog = new SimpleProcessLogger(service.getIdentifier(), service);
+ componentLog.error("Failed to invoke @OnDisabled method due to {}", cause);
+
LOG.error("Failed to invoke @OnDisabled method of {} due to {}", service.getControllerServiceImplementation(), cause.toString());
if ( LOG.isDebugEnabled() ) {
LOG.error("", cause);
[2/2] incubator-nifi git commit: NIFI-250: Incorporate new logic for
controller service state
Posted by ma...@apache.org.
NIFI-250: Incorporate new logic for controller service state
Project: http://git-wip-us.apache.org/repos/asf/incubator-nifi/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-nifi/commit/f246565f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-nifi/tree/f246565f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-nifi/diff/f246565f
Branch: refs/heads/NIFI-250
Commit: f246565f7e5344db91f731e003c7e35e1d7cbe95
Parents: 852cc60
Author: Mark Payne <ma...@hotmail.com>
Authored: Thu Feb 19 15:04:13 2015 -0500
Committer: Mark Payne <ma...@hotmail.com>
Committed: Thu Feb 19 15:04:13 2015 -0500
----------------------------------------------------------------------
.../apache/nifi/controller/FlowFromDOMFactory.java | 5 ++++-
.../nifi/controller/StandardFlowSynchronizer.java | 17 +++++++++++++----
2 files changed, 17 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/f246565f/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/FlowFromDOMFactory.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/FlowFromDOMFactory.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/FlowFromDOMFactory.java
index 2a44176..6e17208 100644
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/FlowFromDOMFactory.java
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/FlowFromDOMFactory.java
@@ -26,6 +26,7 @@ import java.util.Set;
import java.util.concurrent.TimeUnit;
import org.apache.nifi.connectable.Size;
+import org.apache.nifi.controller.service.ControllerServiceState;
import org.apache.nifi.encrypt.StringEncryptor;
import org.apache.nifi.groups.RemoteProcessGroupPortDescriptor;
import org.apache.nifi.remote.StandardRemoteProcessGroupPortDescriptor;
@@ -86,7 +87,9 @@ public class FlowFromDOMFactory {
dto.setName(getString(element, "name"));
dto.setComments(getString(element, "comment"));
dto.setType(getString(element, "class"));
- dto.setEnabled(getBoolean(element, "enabled"));
+
+ final boolean enabled = getBoolean(element, "enabled");
+ dto.setState(enabled ? ControllerServiceState.ENABLED.name() : ControllerServiceState.DISABLED.name());
dto.setProperties(getProperties(element, encryptor));
dto.setAnnotationData(getString(element, "annotationData"));
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/f246565f/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/StandardFlowSynchronizer.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/StandardFlowSynchronizer.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/StandardFlowSynchronizer.java
index 2508b5b..633d58b 100644
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/StandardFlowSynchronizer.java
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/StandardFlowSynchronizer.java
@@ -54,6 +54,7 @@ import org.apache.nifi.controller.exception.ProcessorInstantiationException;
import org.apache.nifi.controller.label.Label;
import org.apache.nifi.controller.reporting.ReportingTaskInstantiationException;
import org.apache.nifi.controller.service.ControllerServiceNode;
+import org.apache.nifi.controller.service.ControllerServiceState;
import org.apache.nifi.encrypt.StringEncryptor;
import org.apache.nifi.events.BulletinFactory;
import org.apache.nifi.fingerprint.FingerprintException;
@@ -361,7 +362,9 @@ public class StandardFlowSynchronizer implements FlowSynchronizer {
}
if ( autoResumeState ) {
- if ( Boolean.TRUE.equals(dto.getEnabled()) ) {
+ final ControllerServiceState state = ControllerServiceState.valueOf(dto.getState());
+ final boolean enable = (state == ControllerServiceState.ENABLED || state == ControllerServiceState.ENABLING);
+ if (enable) {
try {
controller.enableControllerService(node);
} catch (final Exception e) {
@@ -380,10 +383,16 @@ public class StandardFlowSynchronizer implements FlowSynchronizer {
private void updateControllerService(final FlowController controller, final Element controllerServiceElement, final StringEncryptor encryptor) {
final ControllerServiceDTO dto = FlowFromDOMFactory.getControllerService(controllerServiceElement, encryptor);
- final boolean enabled = controller.isControllerServiceEnabled(dto.getId());
- if (dto.getEnabled() && !enabled) {
+ final ControllerServiceState state = ControllerServiceState.valueOf(dto.getState());
+ final boolean dtoEnabled = (state == ControllerServiceState.ENABLED || state == ControllerServiceState.ENABLING);
+
+ final ControllerServiceNode serviceNode = controller.getControllerServiceNode(dto.getId());
+ final ControllerServiceState serviceState = serviceNode.getState();
+ final boolean serviceEnabled = (serviceState == ControllerServiceState.ENABLED || state == ControllerServiceState.ENABLING);
+
+ if (dtoEnabled && !serviceEnabled) {
controller.enableControllerService(controller.getControllerServiceNode(dto.getId()));
- } else if (dto.getEnabled() == Boolean.FALSE && enabled) {
+ } else if (!dtoEnabled && serviceEnabled) {
controller.disableControllerService(controller.getControllerServiceNode(dto.getId()));
}
}