[hornetq-commits] JBoss hornetq SVN: r8125 - in trunk: src/config/common/schema and 4 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Sat Oct 17 08:38:46 EDT 2009
Author: timfox
Date: 2009-10-17 08:38:46 -0400 (Sat, 17 Oct 2009)
New Revision: 8125
Added:
trunk/src/main/org/hornetq/core/journal/impl/SyncSpeedTest.java
Modified:
trunk/examples/core/perf/server0/hornetq-configuration.xml
trunk/src/config/common/schema/hornetq-configuration.xsd
trunk/src/main/org/hornetq/core/config/Configuration.java
trunk/src/main/org/hornetq/core/config/impl/ConfigurationImpl.java
trunk/src/main/org/hornetq/core/config/impl/FileConfiguration.java
trunk/src/main/org/hornetq/core/server/impl/HornetQServerImpl.java
Log:
built sync speed test into server
Modified: trunk/examples/core/perf/server0/hornetq-configuration.xml
===================================================================
--- trunk/examples/core/perf/server0/hornetq-configuration.xml 2009-10-17 12:15:09 UTC (rev 8124)
+++ trunk/examples/core/perf/server0/hornetq-configuration.xml 2009-10-17 12:38:46 UTC (rev 8125)
@@ -17,14 +17,16 @@
<persistence-enabled>true</persistence-enabled>
- <journal-sync-non-transactional>false</journal-sync-non-transactional>
+ <journal-sync-non-transactional>true</journal-sync-non-transactional>
+ <journal-sync-transactional>true</journal-sync-transactional>
<journal-type>ASYNCIO</journal-type>
<journal-min-files>20</journal-min-files>
<journal-aio-buffer-timeout>20000</journal-aio-buffer-timeout>
<log-journal-write-rate>true</log-journal-write-rate>
+ <run-sync-speed-test>true</run-sync-speed-test>
+
<!-- <perf-blast-pages>5000</perf-blast-pages> -->
-
-
+
<queues>
<queue name="perfQueue">
<address>perfAddress</address>
Modified: trunk/src/config/common/schema/hornetq-configuration.xsd
===================================================================
--- trunk/src/config/common/schema/hornetq-configuration.xsd 2009-10-17 12:15:09 UTC (rev 8124)
+++ trunk/src/config/common/schema/hornetq-configuration.xsd 2009-10-17 12:38:46 UTC (rev 8125)
@@ -168,6 +168,8 @@
</xsd:element>
<xsd:element maxOccurs="1" minOccurs="0" name="perf-blast-pages" type="xsd:int">
</xsd:element>
+ <xsd:element maxOccurs="1" minOccurs="0" name="run-sync-speed-test" type="xsd:boolean">
+ </xsd:element>
<xsd:element maxOccurs="1" minOccurs="0" name="server-dump-interval" type="xsd:long">
</xsd:element>
<xsd:element maxOccurs="1" minOccurs="0" name="memory-warning-threshold" type="xsd:int">
Modified: trunk/src/main/org/hornetq/core/config/Configuration.java
===================================================================
--- trunk/src/main/org/hornetq/core/config/Configuration.java 2009-10-17 12:15:09 UTC (rev 8124)
+++ trunk/src/main/org/hornetq/core/config/Configuration.java 2009-10-17 12:38:46 UTC (rev 8125)
@@ -243,6 +243,8 @@
void setLogJournalWriteRate(boolean rate);
+ //Undocumented attributes
+
int getJournalPerfBlastPages();
void setJournalPerfBlastPages(int pages);
@@ -259,6 +261,10 @@
void setMemoryMeasureInterval(long memoryMeasureInterval);
+ boolean isRunSyncSpeedTest();
+
+ void setRunSyncSpeedTest(boolean run);
+
// Paging Properties --------------------------------------------------------------------
String getPagingDirectory();
Modified: trunk/src/main/org/hornetq/core/config/impl/ConfigurationImpl.java
===================================================================
--- trunk/src/main/org/hornetq/core/config/impl/ConfigurationImpl.java 2009-10-17 12:15:09 UTC (rev 8124)
+++ trunk/src/main/org/hornetq/core/config/impl/ConfigurationImpl.java 2009-10-17 12:38:46 UTC (rev 8125)
@@ -110,6 +110,8 @@
public static final boolean DEFAULT_JOURNAL_LOG_WRITE_RATE = false;
public static final int DEFAULT_JOURNAL_PERF_BLAST_PAGES = -1;
+
+ public static final boolean DEFAULT_RUN_SYNC_SPEED_TEST = false;
public static final boolean DEFAULT_WILDCARD_ROUTING_ENABLED = true;
@@ -270,6 +272,8 @@
protected boolean logJournalWriteRate = DEFAULT_JOURNAL_LOG_WRITE_RATE;
protected int journalPerfBlastPages = DEFAULT_JOURNAL_PERF_BLAST_PAGES;
+
+ protected boolean runSyncSpeedTest = DEFAULT_RUN_SYNC_SPEED_TEST;
protected boolean wildcardRoutingEnabled = DEFAULT_WILDCARD_ROUTING_ENABLED;
@@ -670,7 +674,17 @@
{
this.journalPerfBlastPages = journalPerfBlastPages;
}
+
+ public boolean isRunSyncSpeedTest()
+ {
+ return runSyncSpeedTest;
+ }
+ public void setRunSyncSpeedTest(boolean run)
+ {
+ this.runSyncSpeedTest = run;
+ }
+
public boolean isCreateBindingsDir()
{
return createBindingsDir;
@@ -1109,4 +1123,5 @@
{
this.logDelegateFactoryClassName = className;
}
+
}
Modified: trunk/src/main/org/hornetq/core/config/impl/FileConfiguration.java
===================================================================
--- trunk/src/main/org/hornetq/core/config/impl/FileConfiguration.java 2009-10-17 12:15:09 UTC (rev 8124)
+++ trunk/src/main/org/hornetq/core/config/impl/FileConfiguration.java 2009-10-17 12:38:46 UTC (rev 8125)
@@ -319,6 +319,8 @@
logJournalWriteRate = getBoolean(e, "log-journal-write-rate", DEFAULT_JOURNAL_LOG_WRITE_RATE);
journalPerfBlastPages = getInteger(e, "perf-blast-pages", DEFAULT_JOURNAL_PERF_BLAST_PAGES, MINUS_ONE_OR_GT_ZERO);
+
+ runSyncSpeedTest = getBoolean(e, "run-sync-speed-test", runSyncSpeedTest);
wildcardRoutingEnabled = getBoolean(e, "wild-card-routing-enabled", wildcardRoutingEnabled);
Added: trunk/src/main/org/hornetq/core/journal/impl/SyncSpeedTest.java
===================================================================
--- trunk/src/main/org/hornetq/core/journal/impl/SyncSpeedTest.java (rev 0)
+++ trunk/src/main/org/hornetq/core/journal/impl/SyncSpeedTest.java 2009-10-17 12:38:46 UTC (rev 8125)
@@ -0,0 +1,122 @@
+/*
+ * 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.core.journal.impl;
+
+import java.io.File;
+import java.io.RandomAccessFile;
+import java.nio.ByteBuffer;
+import java.nio.channels.FileChannel;
+
+import org.hornetq.core.logging.Logger;
+
+/**
+ * A SyncSpeedTest
+ *
+ * This class just provides some diagnostics on how fast your disk can sync
+ * Useful when determining performance issues
+ *
+ * @author tim fox
+ *
+ *
+ */
+public class SyncSpeedTest
+{
+ private static final Logger log = Logger.getLogger(SyncSpeedTest.class);
+
+ public static void main(final String[] args)
+ {
+ try
+ {
+ new SyncSpeedTest().run();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ public void run() throws Exception
+ {
+ log.info("******* Starting file sync speed test *******");
+
+ int fileSize = 1024 * 1024 * 10;
+
+ int recordSize = 1024;
+
+ int its = 10 * 1024;
+
+ File file = new File("sync-speed-test.dat");
+
+ if (file.exists())
+ {
+ file.delete();
+ }
+
+ RandomAccessFile rfile = new RandomAccessFile(file, "rw");
+
+ FileChannel channel = rfile.getChannel();
+
+ ByteBuffer bb = generateBuffer(fileSize, (byte)'x');
+
+ write(bb, channel, fileSize);
+
+ channel.force(false);
+
+ channel.position(0);
+
+ ByteBuffer bb1 = generateBuffer(recordSize, (byte)'h');
+
+ log.info("Measuring");
+
+ long start = System.currentTimeMillis();
+
+ for (int i = 0; i < its; i++)
+ {
+ write(bb1, channel, recordSize);
+
+ channel.force(false);
+ }
+
+ long end = System.currentTimeMillis();
+
+ double rate = 1000 * ((double)its) / (end - start);
+
+ log.info("Rate of " + rate + " syncs per sec");
+
+ rfile.close();
+
+ file.delete();
+
+ log.info("****** test complete *****");
+ }
+
+ private void write(final ByteBuffer buffer, final FileChannel channel, final int size) throws Exception
+ {
+ buffer.flip();
+
+ channel.write(buffer);
+ }
+
+ private ByteBuffer generateBuffer(final int size, final byte ch)
+ {
+ ByteBuffer bb = ByteBuffer.allocateDirect(size);
+
+ for (int i = 0; i < size; i++)
+ {
+ bb.put(ch);
+ }
+
+ return bb;
+ }
+}
Modified: trunk/src/main/org/hornetq/core/server/impl/HornetQServerImpl.java
===================================================================
--- trunk/src/main/org/hornetq/core/server/impl/HornetQServerImpl.java 2009-10-17 12:15:09 UTC (rev 8124)
+++ trunk/src/main/org/hornetq/core/server/impl/HornetQServerImpl.java 2009-10-17 12:38:46 UTC (rev 8125)
@@ -50,6 +50,7 @@
import org.hornetq.core.exception.HornetQException;
import org.hornetq.core.filter.Filter;
import org.hornetq.core.filter.impl.FilterImpl;
+import org.hornetq.core.journal.impl.SyncSpeedTest;
import org.hornetq.core.logging.LogDelegateFactory;
import org.hornetq.core.logging.Logger;
import org.hornetq.core.management.ManagementService;
@@ -69,7 +70,6 @@
import org.hornetq.core.postoffice.impl.LocalQueueBinding;
import org.hornetq.core.postoffice.impl.PostOfficeImpl;
import org.hornetq.core.remoting.Channel;
-import org.hornetq.core.remoting.Interceptor;
import org.hornetq.core.remoting.RemotingConnection;
import org.hornetq.core.remoting.impl.wireformat.CreateSessionResponseMessage;
import org.hornetq.core.remoting.impl.wireformat.ReattachSessionResponseMessage;
@@ -267,6 +267,13 @@
{
return;
}
+
+ if (configuration.isRunSyncSpeedTest())
+ {
+ SyncSpeedTest test = new SyncSpeedTest();
+
+ test.run();
+ }
initialisePart1();
@@ -1020,7 +1027,7 @@
securityDeployer.start();
}
}
-
+
// Load the journal and populate queues, transactions and caches in memory
loadJournal();
More information about the hornetq-commits
mailing list