diff --git a/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/KahaDBPersistenceAdapter.java b/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/KahaDBPersistenceAdapter.java index 773295956a..0e74e82fe3 100644 --- a/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/KahaDBPersistenceAdapter.java +++ b/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/KahaDBPersistenceAdapter.java @@ -52,6 +52,7 @@ import org.apache.activemq.store.TransactionStore; import org.apache.activemq.store.kahadb.data.KahaLocalTransactionId; import org.apache.activemq.store.kahadb.data.KahaTransactionInfo; import org.apache.activemq.store.kahadb.data.KahaXATransactionId; +import org.apache.activemq.store.kahadb.disk.journal.Journal.JournalDiskSyncStrategy; import org.apache.activemq.usage.SystemUsage; import org.apache.activemq.util.ServiceStopper; @@ -461,6 +462,10 @@ public class KahaDBPersistenceAdapter extends LockableServiceSupport implements return letter.getJournalDiskSyncStrategy(); } + public JournalDiskSyncStrategy getJournalDiskSyncStrategyEnum() { + return letter.getJournalDiskSyncStrategyEnum(); + } + /** * @param journalDiskSyncStrategy */ diff --git a/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/MessageDatabase.java b/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/MessageDatabase.java index 5ee6c4cb74..4fdaa01579 100644 --- a/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/MessageDatabase.java +++ b/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/MessageDatabase.java @@ -254,7 +254,7 @@ public abstract class MessageDatabase extends ServiceSupport implements BrokerSe protected ScheduledExecutorService scheduler; private final Object schedulerLock = new Object(); - protected String journalDiskSyncStrategy = JournalDiskSyncStrategy.ALWAYS.name(); + protected JournalDiskSyncStrategy journalDiskSyncStrategy = JournalDiskSyncStrategy.ALWAYS; protected boolean archiveDataLogs; protected File directoryArchive; protected AtomicLong journalSize = new AtomicLong(0); @@ -3141,8 +3141,7 @@ public abstract class MessageDatabase extends ServiceSupport implements BrokerSe manager.setPreallocationScope(Journal.PreallocationScope.valueOf(preallocationScope.trim().toUpperCase())); manager.setPreallocationStrategy( Journal.PreallocationStrategy.valueOf(preallocationStrategy.trim().toUpperCase())); - manager.setJournalDiskSyncStrategy( - Journal.JournalDiskSyncStrategy.valueOf(journalDiskSyncStrategy.trim().toUpperCase())); + manager.setJournalDiskSyncStrategy(journalDiskSyncStrategy); if (getDirectoryArchive() != null) { IOHelper.mkdirs(getDirectoryArchive()); manager.setDirectoryArchive(getDirectoryArchive()); @@ -3200,13 +3199,12 @@ public abstract class MessageDatabase extends ServiceSupport implements BrokerSe } /** - * @deprecated use {@link #getJournalDiskSyncStrategy} instead + * @deprecated use {@link #getJournalDiskSyncStrategyEnum} or {@link #getJournalDiskSyncStrategy} instead * @return */ @Deprecated public boolean isEnableJournalDiskSyncs() { - return journalDiskSyncStrategy != null && JournalDiskSyncStrategy.ALWAYS.name().equals( - journalDiskSyncStrategy.trim().toUpperCase()); + return journalDiskSyncStrategy == JournalDiskSyncStrategy.ALWAYS; } /** @@ -3216,18 +3214,22 @@ public abstract class MessageDatabase extends ServiceSupport implements BrokerSe @Deprecated public void setEnableJournalDiskSyncs(boolean syncWrites) { if (syncWrites) { - journalDiskSyncStrategy = JournalDiskSyncStrategy.ALWAYS.name(); + journalDiskSyncStrategy = JournalDiskSyncStrategy.ALWAYS; } else { - journalDiskSyncStrategy = JournalDiskSyncStrategy.NEVER.name(); + journalDiskSyncStrategy = JournalDiskSyncStrategy.NEVER; } } - public String getJournalDiskSyncStrategy() { + public JournalDiskSyncStrategy getJournalDiskSyncStrategyEnum() { return journalDiskSyncStrategy; } + public String getJournalDiskSyncStrategy() { + return journalDiskSyncStrategy.name(); + } + public void setJournalDiskSyncStrategy(String journalDiskSyncStrategy) { - this.journalDiskSyncStrategy = journalDiskSyncStrategy; + this.journalDiskSyncStrategy = JournalDiskSyncStrategy.valueOf(journalDiskSyncStrategy.trim().toUpperCase()); } public long getJournalDiskSyncInterval() { diff --git a/activemq-kahadb-store/src/test/java/org/apache/activemq/store/kahadb/JournalSyncStrategyTest.java b/activemq-kahadb-store/src/test/java/org/apache/activemq/store/kahadb/JournalSyncStrategyTest.java index c22339f4ce..33810cb50d 100644 --- a/activemq-kahadb-store/src/test/java/org/apache/activemq/store/kahadb/JournalSyncStrategyTest.java +++ b/activemq-kahadb-store/src/test/java/org/apache/activemq/store/kahadb/JournalSyncStrategyTest.java @@ -67,6 +67,7 @@ public class JournalSyncStrategyTest { assertTrue(journal.isJournalDiskSyncPeriodic()); assertFalse(store.isEnableJournalDiskSyncs()); assertEquals(store.getJournalDiskSyncStrategy(), JournalDiskSyncStrategy.PERIODIC.name()); + assertEquals(store.getJournalDiskSyncStrategyEnum(), JournalDiskSyncStrategy.PERIODIC); assertEquals(store.getJournal().getJournalDiskSyncStrategy(), JournalDiskSyncStrategy.PERIODIC); assertEquals(store.getJournalDiskSyncInterval(), 800); @@ -87,6 +88,7 @@ public class JournalSyncStrategyTest { assertFalse(store.getJournal().isJournalDiskSyncPeriodic()); assertTrue(store.isEnableJournalDiskSyncs()); assertEquals(store.getJournalDiskSyncStrategy(), JournalDiskSyncStrategy.ALWAYS.name()); + assertEquals(store.getJournalDiskSyncStrategyEnum(), JournalDiskSyncStrategy.ALWAYS); assertEquals(store.getJournal().getJournalDiskSyncStrategy(), JournalDiskSyncStrategy.ALWAYS); MessageStore messageStore = store.createQueueMessageStore(new ActiveMQQueue("test")); @@ -101,6 +103,7 @@ public class JournalSyncStrategyTest { assertFalse(store.getJournal().isJournalDiskSyncPeriodic()); assertFalse(store.isEnableJournalDiskSyncs()); assertEquals(store.getJournalDiskSyncStrategy(), JournalDiskSyncStrategy.NEVER.name()); + assertEquals(store.getJournalDiskSyncStrategyEnum(), JournalDiskSyncStrategy.NEVER); assertEquals(store.getJournal().getJournalDiskSyncStrategy(), JournalDiskSyncStrategy.NEVER); MessageStore messageStore = store.createQueueMessageStore(new ActiveMQQueue("test"));