mirror of https://github.com/apache/archiva.git
Desired vs Actual
git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/branches/archiva-jpox-database-refactor@528593 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
710b963f2a
commit
f1baf328fb
|
@ -21,6 +21,8 @@ package org.apache.maven.archiva.scheduled.executors;
|
||||||
|
|
||||||
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
|
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
|
||||||
import org.apache.maven.archiva.configuration.Configuration;
|
import org.apache.maven.archiva.configuration.Configuration;
|
||||||
|
import org.apache.maven.archiva.configuration.RepositoryScanningConfiguration;
|
||||||
|
import org.apache.maven.archiva.consumers.RepositoryContentConsumer;
|
||||||
import org.apache.maven.archiva.database.ArchivaDatabaseException;
|
import org.apache.maven.archiva.database.ArchivaDatabaseException;
|
||||||
import org.apache.maven.archiva.database.RepositoryDAO;
|
import org.apache.maven.archiva.database.RepositoryDAO;
|
||||||
import org.apache.maven.archiva.database.updater.DatabaseUpdater;
|
import org.apache.maven.archiva.database.updater.DatabaseUpdater;
|
||||||
|
@ -49,7 +51,9 @@ import java.util.Map;
|
||||||
* @plexus.component role="org.codehaus.plexus.taskqueue.execution.TaskExecutor"
|
* @plexus.component role="org.codehaus.plexus.taskqueue.execution.TaskExecutor"
|
||||||
* role-hint="archiva-task-executor"
|
* role-hint="archiva-task-executor"
|
||||||
*/
|
*/
|
||||||
public class ArchivaScheduledTaskExecutor extends AbstractLogEnabled implements TaskExecutor
|
public class ArchivaScheduledTaskExecutor
|
||||||
|
extends AbstractLogEnabled
|
||||||
|
implements TaskExecutor
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Configuration store.
|
* Configuration store.
|
||||||
|
@ -62,30 +66,30 @@ public class ArchivaScheduledTaskExecutor extends AbstractLogEnabled implements
|
||||||
* @plexus.requirement role-hint="jdo"
|
* @plexus.requirement role-hint="jdo"
|
||||||
*/
|
*/
|
||||||
private DatabaseUpdater databaseUpdater;
|
private DatabaseUpdater databaseUpdater;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @plexus.requirement role-hint="jdo"
|
* @plexus.requirement role-hint="jdo"
|
||||||
*/
|
*/
|
||||||
private RepositoryDAO repositoryDAO;
|
private RepositoryDAO repositoryDAO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The collection of available database consumers.
|
* The collection of available database consumers.
|
||||||
* @plexus.requirement role="org.apache.maven.archiva.consumers.ArchivaArtifactConsumer"
|
* @plexus.requirement role="org.apache.maven.archiva.consumers.ArchivaArtifactConsumer"
|
||||||
*/
|
*/
|
||||||
private Map availableDBConsumers;
|
private Map availableDBConsumers;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The collection of available repository consumers.
|
* The collection of available repository consumers.
|
||||||
* @plexus.requirement role="org.apache.maven.archiva.consumers.RepositoryContentConsumer"
|
* @plexus.requirement role="org.apache.maven.archiva.consumers.RepositoryContentConsumer"
|
||||||
*/
|
*/
|
||||||
private Map availableRepositoryConsumers;
|
private Map availableRepositoryConsumers;
|
||||||
|
|
||||||
|
public void executeTask( Task task )
|
||||||
public void executeTask( Task task ) throws TaskExecutionException
|
throws TaskExecutionException
|
||||||
{
|
{
|
||||||
|
|
||||||
if ( task instanceof DatabaseTask )
|
if ( task instanceof DatabaseTask )
|
||||||
{
|
{
|
||||||
executeDatabaseTask( (DatabaseTask) task );
|
executeDatabaseTask( (DatabaseTask) task );
|
||||||
}
|
}
|
||||||
else if ( task instanceof RepositoryTask )
|
else if ( task instanceof RepositoryTask )
|
||||||
|
@ -96,15 +100,15 @@ public class ArchivaScheduledTaskExecutor extends AbstractLogEnabled implements
|
||||||
{
|
{
|
||||||
throw new TaskExecutionException( "Unknown Task: " + task.toString() );
|
throw new TaskExecutionException( "Unknown Task: " + task.toString() );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void executeDatabaseTask( DatabaseTask task ) throws TaskExecutionException
|
private void executeDatabaseTask( DatabaseTask task )
|
||||||
|
throws TaskExecutionException
|
||||||
{
|
{
|
||||||
getLogger().info( "Executing task from queue with job name: " + task.getName() );
|
getLogger().info( "Executing task from queue with job name: " + task.getName() );
|
||||||
long time = System.currentTimeMillis();
|
long time = System.currentTimeMillis();
|
||||||
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
databaseUpdater.updateAllUnprocessed();
|
databaseUpdater.updateAllUnprocessed();
|
||||||
|
@ -113,36 +117,37 @@ public class ArchivaScheduledTaskExecutor extends AbstractLogEnabled implements
|
||||||
{
|
{
|
||||||
throw new TaskExecutionException( "Error running unprocessed updater", e );
|
throw new TaskExecutionException( "Error running unprocessed updater", e );
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
databaseUpdater.updateAllProcessed();
|
databaseUpdater.updateAllProcessed();
|
||||||
}
|
}
|
||||||
catch ( ArchivaDatabaseException e )
|
catch ( ArchivaDatabaseException e )
|
||||||
{
|
{
|
||||||
throw new TaskExecutionException( "Error running processed updater", e );
|
throw new TaskExecutionException( "Error running processed updater", e );
|
||||||
}
|
}
|
||||||
|
|
||||||
time = System.currentTimeMillis() - time;
|
time = System.currentTimeMillis() - time;
|
||||||
|
|
||||||
getLogger().info( "Finished database task in " + time + "ms." );
|
getLogger().info( "Finished database task in " + time + "ms." );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void executeRepositoryTask ( RepositoryTask task ) throws TaskExecutionException
|
private void executeRepositoryTask( RepositoryTask task )
|
||||||
|
throws TaskExecutionException
|
||||||
{
|
{
|
||||||
getLogger().info( "Executing task from queue with job name: " + task.getName() );
|
getLogger().info( "Executing task from queue with job name: " + task.getName() );
|
||||||
|
|
||||||
long time = System.currentTimeMillis();
|
long time = System.currentTimeMillis();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ArchivaRepository arepo = repositoryDAO.getRepository( task.getRepositoryId() );
|
ArchivaRepository arepo = repositoryDAO.getRepository( task.getRepositoryId() );
|
||||||
|
|
||||||
RepositoryScanner scanner = new RepositoryScanner();
|
RepositoryScanner scanner = new RepositoryScanner();
|
||||||
|
|
||||||
scanner.scan( arepo, getActiveConsumerList(), true );
|
scanner.scan( arepo, getActiveConsumerList(), true );
|
||||||
|
|
||||||
}
|
}
|
||||||
catch ( ArchivaDatabaseException e )
|
catch ( ArchivaDatabaseException e )
|
||||||
{
|
{
|
||||||
|
@ -152,51 +157,58 @@ public class ArchivaScheduledTaskExecutor extends AbstractLogEnabled implements
|
||||||
{
|
{
|
||||||
throw new TaskExecutionException( "Repository error when executing repository job.", e );
|
throw new TaskExecutionException( "Repository error when executing repository job.", e );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
time = System.currentTimeMillis() - time;
|
time = System.currentTimeMillis() - time;
|
||||||
|
|
||||||
getLogger().info( "Finished repository task for " + time + "ms." );
|
getLogger().info( "Finished repository task for " + time + "ms." );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private List getActiveConsumerList()
|
private List getActiveConsumerList()
|
||||||
{
|
{
|
||||||
List activeConsumers = new ArrayList();
|
List activeConsumers = new ArrayList();
|
||||||
|
|
||||||
|
RepositoryScanningConfiguration repoScanningConfig = archivaConfiguration.getConfiguration()
|
||||||
|
.getRepositoryScanning();
|
||||||
|
|
||||||
|
List configuredGoodConsumers = repoScanningConfig.getGoodConsumers();
|
||||||
|
List configuredBadConsumers = repoScanningConfig.getBadConsumers();
|
||||||
|
|
||||||
List configuredGoodConsumers = archivaConfiguration.getConfiguration().getRepositoryScanning().getGoodConsumers();
|
getLogger().info( "Available Repository Consumers: " + availableRepositoryConsumers );
|
||||||
List configuredBadConsumers = archivaConfiguration.getConfiguration().getRepositoryScanning().getBadConsumers();
|
|
||||||
|
|
||||||
for ( Iterator i = configuredGoodConsumers.iterator(); i.hasNext(); )
|
for ( Iterator i = configuredGoodConsumers.iterator(); i.hasNext(); )
|
||||||
{
|
{
|
||||||
String consumer = (String)i.next();
|
String desiredConsumerId = (String) i.next();
|
||||||
|
RepositoryContentConsumer consumer = (RepositoryContentConsumer) availableRepositoryConsumers
|
||||||
if ( availableRepositoryConsumers.containsKey( availableRepositoryConsumers.get( consumer ) ) )
|
.get( desiredConsumerId );
|
||||||
|
|
||||||
|
if ( consumer == null )
|
||||||
{
|
{
|
||||||
activeConsumers.add( availableRepositoryConsumers.get( consumer ) );
|
getLogger().warn(
|
||||||
}
|
"Desired Consumer [" + desiredConsumerId
|
||||||
else
|
+ "] does not exist. Skipping in repository scan." );
|
||||||
{
|
continue;
|
||||||
getLogger().warn( "RequestedConsumer [" + consumer + "] does not exist. Skipping in repository scan." );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
activeConsumers.add( consumer );
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( Iterator i = configuredBadConsumers.iterator(); i.hasNext(); )
|
for ( Iterator i = configuredBadConsumers.iterator(); i.hasNext(); )
|
||||||
{
|
{
|
||||||
String consumer = (String)i.next();
|
String desiredConsumerId = (String) i.next();
|
||||||
|
RepositoryContentConsumer consumer = (RepositoryContentConsumer) availableRepositoryConsumers
|
||||||
if ( availableRepositoryConsumers.containsKey( availableRepositoryConsumers.get( consumer ) ) )
|
.get( desiredConsumerId );
|
||||||
|
|
||||||
|
if ( consumer == null )
|
||||||
{
|
{
|
||||||
getLogger().warn( "Using consumer " + consumer );
|
getLogger().warn(
|
||||||
activeConsumers.add( availableRepositoryConsumers.get( consumer ) );
|
"Desired Consumer [" + desiredConsumerId
|
||||||
}
|
+ "] does not exist. Skipping in repository scan." );
|
||||||
else
|
continue;
|
||||||
{
|
|
||||||
getLogger().warn( "RequestedConsumer [" + consumer + "] does not exist. Skipping in repository scan." );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
activeConsumers.add( consumer );
|
||||||
}
|
}
|
||||||
|
|
||||||
return activeConsumers;
|
return activeConsumers;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue