Java Code Examples for reactor.core.scheduler.Schedulers#fromExecutor()

The following examples show how to use reactor.core.scheduler.Schedulers#fromExecutor() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultEvictionOperations.java    From titus-control-plane with Apache License 2.0 6 votes vote down vote up
@Inject
public DefaultEvictionOperations(EvictionServiceConfiguration configuration,
                                 V3JobOperations jobOperations,
                                 TitusQuotasManager quotaManager,
                                 TitusRuntime titusRuntime) {
    this.configuration = configuration;
    this.jobOperations = jobOperations;
    this.quotaManager = quotaManager;
    this.titusRuntime = titusRuntime;

    Executor executor = Executors.newSingleThreadScheduledExecutor(r -> {
        Thread thread = new Thread(r, DefaultEvictionOperations.class.getSimpleName());
        thread.setDaemon(true);
        return thread;
    });
    this.scheduler = Schedulers.fromExecutor(executor);
}
 
Example 2
Source File: TemperatureSensor.java    From Hands-On-Reactive-Programming-in-Spring-5 with MIT License 6 votes vote down vote up
@PostConstruct
public void init() {
   ScheduledExecutorService executor =
      new MeteredScheduledThreadPoolExecutor("temp.sensor", 3, meterRegistry);

   Scheduler eventsScheduler = Schedulers.fromExecutor(executor);
   dataStream = Flux
      .range(0, 10)
      .repeat()
      .concatMap(ignore -> this.probe()
         .delayElement(randomDelay(1000), eventsScheduler)
         .name("temperature.probe")
         .metrics()
         .log("temperature.measurement", Level.FINE))
      .publish()
      .refCount();
   log.info("Temperature Sensor is ready");
}
 
Example 3
Source File: SerialTaskManagerWorker.java    From james-project with Apache License 2.0 5 votes vote down vote up
public SerialTaskManagerWorker(Listener listener, Duration pollingInterval) {
    this.pollingInterval = pollingInterval;
    this.taskExecutor = Schedulers.fromExecutor(
        Executors.newSingleThreadExecutor(NamedThreadFactory.withName("task executor")));
    this.listener = listener;
    this.cancelledTasks = Sets.newConcurrentHashSet();
    this.runningTask = new AtomicReference<>();
}
 
Example 4
Source File: HttpServerConfig.java    From soul with Apache License 2.0 5 votes vote down vote up
@Bean
public Scheduler scheduler() {
    ExecutorService threadPool = new ThreadPoolExecutor(100, 100,
            0L, TimeUnit.MILLISECONDS,
            new LinkedBlockingQueue<>(), runnable -> {
                Thread thread = new Thread(runnable, "http-exe");
                thread.setDaemon(false);
                if (thread.getPriority() != Thread.NORM_PRIORITY) {
                    thread.setPriority(Thread.NORM_PRIORITY);
                }
                return thread;
            });
    return Schedulers.fromExecutor(threadPool);
}
 
Example 5
Source File: ReviewServiceApplication.java    From Hands-On-Microservices-with-Spring-Boot-and-Spring-Cloud with MIT License 4 votes vote down vote up
@Bean
public Scheduler jdbcScheduler() {
    LOG.info("Creates a jdbcScheduler with connectionPoolSize = " + connectionPoolSize);
    return Schedulers.fromExecutor(Executors.newFixedThreadPool(connectionPoolSize));
}
 
Example 6
Source File: App.java    From FrameworkBenchmarks with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Bean
public Scheduler ioScheduler() {
    return Schedulers.fromExecutor(Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() * 2));
}
 
Example 7
Source File: DbConfig.java    From Spring-Boot-2.0-Projects with MIT License 4 votes vote down vote up
@Bean
public Scheduler dbScheduler() {
    return Schedulers.fromExecutor(Executors.newFixedThreadPool(connectionPoolSize));
}
 
Example 8
Source File: ReviewServiceApplication.java    From Hands-On-Microservices-with-Spring-Boot-and-Spring-Cloud with MIT License 4 votes vote down vote up
@Bean
public Scheduler jdbcScheduler() {
    LOG.info("Creates a jdbcScheduler with connectionPoolSize = " + connectionPoolSize);
    return Schedulers.fromExecutor(Executors.newFixedThreadPool(connectionPoolSize));
}
 
Example 9
Source File: ReviewServiceApplication.java    From Hands-On-Microservices-with-Spring-Boot-and-Spring-Cloud with MIT License 4 votes vote down vote up
@Bean
public Scheduler jdbcScheduler() {
    LOG.info("Creates a jdbcScheduler with connectionPoolSize = " + connectionPoolSize);
    return Schedulers.fromExecutor(Executors.newFixedThreadPool(connectionPoolSize));
}
 
Example 10
Source File: ReviewServiceApplication.java    From Hands-On-Microservices-with-Spring-Boot-and-Spring-Cloud with MIT License 4 votes vote down vote up
@Bean
public Scheduler jdbcScheduler() {
    LOG.info("Creates a jdbcScheduler with connectionPoolSize = " + connectionPoolSize);
    return Schedulers.fromExecutor(Executors.newFixedThreadPool(connectionPoolSize));
}
 
Example 11
Source File: ReviewServiceApplication.java    From Hands-On-Microservices-with-Spring-Boot-and-Spring-Cloud with MIT License 4 votes vote down vote up
@Bean
public Scheduler jdbcScheduler() {
    LOG.info("Creates a jdbcScheduler with connectionPoolSize = " + connectionPoolSize);
    return Schedulers.fromExecutor(Executors.newFixedThreadPool(connectionPoolSize));
}
 
Example 12
Source File: ReviewServiceApplication.java    From Hands-On-Microservices-with-Spring-Boot-and-Spring-Cloud with MIT License 4 votes vote down vote up
@Bean
public Scheduler jdbcScheduler() {
    LOG.info("Creates a jdbcScheduler with connectionPoolSize = " + connectionPoolSize);
    return Schedulers.fromExecutor(Executors.newFixedThreadPool(connectionPoolSize));
}
 
Example 13
Source File: ReviewServiceApplication.java    From Hands-On-Microservices-with-Spring-Boot-and-Spring-Cloud with MIT License 4 votes vote down vote up
@Bean
public Scheduler jdbcScheduler() {
    LOG.info("Creates a jdbcScheduler with connectionPoolSize = " + connectionPoolSize);
    return Schedulers.fromExecutor(Executors.newFixedThreadPool(connectionPoolSize));
}
 
Example 14
Source File: ReviewServiceApplication.java    From Hands-On-Microservices-with-Spring-Boot-and-Spring-Cloud with MIT License 4 votes vote down vote up
@Bean
public Scheduler jdbcScheduler() {
    LOG.info("Creates a jdbcScheduler with connectionPoolSize = " + connectionPoolSize);
    return Schedulers.fromExecutor(Executors.newFixedThreadPool(connectionPoolSize));
}
 
Example 15
Source File: ReviewServiceApplication.java    From Hands-On-Microservices-with-Spring-Boot-and-Spring-Cloud with MIT License 4 votes vote down vote up
@Bean
public Scheduler jdbcScheduler() {
    LOG.info("Creates a jdbcScheduler with connectionPoolSize = " + connectionPoolSize);
    return Schedulers.fromExecutor(Executors.newFixedThreadPool(connectionPoolSize));
}
 
Example 16
Source File: ReviewServiceApplication.java    From Hands-On-Microservices-with-Spring-Boot-and-Spring-Cloud with MIT License 4 votes vote down vote up
@Bean
public Scheduler jdbcScheduler() {
    LOG.info("Creates a jdbcScheduler with connectionPoolSize = " + connectionPoolSize);
    return Schedulers.fromExecutor(Executors.newFixedThreadPool(connectionPoolSize));
}
 
Example 17
Source File: ReviewServiceApplication.java    From Hands-On-Microservices-with-Spring-Boot-and-Spring-Cloud with MIT License 4 votes vote down vote up
@Bean
public Scheduler jdbcScheduler() {
    LOG.info("Creates a jdbcScheduler with connectionPoolSize = " + connectionPoolSize);
    return Schedulers.fromExecutor(Executors.newFixedThreadPool(connectionPoolSize));
}
 
Example 18
Source File: ReviewServiceApplication.java    From Hands-On-Microservices-with-Spring-Boot-and-Spring-Cloud with MIT License 4 votes vote down vote up
@Bean
public Scheduler jdbcScheduler() {
    LOG.info("Creates a jdbcScheduler with connectionPoolSize = " + connectionPoolSize);
    return Schedulers.fromExecutor(Executors.newFixedThreadPool(connectionPoolSize));
}
 
Example 19
Source File: ReviewServiceApplication.java    From Hands-On-Microservices-with-Spring-Boot-and-Spring-Cloud with MIT License 4 votes vote down vote up
@Bean
public Scheduler jdbcScheduler() {
    LOG.info("Creates a jdbcScheduler with connectionPoolSize = " + connectionPoolSize);
    return Schedulers.fromExecutor(Executors.newFixedThreadPool(connectionPoolSize));
}