Skip to content
This repository has been archived by the owner on Aug 11, 2020. It is now read-only.

Commit

Permalink
NEXUS-5602: WL init add significant startup time.
Browse files Browse the repository at this point in the history
This change now splits "WL init at boot" from "WL init
at repo addition on runtime" cases. Before, both were
doing same, but due to "cascade", one Nexus with lot of
repo and/or groups booted slower than before.

Now the "cascade" is not done in case of "boot" but on
"repo add at runtime" case is still done (and is needed).
On boot, extra step is done to explicitly init group reposes
WL, instead relying on having them updated implicitly due to
cascade.

This also meant, while former solution was correct, it was
sloppy as same group was updated over and over again on boot
process.
  • Loading branch information
cstamas committed Mar 19, 2013
1 parent c9b8dd0 commit 9a81366
Showing 1 changed file with 30 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,12 @@ public void startup()
final ArrayList<MavenRepository> initableRepositories = new ArrayList<MavenRepository>();
initableRepositories.addAll( repositoryRegistry.getRepositoriesWithFacet( MavenHostedRepository.class ) );
initableRepositories.addAll( repositoryRegistry.getRepositoriesWithFacet( MavenProxyRepository.class ) );
initableRepositories.addAll( repositoryRegistry.getRepositoriesWithFacet( MavenGroupRepository.class ) );
for ( MavenRepository mavenRepository : initableRepositories )
{
if ( mavenRepository.getLocalStatus().shouldServiceRequest() )
{
initializeWhitelist( mavenRepository );
doInitializeWhitelist( mavenRepository, false );
}
}
}
Expand Down Expand Up @@ -225,10 +226,10 @@ public void shutdown()
@Override
public void initializeWhitelist( final MavenRepository mavenRepository )
{
doInitializeWhitelist( mavenRepository );
doInitializeWhitelist( mavenRepository, true );
}

protected void doInitializeWhitelist( final MavenRepository mavenRepository )
protected void doInitializeWhitelist( final MavenRepository mavenRepository, final boolean propagate )
{
getLogger().debug( "Initializing white-list of {}",
RepositoryStringUtils.getHumanizedNameString( mavenRepository ) );
Expand All @@ -239,15 +240,15 @@ protected void doInitializeWhitelist( final MavenRepository mavenRepository )
{
// good, we assume is up to date, which should be unless user tampered with it
// in that case, just delete it + update and should be fixed.
publish( mavenRepository, prefixSource );
publish( mavenRepository, prefixSource, propagate );
getLogger().info( "Existing white-list of {} initialized",
RepositoryStringUtils.getHumanizedNameString( mavenRepository ) );
}
else
{
// mark it for noscrape if not marked yet
// this is mainly important on 1st boot or newly added reposes
unpublish( mavenRepository );
unpublish( mavenRepository, propagate );
// spawn update, this will do whatever is needed (and handle cases like blocked, out of service etc),
// publish
updateWhitelist( mavenRepository );
Expand All @@ -261,7 +262,7 @@ protected void doInitializeWhitelist( final MavenRepository mavenRepository )
RepositoryStringUtils.getHumanizedNameString( mavenRepository ), e );
try
{
unpublish( mavenRepository );
unpublish( mavenRepository, propagate );
}
catch ( IOException ioe )
{
Expand Down Expand Up @@ -979,6 +980,13 @@ public boolean revokeWLEntry( final MavenHostedRepository mavenHostedRepository,
@Override
public void publish( final MavenRepository mavenRepository, final PrefixSource prefixSource )
throws IOException
{
publish( mavenRepository, prefixSource, true );
}

protected void publish( final MavenRepository mavenRepository, final PrefixSource prefixSource,
final boolean propagate )
throws IOException
{
// publish prefix file
final FilePrefixSource prefixesFile = getPrefixSourceFor( mavenRepository );
Expand All @@ -998,13 +1006,22 @@ public void publish( final MavenRepository mavenRepository, final PrefixSource p
// event
eventBus.post( new WLPublishedRepositoryEvent( mavenRepository, prefixesFile ) );

// propagate
propagateWLUpdateOf( mavenRepository );
if ( propagate )
{
// propagate
propagateWLUpdateOf( mavenRepository );
}
}

@Override
public void unpublish( final MavenRepository mavenRepository )
throws IOException
{
unpublish( mavenRepository, true );
}

protected void unpublish( final MavenRepository mavenRepository, final boolean propagate )
throws IOException
{
// delete (if any) published files, even those that user might manually put there
getPrefixSourceFor( mavenRepository ).delete();
Expand All @@ -1022,8 +1039,11 @@ public void unpublish( final MavenRepository mavenRepository )
// event
eventBus.post( new WLUnpublishedRepositoryEvent( mavenRepository ) );

// propagate
propagateWLUpdateOf( mavenRepository );
if ( propagate )
{
// propagate
propagateWLUpdateOf( mavenRepository );
}
}

protected void propagateWLUpdateOf( final MavenRepository mavenRepository )
Expand Down

0 comments on commit 9a81366

Please sign in to comment.