List of usage examples for java.util.concurrent Executors newScheduledThreadPool
public static ScheduledExecutorService newScheduledThreadPool(int corePoolSize)
From source file:rmblworx.tools.timey.SimpleCountdown.java
@Override public TimeDescriptor startCountdown(final int delayPerThread, final TimeUnit timeUnit) { if (delayPerThread < 1) { throw new ValueMinimumArgumentException(); } else if (timeUnit == null) { throw new NullArgumentException(); }// w w w . jav a2 s .c o m this.scheduler = Executors.newScheduledThreadPool(THREAD_POOL_SIZE); final CountdownRunnable countdown = (CountdownRunnable) this.springContext.getBean("countdownRunnable", this.timeDescriptor, Long.valueOf(this.timePassed)); this.countdownFuture = this.scheduler.scheduleAtFixedRate(countdown, 0, delayPerThread, timeUnit); return this.timeDescriptor; }
From source file:com.conwet.silbops.connectors.comet.CometAPIHandler.java
public CometAPIHandler(Broker broker, int keelAlivePeriod) { this.broker = broker; this.keepAlivePeriod = keelAlivePeriod * 1000; // from sec to millis nextStreamID = new AtomicLong(); connStatus = new ConnectionStatus(); dispatcher = new HashMap<>(); connectionMonitor = Executors.newScheduledThreadPool(1); this.initialize(); this.createMonitorService(); }
From source file:org.eclipse.flux.core.KeepAliveConnector.java
public KeepAliveConnector(ChannelSwitcher switcher, MessageConnector mc, String serviceTypeId, long keepAliveDelay, long keepAliveResponseTimeout) { this.channelSwitcher = switcher; this.messageConnector = mc; this.serviceTypeId = serviceTypeId; this.executor = Executors.newScheduledThreadPool(2); this.keepAliveDelay = keepAliveDelay; this.keepAliveResponseTimeout = keepAliveResponseTimeout; this.messageConnector.addMessageHandler(keepAliveResponseHandler); setKeepAliveDelayedMessage();/*w ww . j av a 2 s. c o m*/ mc.addChannelListener(channelListener); }
From source file:org.apache.brooklyn.util.HttpAssertsTest.java
private void initVars() { baseUrl = server.getUrl();//ww w. j av a 2s . c o m httpClient = HttpTool.httpClientBuilder().uri(baseUrl).build(); baseUri = URI.create(baseUrl); simpleEndpoint = testUri("/simple"); executor = Executors.newScheduledThreadPool(3); }
From source file:com.netflix.paas.PaasModule.java
@Override protected void configure() { LOG.info("Loading PaasModule"); bind(EventBus.class).toInstance(eventBus); bindListener(Matchers.any(), new TypeListener() { public <I> void hear(TypeLiteral<I> typeLiteral, TypeEncounter<I> typeEncounter) { typeEncounter.register(new InjectionListener<I>() { public void afterInjection(I i) { eventBus.register(i); }/* w w w . j a v a 2 s . co m*/ }); } }); bind(TaskManager.class).to(InlineTaskManager.class); // Constants bind(String.class).annotatedWith(Names.named("namespace")).toInstance("com.netflix.pass."); bind(String.class).annotatedWith(Names.named("appname")).toInstance("paas"); bind(AbstractConfiguration.class).toInstance(ConfigurationManager.getConfigInstance()); // Configuration bind(PaasConfiguration.class).to(ArchaeusPaasConfiguration.class).in(Scopes.SINGLETON); // Stuff bind(ScheduledExecutorService.class).annotatedWith(Names.named("tasks")) .toInstance(Executors.newScheduledThreadPool(10)); bind(DaoProvider.class).in(Scopes.SINGLETON); // Rest resources bind(DataResource.class).in(Scopes.SINGLETON); bind(SchemaAdminResource.class).to(JerseySchemaAdminResourceImpl.class).in(Scopes.SINGLETON); bind(SchemaService.class).to(DaoSchemaService.class).in(Scopes.SINGLETON); }
From source file:oz.hadoop.yarn.api.core.AbstractApplicationMasterLauncher.java
/** * //from ww w .j ava2 s .c o m * @param applicationSpecification */ @SuppressWarnings("unchecked") AbstractApplicationMasterLauncher(Map<String, Object> applicationSpecification) { Assert.notNull(applicationSpecification, "'applicationSpecification' must not be null"); this.applicationSpecification = applicationSpecification; this.applicationName = (String) this.applicationSpecification.get(YayaConstants.APPLICATION_NAME); this.applicationContainerSpecification = new PrimitiveImmutableTypeMap( (Map<String, Object>) this.applicationSpecification.get(YayaConstants.CONTAINER_SPEC)); // we only need YarnConfig locally to launch Application Master. No need to pass it along as application arguments. this.yarnConfig = (YarnConfiguration) this.applicationSpecification.remove(YayaConstants.YARN_CONFIG); this.executor = Executors.newScheduledThreadPool(2); this.finite = (StringUtils.hasText(this.applicationContainerSpecification.getString(YayaConstants.COMMAND)) || this.applicationContainerSpecification.getString(YayaConstants.CONTAINER_ARG) != null) ? true : false; String cjt = (String) this.applicationSpecification.get(YayaConstants.CLIENTS_JOIN_TIMEOUT); this.awaitAllContainersTimeout = StringUtils.hasText(cjt) ? Integer.parseInt(cjt) : 30; }
From source file:org.wso2.carbon.coordination.core.services.impl.ZKCoordinationService.java
public ZKCoordinationService(CoordinationConfiguration conf) throws CoordinationException { this.closed = false; this.enabled = conf.isEnabled(); if (this.isEnabled()) { try {/* www . ja va 2s. co m*/ this.zooKeeper = new ZooKeeper(conf.getConnectionString(), conf.getSessionTimeout(), this); if (znodeOnCloseDeletionList == null) { znodeOnCloseDeletionList = new Vector<String>(); } if (scheduler == null || scheduler.isShutdown()) { znodeTimerDeletionList = new Vector<ZKCoordinationService.ZNodeDeletionEntry>(); scheduler = Executors.newScheduledThreadPool(MAX_SCHEDULER_THREADS); scheduler.scheduleWithFixedDelay(new ZNodeDeletionTask(), ZNODE_CLEANUP_TASK_INTERVAL, ZNODE_CLEANUP_TASK_INTERVAL, TimeUnit.MILLISECONDS); } log.info("Coordination service connection established with ZooKeeper."); } catch (IOException e) { new CoordinationException(ExceptionCode.IO_ERROR, e); } } else { log.info("Coordination service disabled."); } }
From source file:rmblworx.tools.timey.SimpleTimer.java
@Override public TimeDescriptor startStopwatch(final int delayPerThread, final TimeUnit timeUnit) { if (delayPerThread < 1) { throw new ValueMinimumArgumentException(); } else if (timeUnit == null) { throw new NullArgumentException(); }//from w w w. j a v a2s .c o m this.timer = (TimerRunnable) this.springContext.getBean("timerRunnable", this.timeDescriptor, this.timePassed); this.scheduler = Executors.newScheduledThreadPool(THREAD_POOL_SIZE); this.timerFuture = this.scheduler.scheduleAtFixedRate(this.timer, 0, delayPerThread, timeUnit); this.wasStoppedBefore = false; return this.timeDescriptor; }
From source file:uk.ac.ucl.excites.sapelli.relay.BackgroundService.java
@Override public void onCreate() { // The service is being created this.mContext = this; // Initialise the database dao = new SmsDatabaseSQLite(mContext); // Add an SMS receiver registerSmsReceiver();//w w w . ja v a 2s.c om // Creates a thread pool that can schedule commands to run after a given // delay, or to execute periodically. scheduleTaskExecutor = Executors.newScheduledThreadPool(1); isSending = false; // TODO test // dao.populateDb(10); // dao.retrieveSmsObjects(); // Wait for the Debugger to be attached // android.os.Debug.waitForDebugger(); }
From source file:com.thinkbiganalytics.server.KyloServerApplication.java
@Bean(destroyMethod = "shutdown") public Executor scheduledTaskExecutor() { return Executors.newScheduledThreadPool(25); }