[hornetq-commits] JBoss hornetq SVN: r9199 - branches/HnetQ_323_cn/docs/user-manual/zh.

do-not-reply at jboss.org do-not-reply at jboss.org
Wed May 5 04:00:40 EDT 2010


Author: gaohoward
Date: 2010-05-05 04:00:38 -0400 (Wed, 05 May 2010)
New Revision: 9199

Modified:
   branches/HnetQ_323_cn/docs/user-manual/zh/thread-pooling.xml
Log:
done


Modified: branches/HnetQ_323_cn/docs/user-manual/zh/thread-pooling.xml
===================================================================
--- branches/HnetQ_323_cn/docs/user-manual/zh/thread-pooling.xml	2010-05-05 03:10:14 UTC (rev 9198)
+++ branches/HnetQ_323_cn/docs/user-manual/zh/thread-pooling.xml	2010-05-05 08:00:38 UTC (rev 9199)
@@ -17,98 +17,74 @@
 <!-- permitted by applicable law.                                                  -->
 <!-- ============================================================================= -->
 <chapter id="thread-pooling">
-    <title>Thread management</title>
-    <para>This chapter describes how HornetQ uses and pools threads and how you can manage
-        them.</para>
-    <para>First we'll discuss how threads are managed and used on the server side, then we'll look
-        at the client side.</para>
+    <title>线程管理</title>
+    <para>本章讲述HornetQ如何使用线程池以及如何管理线程。</para>
+    <para>首先我们讨论在服务器端线程是如何被管理的,然后我们再讨论客户端的情况。</para>
     <section>
-        <title>Server-Side Thread Management</title>
-        <para>Each HornetQ Server maintains a single thread pool for general use, and a scheduled
-            thread pool for scheduled use. A Java scheduled thread pool cannot be configured to use
-            a standard thread pool, otherwise we could use a single thread pool for both scheduled
-            and non scheduled activity.</para>
-        <para>There are also a small number of other places where threads are used directly, we'll
-            discuss each in turn.</para>
+        <title>服务器端线程的管理</title>
+        <para>每个HornetQ服务器都有一个线程池作为一般线程使用,另外还有一个可计划线程池。Java的可计划线程池不能作为
+            标准的线程池使用,因此我们采用了两个单独的线程池。</para>
+        <para>另外在其它一些地方直接使用了线程,没有用线程池。我们将对这些线程作出解释。</para>
         <section id="server.scheduled.thread.pool">
-            <title>Server Scheduled Thread Pool</title>
-            <para>The server scheduled thread pool is used for most activities on the server side
-                that require running periodically or with delays. It maps internally to a <literal
-                    >java.util.concurrent.ScheduledThreadPoolExecutor</literal> instance.</para>
-            <para>The maximum number of thread used by this pool is configure in <literal
-                    >hornetq-configuration.xml</literal> with the <literal
-                    >scheduled-thread-pool-max-size</literal> parameter. The default value is
-                    <literal>5</literal> threads. A small number of threads is usually sufficient
-                for this pool.</para>
+            <title>服务器端可计划线程池</title>
+            <para>服务器可计划线程池可以定期地或延迟地执行所交给的任务,它用来完成HornetQ中绝大部分这样的任务。
+                  它内部使用的是一个 <literal
+                    >java.util.concurrent.ScheduledThreadPoolExecutor</literal>实例。</para>
+            <para>最大线程数可以在<literal
+                    >hornetq-configuration.xml</literal>文件中进行配置,参数名是<literal
+                    >scheduled-thread-pool-max-size</literal>。默认值是<literal>5</literal>。
+                    通常这个线程池不需要很大数量的线程。</para>
         </section>
         <section>
-            <title>General Purpose Server Thread Pool</title>
-            <para>This general purpose thread pool is used for most asynchronous actions on the
-                server side. It maps internally to a <literal
-                    >java.util.concurrent.ThreadPoolExecutor</literal> instance.</para>
-            <para>The maximum number of thread used by this pool is configure in <literal
-                    >hornetq-configuration.xml</literal> with the <literal
-                    >thread-pool-max-size</literal> parameter.</para>
-            <para>If a value of <literal>-1</literal> is used this signifies that the thread pool
-                has no upper bound and new threads will be created on demand if there are enough
-                threads available to satisfy a request. If activity later subsides then threads are
-                timed-out and closed.</para>
-            <para>If a value of <literal>n</literal> where <literal>n</literal>is a positive integer
-                greater than zero is used this signifies that the thread pool is bounded. If more
-                requests come in and there are no free threads in the pool and the pool is full then
-                requests will block until a thread becomes available. It is recommended that a
-                bounded thread pool is used with caution since it can lead to dead-lock situations
-                if the upper bound is chosen to be too low.</para>
-            <para>The default value for <literal>thread-pool-max-size</literal> is <literal
-                    >-1</literal>, i.e. the thread pool is unbounded.</para>
-            <para>See the <ulink
+            <title>服务器通用线程池</title>
+            <para>服务器端绝大部分的异步操作都是由这个线程池来完成的。在它的内部使用了一个<literal
+                    >java.util.concurrent.ThreadPoolExecutor</literal>的实例。</para>
+            <para>这个线程池的最大线程数在<literal>hornetq-configuration.xml</literal>文件中配置,相应的参数名为<literal
+                    >thread-pool-max-size</literal>。</para>
+            <para>如果将参数设为<literal>-1</literal>则表示该线程池没有线程限制。也就是说当线程不够用时,线程池就
+                会创建新的线程。当任务不多时,空闲的线程将会超时并被关闭。</para>
+            <para>如果这个参数的值是一个大于零的整数<literal>n</literal>,则该线程池的线程数是有限的。当所有线程都
+                处于忙的状态并且线程数已经达到n时,任何新的请求都将被阻塞直到有线程空闲为止。在设置线程上限时,我们建议
+                要非常谨慎。因为如何线程数量过低会造成死锁情况的发生。</para>
+            <para><literal>thread-pool-max-size</literal>的默认值是<literal
+                    >-1</literal>,即线程池没有上限。</para>
+            <para>参见<ulink
                     url="http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/ThreadPoolExecutor.html"
-                    >J2SE javadoc</ulink> for more information on unbounded (cached), and bounded
-                (fixed) thread pools.</para>
+                    >J2SE javadoc</ulink>有关无边界(缓存)和有边界(固定)线程池的解释。</para>
         </section>
         <section>
-            <title>Expiry Reaper Thread</title>
-            <para>A single thread is also used on the server side to scan for expired messages in
-                queues. We cannot use either of the thread pools for this since this thread needs to
-                run at its own configurable priority.</para>
-            <para>For more information on configuring the reaper, please see <xref
-                    linkend="message-expiry"/>.</para>
+            <title>过期回收线程</title>
+            <para>HornetQ使用一个单独的线程来扫描队列中过期的消息。由于这个线程需要自己的优先级配置,所以不能使用上述的
+                任何一个线程池。</para>
+            <para>关于回收线程的配置请参阅<xref linkend="message-expiry"/>。</para>
         </section>
         <section>
-            <title>Asynchronous IO</title>
-            <para>Asynchronous IO has a thread pool for receiving and dispatching events out of the
-                native layer. You will find it on a thread dump with the prefix
-                HornetQ-AIO-poller-pool. HornetQ uses one thread per opened file on the journal
-                (there is usually one).</para>
-            <para>There is also a single thread used to invoke writes on libaio. We do that to avoid
-                context switching on libaio what would cause performance issues. You will find this
-                thread on a thread dump with the prefix HornetQ-AIO-writer-pool.</para>
+            <title>异步IO</title>
+            <para>HornetQ使用一个线程池来进行异步IO的操作,包括事件的接收和发送。这些线程的名字都是以
+                HornetQ-AIO-poller-pool为开头。每个打开的日志文件都对应有一个线程为其服务(通常只有
+                一个)。</para>
+            <para>还有一个单独的线程用于向libaio发送写请求。这样做是为了避免上下文转换带来的性能下降。该
+                线程的名字以HornetQ-AIO-writer-pool开头。</para>
         </section>
     </section>
     <section id="thread-pooling.client.side">
-        <title>Client-Side Thread Management</title>
-        <para>On the client side, HornetQ maintains a single static scheduled thread pool and a
-            single static general thread pool for use by all clients using the same classloader in
-            that JVM instance.</para>
-        <para>The static scheduled thread pool has a maximum size of <literal>5</literal> threads,
-            and the general purpose thread pool has an unbounded maximum size.</para>
-        <para>If required HornetQ can also be configured so that each <literal
-                >ClientSessionFactory</literal> instance does not use these static pools but instead
-            maintains its own scheduled and general purpose pool. Any sessions created from that
-                <literal>ClientSessionFactory</literal> will use those pools instead.</para>
-        <para>To configure a <literal>ClientSessionFactory</literal> instance to use its own pools,
-            simply use the appropriate setter methods immediately after creation, for
-            example:</para>
+        <title>客户端线程管理</title>
+        <para>在客户端HornetQ有一个静态的可计划线程池和一个静态的通用线程池,它们在一个JVM中由同一个classloader装载的所有客户端
+            共同使用。</para>
+        <para>静态的可计划的线程池的最大线程数为 <literal>5</literal>,通用线程池则没有线程数限制。</para>
+        <para>如果需要还可以配置一个<literal
+                >ClientSessionFactory</literal>实例以使它拥有自己的可计划与通用线程池。通过这个工厂创建的会话都
+            将使用这些线程池。</para>
+        <para>要想配置<literal>ClientSessionFactory</literal>使用自己的线程池,只要调用它相应的方法取出可,如:</para>
         <programlisting>ClientSessionFactory myFactory = HornetQClient.createClientSessionFactory(...);
 myFactory.setUseGlobalPools(false);
 myFactory.setScheduledThreadPoolMaxSize(10);
 myFactory.setThreadPoolMaxSize(-1);   </programlisting>
-        <para>If you're using the JMS API, you can set the same parameters on the ClientSessionFactory and use it to create the <literal
-                >ConnectionFactory</literal> instance, for example:</para>
+        <para>如果使用JMS,你可以先用同样的参数设置ClientSessionFactory,然后再用这样工厂创建<literal
+                >ConnectionFactory</literal>的实例。如:</para>
         <programlisting>ConnectionFactory myConnectionFactory = HornetQJMSClient.createConnectionFactory(myFactory);     </programlisting>
-        <para>If you're using JNDI to instantiate <literal>HornetQConnectionFactory</literal>
-            instances, you can also set these parameters in the <literal>hornetq-jms.xml</literal>
-            file where you describe your connection factory, for example:</para>
+        <para>如果你使用JNDI来创建<literal>HornetQConnectionFactory</literal>
+            实例,你还可以在<literal>hornetq-jms.xml</literal>文件中进行配置。如:</para>
         <programlisting>&lt;connection-factory name="ConnectionFactory"&gt;
     &lt;connectors>
        &lt;connector-ref connector-name="netty"/&gt;



More information about the hornetq-commits mailing list