Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

MDEPLOY-214: Added property "retryFailedDeploymentDelay". #18

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public class ProjectDeployerRequest

private int retryFailedDeploymentCount;

private int retryFailedDeploymentDelay;

// From DeployMojo

private MavenProject project;
Expand Down Expand Up @@ -78,6 +80,23 @@ public ProjectDeployerRequest setRetryFailedDeploymentCount( int retryFailedDepl
return this;
}

/**
* @return the retryFailedDeploymentCount
*/
public int getRetryFailedDeploymentDelay()
{
return retryFailedDeploymentDelay;
}

/**
* @param retryFailedDeploymentDelay the retryFailedDeploymentDelay to set
*/
public ProjectDeployerRequest setRetryFailedDeploymentDelay( int retryFailedDeploymentDelay )
{
this.retryFailedDeploymentDelay = retryFailedDeploymentDelay;
return this;
}

/**
* @return the project
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public class DefaultProjectDeployer
implements ProjectDeployer
{
private static final Logger LOGGER = LoggerFactory.getLogger( DefaultProjectDeployer.class );
private static final int MAX_RETRY_DELAY = 300; // seconds

@Requirement
private ArtifactDeployer deployer;
Expand Down Expand Up @@ -95,6 +96,7 @@ public void deploy( ProjectBuildingRequest buildingRequest, ProjectDeployerReque
artifact.setRepository( artifactRepository );

int retryFailedDeploymentCount = request.getRetryFailedDeploymentCount();
int retryFailedDeploymentDelay = request.getRetryFailedDeploymentDelay();

try
{
Expand Down Expand Up @@ -141,7 +143,8 @@ else if ( !attachedArtifacts.isEmpty() )
deployableArtifacts.add( attached );
}

deploy( buildingRequest, deployableArtifacts, artifactRepository, retryFailedDeploymentCount );
deploy( buildingRequest, deployableArtifacts, artifactRepository, retryFailedDeploymentCount,
retryFailedDeploymentDelay );
}
catch ( ArtifactDeployerException e )
{
Expand All @@ -150,12 +153,14 @@ else if ( !attachedArtifacts.isEmpty() )
}

private void deploy( ProjectBuildingRequest request, Collection<Artifact> artifacts,
ArtifactRepository deploymentRepository, int retryFailedDeploymentCount )
ArtifactRepository deploymentRepository, int retryFailedDeploymentCount,
int retryFailedDeploymentDelay )
throws ArtifactDeployerException
{

// for now retry means redeploy the complete artifacts collection
int retryFailedDeploymentCounter = Math.max( 1, Math.min( 10, retryFailedDeploymentCount ) );
int retryDelay = Math.max( 1, Math.min( MAX_RETRY_DELAY, retryFailedDeploymentDelay ) );
ArtifactDeployerException exception = null;
for ( int count = 0; count < retryFailedDeploymentCounter; count++ )
{
Expand All @@ -177,6 +182,15 @@ private void deploy( ProjectBuildingRequest request, Collection<Artifact> artifa
{
LOGGER.warn( "Encountered issue during deployment: " + e.getLocalizedMessage() );
LOGGER.debug( e.getMessage() );
try
{
LOGGER.warn( "retrying in " + retryDelay + " seconds." );
Thread.sleep( retryDelay * 1000L );
}
catch ( InterruptedException e1 )
{
// ignored
}
}
if ( exception == null )
{
Expand Down