Murtadha Hubail has uploaded a new change for review.
https://asterix-gerrit.ics.uci.edu/2239
Change subject: [NO ISSUE][OTR] Dynamically Determine Default Config File
......................................................................
[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
---
M asterixdb/asterix-app/pom.xml
M
asterixdb/asterix-app/src/main/java/org/apache/asterix/api/common/AsterixHyracksIntegrationUtil.java
2 files changed, 39 insertions(+), 8 deletions(-)
git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb
refs/changes/39/2239/1
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>
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..1d5da52 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,15 @@
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.Optional;
+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 +61,19 @@
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",
- "cc.conf");
+ public static final String DEFAULT_CONF_FILE = joinPath(getProjectPath(),
"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 @@
* 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 @@
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,22 @@
opts.add(Pair.of(name, value));
}
+ private static String 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)) {
+ final Optional<Path> match = pathStream.findFirst();
+ if (!match.isPresent()) {
+ throw new IllegalStateException("Couldn't find " + targetDir +
" dir");
+ }
+ return match.get().toFile().getAbsolutePath();
+ } catch (IOException e) {
+ throw new IllegalStateException();
+ }
+ }
+
static class LoggerHolder {
static final Logger LOGGER = LogManager.getLogger();
--
To view, visit https://asterix-gerrit.ics.uci.edu/2239
To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I56a596bec63b4347a1db6660c4d57fc662fff0fc
Gerrit-PatchSet: 1
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Murtadha Hubail <[email protected]>