Skip to content

Commit

Permalink
fix(ct): simplify the dist
Browse files Browse the repository at this point in the history
  • Loading branch information
HJ-Young committed Oct 14, 2024
1 parent 2896c07 commit 584c79b
Show file tree
Hide file tree
Showing 12 changed files with 53 additions and 205 deletions.

This file was deleted.

Binary file not shown.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -31,76 +31,66 @@ public class ClusterConstant {
public static final String PD = "pd";
public static final String STORE = "store";
public static final String SERVER = "server";

public static final String LIB_DIR = "lib";
public static final String EXT_DIR = "ext";
public static final String PLUGINS_DIR = "plugins";
public static final String BIN_DIR = "bin";
public static final String CONF_DIR = "conf";

public static final String PD_PACKAGE_PREFIX = "apache-hugegraph-pd-incubating";
public static final String PD_JAR_PREFIX = "hg-pd-service";
public static final String STORE_PACKAGE_PREFIX = "apache-hugegraph-store-incubating";
public static final String STORE_JAR_PREFIX = "hg-store-node";
public static final String SERVER_PACKAGE_PREFIX = "apache-hugegraph-server-incubating";
public static final String CT_PACKAGE_PREFIX = "apache-hugegraph-ct-incubating";

public static final String APPLICATION_FILE = "application.yml";
public static final String SERVER_PROPERTIES = "rest-server.properties";
public static final String HUGEGRAPH_PROPERTIES = "graphs/hugegraph.properties";

public static final String LOG4J_FILE = "log4j2.xml";
public static final String LICENSE_FILE = "hugegraph.license";
public static final String PD_TEMPLATE_FILE = "pd-application.yml.template";

public static final String STORE_TEMPLATE_FILE = "store-application.yml.template";
public static final String SERVER_TEMPLATE_FILE = "rest-server.properties.template";
public static final String GRAPH_TEMPLATE_FILE = "hugegraph.properties.template";
public static final String GREMLIN_DRIVER_SETTING_FILE = "gremlin-driver-settings.yaml";
public static final String GREMLIN_SERVER_FILE = "gremlin-server.yaml";
public static final String COMPUTER_SETTING_FILE = "computer.yaml";
public static final String HUGEGRAPH_SERVER_KEYSTORE = "hugegraph-server.keystore";
public static final String REMOTE_SETTING_FILE = "remote.yaml";
public static final String REMOTE_OBJECTS_SETTING_FILE = "remote-objects.yaml";
public static final String EMPTY_SAMPLE_GROOVY_FILE = "scripts/empty-sample.groovy";
public static final String EXAMPLE_GROOVY_FILE = "scripts/example.groovy";

public static final String LOCALHOST = "127.0.0.1";

public static final String JAVA_CMD = System.getProperty("java.home") +
File.separator + BIN_DIR + File.separator +
(SystemUtils.IS_OS_WINDOWS ? "java.exe" : "java");

public static final String PD_DIST_PATH = PROJECT_DIR + File.separator +
"hugegraph-pd" + File.separator;

public static final String PD_LIB_PATH = getFileInDir(PD_DIST_PATH, PD_PACKAGE_PREFIX) +
File.separator + LIB_DIR + File.separator;

public static final String STORE_DIST_PATH = PROJECT_DIR + File.separator + "hugegraph-store" +
File.separator;

public static final String STORE_LIB_PATH = getFileInDir(STORE_DIST_PATH, STORE_PACKAGE_PREFIX)
+ File.separator + LIB_DIR + File.separator;

public static final String SERVER_DIST_PATH = PROJECT_DIR + File.separator +
"hugegraph-server" + File.separator;

public static final String SERVER_LIB_PATH = getFileInDir(SERVER_DIST_PATH,
SERVER_PACKAGE_PREFIX) +
File.separator;

public static final String CT_DIST_PATH = PROJECT_DIR + File.separator +
"hugegraph-cluster-test" + File.separator;

public static final String CT_PACKAGE_PATH = getFileInDir(CT_DIST_PATH, CT_PACKAGE_PREFIX) +
File.separator;

public static final String PD_TEMPLATE_PATH = CT_PACKAGE_PATH + PD + File.separator;

public static final String STORE_TEMPLATE_PATH = CT_PACKAGE_PATH + STORE + File.separator;

public static final String SERVER_TEMPLATE_PATH = CT_PACKAGE_PATH + SERVER + File.separator;
public static final String JAVA_CMD =
System.getProperty("java.home") + File.separator + BIN_DIR + File.separator +
(SystemUtils.IS_OS_WINDOWS ? "java.exe" : "java");
public static final String PD_DIST_PATH =
PROJECT_DIR + File.separator + "hugegraph-pd" + File.separator;
public static final String PD_LIB_PATH =
getFileInDir(PD_DIST_PATH, PD_PACKAGE_PREFIX) + File.separator + LIB_DIR +
File.separator;
public static final String PD_TEMPLATE_PATH =
getFileInDir(PD_DIST_PATH, PD_PACKAGE_PREFIX) + File.separator + CONF_DIR +
File.separator;
public static final String STORE_DIST_PATH =
PROJECT_DIR + File.separator + "hugegraph-store" + File.separator;
public static final String STORE_LIB_PATH =
getFileInDir(STORE_DIST_PATH, STORE_PACKAGE_PREFIX) + File.separator + LIB_DIR +
File.separator;
public static final String STORE_TEMPLATE_PATH =
getFileInDir(STORE_DIST_PATH, STORE_PACKAGE_PREFIX) + File.separator + CONF_DIR +
File.separator;
public static final String SERVER_DIST_PATH =
PROJECT_DIR + File.separator + "hugegraph-server" + File.separator;
public static final String SERVER_LIB_PATH =
getFileInDir(SERVER_DIST_PATH, SERVER_PACKAGE_PREFIX) +
File.separator;
public static final String SERVER_TEMPLATE_PATH =
getFileInDir(SERVER_DIST_PATH, SERVER_PACKAGE_PREFIX) +
File.separator + CONF_DIR + File.separator;
public static final String CT_DIST_PATH =
PROJECT_DIR + File.separator + "hugegraph-cluster-test" + File.separator;
public static final String CT_PACKAGE_PATH =
getFileInDir(CT_DIST_PATH, CT_PACKAGE_PREFIX) + File.separator;
public static final String CONFIG_FILE_PATH = CT_PACKAGE_PATH + CONF_DIR + File.separator;

private ClusterConstant() {
throw new IllegalStateException("Utility class");
Expand Down Expand Up @@ -133,15 +123,15 @@ public static boolean isJava11OrHigher() {
}

public static String getProjectDir() {
String userDir = System.getProperty("user.dir"); // 获取当前工作目录
Path path = Paths.get(userDir); // 将路径字符串转换为 Path 对象
String userDir = System.getProperty("user.dir"); // get current dir
Path path = Paths.get(userDir);

if (userDir.endsWith("hugegraph-cluster-test")) {
return path.getParent().toString(); // 返回上一级目录
return path.getParent().toString();
} else if (userDir.endsWith("hugegraph-clustertest-test")) {
return path.getParent().getParent().toString(); // 返回上两级目录
return path.getParent().getParent().toString();
}

return userDir; // 如果不匹配则返回当前目录
return userDir; // Return current dir if not matched
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,17 @@

package org.apache.hugegraph.ct.config;

import static org.apache.hugegraph.ct.base.ClusterConstant.CT_PACKAGE_PATH;
import static org.apache.hugegraph.ct.base.ClusterConstant.CONFIG_FILE_PATH;
import static org.apache.hugegraph.ct.base.ClusterConstant.GRAPH_TEMPLATE_FILE;
import static org.apache.hugegraph.ct.base.ClusterConstant.HUGEGRAPH_PROPERTIES;
import static org.apache.hugegraph.ct.base.ClusterConstant.SERVER_TEMPLATE_PATH;

import java.nio.file.Paths;
import java.util.List;

public class GraphConfig extends AbstractConfig {

public GraphConfig() {
readTemplate(Paths.get(SERVER_TEMPLATE_PATH + GRAPH_TEMPLATE_FILE));
readTemplate(Paths.get(CONFIG_FILE_PATH + GRAPH_TEMPLATE_FILE));
this.fileName = HUGEGRAPH_PROPERTIES;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@
package org.apache.hugegraph.ct.config;

import static org.apache.hugegraph.ct.base.ClusterConstant.APPLICATION_FILE;
import static org.apache.hugegraph.ct.base.ClusterConstant.CT_PACKAGE_PATH;
import static org.apache.hugegraph.ct.base.ClusterConstant.CONFIG_FILE_PATH;
import static org.apache.hugegraph.ct.base.ClusterConstant.LOCALHOST;
import static org.apache.hugegraph.ct.base.ClusterConstant.PD_TEMPLATE_FILE;
import static org.apache.hugegraph.ct.base.ClusterConstant.PD_TEMPLATE_PATH;
import static org.apache.hugegraph.ct.base.EnvUtil.getAvailablePort;

import java.nio.file.Paths;
Expand All @@ -37,7 +36,7 @@ public class PDConfig extends AbstractConfig {
private final int restPort;

public PDConfig() {
readTemplate(Paths.get(PD_TEMPLATE_PATH + PD_TEMPLATE_FILE));
readTemplate(Paths.get(CONFIG_FILE_PATH + PD_TEMPLATE_FILE));
this.fileName = APPLICATION_FILE;
this.raftPort = getAvailablePort();
this.grpcPort = getAvailablePort();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@

package org.apache.hugegraph.ct.config;

import static org.apache.hugegraph.ct.base.ClusterConstant.CT_PACKAGE_PATH;
import static org.apache.hugegraph.ct.base.ClusterConstant.CONFIG_FILE_PATH;
import static org.apache.hugegraph.ct.base.ClusterConstant.LOCALHOST;
import static org.apache.hugegraph.ct.base.ClusterConstant.SERVER_PROPERTIES;
import static org.apache.hugegraph.ct.base.ClusterConstant.SERVER_TEMPLATE_FILE;
import static org.apache.hugegraph.ct.base.ClusterConstant.SERVER_TEMPLATE_PATH;
import static org.apache.hugegraph.ct.base.EnvUtil.getAvailablePort;

import java.nio.file.Paths;
Expand All @@ -35,7 +34,7 @@ public class ServerConfig extends AbstractConfig {
private final int restPort;

public ServerConfig() {
readTemplate(Paths.get(SERVER_TEMPLATE_PATH + SERVER_TEMPLATE_FILE));
readTemplate(Paths.get(CONFIG_FILE_PATH + SERVER_TEMPLATE_FILE));
this.fileName = SERVER_PROPERTIES;
this.rpcPort = getAvailablePort();
this.restPort = getAvailablePort();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@
package org.apache.hugegraph.ct.config;

import static org.apache.hugegraph.ct.base.ClusterConstant.APPLICATION_FILE;
import static org.apache.hugegraph.ct.base.ClusterConstant.CT_PACKAGE_PATH;
import static org.apache.hugegraph.ct.base.ClusterConstant.CONFIG_FILE_PATH;
import static org.apache.hugegraph.ct.base.ClusterConstant.LOCALHOST;
import static org.apache.hugegraph.ct.base.ClusterConstant.STORE_TEMPLATE_FILE;
import static org.apache.hugegraph.ct.base.ClusterConstant.STORE_TEMPLATE_PATH;
import static org.apache.hugegraph.ct.base.EnvUtil.getAvailablePort;

import java.nio.file.Paths;
Expand All @@ -37,8 +36,7 @@ public class StoreConfig extends AbstractConfig {
private final int restPort;

public StoreConfig() {
readTemplate(
Paths.get(STORE_TEMPLATE_PATH + STORE_TEMPLATE_FILE));
readTemplate(Paths.get(CONFIG_FILE_PATH + STORE_TEMPLATE_FILE));
this.fileName = APPLICATION_FILE;
this.raftPort = getAvailablePort();
this.grpcPort = getAvailablePort();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import static org.apache.hugegraph.ct.base.ClusterConstant.CONF_DIR;
import static org.apache.hugegraph.ct.base.ClusterConstant.JAVA_CMD;
import static org.apache.hugegraph.ct.base.ClusterConstant.LICENSE_FILE;
import static org.apache.hugegraph.ct.base.ClusterConstant.LOG4J_FILE;
import static org.apache.hugegraph.ct.base.ClusterConstant.PD_JAR_PREFIX;
import static org.apache.hugegraph.ct.base.ClusterConstant.PD_LIB_PATH;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import static org.apache.hugegraph.ct.base.ClusterConstant.EXT_DIR;
import static org.apache.hugegraph.ct.base.ClusterConstant.GREMLIN_DRIVER_SETTING_FILE;
import static org.apache.hugegraph.ct.base.ClusterConstant.GREMLIN_SERVER_FILE;
import static org.apache.hugegraph.ct.base.ClusterConstant.HUGEGRAPH_SERVER_KEYSTORE;
import static org.apache.hugegraph.ct.base.ClusterConstant.JAVA_CMD;
import static org.apache.hugegraph.ct.base.ClusterConstant.LIB_DIR;
import static org.apache.hugegraph.ct.base.ClusterConstant.LOG4J_FILE;
Expand All @@ -46,10 +45,8 @@ public class ServerNodeWrapper extends AbstractNodeWrapper {

public ServerNodeWrapper(int clusterIndex, int index) {
super(clusterIndex, index);
this.fileNames = new ArrayList<>(List.of(LOG4J_FILE, HUGEGRAPH_SERVER_KEYSTORE,
COMPUTER_SETTING_FILE, GREMLIN_SERVER_FILE,
GREMLIN_DRIVER_SETTING_FILE, REMOTE_SETTING_FILE,
REMOTE_OBJECTS_SETTING_FILE));
this.fileNames = new ArrayList<>(List.of(LOG4J_FILE, GREMLIN_SERVER_FILE, GREMLIN_DRIVER_SETTING_FILE,
REMOTE_SETTING_FILE, REMOTE_OBJECTS_SETTING_FILE));
this.workPath = SERVER_LIB_PATH;
createNodeDir(Paths.get(SERVER_TEMPLATE_PATH), getNodePath() + CONF_DIR + File.separator);
this.fileNames = new ArrayList<>(List.of(EMPTY_SAMPLE_GROOVY_FILE, EXAMPLE_GROOVY_FILE));
Expand Down
6 changes: 6 additions & 0 deletions hugegraph-pd/hg-pd-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,11 @@
<artifactId>commons-collections4</artifactId>
<version>4.4</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>31.0.1-android</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>

0 comments on commit 584c79b

Please sign in to comment.