List of usage examples for java.util.concurrent Executors newScheduledThreadPool
public static ScheduledExecutorService newScheduledThreadPool(int corePoolSize)
From source file:org.wso2.iot.refarch.rpi.agent.Publisher.java
private void start(int updateInterval) { ScheduledExecutorService dhtReaderScheduler = Executors.newScheduledThreadPool(1); dhtReaderScheduler.scheduleWithFixedDelay(new MonitoringTask(dhtSensor), 0, updateInterval, TimeUnit.SECONDS);//w w w . j a v a 2s . c o m }
From source file:com.kixeye.scout.eureka.EurekaServiceDiscoveryClient.java
/** * Creates a discovery client with default scheduler. * /*from ww w . ja v a 2 s.co m*/ * @param eurekaServiceUrl the url of the eureka instance, i.e. http://host:port/eureka/v2 * @param refreshRate * @param refreshRateTimeUnit */ public EurekaServiceDiscoveryClient(String eurekaServiceUrl, long refreshRate, TimeUnit refreshRateTimeUnit) { this(eurekaServiceUrl, refreshRate, refreshRateTimeUnit, Executors.newScheduledThreadPool(1)); }
From source file:org.asciidoctor.maven.AsciidoctorRefreshMojo.java
private void startUpdater() { updaterScheduler = Executors.newScheduledThreadPool(1); // we prevent refreshing more often than all 200ms and we refresh at least once/s // NOTE1: it is intended to avoid too much time space between file polling and re-rendering // NOTE2: if nothing to refresh it does nothing so all is fine updaterScheduler.scheduleAtFixedRate(new Updater(needsUpdate, this), 0, Math.min(1000, Math.max(200, interval / 2)), TimeUnit.MILLISECONDS); }
From source file:org.sbs.goodcrawler.fetcher.FailedPageBackup.java
public void init() { ignoreFailedPage = Boolean.getBoolean(config.getString(GlobalConstants.ignoreFailedPages, "true")); if (!ignoreFailedPage) { Queue = new LinkedBlockingDeque<Page>(config.getInt(GlobalConstants.failedPagesQueueSize, 2000)); // //from w w w. j a v a 2s. co m BackupFailedPages backup = new BackupFailedPages(); Thread failedPagesBackupThread = new Thread(backup, "failed-pages-backup-thread"); ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); scheduler.scheduleAtFixedRate(failedPagesBackupThread, 60, 60, TimeUnit.SECONDS); } }
From source file:com.gigaspaces.blueprint.frauddetection.feeder.Feeder.java
public void afterPropertiesSet() throws Exception { log.info("--- STARTING FEEDER WITH CYCLE [" + defaultDelay + "]"); executorService = Executors.newScheduledThreadPool(1); feederTask = new FeederTask(); sf = executorService.scheduleAtFixedRate(feederTask, defaultDelay, defaultDelay, TimeUnit.MILLISECONDS); }
From source file:ai.grakn.engine.backgroundtasks.InMemoryTaskManager.java
private InMemoryTaskManager() { instantiatedTasks = new ConcurrentHashMap<>(); stateStorage = InMemoryStateStorage.getInstance(); stateUpdateLock = new ReentrantLock(); ConfigProperties properties = ConfigProperties.getInstance(); schedulingService = Executors.newScheduledThreadPool(1); executorService = Executors.newFixedThreadPool(properties.getAvailableThreads()); }
From source file:scouter.plugin.server.alert.email.EmailPlugin.java
public EmailPlugin() { if (ai.incrementAndGet() == 1) { ScheduledExecutorService executor = Executors.newScheduledThreadPool(1); //thread count check executor.scheduleAtFixedRate(new Runnable() { @Override/*w w w. ja v a 2 s . c o m*/ public void run() { for (int objHash : javaeeObjHashList) { try { if (AgentManager.isActive(objHash)) { ObjectPack objectPack = AgentManager.getAgent(objHash); MapPack mapPack = new MapPack(); mapPack.put("objHash", objHash); mapPack = AgentCall.call(objectPack, RequestCmd.OBJECT_THREAD_LIST, mapPack); final int LIMIT = 30; //? . ? 20 ? 30 ? ? // . ? thread exceed threshold ?? . int threadCountThreshold = conf.getInt("ext_plugin_thread_count_threshold", LIMIT); int threadCount = mapPack.getList("name").size(); /* ? */ if (threadCountThreshold != 0 && threadCount > threadCountThreshold) { AlertPack ap = new AlertPack(); // ? 2 FATAL, ? WARN if (threadCount > threadCountThreshold * 2) ap.level = AlertLevel.FATAL; else ap.level = AlertLevel.WARN; ap.objHash = objHash; ap.title = " !"; ap.message = objectPack.objName + "? " + threadCount + ", (" + LIMIT + ") !"; ap.time = System.currentTimeMillis(); ap.objType = objectPack.objType; long limitTime = conf.getLong("ext_plugin_thread_limit_time", 120000); //2 long safeTime = conf.getLong("ext_plugin_thread_safe_time", 180000); //3 //? ? objectPack.objName ? if (objectContainer.sendAlert(ap, objectPack.objName, limitTime, safeTime)) alert(ap); } } } catch (Exception e) { // ignore } } } }, 0, 5, TimeUnit.SECONDS); //5 } }
From source file:io.nirvagi.utils.servlet.RecorderServlet.java
public void init() { recorder = new MonteScreenRecorder(); executorService = Executors.newScheduledThreadPool(1); }
From source file:org.ebayopensource.scc.impl.DefaultPolicyManagerTest.java
@Test public void testMergeGlobalPolicyJsonConfigIntoJCSProps() { String jsonConfig = "{" + "\"maxCount\": \"123\"," + "\"timeToLive\": 123456," + "\"update\" : \"LRU\"," + "\"cacheDir\" : \"./cache\"" + "}"; m_configMap.clear();//w ww.jav a2s. com m_configMap.putAll(new Gson().fromJson(jsonConfig, Map.class)); new DefaultPolicyManager(m_appConfigMock, m_keyGenMock, Executors.newScheduledThreadPool(1)); ArgumentCaptor<AppConfiguration> appConfigArgCaptor = ArgumentCaptor.forClass(AppConfiguration.class); ArgumentCaptor<Properties> mergedPropsArg = ArgumentCaptor.forClass(Properties.class); ArgumentCaptor<ScheduledExecutorService> scheduledServiceCaptor = ArgumentCaptor .forClass(ScheduledExecutorService.class); Mockito.verify(m_jcsCacheMock).init(appConfigArgCaptor.capture(), mergedPropsArg.capture(), scheduledServiceCaptor.capture()); Properties mergedProps = mergedPropsArg.getValue(); assertThat(mergedProps, is(notNullValue())); mergedProps.getProperty("jcs.default.cacheattributes.MaxObjects"); assertThat(mergedProps.getProperty("jcs.default.cacheattributes.MaxObjects"), is("123")); assertThat(mergedProps.getProperty("jcs.default.elementattributes.MaxLife"), is("123456")); assertThat(mergedProps.getProperty("jcs.default.cacheattributes.MemoryCacheName"), is("org.apache.commons.jcs.engine.memory.lru.LRUMemoryCache")); assertThat(mergedProps.getProperty("jcs.auxiliary.DC.attributes.DiskPath"), is("./cache")); }
From source file:io.syndesis.controllers.integration.IntegrationController.java
@PostConstruct public void start() { executor = Executors.newSingleThreadExecutor(); scheduler = Executors.newScheduledThreadPool(1); scanIntegrationsForWork();//w ww . j a v a 2 s .c o m eventBus.subscribe("integration-controller", getChangeEventSubscription()); }