aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-ce/src
diff options
context:
space:
mode:
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>2017-07-06 11:43:36 +0200
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>2017-07-17 10:52:47 +0200
commit525067cc13b2daf2b5f0ffa84e56ab0ceb20e84f (patch)
tree4bb4a83721119c2a16bfe1756d079dbfe0d87613 /server/sonar-ce/src
parent3c46dcc658fb7080eb448b3c1b969380c4d4684f (diff)
downloadsonarqube-525067cc13b2daf2b5f0ffa84e56ab0ceb20e84f.tar.gz
sonarqube-525067cc13b2daf2b5f0ffa84e56ab0ceb20e84f.zip
SONAR-9525 add workerThreadCount to CE's MBean
Diffstat (limited to 'server/sonar-ce/src')
-rw-r--r--server/sonar-ce/src/main/java/org/sonar/ce/monitoring/CeTasksMBean.java5
-rw-r--r--server/sonar-ce/src/main/java/org/sonar/ce/monitoring/CeTasksMBeanImpl.java6
-rw-r--r--server/sonar-ce/src/test/java/org/sonar/ce/monitoring/CeTasksMBeanImplTest.java10
3 files changed, 19 insertions, 2 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 2e85a5d0c02..cd01f6dbfb5 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
@@ -49,6 +49,11 @@ public interface CeTasksMBean {
long getProcessingTime();
/**
+ * Configured maximum number of workers.
+ */
+ int getWorkerMaxCount();
+
+ /**
* Configured number of Workers.
*/
int getWorkerCount();
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 9797b414f26..c2e0fdf576c 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
@@ -73,6 +73,11 @@ public class CeTasksMBeanImpl implements CeTasksMBean, Startable, SystemInfoSect
}
@Override
+ public int getWorkerMaxCount() {
+ return ceConfiguration.getWorkerMaxCount();
+ }
+
+ @Override
public int getWorkerCount() {
return ceConfiguration.getWorkerCount();
}
@@ -87,6 +92,7 @@ public class CeTasksMBeanImpl implements CeTasksMBean, Startable, SystemInfoSect
builder.addAttributesBuilder().setKey("Processed With Success").setLongValue(getSuccessCount()).build();
builder.addAttributesBuilder().setKey("Processing Time (ms)").setLongValue(getProcessingTime()).build();
builder.addAttributesBuilder().setKey("Worker Count").setLongValue(getWorkerCount()).build();
+ builder.addAttributesBuilder().setKey("Max Worker Count").setLongValue(getWorkerMaxCount()).build();
return builder.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 2afe062b683..a87598bfeed 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
@@ -36,6 +36,7 @@ public class CeTasksMBeanImplTest {
private static final long ERROR_COUNT = 10;
private static final long SUCCESS_COUNT = 13;
private static final long PROCESSING_TIME = 987;
+ private static final int WORKER_MAX_COUNT = 666;
private static final int WORKER_COUNT = 56;
private CeTasksMBeanImpl underTest = new CeTasksMBeanImpl(new DumbCEQueueStatus(), new DumbCeConfiguration());
@@ -66,10 +67,15 @@ public class CeTasksMBeanImplTest {
}
@Test
+ public void getWorkerMaxCount_delegates_to_the_CEConfiguration_instance() {
+ assertThat(underTest.getWorkerMaxCount()).isEqualTo(WORKER_MAX_COUNT);
+ }
+
+ @Test
public void export_system_info() {
ProtobufSystemInfo.Section section = underTest.toProtobuf();
assertThat(section.getName()).isEqualTo("Compute Engine Tasks");
- assertThat(section.getAttributesCount()).isEqualTo(6);
+ assertThat(section.getAttributesCount()).isEqualTo(7);
}
/**
@@ -126,7 +132,7 @@ public class CeTasksMBeanImplTest {
private static class DumbCeConfiguration implements CeConfiguration {
@Override
public int getWorkerMaxCount() {
- throw new UnsupportedOperationException("getWorkerMaxCount is not implemented");
+ return WORKER_MAX_COUNT;
}
@Override