Skip to content

Commit 18bedd2

Browse files
authored
update java version to 11 (#170)
1 parent d890a24 commit 18bedd2

13 files changed

Lines changed: 62 additions & 48 deletions

File tree

.github/workflows/ci.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
uses: actions/setup-java@v2
2323
with:
2424
java-version: '8'
25-
distribution: 'adopt'
25+
distribution: 'zulu'
2626

2727
- name: Setup Python3
2828
uses: actions/setup-python@v2
@@ -57,9 +57,6 @@ jobs:
5757
with:
5858
fetch-depth: 2
5959

60-
- name: Compile
61-
run: mvn clean compile -Dmaven.javadoc.skip=true | grep -v "Downloading\|Downloaded"
62-
6360
- name: Prepare env and service
6461
env:
6562
TRAVIS_DIR: computer-dist/src/assembly/travis
@@ -69,6 +66,15 @@ jobs:
6966
$TRAVIS_DIR/install-hugegraph-from-source.sh $COMMIT_ID | grep -v "Downloading\|Downloaded"
7067
$TRAVIS_DIR/load-data-into-hugegraph.sh
7168
69+
- name: Install JDK 11
70+
uses: actions/setup-java@v2
71+
with:
72+
java-version: '11'
73+
distribution: 'zulu'
74+
75+
- name: Compile
76+
run: mvn clean compile -Dmaven.javadoc.skip=true | grep -v "Downloading\|Downloaded"
77+
7278
- name: Integrate test
7379
run: mvn test -P integrate-test
7480

.github/workflows/publish_images.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ jobs:
3636
username: ${{ secrets.DOCKERHUB_USERNAME }}
3737
password: ${{ secrets.DOCKERHUB_PASSWORD }}
3838

39-
- name: Install JDK 8
39+
- name: Install JDK 11
4040
uses: actions/setup-java@v2
4141
with:
42-
java-version: '8'
43-
distribution: 'adopt'
42+
java-version: '11'
43+
distribution: 'zulu'
4444

4545
- name: Cache Maven packages
4646
uses: actions/cache@v2

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ jobs:
88
build:
99
runs-on: ubuntu-20.04
1010
steps:
11-
- name: Install JDK 8
11+
- name: Install JDK 11
1212
uses: actions/setup-java@v2
1313
with:
14-
java-version: '8'
14+
java-version: '11'
1515
distribution: 'adopt'
1616

1717
- name: Cache Maven packages

computer-core/src/main/java/com/baidu/hugegraph/computer/core/config/ComputerOptions.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -638,15 +638,15 @@ public static synchronized ComputerOptions instance() {
638638
"transport.server_threads",
639639
"The number of transport threads for server.",
640640
positiveInt(),
641-
TransportConf.NUMBER_CPU_CORES
641+
TransportConf.DEFAULT_THREADS
642642
);
643643

644644
public static final ConfigOption<Integer> TRANSPORT_CLIENT_THREADS =
645645
new ConfigOption<>(
646646
"transport.client_threads",
647647
"The number of transport threads for client.",
648648
positiveInt(),
649-
TransportConf.NUMBER_CPU_CORES
649+
TransportConf.DEFAULT_THREADS
650650
);
651651

652652
public static final ConfigOption<Class<?>> TRANSPORT_PROVIDER_CLASS =

computer-core/src/main/java/com/baidu/hugegraph/computer/core/network/TransportConf.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ public class TransportConf {
3535
"transport-netty-server";
3636
public static final String CLIENT_THREAD_GROUP_NAME =
3737
"transport-netty-client";
38-
public static final int NUMBER_CPU_CORES =
39-
Runtime.getRuntime().availableProcessors();
4038
private final Config config;
4139

40+
public static final int DEFAULT_THREADS = 4;
41+
4242
public static TransportConf wrapConfig(Config config) {
4343
return new TransportConf(config);
4444
}
@@ -72,11 +72,7 @@ public int clientThreads() {
7272
}
7373

7474
private int maxTransportThreads() {
75-
Integer workerCount = this.config
76-
.get(ComputerOptions.JOB_WORKERS_COUNT);
77-
Integer partitions = this.config
78-
.get(ComputerOptions.JOB_PARTITIONS_COUNT);
79-
return partitions / workerCount + 1;
75+
return this.config.get(ComputerOptions.JOB_WORKERS_COUNT);
8076
}
8177

8278
public TransportProvider transportProvider() {

computer-dist/Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
FROM openjdk:8-jre
1+
FROM openjdk:11-jre
22
LABEL maintainer="HugeGraph Docker Maintainers <hugegraph@googlegroups.com>"
3-
ENV JAVA_OPTS="-XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap -XX:MaxRAMFraction=2 -XshowSettings:vm"
3+
# use ParallelGC which is more friendly to olap system
4+
ENV JAVA_OPTS="-XX:+UnlockExperimentalVMOptions -XX:+UseParallelGC -XX:+UseContainerSupport -XX:MaxRAMPercentage=50 -XshowSettings:vm"
45
COPY . /etc/local/hugegraph-computer
56
WORKDIR /etc/local/hugegraph-computer
67
RUN apt-get update && apt-get -y install gettext-base && apt-get -y install wget

computer-dist/src/assembly/static/bin/start-computer.sh

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,17 @@ else
164164
JAVA="$JAVA_HOME/bin/java -server"
165165
fi
166166

167+
# Set up count of cpu if it unspecified from k8s drive,
168+
# avoid `Runtime.getRuntime().availableProcessors()` always return 1
169+
if [[ "${DRIVE}" = "${K8S_DRIVE}" && -z "${CPU_LIMIT}" ]]; then
170+
PROCESSOR_COUNT="$(cat /proc/cpuinfo | grep "processor" | wc -l)"
171+
let MAX_PROCESSOR_COUNT=8
172+
if [[ ${PROCESSOR_COUNT} -gt ${MAX_PROCESSOR_COUNT} ]]; then
173+
PROCESSOR_COUNT="$MAX_PROCESSOR_COUNT"
174+
fi
175+
JAVA_OPTS="${JAVA_OPTS} -XX:ActiveProcessorCount=${PROCESSOR_COUNT}"
176+
fi
177+
167178
if [ ! -a "${CONF_DIR}" ];then
168179
mkdir -p "${CONF_DIR}"
169180
fi
@@ -185,9 +196,9 @@ fi
185196
MAIN_CLASS=com.baidu.hugegraph.computer.dist.HugeGraphComputer
186197

187198
if [ "${LOG4j_CONF}" != "" ]; then
188-
exec ${JAVA} -Dname="hugegraph-computer" "${LOG4j_CONF}" ${JVM_OPTIONS} \
199+
exec ${JAVA} -Dname="hugegraph-computer" "${LOG4j_CONF}" ${JAVA_OPTS} ${JVM_OPTIONS} \
189200
-cp "${CP}" ${MAIN_CLASS} "${NEW_COMPUTER_CONF_PATH}" ${ROLE} ${DRIVE}
190201
else
191-
exec ${JAVA} -Dname="hugegraph-computer" ${JVM_OPTIONS} -cp "${CP}" \
202+
exec ${JAVA} -Dname="hugegraph-computer" ${JAVA_OPTS} ${JVM_OPTIONS} -cp "${CP}" \
192203
${MAIN_CLASS} "${NEW_COMPUTER_CONF_PATH}" ${ROLE} ${DRIVE}
193204
fi

computer-k8s-operator/Dockerfile

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
FROM openjdk:8-jre-alpine
1+
FROM openjdk:11-jre
22
LABEL maintainer="HugeGraph Docker Maintainers <hugegraph@googlegroups.com>"
3-
4-
ENV JAVA_OPTS="-XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap -XX:MaxRAMFraction=2 -XshowSettings:vm"
53
WORKDIR /opt/app
64
COPY target/hugegraph-computer-operator-*.jar hugegraph-computer-operator.jar
75
ENTRYPOINT ["java", "-jar", "hugegraph-computer-operator.jar"]

computer-k8s-operator/README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,14 @@ spec:
5252
image: hugegraph/hugegraph-builtin-algorithms:latest # algorithm image url
5353
jarFile: /opt/jars/hugegraph-builtin-algorithms.jar
5454
pullPolicy: Always
55-
workerInstances: 50
55+
workerCpu: "4"
56+
workerMemory: "4Gi"
57+
workerInstances: 5
5658
computerConf:
59+
job.partitions_count: "20"
5760
algorithm.params_class: com.baidu.hugegraph.computer.algorithm.centrality.pagerank.PageRankParams
5861
hugegraph.url: http://${hugegraph-server-host}:${hugegraph-server-port} # hugegraph server url
59-
job.partitions_count: "200"
60-
hugegraph.name: "hugegraph"
62+
hugegraph.name: hugegraph
6163
EOF
6264
```
6365

computer-k8s-operator/src/main/java/com/baidu/hugegraph/computer/k8s/operator/controller/ComputerJobDeployer.java

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ public class ComputerJobDeployer {
8585
private static final String RPC_PORT_NAME = "rpc-port";
8686
private static final int DEFAULT_TRANSPORT_PORT = 8099;
8787
private static final int DEFAULT_RPC_PORT = 8090;
88-
private static final int DEFAULT_TRANSPORT_THREADS = 8;
8988
private static final String COMPUTER_CONFIG_MAP_VOLUME =
9089
"computer-config-map-volume";
9190

@@ -198,19 +197,6 @@ private Set<ContainerPort> handleConfig(ComputerJobSpec spec) {
198197
config.put(ComputerOptions.RPC_SERVER_PORT.name(), rpcPort);
199198
}
200199

201-
/*
202-
Set a default number of transport threads,
203-
if the number of CPU quantity of the worker is not specified
204-
*/
205-
if (spec.getWorkerCpu() == null) {
206-
String defaultThreads = String.valueOf(DEFAULT_TRANSPORT_THREADS);
207-
208-
config.putIfAbsent(ComputerOptions.TRANSPORT_CLIENT_THREADS.name(),
209-
defaultThreads);
210-
config.putIfAbsent(ComputerOptions.TRANSPORT_SERVER_THREADS.name(),
211-
defaultThreads);
212-
}
213-
214200
ContainerPort transportContainerPort = new ContainerPortBuilder()
215201
.withName(TRANSPORT_PORT_NAME)
216202
.withContainerPort(Integer.valueOf(transportPort))
@@ -471,6 +457,22 @@ private Container getContainer(String name, ComputerJobSpec spec,
471457
memory = spec.getWorkerMemory();
472458
}
473459

460+
if (cpu != null) {
461+
EnvVar cpuLimit = new EnvVarBuilder()
462+
.withName(Constants.ENV_CPU_LIMIT)
463+
.withValue(cpu.toString())
464+
.build();
465+
envVars.add(cpuLimit);
466+
}
467+
468+
if (memory != null) {
469+
EnvVar memoryLimit = new EnvVarBuilder()
470+
.withName(Constants.ENV_MEMORY_LIMIT)
471+
.withValue(memory.toString())
472+
.build();
473+
envVars.add(memoryLimit);
474+
}
475+
474476
List<VolumeMount> volumeMounts = spec.getVolumeMounts();
475477
if (volumeMounts == null) {
476478
volumeMounts = new ArrayList<>();

0 commit comments

Comments
 (0)