/** * Finds out whether we are in testing environment (usually ITs) and logs of all processes must be forward to * App's System.out. This is specified by the value of property {@link #ALL_LOGS_TO_CONSOLE_PROPERTY}. */ public boolean isAllLogsToConsoleEnabled(Props props) { return props.valueAsBoolean(ALL_LOGS_TO_CONSOLE_PROPERTY, false); }
private static boolean isClusterEnabled(Props props) { return props.valueAsBoolean(CLUSTER_ENABLED.getKey()); }
@Test @UseDataProvider("beforeAndAfterBlanks") public void booleanOf(String blankBefore, String blankAfter) { Properties p = new Properties(); p.setProperty("foo", blankBefore + "True" + blankAfter); p.setProperty("bar", blankBefore + "false" + blankAfter); Props props = new Props(p); assertThat(props.valueAsBoolean("foo")).isTrue(); assertThat(props.valueAsBoolean("bar")).isFalse(); assertThat(props.valueAsBoolean("foo", false)).isTrue(); assertThat(props.valueAsBoolean("bar", true)).isFalse(); assertThat(props.valueAsBoolean("unknown")).isFalse(); assertThat(props.valueAsBoolean("unset", false)).isFalse(); assertThat(props.valueAsBoolean("unset", true)).isTrue(); }
public EsSettings(Props props, EsInstallation fileSystem, System2 system2) { this.props = props; this.fileSystem = fileSystem; this.clusterName = props.nonNullValue(CLUSTER_NAME.getKey()); this.clusterEnabled = props.valueAsBoolean(CLUSTER_ENABLED.getKey()); if (this.clusterEnabled) { this.nodeName = props.value(CLUSTER_NODE_NAME.getKey(), "sonarqube-" + UUID.randomUUID().toString()); } else { this.nodeName = STANDALONE_NODE_NAME; } String esJvmOptions = system2.getenv("ES_JVM_OPTIONS"); if (esJvmOptions != null && !esJvmOptions.trim().isEmpty()) { LOGGER.warn("ES_JVM_OPTIONS is defined but will be ignored. " + "Use sonar.search.javaOpts and/or sonar.search.javaAdditionalOpts in sonar.properties to specify jvm options for Elasticsearch"); } }
@Override public void startWatching() { if (settings.getProps().valueAsBoolean(ENABLE_STOP_COMMAND.getKey())) { start(); } }
@Test public void completeDefaults_adds_default_values() { Props props = new Props(new Properties()); ProcessProperties.completeDefaults(props); assertThat(props.value("sonar.search.javaOpts")).contains("-Xmx"); assertThat(props.valueAsInt("sonar.jdbc.maxActive")).isEqualTo(60); assertThat(props.valueAsBoolean("sonar.sonarcloud.enabled")).isEqualTo(false); assertThat(props.valueAsBoolean("sonar.updatecenter.activate")).isEqualTo(true); }
private void enableSetting(boolean b) { when(settings.getProps().valueAsBoolean(ENABLE_STOP_COMMAND.getKey())).thenReturn(b); }
if (props.valueAsBoolean(SONARCLOUD_ENABLED.getKey())) { StandaloneCeDistributedInformation.class, CEQueueStatusImpl.class); } else if (props.valueAsBoolean(CLUSTER_ENABLED.getKey())) { container.add( CeCleaningModule.class,
public LoggerContext configure() { LoggerContext ctx = helper.getRootContext(); ctx.reset(); helper.enableJulChangePropagation(ctx); configureConsole(ctx); if (helper.isAllLogsToConsoleEnabled(appSettings.getProps()) || !appSettings.getProps().valueAsBoolean("sonar.wrapped", false)) { configureWithLogbackWritingToFile(ctx); } else { configureWithWrapperWritingToFile(ctx); } helper.apply( LogLevelConfig.newBuilder(helper.getRootLoggerName()) .rootLevelFor(ProcessId.APP) .immutableLevel("com.hazelcast", Level.toLevel("WARN")) .build(), appSettings.getProps()); return ctx; }
private static void configureLogbackAccess(Tomcat tomcat, Props props) { if (props.valueAsBoolean(PROPERTY_ENABLE, true)) { ProgrammaticLogbackValve valve = new ProgrammaticLogbackValve(); LogbackHelper helper = new LogbackHelper(); LogbackHelper.RollingPolicy policy = helper.createRollingPolicy(valve, props, "access"); FileAppender appender = policy.createAppender("ACCESS_LOG"); PatternLayoutEncoder fileEncoder = new PatternLayoutEncoder(); fileEncoder.setContext(valve); fileEncoder.setPattern(props.value(PROPERTY_PATTERN, DEFAULT_SQ_ACCESS_LOG_PATTERN)); fileEncoder.start(); appender.setEncoder(fileEncoder); appender.start(); valve.addAppender(appender); tomcat.getHost().getPipeline().addValve(valve); } }
private static boolean isClusterEnabled(Props props) { return props.valueAsBoolean(CLUSTER_ENABLED); }
boolean inCluster() { return props.valueAsBoolean(ProcessConstants.CLUSTER_ACTIVATE, false); }
boolean isMaster() { return props.valueAsBoolean(ProcessConstants.CLUSTER_MASTER, false); }
public EsSettings(Props props, EsInstallation fileSystem, System2 system2) { this.props = props; this.fileSystem = fileSystem; this.clusterName = props.nonNullValue(CLUSTER_NAME); this.clusterEnabled = props.valueAsBoolean(CLUSTER_ENABLED); if (this.clusterEnabled) { this.nodeName = props.value(CLUSTER_NODE_NAME, "sonarqube-" + UUID.randomUUID().toString()); } else { this.nodeName = STANDALONE_NODE_NAME; } String esJvmOptions = system2.getenv("ES_JVM_OPTIONS"); if (esJvmOptions != null && !esJvmOptions.trim().isEmpty()) { LOGGER.warn("ES_JVM_OPTIONS is defined but will be ignored. " + "Use sonar.search.javaOpts and/or sonar.search.javaAdditionalOpts in sonar.properties to specify jvm options for Elasticsearch"); } }
@Override public void startWatching() { if (settings.getProps().valueAsBoolean(ProcessProperties.ENABLE_STOP_COMMAND)) { start(); } }
public LoggerContext configure() { LoggerContext ctx = helper.getRootContext(); ctx.reset(); helper.enableJulChangePropagation(ctx); configureConsole(ctx); if (helper.isAllLogsToConsoleEnabled(appSettings.getProps()) || !appSettings.getProps().valueAsBoolean("sonar.wrapped", false)) { configureWithLogbackWritingToFile(ctx); } else { configureWithWrapperWritingToFile(ctx); } helper.apply( LogLevelConfig.newBuilder(helper.getRootLoggerName()) .rootLevelFor(ProcessId.APP) .immutableLevel("com.hazelcast", Level.toLevel("WARN")) .build(), appSettings.getProps()); return ctx; }
private static void configureLogbackAccess(Tomcat tomcat, Props props) { if (props.valueAsBoolean(PROPERTY_ENABLE, true)) { ProgrammaticLogbackValve valve = new ProgrammaticLogbackValve(); LogbackHelper helper = new LogbackHelper(); LogbackHelper.RollingPolicy policy = helper.createRollingPolicy(valve, props, "access"); FileAppender appender = policy.createAppender("ACCESS_LOG"); PatternLayoutEncoder fileEncoder = new PatternLayoutEncoder(); fileEncoder.setContext(valve); fileEncoder.setPattern(props.value(PROPERTY_PATTERN, DEFAULT_SQ_ACCESS_LOG_PATTERN)); fileEncoder.start(); appender.setEncoder(fileEncoder); appender.start(); valve.addAppender(appender); tomcat.getHost().getPipeline().addValve(valve); } }
if (props.valueAsBoolean(ProcessProperties.CLUSTER_ENABLED)) { container.add(