Skip to content

Commit ec173cb

Browse files
committed
GEODE-10231 : Add configuration for suppressing FunctionException logging
System property for suppressing FunctionException logging: gemfire.logging.suppressFunctionExceptionLogging=true
1 parent 1602044 commit ec173cb

File tree

9 files changed

+94
-14
lines changed

9 files changed

+94
-14
lines changed

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

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@
5656
public abstract class AbstractExecution implements InternalExecution {
5757
private static final Logger logger = LogService.getLogger();
5858

59+
/** Whether to suppress logging of FunctionException */
60+
public static final boolean SUPPRESS_FUNCTION_EXCEPTION_LOGGING =
61+
Boolean.getBoolean(GeodeGlossary.GEMFIRE_PREFIX + "logging.suppressFunctionExceptionLogging");
62+
5963
public static final int DEFAULT_CLIENT_FUNCTION_TIMEOUT = 0;
6064
private static final String CLIENT_FUNCTION_TIMEOUT_SYSTEM_PROPERTY =
6165
GeodeGlossary.GEMFIRE_PREFIX + "CLIENT_FUNCTION_TIMEOUT";
@@ -504,8 +508,16 @@ private void handleException(Throwable functionException, final Function fn,
504508
((InternalResultSender) sender).setException(functionException);
505509
}
506510
} else {
507-
logger.warn("Exception occurred on local node while executing Function:",
508-
functionException);
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+
}
509521
}
510522
}
511523

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,18 @@ public void setException(Throwable exception) {
224224
} else {
225225
((LocalResultCollector) rc).setException(exception);
226226
// this.lastResult(exception);
227-
logger.info("Unexpected exception during function execution on local node Distributed Region",
228-
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+
}
229239
}
230240
rc.endResults();
231241
localLastResultReceived = true;

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,17 @@ public void sendException(Throwable exception) {
232232
public void setException(Throwable exception) {
233233
((LocalResultCollector) rc).setException(exception);
234234
// this.lastResult(exception);
235-
logger.info("Unexpected exception during function execution local member",
236-
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+
237246
rc.endResults();
238247
localLastResultReceived = true;
239248
}

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -390,8 +390,18 @@ public void setException(Throwable exception) {
390390
serverSender.setException(exception);
391391
} else {
392392
((LocalResultCollector) rc).setException(exception);
393-
logger.info("Unexpected exception during function execution on local node Partitioned Region",
394-
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+
}
395405
}
396406
rc.endResults();
397407
localLastResultReceived = true;

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -321,9 +321,17 @@ public synchronized void setException(Throwable exception) {
321321
}
322322
String exceptionMessage = exception.getMessage() != null ? exception.getMessage()
323323
: "Exception occurred during function execution";
324-
logger.warn(String.format("Exception on server while executing function : %s",
325-
fn),
326-
exception);
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+
}
334+
327335
if (logger.isDebugEnabled()) {
328336
logger.debug("ServerToClientFunctionResultSender sending Function Exception : ");
329337
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ 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.|
134135
| 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.|
135136
| gemfire.MAX_PENDING_CANCELS | Integer | `10000` | See `org.apache.geode.internal.cache.ExpirationScheduler#MAX_PENDING_CANCELS`.|
136137
| 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/command/ExecuteFunction70.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,15 @@ private void executeFunctionLocally(final Function fn, final FunctionContext cx,
431431
if (logger.isDebugEnabled()) {
432432
logger.debug("Exception on server while executing function: {}", fn, e);
433433
}
434+
} catch (FunctionException e) {
435+
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+
}
434443
} catch (Exception e) {
435444
stats.endFunctionExecutionWithException(startExecution, fn.hasResult());
436445
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: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,9 +220,17 @@ public void cmdExecute(final @NotNull Message clientMessage,
220220
resultSender.setException(fe);
221221
} else {
222222
if (setLastResultReceived(resultSender)) {
223-
logger.warn(String.format("Exception on server while executing function : %s",
224-
function),
225-
fe);
223+
if (AbstractExecution.SUPPRESS_FUNCTION_EXCEPTION_LOGGING) {
224+
if (logger.isDebugEnabled()) {
225+
logger.debug(String.format("Exception on server while executing function : %s",
226+
function),
227+
fe);
228+
}
229+
} else {
230+
logger.warn(String.format("Exception on server while executing function : %s",
231+
function),
232+
fe);
233+
}
226234
sendException(hasResult, clientMessage, message, serverConnection, fe);
227235
}
228236
}

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,13 @@
3535
import org.apache.geode.cache.execute.Execution;
3636
import org.apache.geode.cache.execute.Function;
3737
import org.apache.geode.cache.execute.FunctionContext;
38+
import org.apache.geode.cache.execute.FunctionException;
3839
import org.apache.geode.cache.execute.FunctionService;
3940
import org.apache.geode.cache.execute.ResultCollector;
4041
import org.apache.geode.cache.query.RegionNotFoundException;
4142
import org.apache.geode.distributed.DistributedMember;
4243
import org.apache.geode.internal.cache.InternalCache;
44+
import org.apache.geode.internal.cache.execute.AbstractExecution;
4345
import org.apache.geode.internal.cache.execute.InternalFunction;
4446
import org.apache.geode.internal.classloader.ClassPathLoader;
4547
import org.apache.geode.internal.security.SecurityService;
@@ -244,6 +246,17 @@ public void execute(FunctionContext<Object[]> context) {
244246
CliStrings.format(
245247
CliStrings.EXECUTE_FUNCTION__MSG__RESULT_COLLECTOR_0_NOT_FOUND_ERROR_1,
246248
resultCollectorName, e.getMessage())));
249+
} 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+
258+
context.getResultSender().lastResult(
259+
new CliFunctionResult(context.getMemberName(), ERROR, "Exception: " + e.getMessage()));
247260
} catch (Exception e) {
248261
logger.error("error executing function " + functionId, e);
249262
context.getResultSender().lastResult(

0 commit comments

Comments
 (0)