Skip to content

Commit

Permalink
Avoid log pollution due to PASSIVE state before start
Browse files Browse the repository at this point in the history
  • Loading branch information
vbekiaris committed Aug 8, 2022
1 parent 5231208 commit 426c074
Showing 1 changed file with 13 additions and 0 deletions.
Expand Up @@ -17,6 +17,7 @@
package com.hazelcast.spi.impl.operationservice;

import com.hazelcast.cluster.Address;
import com.hazelcast.cluster.ClusterState;
import com.hazelcast.internal.cluster.ClusterClock;
import com.hazelcast.internal.partition.InternalPartition;
import com.hazelcast.internal.server.ServerConnection;
Expand Down Expand Up @@ -637,6 +638,7 @@ public void onExecutionFailure(Throwable e) {
*
* @param e Exception/Error thrown during operation execution
*/
@SuppressWarnings("checkstyle:cyclomaticcomplexity")
public void logError(Throwable e) {
final ILogger logger = getLogger();
if (e instanceof SilentException) {
Expand All @@ -652,6 +654,17 @@ public void logError(Throwable e) {
} catch (Throwable ignored) {
ignore(ignored);
}
} else if (e instanceof IllegalStateException) {
// if start is not yet completed, do not warn about IllegalStateExceptions
// due to cluster state being PASSIVE
final Level level = nodeEngine != null
&& nodeEngine.getClusterService().getClusterState() == ClusterState.PASSIVE
&& nodeEngine.isStartCompleted()
&& nodeEngine.isRunning()
? Level.WARNING : Level.FINE;
if (logger.isLoggable(level)) {
logger.log(level, e.getMessage(), e);
}
} else {
final Level level = nodeEngine != null && nodeEngine.isRunning() ? Level.SEVERE : Level.FINEST;
if (logger.isLoggable(level)) {
Expand Down

0 comments on commit 426c074

Please sign in to comment.