@Test public void testCreateExecutorServiceWithManualValueCorrect() { int valueToSet = 1234; System.setProperty(PipelineExecutorTaskManagerImpl.THREAD_POOL_SIZE_PROPERTY_NAME, Integer.toString(valueToSet)); ExecutorService executorService = taskManagerHelper.createExecutorService(); verifyExecutorServiceAndDestroy(executorService, valueToSet); }
public ExecutorService createExecutorService() { final String threadPoolSizeValue = System.getProperties().getProperty(THREAD_POOL_SIZE_PROPERTY_NAME); int threadPoolSize; if (threadPoolSizeValue == null) { threadPoolSize = DEFAULT_THREAD_POOL_SIZE; logger.debug(THREAD_POOL_SIZE_PROPERTY_NAME + " property was not set, by default value will be used: " + DEFAULT_THREAD_POOL_SIZE); } else { try { threadPoolSize = Integer.parseInt(threadPoolSizeValue); if (threadPoolSize <= 0) { threadPoolSize = DEFAULT_THREAD_POOL_SIZE; logger.error(THREAD_POOL_SIZE_PROPERTY_NAME + " property must be greater than 0, by default value will be used: " + DEFAULT_THREAD_POOL_SIZE); } else { logger.debug(THREAD_POOL_SIZE_PROPERTY_NAME + " property will be set to: " + threadPoolSize); } } catch (Exception e) { threadPoolSize = DEFAULT_THREAD_POOL_SIZE; logger.error(THREAD_POOL_SIZE_PROPERTY_NAME + " property was set to a wrong value, by default value will be used: " + DEFAULT_THREAD_POOL_SIZE, e); } } return Executors.newFixedThreadPool(threadPoolSize); }
PipelineExecutorTaskManagerImplHelper { public ExecutorService createExecutorService() { final String threadPoolSizeValue = System.getProperties().getProperty(THREAD_POOL_SIZE_PROPERTY_NAME); int threadPoolSize; if (threadPoolSizeValue == null) { threadPoolSize = DEFAULT_THREAD_POOL_SIZE; logger.debug(THREAD_POOL_SIZE_PROPERTY_NAME + " property was not set, by default value will be used: " + DEFAULT_THREAD_POOL_SIZE); } else { try { threadPoolSize = Integer.parseInt(threadPoolSizeValue); if (threadPoolSize <= 0) { threadPoolSize = DEFAULT_THREAD_POOL_SIZE; logger.error(THREAD_POOL_SIZE_PROPERTY_NAME + " property must be greater than 0, by default value will be used: " + DEFAULT_THREAD_POOL_SIZE); } else { logger.debug(THREAD_POOL_SIZE_PROPERTY_NAME + " property will be set to: " + threadPoolSize); } } catch (Exception e) { threadPoolSize = DEFAULT_THREAD_POOL_SIZE; logger.error(THREAD_POOL_SIZE_PROPERTY_NAME + " property was set to a wrong value, by default value will be used: " + DEFAULT_THREAD_POOL_SIZE, e); } } return Executors.newFixedThreadPool(threadPoolSize); } }
PipelineExecutorTaskManagerImplHelper { public ExecutorService createExecutorService() { final String threadPoolSizeValue = System.getProperties().getProperty(THREAD_POOL_SIZE_PROPERTY_NAME); int threadPoolSize; if (threadPoolSizeValue == null) { threadPoolSize = DEFAULT_THREAD_POOL_SIZE; logger.debug(THREAD_POOL_SIZE_PROPERTY_NAME + " property was not set, by default value will be used: " + DEFAULT_THREAD_POOL_SIZE); } else { try { threadPoolSize = Integer.parseInt(threadPoolSizeValue); if (threadPoolSize <= 0) { threadPoolSize = DEFAULT_THREAD_POOL_SIZE; logger.error(THREAD_POOL_SIZE_PROPERTY_NAME + " property must be greater than 0, by default value will be used: " + DEFAULT_THREAD_POOL_SIZE); } else { logger.debug(THREAD_POOL_SIZE_PROPERTY_NAME + " property will be set to: " + threadPoolSize); } } catch (Exception e) { threadPoolSize = DEFAULT_THREAD_POOL_SIZE; logger.error(THREAD_POOL_SIZE_PROPERTY_NAME + " property was set to a wrong value, by default value will be used: " + DEFAULT_THREAD_POOL_SIZE, e); } } return Executors.newFixedThreadPool(threadPoolSize); } PipelineExecutorTaskManagerImplHelper(final Instance<ConfigExecutor> configExecutorInstance,
                                                 final Instance<PipelineEventListener> pipelineEventListenerInstance); }
PipelineExecutorTaskManagerImplHelper { public ExecutorService createExecutorService() { final String threadPoolSizeValue = System.getProperties().getProperty(THREAD_POOL_SIZE_PROPERTY_NAME); int threadPoolSize; if (threadPoolSizeValue == null) { threadPoolSize = DEFAULT_THREAD_POOL_SIZE; logger.debug(THREAD_POOL_SIZE_PROPERTY_NAME + " property was not set, by default value will be used: " + DEFAULT_THREAD_POOL_SIZE); } else { try { threadPoolSize = Integer.parseInt(threadPoolSizeValue); if (threadPoolSize <= 0) { threadPoolSize = DEFAULT_THREAD_POOL_SIZE; logger.error(THREAD_POOL_SIZE_PROPERTY_NAME + " property must be greater than 0, by default value will be used: " + DEFAULT_THREAD_POOL_SIZE); } else { logger.debug(THREAD_POOL_SIZE_PROPERTY_NAME + " property will be set to: " + threadPoolSize); } } catch (Exception e) { threadPoolSize = DEFAULT_THREAD_POOL_SIZE; logger.error(THREAD_POOL_SIZE_PROPERTY_NAME + " property was set to a wrong value, by default value will be used: " + DEFAULT_THREAD_POOL_SIZE, e); } } return Executors.newFixedThreadPool(threadPoolSize); } PipelineExecutorTaskManagerImplHelper(final Instance<ConfigExecutor> configExecutorInstance,
                                                 final Instance<PipelineEventListener> pipelineEventListenerInstance); ExecutorService createExecutorService(); PipelineExecutor createPipelineExecutor(); List<PipelineEventListener> createExternalListeners(); void notifyExternalListeners(final List<PipelineEventListener> externalListeners,
                                        final PipelineEvent event); PipelineExecutorTaskImpl createTask(final PipelineExecutorTaskDef taskDef); PipelineExecutorTaskImpl createTask(final PipelineExecutorTaskDef taskDef,
                                               final String executionId); String generateTaskId(); void setTaskInStoppedStatus(final PipelineExecutorTaskImpl task); }
PipelineExecutorTaskManagerImplHelper { public ExecutorService createExecutorService() { final String threadPoolSizeValue = System.getProperties().getProperty(THREAD_POOL_SIZE_PROPERTY_NAME); int threadPoolSize; if (threadPoolSizeValue == null) { threadPoolSize = DEFAULT_THREAD_POOL_SIZE; logger.debug(THREAD_POOL_SIZE_PROPERTY_NAME + " property was not set, by default value will be used: " + DEFAULT_THREAD_POOL_SIZE); } else { try { threadPoolSize = Integer.parseInt(threadPoolSizeValue); if (threadPoolSize <= 0) { threadPoolSize = DEFAULT_THREAD_POOL_SIZE; logger.error(THREAD_POOL_SIZE_PROPERTY_NAME + " property must be greater than 0, by default value will be used: " + DEFAULT_THREAD_POOL_SIZE); } else { logger.debug(THREAD_POOL_SIZE_PROPERTY_NAME + " property will be set to: " + threadPoolSize); } } catch (Exception e) { threadPoolSize = DEFAULT_THREAD_POOL_SIZE; logger.error(THREAD_POOL_SIZE_PROPERTY_NAME + " property was set to a wrong value, by default value will be used: " + DEFAULT_THREAD_POOL_SIZE, e); } } return Executors.newFixedThreadPool(threadPoolSize); } PipelineExecutorTaskManagerImplHelper(final Instance<ConfigExecutor> configExecutorInstance,
                                                 final Instance<PipelineEventListener> pipelineEventListenerInstance); ExecutorService createExecutorService(); PipelineExecutor createPipelineExecutor(); List<PipelineEventListener> createExternalListeners(); void notifyExternalListeners(final List<PipelineEventListener> externalListeners,
                                        final PipelineEvent event); PipelineExecutorTaskImpl createTask(final PipelineExecutorTaskDef taskDef); PipelineExecutorTaskImpl createTask(final PipelineExecutorTaskDef taskDef,
                                               final String executionId); String generateTaskId(); void setTaskInStoppedStatus(final PipelineExecutorTaskImpl task);  }