From 557f02ba4d721620e53ae1a45cb879d653e4fab2 Mon Sep 17 00:00:00 2001 From: Bernd Gutjahr Date: Tue, 11 Apr 2017 09:47:11 +0200 Subject: [PATCH] ARTEMIS-1108: Removed AIOFileLockManager AIOFileLockManager doesn't work on NFS-mounted share store directories. Since the GFS2 bug https://bugzilla.redhat.com/show_bug.cgi?id=678585 has been fixed end of 2011, the class AIOFileLockManager is no longer needed and I have removed it. --- .../server/impl/AIOFileLockNodeManager.java | 103 ------------------ .../core/server/impl/ActiveMQServerImpl.java | 3 - .../tests/util/ColocatedActiveMQServer.java | 9 +- .../unit/core/server/impl/FileLockTest.java | 10 -- 4 files changed, 1 insertion(+), 124 deletions(-) delete mode 100644 artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/AIOFileLockNodeManager.java diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/AIOFileLockNodeManager.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/AIOFileLockNodeManager.java deleted file mode 100644 index 0892a11fc5..0000000000 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/AIOFileLockNodeManager.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * 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.activemq.artemis.core.server.impl; - -import java.io.File; -import java.nio.channels.FileLock; - -import org.apache.activemq.artemis.core.io.aio.ActiveMQFileLock; -import org.apache.activemq.artemis.jlibaio.LibaioContext; -import org.apache.activemq.artemis.jlibaio.LibaioFile; - -/** - * This is using the ActiveMQ Artemis Libaio Native to perform calls to flock on a Linux system. At the - * current version of RHEL there's a bug on GFS2 and because of that fctl is not functional what - * will cause issues on Failover over Shared Storage. - *

- * This will provide an alternative to perform locks through our native module until fctl is fixed - * on Linux. - *

- * https://bugzilla.redhat.com/show_bug.cgi?id=678585 - */ -public final class AIOFileLockNodeManager extends FileLockNodeManager { - - /** - * @param directory - * @param replicatingBackup - */ - public AIOFileLockNodeManager(final File directory, boolean replicatingBackup) { - super(directory, replicatingBackup); - } - - public AIOFileLockNodeManager(final File directory, boolean replicatingBackup, long lockAcquisitionTimeout) { - super(directory, replicatingBackup); - - this.lockAcquisitionTimeout = lockAcquisitionTimeout; - } - - @Override - protected FileLock tryLock(final int lockPos) throws Exception { - File file = newFileForRegionLock(lockPos); - - LibaioFile fileControl = LibaioContext.openControlFile(file.getAbsolutePath(), false); - - if (!fileControl.lock()) { - fileControl.close(); - return null; - } - - FileLock lock = new ActiveMQFileLock(fileControl); - - return lock; - - } - - @Override - protected FileLock lock(final int liveLockPos) throws Exception { - long start = System.currentTimeMillis(); - - File file = newFileForRegionLock(liveLockPos); - - while (!interrupted) { - FileLock lockFile = tryLock(liveLockPos); - if (lockFile != null) { - return lockFile; - } else { - try { - Thread.sleep(500); - } catch (InterruptedException e) { - return null; - } - - if (lockAcquisitionTimeout != -1 && (System.currentTimeMillis() - start) > lockAcquisitionTimeout) { - throw new Exception("timed out waiting for lock"); - } - } - } - - return null; - } - - /** - * @param liveLockPos - * @return - */ - protected File newFileForRegionLock(final int liveLockPos) { - File file = newFile("server." + liveLockPos + ".lock"); - return file; - } -} diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java index ede4ff0306..4934b09308 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java @@ -154,7 +154,6 @@ import org.apache.activemq.artemis.core.settings.impl.ResourceLimitSettings; import org.apache.activemq.artemis.core.transaction.ResourceManager; import org.apache.activemq.artemis.core.transaction.impl.ResourceManagerImpl; import org.apache.activemq.artemis.core.version.Version; -import org.apache.activemq.artemis.jlibaio.LibaioContext; import org.apache.activemq.artemis.spi.core.protocol.ProtocolManagerFactory; import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection; import org.apache.activemq.artemis.spi.core.protocol.SessionCallback; @@ -446,8 +445,6 @@ public class ActiveMQServerImpl implements ActiveMQServer { NodeManager manager; if (!configuration.isPersistenceEnabled()) { manager = new InVMNodeManager(replicatingBackup); - } else if (configuration.getJournalType() == JournalType.ASYNCIO && LibaioContext.isLoaded()) { - manager = new AIOFileLockNodeManager(directory, replicatingBackup, configuration.getJournalLockAcquisitionTimeout()); } else { manager = new FileLockNodeManager(directory, replicatingBackup, configuration.getJournalLockAcquisitionTimeout()); } diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/ColocatedActiveMQServer.java b/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/ColocatedActiveMQServer.java index 6130dcf0a9..c90118753f 100644 --- a/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/ColocatedActiveMQServer.java +++ b/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/ColocatedActiveMQServer.java @@ -22,12 +22,9 @@ import java.io.File; import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.core.config.impl.FileConfiguration; import org.apache.activemq.artemis.core.server.ActiveMQServer; -import org.apache.activemq.artemis.core.server.JournalType; import org.apache.activemq.artemis.core.server.NodeManager; -import org.apache.activemq.artemis.core.server.impl.AIOFileLockNodeManager; import org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl; import org.apache.activemq.artemis.core.server.impl.FileLockNodeManager; -import org.apache.activemq.artemis.jlibaio.LibaioContext; import org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager; public class ColocatedActiveMQServer extends ActiveMQServerImpl { @@ -68,11 +65,7 @@ public class ColocatedActiveMQServer extends ActiveMQServerImpl { @Override protected NodeManager createNodeManager(final File directory, boolean replicatingBackup) { if (replicatingBackup) { - if (getConfiguration().getJournalType() == JournalType.ASYNCIO && LibaioContext.isLoaded()) { - return new AIOFileLockNodeManager(directory, replicatingBackup, getConfiguration().getJournalLockAcquisitionTimeout()); - } else { - return new FileLockNodeManager(directory, replicatingBackup, getConfiguration().getJournalLockAcquisitionTimeout()); - } + return new FileLockNodeManager(directory, replicatingBackup, getConfiguration().getJournalLockAcquisitionTimeout()); } else { if (backup) { return nodeManagerBackup; diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/impl/FileLockTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/impl/FileLockTest.java index 76dcfa8f4f..88127937bc 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/impl/FileLockTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/impl/FileLockTest.java @@ -18,9 +18,7 @@ package org.apache.activemq.artemis.tests.unit.core.server.impl; import java.io.File; -import org.apache.activemq.artemis.core.server.impl.AIOFileLockNodeManager; import org.apache.activemq.artemis.core.server.impl.FileLockNodeManager; -import org.apache.activemq.artemis.jlibaio.LibaioContext; import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.junit.Before; import org.junit.Test; @@ -41,14 +39,6 @@ public class FileLockTest extends ActiveMQTestBase { } - @Test - public void testAIOLock() throws Exception { - if (LibaioContext.isLoaded()) { - doTestLock(new AIOFileLockNodeManager(getTestDirfile(), false), new AIOFileLockNodeManager(getTestDirfile(), false)); - } - - } - public void doTestLock(final FileLockNodeManager lockManager1, final FileLockNodeManager lockManager2) throws Exception { lockManager1.start();