From 0b5d004afae1e53c8e68f72f193bf6fc69b1b07a Mon Sep 17 00:00:00 2001 From: zsitole Date: Fri, 15 Apr 2022 14:58:00 +0300 Subject: [PATCH] GEODE-10231 : Add configuration for suppressing FunctionException logging - pmd fix - logger format fix --- .../geode/internal/cache/execute/AbstractExecution.java | 6 ++++-- .../execute/DistributedRegionFunctionResultSender.java | 6 ++++-- .../cache/execute/MemberFunctionResultSender.java | 6 ++++-- .../execute/PartitionedRegionFunctionResultSender.java | 6 ++++-- .../cache/execute/ServerToClientFunctionResultSender.java | 8 +++++--- .../geode/internal/cache/tier/sockets/BaseCommand.java | 3 ++- .../cache/tier/sockets/command/ExecuteFunction70.java | 2 +- .../tier/sockets/command/ExecuteRegionFunction66.java | 7 +++---- .../internal/cli/functions/UserFunctionExecution.java | 6 ++++-- 9 files changed, 31 insertions(+), 19 deletions(-) diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/execute/AbstractExecution.java b/geode-core/src/main/java/org/apache/geode/internal/cache/execute/AbstractExecution.java index 35e9e7904909..ef74ada2d5fd 100755 --- a/geode-core/src/main/java/org/apache/geode/internal/cache/execute/AbstractExecution.java +++ b/geode-core/src/main/java/org/apache/geode/internal/cache/execute/AbstractExecution.java @@ -27,6 +27,7 @@ import org.apache.geode.InternalGemFireException; import org.apache.geode.SystemFailure; +import org.apache.geode.annotations.Immutable; import org.apache.geode.annotations.internal.MakeNotStatic; import org.apache.geode.cache.LowMemoryException; import org.apache.geode.cache.TransactionException; @@ -57,7 +58,8 @@ */ public abstract class AbstractExecution implements InternalExecution { private static final Logger logger = LogService.getLogger(); - private static final Marker FUNCTION_EXCEPTION_MARKER = + @Immutable + private static final Marker functionExceptionMarker = MarkerManager.getMarker("FUNCTION_EXCEPTION_MARKER"); public static final int DEFAULT_CLIENT_FUNCTION_TIMEOUT = 0; @@ -508,7 +510,7 @@ private void handleException(Throwable functionException, final Function fn, ((InternalResultSender) sender).setException(functionException); } } else { - logger.warn(functionException instanceof FunctionException ? FUNCTION_EXCEPTION_MARKER : null, + logger.warn(functionException instanceof FunctionException ? functionExceptionMarker : null, "Exception occurred on local node while executing Function:", functionException); } diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/execute/DistributedRegionFunctionResultSender.java b/geode-core/src/main/java/org/apache/geode/internal/cache/execute/DistributedRegionFunctionResultSender.java index ac7b403f40b8..afd2083e5b8e 100644 --- a/geode-core/src/main/java/org/apache/geode/internal/cache/execute/DistributedRegionFunctionResultSender.java +++ b/geode-core/src/main/java/org/apache/geode/internal/cache/execute/DistributedRegionFunctionResultSender.java @@ -18,6 +18,7 @@ import org.apache.logging.log4j.Marker; import org.apache.logging.log4j.MarkerManager; +import org.apache.geode.annotations.Immutable; import org.apache.geode.cache.execute.Function; import org.apache.geode.cache.execute.FunctionException; import org.apache.geode.cache.execute.ResultCollector; @@ -31,7 +32,8 @@ public class DistributedRegionFunctionResultSender implements InternalResultSender { private static final Logger logger = LogService.getLogger(); - private static final Marker FUNCTION_EXCEPTION_MARKER = + @Immutable + private static final Marker functionExceptionMarker = MarkerManager.getMarker("FUNCTION_EXCEPTION_MARKER"); DistributedRegionFunctionStreamingMessage msg = null; @@ -228,7 +230,7 @@ public void setException(Throwable exception) { } else { ((LocalResultCollector) rc).setException(exception); // this.lastResult(exception); - logger.info(exception instanceof FunctionException ? FUNCTION_EXCEPTION_MARKER : null, + logger.info(exception instanceof FunctionException ? functionExceptionMarker : null, "Unexpected exception during function execution on local node Distributed Region", exception); } diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/execute/MemberFunctionResultSender.java b/geode-core/src/main/java/org/apache/geode/internal/cache/execute/MemberFunctionResultSender.java index 41699b3a9fa7..eb2c15fde071 100644 --- a/geode-core/src/main/java/org/apache/geode/internal/cache/execute/MemberFunctionResultSender.java +++ b/geode-core/src/main/java/org/apache/geode/internal/cache/execute/MemberFunctionResultSender.java @@ -19,6 +19,7 @@ import org.apache.logging.log4j.Marker; import org.apache.logging.log4j.MarkerManager; +import org.apache.geode.annotations.Immutable; import org.apache.geode.cache.execute.Function; import org.apache.geode.cache.execute.FunctionException; import org.apache.geode.cache.execute.ResultCollector; @@ -33,7 +34,8 @@ public class MemberFunctionResultSender implements InternalResultSender { private static final Logger logger = LogService.getLogger(); - private static final Marker FUNCTION_EXCEPTION_MARKER = + @Immutable + private static final Marker functionExceptionMarker = MarkerManager.getMarker("FUNCTION_EXCEPTION_MARKER"); MemberFunctionStreamingMessage msg = null; @@ -236,7 +238,7 @@ public void sendException(Throwable exception) { public void setException(Throwable exception) { ((LocalResultCollector) rc).setException(exception); // this.lastResult(exception); - logger.info(exception instanceof FunctionException ? FUNCTION_EXCEPTION_MARKER : null, + logger.info(exception instanceof FunctionException ? functionExceptionMarker : null, "Unexpected exception during function execution local member", exception); rc.endResults(); diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/execute/PartitionedRegionFunctionResultSender.java b/geode-core/src/main/java/org/apache/geode/internal/cache/execute/PartitionedRegionFunctionResultSender.java index 57e1747784b5..3e2fd5d1fcd6 100644 --- a/geode-core/src/main/java/org/apache/geode/internal/cache/execute/PartitionedRegionFunctionResultSender.java +++ b/geode-core/src/main/java/org/apache/geode/internal/cache/execute/PartitionedRegionFunctionResultSender.java @@ -20,6 +20,7 @@ import org.apache.logging.log4j.Marker; import org.apache.logging.log4j.MarkerManager; +import org.apache.geode.annotations.Immutable; import org.apache.geode.cache.execute.Function; import org.apache.geode.cache.execute.FunctionException; import org.apache.geode.cache.execute.ResultCollector; @@ -44,7 +45,8 @@ public class PartitionedRegionFunctionResultSender implements InternalResultSender { private static final Logger logger = LogService.getLogger(); - private static final Marker FUNCTION_EXCEPTION_MARKER = + @Immutable + private static final Marker functionExceptionMarker = MarkerManager.getMarker("FUNCTION_EXCEPTION_MARKER"); PartitionedRegionFunctionStreamingMessage msg = null; @@ -394,7 +396,7 @@ public void setException(Throwable exception) { serverSender.setException(exception); } else { ((LocalResultCollector) rc).setException(exception); - logger.info(exception instanceof FunctionException ? FUNCTION_EXCEPTION_MARKER : null, + logger.info(exception instanceof FunctionException ? functionExceptionMarker : null, "Unexpected exception during function execution on local node Partitioned Region", exception); } diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/execute/ServerToClientFunctionResultSender.java b/geode-core/src/main/java/org/apache/geode/internal/cache/execute/ServerToClientFunctionResultSender.java index 7823cc52cf1d..decd8db5eeb1 100755 --- a/geode-core/src/main/java/org/apache/geode/internal/cache/execute/ServerToClientFunctionResultSender.java +++ b/geode-core/src/main/java/org/apache/geode/internal/cache/execute/ServerToClientFunctionResultSender.java @@ -23,6 +23,7 @@ import org.apache.logging.log4j.Marker; import org.apache.logging.log4j.MarkerManager; +import org.apache.geode.annotations.Immutable; import org.apache.geode.cache.execute.Function; import org.apache.geode.cache.execute.FunctionException; import org.apache.geode.cache.execute.ResultSender; @@ -39,7 +40,8 @@ public class ServerToClientFunctionResultSender implements ResultSender { private static final Logger logger = LogService.getLogger(); - private static final Marker FUNCTION_EXCEPTION_MARKER = + @Immutable + private static final Marker functionExceptionMarker = MarkerManager.getMarker("FUNCTION_EXCEPTION_MARKER"); protected ChunkedMessage msg = null; @@ -325,8 +327,8 @@ public synchronized void setException(Throwable exception) { } String exceptionMessage = exception.getMessage() != null ? exception.getMessage() : "Exception occurred during function execution"; - logger.warn(exception instanceof FunctionException ? FUNCTION_EXCEPTION_MARKER : null, - String.format("Exception on server while executing function : %s", fn), exception); + logger.warn(exception instanceof FunctionException ? functionExceptionMarker : null, + "Exception on server while executing function : {}", fn, exception); if (logger.isDebugEnabled()) { logger.debug("ServerToClientFunctionResultSender sending Function Exception : "); diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/BaseCommand.java b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/BaseCommand.java index 5e768d1c3dc7..dc109901bbc6 100644 --- a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/BaseCommand.java +++ b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/BaseCommand.java @@ -90,7 +90,8 @@ public abstract class BaseCommand implements Command { protected static final Logger logger = LogService.getLogger(); - protected static final Marker FUNCTION_EXCEPTION_MARKER = + @Immutable + protected static final Marker functionExceptionMarker = MarkerManager.getMarker("FUNCTION_EXCEPTION_MARKER"); @Immutable diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/ExecuteFunction70.java b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/ExecuteFunction70.java index e0f78b912581..cc11c0e130f8 100644 --- a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/ExecuteFunction70.java +++ b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/ExecuteFunction70.java @@ -433,7 +433,7 @@ private void executeFunctionLocally(final Function fn, final FunctionContext cx, } } catch (FunctionException e) { stats.endFunctionExecutionWithException(startExecution, fn.hasResult()); - logger.warn(FUNCTION_EXCEPTION_MARKER, "Exception on server while executing function: {}", + logger.warn(functionExceptionMarker, "Exception on server while executing function: {}", fn, e); } catch (Exception e) { stats.endFunctionExecutionWithException(startExecution, fn.hasResult()); diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/ExecuteRegionFunction66.java b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/ExecuteRegionFunction66.java index 2eb8de576e66..ffe701674475 100644 --- a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/ExecuteRegionFunction66.java +++ b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/ExecuteRegionFunction66.java @@ -220,10 +220,9 @@ public void cmdExecute(final @NotNull Message clientMessage, resultSender.setException(fe); } else { if (setLastResultReceived(resultSender)) { - logger.warn(FUNCTION_EXCEPTION_MARKER, - String.format("Exception on server while executing function : %s", - function), - fe); + logger.warn(functionExceptionMarker, + "Exception on server while executing function : {}", + function, fe); sendException(hasResult, clientMessage, message, serverConnection, fe); } } diff --git a/geode-gfsh/src/main/java/org/apache/geode/management/internal/cli/functions/UserFunctionExecution.java b/geode-gfsh/src/main/java/org/apache/geode/management/internal/cli/functions/UserFunctionExecution.java index 26f504568131..321058617350 100644 --- a/geode-gfsh/src/main/java/org/apache/geode/management/internal/cli/functions/UserFunctionExecution.java +++ b/geode-gfsh/src/main/java/org/apache/geode/management/internal/cli/functions/UserFunctionExecution.java @@ -32,6 +32,7 @@ import org.apache.logging.log4j.MarkerManager; import org.apache.shiro.subject.Subject; +import org.apache.geode.annotations.Immutable; import org.apache.geode.cache.Cache; import org.apache.geode.cache.Region; import org.apache.geode.cache.execute.Execution; @@ -58,7 +59,8 @@ public class UserFunctionExecution implements InternalFunction { private static final long serialVersionUID = 1L; private static final Logger logger = LogService.getLogger(); - private static final Marker FUNCTION_EXCEPTION_MARKER = + @Immutable + private static final Marker functionExceptionMarker = MarkerManager.getMarker("FUNCTION_EXCEPTION_MARKER"); protected static final String ID = @@ -251,7 +253,7 @@ public void execute(FunctionContext context) { CliStrings.EXECUTE_FUNCTION__MSG__RESULT_COLLECTOR_0_NOT_FOUND_ERROR_1, resultCollectorName, e.getMessage()))); } catch (FunctionException e) { - logger.error(FUNCTION_EXCEPTION_MARKER, "error executing function " + functionId, e); + logger.error(functionExceptionMarker, "error executing function {}", functionId, e); context.getResultSender().lastResult( new CliFunctionResult(context.getMemberName(), ERROR, "Exception: " + e.getMessage())); } catch (Exception e) {