提交 3bef3a7f 编写于 作者: C Chesnay Schepler

[FLINK-16808][e2e] Consolidated logging

上级 e0333a41
......@@ -18,18 +18,13 @@
package org.apache.flink.tests.util.kafka;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* A {@link KafkaResourceFactory} for the {@link LocalStandaloneKafkaResourceFactory}.
*/
public final class LocalStandaloneKafkaResourceFactory implements KafkaResourceFactory {
private static final Logger LOG = LoggerFactory.getLogger(LocalStandaloneKafkaResourceFactory.class);
@Override
public KafkaResource create(final String kafkaVersion) {
LOG.info("Created {}.", LocalStandaloneKafkaResource.class.getSimpleName());
return new LocalStandaloneKafkaResource(kafkaVersion);
}
}
......@@ -19,8 +19,6 @@
package org.apache.flink.tests.util.cache;
import org.junit.rules.TemporaryFolder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
......@@ -28,13 +26,11 @@ import java.io.IOException;
* A {@link DownloadCacheFactory} for the {@link LolCache}.
*/
public final class LolCacheFactory implements DownloadCacheFactory {
private static final Logger LOG = LoggerFactory.getLogger(LolCacheFactory.class);
@Override
public DownloadCache create() throws IOException {
final TemporaryFolder folder = new TemporaryFolder();
folder.create();
LOG.info("Created {}.", LolCache.class.getSimpleName());
return new LolCache(folder);
}
}
......@@ -20,9 +20,6 @@ package org.apache.flink.tests.util.cache;
import org.apache.flink.tests.util.parameters.ParameterProperty;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.time.Period;
......@@ -32,7 +29,6 @@ import java.util.Optional;
* A {@link DownloadCacheFactory} for the {@link PersistingDownloadCache}.
*/
public final class PersistingDownloadCacheFactory implements DownloadCacheFactory {
private static final Logger LOG = LoggerFactory.getLogger(PersistingDownloadCacheFactory.class);
private static final ParameterProperty<Path> TMP_DIR = new ParameterProperty<>("cache-dir", value -> Paths.get(value));
private static final ParameterProperty<Period> TIME_TO_LIVE = new ParameterProperty<>("cache-ttl", Period::parse);
......@@ -44,10 +40,8 @@ public final class PersistingDownloadCacheFactory implements DownloadCacheFactor
final Optional<Path> tmpDir = TMP_DIR.get();
final Period timeToLive = TIME_TO_LIVE.get(TIME_TO_LIVE_DEFAULT);
if (!tmpDir.isPresent()) {
LOG.debug("Not loading {} because {} was not set.", PersistingDownloadCache.class, TMP_DIR.getPropertyName());
throw new IllegalArgumentException(String.format("Not loading %s because %s was not set.", PersistingDownloadCache.class, TMP_DIR.getPropertyName()));
}
LOG.info("Created {}.", PersistingDownloadCache.class.getSimpleName());
return new PersistingDownloadCache(tmpDir.get(), timeToLive);
}
}
......@@ -20,9 +20,6 @@ package org.apache.flink.tests.util.cache;
import org.apache.flink.tests.util.parameters.ParameterProperty;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Optional;
......@@ -31,7 +28,6 @@ import java.util.Optional;
* A {@link DownloadCacheFactory} for the {@link TravisDownloadCache}.
*/
public final class TravisDownloadCacheFactory implements DownloadCacheFactory {
private static final Logger LOG = LoggerFactory.getLogger(TravisDownloadCacheFactory.class);
private static final ParameterProperty<Path> TMP_DIR = new ParameterProperty<>("cache-dir", value -> Paths.get(value));
private static final ParameterProperty<Integer> BUILDS_TO_LIVE = new ParameterProperty<>("cache-btl", Integer::parseInt);
......@@ -43,18 +39,14 @@ public final class TravisDownloadCacheFactory implements DownloadCacheFactory {
final Optional<Integer> timeToLive = BUILDS_TO_LIVE.get();
final Optional<Integer> buildNumber = BUILD_NUMBER.get();
if (!tmpDir.isPresent()) {
LOG.debug("Not loading {} because {} was not set.", TravisDownloadCache.class, TMP_DIR.getPropertyName());
throw new IllegalArgumentException(String.format("Not loading %s because %s was not set.", TravisDownloadCache.class, TMP_DIR.getPropertyName()));
}
if (!timeToLive.isPresent()) {
LOG.debug("Not loading {} because {} was not set.", TravisDownloadCache.class, BUILDS_TO_LIVE.getPropertyName());
throw new IllegalArgumentException(String.format("Not loading %s because %s was not set.", TravisDownloadCache.class, BUILDS_TO_LIVE.getPropertyName()));
}
if (!buildNumber.isPresent()) {
LOG.debug("Not loading {} because {} was not set.", TravisDownloadCache.class, BUILD_NUMBER.getPropertyName());
throw new IllegalArgumentException(String.format("Not loading %s because %s was not set.", TravisDownloadCache.class, BUILD_NUMBER.getPropertyName()));
}
LOG.info("Created {}.", TravisDownloadCache.class.getSimpleName());
return new TravisDownloadCache(tmpDir.get(), timeToLive.get(), buildNumber.get());
}
}
......@@ -40,14 +40,12 @@ public final class LocalStandaloneFlinkResourceFactory implements FlinkResourceF
public FlinkResource create(FlinkResourceSetup setup) {
Optional<Path> distributionDirectory = DISTRIBUTION_DIRECTORY.get();
if (!distributionDirectory.isPresent()) {
LOG.warn("The distDir property was not set. You can set it when running maven via -DdistDir=<path> .");
throw new IllegalArgumentException("The distDir property was not set. You can set it when running maven via -DdistDir=<path> .");
}
Optional<Path> logBackupDirectory = DISTRIBUTION_LOG_BACKUP_DIRECTORY.get();
if (!logBackupDirectory.isPresent()) {
LOG.warn("Property {} not set, logs will not be backed up in case of test failures.", DISTRIBUTION_LOG_BACKUP_DIRECTORY.getPropertyName());
}
LOG.info("Created {}.", LocalStandaloneFlinkResource.class.getSimpleName());
return new LocalStandaloneFlinkResource(distributionDirectory.get(), logBackupDirectory.orElse(null), setup);
}
}
......@@ -18,6 +18,9 @@
package org.apache.flink.tests.util.util;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.List;
import java.util.ServiceLoader;
......@@ -29,6 +32,8 @@ import java.util.function.Supplier;
public enum FactoryUtils {
;
private static final Logger LOG = LoggerFactory.getLogger(FactoryUtils.class);
/**
* Loads all factories for the given class using the {@link ServiceLoader} and attempts to create an instance.
*
......@@ -49,7 +54,9 @@ public enum FactoryUtils {
try {
R resource = factoryInvoker.invoke(factory);
instantiatedResources.add(resource);
LOG.info("Instantiated {}.", resource.getClass().getSimpleName());
} catch (Exception e) {
LOG.debug("Factory {} could not instantiate instance.", factory.getClass().getSimpleName(), e);
errorsDuringInitialization.add(e);
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册