+++ /dev/null
-/*
- * 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;
- }
-}
try {
sharedMemory = new RandomAccessFile(new File(directory, "sharedmemory"), "rw");
mappedByteBuffer = sharedMemory.getChannel().map(FileChannel.MapMode.READ_WRITE, 0, MAX_SHARED_MEMORY);
+ cleanData();
} catch (IOException e) {
throw new IllegalArgumentException("Unable to create shared memory : ", e);
}
return result;
}
+ private void cleanData() {
+ for (int i = offset(); i < BYTE_LENGTH_FOR_ONE_PROCESS; i++) {
+ mappedByteBuffer.put(i, EMPTY);
+ }
+ }
+
public static final int getMaxProcesses() {
return MAX_PROCESSES;
}
import org.sonar.process.StopWatcher;
import org.sonar.process.Stoppable;
import org.sonar.process.monitor.JavaCommand;
-import org.sonar.process.monitor.KnownJavaCommand;
import org.sonar.process.monitor.Monitor;
import java.io.File;
public void start(Props props) {
if (props.valueAsBoolean(ProcessConstants.ENABLE_STOP_COMMAND, false)) {
File tempDir = props.nonNullValueAsFile(ProcessConstants.PATH_TEMP);
- ProcessCommands commands = new ProcessCommands(tempDir, KnownJavaCommand.APP.getIndex());
+ ProcessCommands commands = new ProcessCommands(tempDir, 0);
stopWatcher = new StopWatcher(commands, this);
stopWatcher.start();
}