Skip to content

Commit b457f15

Browse files
committed
GEODE-10231 : Add configuration for suppressing FunctionException logging
Use Log4j Markers for FunctionException logs
1 parent ec173cb commit b457f15

File tree

10 files changed

+49
-86
lines changed

10 files changed

+49
-86
lines changed

geode-core/src/main/java/org/apache/geode/internal/cache/execute/AbstractExecution.java

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
import java.util.concurrent.TimeUnit;
2323

2424
import org.apache.logging.log4j.Logger;
25+
import org.apache.logging.log4j.Marker;
26+
import org.apache.logging.log4j.MarkerManager;
2527

2628
import org.apache.geode.InternalGemFireException;
2729
import org.apache.geode.SystemFailure;
@@ -55,10 +57,8 @@
5557
*/
5658
public abstract class AbstractExecution implements InternalExecution {
5759
private static final Logger logger = LogService.getLogger();
58-
59-
/** Whether to suppress logging of FunctionException */
60-
public static final boolean SUPPRESS_FUNCTION_EXCEPTION_LOGGING =
61-
Boolean.getBoolean(GeodeGlossary.GEMFIRE_PREFIX + "logging.suppressFunctionExceptionLogging");
60+
private static final Marker FUNCTION_EXCEPTION_MARKER =
61+
MarkerManager.getMarker("FUNCTION_EXCEPTION_MARKER");
6262

6363
public static final int DEFAULT_CLIENT_FUNCTION_TIMEOUT = 0;
6464
private static final String CLIENT_FUNCTION_TIMEOUT_SYSTEM_PROPERTY =
@@ -508,16 +508,9 @@ private void handleException(Throwable functionException, final Function fn,
508508
((InternalResultSender) sender).setException(functionException);
509509
}
510510
} else {
511-
if (AbstractExecution.SUPPRESS_FUNCTION_EXCEPTION_LOGGING
512-
&& functionException instanceof FunctionException) {
513-
if (logger.isDebugEnabled()) {
514-
logger.debug("Exception occurred on local node while executing Function:",
515-
functionException);
516-
}
517-
} else {
518-
logger.warn("Exception occurred on local node while executing Function:",
519-
functionException);
520-
}
511+
logger.warn(functionException instanceof FunctionException ? FUNCTION_EXCEPTION_MARKER : null,
512+
"Exception occurred on local node while executing Function:",
513+
functionException);
521514
}
522515
}
523516

geode-core/src/main/java/org/apache/geode/internal/cache/execute/DistributedRegionFunctionResultSender.java

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
package org.apache.geode.internal.cache.execute;
1616

1717
import org.apache.logging.log4j.Logger;
18+
import org.apache.logging.log4j.Marker;
19+
import org.apache.logging.log4j.MarkerManager;
1820

1921
import org.apache.geode.cache.execute.Function;
2022
import org.apache.geode.cache.execute.FunctionException;
@@ -29,6 +31,8 @@
2931
public class DistributedRegionFunctionResultSender implements InternalResultSender {
3032

3133
private static final Logger logger = LogService.getLogger();
34+
private static final Marker FUNCTION_EXCEPTION_MARKER =
35+
MarkerManager.getMarker("FUNCTION_EXCEPTION_MARKER");
3236

3337
DistributedRegionFunctionStreamingMessage msg = null;
3438

@@ -224,18 +228,9 @@ public void setException(Throwable exception) {
224228
} else {
225229
((LocalResultCollector) rc).setException(exception);
226230
// this.lastResult(exception);
227-
if (AbstractExecution.SUPPRESS_FUNCTION_EXCEPTION_LOGGING
228-
&& exception instanceof FunctionException) {
229-
if (logger.isDebugEnabled()) {
230-
logger.debug(
231-
"Unexpected exception during function execution on local node Distributed Region",
232-
exception);
233-
}
234-
} else {
235-
logger.info(
236-
"Unexpected exception during function execution on local node Distributed Region",
237-
exception);
238-
}
231+
logger.info(exception instanceof FunctionException ? FUNCTION_EXCEPTION_MARKER : null,
232+
"Unexpected exception during function execution on local node Distributed Region",
233+
exception);
239234
}
240235
rc.endResults();
241236
localLastResultReceived = true;

geode-core/src/main/java/org/apache/geode/internal/cache/execute/MemberFunctionResultSender.java

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
package org.apache.geode.internal.cache.execute;
1717

1818
import org.apache.logging.log4j.Logger;
19+
import org.apache.logging.log4j.Marker;
20+
import org.apache.logging.log4j.MarkerManager;
1921

2022
import org.apache.geode.cache.execute.Function;
2123
import org.apache.geode.cache.execute.FunctionException;
@@ -31,6 +33,8 @@
3133
public class MemberFunctionResultSender implements InternalResultSender {
3234

3335
private static final Logger logger = LogService.getLogger();
36+
private static final Marker FUNCTION_EXCEPTION_MARKER =
37+
MarkerManager.getMarker("FUNCTION_EXCEPTION_MARKER");
3438

3539
MemberFunctionStreamingMessage msg = null;
3640

@@ -232,17 +236,9 @@ public void sendException(Throwable exception) {
232236
public void setException(Throwable exception) {
233237
((LocalResultCollector) rc).setException(exception);
234238
// this.lastResult(exception);
235-
if (AbstractExecution.SUPPRESS_FUNCTION_EXCEPTION_LOGGING
236-
&& exception instanceof FunctionException) {
237-
if (logger.isDebugEnabled()) {
238-
logger.debug("Unexpected exception during function execution local member",
239-
exception);
240-
}
241-
} else {
242-
logger.info("Unexpected exception during function execution local member",
243-
exception);
244-
}
245-
239+
logger.info(exception instanceof FunctionException ? FUNCTION_EXCEPTION_MARKER : null,
240+
"Unexpected exception during function execution local member",
241+
exception);
246242
rc.endResults();
247243
localLastResultReceived = true;
248244
}

geode-core/src/main/java/org/apache/geode/internal/cache/execute/PartitionedRegionFunctionResultSender.java

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818

1919
import org.apache.logging.log4j.Logger;
20+
import org.apache.logging.log4j.Marker;
21+
import org.apache.logging.log4j.MarkerManager;
2022

2123
import org.apache.geode.cache.execute.Function;
2224
import org.apache.geode.cache.execute.FunctionException;
@@ -42,6 +44,8 @@
4244
public class PartitionedRegionFunctionResultSender implements InternalResultSender {
4345

4446
private static final Logger logger = LogService.getLogger();
47+
private static final Marker FUNCTION_EXCEPTION_MARKER =
48+
MarkerManager.getMarker("FUNCTION_EXCEPTION_MARKER");
4549

4650
PartitionedRegionFunctionStreamingMessage msg = null;
4751

@@ -390,18 +394,9 @@ public void setException(Throwable exception) {
390394
serverSender.setException(exception);
391395
} else {
392396
((LocalResultCollector) rc).setException(exception);
393-
if (AbstractExecution.SUPPRESS_FUNCTION_EXCEPTION_LOGGING
394-
&& exception instanceof FunctionException) {
395-
if (logger.isDebugEnabled()) {
396-
logger.debug(
397-
"Unexpected exception during function execution on local node Partitioned Region",
398-
exception);
399-
}
400-
} else {
401-
logger.info(
402-
"Unexpected exception during function execution on local node Partitioned Region",
403-
exception);
404-
}
397+
logger.info(exception instanceof FunctionException ? FUNCTION_EXCEPTION_MARKER : null,
398+
"Unexpected exception during function execution on local node Partitioned Region",
399+
exception);
405400
}
406401
rc.endResults();
407402
localLastResultReceived = true;

geode-core/src/main/java/org/apache/geode/internal/cache/execute/ServerToClientFunctionResultSender.java

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
import java.util.concurrent.atomic.AtomicBoolean;
2121

2222
import org.apache.logging.log4j.Logger;
23+
import org.apache.logging.log4j.Marker;
24+
import org.apache.logging.log4j.MarkerManager;
2325

2426
import org.apache.geode.cache.execute.Function;
2527
import org.apache.geode.cache.execute.FunctionException;
@@ -37,6 +39,8 @@
3739

3840
public class ServerToClientFunctionResultSender implements ResultSender {
3941
private static final Logger logger = LogService.getLogger();
42+
private static final Marker FUNCTION_EXCEPTION_MARKER =
43+
MarkerManager.getMarker("FUNCTION_EXCEPTION_MARKER");
4044

4145
protected ChunkedMessage msg = null;
4246

@@ -321,16 +325,8 @@ public synchronized void setException(Throwable exception) {
321325
}
322326
String exceptionMessage = exception.getMessage() != null ? exception.getMessage()
323327
: "Exception occurred during function execution";
324-
if (AbstractExecution.SUPPRESS_FUNCTION_EXCEPTION_LOGGING
325-
&& exception instanceof FunctionException) {
326-
if (logger.isDebugEnabled()) {
327-
logger.debug(String.format("Exception on server while executing function : %s",
328-
fn), exception);
329-
}
330-
} else {
331-
logger.warn(String.format("Exception on server while executing function : %s",
332-
fn), exception);
333-
}
328+
logger.warn(exception instanceof FunctionException ? FUNCTION_EXCEPTION_MARKER : null,
329+
String.format("Exception on server while executing function : %s", fn), exception);
334330

335331
if (logger.isDebugEnabled()) {
336332
logger.debug("ServerToClientFunctionResultSender sending Function Exception : ");

geode-core/src/main/java/org/apache/geode/internal/cache/properties.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ DistributionConfigImpl constructor prepends `gemfire.` to each valid attribute n
131131
| gemfire.EXPIRY_UNITS_MS | Boolean | `false` | See `org.apache.geode.internal.cache.LocalRegion#EXPIRY_MS_PROPERTY`.<p>Used by unit tests to set expiry to milliseconds instead of the default seconds. Used in ExpiryTask.|
132132
| gemfire.IDLE_THREAD_TIMEOUT | Integer | `30000 * 60` | See `org.apache.geode.distributed.internal.FunctionExecutionPooledExecutor` constructor.<p>See `org.apache.geode.internal.logging.CoreLoggingExecutors#getIdleThreadTimeoutMillis`<p>Units are in milliseconds.|
133133
| gemfire.locator-load-imbalance-threshold | Float | `10.0` | See `org.apache.geode.distributed.internal.LocatorLoadSnapshot#LOAD_IMBALANCE_THRESHOLD_PROPERTY_NAME`<p>Sets the connection count threshold for rebalancing clients. When a client asks the locator whether it should switch to a less loaded server the locator will respond "no" if the connection-count gap between the highest-loaded server and the least-loaded server is within this threshold. If the threshold is reached the locator will aggressivley reassign clients until balance is re-established.|
134-
| gemfire.logging.suppressFunctionExceptionLogging | Boolean | `false` | See `org.apache.geode.internal.cache.execute.AbstractExecution#SUPPRESS_FUNCTION_EXCEPTION_LOGGING`.<p>Whether to suppress logging of FunctionException during function execution.|
135134
| gemfire.memoryEventTolerance | Integer | `0` | See `org.apache.geode.internal.cache.control.MemoryThresholds#memoryStateChangeTolerance`<p>Number of eviction or critical state changes that have to occur before the event is delivered.<p>The default is `0` so we will change states immediately by default.|
136135
| gemfire.MAX_PENDING_CANCELS | Integer | `10000` | See `org.apache.geode.internal.cache.ExpirationScheduler#MAX_PENDING_CANCELS`.|
137136
| gemfire.MAXIMUM_SHUTDOWN_PEEKS | Integer | `50` | See `org.apache.geode.internal.cache.tier.sockets.CacheClientProxy#MAXIMUM_SHUTDOWN_PEEKS`.<p>The number of times to peek on shutdown before giving up and shutting down.</p>|

geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/BaseCommand.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
import java.util.regex.Pattern;
3535

3636
import org.apache.logging.log4j.Logger;
37+
import org.apache.logging.log4j.Marker;
38+
import org.apache.logging.log4j.MarkerManager;
3739
import org.jetbrains.annotations.NotNull;
3840
import org.jetbrains.annotations.Nullable;
3941

@@ -88,6 +90,8 @@
8890

8991
public abstract class BaseCommand implements Command {
9092
protected static final Logger logger = LogService.getLogger();
93+
protected static final Marker FUNCTION_EXCEPTION_MARKER =
94+
MarkerManager.getMarker("FUNCTION_EXCEPTION_MARKER");
9195

9296
@Immutable
9397
private static final byte[] OK_BYTES = new byte[] {0};

geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/ExecuteFunction70.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -433,13 +433,8 @@ private void executeFunctionLocally(final Function fn, final FunctionContext cx,
433433
}
434434
} catch (FunctionException e) {
435435
stats.endFunctionExecutionWithException(startExecution, fn.hasResult());
436-
if (AbstractExecution.SUPPRESS_FUNCTION_EXCEPTION_LOGGING) {
437-
if (logger.isDebugEnabled()) {
438-
logger.debug("Exception on server while executing function: {}", fn, e);
439-
}
440-
} else {
441-
logger.warn("Exception on server while executing function: {}", fn, e);
442-
}
436+
logger.warn(FUNCTION_EXCEPTION_MARKER, "Exception on server while executing function: {}",
437+
fn, e);
443438
} catch (Exception e) {
444439
stats.endFunctionExecutionWithException(startExecution, fn.hasResult());
445440
logger.warn("Exception on server while executing function: {}", fn, e);

geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/ExecuteRegionFunction66.java

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -220,17 +220,10 @@ public void cmdExecute(final @NotNull Message clientMessage,
220220
resultSender.setException(fe);
221221
} else {
222222
if (setLastResultReceived(resultSender)) {
223-
if (AbstractExecution.SUPPRESS_FUNCTION_EXCEPTION_LOGGING) {
224-
if (logger.isDebugEnabled()) {
225-
logger.debug(String.format("Exception on server while executing function : %s",
223+
logger.warn(FUNCTION_EXCEPTION_MARKER,
224+
String.format("Exception on server while executing function : %s",
226225
function),
227-
fe);
228-
}
229-
} else {
230-
logger.warn(String.format("Exception on server while executing function : %s",
231-
function),
232-
fe);
233-
}
226+
fe);
234227
sendException(hasResult, clientMessage, message, serverConnection, fe);
235228
}
236229
}

geode-gfsh/src/main/java/org/apache/geode/management/internal/cli/functions/UserFunctionExecution.java

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
import java.util.stream.Collectors;
2929

3030
import org.apache.logging.log4j.Logger;
31+
import org.apache.logging.log4j.Marker;
32+
import org.apache.logging.log4j.MarkerManager;
3133
import org.apache.shiro.subject.Subject;
3234

3335
import org.apache.geode.cache.Cache;
@@ -41,7 +43,6 @@
4143
import org.apache.geode.cache.query.RegionNotFoundException;
4244
import org.apache.geode.distributed.DistributedMember;
4345
import org.apache.geode.internal.cache.InternalCache;
44-
import org.apache.geode.internal.cache.execute.AbstractExecution;
4546
import org.apache.geode.internal.cache.execute.InternalFunction;
4647
import org.apache.geode.internal.classloader.ClassPathLoader;
4748
import org.apache.geode.internal.security.SecurityService;
@@ -57,6 +58,9 @@
5758
public class UserFunctionExecution implements InternalFunction<Object[]> {
5859
private static final long serialVersionUID = 1L;
5960
private static final Logger logger = LogService.getLogger();
61+
private static final Marker FUNCTION_EXCEPTION_MARKER =
62+
MarkerManager.getMarker("FUNCTION_EXCEPTION_MARKER");
63+
6064
protected static final String ID =
6165
"org.apache.geode.management.internal.cli.functions.UserFunctionExecution";
6266

@@ -247,14 +251,7 @@ public void execute(FunctionContext<Object[]> context) {
247251
CliStrings.EXECUTE_FUNCTION__MSG__RESULT_COLLECTOR_0_NOT_FOUND_ERROR_1,
248252
resultCollectorName, e.getMessage())));
249253
} catch (FunctionException e) {
250-
if (AbstractExecution.SUPPRESS_FUNCTION_EXCEPTION_LOGGING) {
251-
if (logger.isDebugEnabled()) {
252-
logger.debug("error executing function " + functionId, e);
253-
}
254-
} else {
255-
logger.error("error executing function " + functionId, e);
256-
}
257-
254+
logger.error(FUNCTION_EXCEPTION_MARKER, "error executing function " + functionId, e);
258255
context.getResultSender().lastResult(
259256
new CliFunctionResult(context.getMemberName(), ERROR, "Exception: " + e.getMessage()));
260257
} catch (Exception e) {

0 commit comments

Comments
 (0)