From 8d3f82a479b6eb2bf709b1831351e20309735683 Mon Sep 17 00:00:00 2001 From: olivier lamy Date: Tue, 20 Jun 2017 21:49:28 +1000 Subject: [PATCH] [MRM-1956] Replace tomcat-jdbc pool with HikariCP Signed-off-by: olivier lamy --- archiva-jetty/pom.xml | 16 +++----- archiva-jetty/src/main/conf/jetty.xml | 20 +++++----- .../scanner/DefaultRepositoryScanner.java | 2 +- ...vaRepositoryScanningTaskExecutorTest.java} | 13 ++++--- ...ositoryScanningTaskExecutorPhase1Test.java | 2 +- ...ositoryScanningTaskExecutorPhase2Test.java | 38 +++++++------------ .../src/test/resources/log4j2-test.xml | 38 +++++++++++++++++++ pom.xml | 21 ++++------ 8 files changed, 83 insertions(+), 67 deletions(-) rename archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/java/org/apache/archiva/scheduler/repository/{ArchivaRepositoryScanningTaskExecutorAbstractTest.java => AbstractArchivaRepositoryScanningTaskExecutorTest.java} (92%) create mode 100644 archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/resources/log4j2-test.xml diff --git a/archiva-jetty/pom.xml b/archiva-jetty/pom.xml index 33b00489c..36b95ae92 100644 --- a/archiva-jetty/pom.xml +++ b/archiva-jetty/pom.xml @@ -65,7 +65,11 @@ ${jettyVersion} runtime - + + com.zaxxer + HikariCP + runtime + org.apache.derby derby @@ -81,16 +85,6 @@ ant runtime - - org.apache.tomcat - tomcat-jdbc - runtime - - - org.apache.tomcat - tomcat-juli - runtime - diff --git a/archiva-jetty/src/main/conf/jetty.xml b/archiva-jetty/src/main/conf/jetty.xml index b7e66d463..31c81822d 100644 --- a/archiva-jetty/src/main/conf/jetty.xml +++ b/archiva-jetty/src/main/conf/jetty.xml @@ -157,31 +157,29 @@ jdbc/users - + org.apache.derby.jdbc.EmbeddedDriver - jdbc:derby:/data/databases/users;create=true + jdbc:derby:/data/databases/users;create=true sa - 20 - true - true - 5 - true + 20 + 5 - select 1 + + diff --git a/archiva-modules/archiva-base/archiva-repository-scanner/src/main/java/org/apache/archiva/repository/scanner/DefaultRepositoryScanner.java b/archiva-modules/archiva-base/archiva-repository-scanner/src/main/java/org/apache/archiva/repository/scanner/DefaultRepositoryScanner.java index 56ef2fd42..6257880dd 100644 --- a/archiva-modules/archiva-base/archiva-repository-scanner/src/main/java/org/apache/archiva/repository/scanner/DefaultRepositoryScanner.java +++ b/archiva-modules/archiva-base/archiva-repository-scanner/src/main/java/org/apache/archiva/repository/scanner/DefaultRepositoryScanner.java @@ -53,7 +53,7 @@ public class DefaultRepositoryScanner @Inject private RepositoryContentConsumers repositoryContentConsumers; - private Set inProgressScans = new LinkedHashSet(); + private Set inProgressScans = new LinkedHashSet<>(); @Override public RepositoryScanStatistics scan( ManagedRepository repository, long changesSince ) diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/java/org/apache/archiva/scheduler/repository/ArchivaRepositoryScanningTaskExecutorAbstractTest.java b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/java/org/apache/archiva/scheduler/repository/AbstractArchivaRepositoryScanningTaskExecutorTest.java similarity index 92% rename from archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/java/org/apache/archiva/scheduler/repository/ArchivaRepositoryScanningTaskExecutorAbstractTest.java rename to archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/java/org/apache/archiva/scheduler/repository/AbstractArchivaRepositoryScanningTaskExecutorTest.java index 1698f078a..dcddb7153 100644 --- a/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/java/org/apache/archiva/scheduler/repository/ArchivaRepositoryScanningTaskExecutorAbstractTest.java +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/java/org/apache/archiva/scheduler/repository/AbstractArchivaRepositoryScanningTaskExecutorTest.java @@ -27,9 +27,11 @@ import org.apache.archiva.metadata.repository.stats.RepositoryStatisticsManager; import org.apache.archiva.mock.MockRepositorySessionFactory; import org.apache.archiva.redback.components.taskqueue.execution.TaskExecutor; import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner; +import org.apache.commons.lang.StringUtils; import org.codehaus.plexus.util.FileUtils; import org.junit.After; import org.junit.Before; +import org.junit.BeforeClass; import org.junit.runner.RunWith; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; @@ -48,7 +50,7 @@ import static org.mockito.Mockito.mock; @RunWith( ArchivaSpringJUnit4ClassRunner.class ) @ContextConfiguration( locations = { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context.xml" } ) @DirtiesContext( classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD ) -public abstract class ArchivaRepositoryScanningTaskExecutorAbstractTest +public abstract class AbstractArchivaRepositoryScanningTaskExecutorTest extends TestCase { @Inject @@ -96,12 +98,11 @@ public abstract class ArchivaRepositoryScanningTaskExecutorAbstractTest // set the timestamps to a time well in the past Calendar cal = Calendar.getInstance(); cal.add( Calendar.YEAR, -1 ); - for ( File f : (List) FileUtils.getFiles( repoDir, "**", null ) ) - { - f.setLastModified( cal.getTimeInMillis() ); - } + FileUtils.getFiles( repoDir, "**", null ) // + .stream().forEach( file -> file.setLastModified( cal.getTimeInMillis() ) ); + // TODO: test they are excluded instead - for ( String dir : (List) FileUtils.getDirectoryNames( repoDir, "**/.svn", null, false ) ) + for ( String dir : FileUtils.getDirectoryNames( repoDir, "**/.svn", null, false ) ) { FileUtils.deleteDirectory( new File( repoDir, dir ) ); } diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/java/org/apache/archiva/scheduler/repository/ArchivaRepositoryScanningTaskExecutorPhase1Test.java b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/java/org/apache/archiva/scheduler/repository/ArchivaRepositoryScanningTaskExecutorPhase1Test.java index 200ebde05..6d6383a57 100644 --- a/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/java/org/apache/archiva/scheduler/repository/ArchivaRepositoryScanningTaskExecutorPhase1Test.java +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/java/org/apache/archiva/scheduler/repository/ArchivaRepositoryScanningTaskExecutorPhase1Test.java @@ -33,7 +33,7 @@ import java.util.Collection; */ @ContextConfiguration( locations = { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context.xml" } ) public class ArchivaRepositoryScanningTaskExecutorPhase1Test - extends ArchivaRepositoryScanningTaskExecutorAbstractTest + extends AbstractArchivaRepositoryScanningTaskExecutorTest { // Split of ArchivaRepositoryScanningTaskExecutorTest should be executed first // to avoid testConsumer in unknown state if member of Phase2 all ready executed diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/java/org/apache/archiva/scheduler/repository/ArchivaRepositoryScanningTaskExecutorPhase2Test.java b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/java/org/apache/archiva/scheduler/repository/ArchivaRepositoryScanningTaskExecutorPhase2Test.java index e34694556..4a537234d 100644 --- a/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/java/org/apache/archiva/scheduler/repository/ArchivaRepositoryScanningTaskExecutorPhase2Test.java +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/java/org/apache/archiva/scheduler/repository/ArchivaRepositoryScanningTaskExecutorPhase2Test.java @@ -34,26 +34,23 @@ import java.util.Date; /** * ArchivaRepositoryScanningTaskExecutorPhase2Test - * - * */ @ContextConfiguration( locations = { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context.xml" } ) public class ArchivaRepositoryScanningTaskExecutorPhase2Test - extends ArchivaRepositoryScanningTaskExecutorAbstractTest + extends AbstractArchivaRepositoryScanningTaskExecutorTest { @Test public void testExecutorScanOnlyNewArtifacts() throws Exception { + createAndSaveTestStats(); + RepositoryTask repoTask = new RepositoryTask(); repoTask.setRepositoryId( TEST_REPO_ID ); repoTask.setScanAll( false ); - - createAndSaveTestStats(); - taskExecutor.executeTask( repoTask ); // check no artifacts processed @@ -67,7 +64,7 @@ public class ArchivaRepositoryScanningTaskExecutorPhase2Test RepositoryStatistics newStats = repositoryStatisticsManager.getLastStatistics( metadataRepository, TEST_REPO_ID ); assertEquals( 0, newStats.getNewFileCount() ); - assertEquals( 31, newStats.getTotalFileCount() ); + assertEquals( 41, newStats.getTotalFileCount() ); // FIXME: can't test these as they weren't stored in the database, move to tests for RepositoryStatisticsManager implementation // assertEquals( 8, newStats.getTotalArtifactCount() ); // assertEquals( 3, newStats.getTotalGroupCount() ); @@ -100,7 +97,7 @@ public class ArchivaRepositoryScanningTaskExecutorPhase2Test RepositoryStatistics updatedStats = repositoryStatisticsManager.getLastStatistics( metadataRepository, TEST_REPO_ID ); assertEquals( 2, updatedStats.getNewFileCount() ); - assertEquals( 33, updatedStats.getTotalFileCount() ); + assertEquals( 43, updatedStats.getTotalFileCount() ); // FIXME: can't test these as they weren't stored in the database, move to tests for RepositoryStatisticsManager implementation // assertEquals( 8, newStats.getTotalArtifactCount() ); // assertEquals( 3, newStats.getTotalGroupCount() ); @@ -147,7 +144,7 @@ public class ArchivaRepositoryScanningTaskExecutorPhase2Test RepositoryStatistics newStats = repositoryStatisticsManager.getLastStatistics( metadataRepository, TEST_REPO_ID ); assertEquals( 2, newStats.getNewFileCount() ); - assertEquals( 33, newStats.getTotalFileCount() ); + assertEquals( 43, newStats.getTotalFileCount() ); // FIXME: can't test these as they weren't stored in the database, move to tests for RepositoryStatisticsManager implementation // assertEquals( 8, newStats.getTotalArtifactCount() ); // assertEquals( 3, newStats.getTotalGroupCount() ); @@ -194,7 +191,7 @@ public class ArchivaRepositoryScanningTaskExecutorPhase2Test RepositoryStatistics newStats = repositoryStatisticsManager.getLastStatistics( metadataRepository, TEST_REPO_ID ); assertEquals( 2, newStats.getNewFileCount() ); - assertEquals( 33, newStats.getTotalFileCount() ); + assertEquals( 43, newStats.getTotalFileCount() ); // FIXME: can't test these as they weren't stored in the database, move to tests for RepositoryStatisticsManager implementation // assertEquals( 8, newStats.getTotalArtifactCount() ); // assertEquals( 3, newStats.getTotalGroupCount() ); @@ -212,8 +209,9 @@ public class ArchivaRepositoryScanningTaskExecutorPhase2Test repoTask.setScanAll( true ); Date date = Calendar.getInstance().getTime(); - repositoryStatisticsManager.addStatisticsAfterScan( metadataRepository, TEST_REPO_ID, - new Date( date.getTime() - 1234567 ), date, 8, 8 ); + repositoryStatisticsManager.addStatisticsAfterScan( metadataRepository, TEST_REPO_ID, // + new Date( date.getTime() - 1234567 ), // + date, 8, 8 ); // taskExecutor.executeTask( repoTask ); @@ -227,17 +225,9 @@ public class ArchivaRepositoryScanningTaskExecutorPhase2Test throws MetadataRepositoryException { Date date = Calendar.getInstance().getTime(); - RepositoryStatistics stats = new RepositoryStatistics(); - stats.setScanStartTime( new Date( date.getTime() - 1234567 ) ); - stats.setScanEndTime( date ); - stats.setNewFileCount( 31 ); - stats.setTotalArtifactCount( 8 ); - stats.setTotalFileCount( 31 ); - stats.setTotalGroupCount( 3 ); - stats.setTotalProjectCount( 5 ); - stats.setTotalArtifactFileSize( 38545 ); - - repositoryStatisticsManager.addStatisticsAfterScan( metadataRepository, TEST_REPO_ID, - new Date( date.getTime() - 1234567 ), date, 31, 31 ); + + repositoryStatisticsManager.addStatisticsAfterScan( metadataRepository, TEST_REPO_ID, // + new Date( date.getTime() - 1234567 ), date, // + 41, 41 ); } } diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/resources/log4j2-test.xml b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/resources/log4j2-test.xml new file mode 100644 index 000000000..fdc40af5a --- /dev/null +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/resources/log4j2-test.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/pom.xml b/pom.xml index b78f61ef2..8e12a4c54 100644 --- a/pom.xml +++ b/pom.xml @@ -79,7 +79,7 @@ 2.14.1 3.0.3 - 10.10.1.1 + 10.13.1.1 4.5.2 4.4.4 1.4 @@ -95,7 +95,6 @@ 1.1 2.1 3.0.15 - 7.0.54 2.27 clean install @@ -460,7 +459,13 @@ com.lmax disruptor - 3.2.1 + 3.3.6 + + + + com.zaxxer + HikariCP + 2.6.3