From 36f5fd2156fe0c443e0f7aaff5a17da83826d872 Mon Sep 17 00:00:00 2001 From: Haoqiong Bian Date: Fri, 3 Jan 2025 23:42:02 +0800 Subject: [PATCH] [Issue #819] revise jdk version check for reflect constructor (#821) --- .../common/physical/natives/DirectIoLib.java | 14 +++++++------- pixels-daemon/pom.xml | 5 +++-- .../pixels/daemon/scaling/policy/AIASPolicy.java | 8 ++++---- pom.xml | 1 + 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/pixels-common/src/main/java/io/pixelsdb/pixels/common/physical/natives/DirectIoLib.java b/pixels-common/src/main/java/io/pixelsdb/pixels/common/physical/natives/DirectIoLib.java index 8994eda8a..1f7b98cf0 100644 --- a/pixels-common/src/main/java/io/pixelsdb/pixels/common/physical/natives/DirectIoLib.java +++ b/pixels-common/src/main/java/io/pixelsdb/pixels/common/physical/natives/DirectIoLib.java @@ -86,25 +86,25 @@ public class DirectIoLib { if (JavaVersion <= 11) { - // this is from sun.nio.ch.Util.initDBBRConstructor + // This is from sun.nio.ch.Util.initDBBRConstructor. Class cl = Class.forName("java.nio.DirectByteBufferR"); directByteBufferRConstructor = cl.getDeclaredConstructor( int.class, long.class, FileDescriptor.class, Runnable.class); } - else if (JavaVersion <= 17) + else if (JavaVersion < 21) { - /* the creator of DirectByteBufferR is changed after java 11 and is not compatible with java 8. + /* The creator of DirectByteBufferR is changed after java 11 and is not compatible with java 8. * Therefore, we use DirectByteBuffer to create direct read only buffer. */ Class cl = Class.forName("java.nio.DirectByteBuffer"); - directByteBufferRConstructor = cl.getDeclaredConstructor( - long.class, int.class); + directByteBufferRConstructor = cl.getDeclaredConstructor(long.class, int.class); } else { + /* the creator of DirectByteBuffer is changed in java 21+. + */ Class cl = Class.forName("java.nio.DirectByteBuffer"); - directByteBufferRConstructor = cl.getDeclaredConstructor( - long.class, long.class); + directByteBufferRConstructor = cl.getDeclaredConstructor(long.class, long.class); } directByteBufferRConstructor.setAccessible(true); diff --git a/pixels-daemon/pom.xml b/pixels-daemon/pom.xml index cb7debf07..71d4a0afb 100644 --- a/pixels-daemon/pom.xml +++ b/pixels-daemon/pom.xml @@ -197,9 +197,10 @@ org.apache.maven.plugins maven-compiler-plugin + ${maven.plugin.compile.version} - 11 - 11 + 8 + 8 diff --git a/pixels-daemon/src/main/java/io/pixelsdb/pixels/daemon/scaling/policy/AIASPolicy.java b/pixels-daemon/src/main/java/io/pixelsdb/pixels/daemon/scaling/policy/AIASPolicy.java index 4c3180a89..c0b15fd2b 100644 --- a/pixels-daemon/src/main/java/io/pixelsdb/pixels/daemon/scaling/policy/AIASPolicy.java +++ b/pixels-daemon/src/main/java/io/pixelsdb/pixels/daemon/scaling/policy/AIASPolicy.java @@ -19,9 +19,6 @@ */ package io.pixelsdb.pixels.daemon.scaling.policy; -import java.io.IOException; -import java.io.InputStreamReader; - import io.grpc.ManagedChannel; import io.grpc.ManagedChannelBuilder; import io.pixelsdb.pixels.common.utils.ConfigFactory; @@ -31,6 +28,8 @@ import org.apache.logging.log4j.Logger; import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; import java.util.Arrays; public class AIASPolicy extends Policy @@ -49,7 +48,8 @@ private void scaling(double[] cpuTimes, double[] memUsages) log.info("INFO: expend to "+ WorkerNum1 + " or " + WorkerNum2); } - public boolean transDump(long timestamp){ + public boolean transDump(long timestamp) + { String host = ConfigFactory.Instance().getProperty("trans.server.host"); int port = Integer.parseInt(ConfigFactory.Instance().getProperty("trans.server.port")); ManagedChannel channel = ManagedChannelBuilder.forAddress(host,port) diff --git a/pom.xml b/pom.xml index 9b9462d1c..c604a6bbc 100644 --- a/pom.xml +++ b/pom.xml @@ -68,6 +68,7 @@ 8 true 3.1.0 + 3.8.1 3.2.2 3.5.0 3.1.0