This is an automated email from the ASF dual-hosted git repository.
klund pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git
The following commit(s) were added to refs/heads/develop by this push:
new e6d2a6c GEODE-6122: Delete old Logging performance tests
e6d2a6c is described below
commit e6d2a6cd3ef246a471c178dabb45a63dac07f2bf
Author: Kirk Lund <[email protected]>
AuthorDate: Mon Dec 3 15:12:29 2018 -0800
GEODE-6122: Delete old Logging performance tests
The old perf tests are replaced with new JMH benchmarks:
* CacheLoggingBenchmark
* LogWriterAppenderBenchmark
---
.../logging/LogWriterDisabledPerformanceTest.java | 46 -----
.../internal/logging/LogWriterPerformanceTest.java | 105 -----------
.../logging/LoggingPerformanceTestCase.java | 200 ---------------------
.../log4j/Log4J2DisabledPerformanceTest.java | 49 -----
.../logging/log4j/Log4J2PerformanceTest.java | 126 -------------
.../LogWriterLoggerDisabledPerformanceTest.java | 49 -----
.../log4j/LogWriterLoggerPerformanceTest.java | 125 -------------
.../internal/logging/TestLogWriterFactory.java | 133 --------------
8 files changed, 833 deletions(-)
diff --git
a/geode-core/src/performanceTest/java/org/apache/geode/internal/logging/LogWriterDisabledPerformanceTest.java
b/geode-core/src/performanceTest/java/org/apache/geode/internal/logging/LogWriterDisabledPerformanceTest.java
deleted file mode 100644
index 5c084b9..0000000
---
a/geode-core/src/performanceTest/java/org/apache/geode/internal/logging/LogWriterDisabledPerformanceTest.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
contributor license
- * agreements. See the NOTICE file distributed with this work for additional
information regarding
- * copyright ownership. The ASF licenses this file to You under the Apache
License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the
License. You may obtain a
- * copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
distributed under the License
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express
- * or implied. See the License for the specific language governing permissions
and limitations under
- * the License.
- */
-package org.apache.geode.internal.logging;
-
-import org.junit.Ignore;
-import org.junit.experimental.categories.Category;
-
-import org.apache.geode.LogWriter;
-import org.apache.geode.test.junit.categories.LoggingTest;
-import org.apache.geode.test.junit.categories.PerformanceTest;
-
-@Category({PerformanceTest.class, LoggingTest.class})
-@Ignore("TODO: repackage as jmh benchmark")
-public class LogWriterDisabledPerformanceTest extends LogWriterPerformanceTest
{
-
- @Override
- protected PerformanceLogger createPerformanceLogger() {
- final LogWriter logWriter = createLogWriter();
-
- final PerformanceLogger perfLogger = new PerformanceLogger() {
- @Override
- public void log(final String message) {
- logWriter.fine(message);
- }
-
- @Override
- public boolean isEnabled() {
- return logWriter.fineEnabled();
- }
- };
-
- return perfLogger;
- }
-}
diff --git
a/geode-core/src/performanceTest/java/org/apache/geode/internal/logging/LogWriterPerformanceTest.java
b/geode-core/src/performanceTest/java/org/apache/geode/internal/logging/LogWriterPerformanceTest.java
deleted file mode 100644
index 922d891..0000000
---
a/geode-core/src/performanceTest/java/org/apache/geode/internal/logging/LogWriterPerformanceTest.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
contributor license
- * agreements. See the NOTICE file distributed with this work for additional
information regarding
- * copyright ownership. The ASF licenses this file to You under the Apache
License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the
License. You may obtain a
- * copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
distributed under the License
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express
- * or implied. See the License for the specific language governing permissions
and limitations under
- * the License.
- */
-package org.apache.geode.internal.logging;
-
-import static org.apache.geode.distributed.ConfigurationProperties.LOG_FILE;
-import static org.apache.geode.distributed.ConfigurationProperties.LOG_LEVEL;
-import static org.junit.Assert.assertTrue;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.util.Properties;
-
-import org.junit.Ignore;
-import org.junit.experimental.categories.Category;
-
-import org.apache.geode.LogWriter;
-import org.apache.geode.distributed.internal.DistributionConfig;
-import org.apache.geode.distributed.internal.DistributionConfigImpl;
-import org.apache.geode.internal.util.IOUtils;
-import org.apache.geode.test.junit.categories.LoggingTest;
-import org.apache.geode.test.junit.categories.PerformanceTest;
-
-/**
- * Tests performance of logging when level is OFF.
- */
-@Category({PerformanceTest.class, LoggingTest.class})
-@Ignore("TODO: repackage as jmh benchmark")
-public class LogWriterPerformanceTest extends LoggingPerformanceTestCase {
-
- private Properties createGemFireProperties() {
- final Properties props = new Properties();
- logFile = new File(configDirectory, DistributionConfig.GEMFIRE_PREFIX +
"log");
- final String logFilePath =
IOUtils.tryGetCanonicalPathElseGetAbsolutePath(logFile);
- props.setProperty(LOG_FILE, logFilePath);
- props.setProperty(LOG_LEVEL, "info");
- return props;
- }
-
- protected void writeProperties(final Properties props, final File file)
throws IOException {
- final FileOutputStream out = new FileOutputStream(file);
- try {
- props.store(out, null);
- } finally {
- out.close();
- }
- }
-
- protected LogWriter createLogWriter() {
- final Properties props = createGemFireProperties();
-
- // create configuration with log-file and log-level
- // this.configDirectory = new File(getUniqueName());
-
- configDirectory.mkdir();
- assertTrue(configDirectory.isDirectory() && configDirectory.canWrite());
-
- // this.gemfireProperties = new File(this.configDirectory,
"gemfire.properties");
- // writeProperties(props, this.gemfireProperties);
-
- final DistributionConfig config = new DistributionConfigImpl(props, false,
false);
-
- // create a LogWriter that writes to log-file
- final boolean appendToFile = false;
- final boolean isLoner = true;
- final boolean isSecurityLog = false;
- final boolean logConfig = true;
- final FileOutputStream[] fosHolder = null;
-
- final LogWriter logWriter =
TestLogWriterFactory.createLogWriter(appendToFile, isLoner,
- isSecurityLog, config, logConfig, fosHolder);
- return logWriter;
- }
-
- @Override
- protected PerformanceLogger createPerformanceLogger() {
- final LogWriter logWriter = createLogWriter();
-
- final PerformanceLogger perfLogger = new PerformanceLogger() {
- @Override
- public void log(final String message) {
- logWriter.info(message);
- }
-
- @Override
- public boolean isEnabled() {
- return logWriter.infoEnabled();
- }
- };
-
- return perfLogger;
- }
-}
diff --git
a/geode-core/src/performanceTest/java/org/apache/geode/internal/logging/LoggingPerformanceTestCase.java
b/geode-core/src/performanceTest/java/org/apache/geode/internal/logging/LoggingPerformanceTestCase.java
deleted file mode 100644
index 23b0897..0000000
---
a/geode-core/src/performanceTest/java/org/apache/geode/internal/logging/LoggingPerformanceTestCase.java
+++ /dev/null
@@ -1,200 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
contributor license
- * agreements. See the NOTICE file distributed with this work for additional
information regarding
- * copyright ownership. The ASF licenses this file to You under the Apache
License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the
License. You may obtain a
- * copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
distributed under the License
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express
- * or implied. See the License for the specific language governing permissions
and limitations under
- * the License.
- */
-package org.apache.geode.internal.logging;
-
-import static org.junit.Assert.assertTrue;
-
-import java.io.File;
-import java.io.IOException;
-
-import org.junit.After;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TestName;
-
-import org.apache.geode.distributed.internal.DistributionConfig;
-import org.apache.geode.internal.util.StopWatch;
-
-/**
- * Tests performance of logging when level is OFF.
- */
-public abstract class LoggingPerformanceTestCase {
-
- protected static final boolean TIME_BASED = Boolean
- .getBoolean(DistributionConfig.GEMFIRE_PREFIX +
"test.LoggingPerformanceTestCase.TIME_BASED");
- protected static final long TIME_TO_RUN = 1000 * 60 * 10; // ten minutes
- protected static final int LOG_SETS = 1000;
- protected static final int LOG_REPETITIONS_PER_SET = 1000;
- protected static final String message = "This is a log message";
-
- protected File configDirectory = new File(getUniqueName());// null;
- protected File logFile = new File(configDirectory, getUniqueName() + ".log");
-
- @Rule
- public TestName testName = new TestName();
-
- @After
- public void tearDownLoggingPerformanceTestCase() throws Exception {
- this.configDirectory = null; // leave this directory in place for now
- }
-
- protected String getUniqueName() {
- return getClass().getSimpleName() + "_" + testName.getMethodName();
- }
-
- protected long performLoggingTest(final PerformanceLogger perfLogger) {
- if (TIME_BASED) {
- return performTimeBasedLoggingTest(perfLogger);
- } else {
- return performCountBasedLoggingTest(perfLogger);
- }
- }
-
- protected long performIsEnabledTest(final PerformanceLogger perfLogger) {
- if (TIME_BASED) {
- return performTimeBasedIsEnabledTest(perfLogger);
- } else {
- return performCountBasedIsEnabledTest(perfLogger);
- }
- }
-
- protected long performTimeBasedLoggingTest(final PerformanceLogger
perfLogger) {
- System.out.println("\nBeginning " + getUniqueName());
-
- final StopWatch stopWatch = new StopWatch(true);
- long count = 0;
- while (stopWatch.elapsedTimeMillis() < TIME_TO_RUN) {
- perfLogger.log(message);
- count++;
- }
- stopWatch.stop();
-
- final long millis = stopWatch.elapsedTimeMillis();
- final long seconds = millis / 1000;
- final long minutes = seconds / 60;
-
- System.out.println(getUniqueName() + " performTimeBasedLoggingTest");
- System.out.println("Number of log statements: " + count);
- System.out.println("Total elapsed time in millis: " + millis);
- System.out.println("Total elapsed time in seconds: " + seconds);
- System.out.println("Total elapsed time in minutes: " + minutes);
-
- return millis;
- }
-
- protected long performCountBasedLoggingTest(final PerformanceLogger
perfLogger) {
- System.out.println("\nBeginning " + getUniqueName());
-
- final StopWatch stopWatch = new StopWatch(true);
- for (int sets = 0; sets < LOG_SETS; sets++) {
- for (int count = 0; count < LOG_REPETITIONS_PER_SET; count++) {
- perfLogger.log(message);
- }
- }
- stopWatch.stop();
-
- final long millis = stopWatch.elapsedTimeMillis();
- final long seconds = millis / 1000;
- final long minutes = seconds / 60;
-
- System.out.println(getUniqueName() + " performCountBasedLoggingTest");
- System.out.println("Number of log statements: " + LOG_SETS *
LOG_REPETITIONS_PER_SET);
- System.out.println("Total elapsed time in millis: " + millis);
- System.out.println("Total elapsed time in seconds: " + seconds);
- System.out.println("Total elapsed time in minutes: " + minutes);
-
- return millis;
- }
-
- protected long performTimeBasedIsEnabledTest(final PerformanceLogger
perfLogger) {
- System.out.println("\nBeginning " + getUniqueName());
-
- final StopWatch stopWatch = new StopWatch(true);
- long count = 0;
- while (stopWatch.elapsedTimeMillis() < TIME_TO_RUN) {
- perfLogger.isEnabled();
- count++;
- }
- stopWatch.stop();
-
- final long millis = stopWatch.elapsedTimeMillis();
- final long seconds = millis / 1000;
- final long minutes = seconds / 60;
-
- System.out.println(getUniqueName() + " performTimeBasedIsEnabledTest");
- System.out.println("Number of isEnabled statements: " + count);
- System.out.println("Total elapsed time in millis: " + millis);
- System.out.println("Total elapsed time in seconds: " + seconds);
- System.out.println("Total elapsed time in minutes: " + minutes);
-
- return millis;
- }
-
- protected long performCountBasedIsEnabledTest(final PerformanceLogger
perfLogger) {
- System.out.println("\nBeginning " + getUniqueName());
-
- final StopWatch stopWatch = new StopWatch(true);
- for (int sets = 0; sets < LOG_SETS; sets++) {
- for (int count = 0; count < LOG_REPETITIONS_PER_SET; count++) {
- perfLogger.isEnabled();
- }
- }
- stopWatch.stop();
-
- final long millis = stopWatch.elapsedTimeMillis();
- final long seconds = millis / 1000;
- final long minutes = seconds / 60;
-
- System.out.println(getUniqueName() + " performCountBasedIsEnabledTest");
- System.out.println("Number of isEnabled statements: " + LOG_SETS *
LOG_REPETITIONS_PER_SET);
- System.out.println("Total elapsed time in millis: " + millis);
- System.out.println("Total elapsed time in seconds: " + seconds);
- System.out.println("Total elapsed time in minutes: " + minutes);
-
- return millis;
- }
-
- protected abstract PerformanceLogger createPerformanceLogger() throws
IOException;
-
- @Test
- public void testCountBasedLogging() throws Exception {
- performCountBasedLoggingTest(createPerformanceLogger());
- assertTrue(this.logFile.exists());
- }
-
- @Test
- public void testTimeBasedLogging() throws Exception {
- performTimeBasedLoggingTest(createPerformanceLogger());
- assertTrue(this.logFile.exists());
- }
-
- @Test
- public void testCountBasedIsEnabled() throws Exception {
- performCountBasedIsEnabledTest(createPerformanceLogger());
- assertTrue(this.logFile.exists());
- }
-
- @Test
- public void testTimeBasedIsEnabled() throws Exception {
- performTimeBasedIsEnabledTest(createPerformanceLogger());
- assertTrue(this.logFile.exists());
- }
-
- public static interface PerformanceLogger {
- public void log(final String message);
-
- public boolean isEnabled();
- }
-}
diff --git
a/geode-core/src/performanceTest/java/org/apache/geode/internal/logging/log4j/Log4J2DisabledPerformanceTest.java
b/geode-core/src/performanceTest/java/org/apache/geode/internal/logging/log4j/Log4J2DisabledPerformanceTest.java
deleted file mode 100644
index f89ca87..0000000
---
a/geode-core/src/performanceTest/java/org/apache/geode/internal/logging/log4j/Log4J2DisabledPerformanceTest.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
contributor license
- * agreements. See the NOTICE file distributed with this work for additional
information regarding
- * copyright ownership. The ASF licenses this file to You under the Apache
License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the
License. You may obtain a
- * copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
distributed under the License
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express
- * or implied. See the License for the specific language governing permissions
and limitations under
- * the License.
- */
-package org.apache.geode.internal.logging.log4j;
-
-import java.io.IOException;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.Logger;
-import org.junit.Ignore;
-import org.junit.experimental.categories.Category;
-
-import org.apache.geode.test.junit.categories.LoggingTest;
-import org.apache.geode.test.junit.categories.PerformanceTest;
-
-@Category({PerformanceTest.class, LoggingTest.class})
-@Ignore("TODO: repackage as jmh benchmark")
-public class Log4J2DisabledPerformanceTest extends Log4J2PerformanceTest {
-
- @Override
- protected PerformanceLogger createPerformanceLogger() throws IOException {
- final Logger logger = createLogger();
-
- final PerformanceLogger perfLogger = new PerformanceLogger() {
- @Override
- public void log(String message) {
- logger.debug(message);
- }
-
- @Override
- public boolean isEnabled() {
- return logger.isEnabled(Level.DEBUG);
- }
- };
-
- return perfLogger;
- }
-}
diff --git
a/geode-core/src/performanceTest/java/org/apache/geode/internal/logging/log4j/Log4J2PerformanceTest.java
b/geode-core/src/performanceTest/java/org/apache/geode/internal/logging/log4j/Log4J2PerformanceTest.java
deleted file mode 100644
index cd873ca..0000000
---
a/geode-core/src/performanceTest/java/org/apache/geode/internal/logging/log4j/Log4J2PerformanceTest.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
contributor license
- * agreements. See the NOTICE file distributed with this work for additional
information regarding
- * copyright ownership. The ASF licenses this file to You under the Apache
License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the
License. You may obtain a
- * copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
distributed under the License
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express
- * or implied. See the License for the specific language governing permissions
and limitations under
- * the License.
- */
-package org.apache.geode.internal.logging.log4j;
-
-import static org.junit.Assert.assertTrue;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URL;
-
-import org.apache.commons.io.FileUtils;
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.config.ConfigurationFactory;
-import org.junit.After;
-import org.junit.Ignore;
-import org.junit.experimental.categories.Category;
-
-import org.apache.geode.distributed.internal.DistributionConfig;
-import org.apache.geode.internal.logging.LoggingPerformanceTestCase;
-import org.apache.geode.internal.util.IOUtils;
-import org.apache.geode.test.junit.categories.LoggingTest;
-import org.apache.geode.test.junit.categories.PerformanceTest;
-
-@Category({PerformanceTest.class, LoggingTest.class})
-@Ignore("TODO: repackage as jmh benchmark")
-public class Log4J2PerformanceTest extends LoggingPerformanceTestCase {
-
- private static final int DEFAULT_LOG_FILE_SIZE_LIMIT = Integer.MAX_VALUE;
- private static final int DEFAULT_LOG_FILE_COUNT_LIMIT = 20;
-
- private static final String SYS_LOG_FILE = "gemfire-log-file";
- private static final String SYS_LOG_FILE_SIZE_LIMIT =
"gemfire-log-file-size-limit";
- private static final String SYS_LOG_FILE_COUNT_LIMIT =
"gemfire-log-file-count-limit";
-
- private File config;
-
- @After
- public void tearDownLog4J2PerformanceTest() {
- config = null; // leave this file in place for now
- }
-
- private void setPropertySubstitutionValues(final String logFile, final int
logFileSizeLimitMB,
- final int logFileCountLimit) {
- if (logFileSizeLimitMB < 0) {
- throw new IllegalArgumentException("logFileSizeLimitMB must be zero or
positive integer");
- }
- if (logFileCountLimit < 0) {
- throw new IllegalArgumentException("logFileCountLimit must be zero or
positive integer");
- }
-
- // flip \ to / if any exist
- final String logFileValue = logFile.replace("\\", "/");
- // append MB
- final String logFileSizeLimitMBValue =
- new StringBuilder(String.valueOf(logFileSizeLimitMB)).append("
MB").toString();
- final String logFileCountLimitValue =
- new StringBuilder(String.valueOf(logFileCountLimit)).toString();
-
- System.setProperty(SYS_LOG_FILE, logFileValue);
- System.setProperty(SYS_LOG_FILE_SIZE_LIMIT, logFileSizeLimitMBValue);
- System.setProperty(SYS_LOG_FILE_COUNT_LIMIT, logFileCountLimitValue);
- }
-
- Logger createLogger() throws IOException {
- // create configuration with log-file and log-level
- configDirectory = new File(getUniqueName());
- configDirectory.mkdir();
- assertTrue(configDirectory.isDirectory() && configDirectory.canWrite());
-
- // copy the log4j2-test.xml to the configDirectory
- // final URL srcURL =
- //
getClass().getResource("/org/apache/geode/internal/logging/log4j/log4j2-test.xml");
- final URL srcURL = getClass().getResource("log4j2-test.xml");
- final File src = new File(srcURL.getFile());
- FileUtils.copyFileToDirectory(src, configDirectory);
- config = new File(configDirectory, "log4j2-test.xml");
- assertTrue(config.exists());
-
- logFile = new File(configDirectory, DistributionConfig.GEMFIRE_PREFIX +
"log");
- final String logFilePath =
IOUtils.tryGetCanonicalPathElseGetAbsolutePath(logFile);
- final String logFileName =
- logFilePath.substring(0, logFilePath.lastIndexOf(File.separatorChar));
- setPropertySubstitutionValues(logFileName, DEFAULT_LOG_FILE_SIZE_LIMIT,
- DEFAULT_LOG_FILE_COUNT_LIMIT);
-
- final String configPath =
- "file://" + IOUtils.tryGetCanonicalPathElseGetAbsolutePath(config);
- System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY,
configPath);
-
- final Logger logger = LogManager.getLogger();
- return logger;
- }
-
- @Override
- protected PerformanceLogger createPerformanceLogger() throws IOException {
- final Logger logger = createLogger();
-
- final PerformanceLogger perfLogger = new PerformanceLogger() {
- @Override
- public void log(String message) {
- logger.info(message);
- }
-
- @Override
- public boolean isEnabled() {
- return logger.isEnabled(Level.INFO);
- }
- };
-
- return perfLogger;
- }
-}
diff --git
a/geode-core/src/performanceTest/java/org/apache/geode/internal/logging/log4j/LogWriterLoggerDisabledPerformanceTest.java
b/geode-core/src/performanceTest/java/org/apache/geode/internal/logging/log4j/LogWriterLoggerDisabledPerformanceTest.java
deleted file mode 100644
index e432ed5..0000000
---
a/geode-core/src/performanceTest/java/org/apache/geode/internal/logging/log4j/LogWriterLoggerDisabledPerformanceTest.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
contributor license
- * agreements. See the NOTICE file distributed with this work for additional
information regarding
- * copyright ownership. The ASF licenses this file to You under the Apache
License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the
License. You may obtain a
- * copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
distributed under the License
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express
- * or implied. See the License for the specific language governing permissions
and limitations under
- * the License.
- */
-package org.apache.geode.internal.logging.log4j;
-
-import java.io.IOException;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.Logger;
-import org.junit.Ignore;
-import org.junit.experimental.categories.Category;
-
-import org.apache.geode.test.junit.categories.LoggingTest;
-import org.apache.geode.test.junit.categories.PerformanceTest;
-
-@Category({PerformanceTest.class, LoggingTest.class})
-@Ignore("TODO: repackage as jmh benchmark")
-public class LogWriterLoggerDisabledPerformanceTest extends
LogWriterLoggerPerformanceTest {
-
- @Override
- protected PerformanceLogger createPerformanceLogger() throws IOException {
- final Logger logger = createLogger();
-
- final PerformanceLogger perfLogger = new PerformanceLogger() {
- @Override
- public void log(String message) {
- logger.debug(message);
- }
-
- @Override
- public boolean isEnabled() {
- return logger.isEnabled(Level.DEBUG);
- }
- };
-
- return perfLogger;
- }
-}
diff --git
a/geode-core/src/performanceTest/java/org/apache/geode/internal/logging/log4j/LogWriterLoggerPerformanceTest.java
b/geode-core/src/performanceTest/java/org/apache/geode/internal/logging/log4j/LogWriterLoggerPerformanceTest.java
deleted file mode 100644
index 3f94657..0000000
---
a/geode-core/src/performanceTest/java/org/apache/geode/internal/logging/log4j/LogWriterLoggerPerformanceTest.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
contributor license
- * agreements. See the NOTICE file distributed with this work for additional
information regarding
- * copyright ownership. The ASF licenses this file to You under the Apache
License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the
License. You may obtain a
- * copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
distributed under the License
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express
- * or implied. See the License for the specific language governing permissions
and limitations under
- * the License.
- */
-package org.apache.geode.internal.logging.log4j;
-
-import static org.junit.Assert.assertTrue;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URL;
-
-import org.apache.commons.io.FileUtils;
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.config.ConfigurationFactory;
-import org.junit.After;
-import org.junit.Ignore;
-import org.junit.experimental.categories.Category;
-
-import org.apache.geode.distributed.internal.DistributionConfig;
-import org.apache.geode.internal.logging.LoggingPerformanceTestCase;
-import org.apache.geode.internal.util.IOUtils;
-import org.apache.geode.test.junit.categories.LoggingTest;
-import org.apache.geode.test.junit.categories.PerformanceTest;
-
-@Category({PerformanceTest.class, LoggingTest.class})
-@Ignore("TODO: repackage as jmh benchmark")
-public class LogWriterLoggerPerformanceTest extends LoggingPerformanceTestCase
{
-
- private static final int DEFAULT_LOG_FILE_SIZE_LIMIT = Integer.MAX_VALUE;
- private static final int DEFAULT_LOG_FILE_COUNT_LIMIT = 20;
-
- private static final String SYS_LOG_FILE = "gemfire-log-file";
- private static final String SYS_LOG_FILE_SIZE_LIMIT =
"gemfire-log-file-size-limit";
- private static final String SYS_LOG_FILE_COUNT_LIMIT =
"gemfire-log-file-count-limit";
-
- private File config;
-
- @After
- public void tearDownLogWriterLoggerPerformanceTest() {
- config = null; // leave this file in place for now
- }
-
- private void setPropertySubstitutionValues(final String logFile, final int
logFileSizeLimitMB,
- final int logFileCountLimit) {
- if (logFileSizeLimitMB < 0) {
- throw new IllegalArgumentException("logFileSizeLimitMB must be zero or
positive integer");
- }
- if (logFileCountLimit < 0) {
- throw new IllegalArgumentException("logFileCountLimit must be zero or
positive integer");
- }
-
- // flip \ to / if any exist
- final String logFileValue = logFile.replace("\\", "/");
- // append MB
- final String logFileSizeLimitMBValue =
- new StringBuilder(String.valueOf(logFileSizeLimitMB)).append("
MB").toString();
- final String logFileCountLimitValue =
- new StringBuilder(String.valueOf(logFileCountLimit)).toString();
-
- System.setProperty(SYS_LOG_FILE, logFileValue);
- System.setProperty(SYS_LOG_FILE_SIZE_LIMIT, logFileSizeLimitMBValue);
- System.setProperty(SYS_LOG_FILE_COUNT_LIMIT, logFileCountLimitValue);
- }
-
- Logger createLogger() throws IOException {
- // create configuration with log-file and log-level
- configDirectory = new File(getUniqueName());
- configDirectory.mkdir();
- assertTrue(configDirectory.isDirectory() && configDirectory.canWrite());
-
- // copy the log4j2-test.xml to the configDirectory
- // final URL srcURL =
- //
getClass().getResource("/org/apache/geode/internal/logging/log4j/log4j2-test.xml");
- final URL srcURL = getClass().getResource("log4j2-test.xml");
- final File src = new File(srcURL.getFile());
- FileUtils.copyFileToDirectory(src, configDirectory);
- config = new File(configDirectory, "log4j2-test.xml");
- assertTrue(config.exists());
-
- logFile = new File(configDirectory, DistributionConfig.GEMFIRE_PREFIX +
"log");
- final String logFilePath =
IOUtils.tryGetCanonicalPathElseGetAbsolutePath(logFile);
- final String logFileName =
- logFilePath.substring(0, logFilePath.lastIndexOf(File.separatorChar));
- setPropertySubstitutionValues(logFileName, DEFAULT_LOG_FILE_SIZE_LIMIT,
- DEFAULT_LOG_FILE_COUNT_LIMIT);
-
- final String configPath =
- "file://" + IOUtils.tryGetCanonicalPathElseGetAbsolutePath(config);
- System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY,
configPath);
-
- final Logger logger = LogWriterLogger.create(getClass().getName(), false);
- return logger;
- }
-
- @Override
- protected PerformanceLogger createPerformanceLogger() throws IOException {
- final Logger logger = createLogger();
-
- final PerformanceLogger perfLogger = new PerformanceLogger() {
- @Override
- public void log(String message) {
- logger.info(message);
- }
-
- @Override
- public boolean isEnabled() {
- return logger.isEnabled(Level.INFO);
- }
- };
-
- return perfLogger;
- }
-}
diff --git
a/geode-junit/src/main/java/org/apache/geode/internal/logging/TestLogWriterFactory.java
b/geode-junit/src/main/java/org/apache/geode/internal/logging/TestLogWriterFactory.java
deleted file mode 100644
index daee34d..0000000
---
a/geode-junit/src/main/java/org/apache/geode/internal/logging/TestLogWriterFactory.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
contributor license
- * agreements. See the NOTICE file distributed with this work for additional
information regarding
- * copyright ownership. The ASF licenses this file to You under the Apache
License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the
License. You may obtain a
- * copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
distributed under the License
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express
- * or implied. See the License for the specific language governing permissions
and limitations under
- * the License.
- */
-package org.apache.geode.internal.logging;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.PrintStream;
-
-import org.junit.Assert;
-
-import org.apache.geode.GemFireIOException;
-import org.apache.geode.LogWriter;
-import org.apache.geode.distributed.internal.DistributionConfig;
-import org.apache.geode.distributed.internal.InternalLocator;
-import org.apache.geode.internal.OSProcess;
-import org.apache.geode.internal.process.ProcessLauncherContext;
-import org.apache.geode.internal.util.LogFileUtils;
-
-/**
- * Creates LogWriter instances for testing.
- */
-public class TestLogWriterFactory extends Assert {
-
- public static LogWriter createLogWriter(final boolean appendToFile, final
boolean isLoner,
- final boolean isSecurityLog, final DistributionConfig config, final
boolean logConfig,
- final FileOutputStream[] FOSHolder) {
-
- assertFalse(isSecurityLog);
- LogWriter logger = null;
- File logFile = config.getLogFile();
- assertNotNull(logFile);
- PrintStream out;
- String firstMsg = null;
- boolean firstMsgWarning = false;
-
- LogWriter mlw = null;
-
- if (logFile == null || logFile.equals(new File(""))) {
- out = System.out;
- } else {
- if (logFile.exists()) {
- boolean useChildLogging = config.getLogFile() != null
- && !config.getLogFile().equals(new File("")) &&
config.getLogFileSizeLimit() != 0;
- boolean statArchivesRolling = config.getStatisticArchiveFile() != null
- && !config.getStatisticArchiveFile().equals(new File(""))
- && config.getArchiveFileSizeLimit() != 0 &&
config.getStatisticSamplingEnabled();
- if (!appendToFile || useChildLogging || statArchivesRolling) { //
check useChildLogging for
- // bug
50659
- File oldMain = ManagerLogWriter.getLogNameForOldMainLog(logFile,
- isSecurityLog || useChildLogging || statArchivesRolling);
- boolean succeeded = LogFileUtils.renameAggressively(logFile,
oldMain);
- if (succeeded) {
- firstMsg = String.format("Renamed old log file to %s.",
- oldMain);
- } else {
- firstMsgWarning = true;
- firstMsg = String.format("Could not rename %s to %s.",
- logFile, oldMain);
- }
- }
- }
-
- FileOutputStream fos;
- try {
- fos = new FileOutputStream(logFile, true);
- } catch (FileNotFoundException ex) {
- String s = String.format("Could not open log file %s.",
- logFile);
- throw new GemFireIOException(s, ex);
- }
- out = new PrintStream(fos);
- if (FOSHolder != null) {
- FOSHolder[0] = fos;
- }
-
- if (isSecurityLog) {
- mlw =
- new SecurityManagerLogWriter(config.getSecurityLogLevel(), out,
config.getName(), true);
- } else {
- mlw = new ManagerLogWriter(config.getLogLevel(), out,
config.getName(), true);
- }
- ((ManagerLogWriter) mlw).setConfig(config);
- }
-
- if (mlw.infoEnabled()) {
- if (!isLoner || /* do this on a loner to fix bug 35602 */
- !Boolean.getBoolean(InternalLocator.INHIBIT_DM_BANNER)) {
- mlw.info(new Banner().getString(null));
- }
- }
- logger = mlw;
-
- if (firstMsg != null) {
- if (firstMsgWarning) {
- logger.warning(firstMsg);
- } else {
- logger.info(firstMsg);
- }
- }
- if (logConfig && logger.configEnabled()) {
- logger.config(
- "Startup Configuration: " +
- config.toLoggerString());
- }
-
- // fix #46493 by moving redirectOutput invocation here
- if (ProcessLauncherContext.isRedirectingOutput()) {
- try {
- OSProcess.redirectOutput(config.getLogFile());
- } catch (IOException e) {
- logger.error(e);
- // throw new GemFireIOException("Unable to redirect output to " +
config.getLogFile(), e);
- }
- }
-
- return logger;
- }
-
-}