Skip to content

Commit

Permalink
ImlCopy.post - add retry
Browse files Browse the repository at this point in the history
Signed-off-by: qGYdXbY2 <[email protected]>
  • Loading branch information
qGYdXbY2 committed Dec 19, 2024
1 parent a5245d0 commit c8ad236
Showing 1 changed file with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,28 @@ public ExecutionMode getExecutionMode() {
return SYNC;
}

private void sleepWithIncr(int i) { try { Thread.sleep( i * 15000 ); } catch (InterruptedException ignored) {} }

private void writeContentUpdatedAtTs() throws WebClientException
{
int nrRetries = 3;

for( int i = 0; i < nrRetries; i++)
try
{ hubWebClient().patchSpace(getSpaceId(), Map.of("contentUpdatedAt", Core.currentTimeMillis()));
return;
}
catch( WebClientException e )
{ logger.error("[{}] writeContentUpdatedAtTs() -> retry({}) {}", getGlobalStepId(), i+1, getSpaceId());
sleepWithIncr(i + 1);
}

//TODO: handle ts not updated after retries -> should throw a "retryable Exception", when available. Ignore for now.
logger.error("[{}] could not write contentUpadtedAt to space {}", getGlobalStepId(), getSpaceId());

}



@Override
public void execute() throws Exception {
Expand All @@ -193,7 +215,7 @@ public void execute() throws Exception {
setCopiedByteSize( statistics.getByteSize() );

if( statistics.getFeatureCount() > 0 )
hubWebClient().patchSpace(getSpaceId(), Map.of("contentUpdatedAt", Core.currentTimeMillis()));
writeContentUpdatedAtTs();

}

Expand Down

0 comments on commit c8ad236

Please sign in to comment.