List of usage examples for java.util.concurrent Executors newSingleThreadScheduledExecutor
public static ScheduledExecutorService newSingleThreadScheduledExecutor()
From source file:org.apache.hadoop.hbase.master.assignment.TestAssignmentManager.java
@Before public void setUp() throws Exception { UTIL = new HBaseTestingUtility(); this.executor = Executors.newSingleThreadScheduledExecutor(); setupConfiguration(UTIL.getConfiguration()); master = new MockMasterServices(UTIL.getConfiguration(), this.regionsToRegionServers); rsDispatcher = new MockRSProcedureDispatcher(master); master.start(NSERVERS, rsDispatcher); am = master.getAssignmentManager();/*from ww w . ja va 2 s . c om*/ assignProcMetrics = am.getAssignmentManagerMetrics().getAssignProcMetrics(); unassignProcMetrics = am.getAssignmentManagerMetrics().getUnassignProcMetrics(); setUpMeta(); }
From source file:ddf.catalog.cache.solr.impl.SolrCache.java
private void configureCacheExpirationScheduler() { shutdownCacheExpirationScheduler();//from ww w. ja v a 2s . c om LOGGER.info("Configuring cache expiration scheduler with an expiration interval of {} minute(s).", expirationIntervalInMinutes); scheduler = Executors.newSingleThreadScheduledExecutor(); scheduler.scheduleAtFixedRate(new ExpirationRunner(), 0, expirationIntervalInMinutes, TimeUnit.MINUTES); }
From source file:playmidi.gui.Main.java
private void PlayButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_PlayButtonActionPerformed if (this.pTask != null) { barRunner = Executors.newSingleThreadScheduledExecutor(); playerRunner = Executors.newSingleThreadScheduledExecutor(); ProgressBarUpdater pup = new ProgressBarUpdater(this.PositionBar, this.pTask); barRunner.scheduleAtFixedRate(pup, 0, 1000, TimeUnit.MILLISECONDS); playerRunner.execute(pTask);/*from w w w. ja va 2 s . c o m*/ } }
From source file:org.appcelerator.titanium.util.TiResponseCache.java
public TiResponseCache(File cachedir, TiApplication tiApp) { super();/*from w ww .j a v a 2 s. com*/ assert cachedir.isDirectory() : "cachedir MUST be a directory"; cacheDir = cachedir; maxCacheSize = tiApp.getSystemProperties().getInt(CACHE_SIZE_KEY, DEFAULT_CACHE_SIZE) * 1024; Log.d(TAG, "max cache size is:" + maxCacheSize, Log.DEBUG_MODE); cleanupExecutor = Executors.newSingleThreadScheduledExecutor(); TiCacheCleanup command = new TiCacheCleanup(cacheDir, maxCacheSize); cleanupExecutor.scheduleWithFixedDelay(command, INITIAL_DELAY, CLEANUP_DELAY, TimeUnit.MILLISECONDS); }
From source file:de.msal.shoutemo.connector.GetPostsService.java
/** * Sets the {@code INTERVAL} of this service in which the refresh calls should occur. This * {@code INTERVAL} is dependant on the given {@code timeSinceLastPost}. If the latest post was * some hours ago, it is not necessary to update every some seconds, but maybe every half a * minute. <br/> After the new refresh rate is altered, the task will be stoped and restartet at * its new rate./*from ww w .j av a 2 s .co m*/ * * @param timeSinceLastPost the time in ms between the last post and the current time on the * phone. * @return the {@code INTERVAL} which was set, in ms. */ private long setIntervall(long timeSinceLastPost) { long oldInterval = INTERVAL; if (timeSinceLastPost < 120000) { // < 2min INTERVAL = 2500; // 2.5s } else if (timeSinceLastPost < 300000) { // 2min - 5min INTERVAL = 5000; // 5.0s } else if (timeSinceLastPost < 600000) { // 5min - 10min INTERVAL = 10000; // 10.0s } else { // > 10min INTERVAL = 15000; // 15.0s } if (INTERVAL != oldInterval && worker != null && !worker.isShutdown()) { worker.shutdown(); worker = Executors.newSingleThreadScheduledExecutor(); worker.scheduleAtFixedRate(new GetPostsTask(), 0, INTERVAL, TimeUnit.MILLISECONDS); } return INTERVAL; }
From source file:com.ah.be.license.AeroLicenseTimer.java
/** * Change the evaluation license allowed use time based on the server running time *//*w w w.j a v a2s. c om*/ public void evaluationOrVmwareTimer() { EvaluationLicenseTask taskEvalue = new EvaluationLicenseTask(); if (null == evaluationTimer || evaluationTimer.isShutdown()) { evaluationTimer = Executors.newSingleThreadScheduledExecutor(); evaluateFuture = evaluationTimer.scheduleWithFixedDelay(taskEvalue, 60 * 60, 60 * 60, TimeUnit.SECONDS); //evaluateFuture = evaluationTimer.scheduleAtFixedRate(taskEvalue, 60 * 3, 60 * 3, TimeUnit.SECONDS); BeLogTools.info(HmLogConst.M_TRACER | HmLogConst.M_LICENSE, "<BE Thread> Evaluation License timer is running..."); } }
From source file:at.wada811.android.library.demos.concurrent.ExecutorActivity.java
/** * {@link ScheduledExecutorService#schedule(Runnable, long, TimeUnit)} ??? * // www . j ava 2s. c o m * <p> * ??????????? * </p> */ public void newSingleThreadScheduledExecutorDuringExecutionTest() { LogUtils.d(); ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor(); executorService.schedule(new ExecutorRunnable("A", 1), 1, TimeUnit.SECONDS); executorService.schedule(new ExecutorRunnable("B", 1), 1, TimeUnit.SECONDS); executorService.schedule(new ExecutorRunnable("C", 1), 1, TimeUnit.SECONDS); executorService.schedule(new ExecutorRunnable("D", 1), 1, TimeUnit.SECONDS); }
From source file:io.fabric8.agent.download.DownloadManagerTest.java
/** * Prepares DownloadManager to test// w w w.j a va2s . c om * * @param remoteRepo * @param settingsFile * @param props * @return * @throws IOException */ private DownloadManager createDownloadManager(String remoteRepo, String settingsFile, Properties props) throws IOException { File mavenSettings = new File(karafHome, settingsFile); Hashtable<String, String> properties = new Hashtable<>(); if (props != null) { for (Map.Entry<Object, Object> entry : props.entrySet()) { properties.put(entry.getKey().toString(), entry.getValue().toString()); } } properties.put("org.ops4j.pax.url.mvn.localRepository", systemRepoUri); properties.put("org.ops4j.pax.url.mvn.repositories", remoteRepo); properties.put("org.ops4j.pax.url.mvn.defaultRepositories", systemRepoUri); properties.put("org.ops4j.pax.url.mvn.settings", mavenSettings.toURI().toString()); MavenResolver resolver = MavenResolvers.createMavenResolver(properties, "org.ops4j.pax.url.mvn"); return DownloadManagers.createDownloadManager(resolver, Executors.newSingleThreadScheduledExecutor()); }
From source file:org.kepler.gui.KeplerInitializer.java
private static void updateDataSources() { if (autoUpdate) { Executors.newSingleThreadScheduledExecutor().schedule(new Runnable() { public void run() { SearchRegistryAction.queryRegistryRewriteConfig(); }//w w w. j a v a 2s . co m }, autoUpdateDelay, TimeUnit.SECONDS); } }
From source file:com.taobao.diamond.client.impl.DefaultDiamondPublisher.java
public synchronized void start() { if (isRun) {//from w ww.j av a 2 s . c om return; } if (null == scheduledExecutor || scheduledExecutor.isTerminated()) { scheduledExecutor = Executors.newSingleThreadScheduledExecutor(); } if (null == scheduler || scheduler.isTerminated()) { scheduler = Executors.newSingleThreadScheduledExecutor(); } serverAddressProcessor = new ServerAddressProcessor(this.diamondConfigure, this.scheduledExecutor); serverAddressProcessor.setClusterType(clusterType); serverAddressProcessor.start(); // domainNamePos randomDomainNamePos(); initHttpClient(); try { initPushitClient(); } catch (Exception e) { log.error("", e); } publishTaskManager = new TaskManager("publish task manager thread"); // isRun = true; // rotateCheckAndPublish(); }