-
Notifications
You must be signed in to change notification settings - Fork 952
ARTEMIS-5972: Replace JNI with Panama Foreign Function & Memory (FFM)… #6444
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -238,6 +238,9 @@ public class Create extends InstallAbstract { | |
| @Option(names = "--aio", description = "Set the journal as asyncio.") | ||
| private boolean aio; | ||
|
|
||
| @Option(names = "--aio2", description = "Set the journal as asyncio 2 (Panama FFM).") | ||
| private boolean aio2; | ||
|
|
||
| @Option(names = "--nio", description = "Set the journal as nio.") | ||
| private boolean nio; | ||
|
|
||
|
|
@@ -1010,7 +1013,7 @@ private void setupJournalType() { | |
| aio = false; | ||
| } | ||
| } | ||
| int countJournalTypes = countBoolean(aio, nio, mapped); | ||
| int countJournalTypes = countBoolean(aio2, aio, nio, mapped); | ||
| if (countJournalTypes > 1) { | ||
| throw new RuntimeException("You can only select one journal type (--nio | --aio | --mapped)."); | ||
| } | ||
|
|
@@ -1023,7 +1026,9 @@ private void setupJournalType() { | |
| } | ||
| } | ||
|
|
||
| if (aio) { | ||
| if (aio2) { | ||
| journalType = JournalType.ASYNCIO_2; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. similarly
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's decide on an agreeable naming convention. |
||
| } else if (aio) { | ||
| journalType = JournalType.ASYNCIO; | ||
| } else if (nio) { | ||
| journalType = JournalType.NIO; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,184 @@ | ||
| <!-- | ||
| 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. | ||
| --> | ||
| <project xmlns="http://maven.apache.org/POM/4.0.0" | ||
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
| <modelVersion>4.0.0</modelVersion> | ||
| <parent> | ||
| <groupId>org.apache.artemis</groupId> | ||
| <artifactId>artemis-pom</artifactId> | ||
| <version>2.55.0-SNAPSHOT</version> | ||
| <relativePath>../artemis-pom/pom.xml</relativePath> | ||
| </parent> | ||
|
|
||
| <artifactId>artemis-ffm</artifactId> | ||
| <packaging>jar</packaging> | ||
| <name>Apache Artemis FFM</name> | ||
|
|
||
| <properties> | ||
| <test.stress.time>5000</test.stress.time> | ||
|
|
||
| <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
| <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> | ||
|
|
||
| <activemq-surefire-argline> | ||
| -Dtest.stress.time=${test.stress.time} --enable-native-access=ALL-UNNAMED | ||
| </activemq-surefire-argline> | ||
| </properties> | ||
|
|
||
| <dependencies> | ||
| <dependency> | ||
| <groupId>org.slf4j</groupId> | ||
| <artifactId>slf4j-api</artifactId> | ||
| <version>${slf4j.version}</version> | ||
| <scope>provided</scope> | ||
| <!-- License: MIT --> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>junit</groupId> | ||
| <artifactId>junit</artifactId> | ||
| <scope>test</scope> | ||
| <!-- License: EPL 1.0 --> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.junit.vintage</groupId> | ||
| <artifactId>junit-vintage-engine</artifactId> | ||
| <scope>test</scope> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.junit.jupiter</groupId> | ||
| <artifactId>junit-jupiter</artifactId> | ||
| <scope>test</scope> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.slf4j</groupId> | ||
| <artifactId>slf4j-simple</artifactId> | ||
| <version>${slf4j.version}</version> | ||
| <scope>test</scope> | ||
| </dependency> | ||
| </dependencies> | ||
|
|
||
| <profiles> | ||
| <profile> | ||
| <id>jdk24onwards</id> | ||
| <activation> | ||
| <jdk>[24,)</jdk> | ||
| </activation> | ||
| <build> | ||
| <plugins> | ||
| <plugin> | ||
| <artifactId>maven-compiler-plugin</artifactId> | ||
| <configuration> | ||
| <release>24</release> | ||
| </configuration> | ||
| <executions> | ||
| <execution> | ||
| <id>java24-compile</id> | ||
| <phase>compile</phase> | ||
| <goals> | ||
| <goal>compile</goal> | ||
| </goals> | ||
| <configuration> | ||
| <outputDirectory>${project.build.outputDirectory}</outputDirectory> | ||
| <compileSourceRoots> | ||
| <compileSourceRoot>${project.basedir}/src/main/java24</compileSourceRoot> | ||
| </compileSourceRoots> | ||
| </configuration> | ||
| </execution> | ||
| <execution> | ||
| <id>java24-test-compile</id> | ||
| <phase>test-compile</phase> | ||
| <goals> | ||
| <goal>testCompile</goal> | ||
| </goals> | ||
| <configuration> | ||
| <compileSourceRoots>${project.basedir}/src/test/java24</compileSourceRoots> | ||
| </configuration> | ||
| </execution> | ||
| </executions> | ||
| </plugin> | ||
| <plugin> | ||
| <artifactId>maven-jar-plugin</artifactId> | ||
| <!-- Do jar creation earlier, before the "test" phase, so that the | ||
| multi-release-jar content is visible to any dependent modules, | ||
| enabling them to use the relevant classes during their tests. --> | ||
| <executions> | ||
| <execution> | ||
| <id>default-jar</id> | ||
| <phase>package</phase> | ||
| <goals> | ||
| <goal>jar</goal> | ||
| </goals> | ||
| <configuration> | ||
| <archive> | ||
| <manifestEntries> | ||
| <Multi-Release>true</Multi-Release> | ||
| </manifestEntries> | ||
| </archive> | ||
| </configuration> | ||
| </execution> | ||
| </executions> | ||
| </plugin> | ||
| </plugins> | ||
| </build> | ||
| </profile> | ||
| </profiles> | ||
| <build> | ||
| <resources> | ||
| <resource> | ||
| <directory>${basedir}/target/output/</directory> | ||
| </resource> | ||
| </resources> | ||
| <plugins> | ||
| <plugin> | ||
| <groupId>org.apache.felix</groupId> | ||
| <artifactId>maven-bundle-plugin</artifactId> | ||
| <version>5.1.9</version> | ||
| <executions> | ||
| <execution> | ||
| <id>bundle-manifest</id> | ||
| <goals> | ||
| <goal>manifest</goal> | ||
| </goals> | ||
| <phase>process-classes</phase> | ||
| </execution> | ||
| <execution> | ||
| <id>default-bundle</id> | ||
| <goals> | ||
| <goal>bundle</goal> | ||
| </goals> | ||
| <phase>package</phase> | ||
| </execution> | ||
| </executions> | ||
| <configuration> | ||
| <instructions> | ||
| <Bundle-SymbolicName>org.apache.artemis.ffm</Bundle-SymbolicName> | ||
| <Bundle-Version>${project.version}</Bundle-Version> | ||
| <Export-Package>org.apache.artemis.nativo.jlibaio;version="${project.version}"</Export-Package> | ||
| <!-- Use ! for exclusion in bnd --> | ||
| <Import-Package>!java.lang.foreign,*</Import-Package> | ||
| <DynamicImport-Package>*</DynamicImport-Package> | ||
| <Require-Capability> | ||
| osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=17))" | ||
| </Require-Capability> | ||
| </instructions> | ||
| </configuration> | ||
| </plugin> | ||
| </plugins> | ||
| </build> | ||
| </project> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,30 +14,18 @@ | |
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package org.apache.activemq.artemis.core.io.aio; | ||
| package org.apache.artemis.nativo.jlibaio; | ||
|
|
||
| import java.io.Closeable; | ||
| import java.io.IOException; | ||
| import java.nio.channels.FileChannel; | ||
| import java.nio.channels.FileLock; | ||
|
|
||
| import org.apache.activemq.artemis.nativo.jlibaio.LibaioFile; | ||
| public class LibaioContext<Callback extends SubmitInfo> implements Closeable { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is rather a lot of API in here that will need to be kept in check with the Java 24+ variant. I wonder if it might need a checker in future to ensure parity. Alternatively, since its not obvious to me that any pre-Java24 code is referencing this class currently (as its referencing the The isSupported check could be implemented in a single-method class (then called from LibaioContext) with two variants if that still needs to support both, though again its not clear to me that is true yet.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are right, this class is never used, let me remove this.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, I forgot that this is used in test classes, we added this just to reduce the complexity in other modules. I believe the other APIs would not be called, so we can remove those and just keep the isSupported() method. |
||
|
|
||
| public class ActiveMQFileLock extends FileLock { | ||
|
|
||
| private final LibaioFile file; | ||
|
|
||
| public ActiveMQFileLock(final LibaioFile handle) { | ||
| super((FileChannel) null, 0, 0, false); | ||
| this.file = handle; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean isValid() { | ||
| return true; | ||
| public static boolean isSupported() { | ||
| return false; | ||
| } | ||
|
|
||
| @Override | ||
| public void release() throws IOException { | ||
| file.close(); | ||
| public void close() throws IOException { | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| /* | ||
| * 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.artemis.nativo.jlibaio; | ||
|
|
||
| import java.io.Closeable; | ||
| import java.io.IOException; | ||
|
|
||
| public class LibaioFile<Callback extends SubmitInfo> implements Closeable { | ||
|
|
||
| private final String errorMsg = "This is not supported for JDK < 24."; | ||
|
|
||
| LibaioFile(int fd, LibaioContext ctx) { | ||
| } | ||
|
|
||
| public int getBlockSize() throws IOException { | ||
| throw new UnsupportedOperationException(errorMsg); | ||
| } | ||
|
|
||
| public void fill(int alignment, long size) throws IOException { | ||
| throw new UnsupportedOperationException(errorMsg); | ||
| } | ||
|
|
||
| @Override | ||
| public void close() throws IOException { | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| /* | ||
| * 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.artemis.nativo.jlibaio; | ||
|
|
||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
|
|
||
| public class NativeLogger { | ||
|
|
||
| private static final Logger logger = LoggerFactory.getLogger(NativeLogger.class); | ||
|
|
||
| public static final String PROJECT_PREFIX = "jlibaio"; | ||
|
|
||
| private static final int DIFFERENT_VERSION_ID = 163001; | ||
| private static final String DIFFERENT_VERSION = PROJECT_PREFIX + DIFFERENT_VERSION_ID + " You have a native library with a different version than expected"; | ||
|
|
||
| public static final void incompatibleNativeLibrary() { | ||
| logger.warn(DIFFERENT_VERSION); | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd wonder about either something like --aio-ffm, (or maybe just reusing the existing aio option and having an additional toggle that says whether it is ffm or not (i.e jni).
'aio2' seems more like a distinct version of aio, not 'use different way to access same aio version'...and if there ever were such an aio version, it would clash.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aio could have more variants than this, like currently we are using libaio for kernel level I/O operations and later we can replace libaio with io_uring or something else.
So the naming conventions would again change in future.
What if we mention underlying I/O libs something like: --libaio-jni / --libaio-ffm / --iouring-ffm ? or --aio-libaio-jni / --aio-libaio-ffm / --aio-iouring-ffm?
Any suggestions from this POV?