Skip to content

Commit

Permalink
Fix test when doris-meta dir not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
CalvinKirs committed Sep 19, 2023
1 parent 740ec0c commit 364bdcf
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
21 changes: 10 additions & 11 deletions fe/fe-core/src/main/java/org/apache/doris/DorisFE.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ public class DorisFE {
public static final String PID_DIR = System.getenv("PID_DIR");


private static final String LOCK_FILE_PATH = Config.meta_dir + "/process.lock";
private static String LOCK_FILE_PATH;

private static final String LOCK_FILE_NAME = "process.lock";
private static FileChannel processLockFileChannel;
private static FileLock processFileLock;

Expand All @@ -95,12 +97,6 @@ public static void start(String dorisHomeDir, String pidDir, String[] args, Star
System.err.println("env PID_DIR is not set.");
return;
}
try {
tryLockProcess();
} catch (Exception e) {
LOG.error("start doris failed.", e);
System.exit(-1);
}

CommandLineOptions cmdLineOpts = parseArgs(args);

Expand All @@ -116,7 +112,13 @@ public static void start(String dorisHomeDir, String pidDir, String[] args, Star
// Must init custom config after init config, separately.
// Because the path of custom config file is defined in fe.conf
config.initCustom(Config.custom_config_dir + "/fe_custom.conf");

LOCK_FILE_PATH = Config.meta_dir + "/" + LOCK_FILE_NAME;
try {
tryLockProcess();
} catch (Exception e) {
LOG.error("start doris failed.", e);
System.exit(-1);
}
LdapConfig ldapConfig = new LdapConfig();
if (new File(dorisHomeDir + "/conf/ldap.conf").exists()) {
ldapConfig.init(dorisHomeDir + "/conf/ldap.conf");
Expand Down Expand Up @@ -430,9 +432,6 @@ private static boolean createAndLockPidFile(String pidFilePath) throws IOExcepti
* that only one FE process can occupy a metadata directory, and other processes will fail to start.
*/
private static void tryLockProcess() {
if (null == System.getenv("DORIS_HOME")) {
return;
}
try {
processLockFileChannel = FileChannel.open(new File(LOCK_FILE_PATH).toPath(), StandardOpenOption.WRITE,
StandardOpenOption.CREATE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,12 @@ private static int startFEServerWithoutRetry(String runningDir) throws EnvVarNot
if (!file.exists()) {
file.mkdir();
}
if (null != System.getenv("DORIS_HOME")) {
File metaDir = new File(Config.meta_dir);
if (!metaDir.exists()) {
metaDir.mkdir();
}
}

int feHttpPort = findValidPort();
int feRpcPort = findValidPort();
Expand Down

0 comments on commit 364bdcf

Please sign in to comment.