<defaultValue>0 0 * * * ?</defaultValue>
</field>
<field>
- <name>converterCronExpression</name>
+ <name>reporterCronExpression</name>
<version>1.0.0</version>
<type>String</type>
- <description>When to run the converter mechanism. Default is every 4 hours, on the half hour.</description>
- <defaultValue>0 30 0/4 * * ?</defaultValue>
+ <description>When to run the indexing mechanism. Default is every hour on the half hour.</description>
+ <defaultValue>0 30 * * * ?</defaultValue>
</field>
<field>
<name>globalBlackListPatterns</name>
private static final String INDEXER_JOB = "indexerTask";
+ private static final String REPORTER_JOB = "reporterTask";
+
/**
* @plexus.requirement role-hint="indexer"
*/
private RepositoryTask indexerTask;
+ /**
+ * @plexus.requirement role-hint="reporter"
+ */
+ private RepositoryTask reporterTask;
+
public void start()
throws StartingException
{
private void scheduleJobs( Configuration configuration )
throws ParseException, SchedulerException
{
+ // TODO! would be nice to queue jobs that are triggered so we could avoid two running at the same time (so have a queue for discovery based jobs so they didn't thrash the repo)
if ( configuration.getIndexPath() != null )
{
- JobDetail jobDetail = new JobDetail( INDEXER_JOB, DISCOVERER_GROUP, RepositoryTaskJob.class );
- JobDataMap dataMap = new JobDataMap();
- dataMap.put( AbstractJob.LOGGER, getLogger() );
- dataMap.put( RepositoryTaskJob.TASK_KEY, indexerTask );
- jobDetail.setJobDataMap( dataMap );
+ JobDetail jobDetail = createJobDetail( INDEXER_JOB, indexerTask );
getLogger().info( "Scheduling indexer: " + configuration.getIndexerCronExpression() );
CronTrigger trigger =
{
getLogger().info( "Not scheduling indexer - index path is not configured" );
}
+
+ JobDetail jobDetail = createJobDetail( REPORTER_JOB, reporterTask );
+
+ getLogger().info( "Scheduling reporter: " + configuration.getReporterCronExpression() );
+ CronTrigger trigger =
+ new CronTrigger( REPORTER_JOB + "Trigger", DISCOVERER_GROUP, configuration.getReporterCronExpression() );
+ scheduler.scheduleJob( jobDetail, trigger );
+ }
+
+ private JobDetail createJobDetail( String jobName, RepositoryTask task )
+ {
+ JobDetail jobDetail = new JobDetail( jobName, DISCOVERER_GROUP, RepositoryTaskJob.class );
+ JobDataMap dataMap = new JobDataMap();
+ dataMap.put( AbstractJob.LOGGER, getLogger() );
+ dataMap.put( RepositoryTaskJob.TASK_KEY, task );
+ jobDetail.setJobDataMap( dataMap );
+ return jobDetail;
}
public void stop()
try
{
scheduler.unscheduleJob( INDEXER_JOB, DISCOVERER_GROUP );
+ scheduler.unscheduleJob( REPORTER_JOB, DISCOVERER_GROUP );
}
catch ( SchedulerException e )
{
{
indexerTask.execute();
}
+
+ public void runReporter()
+ throws TaskExecutionException
+ {
+ reporterTask.execute();
+ }
}
void runIndexer()
throws TaskExecutionException;
+
+ void runReporter()
+ throws TaskExecutionException;
}
+++ /dev/null
-package org.apache.maven.archiva.scheduler.task;
-
-/*
- * Copyright 2005-2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
-
-import java.util.Collection;
-
-/**
- * Filter that removes artifacts already in the index.
- * TODO: we could do timestamp comparisons here
- */
-public class IndexRecordExistsArtifactFilter
- implements ArtifactFilter
-{
- private final Collection keys;
-
- public IndexRecordExistsArtifactFilter( Collection keys )
- {
- this.keys = keys;
- }
-
- public boolean include( Artifact artifact )
- {
- String artifactKey = artifact.getGroupId() + ":" + artifact.getArtifactId() + ":" + artifact.getVersion() +
- ( artifact.getClassifier() != null ? ":" + artifact.getClassifier() : "" );
- return !keys.contains( artifactKey );
- }
-}
import org.apache.maven.archiva.indexer.RepositoryArtifactIndex;
import org.apache.maven.archiva.indexer.RepositoryArtifactIndexFactory;
import org.apache.maven.archiva.indexer.RepositoryIndexException;
+import org.apache.maven.archiva.indexer.record.IndexRecordExistsArtifactFilter;
import org.apache.maven.archiva.indexer.record.RepositoryIndexRecordFactory;
import org.apache.maven.archiva.scheduler.TaskExecutionException;
import org.apache.maven.artifact.repository.ArtifactRepository;
import java.util.Map;
/**
- * Task for discovering changes in the repository.
+ * Task for discovering changes in the repository and updating the index accordingly.
*
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
* @plexus.component role="org.apache.maven.archiva.scheduler.task.RepositoryTask" role-hint="indexer"
throws TaskExecutionException
{
long time = System.currentTimeMillis();
- getLogger().info( "Starting repository discovery process" );
+ getLogger().info( "Starting repository indexing process" );
RepositoryArtifactIndex index = indexFactory.createStandardIndex( indexPath );
--- /dev/null
+package org.apache.maven.archiva.scheduler.task;
+
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.maven.archiva.configuration.Configuration;
+import org.apache.maven.archiva.configuration.ConfigurationStore;
+import org.apache.maven.archiva.configuration.ConfigurationStoreException;
+import org.apache.maven.archiva.configuration.ConfiguredRepositoryFactory;
+import org.apache.maven.archiva.scheduler.TaskExecutionException;
+import org.codehaus.plexus.logging.AbstractLogEnabled;
+
+import java.util.Map;
+
+/**
+ * Task for discovering problems in the repository.
+ *
+ * @author <a href="mailto:brett@apache.org">Brett Porter</a>
+ * @plexus.component role="org.apache.maven.archiva.scheduler.task.RepositoryTask" role-hint="reporter"
+ */
+public class ReporterTask
+ extends AbstractLogEnabled
+ implements RepositoryTask
+{
+ /**
+ * Configuration store.
+ *
+ * @plexus.requirement
+ */
+ private ConfigurationStore configurationStore;
+
+ /**
+ * @plexus.requirement
+ */
+ private ConfiguredRepositoryFactory repoFactory;
+
+ /**
+ * @plexus.requirement role="org.apache.maven.archiva.discoverer.ArtifactDiscoverer"
+ */
+ private Map artifactDiscoverers;
+
+ public void execute()
+ throws TaskExecutionException
+ {
+ Configuration configuration;
+ try
+ {
+ configuration = configurationStore.getConfigurationFromStore();
+ }
+ catch ( ConfigurationStoreException e )
+ {
+ throw new TaskExecutionException( e.getMessage(), e );
+ }
+
+ execute( configuration );
+ }
+
+ private void execute( Configuration configuration )
+ throws TaskExecutionException
+ {
+ long time = System.currentTimeMillis();
+ getLogger().info( "Starting repository reporting process" );
+
+ // TODO!
+
+ time = System.currentTimeMillis() - time;
+ getLogger().info( "Finished repository reporting process in " + time + "ms" );
+ }
+
+ public void executeNowIfNeeded()
+ throws TaskExecutionException
+ {
+ Configuration configuration;
+ try
+ {
+ configuration = configurationStore.getConfigurationFromStore();
+ }
+ catch ( ConfigurationStoreException e )
+ {
+ throw new TaskExecutionException( e.getMessage(), e );
+ }
+
+ // TODO!
+ }
+}
--- /dev/null
+package org.apache.maven.archiva.indexer.record;
+
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
+
+import java.util.Collection;
+
+/**
+ * Filter that removes artifacts already in the index.
+ * TODO: we could do timestamp comparisons here
+ */
+public class IndexRecordExistsArtifactFilter
+ implements ArtifactFilter
+{
+ private final Collection keys;
+
+ public IndexRecordExistsArtifactFilter( Collection keys )
+ {
+ this.keys = keys;
+ }
+
+ public boolean include( Artifact artifact )
+ {
+ String artifactKey = artifact.getGroupId() + ":" + artifact.getArtifactId() + ":" + artifact.getVersion() +
+ ( artifact.getClassifier() != null ? ":" + artifact.getClassifier() : "" );
+ return !keys.contains( artifactKey );
+ }
+}
+++ /dev/null
-package org.apache.maven.archiva.web.action.admin;
-
-/*
- * Copyright 2005-2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import com.opensymphony.xwork.ActionSupport;
-import org.apache.maven.archiva.scheduler.RepositoryTaskScheduler;
-import org.apache.maven.archiva.scheduler.TaskExecutionException;
-
-/**
- * Configures the application.
- *
- * @plexus.component role="com.opensymphony.xwork.Action" role-hint="runIndexerAction"
- */
-public class RunIndexerAction
- extends ActionSupport
-{
- /**
- * @plexus.requirement
- */
- private RepositoryTaskScheduler taskScheduler;
-
- public String execute()
- throws TaskExecutionException
- {
- taskScheduler.runIndexer();
-
- return SUCCESS;
- }
-}
--- /dev/null
+package org.apache.maven.archiva.web.action.admin;
+
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import com.opensymphony.xwork.ActionSupport;
+import org.apache.maven.archiva.scheduler.RepositoryTaskScheduler;
+import org.apache.maven.archiva.scheduler.TaskExecutionException;
+
+/**
+ * Configures the application.
+ *
+ * @plexus.component role="com.opensymphony.xwork.Action" role-hint="runRepositoryTaskAction"
+ */
+public class RunRepositoryTaskAction
+ extends ActionSupport
+{
+ /**
+ * @plexus.requirement
+ */
+ private RepositoryTaskScheduler taskScheduler;
+
+ public String runIndexer()
+ throws TaskExecutionException
+ {
+ taskScheduler.runIndexer();
+
+ return SUCCESS;
+ }
+
+ public String runReporter()
+ throws TaskExecutionException
+ {
+ taskScheduler.runReporter();
+
+ return SUCCESS;
+ }
+}
<interceptor-ref name="defaultStack"/>
</action>
- <action name="runIndexer" class="runIndexerAction">
+ <action name="runIndexer" class="runRepositoryTaskAction" method="runIndexer">
+ <result type="redirect-action">index</result>
+ </action>
+
+ <action name="runReporter" class="runRepositoryTaskAction" method="runReporter">
<result type="redirect-action">index</result>
</action>
</package>
<ww:form method="post" action="saveConfiguration" namespace="/admin" validate="true">
<ww:textfield name="indexPath" label="Index Directory" size="100"/>
<ww:textfield name="indexerCronExpression" label="Indexing Schedule"/>
+ <ww:textfield name="reporterCronExpression" label="Reporting Schedule"/>
<ww:hidden name="proxy.protocol" value="http"/>
<ww:textfield name="proxy.host" label="HTTP Proxy Host"/>
<ww:textfield name="proxy.port" label="HTTP Proxy Port"/>
<td>
<ww:property value="indexerCronExpression"/>
</td>
- <%-- TODO: a "run now without timestamp checking" operation should be here too, to pick up any stragglers (in the event of a bug) --%>
<%-- TODO: a "delete index and run now" operation should be here too (really clean, remove deletions that didn't get picked up) --%>
<td><a href="<ww:url action="runIndexer" />">Run Now</a></td>
</tr>
+ <tr>
+ <th>Reporting Schedule</th>
+ <td>
+ <ww:property value="reporterCronExpression"/>
+ </td>
+ <td><a href="<ww:url action="runReporter" />">Run Now</a></td>
+ </tr>
</table>
<ww:set name="proxy" value="proxy"/>
Indexing Cron Expression:
<input type="text"/>
</p>
+ <p>
+ Reporting Cron Expression:
+ <input type="text"/>
+ </p>
<p>
<input type="submit" value="Save Configuration"/>
</p>
<a href="#">Run Now</a>
</td>
</tr>
+ <tr>
+ <th>Reporting Schedule</th>
+ <td>...</td>
+ <td>
+ <a href="#">Run Now</a>
+ </td>
+ </tr>
</table>
<p>