private void writeThreadPool( XMLExtendedStreamWriter writer, String name, ThreadPoolConfiguration threadPoolConfiguration) throws XMLStreamException { ThreadPoolExecutorFactory<?> threadPoolFactory = threadPoolConfiguration.threadPoolFactory(); if (threadPoolFactory != null) { writer.writeStartElement(THREAD_POOL_FACTORIES.get(threadPoolFactory.getClass().getName())); writer.writeAttribute(Attribute.NAME, name); ThreadFactory threadFactory = threadPoolConfiguration.threadFactory(); if (threadFactory instanceof DefaultThreadFactory) { DefaultThreadFactory tf = (DefaultThreadFactory) threadFactory; writer.writeAttribute(Attribute.THREAD_FACTORY, tf.getName()); } if (threadPoolFactory instanceof BlockingThreadPoolExecutorFactory) { BlockingThreadPoolExecutorFactory pool = (BlockingThreadPoolExecutorFactory) threadPoolFactory; writer.writeAttribute(Attribute.MAX_THREADS, Integer.toString(pool.maxThreads())); writer.writeAttribute(Attribute.CORE_THREADS, Integer.toString(pool.coreThreads())); writer.writeAttribute(Attribute.QUEUE_LENGTH, Integer.toString(pool.queueLength())); writer.writeAttribute(Attribute.KEEP_ALIVE_TIME, Long.toString(pool.keepAlive())); } writer.writeEndElement(); } }
private void writeThreads(XMLExtendedStreamWriter writer, GlobalConfiguration globalConfiguration) throws XMLStreamException { writer.writeStartElement(Element.THREADS); ConcurrentMap<String, DefaultThreadFactory> threadFactories = CollectionFactory.makeConcurrentMap(); for (ThreadPoolConfiguration threadPoolConfiguration : Arrays.asList( globalConfiguration.expirationThreadPool(), globalConfiguration.listenerThreadPool(), globalConfiguration.persistenceThreadPool(), globalConfiguration.replicationQueueThreadPool(), globalConfiguration.stateTransferThreadPool(), globalConfiguration.transport().remoteCommandThreadPool(), globalConfiguration.transport().transportThreadPool())) { ThreadFactory threadFactory = threadPoolConfiguration.threadFactory(); if (threadFactory instanceof DefaultThreadFactory) { DefaultThreadFactory tf = (DefaultThreadFactory) threadFactory; threadFactories.putIfAbsent(tf.getName(), tf); } } for (DefaultThreadFactory threadFactory : threadFactories.values()) { writeThreadFactory(writer, threadFactory); } writeThreadPool(writer, "async-pool", globalConfiguration.asyncThreadPool()); writeThreadPool(writer, "expiration-pool", globalConfiguration.expirationThreadPool()); writeThreadPool(writer, "listener-pool", globalConfiguration.listenerThreadPool()); writeThreadPool(writer, "persistence-pool", globalConfiguration.persistenceThreadPool()); writeThreadPool( writer, "replication-queue-pool", globalConfiguration.replicationQueueThreadPool()); writeThreadPool(writer, "state-transfer-pool", globalConfiguration.stateTransferThreadPool()); writeThreadPool( writer, "remote-command-pool", globalConfiguration.transport().remoteCommandThreadPool()); writeThreadPool( writer, "transport-pool", globalConfiguration.transport().transportThreadPool()); writer.writeEndElement(); }