Skip to content
Open
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
5 changes: 5 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ jobs:
java-version: ${{ matrix.java }}
distribution: 'temurin'

- name: Install System libaio Packages
run: |
sudo apt-get update
sudo apt-get install -y libaio1 libaio-dev

# use 'install' so smoke-tests will work
# By setting anything to org.apache.activemq.artemis.core.io.aio.AIOSequentialFileFactory.DISABLED we are disabling libaio loading on the testsuite
- name: Fast Tests
Expand Down
5 changes: 5 additions & 0 deletions artemis-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,11 @@
<artifactId>artemis-jms-server</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.artemis</groupId>
<artifactId>artemis-ffm</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.artemis</groupId>
<artifactId>artemis-journal</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Copy link
Copy Markdown
Member

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.

Copy link
Copy Markdown
Author

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?


@Option(names = "--nio", description = "Set the journal as nio.")
private boolean nio;

Expand Down Expand Up @@ -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).");
}
Expand All @@ -1023,7 +1026,9 @@ private void setupJournalType() {
}
}

if (aio) {
if (aio2) {
journalType = JournalType.ASYNCIO_2;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similarly

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.apache.activemq.artemis.core.io.SequentialFile;
import org.apache.activemq.artemis.core.io.SequentialFileFactory;
import org.apache.activemq.artemis.core.io.aio.AIOSequentialFileFactory;
import org.apache.activemq.artemis.core.io.aio2.AIO2Helper;
import org.apache.activemq.artemis.core.io.mapped.MappedSequentialFileFactory;
import org.apache.activemq.artemis.core.io.nio.NIOSequentialFileFactory;
import org.apache.activemq.artemis.core.server.ActiveMQMessageBundle;
Expand Down Expand Up @@ -247,7 +248,12 @@ private static SequentialFileFactory newFactory(File datafolder, boolean datasyn
case ASYNCIO:
factory = new AIOSequentialFileFactory(datafolder, maxAIO).setDatasync(datasync);
factory.start();
((AIOSequentialFileFactory) factory).disableBufferReuse();
factory.disableBufferReuse();
return factory;
case ASYNCIO_2:
factory = AIO2Helper.getAIO2SequentialFileFactory(datafolder, maxAIO).setDatasync(datasync);
factory.start();
factory.disableBufferReuse();
return factory;
case MAPPED:
factory = new MappedSequentialFileFactory(datafolder, fileSize, false, 0, 0, null)
Expand Down
1 change: 1 addition & 0 deletions artemis-features/src/main/resources/features.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
<bundle dependency="true">mvn:org.snakeyaml/snakeyaml-engine/${snakeyaml-engine.version}</bundle>

<bundle>mvn:org.apache.activemq/activemq-artemis-native/${activemq-artemis-native-version}</bundle>
<bundle>mvn:org.apache.artemis/artemis-ffm/${pom.version}</bundle>
<bundle>mvn:org.apache.artemis/artemis-lockmanager-api/${pom.version}</bundle>
<bundle>mvn:org.apache.artemis/artemis-server-osgi/${pom.version}</bundle>
</feature>
Expand Down
184 changes: 184 additions & 0 deletions artemis-ffm/pom.xml
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:="(&amp;(osgi.ee=JavaSE)(version=17))"
</Require-Capability>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The 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 artemis-native version in a different package, I guess) then could it potentially be removed just now? It is supposed to be the case that multi-release stuff has a base version with API in sync, but there are clearly lots of files already that only have java24+ classes, so could this be another?

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.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, this class is never used, let me remove this.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The 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);
}
}
Loading