Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangstar333 committed Jun 3, 2024
1 parent 60fce37 commit 796f9c0
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
10 changes: 5 additions & 5 deletions be/src/util/jni-util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ jmethodID JniUtil::get_jmx_json_ = nullptr;
jobject JniUtil::jni_scanner_loader_obj_ = nullptr;
jmethodID JniUtil::jni_scanner_loader_method_ = nullptr;
jlong JniUtil::max_jvm_heap_memory_size_ = 0;
jmethodID JniUtil::_drop_udf_cache_method_id = nullptr;
jmethodID JniUtil::_clean_udf_cache_method_id = nullptr;

Status JniUtfCharGuard::create(JNIEnv* env, jstring jstr, JniUtfCharGuard* out) {
DCHECK(jstr != nullptr);
Expand Down Expand Up @@ -443,9 +443,9 @@ Status JniUtil::init_jni_scanner_loader(JNIEnv* env) {
env->CallVoidMethod(jni_scanner_loader_obj_, load_jni_scanner);
RETURN_ERROR_IF_EXC(env);

_drop_udf_cache_method_id = env->GetMethodID(jni_scanner_loader_cls, "removeUdfClassLoader",
"(Ljava/lang/String;)V");
if (_drop_udf_cache_method_id == nullptr) {
_clean_udf_cache_method_id = env->GetMethodID(jni_scanner_loader_cls, "cleanUdfClassLoader",
"(Ljava/lang/String;)V");
if (_clean_udf_cache_method_id == nullptr) {
if (env->ExceptionOccurred()) {
env->ExceptionDescribe();
}
Expand All @@ -458,7 +458,7 @@ Status JniUtil::init_jni_scanner_loader(JNIEnv* env) {
Status JniUtil::clean_udf_class_load_cache(const std::string& function_signature) {
JNIEnv* env = nullptr;
RETURN_IF_ERROR(JniUtil::GetJNIEnv(&env));
env->CallVoidMethod(jni_scanner_loader_obj_, _drop_udf_cache_method_id,
env->CallVoidMethod(jni_scanner_loader_obj_, _clean_udf_cache_method_id,
env->NewStringUTF(function_signature.c_str()));
RETURN_ERROR_IF_EXC(env);
return Status::OK();
Expand Down
2 changes: 1 addition & 1 deletion be/src/util/jni-util.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class JniUtil {
// Thread-local cache of the JNIEnv for this thread.
static __thread JNIEnv* tls_env_;
static jlong max_jvm_heap_memory_size_;
static jmethodID _drop_udf_cache_method_id;
static jmethodID _clean_udf_cache_method_id;
};

/// Helper class for lifetime management of chars from JNI, releasing JNI chars when
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ public static synchronized void cacheClassLoader(String functionSignature, Class
udfLoadedClasses.put(functionSignature, classLoader, expirationTime * 60 * 1000L);
}

public synchronized void removeUdfClassLoader(String functionSignature) {
LOG.info("removeUdfClassLoader for: " + functionSignature);
public synchronized void cleanUdfClassLoader(String functionSignature) {
LOG.info("cleanUdfClassLoader for: " + functionSignature);
udfLoadedClasses.remove(functionSignature);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ private Method findPrepareMethod(Method[] methods) {
return null; // Method not found
}

public ClassLoader getClassLoader(String jarPath, String signature, long expirationTimeMs)
public ClassLoader getClassLoader(String jarPath, String signature, long expirationTime)
throws MalformedURLException, FileNotFoundException {
ClassLoader loader = null;
if (jarPath == null) {
Expand All @@ -155,7 +155,7 @@ public ClassLoader getClassLoader(String jarPath, String signature, long expirat
classLoader = UdfUtils.getClassLoader(jarPath, parent);
loader = classLoader;
if (isStaticLoad) {
ScannerLoader.cacheClassLoader(signature, loader, expirationTimeMs);
ScannerLoader.cacheClassLoader(signature, loader, expirationTime);
}
}
}
Expand All @@ -174,11 +174,11 @@ protected void init(TJavaUdfExecutorCtorParams request, String jarPath, Type fun
LOG.debug("Loading UDF '" + className + "' from " + jarPath);
}
isStaticLoad = request.getFn().isSetIsStaticLoad() && request.getFn().is_static_load;
long expirationTimeMs = 360L; // default is 6 hours
long expirationTime = 360L; // default is 6 hours
if (request.getFn().isSetExpirationTime()) {
expirationTimeMs = request.getFn().getExpirationTime();
expirationTime = request.getFn().getExpirationTime();
}
ClassLoader loader = getClassLoader(jarPath, request.getFn().getSignature(), expirationTimeMs);
ClassLoader loader = getClassLoader(jarPath, request.getFn().getSignature(), expirationTime);
Class<?> c = Class.forName(className, true, loader);
methodAccess = MethodAccess.get(c);
Constructor<?> ctor = c.getConstructor();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ private void analyzeCommon(Analyzer analyzer) throws AnalysisException {
throw new AnalysisException("expirationTime should greater than zero: ");
}
this.expirationTime = timeMinutes;
}
}
}
}

Expand Down

0 comments on commit 796f9c0

Please sign in to comment.