private static ExecutorService startAlertClientService( SystemMain system, AtomicInteger jobCounter) { int configuredCount = Integer.valueOf( system.getConfiguration().getValue(SystemConfiguration.Property.CLIENT_THREADS)); int configuredTimeout = Integer.valueOf( system .getConfiguration() .getValue(SystemConfiguration.Property.CLIENT_CONNECT_TIMEOUT)); int threadPoolCount = Math.max(configuredCount, 2); int timeout = Math.max(10000, configuredTimeout); ExecutorService service = Executors.newFixedThreadPool( threadPoolCount, new ThreadFactory() { AtomicInteger id = new AtomicInteger(0); @Override public Thread newThread(Runnable r) { return new Thread(r, MessageFormat.format("alertclient-{0}", id.getAndIncrement())); } }); system.getServiceFactory().getMonitorService().startRecordingCounters(); for (int i = 0; i < threadPoolCount; i++) { service.submit( new Alerter(system.getServiceFactory().getAlertService(), timeout, jobCounter)); } return service; }
private static ExecutorService startCommitAnnotationsClientService( SystemMain system, AtomicInteger jobCounter) { int configuredCount = Integer.valueOf( system.getConfiguration().getValue(SystemConfiguration.Property.CLIENT_THREADS)); int threadPoolCount = Math.max(configuredCount, 2); ExecutorService service = Executors.newFixedThreadPool( threadPoolCount, new ThreadFactory() { AtomicInteger id = new AtomicInteger(0); @Override public Thread newThread(Runnable r) { return new Thread( r, MessageFormat.format("annotationcommitclient-{0}", id.getAndIncrement())); } }); for (int i = 0; i < threadPoolCount; i++) { service.submit( new AnnotationCommitter( system.getServiceFactory().getCollectionService(), system.getServiceFactory().getMonitorService(), jobCounter)); } return service; }