Author: clebert.suconic(a)jboss.com
Date: 2009-12-04 21:05:16 -0500 (Fri, 04 Dec 2009)
New Revision: 8572
Added:
trunk/tests/src/org/hornetq/tests/integration/journal/NIOBufferedJournalCompactTest.java
Modified:
trunk/src/main/org/hornetq/core/journal/SequentialFile.java
trunk/src/main/org/hornetq/core/journal/impl/AIOSequentialFile.java
trunk/src/main/org/hornetq/core/journal/impl/AbstractJournalUpdateTask.java
trunk/src/main/org/hornetq/core/journal/impl/JournalImpl.java
trunk/src/main/org/hornetq/core/journal/impl/NIOSequentialFile.java
trunk/tests/src/org/hornetq/tests/integration/journal/NIOJournalCompactTest.java
trunk/tests/src/org/hornetq/tests/unit/core/journal/impl/fakes/FakeSequentialFileFactory.java
Log:
A few tweaks on persistence
Modified: trunk/src/main/org/hornetq/core/journal/SequentialFile.java
===================================================================
--- trunk/src/main/org/hornetq/core/journal/SequentialFile.java 2009-12-04 20:54:28 UTC
(rev 8571)
+++ trunk/src/main/org/hornetq/core/journal/SequentialFile.java 2009-12-05 02:05:16 UTC
(rev 8572)
@@ -36,13 +36,13 @@
boolean isOpen();
boolean exists();
-
+
/**
* The maximum number of simultaneous writes accepted
* @param maxIO
* @throws Exception
*/
- void open(int maxIO) throws Exception;
+ void open(int maxIO, boolean useExecutor) throws Exception;
boolean fits(int size);
Modified: trunk/src/main/org/hornetq/core/journal/impl/AIOSequentialFile.java
===================================================================
--- trunk/src/main/org/hornetq/core/journal/impl/AIOSequentialFile.java 2009-12-04
20:54:28 UTC (rev 8571)
+++ trunk/src/main/org/hornetq/core/journal/impl/AIOSequentialFile.java 2009-12-05
02:05:16 UTC (rev 8572)
@@ -178,14 +178,14 @@
public void open() throws Exception
{
- open(maxIO);
+ open(maxIO, true);
}
- public synchronized void open(final int maxIO) throws Exception
+ public synchronized void open(final int maxIO, final boolean useExecutor) throws
Exception
{
opened = true;
- aioFile = new AsynchronousFileImpl(writerExecutor, pollerExecutor);
+ aioFile = new AsynchronousFileImpl(useExecutor ? writerExecutor : null,
pollerExecutor);
aioFile.open(getFile().getAbsolutePath(), maxIO);
Modified: trunk/src/main/org/hornetq/core/journal/impl/AbstractJournalUpdateTask.java
===================================================================
--- trunk/src/main/org/hornetq/core/journal/impl/AbstractJournalUpdateTask.java 2009-12-04
20:54:28 UTC (rev 8571)
+++ trunk/src/main/org/hornetq/core/journal/impl/AbstractJournalUpdateTask.java 2009-12-05
02:05:16 UTC (rev 8572)
@@ -98,7 +98,7 @@
try
{
- controlFile.open(1);
+ controlFile.open(1, false);
HornetQBuffer renameBuffer = HornetQBuffers.dynamicBuffer(1);
@@ -219,7 +219,7 @@
currentFile = journal.getFile(false, false, false, true);
sequentialFile = currentFile.getFile();
- sequentialFile.open(1);
+ sequentialFile.open(1, false);
fileID = nextOrderingID++;
currentFile = new JournalFileImpl(sequentialFile, fileID);
Modified: trunk/src/main/org/hornetq/core/journal/impl/JournalImpl.java
===================================================================
--- trunk/src/main/org/hornetq/core/journal/impl/JournalImpl.java 2009-12-04 20:54:28 UTC
(rev 8571)
+++ trunk/src/main/org/hornetq/core/journal/impl/JournalImpl.java 2009-12-05 02:05:16 UTC
(rev 8572)
@@ -369,7 +369,7 @@
final JournalFile file,
final JournalReaderCallback reader) throws
Exception
{
- file.getFile().open(1);
+ file.getFile().open(1, false);
ByteBuffer wholeFileBuffer = null;
try
{
@@ -2616,7 +2616,7 @@
SequentialFile sf = file.getFile();
- sf.open(1);
+ sf.open(1, false);
sf.position(0);
@@ -2725,7 +2725,7 @@
{
SequentialFile file = fileFactory.createSequentialFile(fileName, maxAIO);
- file.open(1);
+ file.open(1, false);
ByteBuffer bb = fileFactory.newBuffer(SIZE_HEADER);
@@ -2912,7 +2912,7 @@
}
else
{
- sequentialFile.open(1);
+ sequentialFile.open(1, false);
}
if (fill)
@@ -2946,7 +2946,7 @@
}
else
{
- file.getFile().open(1);
+ file.getFile().open(1, false);
}
file.getFile().position(file.getFile().calculateBlockStart(SIZE_HEADER));
Modified: trunk/src/main/org/hornetq/core/journal/impl/NIOSequentialFile.java
===================================================================
--- trunk/src/main/org/hornetq/core/journal/impl/NIOSequentialFile.java 2009-12-04
20:54:28 UTC (rev 8571)
+++ trunk/src/main/org/hornetq/core/journal/impl/NIOSequentialFile.java 2009-12-05
02:05:16 UTC (rev 8572)
@@ -89,10 +89,10 @@
* Some operations while initializing files on the journal may require a different
maxIO */
public synchronized void open() throws Exception
{
- open(defaultMaxIO);
+ open(defaultMaxIO, true);
}
- public void open(final int maxIO) throws Exception
+ public void open(final int maxIO, final boolean useExecutor) throws Exception
{
rfile = new RandomAccessFile(getFile(), "rw");
@@ -100,7 +100,7 @@
fileSize = channel.size();
- if (writerExecutor != null)
+ if (writerExecutor != null && useExecutor)
{
maxIOSemaphore = new Semaphore(maxIO);
this.maxIO = maxIO;
@@ -286,7 +286,7 @@
return;
}
- if (writerExecutor == null)
+ if (maxIOSemaphore == null)
{
doInternalWrite(bytes, sync, callback);
}
Added:
trunk/tests/src/org/hornetq/tests/integration/journal/NIOBufferedJournalCompactTest.java
===================================================================
---
trunk/tests/src/org/hornetq/tests/integration/journal/NIOBufferedJournalCompactTest.java
(rev 0)
+++
trunk/tests/src/org/hornetq/tests/integration/journal/NIOBufferedJournalCompactTest.java 2009-12-05
02:05:16 UTC (rev 8572)
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Red Hat 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.hornetq.tests.integration.journal;
+
+import java.io.File;
+
+import org.hornetq.core.config.impl.ConfigurationImpl;
+import org.hornetq.core.journal.SequentialFileFactory;
+import org.hornetq.core.journal.impl.AIOSequentialFileFactory;
+import org.hornetq.core.journal.impl.NIOSequentialFileFactory;
+
+/**
+ * A NIOBufferedJournalCompactTest
+ *
+ * @author <mailto:clebert.suconic@jboss.org">Clebert Suconic</a>
+ *
+ *
+ */
+public class NIOBufferedJournalCompactTest extends NIOJournalCompactTest
+{
+
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+ @Override
+ protected SequentialFileFactory getFileFactory() throws Exception
+ {
+ File file = new File(getTestDir());
+
+ deleteDirectory(file);
+
+ file.mkdir();
+
+ return new NIOSequentialFileFactory(getTestDir(), true);
+ }
+
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+
+}
Modified:
trunk/tests/src/org/hornetq/tests/integration/journal/NIOJournalCompactTest.java
===================================================================
---
trunk/tests/src/org/hornetq/tests/integration/journal/NIOJournalCompactTest.java 2009-12-04
20:54:28 UTC (rev 8571)
+++
trunk/tests/src/org/hornetq/tests/integration/journal/NIOJournalCompactTest.java 2009-12-05
02:05:16 UTC (rev 8572)
@@ -507,7 +507,7 @@
public void testSimpleCompacting() throws Exception
{
- setup(2, 60 * 1024, true);
+ setup(2, 60 * 1024, false);
createJournal();
startJournal();
@@ -756,7 +756,7 @@
protected void setUp() throws Exception
{
super.setUp();
-
+
File file = new File(getTestDir());
deleteDirectory(file);
Modified:
trunk/tests/src/org/hornetq/tests/unit/core/journal/impl/fakes/FakeSequentialFileFactory.java
===================================================================
---
trunk/tests/src/org/hornetq/tests/unit/core/journal/impl/fakes/FakeSequentialFileFactory.java 2009-12-04
20:54:28 UTC (rev 8571)
+++
trunk/tests/src/org/hornetq/tests/unit/core/journal/impl/fakes/FakeSequentialFileFactory.java 2009-12-05
02:05:16 UTC (rev 8572)
@@ -363,10 +363,10 @@
public void open() throws Exception
{
- open(0);
+ open(1, true);
}
- public synchronized void open(final int currentMaxIO) throws Exception
+ public synchronized void open(final int currentMaxIO, final boolean useExecutor)
throws Exception
{
open = true;
checkAndResize(0);