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:
Joakim Erdfelt 2007-04-13 19:04:08 +00:00
parent 710b963f2a
commit f1baf328fb
1 changed files with 65 additions and 53 deletions

View File

@ -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.
@ -80,8 +84,8 @@ public class ArchivaScheduledTaskExecutor extends AbstractLogEnabled implements
*/ */
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 )
@ -99,12 +103,12 @@ public class ArchivaScheduledTaskExecutor extends AbstractLogEnabled implements
} }
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();
@ -129,7 +133,8 @@ public class ArchivaScheduledTaskExecutor extends AbstractLogEnabled implements
} }
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() );
@ -153,50 +158,57 @@ 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();
List configuredGoodConsumers = archivaConfiguration.getConfiguration().getRepositoryScanning().getGoodConsumers(); RepositoryScanningConfiguration repoScanningConfig = archivaConfiguration.getConfiguration()
List configuredBadConsumers = archivaConfiguration.getConfiguration().getRepositoryScanning().getBadConsumers(); .getRepositoryScanning();
List configuredGoodConsumers = repoScanningConfig.getGoodConsumers();
List configuredBadConsumers = repoScanningConfig.getBadConsumers();
getLogger().info( "Available Repository Consumers: " + availableRepositoryConsumers );
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
.get( desiredConsumerId );
if ( availableRepositoryConsumers.containsKey( availableRepositoryConsumers.get( consumer ) ) ) 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
.get( desiredConsumerId );
if ( availableRepositoryConsumers.containsKey( availableRepositoryConsumers.get( consumer ) ) ) 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;
} }
} }