use of org.sonar.process.ProcessId in project sonarqube by SonarSource.
the class ProcessLauncherImpl method launchJava.
private <T extends JvmOptions> Process launchJava(JavaCommand<T> javaCommand) {
ProcessId processId = javaCommand.getProcessId();
try {
ProcessBuilder processBuilder = create(javaCommand);
logLaunchedCommand(javaCommand, processBuilder);
return processBuilder.start();
} catch (Exception e) {
throw new IllegalStateException(format("Fail to launch process [%s]", processId.getKey()), e);
}
}
use of org.sonar.process.ProcessId in project sonarqube by SonarSource.
the class ProcessLauncherImpl method launch.
public ManagedProcess launch(AbstractCommand command) {
EsInstallation esInstallation = command.getEsInstallation();
if (esInstallation != null) {
cleanupOutdatedEsData(esInstallation);
writeConfFiles(esInstallation);
}
Process process;
if (command instanceof EsScriptCommand) {
process = launchExternal((EsScriptCommand) command);
} else if (command instanceof JavaCommand) {
process = launchJava((JavaCommand<?>) command);
} else {
throw new IllegalStateException("Unexpected type of command: " + command.getClass());
}
ProcessId processId = command.getProcessId();
try {
if (processId == ProcessId.ELASTICSEARCH) {
checkArgument(esInstallation != null, "Incorrect configuration EsInstallation is null");
EsConnectorImpl esConnector = new EsConnectorImpl(singleton(HostAndPort.fromParts(esInstallation.getHost(), esInstallation.getHttpPort())), esInstallation.getBootstrapPassword());
return new EsManagedProcess(process, processId, esConnector);
} else {
ProcessCommands commands = allProcessesCommands.createAfterClean(processId.getIpcIndex());
return new ProcessCommandsManagedProcess(process, processId, commands);
}
} catch (Exception e) {
// just in case
if (process != null) {
process.destroyForcibly();
}
throw new IllegalStateException(format("Fail to launch monitor of process [%s]", processId.getKey()), e);
}
}
use of org.sonar.process.ProcessId in project sonarqube by SonarSource.
the class SchedulerImpl method schedule.
@Override
public void schedule() throws InterruptedException {
if (!nodeLifecycle.tryToMoveTo(NodeLifecycle.State.STARTING)) {
return;
}
firstWaitingEsLog.set(true);
processesById.clear();
for (ProcessId processId : ClusterSettings.getEnabledProcesses(settings)) {
ManagedProcessHandler process = ManagedProcessHandler.builder(processId).addProcessLifecycleListener(this).addEventListener(this).setWatcherDelayMs(processWatcherDelayMs).setStopTimeout(stopTimeoutFor(processId, settings)).setHardStopTimeout(HARD_STOP_TIMEOUT).setAppSettings(settings).build();
processesById.put(process.getProcessId(), process);
}
operationalCountDown.set(processesById.size());
tryToStartAll();
}
use of org.sonar.process.ProcessId in project sonarqube by SonarSource.
the class HazelcastMemberBuilder method build.
public HazelcastMember build() {
Config config = new Config();
// do not use the value defined by property sonar.cluster.name.
// Hazelcast does not fail when joining a cluster with different name.
// Apparently this behavior exists since Hazelcast 3.8.2 (see note
// at http://docs.hazelcast.org/docs/3.8.6/manual/html-single/index.html#creating-cluster-groups)
config.setClusterName("SonarQube");
// Configure network
NetworkConfig netConfig = config.getNetworkConfig();
netConfig.setPort(port).setPortAutoIncrement(false).setReuseAddress(true);
netConfig.getInterfaces().setEnabled(true).setInterfaces(singletonList(requireNonNull(networkInterface, "Network interface is missing")));
JoinConfig joinConfig = netConfig.getJoin();
joinConfig.getAwsConfig().setEnabled(false);
joinConfig.getMulticastConfig().setEnabled(false);
if (KUBERNETES.equals(type)) {
joinConfig.getKubernetesConfig().setEnabled(true).setProperty("service-dns", requireNonNull(members, "Service DNS is missing")).setProperty("service-port", CLUSTER_NODE_HZ_PORT.getDefaultValue());
} else {
List<String> addressesWithDefaultPorts = Stream.of(this.members.split(",")).filter(host -> !host.isBlank()).map(String::trim).map(HazelcastMemberBuilder::applyDefaultPortToHost).collect(Collectors.toList());
joinConfig.getTcpIpConfig().setEnabled(true);
joinConfig.getTcpIpConfig().setMembers(requireNonNull(addressesWithDefaultPorts, "Members are missing"));
}
// We are not using the partition group of Hazelcast, so disabling it
config.getPartitionGroupConfig().setEnabled(false);
// Tweak HazelCast configuration
config.setProperty("hazelcast.tcp.join.port.try.count", "10").setProperty("hazelcast.socket.bind.any", "false").setProperty("hazelcast.phone.home.enabled", "false").setProperty("hazelcast.logging.type", "slf4j");
MemberAttributeConfig attributes = config.getMemberAttributeConfig();
attributes.setAttribute(Attribute.NODE_NAME.getKey(), requireNonNull(nodeName, "Node name is missing"));
attributes.setAttribute(Attribute.PROCESS_KEY.getKey(), requireNonNull(processId, "Process key is missing").getKey());
return new HazelcastMemberImpl(Hazelcast.newHazelcastInstance(config));
}
Aggregations