Skip to content

Commit

Permalink
[Issue #819] revise jdk version check for reflect constructor (#821)
Browse files Browse the repository at this point in the history
  • Loading branch information
bianhq authored Jan 3, 2025
1 parent 53047eb commit 36f5fd2
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
5 changes: 3 additions & 2 deletions pixels-daemon/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,10 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven.plugin.compile.version}</version>
<configuration>
<source>11</source>
<target>11</target>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
</plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand All @@ -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)
Expand Down
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
<maven.compiler.target>8</maven.compiler.target>
<maven.compiler.useIncrementalCompilation>true</maven.compiler.useIncrementalCompilation>
<maven.plugin.source.version>3.1.0</maven.plugin.source.version>
<maven.plugin.compile.version>3.8.1</maven.plugin.compile.version>
<maven.plugin.shade.version>3.2.2</maven.plugin.shade.version>
<maven.plugin.assembly.version>3.5.0</maven.plugin.assembly.version>
<maven.plugin.deploy.version>3.1.0</maven.plugin.deploy.version>
Expand Down

0 comments on commit 36f5fd2

Please # to comment.