diff options
author | Jacek <jacek.poreda@sonarsource.com> | 2021-06-23 11:17:35 +0200 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2021-06-23 20:03:04 +0000 |
commit | dcbb4b724fbc8cba4f912fd483faedb3ee98f046 (patch) | |
tree | 0523f2dd19746a755b24029bebbd9c24835b4c36 /server/sonar-ce/src | |
parent | b123a8332adb61970e78e846428928cca675e7d3 (diff) | |
download | sonarqube-dcbb4b724fbc8cba4f912fd483faedb3ee98f046.tar.gz sonarqube-dcbb4b724fbc8cba4f912fd483faedb3ee98f046.zip |
SONAR-15057 Change Optional<Long> type to long, to comply CeTasksMBean with JMX spec
Diffstat (limited to 'server/sonar-ce/src')
3 files changed, 6 insertions, 8 deletions
diff --git a/server/sonar-ce/src/main/java/org/sonar/ce/monitoring/CeTasksMBean.java b/server/sonar-ce/src/main/java/org/sonar/ce/monitoring/CeTasksMBean.java index 9c098f91ada..3764fd6c6fd 100644 --- a/server/sonar-ce/src/main/java/org/sonar/ce/monitoring/CeTasksMBean.java +++ b/server/sonar-ce/src/main/java/org/sonar/ce/monitoring/CeTasksMBean.java @@ -20,7 +20,6 @@ package org.sonar.ce.monitoring; import java.util.List; -import java.util.Optional; public interface CeTasksMBean { @@ -34,7 +33,7 @@ public interface CeTasksMBean { /** * The age, in ms, of the oldest pending task. */ - Optional<Long> getLongestTimePending(); + long getLongestTimePending(); /** * Count of tasks under processing. diff --git a/server/sonar-ce/src/main/java/org/sonar/ce/monitoring/CeTasksMBeanImpl.java b/server/sonar-ce/src/main/java/org/sonar/ce/monitoring/CeTasksMBeanImpl.java index 2f4b5bf501c..f35bf1fa7d3 100644 --- a/server/sonar-ce/src/main/java/org/sonar/ce/monitoring/CeTasksMBeanImpl.java +++ b/server/sonar-ce/src/main/java/org/sonar/ce/monitoring/CeTasksMBeanImpl.java @@ -20,7 +20,6 @@ package org.sonar.ce.monitoring; import java.util.List; -import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; import org.picocontainer.Startable; @@ -64,8 +63,8 @@ public class CeTasksMBeanImpl implements CeTasksMBean, Startable, SystemInfoSect } @Override - public Optional<Long> getLongestTimePending() { - return queueStatus.getLongestTimePending(); + public long getLongestTimePending() { + return queueStatus.getLongestTimePending().orElse(0L); } @Override @@ -122,7 +121,7 @@ public class CeTasksMBeanImpl implements CeTasksMBean, Startable, SystemInfoSect ProtobufSystemInfo.Section.Builder builder = ProtobufSystemInfo.Section.newBuilder(); builder.setName("Compute Engine Tasks"); builder.addAttributesBuilder().setKey("Pending").setLongValue(getPendingCount()).build(); - builder.addAttributesBuilder().setKey("Longest Time Pending (ms)").setLongValue(getLongestTimePending().orElse(0L)).build(); + builder.addAttributesBuilder().setKey("Longest Time Pending (ms)").setLongValue(getLongestTimePending()).build(); builder.addAttributesBuilder().setKey("In Progress").setLongValue(getInProgressCount()).build(); builder.addAttributesBuilder().setKey("Processed With Error").setLongValue(getErrorCount()).build(); builder.addAttributesBuilder().setKey("Processed With Success").setLongValue(getSuccessCount()).build(); diff --git a/server/sonar-ce/src/test/java/org/sonar/ce/monitoring/CeTasksMBeanImplTest.java b/server/sonar-ce/src/test/java/org/sonar/ce/monitoring/CeTasksMBeanImplTest.java index 6ef75da807f..44c0b4d6325 100644 --- a/server/sonar-ce/src/test/java/org/sonar/ce/monitoring/CeTasksMBeanImplTest.java +++ b/server/sonar-ce/src/test/java/org/sonar/ce/monitoring/CeTasksMBeanImplTest.java @@ -47,7 +47,7 @@ import static org.mockito.Mockito.when; public class CeTasksMBeanImplTest { private static final long PENDING_COUNT = 2; - private static final Optional<Long> PENDING_TIME = Optional.of(10_000L); + private static final long PENDING_TIME = 10_000L; private static final long IN_PROGRESS_COUNT = 5; private static final long ERROR_COUNT = 10; private static final long SUCCESS_COUNT = 13; @@ -157,7 +157,7 @@ public class CeTasksMBeanImplTest { @Override public Optional<Long> getLongestTimePending() { - return PENDING_TIME; + return Optional.of(PENDING_TIME); } @Override |