Skip to content

Commit

Permalink
Treat closed channel as benign failure in backup stress tests
Browse files Browse the repository at this point in the history
  • Loading branch information
martinfurmanski committed Sep 28, 2018
1 parent fc8b325 commit 0223a93
Showing 1 changed file with 11 additions and 3 deletions.
Expand Up @@ -24,7 +24,9 @@


import java.io.File; import java.io.File;
import java.net.ConnectException; import java.net.ConnectException;
import java.nio.channels.ClosedChannelException;
import java.util.Optional; import java.util.Optional;
import java.util.Set;
import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicLong;


import org.neo4j.backup.impl.OnlineBackupCommandBuilder; import org.neo4j.backup.impl.OnlineBackupCommandBuilder;
Expand All @@ -36,10 +38,16 @@
import static org.neo4j.backup.impl.SelectedBackupProtocol.CATCHUP; import static org.neo4j.backup.impl.SelectedBackupProtocol.CATCHUP;
import static org.neo4j.causalclustering.core.CausalClusteringSettings.transaction_advertised_address; import static org.neo4j.causalclustering.core.CausalClusteringSettings.transaction_advertised_address;
import static org.neo4j.helpers.Exceptions.findCauseOrSuppressed; import static org.neo4j.helpers.Exceptions.findCauseOrSuppressed;
import static org.neo4j.helpers.collection.Iterators.asSet;
import static org.neo4j.io.NullOutputStream.NULL_OUTPUT_STREAM; import static org.neo4j.io.NullOutputStream.NULL_OUTPUT_STREAM;


class BackupHelper class BackupHelper
{ {
private static final Set<Class<? extends Throwable>> BENIGN_EXCEPTIONS = asSet(
ConnectException.class,
ClosedChannelException.class
);

AtomicLong backupNumber = new AtomicLong(); AtomicLong backupNumber = new AtomicLong();
AtomicLong successfulBackups = new AtomicLong(); AtomicLong successfulBackups = new AtomicLong();


Expand Down Expand Up @@ -82,10 +90,10 @@ Optional<File> backup( ClusterMember member ) throws Exception
} }
catch ( CommandFailed e ) catch ( CommandFailed e )
{ {
Optional<Throwable> connectException = findCauseOrSuppressed( e, t -> t instanceof ConnectException ); Optional<Throwable> benignException = findCauseOrSuppressed( e, t -> BENIGN_EXCEPTIONS.contains( t.getClass() ) );
if ( connectException.isPresent() ) if ( benignException.isPresent() )
{ {
log.info( "Benign failure: " + connectException.get().getMessage() ); log.info( "Benign failure: " + benignException.get().getMessage() );
} }
else else
{ {
Expand Down

0 comments on commit 0223a93

Please sign in to comment.