Skip to content

Commit

Permalink
GEODE-10231 : Add configuration for suppressing FunctionException log…
Browse files Browse the repository at this point in the history
…ging

- pmd fix
- logger format fix
  • Loading branch information
zsitole committed Apr 15, 2022
1 parent b457f15 commit 0b5d004
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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 : ");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -58,7 +59,8 @@
public class UserFunctionExecution implements InternalFunction<Object[]> {
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 =
Expand Down Expand Up @@ -251,7 +253,7 @@ public void execute(FunctionContext<Object[]> 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) {
Expand Down

0 comments on commit 0b5d004

Please sign in to comment.