diff options
author | Eric Hartmann <hartmann.eric@gmail.com> | 2015-02-21 08:28:12 +0100 |
---|---|---|
committer | Eric Hartmann <hartmann.eric@gmail.com> | 2015-02-21 08:28:12 +0100 |
commit | 69d136d3a71e36521ddd56d0e5b037fb7472c95d (patch) | |
tree | 603b6dcb0a51c5cfe45870bd8aa24165d85adfe4 /server/sonar-process-monitor/src | |
parent | 1c64edd9c99077b592c0fcd8805c62cdca562080 (diff) | |
download | sonarqube-69d136d3a71e36521ddd56d0e5b037fb7472c95d.tar.gz sonarqube-69d136d3a71e36521ddd56d0e5b037fb7472c95d.zip |
SONAR-6036 : Remove KnownJavaCommand and clean the memory at the startup of the ProcessCommand
Diffstat (limited to 'server/sonar-process-monitor/src')
4 files changed, 3 insertions, 70 deletions
diff --git a/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/JavaCommand.java b/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/JavaCommand.java index f4593308b9b..d4b774cb851 100644 --- a/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/JavaCommand.java +++ b/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/JavaCommand.java @@ -58,10 +58,7 @@ public class JavaCommand { public JavaCommand(String key) { this.key = key; - processIndex = KnownJavaCommand.lookIndexFor(key); - if (processIndex == -1) { - processIndex = Monitor.getNextProcessId(); - } + processIndex = Monitor.getNextProcessId(); } public String getKey() { diff --git a/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/KnownJavaCommand.java b/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/KnownJavaCommand.java deleted file mode 100644 index ce9a49aed1a..00000000000 --- a/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/KnownJavaCommand.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.process.monitor; - -/** - * Created by eric on 20/02/15. - */ -public enum KnownJavaCommand { - APP("app", 0), WEB("web", 1), ELASTIC_SEARCH("search", 2), UNKNOWN("unknown", -1); - - private String key; - private int index; - - KnownJavaCommand(String key, int index) { - this.key = key; - this.index = index; - } - - public String getKey() { - return key; - } - - public int getIndex() { - return index; - } - - public static KnownJavaCommand lookFor(String key) { - for (KnownJavaCommand knownJavaCommand : KnownJavaCommand.values()) { - if (knownJavaCommand.getKey().equals(key)) { - return knownJavaCommand; - } - } - return KnownJavaCommand.UNKNOWN; - } - - public static int lookIndexFor(String key) { - return lookFor(key).getIndex(); - } - - public static int getFirstIndexAvailable() { - int result = 0; - for (KnownJavaCommand knownJavaCommand : KnownJavaCommand.values()) { - result = knownJavaCommand.getIndex() >= result ? knownJavaCommand.getIndex() + 1 : result; - } - return result; - } -} diff --git a/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/Monitor.java b/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/Monitor.java index ccbeb558db0..fd546b9df5d 100644 --- a/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/Monitor.java +++ b/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/Monitor.java @@ -40,7 +40,7 @@ public class Monitor { // used by awaitStop() to block until all processes are shutdown private final List<WatcherThread> watcherThreads = new CopyOnWriteArrayList<WatcherThread>(); - static int nextProcessId = KnownJavaCommand.getFirstIndexAvailable(); + static int nextProcessId = 0; Monitor(JavaProcessLauncher launcher, SystemExit exit, TerminatorThread terminator) { this.launcher = launcher; diff --git a/server/sonar-process-monitor/src/test/java/org/sonar/process/monitor/MonitorTest.java b/server/sonar-process-monitor/src/test/java/org/sonar/process/monitor/MonitorTest.java index 4a27d50ed62..e88b8d49379 100644 --- a/server/sonar-process-monitor/src/test/java/org/sonar/process/monitor/MonitorTest.java +++ b/server/sonar-process-monitor/src/test/java/org/sonar/process/monitor/MonitorTest.java @@ -217,7 +217,7 @@ public class MonitorTest { } catch (IllegalStateException e) { assertThat(e).hasMessageStartingWith("The maximum number of processes launched has been reached "); } finally { - Monitor.nextProcessId = KnownJavaCommand.getFirstIndexAvailable(); + Monitor.nextProcessId = 0; } } |