Skip to content

Commit

Permalink
use the retry strategy in read replica startup
Browse files Browse the repository at this point in the history
  • Loading branch information
martinfurmanski committed Jan 11, 2017
1 parent a12a17d commit 10b880e
Showing 1 changed file with 6 additions and 5 deletions.
Expand Up @@ -51,8 +51,8 @@ class ReadReplicaStartupProcess implements Lifecycle
private final CoreMemberSelectionStrategy connectionStrategy;
private final Log debugLog;
private final Log userLog;
private final RetryStrategy.Timeout timeout;

private final RetryStrategy retryStrategy;
private final CopiedStoreRecovery copiedStoreRecovery;
private String lastIssue;

Expand All @@ -65,8 +65,8 @@ class ReadReplicaStartupProcess implements Lifecycle
this.localDatabase = localDatabase;
this.txPulling = txPulling;
this.connectionStrategy = connectionStrategy;
this.retryStrategy = retryStrategy;
this.copiedStoreRecovery = copiedStoreRecovery;
this.timeout = retryStrategy.newTimeout();
this.debugLog = debugLogProvider.getLog( getClass() );
this.userLog = userLogProvider.getLog( getClass() );
}
Expand All @@ -86,8 +86,8 @@ private String issueOf( String operation, int attempt )
@Override
public void start() throws IOException
{
long retryInterval = 5_000;
boolean syncedWithCore = false;
RetryStrategy.Timeout timeout = retryStrategy.newTimeout();
for ( int attempt = 1; attempt <= MAX_ATTEMPTS && !syncedWithCore; attempt++ )
{
MemberId source = findCoreMemberToCopyFrom();
Expand All @@ -114,8 +114,8 @@ public void start() throws IOException

try
{
Thread.sleep( retryInterval );
retryInterval = Math.min( 60_000, retryInterval * 2 );
Thread.sleep( timeout.getMillis() );
timeout.increment();
}
catch ( InterruptedException e )
{
Expand Down Expand Up @@ -182,6 +182,7 @@ private void ensureSameStoreIdAs( MemberId remoteCore ) throws StoreIdDownloadFa

private MemberId findCoreMemberToCopyFrom()
{
RetryStrategy.Timeout timeout = retryStrategy.newTimeout();
while ( true )
{
try
Expand Down

0 comments on commit 10b880e

Please sign in to comment.