Tabnine Logo
ExecutorsFactory
Code IndexAdd Tabnine to your IDE (free)

How to use
ExecutorsFactory
in
org.atmosphere.util

Best Java code snippets using org.atmosphere.util.ExecutorsFactory (Showing top 20 results out of 315)

origin: Atmosphere/atmosphere

public ThirtySecondsCache(MetaBroadcaster metaBroadcaster, AtmosphereConfig config) {
  this.metaBroadcaster = metaBroadcaster;
  ExecutorsFactory.getScheduler(config).scheduleAtFixedRate(this, 0, 30, TimeUnit.SECONDS);
}
origin: Atmosphere/atmosphere

protected synchronized void configExecutors() {
  if (shared) {
    handleExecutors = false;
    isExecutorShared = true;
    isAsyncExecutorShared = true;
  }
  executorService = ExecutorsFactory.getMessageDispatcher(config, broadcasterId);
  asyncWriteService = ExecutorsFactory.getAsyncOperationExecutor(config, broadcasterId);
  scheduler = ExecutorsFactory.getScheduler(config);
}
origin: Atmosphere/atmosphere

  asyncExecutor = ExecutorsFactory.getAsyncOperationExecutor(config, "WebSocket");
} else {
  asyncExecutor = VoidExecutorService.VOID;
scheduler = ExecutorsFactory.getScheduler(config);
optimizeMapping();
origin: Atmosphere/atmosphere

logger.info("Shared ExecutorService supported: {}", sharedThreadPools);
ExecutorService executorService = ExecutorsFactory.getMessageDispatcher(config, Broadcaster.ROOT_MASTER);
if (executorService != null) {
  if (ThreadPoolExecutor.class.isAssignableFrom(executorService.getClass())) {
executorService = ExecutorsFactory.getAsyncOperationExecutor(config, Broadcaster.ROOT_MASTER);
if (executorService != null) {
  if (ThreadPoolExecutor.class.isAssignableFrom(executorService.getClass())) {
origin: Atmosphere/atmosphere-extensions

void startConsumer() {
  consumer.subscribe(Arrays.asList(topic));
  ExecutorsFactory.getMessageDispatcher(config, "kafka").execute(new Runnable() {
    @Override
    public void run() {
      while (!closed.get()) {
        ConsumerRecords<String, String> records = consumer.poll(1000);
        for (ConsumerRecord<String, String> record : records) {
          broadcastReceivedMessage(record.value());
        }
      }
      consumer.close();
      ((Set<String>)config.properties().get("topics")).remove(topic);
    }
  });
}
origin: Atmosphere/atmosphere

/**
 * Create a {@link ScheduledExecutorService} used ot schedule I/O and non I/O events.
 *
 * @param config the {@link AtmosphereConfig}
 * @return {@link ScheduledExecutorService}
 */
public static ScheduledExecutorService getScheduler(final AtmosphereConfig config) {
  final boolean shared = config.framework().isShareExecutorServices();
  if (!shared || config.properties().get(SCHEDULER_THREAD_POOL) == null) {
    int threads = config.getInitParameter(ApplicationConfig.SCHEDULER_THREADPOOL_MAXSIZE, Runtime.getRuntime().availableProcessors());
    logger.trace("Max number of Atmosphere-Scheduler {}", threads);
    ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(threads, new ThreadFactory() {
      private final AtomicInteger count = new AtomicInteger();
      @Override
      public Thread newThread(final Runnable runnable) {
        Thread t = new Thread(runnable, "Atmosphere-Scheduler-" + count.getAndIncrement());
        t.setDaemon(true);
        return t;
      }
    });
    if (shared) {
      config.properties().put(SCHEDULER_THREAD_POOL, scheduler);
    }
    keepAliveThreads((ThreadPoolExecutor) scheduler, config);
    return scheduler;
  } else {
    return (ScheduledExecutorService) config.properties().get(SCHEDULER_THREAD_POOL);
  }
}
origin: Atmosphere/atmosphere

ExecutorsFactory.reset(config);
origin: Atmosphere/atmosphere

keepAliveThreads(messageService, config);
origin: Atmosphere/atmosphere

private void start() {
  if (future != null) {
    future.cancel(false);
  }
  if (maxInactiveTime > 0) {
    logger.info("{} started with idle timeout set to {}", IdleResourceInterceptor.class.getSimpleName(), maxInactiveTime);
    future = ExecutorsFactory.getScheduler(config).scheduleAtFixedRate(new Runnable() {
      public void run() {
        idleResources();
      }
    }, 0, 2, TimeUnit.SECONDS);
  }
}
origin: Atmosphere/atmosphere

keepAliveThreads(asyncWriteService, config);
origin: Atmosphere/atmosphere

@Override
public void configure(AtmosphereConfig config) {
  Object o = config.properties().get("shared");
  if (o != null) {
    isShared = Boolean.parseBoolean(o.toString());
  }
  if (isShared) {
    reaper = ExecutorsFactory.getScheduler(config);
  } else {
    reaper = Executors.newSingleThreadScheduledExecutor();
  }
  this.config = config;
}
origin: Atmosphere/atmosphere

@Override
public void configure(AtmosphereConfig config) {
  Object o = config.properties().get("shared");
  if (o != null) {
    shared = Boolean.parseBoolean(o.toString());
  }
  if (shared) {
    taskScheduler = ExecutorsFactory.getScheduler(config);
  } else {
    taskScheduler = Executors.newSingleThreadScheduledExecutor();
  }
  clientIdleTime = TimeUnit.SECONDS.toMillis(
      Long.valueOf(config.getInitParameter(UUIDBROADCASTERCACHE_CLIENT_IDLETIME, "60")));
  invalidateCacheInterval = TimeUnit.SECONDS.toMillis(
      Long.valueOf(config.getInitParameter(UUIDBROADCASTERCACHE_IDLE_CACHE_INTERVAL, "30")));
  uuidProvider = config.uuidProvider();
}
origin: Atmosphere/atmosphere

@Override
public void configure(AtmosphereConfig config) {
  factory = config.getBroadcasterFactory();
  factory.addBroadcasterListener(new B());
  stateTracker = ExecutorsFactory.getScheduler(config);
  String s = config.getInitParameter(STATE_RECOVERY_TIMEOUT);
  if (s != null) {
    timeout = Long.parseLong(s);
  }
  startStateTracker();
  logger.trace("{} started.", AtmosphereResourceStateRecovery.class.getName());
}
origin: Atmosphere/atmosphere

@Override
public void setBroadcasterConfig(BroadcasterConfig bc) {
  this.bc = bc;
  bc.setExecutorService(null, false).setAsyncWriteService(null, false)
      .setScheduledExecutorService(ExecutorsFactory.getScheduler(config));
}
origin: Atmosphere/atmosphere

heartBeat = ExecutorsFactory.getScheduler(config);
origin: Atmosphere/atmosphere

@Override
protected BroadcasterConfig createBroadcasterConfig(AtmosphereConfig config) {
  BroadcasterConfig bc = (BroadcasterConfig) config.properties().get(BroadcasterConfig.class.getName());
  if (bc == null) {
    bc = new BroadcasterConfig(config.framework().broadcasterFilters(), config, false, getID())
        .init()
        .setScheduledExecutorService(ExecutorsFactory.getScheduler(config));
  }
  return bc;
}
origin: Atmosphere/atmosphere

/**
 * All proprietary Comet based {@link Servlet} must invoke the cancelled method when the underlying WebServer
 * detect that the client closed the connection.
 *
 * @param req the {@link AtmosphereRequest}
 * @param res the {@link AtmosphereResponse}
 * @return action the Action operation.
 * @throws java.io.IOException
 * @throws javax.servlet.ServletException
 */
public Action cancelled(final AtmosphereRequest req, final AtmosphereResponse res)
    throws IOException, ServletException {
  logger.trace("Cancelling {}", req);
  final AtmosphereResourceImpl r = AtmosphereResourceImpl.class.cast(req.resource());
  // Leave a chance to the client to send the disconnect message before processing the connection
  if (closingTime > 0) {
    ExecutorsFactory.getScheduler(config).schedule(new Callable<Object>() {
      @Override
      public Object call() throws Exception {
        endRequest(r, true);
        return null;
      }
    }, closingTime, TimeUnit.MILLISECONDS);
  } else {
    if (completeLifecycle(req.resource(), true)) {
      config.framework().notify(Action.TYPE.CANCELLED, req, res);
    }
  }
  return cancelledAction;
}
origin: Atmosphere/atmosphere

completeLifecycle = false;
logger.debug("Delaying closing operation for firefox and resource {}", resource.uuid());
ExecutorsFactory.getScheduler(framework.getAtmosphereConfig()).schedule(new Callable<Object>() {
  @Override
  public Object call() throws Exception {
origin: Atmosphere/atmosphere-vertx

AtmosphereCoordinator() {
  framework = new AtmosphereFramework();
  asynchronousProcessor = new NettyCometSupport(framework().getAtmosphereConfig());
  framework.setAsyncSupport(asynchronousProcessor);
  suspendTimer = ExecutorsFactory.getScheduler(framework.getAtmosphereConfig());
  mapper = framework.endPointMapper();
}
origin: Atmosphere/atmosphere-play

private AtmosphereCoordinator() {
  framework = new AtmosphereFramework();
  asynchronousProcessor = new NettyCometSupport(framework().getAtmosphereConfig());
  framework.setAsyncSupport(asynchronousProcessor);
  suspendTimer = ExecutorsFactory.getScheduler(framework.getAtmosphereConfig());
  mapper = framework.endPointMapper();
}
org.atmosphere.utilExecutorsFactory

Javadoc

Stateless Factory to create ExecutorService used in all Atmosphere Component. By default they are shared amongst all component. To change the behavior, add ApplicationConfig#BROADCASTER_SHARABLE_THREAD_POOLS

Most used methods

  • getScheduler
    Create a ScheduledExecutorService used ot schedule I/O and non I/O events.
  • getMessageDispatcher
    Create an ExecutorService to be used for dispatching messages, not I/O events.
  • getAsyncOperationExecutor
    Create an ExecutorService to be used for dispatching I/O events.
  • keepAliveThreads
  • reset

Popular in Java

  • Creating JSON documents from java classes using gson
  • getSupportFragmentManager (FragmentActivity)
  • getApplicationContext (Context)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • Graphics2D (java.awt)
    This Graphics2D class extends the Graphics class to provide more sophisticated control overgraphics
  • URLEncoder (java.net)
    This class is used to encode a string using the format required by application/x-www-form-urlencoded
  • Iterator (java.util)
    An iterator over a sequence of objects, such as a collection.If a collection has been changed since
  • ReentrantLock (java.util.concurrent.locks)
    A reentrant mutual exclusion Lock with the same basic behavior and semantics as the implicit monitor
  • Join (org.hibernate.mapping)
  • Runner (org.openjdk.jmh.runner)
  • Top 15 Vim Plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now