Commit
DRILL-3496: Update: Multiple log msgs. -> single, aligned multi-line message. Main: Changed avoidance of original single hard-to-read list from first draft's multiple single-item log calls (resulting in multiple log calls/entries) to single log call with aligned multi-line message. Also revised message wording, etc. DRILL-3496: Update 2: Some DEBUG -> INFO; another single multi-line msg. - logger.debug(...) -> logger.info(...) for config. file messages - changed drill-module.conf to single multi-line message like scanForImplementations cases DRILL-3496: Update 3: Various review comment responses. - Removed isTraceEnabled/etc. guards. - Simplified logging line break/indentation code. - Added some more "final". - Undid logger cleanup. :-(
- Loading branch information
There are no files selected for viewing
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
|
@@ -34,22 +34,21 @@ | ||
import org.apache.drill.common.logical.data.LogicalOperatorBase; | import org.apache.drill.common.logical.data.LogicalOperatorBase; | ||
import org.apache.drill.common.util.PathScanner; | import org.apache.drill.common.util.PathScanner; | ||
import org.reflections.util.ClasspathHelper; | import org.reflections.util.ClasspathHelper; | ||
import org.slf4j.Logger; | |||
import static org.slf4j.LoggerFactory.getLogger; | |||
|
|
||
import com.fasterxml.jackson.core.JsonGenerator; | import com.fasterxml.jackson.core.JsonGenerator; | ||
import com.fasterxml.jackson.core.JsonParser.Feature; | import com.fasterxml.jackson.core.JsonParser.Feature; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.fasterxml.jackson.databind.SerializationFeature; | import com.fasterxml.jackson.databind.SerializationFeature; | ||
import com.fasterxml.jackson.databind.module.SimpleModule; | import com.fasterxml.jackson.databind.module.SimpleModule; | ||
import com.google.common.annotations.VisibleForTesting; | import com.google.common.annotations.VisibleForTesting; | ||
import com.google.common.base.Joiner; | |||
import com.google.common.collect.ImmutableList; | import com.google.common.collect.ImmutableList; | ||
import com.typesafe.config.Config; | import com.typesafe.config.Config; | ||
import com.typesafe.config.ConfigFactory; | import com.typesafe.config.ConfigFactory; | ||
import com.typesafe.config.ConfigRenderOptions; | import com.typesafe.config.ConfigRenderOptions; | ||
|
|
||
public final class DrillConfig extends NestedConfig{ | public final class DrillConfig extends NestedConfig{ | ||
private static final Logger logger = getLogger(DrillConfig.class); | private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(DrillConfig.class); | ||
|
|
||
private final ObjectMapper mapper; | private final ObjectMapper mapper; | ||
private final ImmutableList<String> startupArguments; | private final ImmutableList<String> startupArguments; | ||
|
@@ -66,18 +65,15 @@ public final class DrillConfig extends NestedConfig{ | ||
public DrillConfig(Config config, boolean enableServerConfigs) { | public DrillConfig(Config config, boolean enableServerConfigs) { | ||
super(config); | super(config); | ||
logger.debug("Setting up DrillConfig object."); | logger.debug("Setting up DrillConfig object."); | ||
if (logger.isTraceEnabled()) { | logger.trace("Given Config object is:\n{}", | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
jaltekruse
Contributor
|
|||
logger.trace("Given Config object is:\n{}", | config.root().render(ConfigRenderOptions.defaults())); | ||
config.root().render(ConfigRenderOptions.defaults())); | |||
} | |||
mapper = new ObjectMapper(); | mapper = new ObjectMapper(); | ||
|
|
||
if (enableServerConfigs) { | if (enableServerConfigs) { | ||
SimpleModule deserModule = new SimpleModule("LogicalExpressionDeserializationModule") | SimpleModule deserModule = new SimpleModule("LogicalExpressionDeserializationModule") | ||
.addDeserializer(LogicalExpression.class, new LogicalExpression.De(this)) | .addDeserializer(LogicalExpression.class, new LogicalExpression.De(this)) | ||
.addDeserializer(SchemaPath.class, new SchemaPath.De(this)); | .addDeserializer(SchemaPath.class, new SchemaPath.De(this)); | ||
|
|
||
|
|||
mapper.registerModule(deserModule); | mapper.registerModule(deserModule); | ||
mapper.enable(SerializationFeature.INDENT_OUTPUT); | mapper.enable(SerializationFeature.INDENT_OUTPUT); | ||
mapper.configure(Feature.ALLOW_UNQUOTED_FIELD_NAMES, true); | mapper.configure(Feature.ALLOW_UNQUOTED_FIELD_NAMES, true); | ||
|
@@ -99,7 +95,7 @@ public List<String> getStartupArguments() { | ||
|
|
||
/** | /** | ||
* Creates a DrillConfig object using the default config file name | * Creates a DrillConfig object using the default config file name | ||
* and with server-specific configuration options disabled. | * and with server-specific configuration options enabled. | ||
* @return The new DrillConfig object. | * @return The new DrillConfig object. | ||
*/ | */ | ||
public static DrillConfig create() { | public static DrillConfig create() { | ||
|
@@ -139,8 +135,9 @@ public static DrillConfig forClient() { | ||
* @param overrideFileResourcePathname | * @param overrideFileResourcePathname | ||
* the classpath resource pathname of the file to use for | * the classpath resource pathname of the file to use for | ||
* configuration override purposes; {@code null} specifies to use the | * configuration override purposes; {@code null} specifies to use the | ||
* default pathname ({@link CommonConstants.CONFIG_OVERRIDE}) | * default pathname ({@link CommonConstants.CONFIG_OVERRIDE}) (does | ||
* (<strong>not</strong> to not look for an override file at all) | * <strong>not</strong> specify to suppress trying to load an | ||
* overrides file) | |||
* @return A merged Config object. | * @return A merged Config object. | ||
*/ | */ | ||
public static DrillConfig create(String overrideFileResourcePathname) { | public static DrillConfig create(String overrideFileResourcePathname) { | ||
|
@@ -156,7 +153,6 @@ public static DrillConfig create(Properties testConfigurations) { | ||
} | } | ||
|
|
||
/** | /** | ||
* ... | |||
* @param overrideFileResourcePathname | * @param overrideFileResourcePathname | ||
* see {@link #create(String)}'s {@code overrideFileResourcePathname} | * see {@link #create(String)}'s {@code overrideFileResourcePathname} | ||
*/ | */ | ||
|
@@ -165,7 +161,6 @@ public static DrillConfig create(String overrideFileResourcePathname, boolean en | ||
} | } | ||
|
|
||
/** | /** | ||
* ... | |||
* @param overrideFileResourcePathname | * @param overrideFileResourcePathname | ||
* see {@link #create(String)}'s {@code overrideFileResourcePathname} | * see {@link #create(String)}'s {@code overrideFileResourcePathname} | ||
* @param overriderProps | * @param overriderProps | ||
|
@@ -190,7 +185,7 @@ private static DrillConfig create(String overrideFileResourcePathname, | ||
final URL url = | final URL url = | ||
classLoader.getResource(CommonConstants.CONFIG_DEFAULT_RESOURCE_PATHNAME); | classLoader.getResource(CommonConstants.CONFIG_DEFAULT_RESOURCE_PATHNAME); | ||
if (null != url) { | if (null != url) { | ||
logger.debug("Loading base config. file at {}.", url); | logger.info("Loading base configuration file at {}.", url); | ||
fallback = | fallback = | ||
ConfigFactory.load(classLoader, | ConfigFactory.load(classLoader, | ||
CommonConstants.CONFIG_DEFAULT_RESOURCE_PATHNAME); | CommonConstants.CONFIG_DEFAULT_RESOURCE_PATHNAME); | ||
|
@@ -199,28 +194,30 @@ private static DrillConfig create(String overrideFileResourcePathname, | ||
} | } | ||
|
|
||
// 2. Load per-module configuration files. | // 2. Load per-module configuration files. | ||
Collection<URL> urls = PathScanner.getConfigURLs(); | final Collection<URL> urls = PathScanner.getConfigURLs(); | ||
logger.debug("Loading configs at the following URLs {}", urls); | final String lineBrokenList = | ||
urls.size() == 0 ? "" : "\n\t- " + Joiner.on("\n\t- ").join(urls); | |||
logger.info("Loading {} module configuration files at: {}.", | |||
urls.size(), lineBrokenList); | |||
for (URL url : urls) { | for (URL url : urls) { | ||
logger.debug("Loading module config. file at {}.", url); | |||
fallback = ConfigFactory.parseURL(url).withFallback(fallback); | fallback = ConfigFactory.parseURL(url).withFallback(fallback); | ||
} | } | ||
|
|
||
// 3. Load any overrides configuration file and overrides from JVM | // 3. Load any specified overrides configuration file along with any | ||
// system properties (e.g., {-Dname=value"). | // overrides from JVM system properties (e.g., {-Dname=value"). | ||
|
|
||
// (Per ConfigFactory.load(...)'s mention of using Thread.getContextClassLoader():) | // (Per ConfigFactory.load(...)'s mention of using Thread.getContextClassLoader():) | ||
final URL overrideFileUrl = | final URL overrideFileUrl = | ||
Thread.currentThread().getContextClassLoader().getResource(overrideFileResourcePathname); | Thread.currentThread().getContextClassLoader().getResource(overrideFileResourcePathname); | ||
if (null != overrideFileUrl ) { | if (null != overrideFileUrl ) { | ||
logger.debug("Loading override config. file at {}.", overrideFileUrl); | logger.info("Loading override config. file at {}.", overrideFileUrl); | ||
} | } | ||
Config effectiveConfig = | Config effectiveConfig = | ||
ConfigFactory.load(overrideFileResourcePathname).withFallback(fallback); | ConfigFactory.load(overrideFileResourcePathname).withFallback(fallback); | ||
|
|
||
// 4. Apply any overriding properties. | // 4. Apply any overriding properties. | ||
if (overriderProps != null) { | if (overriderProps != null) { | ||
logger.debug("Loading override Properties parameter {}.", overriderProps); | logger.info("Loading override Properties parameter {}.", overriderProps); | ||
effectiveConfig = | effectiveConfig = | ||
ConfigFactory.parseProperties(overriderProps).withFallback(effectiveConfig); | ConfigFactory.parseProperties(overriderProps).withFallback(effectiveConfig); | ||
} | } | ||
|
Why would you remove the is trace enabled?