3 * Copyright (C) 2009-2016 SonarSource SA
4 * mailto:contact AT sonarsource DOT com
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 3 of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 package org.sonar.server.computation.monitoring;
22 import java.util.LinkedHashMap;
23 import org.sonar.server.computation.configuration.CeConfiguration;
24 import org.sonar.server.computation.queue.CeQueue;
25 import org.sonar.server.platform.monitoring.BaseMonitorMBean;
27 public class ComputeEngineQueueMonitor extends BaseMonitorMBean implements ComputeEngineQueueMonitorMBean {
28 private final CEQueueStatus queueStatus;
29 private final CeConfiguration ceConfiguration;
31 public ComputeEngineQueueMonitor(CEQueueStatus queueStatus,
32 // ReportQueue initializes CEQueueStatus and is therefor a dependency of
33 // ComputeEngineQueueMonitor.
34 // Do not remove this parameter, it ensures start order of components
36 CeConfiguration ceConfiguration) {
37 this.queueStatus = queueStatus;
38 this.ceConfiguration = ceConfiguration;
42 public String name() {
43 return "ComputeEngine";
47 public LinkedHashMap<String, Object> attributes() {
48 LinkedHashMap<String, Object> attributes = new LinkedHashMap<>();
49 attributes.put("Received", getReceivedCount());
50 attributes.put("Pending", getPendingCount());
51 attributes.put("In progress", getInProgressCount());
52 attributes.put("Successfully processed", getSuccessCount());
53 attributes.put("Processed with error", getErrorCount());
54 attributes.put("Processing time", getProcessingTime());
55 attributes.put("Worker count", getWorkerCount());
60 public long getReceivedCount() {
61 return queueStatus.getReceivedCount();
65 public long getPendingCount() {
66 return queueStatus.getPendingCount();
70 public long getInProgressCount() {
71 return queueStatus.getInProgressCount();
75 public long getErrorCount() {
76 return queueStatus.getErrorCount();
80 public long getSuccessCount() {
81 return queueStatus.getSuccessCount();
85 public long getProcessingTime() {
86 return queueStatus.getProcessingTime();
90 public int getWorkerCount() {
91 return ceConfiguration.getWorkerCount();