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/10/30 21:03:03 UTC

[1/3] nifi git commit: NIFI-869 Fixed SimpleProcessLogger to log correct messages Ensured that SimpleProcessLogger correctly interprets Throwable as discussed in JIRA Added tests

Repository: nifi
Updated Branches:
  refs/heads/master 1d97876f8 -> ba72452f6


NIFI-869 Fixed SimpleProcessLogger to log correct messages Ensured that SimpleProcessLogger correctly interprets Throwable as discussed in JIRA Added tests

Signed-off-by: Mark Payne <ma...@hotmail.com>


Project: http://git-wip-us.apache.org/repos/asf/nifi/repo
Commit: http://git-wip-us.apache.org/repos/asf/nifi/commit/a3d43d23
Tree: http://git-wip-us.apache.org/repos/asf/nifi/tree/a3d43d23
Diff: http://git-wip-us.apache.org/repos/asf/nifi/diff/a3d43d23

Branch: refs/heads/master
Commit: a3d43d23dcf68310b518d35751d1835767d895a4
Parents: 90aea01
Author: Oleg Zhurakousky <ol...@suitcase.io>
Authored: Fri Oct 30 14:24:12 2015 -0400
Committer: Mark Payne <ma...@hotmail.com>
Committed: Fri Oct 30 15:52:33 2015 -0400

----------------------------------------------------------------------
 .../scheduling/StandardProcessScheduler.java    |   2 +-
 .../nifi/processor/SimpleProcessLogger.java     |  20 ++--
 .../nifi/processor/TestSimpleProcessLogger.java | 100 +++++++++++++++++++
 3 files changed, 113 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/nifi/blob/a3d43d23/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-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/scheduling/StandardProcessScheduler.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/scheduling/StandardProcessScheduler.java
index 5d99d07..9ff58c8 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/scheduling/StandardProcessScheduler.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/scheduling/StandardProcessScheduler.java
@@ -655,7 +655,7 @@ public final class StandardProcessScheduler implements ProcessScheduler {
                             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 {}", new Object[]{cause.toString()});
+                            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);

http://git-wip-us.apache.org/repos/asf/nifi/blob/a3d43d23/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/processor/SimpleProcessLogger.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/processor/SimpleProcessLogger.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/processor/SimpleProcessLogger.java
index afd0c59..900ec77 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/processor/SimpleProcessLogger.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/processor/SimpleProcessLogger.java
@@ -62,8 +62,12 @@ public class SimpleProcessLogger implements ProcessorLog {
     }
 
     @Override
-    public void warn(final String msg, final Throwable t) {
-        warn("{} " + msg, new Object[]{component}, t);
+    public void warn(String msg, final Throwable t) {
+        //warn("{} " + msg, new Object[]{component}, t);
+        msg = "{} " + msg;
+        final Object[] os = {component, t.toString(), t};
+        logger.warn(msg, os);
+        logRepository.addLogMessage(LogLevel.WARN, msg, os, t);
     }
 
     @Override
@@ -101,8 +105,8 @@ public class SimpleProcessLogger implements ProcessorLog {
     @Override
     public void trace(String msg, Throwable t) {
         msg = "{} " + msg;
-        final Object[] os = {component};
-        logger.trace(msg, os, t);
+        final Object[] os = {component, t.toString(), t};
+        logger.trace(msg, os);
         logRepository.addLogMessage(LogLevel.TRACE, msg, os, t);
     }
 
@@ -160,7 +164,7 @@ public class SimpleProcessLogger implements ProcessorLog {
     @Override
     public void info(String msg, Throwable t) {
         msg = "{} " + msg;
-        final Object[] os = {component};
+        final Object[] os = {component, t.toString()};
 
         logger.info(msg, os);
         if (logger.isDebugEnabled()) {
@@ -207,12 +211,12 @@ public class SimpleProcessLogger implements ProcessorLog {
     @Override
     public void error(String msg, Throwable t) {
         msg = "{} " + msg;
-        final Object[] os = {component};
-
-        logger.error(msg, os, t);
+        Object[] os = {component, t.toString()};
+        logger.error(msg, os);
         if (logger.isDebugEnabled()) {
             logger.error("", t);
         }
+
         logRepository.addLogMessage(LogLevel.ERROR, msg, os, t);
     }
 

http://git-wip-us.apache.org/repos/asf/nifi/blob/a3d43d23/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/processor/TestSimpleProcessLogger.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/processor/TestSimpleProcessLogger.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/processor/TestSimpleProcessLogger.java
new file mode 100644
index 0000000..2876abb
--- /dev/null
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/processor/TestSimpleProcessLogger.java
@@ -0,0 +1,100 @@
+/*
+ * 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.processor;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import static org.mockito.Mockito.argThat;
+import static org.mockito.Mockito.anyString;
+import static org.mockito.Mockito.times;
+
+import java.lang.reflect.Field;
+
+import org.apache.nifi.reporting.ReportingTask;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.ArgumentMatcher;
+import org.mockito.internal.matchers.VarargMatcher;
+import org.slf4j.Logger;
+
+public class TestSimpleProcessLogger {
+	private final Exception e = new RuntimeException("intentional");
+
+	private  ReportingTask task;
+
+	private SimpleProcessLogger componentLog;
+
+	private Logger logger;
+
+	@Before
+	public void before(){
+		task = mock(ReportingTask.class);
+		when(task.getIdentifier()).thenReturn("foo");
+		when(task.toString()).thenReturn("MyTask");
+		componentLog = new SimpleProcessLogger(task.getIdentifier(), task);
+		try {
+			Field loggerField = componentLog.getClass().getDeclaredField("logger");
+			loggerField.setAccessible(true);
+			logger = mock(Logger.class);
+			loggerField.set(componentLog, logger);
+		} catch (Exception e) {
+			e.printStackTrace();
+			fail(e.getMessage());
+		}
+	}
+
+	@Test
+	public void validateDelegateLoggerReceivesThrowableToStringOnError() {
+		componentLog.error("Hello {}", e);
+		verify(logger, times(1)).error(anyString(), argThat(new MyVarargMatcher()));
+	}
+
+	@Test
+	public void validateDelegateLoggerReceivesThrowableToStringOnInfo() {
+		componentLog.info("Hello {}", e);
+		verify(logger, times(1)).info(anyString(), argThat(new MyVarargMatcher()));
+	}
+
+	@Test
+	public void validateDelegateLoggerReceivesThrowableToStringOnTrace() {
+		componentLog.trace("Hello {}", e);
+		verify(logger, times(1)).trace(anyString(), argThat(new MyVarargMatcher()));
+	}
+
+	@Test
+	public void validateDelegateLoggerReceivesThrowableToStringOnWarn() {
+		componentLog.warn("Hello {}", e);
+		verify(logger, times(1)).warn(anyString(), argThat(new MyVarargMatcher()));
+	}
+
+	/**
+	 *
+	 */
+	private class MyVarargMatcher extends ArgumentMatcher<Object[]> implements VarargMatcher {
+		private static final long serialVersionUID = 1L;
+		@Override
+		public boolean matches(Object argument) {
+			Object[] args = (Object[]) argument;
+			assertEquals(task, args[0]);
+			assertEquals(e.toString(), args[1]);
+			return true;
+		}
+	}
+}


[2/3] nifi git commit: NIFI-869 Fixed formatting issue Fixed formatting issue with printed error message which only apears when NiFi is cnfigured using Logback. Please see NIFI-869 for more details

Posted by ma...@apache.org.
NIFI-869 Fixed formatting issue Fixed formatting issue with printed error message which only apears when NiFi is cnfigured using Logback. Please see NIFI-869 for more details

Signed-off-by: Mark Payne <ma...@hotmail.com>


Project: http://git-wip-us.apache.org/repos/asf/nifi/repo
Commit: http://git-wip-us.apache.org/repos/asf/nifi/commit/90aea013
Tree: http://git-wip-us.apache.org/repos/asf/nifi/tree/90aea013
Diff: http://git-wip-us.apache.org/repos/asf/nifi/diff/90aea013

Branch: refs/heads/master
Commit: 90aea0135062c50e2c8635e178188d2d8c35b883
Parents: dc4004d
Author: Oleg Zhurakousky <ol...@suitcase.io>
Authored: Thu Oct 29 14:19:44 2015 -0400
Committer: Mark Payne <ma...@hotmail.com>
Committed: Fri Oct 30 15:52:33 2015 -0400

----------------------------------------------------------------------
 .../nifi/controller/scheduling/StandardProcessScheduler.java       | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/nifi/blob/90aea013/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-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/scheduling/StandardProcessScheduler.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/scheduling/StandardProcessScheduler.java
index 9ff58c8..5d99d07 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/scheduling/StandardProcessScheduler.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/scheduling/StandardProcessScheduler.java
@@ -655,7 +655,7 @@ public final class StandardProcessScheduler implements ProcessScheduler {
                             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);
+                            componentLog.error("failed to invoke @OnEnabled method due to {}", new Object[]{cause.toString()});
                             LOG.error("Failed to invoke @OnEnabled method of {} due to {}", service.getControllerServiceImplementation(), cause.toString());
                             if (LOG.isDebugEnabled()) {
                                 LOG.error("", cause);


[3/3] nifi git commit: Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/nifi

Posted by ma...@apache.org.
Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/nifi


Project: http://git-wip-us.apache.org/repos/asf/nifi/repo
Commit: http://git-wip-us.apache.org/repos/asf/nifi/commit/ba72452f
Tree: http://git-wip-us.apache.org/repos/asf/nifi/tree/ba72452f
Diff: http://git-wip-us.apache.org/repos/asf/nifi/diff/ba72452f

Branch: refs/heads/master
Commit: ba72452f669b926c2af63ccd5684e0c2b793f405
Parents: a3d43d2 1d97876
Author: Mark Payne <ma...@hotmail.com>
Authored: Fri Oct 30 16:02:15 2015 -0400
Committer: Mark Payne <ma...@hotmail.com>
Committed: Fri Oct 30 16:02:15 2015 -0400

----------------------------------------------------------------------
 .../java/org/apache/nifi/action/Action.java     |  50 ++++
 .../java/org/apache/nifi/action/Component.java  |  34 +++
 .../java/org/apache/nifi/action/Operation.java  |  37 +++
 .../component/details/ComponentDetails.java     |  26 ++
 .../component/details/ExtensionDetails.java     |  26 ++
 .../details/RemoteProcessGroupDetails.java      |  26 ++
 .../nifi/action/details/ActionDetails.java      |  26 ++
 .../nifi/action/details/ConfigureDetails.java   |  30 ++
 .../nifi/action/details/ConnectDetails.java     |  40 +++
 .../apache/nifi/action/details/MoveDetails.java |  30 ++
 .../nifi/action/details/PurgeDetails.java       |  28 ++
 .../org/apache/nifi/reporting/EventAccess.java  |  13 +
 .../org/apache/nifi/util/MockEventAccess.java   |  27 ++
 .../org/apache/nifi/admin/dao/ActionDAO.java    |  12 +-
 .../java/org/apache/nifi/admin/dao/UserDAO.java |   3 +-
 .../nifi/admin/dao/impl/StandardActionDAO.java  |  93 +++---
 .../nifi/admin/dao/impl/StandardUserDAO.java    |   4 +-
 .../apache/nifi/admin/service/AuditService.java |  18 +-
 .../admin/service/action/AddActionsAction.java  |   3 +-
 .../service/action/PurgeActionsAction.java      |   3 +-
 .../service/impl/StandardAuditService.java      |  24 +-
 .../resources/nifi-administration-context.xml   |   2 +-
 .../manager/impl/ClusteredEventAccess.java      |  21 +-
 .../cluster/manager/impl/WebClusterManager.java |   2 +-
 .../apache/nifi/controller/FlowController.java  | 136 +++++----
 .../nifi/spring/FlowControllerFactoryBean.java  |   8 +
 .../src/main/resources/nifi-context.xml         |   1 +
 .../controller/StandardFlowServiceTest.java     |   5 +-
 .../nifi-framework/nifi-user-actions/pom.xml    |   7 +
 .../java/org/apache/nifi/action/Action.java     | 121 --------
 .../java/org/apache/nifi/action/Component.java  |  34 ---
 .../apache/nifi/action/FlowChangeAction.java    | 130 +++++++++
 .../java/org/apache/nifi/action/Operation.java  |  37 ---
 .../component/details/ComponentDetails.java     |  26 --
 .../component/details/ExtensionDetails.java     |  34 ---
 .../details/FlowChangeExtensionDetails.java     |  35 +++
 .../FlowChangeRemoteProcessGroupDetails.java    |  35 +++
 .../details/RemoteProcessGroupDetails.java      |  34 ---
 .../nifi/action/details/ActionDetails.java      |  26 --
 .../nifi/action/details/ConfigureDetails.java   |  52 ----
 .../nifi/action/details/ConnectDetails.java     |  90 ------
 .../details/FlowChangeConfigureDetails.java     |  55 ++++
 .../details/FlowChangeConnectDetails.java       |  97 +++++++
 .../action/details/FlowChangeMoveDetails.java   |  65 +++++
 .../action/details/FlowChangePurgeDetails.java  |  46 +++
 .../apache/nifi/action/details/MoveDetails.java |  61 ----
 .../nifi/action/details/PurgeDetails.java       |  45 ---
 .../apache/nifi/audit/ControllerAuditor.java    |  27 +-
 .../nifi/audit/ControllerServiceAuditor.java    |  43 +--
 .../org/apache/nifi/audit/FunnelAuditor.java    |   7 +-
 .../java/org/apache/nifi/audit/NiFiAuditor.java |  25 +-
 .../java/org/apache/nifi/audit/PortAuditor.java |  27 +-
 .../apache/nifi/audit/ProcessGroupAuditor.java  |  25 +-
 .../org/apache/nifi/audit/ProcessorAuditor.java |  25 +-
 .../apache/nifi/audit/RelationshipAuditor.java  |  18 +-
 .../nifi/audit/RemoteProcessGroupAuditor.java   |  35 +--
 .../apache/nifi/audit/ReportingTaskAuditor.java |  25 +-
 .../org/apache/nifi/audit/SnippetAuditor.java   |  26 +-
 .../nifi/web/StandardNiFiServiceFacade.java     |   9 +-
 .../StandardNiFiWebConfigurationContext.java    |  13 +-
 .../apache/nifi/web/StandardNiFiWebContext.java |  13 +-
 .../nifi/web/api/ApplicationResource.java       |   5 +-
 .../org/apache/nifi/web/api/dto/DtoFactory.java |  20 +-
 .../nifi-pcap-processors/.gitignore             |   1 -
 .../processors/standard/AttributesToJSON.java   | 242 ++++++++++++++++
 .../org.apache.nifi.processor.Processor         |   1 +
 .../standard/TestAttributesToJSON.java          | 282 +++++++++++++++++++
 67 files changed, 1781 insertions(+), 846 deletions(-)
----------------------------------------------------------------------