Repository: asterixdb Updated Branches: refs/heads/master 66d13f7b0 -> 56295d9bb
[NO ISSUE][OTR] Dynamically Determine Default Config File - user model changes: no - storage format changes: no - interface changes: no Details: - Dynamically determine default config file in AsterixHyracksIntegrationUtil. - Use Log4j2 as JUL LogManager. Change-Id: I56a596bec63b4347a1db6660c4d57fc662fff0fc Reviewed-on: https://asterix-gerrit.ics.uci.edu/2239 Sonar-Qube: Jenkins <jenk...@fulliautomatix.ics.uci.edu> Integration-Tests: Jenkins <jenk...@fulliautomatix.ics.uci.edu> Tested-by: Jenkins <jenk...@fulliautomatix.ics.uci.edu> Contrib: Jenkins <jenk...@fulliautomatix.ics.uci.edu> Reviewed-by: Till Westmann <ti...@apache.org> Project: http://git-wip-us.apache.org/repos/asf/asterixdb/repo Commit: http://git-wip-us.apache.org/repos/asf/asterixdb/commit/56295d9b Tree: http://git-wip-us.apache.org/repos/asf/asterixdb/tree/56295d9b Diff: http://git-wip-us.apache.org/repos/asf/asterixdb/diff/56295d9b Branch: refs/heads/master Commit: 56295d9bb2d256721d241e45903d992cec2b0eae Parents: 66d13f7 Author: Murtadha Hubail <mhub...@apache.org> Authored: Wed Dec 20 02:18:37 2017 +0300 Committer: Murtadha Hubail <mhub...@apache.org> Committed: Tue Dec 19 23:05:04 2017 -0800 ---------------------------------------------------------------------- asterixdb/asterix-app/pom.xml | 5 +++ .../common/AsterixHyracksIntegrationUtil.java | 39 ++++++++++++++++---- 2 files changed, 37 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/asterixdb/blob/56295d9b/asterixdb/asterix-app/pom.xml ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/pom.xml b/asterixdb/asterix-app/pom.xml index 0785056..2ca748f 100644 --- a/asterixdb/asterix-app/pom.xml +++ b/asterixdb/asterix-app/pom.xml @@ -578,5 +578,10 @@ <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-core</artifactId> </dependency> + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-jul</artifactId> + <version>2.10.0</version> + </dependency> </dependencies> </project> http://git-wip-us.apache.org/repos/asf/asterixdb/blob/56295d9b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/common/AsterixHyracksIntegrationUtil.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/common/AsterixHyracksIntegrationUtil.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/common/AsterixHyracksIntegrationUtil.java index 54dc064..97079eb 100644 --- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/common/AsterixHyracksIntegrationUtil.java +++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/common/AsterixHyracksIntegrationUtil.java @@ -24,8 +24,14 @@ import static org.apache.hyracks.util.file.FileUtil.joinPath; import java.io.File; import java.io.IOException; import java.net.Inet4Address; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.attribute.BasicFileAttributes; import java.util.ArrayList; import java.util.List; +import java.util.function.BiPredicate; +import java.util.stream.Stream; import org.apache.asterix.app.external.ExternalUDFLibrarian; import org.apache.asterix.common.api.IClusterManagementWork.ClusterState; @@ -54,15 +60,20 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.kohsuke.args4j.CmdLineException; -@SuppressWarnings({"squid:ClassVariableVisibilityCheck","squid:S00112"}) +@SuppressWarnings({ "squid:ClassVariableVisibilityCheck", "squid:S00112" }) public class AsterixHyracksIntegrationUtil { public static final int DEFAULT_HYRACKS_CC_CLIENT_PORT = 1098; public static final int DEFAULT_HYRACKS_CC_CLUSTER_PORT = 1099; - public static final String DEFAULT_CONF_FILE = joinPath("asterixdb", "asterix-app", "src", "test", "resources", + public static final String DEFAULT_CONF_FILE = joinPath(getProjectPath().toString(), "src", "test", "resources", "cc.conf"); private static final String DEFAULT_STORAGE_PATH = joinPath("target", "io", "dir"); private static String storagePath = DEFAULT_STORAGE_PATH; + + static { + System.setProperty("java.util.logging.manager", org.apache.logging.log4j.jul.LogManager.class.getName()); + } + public ClusterControllerService cc; public NodeControllerService[] ncs = new NodeControllerService[2]; public IHyracksClientConnection hcc; @@ -83,8 +94,7 @@ public class AsterixHyracksIntegrationUtil { * main method to run a simple 2 node cluster in-process * suggested VM arguments: <code>-enableassertions -Xmx2048m -Dfile.encoding=UTF-8</code> * - * @param args - * unused + * @param args unused */ public static void main(String[] args) throws Exception { AsterixHyracksIntegrationUtil integrationUtil = new AsterixHyracksIntegrationUtil(); @@ -125,9 +135,9 @@ public class AsterixHyracksIntegrationUtil { ncConfigManager = new ConfigManager(new String[] { "-config-file", confFile }); } ncApplication.registerConfig(ncConfigManager); - nodeControllers.add( - new NodeControllerService(fixupIODevices(createNCConfig(nodeId, ncConfigManager)), ncApplication)); - } ; + nodeControllers.add(new NodeControllerService(fixupIODevices(createNCConfig(nodeId, ncConfigManager)), + ncApplication)); + } opts.stream().forEach(opt -> configManager.set(opt.getLeft(), opt.getRight())); cc.start(); @@ -347,6 +357,21 @@ public class AsterixHyracksIntegrationUtil { opts.add(Pair.of(name, value)); } + /** + * @return the asterix-app absolute path if found, otherwise the default user path. + */ + private static Path getProjectPath() { + final String targetDir = "asterix-app"; + final BiPredicate<Path, BasicFileAttributes> matcher = + (path, attributes) -> path.getFileName().toString().equals(targetDir) && path.toFile().isDirectory(); + final Path currentPath = Paths.get(System.getProperty("user.dir")); + try (Stream<Path> pathStream = Files.find(currentPath, 10, matcher)) { + return pathStream.findFirst().orElse(currentPath); + } catch (IOException e) { + throw new IllegalStateException(e); + } + } + static class LoggerHolder { static final Logger LOGGER = LogManager.getLogger();