This closes #425
This commit is contained in:
commit
b16b864f07
|
@ -50,6 +50,8 @@ public final class AIOSequentialFileFactory extends AbstractSequentialFileFactor
|
|||
|
||||
private final AtomicBoolean running = new AtomicBoolean(false);
|
||||
|
||||
private static final String AIO_TEST_FILE = ".aio-test";
|
||||
|
||||
// This method exists just to make debug easier.
|
||||
// I could replace log.trace by log.info temporarily while I was debugging
|
||||
// Journal
|
||||
|
@ -114,6 +116,36 @@ public final class AIOSequentialFileFactory extends AbstractSequentialFileFactor
|
|||
return LibaioContext.isLoaded();
|
||||
}
|
||||
|
||||
public static boolean isSupported(File journalPath) {
|
||||
if (!isSupported()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
File aioTestFile = new File(journalPath, AIO_TEST_FILE);
|
||||
try {
|
||||
int fd = LibaioContext.open(aioTestFile.getAbsolutePath(), true);
|
||||
LibaioContext.close(fd);
|
||||
aioTestFile.delete();
|
||||
}
|
||||
catch (Exception e) {
|
||||
// try to handle the file using plain Java
|
||||
// return false if and only if we can create/remove the file using
|
||||
// plain Java but not using AIO
|
||||
try {
|
||||
if (!aioTestFile.exists()) {
|
||||
if (!aioTestFile.createNewFile()) return true;
|
||||
}
|
||||
if (!aioTestFile.delete()) return true;
|
||||
}
|
||||
catch (Exception ie) {
|
||||
// we can not even create the test file using plain java
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer allocateDirectBuffer(final int size) {
|
||||
|
||||
|
|
|
@ -390,7 +390,7 @@ public class LibaioContext<Callback extends SubmitInfo> implements Closeable {
|
|||
*/
|
||||
public static native int open(String path, boolean direct);
|
||||
|
||||
static native void close(int fd);
|
||||
public static native void close(int fd);
|
||||
|
||||
/**
|
||||
*/
|
||||
|
|
|
@ -1479,4 +1479,9 @@ public interface ActiveMQServerLogger extends BasicLogger {
|
|||
@LogMessage(level = Logger.Level.DEBUG)
|
||||
@Message(id = 224070, value = "Received Interrupt Exception whilst waiting for component to shutdown: {0}", format = Message.Format.MESSAGE_FORMAT)
|
||||
void interruptWhilstStoppingComponent(String componentClassName);
|
||||
|
||||
@LogMessage(level = Logger.Level.INFO)
|
||||
@Message(id = 224072, value = "libaio was found but the filesystem does not support AIO. Switching the configuration into NIO. Journal path: {0}", format = Message.Format.MESSAGE_FORMAT)
|
||||
void switchingNIOonPath(String journalPath);
|
||||
|
||||
}
|
||||
|
|
|
@ -1682,10 +1682,16 @@ public class ActiveMQServerImpl implements ActiveMQServer {
|
|||
// Create the pools - we have two pools - one for non scheduled - and another for scheduled
|
||||
initializeExecutorServices();
|
||||
|
||||
if (configuration.getJournalType() == JournalType.ASYNCIO && !AIOSequentialFileFactory.isSupported()) {
|
||||
if (configuration.getJournalType() == JournalType.ASYNCIO) {
|
||||
if (!AIOSequentialFileFactory.isSupported()) {
|
||||
ActiveMQServerLogger.LOGGER.switchingNIO();
|
||||
configuration.setJournalType(JournalType.NIO);
|
||||
}
|
||||
else if (!AIOSequentialFileFactory.isSupported(configuration.getJournalLocation())) {
|
||||
ActiveMQServerLogger.LOGGER.switchingNIOonPath(configuration.getJournalLocation().getAbsolutePath());
|
||||
configuration.setJournalType(JournalType.NIO);
|
||||
}
|
||||
}
|
||||
|
||||
managementService = new ManagementServiceImpl(mbeanServer, configuration);
|
||||
|
||||
|
|
Loading…
Reference in New Issue