Skip to content
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

[fix](trino-connector) fix NoClassDefFoundError of hudi Utils class #32846

Merged
merged 9 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions fe/be-java-extensions/trino-connector-scanner/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@ under the License.
</properties>

<dependencies>
<dependency>
<groupId>org.apache.doris</groupId>
<artifactId>hudi-scanner</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.doris</groupId>
<artifactId>java-common</artifactId>
Expand All @@ -47,6 +42,11 @@ under the License.
<groupId>io.trino</groupId>
<artifactId>trino-main</artifactId>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>${commons-io.version}</version>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
// 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.trinoconnector;

import org.apache.commons.io.FileUtils;

import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.management.ManagementFactory;
import java.util.LinkedList;
import java.util.List;

/**
* Utils for handling processes
*/
public class ProcessUtils {
public static long getCurrentProcId() {
try {
return ManagementFactory.getRuntimeMXBean().getPid();
} catch (Exception e) {
throw new RuntimeException("Couldn't find PID of current JVM process.", e);
}
}

public static List<Long> getChildProcessIds(long pid) {
try {
Process pgrep = (new ProcessBuilder("pgrep", "-P", String.valueOf(pid))).start();
BufferedReader reader = new BufferedReader(new InputStreamReader(pgrep.getInputStream()));
List<Long> result = new LinkedList<>();
String line;
while ((line = reader.readLine()) != null) {
result.add(Long.valueOf(line.trim()));
}
pgrep.waitFor();
return result;
} catch (Exception e) {
throw new RuntimeException("Couldn't get child processes of PID " + pid, e);
}
}

public static String getCommandLine(long pid) {
try {
return FileUtils.readFileToString(new File(String.format("/proc/%d/cmdline", pid))).trim();
} catch (IOException e) {
return null;
}
}

public static void killProcess(long pid) {
try {
Process kill = (new ProcessBuilder("kill", "-9", String.valueOf(pid))).start();
kill.waitFor();
} catch (Exception e) {
throw new RuntimeException("Couldn't kill process PID " + pid, e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@

package org.apache.doris.trinoconnector;

import org.apache.doris.hudi.Utils;

import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
Expand Down Expand Up @@ -115,12 +113,12 @@ private static TrinoConnectorCacheValue loadCache(TrinoConnectorCacheKey key) {
ScheduledExecutorService executorService = Executors.newScheduledThreadPool(1);
executorService.scheduleAtFixedRate(() -> {
if (!isKilled.get()) {
List<Long> pids = Utils.getChildProcessIds(
Utils.getCurrentProcId());
List<Long> pids = ProcessUtils.getChildProcessIds(
ProcessUtils.getCurrentProcId());
for (long pid : pids) {
String cmd = Utils.getCommandLine(pid);
String cmd = ProcessUtils.getCommandLine(pid);
if (cmd != null && cmd.contains("org.openjdk.jol.vm.sa.AttachMain")) {
Utils.killProcess(pid);
ProcessUtils.killProcess(pid);
isKilled.set(true);
}
}
Expand Down
5 changes: 0 additions & 5 deletions regression-test/pipeline/external/conf/regression-conf.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,11 @@ excludeSuites = "000_the_start_sentinel_do_not_touch," + // keep this line as th
"test_cast_string_to_array," +
"test_refresh_mtmv," +
"test_spark_load," +
"test_trino_hive_orc," +
"test_trino_hive_other," +
"test_hive_write_insert," +
"test_broker_load_func," +
"test_hive_write_partitions," +
"zzz_the_end_sentinel_do_not_touch" // keep this line as the last line

// this directories will not be executed
excludeDirectories = "external_table_p0/trino_connector" // unstable

customConf1 = "test_custom_conf_value"

// for test csv with header
Expand Down
3 changes: 0 additions & 3 deletions regression-test/pipeline/p0/conf/regression-conf.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@ excludeSuites = "000_the_start_sentinel_do_not_touch," + // keep this line as th
"test_profile," +
"test_refresh_mtmv," +
"test_spark_load," +
"test_trino_hive_orc," +
"test_trino_hive_other," +
"test_hive_write_insert," +
"test_hive_write_partitions," +
"test_broker_load_func," +
Expand All @@ -83,7 +81,6 @@ excludeDirectories = "000_the_start_sentinel_do_not_touch," + // keep this line
"cloud," +
"nereids_rules_p0/subquery," +
"workload_manager_p1," +
"external_table_p0/trino_connector," + // unstable
"zzz_the_end_sentinel_do_not_touch" // keep this line as the last line

customConf1 = "test_custom_conf_value"
Expand Down
Loading