From b385730d0747336f2ebe4bb18722309df6087db6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?S=C3=A9bastien=20Lesaint?= Date: Mon, 21 Mar 2016 17:37:45 +0100 Subject: [PATCH] SONAR-7307 retrieve only one row when polling queue table --- sonar-db/src/main/java/org/sonar/db/ce/CeQueueDao.java | 4 +++- sonar-db/src/main/java/org/sonar/db/ce/CeQueueMapper.java | 2 +- sonar-db/src/test/java/org/sonar/db/ce/CeQueueDaoTest.java | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/sonar-db/src/main/java/org/sonar/db/ce/CeQueueDao.java b/sonar-db/src/main/java/org/sonar/db/ce/CeQueueDao.java index 2ed1b66f5ec..9670c8c8068 100644 --- a/sonar-db/src/main/java/org/sonar/db/ce/CeQueueDao.java +++ b/sonar-db/src/main/java/org/sonar/db/ce/CeQueueDao.java @@ -33,6 +33,8 @@ import static org.sonar.db.ce.CeQueueDto.Status.PENDING; public class CeQueueDao implements Dao { + private static final RowBounds ONE_ROW_LIMIT = new RowBounds(0, 1); + private final System2 system2; public CeQueueDao(System2 system2) { @@ -107,7 +109,7 @@ public class CeQueueDao implements Dao { } public Optional peek(DbSession session) { - List taskUuids = mapper(session).selectEligibleForPeek(); + List taskUuids = mapper(session).selectEligibleForPeek(ONE_ROW_LIMIT); if (taskUuids.isEmpty()) { return Optional.absent(); } diff --git a/sonar-db/src/main/java/org/sonar/db/ce/CeQueueMapper.java b/sonar-db/src/main/java/org/sonar/db/ce/CeQueueMapper.java index 64bcadb1cb7..62fca4a7ff1 100644 --- a/sonar-db/src/main/java/org/sonar/db/ce/CeQueueMapper.java +++ b/sonar-db/src/main/java/org/sonar/db/ce/CeQueueMapper.java @@ -35,7 +35,7 @@ public interface CeQueueMapper { int countByQuery(@Param("query") CeTaskQuery query); - List selectEligibleForPeek(); + List selectEligibleForPeek(RowBounds rowBounds); @CheckForNull CeQueueDto selectByUuid(@Param("uuid") String uuid); diff --git a/sonar-db/src/test/java/org/sonar/db/ce/CeQueueDaoTest.java b/sonar-db/src/test/java/org/sonar/db/ce/CeQueueDaoTest.java index ec970533b14..479bd23bf76 100644 --- a/sonar-db/src/test/java/org/sonar/db/ce/CeQueueDaoTest.java +++ b/sonar-db/src/test/java/org/sonar/db/ce/CeQueueDaoTest.java @@ -55,7 +55,7 @@ public class CeQueueDaoTest { public DbTester db = DbTester.create(system2); private CeQueueDao underTest = new CeQueueDao(system2); - public static final String SELECT_QUEUE_UUID_AND_STATUS_QUERY = "select uuid,status from ce_queue"; + private static final String SELECT_QUEUE_UUID_AND_STATUS_QUERY = "select uuid,status from ce_queue"; @Test public void test_insert() { -- 2.39.5