[JDK] Support OpenJDK (#2804)
Support compile and running Frontend process and Broker process with OpenJDK. OpenJDK 13 is tested.
This commit is contained in:
@ -15,8 +15,7 @@
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
#ifndef BDG_PALO_BE_SRC_QUERY_EXEC_ES_SCAN_NODE_H
|
||||
#define BDG_PALO_BE_SRC_QUERY_EXEC_ES_SCAN_NODE_H
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
@ -89,4 +88,3 @@ private:
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@ -91,17 +91,17 @@ std::string print_plan_node_type(const TPlanNodeType::type& type) {
|
||||
|
||||
std::string get_build_version(bool compact) {
|
||||
std::stringstream ss;
|
||||
ss << PALO_BUILD_VERSION
|
||||
ss << DORIS_BUILD_VERSION
|
||||
#ifdef NDEBUG
|
||||
<< " RELEASE"
|
||||
#else
|
||||
<< " DEBUG"
|
||||
#endif
|
||||
<< " (build " << PALO_BUILD_HASH
|
||||
<< " (build " << DORIS_BUILD_HASH
|
||||
<< ")";
|
||||
|
||||
if (!compact) {
|
||||
ss << std::endl << "Built on " << PALO_BUILD_TIME << " by " << PALO_BUILD_INFO;
|
||||
ss << std::endl << "Built on " << DORIS_BUILD_TIME << " by " << DORIS_BUILD_INFO;
|
||||
}
|
||||
|
||||
return ss.str();
|
||||
|
||||
@ -69,6 +69,48 @@ if [ "$JAVA_HOME" = "" ]; then
|
||||
fi
|
||||
JAVA=$JAVA_HOME/bin/java
|
||||
|
||||
# get jdk version, return version as an Integer.
|
||||
# 1.8 => 8, 13.0 => 13
|
||||
jdk_version() {
|
||||
local result
|
||||
local java_cmd=$JAVA_HOME/bin/java
|
||||
local IFS=$'\n'
|
||||
# remove \r for Cygwin
|
||||
local lines=$("$java_cmd" -Xms32M -Xmx32M -version 2>&1 | tr '\r' '\n')
|
||||
if [[ -z $java_cmd ]]
|
||||
then
|
||||
result=no_java
|
||||
else
|
||||
for line in $lines; do
|
||||
if [[ (-z $result) && ($line = *"version \""*) ]]
|
||||
then
|
||||
local ver=$(echo $line | sed -e 's/.*version "\(.*\)"\(.*\)/\1/; 1q')
|
||||
# on macOS, sed doesn't support '?'
|
||||
if [[ $ver = "1."* ]]
|
||||
then
|
||||
result=$(echo $ver | sed -e 's/1\.\([0-9]*\)\(.*\)/\1/; 1q')
|
||||
else
|
||||
result=$(echo $ver | sed -e 's/\([0-9]*\)\(.*\)/\1/; 1q')
|
||||
fi
|
||||
fi
|
||||
done
|
||||
fi
|
||||
echo "$result"
|
||||
}
|
||||
|
||||
# check java version and choose correct JAVA_OPTS
|
||||
java_version=$(jdk_version)
|
||||
final_java_opt=$JAVA_OPTS
|
||||
if [ $java_version -gt 8 ]; then
|
||||
if [ -z "$JAVA_OPTS_FOR_JDK_9" ]; then
|
||||
echo "JAVA_OPTS_FOR_JDK_9 is not set in fe.conf" >> $LOG_DIR/fe.out
|
||||
exit -1
|
||||
fi
|
||||
final_java_opt=$JAVA_OPTS_FOR_JDK_9
|
||||
fi
|
||||
echo "using java version $java_version" >> $LOG_DIR/fe.out
|
||||
echo $final_java_opt >> $LOG_DIR/fe.out
|
||||
|
||||
# add libs to CLASSPATH
|
||||
for f in $DORIS_HOME/lib/*.jar; do
|
||||
CLASSPATH=$f:${CLASSPATH};
|
||||
@ -102,9 +144,9 @@ if [ x"$HELPER" != x"" ]; then
|
||||
fi
|
||||
|
||||
if [ ${RUN_DAEMON} -eq 1 ]; then
|
||||
nohup $LIMIT $JAVA $JAVA_OPTS org.apache.doris.PaloFe ${HELPER} "$@" >> $LOG_DIR/fe.out 2>&1 </dev/null &
|
||||
nohup $LIMIT $JAVA $final_java_opt org.apache.doris.PaloFe ${HELPER} "$@" >> $LOG_DIR/fe.out 2>&1 </dev/null &
|
||||
else
|
||||
$LIMIT $JAVA $JAVA_OPTS org.apache.doris.PaloFe ${HELPER} "$@" >> $LOG_DIR/fe.out 2>&1 </dev/null
|
||||
$LIMIT $JAVA $final_java_opt org.apache.doris.PaloFe ${HELPER} "$@" >> $LOG_DIR/fe.out 2>&1 </dev/null
|
||||
fi
|
||||
|
||||
echo $! > $pidfile
|
||||
|
||||
@ -25,7 +25,10 @@
|
||||
LOG_DIR = ${DORIS_HOME}/log
|
||||
|
||||
DATE = `date +%Y%m%d-%H%M%S`
|
||||
JAVA_OPTS="-Xmx4096m -XX:+UseMembar -XX:SurvivorRatio=8 -XX:MaxTenuringThreshold=7 -XX:+PrintGCDateStamps -XX:+PrintGCDetails -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:+UseCMSCompactAtFullCollection -XX:CMSFullGCsBeforeCompaction=0 -XX:+CMSClassUnloadingEnabled -XX:-CMSParallelRemarkEnabled -XX:CMSInitiatingOccupancyFraction=80 -XX:SoftRefLRUPolicyMSPerMB=0 -Xloggc:$DORIS_HOME/log/fe.gc.log.$DATE"
|
||||
JAVA_OPTS="-Xmx4096m -XX:+UseMembar -XX:SurvivorRatio=8 -XX:MaxTenuringThreshold=7 -XX:+PrintGCDateStamps -XX:+PrintGCDetails -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:+CMSClassUnloadingEnabled -XX:-CMSParallelRemarkEnabled -XX:CMSInitiatingOccupancyFraction=80 -XX:SoftRefLRUPolicyMSPerMB=0 -Xloggc:$DORIS_HOME/log/fe.gc.log.$DATE"
|
||||
|
||||
# For jdk 9+, this JAVA_OPTS will be used as default JVM options
|
||||
JAVA_OPTS_FOR_JDK_9="-Xmx4096m -XX:SurvivorRatio=8 -XX:MaxTenuringThreshold=7 -XX:+CMSClassUnloadingEnabled -XX:-CMSParallelRemarkEnabled -XX:CMSInitiatingOccupancyFraction=80 -XX:SoftRefLRUPolicyMSPerMB=0 -Xlog:gc*:$DORIS_HOME/log/fe.gc.log.$DATE:time"
|
||||
|
||||
##
|
||||
## the lowercase properties are read by main program.
|
||||
|
||||
22
fe/pom.xml
22
fe/pom.xml
@ -528,6 +528,28 @@ under the License.
|
||||
<version>3.6.5.Final</version>
|
||||
</dependency>
|
||||
|
||||
<!-- support jdk9 -->
|
||||
<dependency>
|
||||
<groupId>javax.annotation</groupId>
|
||||
<artifactId>javax.annotation-api</artifactId>
|
||||
<version>1.3.2</version>
|
||||
</dependency>
|
||||
|
||||
<!-- support jdk9 -->
|
||||
<dependency>
|
||||
<groupId>com.sun.activation</groupId>
|
||||
<artifactId>javax.activation</artifactId>
|
||||
<version>1.2.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- support jdk11 -->
|
||||
<!-- https://mvnrepository.com/artifact/javax.xml.ws/jaxws-api -->
|
||||
<dependency>
|
||||
<groupId>javax.xml.ws</groupId>
|
||||
<artifactId>jaxws-api</artifactId>
|
||||
<version>2.3.0</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
@ -22,6 +22,7 @@ import org.apache.doris.common.CommandLineOptions;
|
||||
import org.apache.doris.common.Config;
|
||||
import org.apache.doris.common.Log4jConfig;
|
||||
import org.apache.doris.common.Version;
|
||||
import org.apache.doris.common.util.JdkUtils;
|
||||
import org.apache.doris.http.HttpServer;
|
||||
import org.apache.doris.journal.bdbje.BDBTool;
|
||||
import org.apache.doris.journal.bdbje.BDBToolOptions;
|
||||
@ -70,6 +71,7 @@ public class PaloFe {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
CommandLineOptions cmdLineOpts = parseArgs(args);
|
||||
System.out.println(cmdLineOpts.toString());
|
||||
|
||||
@ -81,6 +83,12 @@ public class PaloFe {
|
||||
|
||||
// init config
|
||||
new Config().init(dorisHomeDir + "/conf/fe.conf");
|
||||
|
||||
// check it after Config is initialized, otherwise the config 'check_java_version' won't work.
|
||||
if (!JdkUtils.checkJavaVersion()) {
|
||||
throw new IllegalArgumentException("Java version doesn't match");
|
||||
}
|
||||
|
||||
Log4jConfig.initLogging();
|
||||
|
||||
// set dns cache ttl
|
||||
@ -116,7 +124,7 @@ public class PaloFe {
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
System.exit(-1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@ -233,10 +241,11 @@ public class PaloFe {
|
||||
|
||||
private static void checkCommandLineOptions(CommandLineOptions cmdLineOpts) {
|
||||
if (cmdLineOpts.isVersion()) {
|
||||
System.out.println("Build version: " + Version.PALO_BUILD_VERSION);
|
||||
System.out.println("Build time: " + Version.PALO_BUILD_TIME);
|
||||
System.out.println("Build info: " + Version.PALO_BUILD_INFO);
|
||||
System.out.println("Build hash: " + Version.PALO_BUILD_HASH);
|
||||
System.out.println("Build version: " + Version.DORIS_BUILD_VERSION);
|
||||
System.out.println("Build time: " + Version.DORIS_BUILD_TIME);
|
||||
System.out.println("Build info: " + Version.DORIS_BUILD_INFO);
|
||||
System.out.println("Build hash: " + Version.DORIS_BUILD_HASH);
|
||||
System.out.println("Java compile version: " + Version.DORIS_JAVA_COMPILE_VERSION);
|
||||
System.exit(0);
|
||||
} else if (cmdLineOpts.runBdbTools()) {
|
||||
BDBTool bdbTool = new BDBTool(Catalog.getCurrentCatalog().getBdbDir(), cmdLineOpts.getBdbToolOpts());
|
||||
@ -275,3 +284,4 @@ public class PaloFe {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -993,5 +993,11 @@ public class Config extends ConfigBase {
|
||||
*/
|
||||
@ConfField(mutable = true, masterOnly = true)
|
||||
public static int max_running_rollup_job_num_per_table = 1;
|
||||
|
||||
/*
|
||||
* If set to true, Doris will check if the compiled and running versions of Java are compatible
|
||||
*/
|
||||
@ConfField
|
||||
public static boolean check_java_version = true;
|
||||
}
|
||||
|
||||
|
||||
76
fe/src/main/java/org/apache/doris/common/util/JdkUtils.java
Normal file
76
fe/src/main/java/org/apache/doris/common/util/JdkUtils.java
Normal file
@ -0,0 +1,76 @@
|
||||
// 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.doris.common.util;
|
||||
|
||||
import org.apache.doris.common.Config;
|
||||
import org.apache.doris.common.Version;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
|
||||
public class JdkUtils {
|
||||
|
||||
/*
|
||||
* Doris will check if the compiled and running versions of Java are compatible.
|
||||
* The principle the java version at runtime should higher than or equal to the
|
||||
* java version at compile time
|
||||
*/
|
||||
@VisibleForTesting
|
||||
public static boolean checkJavaVersion() {
|
||||
if (!Config.check_java_version) {
|
||||
return true;
|
||||
}
|
||||
|
||||
String javaCompileVersionStr = getJavaVersionFromFullVersion(Version.DORIS_JAVA_COMPILE_VERSION);
|
||||
String javaRuntimeVersionStr = System.getProperty("java.version");
|
||||
|
||||
int compileVersion = JdkUtils.getJavaVersionAsInteger(javaCompileVersionStr);
|
||||
int runtimeVersion = JdkUtils.getJavaVersionAsInteger(javaRuntimeVersionStr);
|
||||
|
||||
if (runtimeVersion < compileVersion) {
|
||||
System.out.println("The runtime java version " + javaRuntimeVersionStr + " is less than "
|
||||
+ "compile version " + javaCompileVersionStr);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Input: openjdk full 'version "13.0.1+9"', 'java full version "1.8.0_131-b11"'
|
||||
* Output: '13.0.1+9', '1.8.0_131-b11'
|
||||
*/
|
||||
public static String getJavaVersionFromFullVersion(String fullVersionStr) {
|
||||
int begin = fullVersionStr.indexOf("\"");
|
||||
int end = fullVersionStr.lastIndexOf("\"");
|
||||
String versionStr = fullVersionStr.substring(begin + 1, end);
|
||||
return versionStr;
|
||||
}
|
||||
|
||||
/*
|
||||
* Input: '13.0.1+9', '1.8.0_131-b11'
|
||||
* Output: 13, 8
|
||||
*/
|
||||
public static int getJavaVersionAsInteger(String javaVersionStr) {
|
||||
String[] parts = javaVersionStr.split("\\.");
|
||||
if (parts[0].equals("1")) {
|
||||
return Integer.valueOf(parts[1]);
|
||||
} else {
|
||||
return Integer.valueOf(parts[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -17,17 +17,17 @@
|
||||
|
||||
package org.apache.doris.http.action;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.doris.common.Version;
|
||||
import org.apache.doris.http.ActionController;
|
||||
import org.apache.doris.http.BaseRequest;
|
||||
import org.apache.doris.http.BaseResponse;
|
||||
import org.apache.doris.http.IllegalArgException;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import io.netty.handler.codec.http.HttpMethod;
|
||||
import oshi.SystemInfo;
|
||||
import oshi.hardware.CentralProcessor;
|
||||
@ -67,10 +67,10 @@ public class IndexAction extends WebBaseAction {
|
||||
private void appendVersionInfo(StringBuilder buffer) {
|
||||
buffer.append("<h2>Version</h2>");
|
||||
buffer.append("<pre>version info<br/>");
|
||||
buffer.append("Version: " + Version.PALO_BUILD_VERSION + "<br/>");
|
||||
buffer.append("Git: " + Version.PALO_BUILD_HASH + "<br/>");
|
||||
buffer.append("Build Info: " + Version.PALO_BUILD_INFO + "<br/>");
|
||||
buffer.append("Build Time: " + Version.PALO_BUILD_TIME + "<br/>");
|
||||
buffer.append("Version: " + Version.DORIS_BUILD_VERSION + "<br/>");
|
||||
buffer.append("Git: " + Version.DORIS_BUILD_HASH + "<br/>");
|
||||
buffer.append("Build Info: " + Version.DORIS_BUILD_INFO + "<br/>");
|
||||
buffer.append("Build Time: " + Version.DORIS_BUILD_TIME + "<br/>");
|
||||
buffer.append("</pre>");
|
||||
}
|
||||
|
||||
|
||||
@ -27,7 +27,7 @@ import java.time.ZoneId;
|
||||
// NOTE: If you want access your variable safe, please hold VariableMgr's lock before access.
|
||||
public final class GlobalVariable {
|
||||
@VariableMgr.VarAttr(name = "version_comment", flag = VariableMgr.READ_ONLY)
|
||||
public static String versionComment = "Doris version " + Version.PALO_BUILD_VERSION;
|
||||
public static String versionComment = "Doris version " + Version.DORIS_BUILD_VERSION;
|
||||
|
||||
@VariableMgr.VarAttr(name = "version", flag = VariableMgr.READ_ONLY)
|
||||
public static String version = "5.1.0";
|
||||
|
||||
@ -136,7 +136,7 @@ public class StmtExecutor {
|
||||
|
||||
summaryProfile.addInfoString(ProfileManager.QUERY_TYPE, "Query");
|
||||
summaryProfile.addInfoString(ProfileManager.QUERY_STATE, context.getState().toString());
|
||||
summaryProfile.addInfoString("Doris Version", Version.PALO_BUILD_VERSION);
|
||||
summaryProfile.addInfoString("Doris Version", Version.DORIS_BUILD_VERSION);
|
||||
summaryProfile.addInfoString(ProfileManager.USER, context.getQualifiedUser());
|
||||
summaryProfile.addInfoString(ProfileManager.DEFAULT_DB, context.getDatabase());
|
||||
summaryProfile.addInfoString(ProfileManager.SQL_STATEMENT, originStmt);
|
||||
|
||||
@ -18,6 +18,7 @@
|
||||
package org.apache.doris.rpc;
|
||||
|
||||
import org.apache.doris.common.Config;
|
||||
import org.apache.doris.common.util.JdkUtils;
|
||||
import org.apache.doris.proto.PCancelPlanFragmentRequest;
|
||||
import org.apache.doris.proto.PCancelPlanFragmentResult;
|
||||
import org.apache.doris.proto.PExecPlanFragmentResult;
|
||||
@ -31,6 +32,8 @@ import org.apache.doris.thrift.TExecPlanFragmentParams;
|
||||
import org.apache.doris.thrift.TNetworkAddress;
|
||||
import org.apache.doris.thrift.TUniqueId;
|
||||
|
||||
import com.baidu.bjf.remoting.protobuf.utils.JDKCompilerHelper;
|
||||
import com.baidu.bjf.remoting.protobuf.utils.compiler.JdkCompiler;
|
||||
import com.baidu.jprotobuf.pbrpc.client.ProtobufRpcProxy;
|
||||
import com.baidu.jprotobuf.pbrpc.transport.RpcClient;
|
||||
import com.baidu.jprotobuf.pbrpc.transport.RpcClientOptions;
|
||||
@ -53,6 +56,11 @@ public class BackendServiceProxy {
|
||||
|
||||
private static BackendServiceProxy INSTANCE;
|
||||
|
||||
static {
|
||||
int javaRuntimeVersion = JdkUtils.getJavaVersionAsInteger(System.getProperty("java.version"));
|
||||
JDKCompilerHelper.setCompiler(new JdkCompiler(JdkCompiler.class.getClassLoader(), String.valueOf(javaRuntimeVersion)));
|
||||
}
|
||||
|
||||
public BackendServiceProxy() {
|
||||
final RpcClientOptions rpcOptions = new RpcClientOptions();
|
||||
rpcOptions.setMaxWait(Config.brpc_idle_wait_max_time);
|
||||
|
||||
@ -257,7 +257,7 @@ public class ExportExportingTask extends MasterTask {
|
||||
|
||||
summaryProfile.addInfoString(ProfileManager.QUERY_TYPE, "Query");
|
||||
summaryProfile.addInfoString(ProfileManager.QUERY_STATE, job.getState().toString());
|
||||
summaryProfile.addInfoString("Doris Version", Version.PALO_BUILD_VERSION);
|
||||
summaryProfile.addInfoString("Doris Version", Version.DORIS_BUILD_VERSION);
|
||||
summaryProfile.addInfoString(ProfileManager.USER, "xxx");
|
||||
summaryProfile.addInfoString(ProfileManager.DEFAULT_DB, String.valueOf(job.getDbId()));
|
||||
summaryProfile.addInfoString(ProfileManager.SQL_STATEMENT, job.getSql());
|
||||
|
||||
48
fe/src/test/java/org/apache/doris/common/JdkUtilsTest.java
Normal file
48
fe/src/test/java/org/apache/doris/common/JdkUtilsTest.java
Normal file
@ -0,0 +1,48 @@
|
||||
// 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.doris.common;
|
||||
|
||||
import org.apache.doris.common.util.JdkUtils;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class JdkUtilsTest {
|
||||
|
||||
@Test
|
||||
public void testNormal() {
|
||||
Assert.assertTrue(JdkUtils.checkJavaVersion());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFunctions() {
|
||||
String versionStr = JdkUtils.getJavaVersionFromFullVersion("java full version \"1.8.0_131-b11\"");
|
||||
Assert.assertEquals("1.8.0_131-b11", versionStr);
|
||||
versionStr = JdkUtils.getJavaVersionFromFullVersion("openjdk full version \"13.0.1+9\"");
|
||||
Assert.assertEquals("13.0.1+9", versionStr);
|
||||
|
||||
int version = JdkUtils.getJavaVersionAsInteger("1.8.0_131-b11");
|
||||
Assert.assertEquals(8, version);
|
||||
version = JdkUtils.getJavaVersionAsInteger("1.7.0_79-b15");
|
||||
Assert.assertEquals(7, version);
|
||||
version = JdkUtils.getJavaVersionAsInteger("13.0.1+9");
|
||||
Assert.assertEquals(13, version);
|
||||
version = JdkUtils.getJavaVersionAsInteger("11.0.0+7");
|
||||
Assert.assertEquals(11, version);
|
||||
}
|
||||
}
|
||||
@ -5,14 +5,11 @@
|
||||
|
||||
package org.apache.doris.common.jmockit;
|
||||
|
||||
import sun.reflect.FieldAccessor;
|
||||
import sun.reflect.ReflectionFactory;
|
||||
|
||||
import java.lang.reflect.AccessibleObject;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.lang.reflect.Type;
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.lang.reflect.Type;
|
||||
import java.lang.reflect.TypeVariable;
|
||||
|
||||
|
||||
@ -225,7 +222,7 @@ public final class FieldReflection {
|
||||
}
|
||||
try {
|
||||
if (Modifier.isStatic(field.getModifiers()) && Modifier.isFinal(field.getModifiers())) {
|
||||
setStaticFinalField(field, value);
|
||||
throw new IllegalArgumentException("Do not allow to set static final field");
|
||||
} else {
|
||||
makeAccessible(field);
|
||||
field.set(targetObject, value);
|
||||
@ -236,6 +233,7 @@ public final class FieldReflection {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
private static void setStaticFinalField(Field field, Object value) throws IllegalAccessException {
|
||||
if (field == null) {
|
||||
throw new IllegalStateException();
|
||||
@ -246,13 +244,14 @@ public final class FieldReflection {
|
||||
} catch (NoSuchFieldException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
|
||||
modifiersField.setAccessible(true);
|
||||
int nonFinalModifiers = modifiersField.getInt(field) - 16;
|
||||
modifiersField.setInt(field, nonFinalModifiers);
|
||||
FieldAccessor accessor = ReflectionFactory.getReflectionFactory().newFieldAccessor(field, false);
|
||||
accessor.set((Object)null, value);
|
||||
}
|
||||
*/
|
||||
|
||||
public static Class<?> getClassType(Type declaredType) {
|
||||
while(!(declaredType instanceof Class)) {
|
||||
@ -285,3 +284,4 @@ public final class FieldReflection {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -21,6 +21,7 @@ import org.apache.doris.catalog.Catalog;
|
||||
import org.apache.doris.common.util.Util;
|
||||
import org.apache.doris.deploy.impl.AmbariDeployManager;
|
||||
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
@ -44,7 +45,7 @@ public class AmbariDeployManagerTest {
|
||||
|
||||
Field encodedAuthInfoF = manager.getClass().getDeclaredField("encodedAuthInfo");
|
||||
encodedAuthInfoF.setAccessible(true);
|
||||
encodedAuthInfoF.set(manager, new sun.misc.BASE64Encoder().encode("admin:admin".getBytes()));
|
||||
encodedAuthInfoF.set(manager, Base64.encodeBase64String("admin:admin".getBytes()));
|
||||
|
||||
Field ambariUrlF = manager.getClass().getDeclaredField("ambariUrl");
|
||||
ambariUrlF.setAccessible(true);
|
||||
|
||||
@ -258,6 +258,14 @@ under the License.
|
||||
<version>1.7.5</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- support jdk9 -->
|
||||
<dependency>
|
||||
<groupId>javax.annotation</groupId>
|
||||
<artifactId>javax.annotation-api</artifactId>
|
||||
<version>1.3.2</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
@ -44,7 +44,7 @@ then
|
||||
echo "DORIS_HOME: ${DORIS_HOME}"
|
||||
fi
|
||||
|
||||
if [[ -z ${PALO_TEST_BINARY_DIR} ]]; then
|
||||
if [[ -z ${DORIS_TEST_BINARY_DIR} ]]; then
|
||||
if [ -e ${DORIS_HOME}/gensrc/build/java/org/apache/doris/common/Version.java \
|
||||
-a -e ${DORIS_HOME}/gensrc/build/gen_cpp/version.h ]; then
|
||||
exit
|
||||
@ -73,6 +73,20 @@ build_hash="${url}@${revision}"
|
||||
build_time="${date}"
|
||||
build_info="${user}@${hostname}"
|
||||
|
||||
java_cmd=
|
||||
if [[ (-n "$JAVA_HOME") && (-x "$JAVA_HOME/bin/java") ]]; then
|
||||
java_cmd="$JAVA_HOME/bin/java"
|
||||
else
|
||||
echo "JAVA_HOME is not set, or java bin is not found"
|
||||
exit -1
|
||||
fi
|
||||
|
||||
java_version_str=`$java_cmd -fullversion 2>&1`
|
||||
java_version_str=$(echo $java_version_str | sed -e 's/"/\\"/g')
|
||||
|
||||
echo "get java cmd: $java_cmd"
|
||||
echo "get java version: $java_version_str"
|
||||
|
||||
VERSION_PACKAGE="${DORIS_HOME}/gensrc/build/java/org/apache/doris/common"
|
||||
mkdir -p ${VERSION_PACKAGE}
|
||||
cat >"${VERSION_PACKAGE}/Version.java" <<EOF
|
||||
@ -96,21 +110,23 @@ cat >"${VERSION_PACKAGE}/Version.java" <<EOF
|
||||
package org.apache.doris.common;
|
||||
|
||||
// This is a generated file, DO NOT EDIT IT.
|
||||
// To change this file, see palo/src/common/version-info
|
||||
// To change this file, see gensrc/script/gen_build_version.sh
|
||||
// the file should be placed in src/java/org/apache/doris/common/Version.java
|
||||
|
||||
public class Version {
|
||||
|
||||
public static final String PALO_BUILD_VERSION = "${build_version}";
|
||||
public static final String PALO_BUILD_HASH = "${build_hash}";
|
||||
public static final String PALO_BUILD_TIME = "${build_time}";
|
||||
public static final String PALO_BUILD_INFO = "${build_info}";
|
||||
public static final String DORIS_BUILD_VERSION = "${build_version}";
|
||||
public static final String DORIS_BUILD_HASH = "${build_hash}";
|
||||
public static final String DORIS_BUILD_TIME = "${build_time}";
|
||||
public static final String DORIS_BUILD_INFO = "${build_info}";
|
||||
public static final String DORIS_JAVA_COMPILE_VERSION = "${java_version_str}";
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println("palo_build_version: " + PALO_BUILD_VERSION);
|
||||
System.out.println("palo_build_hash: " + PALO_BUILD_HASH);
|
||||
System.out.println("palo_build_time: " + PALO_BUILD_TIME);
|
||||
System.out.println("palo_build_info: " + PALO_BUILD_INFO);
|
||||
System.out.println("doris_build_version: " + DORIS_BUILD_VERSION);
|
||||
System.out.println("doris_build_hash: " + DORIS_BUILD_HASH);
|
||||
System.out.println("doris_build_time: " + DORIS_BUILD_TIME);
|
||||
System.out.println("doris_build_info: " + DORIS_BUILD_INFO);
|
||||
System.out.println("doris_java_compile_version: " + DORIS_JAVA_COMPILE_VERSION);
|
||||
}
|
||||
|
||||
}
|
||||
@ -137,18 +153,18 @@ cat >"${GEN_CPP_DIR}/version.h" <<EOF
|
||||
// under the License.
|
||||
|
||||
// This is a generated file, DO NOT EDIT IT.
|
||||
// To change this file, see bin/gen_build_version.sh
|
||||
// the file should be placed in src/be/src/common/version.h
|
||||
// To change this file, see gensrc/script/gen_build_version.sh
|
||||
// the file should be placed in gensrc/build/gen_cpp/version.h
|
||||
|
||||
#ifndef PALO_GEN_CPP_VERSION_H
|
||||
#define PALO_GEN_CPP_VERSION_H
|
||||
#ifndef DORIS_GEN_CPP_VERSION_H
|
||||
#define DORIS_GEN_CPP_VERSION_H
|
||||
|
||||
namespace doris {
|
||||
|
||||
#define PALO_BUILD_VERSION "${build_version}"
|
||||
#define PALO_BUILD_HASH "${build_hash}"
|
||||
#define PALO_BUILD_TIME "${build_time}"
|
||||
#define PALO_BUILD_INFO "${build_info}"
|
||||
#define DORIS_BUILD_VERSION "${build_version}"
|
||||
#define DORIS_BUILD_HASH "${build_hash}"
|
||||
#define DORIS_BUILD_TIME "${build_time}"
|
||||
#define DORIS_BUILD_INFO "${build_info}"
|
||||
|
||||
} // namespace doris
|
||||
|
||||
|
||||
Reference in New Issue
Block a user