Skip to content

Commit

Permalink
Ignore ComException in stress test
Browse files Browse the repository at this point in the history
  • Loading branch information
davidegrohmann committed Oct 5, 2016
1 parent ee585d5 commit f17d49f
Showing 1 changed file with 14 additions and 2 deletions.
Expand Up @@ -26,6 +26,7 @@
import java.util.function.BooleanSupplier;

import org.neo4j.backup.OnlineBackup;
import org.neo4j.com.ComException;
import org.neo4j.coreedge.discovery.Cluster;
import org.neo4j.helpers.SocketAddress;

Expand All @@ -35,7 +36,7 @@ class BackupLoad extends RepeatUntilOnSelectedMemberCallable
private final BiFunction<Boolean,Integer,SocketAddress> backupAddress;

BackupLoad( BooleanSupplier keepGoing, Runnable onFailure, Cluster cluster, File baseDirectory,
BiFunction<Boolean, Integer, SocketAddress> backupAddress )
BiFunction<Boolean,Integer,SocketAddress> backupAddress )
{
super( keepGoing, onFailure, cluster, cluster.edgeMembers().isEmpty() );
this.baseDirectory = baseDirectory;
Expand All @@ -55,7 +56,7 @@ protected void doWorkOnMember( boolean isCore, int id )
}
catch ( RuntimeException e )
{
if ( e.getCause() instanceof ConnectException )
if ( isConnectionError( e ) )
{
// if we could not connect, wait a bit and try again...
LockSupport.parkNanos( 10_000_000 );
Expand All @@ -69,4 +70,15 @@ protected void doWorkOnMember( boolean isCore, int id )
throw new RuntimeException( "Not consistent backup from " + address );
}
}

private boolean isConnectionError( RuntimeException e )
{
return e.getCause() instanceof ConnectException || isChannelClosedException( e ) ||
isChannelClosedException( e.getCause() );
}

private boolean isChannelClosedException( Throwable e )
{
return e instanceof ComException && "Channel has been closed".equals( e.getMessage() );
}
}

0 comments on commit f17d49f

Please sign in to comment.