Search in sources :

Example 1 with ThreadPoolExecutorFactoryBean

use of org.springframework.scheduling.concurrent.ThreadPoolExecutorFactoryBean in project cloudbreak by hortonworks.

the class AppConfig method getThreadPoolExecutorFactoryBean.

@Bean
public ThreadPoolExecutorFactoryBean getThreadPoolExecutorFactoryBean() {
    ThreadPoolExecutorFactoryBean executorFactoryBean = new ThreadPoolExecutorFactoryBean();
    executorFactoryBean.setCorePoolSize(corePoolSize);
    executorFactoryBean.setMaxPoolSize(maxPoolSize);
    executorFactoryBean.setQueueCapacity(queueCapacity);
    return executorFactoryBean;
}
Also used : ThreadPoolExecutorFactoryBean(org.springframework.scheduling.concurrent.ThreadPoolExecutorFactoryBean) ThreadPoolExecutorFactoryBean(org.springframework.scheduling.concurrent.ThreadPoolExecutorFactoryBean) Bean(org.springframework.context.annotation.Bean) SchedulerFactoryBean(org.springframework.scheduling.quartz.SchedulerFactoryBean)

Example 2 with ThreadPoolExecutorFactoryBean

use of org.springframework.scheduling.concurrent.ThreadPoolExecutorFactoryBean in project cas by apereo.

the class Beans method newThreadPoolExecutorFactoryBean.

/**
 * New thread pool executor factory bean.
 *
 * @param keepAlive the keep alive
 * @param maxSize   the max size
 * @return the thread pool executor factory bean
 */
public static ThreadPoolExecutorFactoryBean newThreadPoolExecutorFactoryBean(final long keepAlive, final long maxSize) {
    final ThreadPoolExecutorFactoryBean bean = new ThreadPoolExecutorFactoryBean();
    bean.setMaxPoolSize((int) maxSize);
    bean.setKeepAliveSeconds((int) keepAlive);
    return bean;
}
Also used : ThreadPoolExecutorFactoryBean(org.springframework.scheduling.concurrent.ThreadPoolExecutorFactoryBean)

Example 3 with ThreadPoolExecutorFactoryBean

use of org.springframework.scheduling.concurrent.ThreadPoolExecutorFactoryBean in project cas by apereo.

the class Beans method newThreadPoolExecutorFactoryBean.

/**
 * New thread pool executor factory bean.
 *
 * @param config the config
 * @return the thread pool executor factory bean
 */
public static FactoryBean<ExecutorService> newThreadPoolExecutorFactoryBean(final ConnectionPoolingProperties config) {
    val bean = new ThreadPoolExecutorFactoryBean();
    bean.setMaxPoolSize(config.getMaxSize());
    bean.setCorePoolSize(config.getMinSize());
    bean.afterPropertiesSet();
    return bean;
}
Also used : lombok.val(lombok.val) ThreadPoolExecutorFactoryBean(org.springframework.scheduling.concurrent.ThreadPoolExecutorFactoryBean)

Example 4 with ThreadPoolExecutorFactoryBean

use of org.springframework.scheduling.concurrent.ThreadPoolExecutorFactoryBean in project uPortal by Jasig.

the class ConcurrentDirectoryScannerTest method setup.

@Before
public void setup() throws Exception {
    testDirectory = File.createTempFile("ConcurrentDirectoryScannerTest_", "_dir");
    testDirectory.delete();
    testDirectory.mkdirs();
    final InputStream dataZipStream = this.getClass().getResourceAsStream("/org/apereo/portal/utils/DirScannerData.zip");
    ZipUtils.extract(dataZipStream, testDirectory);
    IOUtils.closeQuietly(dataZipStream);
    executorServiceFactory = new ThreadPoolExecutorFactoryBean();
    executorServiceFactory.setCorePoolSize(0);
    executorServiceFactory.setMaxPoolSize(1);
    executorServiceFactory.setQueueCapacity(500);
    executorServiceFactory.setKeepAliveSeconds(30);
    executorServiceFactory.setAllowCoreThreadTimeOut(true);
    executorServiceFactory.setDaemon(true);
    executorServiceFactory.afterPropertiesSet();
    this.directoryScanner = new ConcurrentDirectoryScanner(executorServiceFactory.getObject());
}
Also used : ThreadPoolExecutorFactoryBean(org.springframework.scheduling.concurrent.ThreadPoolExecutorFactoryBean) InputStream(java.io.InputStream) Before(org.junit.Before)

Example 5 with ThreadPoolExecutorFactoryBean

use of org.springframework.scheduling.concurrent.ThreadPoolExecutorFactoryBean in project uPortal by Jasig.

the class JaxbPortalDataHandlerServiceTest method setup.

@Before
public void setup() throws Exception {
    xmlUtilities = new XmlUtilitiesImpl() {

        @Override
        public Templates getTemplates(Resource stylesheet) throws TransformerConfigurationException, IOException {
            final TransformerFactory transformerFactory = TransformerFactory.newInstance();
            return transformerFactory.newTemplates(new StreamSource(stylesheet.getInputStream()));
        }
    };
    dataImportExportService.setXmlUtilities(xmlUtilities);
    final ThreadPoolExecutorFactoryBean threadPoolExecutorFactoryBean = new ThreadPoolExecutorFactoryBean();
    threadPoolExecutorFactoryBean.setCorePoolSize(0);
    threadPoolExecutorFactoryBean.setMaxPoolSize(20);
    threadPoolExecutorFactoryBean.setQueueCapacity(20);
    threadPoolExecutorFactoryBean.setThreadGroupName("uPortal-ImportExportThreadGroup");
    threadPoolExecutorFactoryBean.setThreadNamePrefix("uPortal-ImportExport-");
    threadPoolExecutorFactoryBean.setThreadPriority(5);
    threadPoolExecutorFactoryBean.setKeepAliveSeconds(30);
    threadPoolExecutorFactoryBean.setDaemon(true);
    threadPoolExecutorFactoryBean.setAllowCoreThreadTimeOut(true);
    threadPoolExecutorFactoryBean.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
    threadPoolExecutorFactoryBean.afterPropertiesSet();
    threadPoolExecutor = threadPoolExecutorFactoryBean.getObject();
    this.dataImportExportService.setImportExportThreadPool(threadPoolExecutor);
    dataImportExportService.setDataFileIncludes(ImmutableSet.of("**/*.xml", "**/*.entity-type", "**/*.template-user", "**/*.user", "**/*.group", "**/*.group_membership", "**/*.membership", "**/*.portlet-type", "**/*.channel-type", "**/*.portlet", "**/*.channel", "**/*.permission", "**/*.permission_set", "**/*.permission_owner", "**/*.profile", "**/*.fragment-layout", "**/*.layout", "**/*.fragment-definition"));
    dataImportExportService.setDataTypeImportOrder(getPortalDataTypes());
}
Also used : XmlUtilitiesImpl(org.apereo.portal.xml.XmlUtilitiesImpl) TransformerFactory(javax.xml.transform.TransformerFactory) TransformerConfigurationException(javax.xml.transform.TransformerConfigurationException) ThreadPoolExecutorFactoryBean(org.springframework.scheduling.concurrent.ThreadPoolExecutorFactoryBean) StreamSource(javax.xml.transform.stream.StreamSource) ClassPathResource(org.springframework.core.io.ClassPathResource) Resource(org.springframework.core.io.Resource) Templates(javax.xml.transform.Templates) IOException(java.io.IOException) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) Before(org.junit.Before)

Aggregations

ThreadPoolExecutorFactoryBean (org.springframework.scheduling.concurrent.ThreadPoolExecutorFactoryBean)5 Before (org.junit.Before)2 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)1 Templates (javax.xml.transform.Templates)1 TransformerConfigurationException (javax.xml.transform.TransformerConfigurationException)1 TransformerFactory (javax.xml.transform.TransformerFactory)1 StreamSource (javax.xml.transform.stream.StreamSource)1 lombok.val (lombok.val)1 XmlUtilitiesImpl (org.apereo.portal.xml.XmlUtilitiesImpl)1 Bean (org.springframework.context.annotation.Bean)1 ClassPathResource (org.springframework.core.io.ClassPathResource)1 Resource (org.springframework.core.io.Resource)1 SchedulerFactoryBean (org.springframework.scheduling.quartz.SchedulerFactoryBean)1