[jboss-cvs] JBoss Messaging SVN: r7512 - in branches/clebert_temp_expirement: src/config/common/schema and 13 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Jul 2 00:35:49 EDT 2009
Author: clebert.suconic at jboss.com
Date: 2009-07-02 00:35:48 -0400 (Thu, 02 Jul 2009)
New Revision: 7512
Modified:
branches/clebert_temp_expirement/examples/core/perf/perf.properties
branches/clebert_temp_expirement/src/config/common/schema/jbm-configuration.xsd
branches/clebert_temp_expirement/src/main/org/jboss/messaging/core/config/Configuration.java
branches/clebert_temp_expirement/src/main/org/jboss/messaging/core/config/impl/ConfigurationImpl.java
branches/clebert_temp_expirement/src/main/org/jboss/messaging/core/config/impl/FileConfiguration.java
branches/clebert_temp_expirement/src/main/org/jboss/messaging/core/config/impl/Validators.java
branches/clebert_temp_expirement/src/main/org/jboss/messaging/core/journal/impl/JournalCompactor.java
branches/clebert_temp_expirement/src/main/org/jboss/messaging/core/journal/impl/JournalImpl.java
branches/clebert_temp_expirement/src/main/org/jboss/messaging/core/persistence/impl/journal/JournalStorageManager.java
branches/clebert_temp_expirement/tests/config/ConfigurationTest-full-config.xml
branches/clebert_temp_expirement/tests/src/org/jboss/messaging/tests/integration/journal/NIOJournalCompactTest.java
branches/clebert_temp_expirement/tests/src/org/jboss/messaging/tests/performance/journal/JournalImplTestUnit.java
branches/clebert_temp_expirement/tests/src/org/jboss/messaging/tests/stress/journal/AddAndRemoveStressTest.java
branches/clebert_temp_expirement/tests/src/org/jboss/messaging/tests/stress/journal/remote/RemoteJournalAppender.java
branches/clebert_temp_expirement/tests/src/org/jboss/messaging/tests/unit/core/config/impl/DefaultsFileConfigurationTest.java
branches/clebert_temp_expirement/tests/src/org/jboss/messaging/tests/unit/core/config/impl/FileConfigurationTest.java
branches/clebert_temp_expirement/tests/src/org/jboss/messaging/tests/unit/core/journal/impl/AlignedJournalImplTest.java
branches/clebert_temp_expirement/tests/src/org/jboss/messaging/tests/unit/core/journal/impl/JournalAsyncTest.java
branches/clebert_temp_expirement/tests/src/org/jboss/messaging/tests/unit/core/journal/impl/JournalImplTestBase.java
branches/clebert_temp_expirement/tests/src/org/jboss/messaging/tests/unit/core/journal/impl/JournalImplTestUnit.java
branches/clebert_temp_expirement/tests/src/org/jboss/messaging/tests/unit/core/journal/impl/fakes/FakeSequentialFileFactory.java
branches/clebert_temp_expirement/tests/src/org/jboss/messaging/tests/util/JournalExample.java
branches/clebert_temp_expirement/tests/src/org/jboss/messaging/tests/util/ListJournal.java
Log:
Adding configuration
Modified: branches/clebert_temp_expirement/examples/core/perf/perf.properties
===================================================================
--- branches/clebert_temp_expirement/examples/core/perf/perf.properties 2009-07-01 23:44:04 UTC (rev 7511)
+++ branches/clebert_temp_expirement/examples/core/perf/perf.properties 2009-07-02 04:35:48 UTC (rev 7512)
@@ -1,4 +1,4 @@
-num-messages=200000
+num-messages=500000
num-warmup-messages=20000
message-size=1024
durable=true
Modified: branches/clebert_temp_expirement/src/config/common/schema/jbm-configuration.xsd
===================================================================
--- branches/clebert_temp_expirement/src/config/common/schema/jbm-configuration.xsd 2009-07-01 23:44:04 UTC (rev 7511)
+++ branches/clebert_temp_expirement/src/config/common/schema/jbm-configuration.xsd 2009-07-02 04:35:48 UTC (rev 7512)
@@ -158,6 +158,10 @@
</xsd:element>
<xsd:element maxOccurs="1" minOccurs="0" name="journal-min-files" type="xsd:int">
</xsd:element>
+ <xsd:element maxOccurs="1" minOccurs="0" name="journal-compact-percentage" type="xsd:int">
+ </xsd:element>
+ <xsd:element maxOccurs="1" minOccurs="0" name="journal-compact-min-files" type="xsd:int">
+ </xsd:element>
<xsd:element maxOccurs="1" minOccurs="0" name="journal-max-aio" type="xsd:int">
</xsd:element>
<xsd:element maxOccurs="1" minOccurs="0" name="perf-blast-pages" type="xsd:int">
Modified: branches/clebert_temp_expirement/src/main/org/jboss/messaging/core/config/Configuration.java
===================================================================
--- branches/clebert_temp_expirement/src/main/org/jboss/messaging/core/config/Configuration.java 2009-07-01 23:44:04 UTC (rev 7511)
+++ branches/clebert_temp_expirement/src/main/org/jboss/messaging/core/config/Configuration.java 2009-07-02 04:35:48 UTC (rev 7512)
@@ -185,6 +185,14 @@
int getJournalFileSize();
void setJournalFileSize(int size);
+
+ int getJournalCompactMinFiles();
+
+ void setJournalCompactMinFiles(int minFiles);
+
+ int getJournalCompactPercentage();
+
+ void setJournalCompactPercentage(int percentage);
int getJournalMinFiles();
Modified: branches/clebert_temp_expirement/src/main/org/jboss/messaging/core/config/impl/ConfigurationImpl.java
===================================================================
--- branches/clebert_temp_expirement/src/main/org/jboss/messaging/core/config/impl/ConfigurationImpl.java 2009-07-01 23:44:04 UTC (rev 7511)
+++ branches/clebert_temp_expirement/src/main/org/jboss/messaging/core/config/impl/ConfigurationImpl.java 2009-07-02 04:35:48 UTC (rev 7512)
@@ -90,6 +90,10 @@
public static final boolean DEFAULT_JOURNAL_SYNC_NON_TRANSACTIONAL = false;
public static final int DEFAULT_JOURNAL_FILE_SIZE = 10485760;
+
+ public static final int DEFAULT_JOURNAL_COMPACT_MIN_FILES = 10;
+
+ public static final int DEFAULT_JOURNAL_COMPACT_PERCENTAGE = 30;
public static final int DEFAULT_JOURNAL_MIN_FILES = 2;
@@ -235,6 +239,11 @@
protected boolean journalSyncNonTransactional = DEFAULT_JOURNAL_SYNC_NON_TRANSACTIONAL;
+
+ protected int journalCompactMinFiles = DEFAULT_JOURNAL_COMPACT_MIN_FILES;
+
+ protected int journalCompactPercentage = DEFAULT_JOURNAL_COMPACT_PERCENTAGE;
+
protected int journalFileSize = DEFAULT_JOURNAL_FILE_SIZE;
protected int journalMinFiles = DEFAULT_JOURNAL_MIN_FILES;
@@ -886,4 +895,36 @@
cother.getManagementAddress().equals(getManagementAddress()) &&
cother.getGlobalPagingSize() == getGlobalPagingSize();
}
+
+ /* (non-Javadoc)
+ * @see org.jboss.messaging.core.config.Configuration#getJournalCompactMinFiles()
+ */
+ public int getJournalCompactMinFiles()
+ {
+ return journalCompactMinFiles;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.messaging.core.config.Configuration#getJournalCompactPercentage()
+ */
+ public int getJournalCompactPercentage()
+ {
+ return journalCompactPercentage;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.messaging.core.config.Configuration#setJournalCompactMinFiles()
+ */
+ public void setJournalCompactMinFiles(int minFiles)
+ {
+ this.journalCompactMinFiles = minFiles;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.messaging.core.config.Configuration#setJournalCompactPercentage()
+ */
+ public void setJournalCompactPercentage(int percentage)
+ {
+ this.journalCompactPercentage = percentage;
+ }
}
Modified: branches/clebert_temp_expirement/src/main/org/jboss/messaging/core/config/impl/FileConfiguration.java
===================================================================
--- branches/clebert_temp_expirement/src/main/org/jboss/messaging/core/config/impl/FileConfiguration.java 2009-07-01 23:44:04 UTC (rev 7511)
+++ branches/clebert_temp_expirement/src/main/org/jboss/messaging/core/config/impl/FileConfiguration.java 2009-07-02 04:35:48 UTC (rev 7512)
@@ -30,6 +30,7 @@
import static org.jboss.messaging.core.config.impl.Validators.MINUS_ONE_OR_GT_ZERO;
import static org.jboss.messaging.core.config.impl.Validators.NOT_NULL_OR_EMPTY;
import static org.jboss.messaging.core.config.impl.Validators.NO_CHECK;
+import static org.jboss.messaging.core.config.impl.Validators.PERCENTAGE;
import static org.jboss.messaging.core.config.impl.Validators.THREAD_PRIORITY_RANGE;
import static org.jboss.messaging.utils.XMLConfigurationUtil.getBoolean;
import static org.jboss.messaging.utils.XMLConfigurationUtil.getDouble;
@@ -313,7 +314,11 @@
journalAIOBufferSize = getInteger(e, "journal-aio-buffer-size", DEFAULT_JOURNAL_AIO_BUFFER_SIZE, GT_ZERO);
journalMinFiles = getInteger(e, "journal-min-files", journalMinFiles, GT_ZERO);
+
+ journalCompactMinFiles = getInteger(e, "journal-compact-min-files", journalCompactMinFiles, GE_ZERO);
+ journalCompactPercentage = getInteger(e, "journal-compact-percentage", journalCompactPercentage, PERCENTAGE);
+
journalMaxAIO = getInteger(e, "journal-max-aio", journalMaxAIO, GT_ZERO);
logJournalWriteRate = getBoolean(e, "log-journal-write-rate", DEFAULT_JOURNAL_LOG_WRITE_RATE);
Modified: branches/clebert_temp_expirement/src/main/org/jboss/messaging/core/config/impl/Validators.java
===================================================================
--- branches/clebert_temp_expirement/src/main/org/jboss/messaging/core/config/impl/Validators.java 2009-07-01 23:44:04 UTC (rev 7511)
+++ branches/clebert_temp_expirement/src/main/org/jboss/messaging/core/config/impl/Validators.java 2009-07-02 04:35:48 UTC (rev 7512)
@@ -78,11 +78,23 @@
}
else
{
- throw new IllegalArgumentException(format("%s must be greater than 0 (actual value: %s", name, val));
+ throw new IllegalArgumentException(format("%s must be greater than 0 (actual value: %s)", name, val));
}
}
};
+ public static Validator PERCENTAGE = new Validator()
+ {
+ public void validate(String name, Object value)
+ {
+ Number val = (Number)value;
+ if (val != null && val.intValue()< 0 || val.intValue() > 100)
+ {
+ throw new IllegalArgumentException(format("%s must be a valid percentual value between 0 and 100 (actual value: %s)", name, val));
+ }
+ }
+ };
+
public static Validator GE_ZERO = new Validator()
{
public void validate(String name, Object value)
@@ -94,7 +106,7 @@
}
else
{
- throw new IllegalArgumentException(format("%s must be greater or equals than 0 (actual value: %s",
+ throw new IllegalArgumentException(format("%s must be greater or equals than 0 (actual value: %s)",
name,
val));
}
Modified: branches/clebert_temp_expirement/src/main/org/jboss/messaging/core/journal/impl/JournalCompactor.java
===================================================================
--- branches/clebert_temp_expirement/src/main/org/jboss/messaging/core/journal/impl/JournalCompactor.java 2009-07-01 23:44:04 UTC (rev 7511)
+++ branches/clebert_temp_expirement/src/main/org/jboss/messaging/core/journal/impl/JournalCompactor.java 2009-07-02 04:35:48 UTC (rev 7512)
@@ -560,6 +560,8 @@
currentFile = journal.getFile(false, false, false);
sequentialFile = currentFile.getFile();
sequentialFile.renameTo(sequentialFile.getFileName() + ".cmp");
+
+ log.info("Writing compacted data into " + sequentialFile.getFileName());
sequentialFile.open(1);
fileID = nextOrderingID++;
currentFile = new JournalFileImpl(sequentialFile, fileID, fileID);
Modified: branches/clebert_temp_expirement/src/main/org/jboss/messaging/core/journal/impl/JournalImpl.java
===================================================================
--- branches/clebert_temp_expirement/src/main/org/jboss/messaging/core/journal/impl/JournalImpl.java 2009-07-01 23:44:04 UTC (rev 7511)
+++ branches/clebert_temp_expirement/src/main/org/jboss/messaging/core/journal/impl/JournalImpl.java 2009-07-02 04:35:48 UTC (rev 7512)
@@ -90,10 +90,6 @@
private static final int STATE_LOADED = 2;
- private static final float COMPACT_MARGIN = 0.3f;
-
- private static final int COMPACT_MINIMAL_FILES = 10;
-
// Static --------------------------------------------------------
private static final Logger log = Logger.getLogger(JournalImpl.class);
@@ -186,6 +182,10 @@
private final int fileSize;
private final int minFiles;
+
+ private final float compactPercentage;
+
+ private final int compactMinFiles;
private final SequentialFileFactory fileFactory;
@@ -225,6 +225,8 @@
public JournalImpl(final int fileSize,
final int minFiles,
+ final int compactMinFiles,
+ final int compactPercentage,
final SequentialFileFactory fileFactory,
final String filePrefix,
final String fileExtension,
@@ -260,6 +262,22 @@
{
throw new IllegalStateException("maxAIO should aways be a positive number");
}
+
+ if (compactPercentage < 0 || compactPercentage > 100)
+ {
+ throw new IllegalArgumentException("Compact Percentage out of range");
+ }
+
+ if (compactPercentage == 0)
+ {
+ this.compactPercentage = 0;
+ }
+ else
+ {
+ this.compactPercentage = (float)compactPercentage / 100f;
+ }
+
+ this.compactMinFiles = compactMinFiles;
this.fileSize = fileSize;
@@ -1696,6 +1714,12 @@
public void checkCompact() throws Exception
{
+ if (compactMinFiles == 0)
+ {
+ // compacting is disabled
+ return;
+ }
+
JournalFile[] dataFiles = getDataFiles();
long totalLiveSize = 0;
@@ -1707,9 +1731,9 @@
long totalBytes = (long)dataFiles.length * (long)fileSize;
- long compactMargin = (long)(totalBytes * COMPACT_MARGIN);
+ long compactMargin = (long)(totalBytes * compactPercentage);
- if (totalLiveSize < compactMargin && compactor == null && dataFiles.length > COMPACT_MINIMAL_FILES)
+ if (totalLiveSize < compactMargin && compactor == null && dataFiles.length > compactMinFiles)
{
log.info("Compacting being started, numberOfDataFiles = " + dataFiles.length + ", liveSize = " + totalLiveSize + ", margin to start compacting = " + compactMargin);
Modified: branches/clebert_temp_expirement/src/main/org/jboss/messaging/core/persistence/impl/journal/JournalStorageManager.java
===================================================================
--- branches/clebert_temp_expirement/src/main/org/jboss/messaging/core/persistence/impl/journal/JournalStorageManager.java 2009-07-01 23:44:04 UTC (rev 7511)
+++ branches/clebert_temp_expirement/src/main/org/jboss/messaging/core/persistence/impl/journal/JournalStorageManager.java 2009-07-02 04:35:48 UTC (rev 7512)
@@ -141,11 +141,11 @@
private final boolean syncTransactional;
private final boolean syncNonTransactional;
-
+
private final int perfBlastPages;
public JournalStorageManager(final Configuration config, final Executor executor)
- {
+ {
this.executor = executor;
if (config.getJournalType() != JournalType.NIO && config.getJournalType() != JournalType.ASYNCIO)
@@ -164,7 +164,14 @@
SequentialFileFactory bindingsFF = new NIOSequentialFileFactory(bindingsDir);
- bindingsJournal = new JournalImpl(1024 * 1024, 2, bindingsFF, "jbm-bindings", "bindings", 1);
+ bindingsJournal = new JournalImpl(1024 * 1024,
+ 2,
+ config.getJournalCompactMinFiles(),
+ config.getJournalCompactPercentage(),
+ bindingsFF,
+ "jbm-bindings",
+ "bindings",
+ 1);
String journalDir = config.getJournalDirectory();
@@ -210,7 +217,9 @@
}
messageJournal = new JournalImpl(config.getJournalFileSize(),
- config.getJournalMinFiles(),
+ config.getJournalMinFiles(),
+ config.getJournalCompactMinFiles(),
+ config.getJournalCompactPercentage(),
journalFF,
"jbm-data",
"jbm",
@@ -221,7 +230,7 @@
checkAndCreateDir(largeMessagesDirectory, config.isCreateJournalDir());
largeMessagesFactory = new NIOSequentialFileFactory(config.getLargeMessagesDirectory());
-
+
perfBlastPages = config.getJournalPerfBlastPages();
}
@@ -243,14 +252,14 @@
}
public long generateUniqueID()
- {
+ {
long id = idGenerator.generateID();
return id;
}
public long getCurrentUniqueID()
- {
+ {
return idGenerator.getCurrentID();
}
@@ -344,10 +353,7 @@
}
else
{
- messageJournal.appendAddRecordTransactional(txID,
- message.getMessageID(),
- ADD_MESSAGE,
- message);
+ messageJournal.appendAddRecordTransactional(txID, message.getMessageID(), ADD_MESSAGE, message);
}
}
@@ -371,18 +377,12 @@
public void storeReferenceTransactional(final long txID, final long queueID, final long messageID) throws Exception
{
- messageJournal.appendUpdateRecordTransactional(txID,
- messageID,
- ADD_REF,
- new RefEncoding(queueID));
+ messageJournal.appendUpdateRecordTransactional(txID, messageID, ADD_REF, new RefEncoding(queueID));
}
public void storeAcknowledgeTransactional(final long txID, final long queueID, final long messageID) throws Exception
{
- messageJournal.appendUpdateRecordTransactional(txID,
- messageID,
- ACKNOWLEDGE_REF,
- new RefEncoding(queueID));
+ messageJournal.appendUpdateRecordTransactional(txID, messageID, ACKNOWLEDGE_REF, new RefEncoding(queueID));
}
public void deletePageTransactional(final long txID, final long recordID) throws Exception
@@ -691,7 +691,7 @@
}
loadPreparedTransactions(pagingManager, resourceManager, queues, preparedTransactions, duplicateIDMap);
-
+
if (perfBlastPages != -1)
{
messageJournal.perfBlast(perfBlastPages);
@@ -890,7 +890,7 @@
public void addQueueBinding(final Binding binding) throws Exception
{
Queue queue = (Queue)binding.getBindable();
-
+
Filter filter = queue.getFilter();
SimpleString filterString = filter == null ? null : filter.getFilterString();
@@ -960,7 +960,7 @@
throw new IllegalStateException("Invalid record type " + rec);
}
}
-
+
idGenerator.setID(lastID + 1);
}
@@ -979,7 +979,7 @@
bindingsJournal.start();
messageJournal.start();
-
+
started = true;
}
Modified: branches/clebert_temp_expirement/tests/config/ConfigurationTest-full-config.xml
===================================================================
--- branches/clebert_temp_expirement/tests/config/ConfigurationTest-full-config.xml 2009-07-01 23:44:04 UTC (rev 7511)
+++ branches/clebert_temp_expirement/tests/config/ConfigurationTest-full-config.xml 2009-07-02 04:35:48 UTC (rev 7512)
@@ -38,6 +38,8 @@
<create-journal-dir>false</create-journal-dir>
<journal-type>NIO</journal-type>
<journal-aio-flush-on-sync>true</journal-aio-flush-on-sync>
+ <journal-compact-min-files>123</journal-compact-min-files>
+ <journal-compact-percentage>33</journal-compact-percentage>
<journal-aio-buffer-timeout>1000</journal-aio-buffer-timeout>
<journal-aio-buffer-size>10000</journal-aio-buffer-size>
<journal-sync-transactional>false</journal-sync-transactional>
Modified: branches/clebert_temp_expirement/tests/src/org/jboss/messaging/tests/integration/journal/NIOJournalCompactTest.java
===================================================================
--- branches/clebert_temp_expirement/tests/src/org/jboss/messaging/tests/integration/journal/NIOJournalCompactTest.java 2009-07-01 23:44:04 UTC (rev 7511)
+++ branches/clebert_temp_expirement/tests/src/org/jboss/messaging/tests/integration/journal/NIOJournalCompactTest.java 2009-07-02 04:35:48 UTC (rev 7512)
@@ -201,7 +201,7 @@
final CountDownLatch latchDone = new CountDownLatch(1);
final CountDownLatch latchWait = new CountDownLatch(1);
- journal = new JournalImpl(fileSize, minFiles, fileFactory, filePrefix, fileExtension, maxAIO)
+ journal = new JournalImpl(fileSize, minFiles, 0, 0, fileFactory, filePrefix, fileExtension, maxAIO)
{
@Override
Modified: branches/clebert_temp_expirement/tests/src/org/jboss/messaging/tests/performance/journal/JournalImplTestUnit.java
===================================================================
--- branches/clebert_temp_expirement/tests/src/org/jboss/messaging/tests/performance/journal/JournalImplTestUnit.java 2009-07-01 23:44:04 UTC (rev 7511)
+++ branches/clebert_temp_expirement/tests/src/org/jboss/messaging/tests/performance/journal/JournalImplTestUnit.java 2009-07-02 04:35:48 UTC (rev 7512)
@@ -200,7 +200,7 @@
public void testSpeedTransactional() throws Exception
{
- Journal journal = new JournalImpl(10 * 1024 * 1024, 10, getFileFactory(), "jbm-data", "jbm", 5000);
+ Journal journal = new JournalImpl(10 * 1024 * 1024, 10, 0, 0, getFileFactory(), "jbm-data", "jbm", 5000);
journal.start();
@@ -261,7 +261,7 @@
log.debug("num Files=" + numFiles);
- Journal journal = new JournalImpl(10 * 1024 * 1024, numFiles, getFileFactory(), "jbm-data", "jbm", 5000);
+ Journal journal = new JournalImpl(10 * 1024 * 1024, numFiles, 0, 0, getFileFactory(), "jbm-data", "jbm", 5000);
journal.start();
@@ -285,7 +285,7 @@
journal.stop();
- journal = new JournalImpl(10 * 1024 * 1024, numFiles, getFileFactory(), "jbm-data", "jbm", 5000);
+ journal = new JournalImpl(10 * 1024 * 1024, numFiles, 0, 0, getFileFactory(), "jbm-data", "jbm", 5000);
journal.start();
journal.load(new ArrayList<RecordInfo>(), null);
Modified: branches/clebert_temp_expirement/tests/src/org/jboss/messaging/tests/stress/journal/AddAndRemoveStressTest.java
===================================================================
--- branches/clebert_temp_expirement/tests/src/org/jboss/messaging/tests/stress/journal/AddAndRemoveStressTest.java 2009-07-01 23:44:04 UTC (rev 7511)
+++ branches/clebert_temp_expirement/tests/src/org/jboss/messaging/tests/stress/journal/AddAndRemoveStressTest.java 2009-07-02 04:35:48 UTC (rev 7512)
@@ -65,7 +65,7 @@
};
private static final long NUMBER_OF_MESSAGES = 210000l;
-
+
private static final int NUMBER_OF_FILES_ON_JOURNAL = 6;
// Attributes ----------------------------------------------------
@@ -76,12 +76,18 @@
// Public --------------------------------------------------------
-
public void testInsertAndLoad() throws Exception
{
SequentialFileFactory factory = new AIOSequentialFileFactory(getTestDir());
- JournalImpl impl = new JournalImpl(10 * 1024 * 1024, NUMBER_OF_FILES_ON_JOURNAL, factory, "jbm", "jbm", 1000);
+ JournalImpl impl = new JournalImpl(10 * 1024 * 1024,
+ NUMBER_OF_FILES_ON_JOURNAL,
+ 0,
+ 0,
+ factory,
+ "jbm",
+ "jbm",
+ 1000);
impl.start();
@@ -99,7 +105,7 @@
impl.stop();
factory = new AIOSequentialFileFactory(getTestDir());
- impl = new JournalImpl(10 * 1024 * 1024, NUMBER_OF_FILES_ON_JOURNAL, factory, "jbm", "jbm", 1000);
+ impl = new JournalImpl(10 * 1024 * 1024, NUMBER_OF_FILES_ON_JOURNAL, 0, 0, factory, "jbm", "jbm", 1000);
impl.start();
@@ -118,7 +124,7 @@
impl.stop();
factory = new AIOSequentialFileFactory(getTestDir());
- impl = new JournalImpl(10 * 1024 * 1024, NUMBER_OF_FILES_ON_JOURNAL, factory, "jbm", "jbm", 1000);
+ impl = new JournalImpl(10 * 1024 * 1024, NUMBER_OF_FILES_ON_JOURNAL, 0, 0, factory, "jbm", "jbm", 1000);
impl.start();
@@ -126,7 +132,7 @@
ArrayList<PreparedTransactionInfo> trans = new ArrayList<PreparedTransactionInfo>();
impl.load(info, trans);
-
+
impl.forceMoveNextFile();
if (info.size() > 0)
@@ -136,7 +142,7 @@
assertEquals(0, info.size());
assertEquals(0, trans.size());
-
+
assertEquals(0, impl.getDataFilesCount());
}
@@ -145,7 +151,14 @@
{
SequentialFileFactory factory = new AIOSequentialFileFactory(getTestDir());
- JournalImpl impl = new JournalImpl(10 * 1024 * 1024, NUMBER_OF_FILES_ON_JOURNAL, factory, "jbm", "jbm", 1000);
+ JournalImpl impl = new JournalImpl(10 * 1024 * 1024,
+ NUMBER_OF_FILES_ON_JOURNAL,
+ 0,
+ 0,
+ factory,
+ "jbm",
+ "jbm",
+ 1000);
impl.start();
@@ -164,7 +177,7 @@
impl.stop();
factory = new AIOSequentialFileFactory(getTestDir());
- impl = new JournalImpl(10 * 1024 * 1024, 10, factory, "jbm", "jbm", 1000);
+ impl = new JournalImpl(10 * 1024 * 1024, 10, 0, 0, factory, "jbm", "jbm", 1000);
impl.start();
@@ -183,7 +196,7 @@
impl.stop();
factory = new AIOSequentialFileFactory(getTestDir());
- impl = new JournalImpl(10 * 1024 * 1024, NUMBER_OF_FILES_ON_JOURNAL, factory, "jbm", "jbm", 1000);
+ impl = new JournalImpl(10 * 1024 * 1024, NUMBER_OF_FILES_ON_JOURNAL, 0, 0, factory, "jbm", "jbm", 1000);
impl.start();
@@ -196,7 +209,7 @@
{
System.out.println("Info ID: " + info.get(0).id);
}
-
+
impl.forceMoveNextFile();
impl.checkAndReclaimFiles();
@@ -216,7 +229,7 @@
protected void setUp() throws Exception
{
super.setUp();
-
+
File file = new File(getTestDir());
deleteDirectory(file);
file.mkdirs();
Modified: branches/clebert_temp_expirement/tests/src/org/jboss/messaging/tests/stress/journal/remote/RemoteJournalAppender.java
===================================================================
--- branches/clebert_temp_expirement/tests/src/org/jboss/messaging/tests/stress/journal/remote/RemoteJournalAppender.java 2009-07-01 23:44:04 UTC (rev 7511)
+++ branches/clebert_temp_expirement/tests/src/org/jboss/messaging/tests/stress/journal/remote/RemoteJournalAppender.java 2009-07-02 04:35:48 UTC (rev 7512)
@@ -41,23 +41,22 @@
*/
public class RemoteJournalAppender
{
-
+
// Constants -----------------------------------------------------
-
+
public static final int OK = 10;
+
// Attributes ----------------------------------------------------
-
+
// Static --------------------------------------------------------
-
+
public static void main(String args[]) throws Exception
{
-
+
if (args.length != 5)
{
- System.err
- .println("Use: java -cp <classpath> "
- + RemoteJournalAppender.class.getCanonicalName()
- + " aio|nio <journalDirectory> <NumberOfElements> <TransactionSize> <NumberOfThreads>");
+ System.err.println("Use: java -cp <classpath> " + RemoteJournalAppender.class.getCanonicalName() +
+ " aio|nio <journalDirectory> <NumberOfElements> <TransactionSize> <NumberOfThreads>");
System.exit(-1);
}
System.out.println("Running");
@@ -66,54 +65,53 @@
long numberOfElements = Long.parseLong(args[2]);
int transactionSize = Integer.parseInt(args[3]);
int numberOfThreads = Integer.parseInt(args[4]);
-
try
{
- appendData(journalType, journalDir,
- numberOfElements, transactionSize, numberOfThreads);
-
+ appendData(journalType, journalDir, numberOfElements, transactionSize, numberOfThreads);
+
}
catch (Exception e)
{
e.printStackTrace(System.out);
System.exit(-1);
}
-
+
System.exit(OK);
}
- public static JournalImpl appendData(String journalType, String journalDir,
- long numberOfElements, int transactionSize, int numberOfThreads) throws Exception
+ public static JournalImpl appendData(String journalType,
+ String journalDir,
+ long numberOfElements,
+ int transactionSize,
+ int numberOfThreads) throws Exception
{
final JournalImpl journal = createJournal(journalType, journalDir);
-
+
journal.start();
journal.load(new LoaderCallback()
{
-
- public void addPreparedTransaction(
- PreparedTransactionInfo preparedTransaction)
+
+ public void addPreparedTransaction(PreparedTransactionInfo preparedTransaction)
{
}
-
+
public void addRecord(RecordInfo info)
{
}
-
+
public void deleteRecord(long id)
{
}
-
+
public void updateRecord(RecordInfo info)
{
}
});
-
-
+
LocalThreads threads[] = new LocalThreads[numberOfThreads];
final AtomicLong sequenceTransaction = new AtomicLong();
-
+
for (int i = 0; i < numberOfThreads; i++)
{
threads[i] = new LocalThreads(journal, numberOfElements, transactionSize, sequenceTransaction);
@@ -121,33 +119,38 @@
}
Exception e = null;
- for (LocalThreads t: threads)
+ for (LocalThreads t : threads)
{
t.join();
-
+
if (t.e != null)
{
e = t.e;
}
}
-
+
if (e != null)
{
throw e;
}
-
-
+
return journal;
}
public static JournalImpl createJournal(String journalType, String journalDir)
{
- JournalImpl journal = new JournalImpl(10485760, 2, getFactory(journalType, journalDir), "journaltst", "tst", 500);
+ JournalImpl journal = new JournalImpl(10485760,
+ 2,
+ 0,
+ 0,
+ getFactory(journalType, journalDir),
+ "journaltst",
+ "tst",
+ 500);
return journal;
}
-
- public static SequentialFileFactory getFactory(String factoryType,
- String directory)
+
+ public static SequentialFileFactory getFactory(String factoryType, String directory)
{
if (factoryType.equals("aio"))
{
@@ -162,29 +165,31 @@
return new NIOSequentialFileFactory(directory);
}
}
+
// Constructors --------------------------------------------------
-
+
// Public --------------------------------------------------------
-
+
// Package protected ---------------------------------------------
-
+
// Protected -----------------------------------------------------
-
-
+
// Private -------------------------------------------------------
-
+
// Inner classes -------------------------------------------------
-
-
+
static class LocalThreads extends Thread
{
final JournalImpl journal;
+
final long numberOfElements;
+
final int transactionSize;
+
final AtomicLong nextID;
-
+
Exception e;
-
+
public LocalThreads(JournalImpl journal, long numberOfElements, int transactionSize, AtomicLong nextID)
{
super();
@@ -194,29 +199,26 @@
this.nextID = nextID;
}
-
-
-
public void run()
{
try
{
int transactionCounter = 0;
-
+
long transactionId = nextID.incrementAndGet();
-
+
for (long i = 0; i < numberOfElements; i++)
{
-
+
long id = nextID.incrementAndGet();
-
- ByteBuffer buffer = ByteBuffer.allocate(512*3);
+
+ ByteBuffer buffer = ByteBuffer.allocate(512 * 3);
buffer.putLong(id);
-
+
if (transactionSize != 0)
{
journal.appendAddRecordTransactional(transactionId, id, (byte)99, buffer.array());
-
+
if (++transactionCounter == transactionSize)
{
System.out.println("Commit transaction " + transactionId);
@@ -230,12 +232,12 @@
journal.appendAddRecord(id, (byte)99, buffer.array(), false);
}
}
-
+
if (transactionCounter != 0)
{
journal.appendCommitRecord(transactionId, true);
}
-
+
if (transactionSize == 0)
{
journal.debugWait();
@@ -245,8 +247,8 @@
{
this.e = e;
}
-
+
}
}
-
+
}
Modified: branches/clebert_temp_expirement/tests/src/org/jboss/messaging/tests/unit/core/config/impl/DefaultsFileConfigurationTest.java
===================================================================
--- branches/clebert_temp_expirement/tests/src/org/jboss/messaging/tests/unit/core/config/impl/DefaultsFileConfigurationTest.java 2009-07-01 23:44:04 UTC (rev 7511)
+++ branches/clebert_temp_expirement/tests/src/org/jboss/messaging/tests/unit/core/config/impl/DefaultsFileConfigurationTest.java 2009-07-02 04:35:48 UTC (rev 7512)
@@ -106,6 +106,10 @@
assertEquals(ConfigurationImpl.DEFAULT_JOURNAL_FILE_SIZE, conf.getJournalFileSize());
+ assertEquals(ConfigurationImpl.DEFAULT_JOURNAL_COMPACT_MIN_FILES, conf.getJournalCompactMinFiles());
+
+ assertEquals(ConfigurationImpl.DEFAULT_JOURNAL_COMPACT_PERCENTAGE, conf.getJournalCompactPercentage());
+
assertEquals(ConfigurationImpl.DEFAULT_JOURNAL_MIN_FILES, conf.getJournalMinFiles());
assertEquals(ConfigurationImpl.DEFAULT_JOURNAL_MAX_AIO, conf.getJournalMaxAIO());
Modified: branches/clebert_temp_expirement/tests/src/org/jboss/messaging/tests/unit/core/config/impl/FileConfigurationTest.java
===================================================================
--- branches/clebert_temp_expirement/tests/src/org/jboss/messaging/tests/unit/core/config/impl/FileConfigurationTest.java 2009-07-01 23:44:04 UTC (rev 7511)
+++ branches/clebert_temp_expirement/tests/src/org/jboss/messaging/tests/unit/core/config/impl/FileConfigurationTest.java 2009-07-02 04:35:48 UTC (rev 7512)
@@ -86,6 +86,8 @@
assertEquals(true, conf.isJournalSyncNonTransactional());
assertEquals(12345678, conf.getJournalFileSize());
assertEquals(100, conf.getJournalMinFiles());
+ assertEquals(123, conf.getJournalCompactMinFiles());
+ assertEquals(33, conf.getJournalCompactPercentage());
assertEquals(56546, conf.getJournalMaxAIO());
assertEquals("largemessagesdir", conf.getLargeMessagesDirectory());
Modified: branches/clebert_temp_expirement/tests/src/org/jboss/messaging/tests/unit/core/journal/impl/AlignedJournalImplTest.java
===================================================================
--- branches/clebert_temp_expirement/tests/src/org/jboss/messaging/tests/unit/core/journal/impl/AlignedJournalImplTest.java 2009-07-01 23:44:04 UTC (rev 7511)
+++ branches/clebert_temp_expirement/tests/src/org/jboss/messaging/tests/unit/core/journal/impl/AlignedJournalImplTest.java 2009-07-02 04:35:48 UTC (rev 7512)
@@ -146,7 +146,7 @@
try
{
- journalImpl = new JournalImpl(2000, 2, factory, "tt", "tt", 1000);
+ journalImpl = new JournalImpl(2000, 2, 0, 0, factory, "tt", "tt", 1000);
fail("Supposed to throw an exception");
}
catch (Exception ignored)
@@ -565,7 +565,7 @@
}
journalImpl.appendCommitRecord(1l, false);
-
+
System.out.println("Files = " + factory.listFiles("tt"));
SequentialFile file = factory.createSequentialFile("tt-1.tt", 1);
@@ -671,7 +671,6 @@
journalImpl.checkAndReclaimFiles();
-
}
public void testReduceFreeFiles() throws Exception
@@ -1256,7 +1255,7 @@
{
SequentialFileFactory factory = new FakeSequentialFileFactory(512, false);
- JournalImpl impl = new JournalImpl(512 + 512 * 3, 20, factory, "jbm", "jbm", 1000);
+ JournalImpl impl = new JournalImpl(512 + 512 * 3, 20, 0, 0, factory, "jbm", "jbm", 1000);
impl.start();
@@ -1269,7 +1268,7 @@
impl.stop();
- impl = new JournalImpl(512 + 1024 + 512, 20, factory, "jbm", "jbm", 1000);
+ impl = new JournalImpl(512 + 1024 + 512, 20, 0, 0, factory, "jbm", "jbm", 1000);
impl.start();
impl.load(dummyLoader);
@@ -1284,7 +1283,7 @@
impl.stop();
- impl = new JournalImpl(512 + 1024 + 512, 20, factory, "jbm", "jbm", 1000);
+ impl = new JournalImpl(512 + 1024 + 512, 20, 0, 0, factory, "jbm", "jbm", 1000);
impl.start();
ArrayList<RecordInfo> info = new ArrayList<RecordInfo>();
@@ -1329,7 +1328,7 @@
{
}
}
-
+
super.tearDown();
}
@@ -1352,7 +1351,7 @@
journalImpl.stop();
}
- journalImpl = new JournalImpl(journalSize, numberOfMinimalFiles, factory, "tt", "tt", 1000);
+ journalImpl = new JournalImpl(journalSize, numberOfMinimalFiles, 0, 0, factory, "tt", "tt", 1000);
journalImpl.start();
Modified: branches/clebert_temp_expirement/tests/src/org/jboss/messaging/tests/unit/core/journal/impl/JournalAsyncTest.java
===================================================================
--- branches/clebert_temp_expirement/tests/src/org/jboss/messaging/tests/unit/core/journal/impl/JournalAsyncTest.java 2009-07-01 23:44:04 UTC (rev 7511)
+++ branches/clebert_temp_expirement/tests/src/org/jboss/messaging/tests/unit/core/journal/impl/JournalAsyncTest.java 2009-07-02 04:35:48 UTC (rev 7512)
@@ -340,7 +340,7 @@
{
}
}
-
+
super.tearDown();
}
@@ -357,7 +357,7 @@
journalImpl.stop();
}
- journalImpl = new JournalImpl(journalSize, numberOfMinimalFiles, factory, "tt", "tt", 1000);
+ journalImpl = new JournalImpl(journalSize, numberOfMinimalFiles, 0, 0, factory, "tt", "tt", 1000);
journalImpl.start();
Modified: branches/clebert_temp_expirement/tests/src/org/jboss/messaging/tests/unit/core/journal/impl/JournalImplTestBase.java
===================================================================
--- branches/clebert_temp_expirement/tests/src/org/jboss/messaging/tests/unit/core/journal/impl/JournalImplTestBase.java 2009-07-01 23:44:04 UTC (rev 7511)
+++ branches/clebert_temp_expirement/tests/src/org/jboss/messaging/tests/unit/core/journal/impl/JournalImplTestBase.java 2009-07-02 04:35:48 UTC (rev 7512)
@@ -66,7 +66,7 @@
protected int fileSize;
protected boolean sync;
-
+
protected String filePrefix = "jbm";
protected String fileExtension = "jbm";
@@ -104,7 +104,7 @@
journal = null;
assertEquals(0, AsynchronousFileImpl.getTotalMaxIO());
-
+
super.tearDown();
}
@@ -143,7 +143,7 @@
public void createJournal() throws Exception
{
- journal = new JournalImpl(fileSize, minFiles, fileFactory, filePrefix, fileExtension, maxAIO);
+ journal = new JournalImpl(fileSize, minFiles, 0, 0, fileFactory, filePrefix, fileExtension, maxAIO);
journal.setAutoReclaim(false);
}
@@ -167,7 +167,7 @@
journal.stop();
}
-
+
protected void loadAndCheck() throws Exception
{
loadAndCheck(false);
@@ -182,7 +182,7 @@
journal.load(committedRecords, preparedTransactions);
checkRecordsEquivalent(records, committedRecords);
-
+
if (printDebugJournal)
{
printJournalLists(records, committedRecords);
@@ -255,7 +255,7 @@
removeRecordsForID(element);
}
-
+
journal.debugWait();
}
@@ -498,7 +498,7 @@
byte[] record = new byte[length];
for (int i = 0; i < length; i++)
{
- //record[i] = RandomUtil.randomByte();
+ // record[i] = RandomUtil.randomByte();
record[i] = getSamplebyte(i);
}
return record;
Modified: branches/clebert_temp_expirement/tests/src/org/jboss/messaging/tests/unit/core/journal/impl/JournalImplTestUnit.java
===================================================================
--- branches/clebert_temp_expirement/tests/src/org/jboss/messaging/tests/unit/core/journal/impl/JournalImplTestUnit.java 2009-07-01 23:44:04 UTC (rev 7511)
+++ branches/clebert_temp_expirement/tests/src/org/jboss/messaging/tests/unit/core/journal/impl/JournalImplTestUnit.java 2009-07-02 04:35:48 UTC (rev 7512)
@@ -128,7 +128,7 @@
{
try
{
- new JournalImpl(JournalImpl.MIN_FILE_SIZE - 1, 10, fileFactory, filePrefix, fileExtension, 1);
+ new JournalImpl(JournalImpl.MIN_FILE_SIZE - 1, 10, 0, 0, fileFactory, filePrefix, fileExtension, 1);
fail("Should throw exception");
}
@@ -139,7 +139,7 @@
try
{
- new JournalImpl(10 * 1024, 1, fileFactory, filePrefix, fileExtension, 1);
+ new JournalImpl(10 * 1024, 1, 0, 0, fileFactory, filePrefix, fileExtension, 1);
fail("Should throw exception");
}
@@ -150,7 +150,7 @@
try
{
- new JournalImpl(10 * 1024, 10, null, filePrefix, fileExtension, 1);
+ new JournalImpl(10 * 1024, 10, 0, 0, null, filePrefix, fileExtension, 1);
fail("Should throw exception");
}
@@ -161,7 +161,7 @@
try
{
- new JournalImpl(10 * 1024, 10, fileFactory, null, fileExtension, 1);
+ new JournalImpl(10 * 1024, 10, 0, 0, fileFactory, null, fileExtension, 1);
fail("Should throw exception");
}
@@ -172,7 +172,7 @@
try
{
- new JournalImpl(10 * 1024, 10, fileFactory, filePrefix, null, 1);
+ new JournalImpl(10 * 1024, 10, 0, 0, fileFactory, filePrefix, null, 1);
fail("Should throw exception");
}
@@ -183,7 +183,7 @@
try
{
- new JournalImpl(10 * 1024, 10, fileFactory, filePrefix, null, 0);
+ new JournalImpl(10 * 1024, 10, 0, 0, fileFactory, filePrefix, null, 0);
fail("Should throw exception");
}
@@ -3023,26 +3023,24 @@
{
delete(i);
}
-
+
System.out.println("After delete ****************************");
System.out.println(journal.debug());
System.out.println("*****************************************");
-
for (int i = 100; i < 200; i++)
{
updateTx(transactionID, i);
}
-
+
System.out.println("After updatetx ****************************");
System.out.println(journal.debug());
System.out.println("*****************************************");
-
journal.forceMoveNextFile();
commit(transactionID++);
-
+
System.out.println("After commit ****************************");
System.out.println(journal.debug());
System.out.println("*****************************************");
@@ -3057,7 +3055,6 @@
System.out.println(journal.debug());
System.out.println("*****************************************");
-
commit(transactionID++);
System.out.println("Before reclaim/after commit ****************************");
Modified: branches/clebert_temp_expirement/tests/src/org/jboss/messaging/tests/unit/core/journal/impl/fakes/FakeSequentialFileFactory.java
===================================================================
--- branches/clebert_temp_expirement/tests/src/org/jboss/messaging/tests/unit/core/journal/impl/fakes/FakeSequentialFileFactory.java 2009-07-01 23:44:04 UTC (rev 7511)
+++ branches/clebert_temp_expirement/tests/src/org/jboss/messaging/tests/unit/core/journal/impl/fakes/FakeSequentialFileFactory.java 2009-07-02 04:35:48 UTC (rev 7512)
@@ -87,7 +87,7 @@
{
FakeSequentialFile sf = fileMap.get(fileName);
- if (sf == null)
+ if (sf == null || sf.data == null)
{
sf = newSequentialFile(fileName);
@@ -627,7 +627,9 @@
*/
public boolean exists()
{
- return fileMap.get(fileName) != null;
+ FakeSequentialFile file = fileMap.get(fileName);
+
+ return file != null && file.data != null && file.data.capacity() > 0;
}
}
Modified: branches/clebert_temp_expirement/tests/src/org/jboss/messaging/tests/util/JournalExample.java
===================================================================
--- branches/clebert_temp_expirement/tests/src/org/jboss/messaging/tests/util/JournalExample.java 2009-07-01 23:44:04 UTC (rev 7511)
+++ branches/clebert_temp_expirement/tests/src/org/jboss/messaging/tests/util/JournalExample.java 2009-07-02 04:35:48 UTC (rev 7512)
@@ -70,8 +70,10 @@
SequentialFileFactory fileFactory = new AIOSequentialFileFactory("/tmp"); // any dir you want
// SequentialFileFactory fileFactory = new NIOSequentialFileFactory("/tmp"); // any dir you want
JournalImpl journalExample = new JournalImpl(10 * 1024 * 1024, // 10M.. we believe that's the usual cilinder
- // bufferSize.. not an exact science here
+ // bufferSize.. not an exact science here
2, // number of files pre-allocated
+ 0,
+ 0,
fileFactory, // AIO or NIO
"exjournal", // file name
"dat", // extension
Modified: branches/clebert_temp_expirement/tests/src/org/jboss/messaging/tests/util/ListJournal.java
===================================================================
--- branches/clebert_temp_expirement/tests/src/org/jboss/messaging/tests/util/ListJournal.java 2009-07-01 23:44:04 UTC (rev 7511)
+++ branches/clebert_temp_expirement/tests/src/org/jboss/messaging/tests/util/ListJournal.java 2009-07-02 04:35:48 UTC (rev 7512)
@@ -67,6 +67,8 @@
JournalImpl journal = new JournalImpl(fileConf.getJournalFileSize(),
fileConf.getJournalMinFiles(),
+ 0,
+ 0,
new NIOSequentialFileFactory(fileConf.getJournalDirectory()),
"jbm-data",
"jbm",
More information about the jboss-cvs-commits
mailing list