javeme commented on code in PR #2615: URL: https://github.com/apache/incubator-hugegraph/pull/2615#discussion_r1712615028
########## hugegraph-it/hg-it-minicluster/src/main/java/org/apache/hugegraph/it/node/PDNodeWrapper.java: ########## @@ -0,0 +1,89 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.hugegraph.it.node; + +import static org.apache.hugegraph.it.base.ClusterConstant.CONF_DIR; +import static org.apache.hugegraph.it.base.ClusterConstant.JAVA_CMD; +import static org.apache.hugegraph.it.base.ClusterConstant.PD_JAR_PREFIX; +import static org.apache.hugegraph.it.base.ClusterConstant.getFileInDir; +import static org.apache.hugegraph.it.base.ClusterConstant.isJava11OrHigher; + +import java.io.File; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.apache.commons.io.FileUtils; + +public class PDNodeWrapper extends AbstractNodeWrapper { + + public PDNodeWrapper(String host, int grpcPort, int clusterIndex, int cnt) { + super(host, grpcPort, clusterIndex, cnt); + } + + public PDNodeWrapper(int clusterId, int cnt) { + this.clusterIndex = clusterId; Review Comment: prefer to keep the same name with clusterId param: this.clusterIndex => this.clusterId ########## hugegraph-it/hg-it-minicluster/src/main/java/org/apache/hugegraph/it/config/ClusterConfImpl.java: ########## @@ -0,0 +1,22 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.hugegraph.it.config; + +public class ClusterConfImpl implements ClusterConf { Review Comment: not sure why this class is empty ########## hugegraph-it/hg-it-dist/pom.xml: ########## @@ -0,0 +1,78 @@ +<?xml version="1.0" encoding="UTF-8"?> Review Comment: hugegraph-it name is a bit hard to understand, it needs to be more specific, such as hugegraph-cluster-deploy or hugegraph-cluster-test ########## hugegraph-it/hg-it-minicluster/src/main/java/org/apache/hugegraph/it/node/PDNodeWrapper.java: ########## @@ -0,0 +1,89 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.hugegraph.it.node; + +import static org.apache.hugegraph.it.base.ClusterConstant.CONF_DIR; +import static org.apache.hugegraph.it.base.ClusterConstant.JAVA_CMD; +import static org.apache.hugegraph.it.base.ClusterConstant.PD_JAR_PREFIX; +import static org.apache.hugegraph.it.base.ClusterConstant.getFileInDir; +import static org.apache.hugegraph.it.base.ClusterConstant.isJava11OrHigher; + +import java.io.File; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.apache.commons.io.FileUtils; + +public class PDNodeWrapper extends AbstractNodeWrapper { + + public PDNodeWrapper(String host, int grpcPort, int clusterIndex, int cnt) { + super(host, grpcPort, clusterIndex, cnt); + } + + public PDNodeWrapper(int clusterId, int cnt) { Review Comment: can we improve the cnt name for better readability, like xxCount ########## hugegraph-it/hg-it-minicluster/src/main/java/org/apache/hugegraph/it/node/PDNodeWrapper.java: ########## @@ -0,0 +1,89 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.hugegraph.it.node; + +import static org.apache.hugegraph.it.base.ClusterConstant.CONF_DIR; +import static org.apache.hugegraph.it.base.ClusterConstant.JAVA_CMD; +import static org.apache.hugegraph.it.base.ClusterConstant.PD_JAR_PREFIX; +import static org.apache.hugegraph.it.base.ClusterConstant.getFileInDir; +import static org.apache.hugegraph.it.base.ClusterConstant.isJava11OrHigher; + +import java.io.File; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.apache.commons.io.FileUtils; + +public class PDNodeWrapper extends AbstractNodeWrapper { + + public PDNodeWrapper(String host, int grpcPort, int clusterIndex, int cnt) { + super(host, grpcPort, clusterIndex, cnt); + } + + public PDNodeWrapper(int clusterId, int cnt) { + this.clusterIndex = clusterId; + this.cnt = cnt; + } + + /* + workPath is path of JAR package, configPath is path of config files + */ + @Override + public void start() { + try { + File stdoutFile = new File(getLogPath()); + List<String> startCmd = new ArrayList<>(); + startCmd.add(JAVA_CMD); + if (!isJava11OrHigher()) { + LOG.error("Please make sure that the JDK is installed and the version >= 11"); + return; + } + String pdNodeJarPath = getFileInDir(workPath, PD_JAR_PREFIX); + startCmd.addAll( + Arrays.asList( + "-Dname=HugeGraphPD" + this.cnt, + "-Xms512m", + "-Xmx4g", + "-XX:+HeapDumpOnOutOfMemoryError", + "-XX:HeapDumpPath=" + configPath + "logs", + "-Dlog4j.configurationFile=" + configPath + CONF_DIR + File.separator + + "log4j2.xml", + "-Dspring.config.location=" + configPath + CONF_DIR + File.separator + + "application.yml", + "-jar", pdNodeJarPath)); + FileUtils.write( + stdoutFile, String.join(" ", startCmd) + "\n\n", StandardCharsets.UTF_8, true); Review Comment: can we add a method like `AbstractNodeWrapper.runCmd(cmd)` or `ProcessUtil.runCmd(cmd)`, to avoid writing these repeated codes in many places. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
