Skip to content

Commit

Permalink
fix 7
Browse files Browse the repository at this point in the history
  • Loading branch information
BePPPower committed Mar 28, 2024
1 parent cc2b1e4 commit 42f0940
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 18 deletions.
5 changes: 0 additions & 5 deletions fe/be-java-extensions/hudi-scanner/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,6 @@ under the License.
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.doris</groupId>
<artifactId>preload-extensions</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
<finalName>hudi-scanner</finalName>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.apache.doris.common.jni.vec.ColumnType;
import org.apache.doris.common.security.authentication.AuthenticationConfig;
import org.apache.doris.common.security.authentication.HadoopUGI;
import org.apache.doris.preload.common.ProcessUtils;

import com.google.common.util.concurrent.ThreadFactoryBuilder;
import org.apache.avro.generic.GenericDatumReader;
Expand Down Expand Up @@ -144,12 +143,12 @@ public void open() throws IOException {
executorService.scheduleAtFixedRate(() -> {
if (!isKilled.get()) {
synchronized (HudiJniScanner.class) {
List<Long> pids = ProcessUtils.getChildProcessIds(
ProcessUtils.getCurrentProcId());
List<Long> pids = Utils.getChildProcessIds(
Utils.getCurrentProcId());
for (long pid : pids) {
String cmd = ProcessUtils.getCommandLine(pid);
String cmd = Utils.getCommandLine(pid);
if (cmd != null && cmd.contains("org.openjdk.jol.vm.sa.AttachMain")) {
ProcessUtils.killProcess(pid);
Utils.killProcess(pid);
isKilled.set(true);
LOG.info("Kill hotspot debugger process " + pid);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,60 @@
import org.apache.doris.common.security.authentication.AuthenticationConfig;
import org.apache.doris.common.security.authentication.HadoopUGI;

import org.apache.commons.io.FileUtils;
import org.apache.hadoop.conf.Configuration;
import org.apache.hudi.common.table.HoodieTableMetaClient;

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;

public class Utils {
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);
}
}

public static HoodieTableMetaClient getMetaClient(Configuration conf, String basePath) {
return HadoopUGI.ugiDoAs(AuthenticationConfig.getKerberosConfig(conf), () -> HoodieTableMetaClient.builder()
.setConf(conf).setBasePath(basePath).build());
Expand Down
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>preload-extensions</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
Expand Up @@ -15,7 +15,7 @@
// specific language governing permissions and limitations
// under the License.

package org.apache.doris.preload.common;
package org.apache.doris.trinoconnector;

import org.apache.commons.io.FileUtils;

Expand Down
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.preload.common.ProcessUtils;

import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
Expand Down

0 comments on commit 42f0940

Please sign in to comment.