Skip to content

Commit d20457f

Browse files
ARTEMIS-5972: Create a Panama / FFM module for native implementations, which is now introducing libaio.
In the configuration we are naming it as ASYNCIO_2. Co-Authored-By: Clebert Suconic <clebertsuconic@apache.org>
1 parent 9754483 commit d20457f

62 files changed

Lines changed: 7632 additions & 31 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ jobs:
5555
java-version: ${{ matrix.java }}
5656
distribution: 'temurin'
5757

58+
- name: Install System libaio Packages
59+
run: |
60+
sudo apt-get update
61+
sudo apt-get install -y libaio1 libaio-dev
62+
5863
# use 'install' so smoke-tests will work
5964
# By setting anything to org.apache.activemq.artemis.core.io.aio.AIOSequentialFileFactory.DISABLED we are disabling libaio loading on the testsuite
6065
- name: Fast Tests

artemis-bom/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,11 @@
166166
<artifactId>artemis-jms-server</artifactId>
167167
<version>${project.version}</version>
168168
</dependency>
169+
<dependency>
170+
<groupId>org.apache.artemis</groupId>
171+
<artifactId>artemis-ffm</artifactId>
172+
<version>${project.version}</version>
173+
</dependency>
169174
<dependency>
170175
<groupId>org.apache.artemis</groupId>
171176
<artifactId>artemis-journal</artifactId>

artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Create.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,9 @@ public class Create extends InstallAbstract {
238238
@Option(names = "--aio", description = "Set the journal as asyncio.")
239239
private boolean aio;
240240

241+
@Option(names = "--aio2", description = "Set the journal as asyncio 2 (Panama FFM).")
242+
private boolean aio2;
243+
241244
@Option(names = "--nio", description = "Set the journal as nio.")
242245
private boolean nio;
243246

@@ -1010,7 +1013,7 @@ private void setupJournalType() {
10101013
aio = false;
10111014
}
10121015
}
1013-
int countJournalTypes = countBoolean(aio, nio, mapped);
1016+
int countJournalTypes = countBoolean(aio2, aio, nio, mapped);
10141017
if (countJournalTypes > 1) {
10151018
throw new RuntimeException("You can only select one journal type (--nio | --aio | --mapped).");
10161019
}
@@ -1023,7 +1026,9 @@ private void setupJournalType() {
10231026
}
10241027
}
10251028

1026-
if (aio) {
1029+
if (aio2) {
1030+
journalType = JournalType.ASYNCIO_2;
1031+
} else if (aio) {
10271032
journalType = JournalType.ASYNCIO;
10281033
} else if (nio) {
10291034
journalType = JournalType.NIO;

artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/util/SyncCalculation.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import org.apache.activemq.artemis.core.io.SequentialFile;
2929
import org.apache.activemq.artemis.core.io.SequentialFileFactory;
3030
import org.apache.activemq.artemis.core.io.aio.AIOSequentialFileFactory;
31+
import org.apache.activemq.artemis.core.io.aio2.AIO2Helper;
3132
import org.apache.activemq.artemis.core.io.mapped.MappedSequentialFileFactory;
3233
import org.apache.activemq.artemis.core.io.nio.NIOSequentialFileFactory;
3334
import org.apache.activemq.artemis.core.server.ActiveMQMessageBundle;
@@ -247,7 +248,12 @@ private static SequentialFileFactory newFactory(File datafolder, boolean datasyn
247248
case ASYNCIO:
248249
factory = new AIOSequentialFileFactory(datafolder, maxAIO).setDatasync(datasync);
249250
factory.start();
250-
((AIOSequentialFileFactory) factory).disableBufferReuse();
251+
factory.disableBufferReuse();
252+
return factory;
253+
case ASYNCIO_2:
254+
factory = AIO2Helper.getAIO2SequentialFileFactory(datafolder, maxAIO).setDatasync(datasync);
255+
factory.start();
256+
factory.disableBufferReuse();
251257
return factory;
252258
case MAPPED:
253259
factory = new MappedSequentialFileFactory(datafolder, fileSize, false, 0, 0, null)

artemis-features/src/main/resources/features.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@
8585
<bundle dependency="true">mvn:org.snakeyaml/snakeyaml-engine/${snakeyaml-engine.version}</bundle>
8686

8787
<bundle>mvn:org.apache.activemq/activemq-artemis-native/${activemq-artemis-native-version}</bundle>
88+
<bundle>mvn:org.apache.artemis/artemis-ffm/${pom.version}</bundle>
8889
<bundle>mvn:org.apache.artemis/artemis-lockmanager-api/${pom.version}</bundle>
8990
<bundle>mvn:org.apache.artemis/artemis-server-osgi/${pom.version}</bundle>
9091
</feature>

artemis-ffm/pom.xml

Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
<!--
2+
Licensed to the Apache Software Foundation (ASF) under one or more
3+
contributor license agreements. See the NOTICE file distributed with
4+
this work for additional information regarding copyright ownership.
5+
The ASF licenses this file to You under the Apache License, Version 2.0
6+
(the "License"); you may not use this file except in compliance with
7+
the License. You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
-->
17+
<project xmlns="http://maven.apache.org/POM/4.0.0"
18+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
19+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
20+
<modelVersion>4.0.0</modelVersion>
21+
<parent>
22+
<groupId>org.apache.artemis</groupId>
23+
<artifactId>artemis-pom</artifactId>
24+
<version>2.55.0-SNAPSHOT</version>
25+
<relativePath>../artemis-pom/pom.xml</relativePath>
26+
</parent>
27+
28+
<artifactId>artemis-ffm</artifactId>
29+
<packaging>jar</packaging>
30+
<name>Apache Artemis FFM</name>
31+
32+
<properties>
33+
<test.stress.time>5000</test.stress.time>
34+
35+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
36+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
37+
38+
<activemq-surefire-argline>
39+
-Dtest.stress.time=${test.stress.time} --enable-native-access=ALL-UNNAMED
40+
</activemq-surefire-argline>
41+
</properties>
42+
43+
<dependencies>
44+
<dependency>
45+
<groupId>org.slf4j</groupId>
46+
<artifactId>slf4j-api</artifactId>
47+
<version>${slf4j.version}</version>
48+
<scope>provided</scope>
49+
<!-- License: MIT -->
50+
</dependency>
51+
52+
<dependency>
53+
<groupId>junit</groupId>
54+
<artifactId>junit</artifactId>
55+
<scope>test</scope>
56+
<!-- License: EPL 1.0 -->
57+
</dependency>
58+
<dependency>
59+
<groupId>org.junit.vintage</groupId>
60+
<artifactId>junit-vintage-engine</artifactId>
61+
<scope>test</scope>
62+
</dependency>
63+
<dependency>
64+
<groupId>org.junit.jupiter</groupId>
65+
<artifactId>junit-jupiter</artifactId>
66+
<scope>test</scope>
67+
</dependency>
68+
<dependency>
69+
<groupId>org.slf4j</groupId>
70+
<artifactId>slf4j-simple</artifactId>
71+
<version>${slf4j.version}</version>
72+
<scope>test</scope>
73+
</dependency>
74+
</dependencies>
75+
76+
<profiles>
77+
<profile>
78+
<id>jdk24onwards</id>
79+
<activation>
80+
<jdk>[24,)</jdk>
81+
</activation>
82+
<build>
83+
<plugins>
84+
<plugin>
85+
<artifactId>maven-compiler-plugin</artifactId>
86+
<configuration>
87+
<release>24</release>
88+
</configuration>
89+
<executions>
90+
<execution>
91+
<id>java24-compile</id>
92+
<phase>compile</phase>
93+
<goals>
94+
<goal>compile</goal>
95+
</goals>
96+
<configuration>
97+
<outputDirectory>${project.build.outputDirectory}</outputDirectory>
98+
<compileSourceRoots>
99+
<compileSourceRoot>${project.basedir}/src/main/java24</compileSourceRoot>
100+
</compileSourceRoots>
101+
</configuration>
102+
</execution>
103+
<execution>
104+
<id>java24-test-compile</id>
105+
<phase>test-compile</phase>
106+
<goals>
107+
<goal>testCompile</goal>
108+
</goals>
109+
<configuration>
110+
<compileSourceRoots>${project.basedir}/src/test/java24</compileSourceRoots>
111+
</configuration>
112+
</execution>
113+
</executions>
114+
</plugin>
115+
<plugin>
116+
<artifactId>maven-jar-plugin</artifactId>
117+
<!-- Do jar creation earlier, before the "test" phase, so that the
118+
multi-release-jar content is visible to any dependent modules,
119+
enabling them to use the relevant classes during their tests. -->
120+
<executions>
121+
<execution>
122+
<id>default-jar</id>
123+
<phase>package</phase>
124+
<goals>
125+
<goal>jar</goal>
126+
</goals>
127+
<configuration>
128+
<archive>
129+
<manifestEntries>
130+
<Multi-Release>true</Multi-Release>
131+
</manifestEntries>
132+
</archive>
133+
</configuration>
134+
</execution>
135+
</executions>
136+
</plugin>
137+
</plugins>
138+
</build>
139+
</profile>
140+
</profiles>
141+
<build>
142+
<resources>
143+
<resource>
144+
<directory>${basedir}/target/output/</directory>
145+
</resource>
146+
</resources>
147+
<plugins>
148+
<plugin>
149+
<groupId>org.apache.felix</groupId>
150+
<artifactId>maven-bundle-plugin</artifactId>
151+
<version>5.1.9</version>
152+
<executions>
153+
<execution>
154+
<id>bundle-manifest</id>
155+
<goals>
156+
<goal>manifest</goal>
157+
</goals>
158+
<phase>process-classes</phase>
159+
</execution>
160+
<execution>
161+
<id>default-bundle</id>
162+
<goals>
163+
<goal>bundle</goal>
164+
</goals>
165+
<phase>package</phase>
166+
</execution>
167+
</executions>
168+
<configuration>
169+
<instructions>
170+
<Bundle-SymbolicName>org.apache.artemis.ffm</Bundle-SymbolicName>
171+
<Bundle-Version>${project.version}</Bundle-Version>
172+
<Export-Package>org.apache.artemis.nativo.jlibaio;version="${project.version}"</Export-Package>
173+
<!-- Use ! for exclusion in bnd -->
174+
<Import-Package>!java.lang.foreign,*</Import-Package>
175+
<DynamicImport-Package>*</DynamicImport-Package>
176+
<Require-Capability>
177+
osgi.ee;filter:="(&amp;(osgi.ee=JavaSE)(version=17))"
178+
</Require-Capability>
179+
</instructions>
180+
</configuration>
181+
</plugin>
182+
</plugins>
183+
</build>
184+
</project>

artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/aio/ActiveMQFileLock.java renamed to artemis-ffm/src/main/java/org/apache/artemis/nativo/jlibaio/LibaioContext.java

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,30 +14,18 @@
1414
* See the License for the specific language governing permissions and
1515
* limitations under the License.
1616
*/
17-
package org.apache.activemq.artemis.core.io.aio;
17+
package org.apache.artemis.nativo.jlibaio;
1818

19+
import java.io.Closeable;
1920
import java.io.IOException;
20-
import java.nio.channels.FileChannel;
21-
import java.nio.channels.FileLock;
2221

23-
import org.apache.activemq.artemis.nativo.jlibaio.LibaioFile;
22+
public class LibaioContext<Callback extends SubmitInfo> implements Closeable {
2423

25-
public class ActiveMQFileLock extends FileLock {
26-
27-
private final LibaioFile file;
28-
29-
public ActiveMQFileLock(final LibaioFile handle) {
30-
super((FileChannel) null, 0, 0, false);
31-
this.file = handle;
32-
}
33-
34-
@Override
35-
public boolean isValid() {
36-
return true;
24+
public static boolean isSupported() {
25+
return false;
3726
}
3827

3928
@Override
40-
public void release() throws IOException {
41-
file.close();
29+
public void close() throws IOException {
4230
}
4331
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package org.apache.artemis.nativo.jlibaio;
18+
19+
import java.io.Closeable;
20+
import java.io.IOException;
21+
22+
public class LibaioFile<Callback extends SubmitInfo> implements Closeable {
23+
24+
private final String errorMsg = "This is not supported for JDK < 24.";
25+
26+
LibaioFile(int fd, LibaioContext ctx) {
27+
}
28+
29+
public int getBlockSize() throws IOException {
30+
throw new UnsupportedOperationException(errorMsg);
31+
}
32+
33+
public void fill(int alignment, long size) throws IOException {
34+
throw new UnsupportedOperationException(errorMsg);
35+
}
36+
37+
@Override
38+
public void close() throws IOException {
39+
}
40+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package org.apache.artemis.nativo.jlibaio;
18+
19+
import org.slf4j.Logger;
20+
import org.slf4j.LoggerFactory;
21+
22+
public class NativeLogger {
23+
24+
private static final Logger logger = LoggerFactory.getLogger(NativeLogger.class);
25+
26+
public static final String PROJECT_PREFIX = "jlibaio";
27+
28+
private static final int DIFFERENT_VERSION_ID = 163001;
29+
private static final String DIFFERENT_VERSION = PROJECT_PREFIX + DIFFERENT_VERSION_ID + " You have a native library with a different version than expected";
30+
31+
public static final void incompatibleNativeLibrary() {
32+
logger.warn(DIFFERENT_VERSION);
33+
}
34+
}

0 commit comments

Comments
 (0)