-
Notifications
You must be signed in to change notification settings - Fork 304
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[#150][#178] feat(all): Add launching process and scripts #191
Conversation
Code Coverage Report
Files
|
.github/workflows/build.yml
Outdated
run: | | ||
gradle assembleDistribution | ||
ls -l distribution/package |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the usage of the ls
command?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
print package directory to help check.
|
||
// Create and config Jetty Server | ||
server = new Server(threadPool); | ||
server = new Server(threadPool2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I may not get the context, Why we need to use a new thread pool?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
} catch (Exception e) { | ||
LOG.error("Error while stopping servlet container", e); | ||
} | ||
LOG.info("Done, Shutting down Graviton Server."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shutting down Graviton Server.
Better: Graviton Server has shut down
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
for (String key : properties.stringPropertyNames()) { | ||
String value = properties.getProperty(key); | ||
String[] splits = value.split("# "); | ||
if (splits.length == 2) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am afraid the condition that length of array is 2 is not enough, see:
configkey configvalue # # this is comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code section has been removed.
@jerryshao Please help me to review this PR. thanks. |
.github/workflows/build.yml
Outdated
echo "Failed to start graviton" | ||
exit 1 | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it is super necessary to start and test a server here, this will prolong the CI time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed bin/graviont.sh start
test. And split Integration Test into a single workflow.
.github/workflows/build.yml
Outdated
- name: Package with Gradle | ||
run: | | ||
gradle assembleDistribution |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it is necessary to add package process here in build.yml
, this script is mainly for UT. Is it better to use another workflow for package things?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Remove the compress
tar.gz
process, only retain only createdistribution/package
directory. - Split Integration Test into a single workflow.
bin/common.sh
Outdated
fi | ||
|
||
if [ "$JVM_VERSION" -lt 8 ] || { [ "$JVM_VERSION" -eq 8 ] && [ "${jvmver#*_}" -lt 151 ]; } ; then | ||
echo "Graviton requires either Java 8 update 151 or newer" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is Java 8 enough, do we require a Java version larger than 151
? Also, I was worrying about the way you get Java version using regex, you may not get the version number from some customized java release like zuul, kona jdk?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
Because after JDK 8u151, Oracle fixed a number of security vulnerabilities and issues to improve system stability and security. We suggest using after JDK 8u151.
https://www.oracle.com/java/technologies/javase/8u151-relnotes.html -
Because we only test passed in Oracle JDK, Other JDK versions not tested, better limit JDK type & version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest not using Oracle JDK 8 as it has a restrictive license. Oracle JDK Java 8 is under the OTN License Agreement for Java (https://www.oracle.com/cis/downloads/licenses/oracle-javase-license.html). This requires a fee / license for commercial use.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest using OpenJDK / Corretto.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hi, @justinmclean thank you for your suggestion.
I create issue #215 to track this problem.
if [[ "$1" == "--config" ]]; then | ||
shift | ||
conf_dir="$1" | ||
if [[ ! -d "${conf_dir}" ]]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May be it is not necessary to add --config <conf-dir>
? I think we can use GRAVITON_CONF_DIR
or GRAVITON_HOME
to infer the conf dir programatically.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The --config
parameter is an option that allows us to easily change the configuration directory in the start scripts.
- When the
--config
parameter is not specified,GRAVITON_CONF_DIR
is the default environment in thegraviton-env.sh
- When the
--config
parameter is specified, theGRAVITON_CONF_DIR
environment is overwritten.
|
||
function found_graviton_server_pid() { | ||
process_name='GravitonServer'; | ||
RUNNING_PIDS=$(ps x | grep ${process_name} | grep -v grep | awk '{print $1}'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it better to write pid to a file to avoid same name process?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using PID
file is a traditional operation, and I have implemented this function in another version.
- Generation the
PID
file in thegraviton.sh start
command. - Deleted the
PID
file in thegraviton.sh stop
command.
However, when the Graviton Server itself exits abnormally, the PID file is not deleted properly.
You will not be able to restart Gravtion Server the next time because there is already an old PID file.
So I think might be better to get the directory PID in the operation system.
I suggest that we can keep this implementation, and consider modifying it later when we have a specific problem.
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, sure.
build.gradle.kts
Outdated
if (it.name == "catalog-hive") { | ||
// println("copyCatalogRuntimeClass: ${it.name}") | ||
from(it.configurations.runtimeClasspath) | ||
into("distribution/package/catalog/catalog-hive/lib") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
catalogs/catalog-hive
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
if (it.name != "catalog-hive") { | ||
// println("copyRuntimeClass: ${it.name}") | ||
from(it.configurations.runtimeClasspath) | ||
into("distribution/package/lib") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't need to copy client jar into lib?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The catalog-hive
JAR need copy to another directory(distribution/package/catalog/catalog-hive/lib
), So I split two different Tasks, copyCatalogRuntimeClass()
and copySubmoduleClass()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I mean is client-jar lib, I think we don't need to include this module's jar files into server's lib.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@@ -133,7 +133,6 @@ Properties loadPropertiesFromFile(File file) throws IOException { | |||
try (InputStream in = Files.newInputStream(file.toPath())) { | |||
properties.load(in); | |||
return properties; | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this seems like a unnecessary change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change has been rollback.
LOG.info("Shutting down Graviton Server ... "); | ||
try { | ||
server.stop(); | ||
Thread.sleep(3000); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we'd better not make this hardcoded.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, added SERVER_SHUTDOWN_TIMEOUT
into Configure
.
rootLogger.level = debug | ||
|
||
# Root logger referring to console appender | ||
rootLogger.appenderRef.stdout.ref = consoleLogger |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this file seems not necessary, as we already removed this in the previous pr.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed this log4j2.properties
file.
bin/common.sh
Outdated
function addEachJarInDirRecursive(){ | ||
if [[ -d "${1}" ]]; then | ||
for jar in "${1}"/**/*.jar ; do | ||
GRAVITON_CLASSPATH="$jar:$GRAVITON_CLASSPATH" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest to add "{}" to variables to avoid potentially issues.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
println() | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems we only print some dependency information here for this allDeps
task, is this necessary? Also gradle has a similar functionality.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I using a new function to replace it.
val allDeps by tasks.registering(DependencyReportTask::class)
Now if you execute ./gradlew allDeps
command, will print all subproject dependency
LOG.info("Shutting down Graviton Server ... "); | ||
try { | ||
server.stop(); | ||
Thread.sleep(server.serverConfig.get(ServerConfig.SERVER_SHUTDOWN_TIMEOUT)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we also need to put this configuration into graviton.conf.template
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added it into graviton.conf.template
.
@@ -185,7 +188,7 @@ private ExecutorThreadPool createThreadPool(int coreThreads, int maxThreads) { | |||
maxThreads, | |||
60, | |||
TimeUnit.SECONDS, | |||
new LinkedBlockingQueue<>(), | |||
new LinkedBlockingQueue<>(100), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to make this configurable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jerryshao I think so.
An unbounded queue is dangerous and not recommended in Java when using thread pool. here I notice this problem and advice @xunliu to change here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added graviton.server.webserver.executorThreadPoolSize
configuration parameter to graviton.conf
.
echo "Graviton requires either Java 8 update 151 or newer" | ||
exit 1; | ||
fi | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The indention of this method is 4 spaces.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The indention of this method is 4 spaces.
This is not fixed.
@@ -59,6 +59,13 @@ public class ServerConfig extends Config { | |||
.intConf() | |||
.createWithDefault(128 * 1024); | |||
|
|||
public static final ConfigEntry<Integer> WEBSERVER_EXECUTOR_THREAD_POOL_SIZE = | |||
new ConfigBuilder("graviton.server.webserver.executorThreadPoolSize") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This configuration may not be the thread pool size? I think it should be queue size?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, modify to WEBSERVER_THREAD_POOL_WORK_QUEUE_SIZE
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I'm going to merge this PR. We don't restrict the JDK vendor version, I think there's no issue here, and can be addressed later if necessary.
What changes were proposed in this pull request?
Through
graviton.sh
script launching GravtionServer.Command
Directory struct
Scripts context
Assemble Distribution
./gradlew clean build
./gradlew compileDistribution
${project_root_dir}/bin/
directory to${project_root_dir}/distribution/package/bin/
.${project_root_dir}/conf/
directory to${project_root_dir}/distribution/package/conf/
and remove.template
file name suffix.${project_root_dir}/${sub_module}/lib
to${project_root_dir}/distribution/package/lib/
${project_root_dir}/catalog-hive}/lib
to${project_root_dir}/distribution/package/catalogs/catalog-hive/lib
./gradlew assembleDistribution
${project_root_dir}/distribution/package
generategraviton-${version}-bin.tar
andgraviton-${version}-bin.tar.sha256
./distribution/package/bin/graviton.sh start|stop|status
Why are the changes needed?
Through script launching
Graviton Server
.Fix: #178
Does this PR introduce any user-facing change?
N/A
How was this patch tested?
Test on PullRequst submission