io.vlingo.common.Scheduled Java Examples
The following examples show how to use
io.vlingo.common.Scheduled.
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: GapRetryReader.java From vlingo-symbio with Mozilla Public License 2.0 | 6 votes |
@Override public void intervalSignal(Scheduled<RetryGappedEntries<T>> scheduled, RetryGappedEntries<T> data) { Function<List<Long>, List<T>> gappedReader = data.gappedReader; List<T> fillups = gappedReader.apply(data.gappedEntries.getGapIds()); GappedEntries<T> nextGappedEntries = data.gappedEntries.fillupWith(fillups); if (!nextGappedEntries.containGaps() || !data.moreRetries()) { CompletesEventually eventually = data.gappedEntries.getEventually(); if (nextGappedEntries.size() == 1) { // Only one entry has to be returned. // {@link EntryReader<T>} - read one Entry<T> method. eventually.with(nextGappedEntries.getFirst().orElse(null)); } else { // {@link EntryReader<T>} - read a list of Entry<T> eventually.with(nextGappedEntries.getSortedLoadedEntries()); } } else { RetryGappedEntries<T> nextData = data.nextRetry(nextGappedEntries); scheduler().scheduleOnce(scheduled, nextData, 0L, data.retryInterval); } }
Example #2
Source File: DirectoryEvictor.java From vlingo-actors with Mozilla Public License 2.0 | 6 votes |
@Override public void intervalSignal(Scheduled<Object> scheduled, Object o) { logger().debug("Started eviction routine"); float fillRatio = Runtime.getRuntime().freeMemory() / (float) Runtime.getRuntime().totalMemory(); if (fillRatio >= config.fillRatioHigh()) { logger().debug("Memory fill ratio {} exceeding watermark ({})", fillRatio, config.fillRatioHigh()); Collection<Address> evicted = directory.evictionCandidates(config.lruThresholdMillis()).stream() .flatMap(actor -> { if(actor.lifeCycle.evictable.stop(config.lruThresholdMillis())) { return Stream.of(actor.address()); } else { return Stream.empty(); } }) .collect(Collectors.toCollection(ArrayList::new)); logger().debug("Evicted {} actors :: {}", evicted.size(), evicted); } else { logger().debug("Memory fill ratio {} was below watermark ({})", fillRatio, config.fillRatioHigh()); } }
Example #3
Source File: ExpiringHardRefHolder.java From vlingo-lattice with Mozilla Public License 2.0 | 6 votes |
@Override public void intervalSignal(Scheduled<Object> scheduled, Object data) { logger.debug("Starting expired references cleanup at {} ...", now.get()); int count = 0; Expiring next; do { next = queue.peek(); if (next == null) { // queue is empty break; } if (next.bestBefore.isBefore(now.get())) { // dereference queue.remove(); ++count; } else { // stop next = null; } } while (next != null); logger.debug("Finished cleanup of expired references at {}. {} removed.", now.get(), count); }
Example #4
Source File: SseStreamResource.java From vlingo-http with Mozilla Public License 2.0 | 6 votes |
@SuppressWarnings("unchecked") public SsePublisherActor(final String streamName, final Class<? extends Actor> feedClass, final int feedPayload, final int feedInterval, final String feedDefaultId) { this.streamName = streamName; this.subscribers = new HashMap<>(); final ActorInstantiator<?> instantiator = ActorInstantiatorRegistry.instantiatorFor(feedClass); if(instantiator==null)throw new IllegalArgumentException("No ActorInstantiator registred for feedClass="+feedClass.toString()); instantiator.set("feedClass", feedClass); instantiator.set("streamName", streamName); instantiator.set("feedPayload", feedPayload); instantiator.set("feedDefaultId", feedDefaultId); this.feed = stage().actorFor(SseFeed.class, Definition.has(feedClass, instantiator)); this.cancellable = stage().scheduler().schedule(selfAs(Scheduled.class), null, 10, feedInterval); logger().info("SsePublisher started for: " + this.streamName); }
Example #5
Source File: SchedulerTest.java From vlingo-actors with Mozilla Public License 2.0 | 5 votes |
@Override public void intervalSignal(final Scheduled<Integer> scheduled, final Integer data) { if (count < maximum) { schedule(); } else { completesEventually.with(count); selfAs(Stoppable.class).stop(); } }
Example #6
Source File: SchedulerTest.java From vlingo-actors with Mozilla Public License 2.0 | 5 votes |
@Override @Before public void setUp() { world = World.startWithDefaults("scheduler"); scheduled = new Scheduled<CounterHolder>() { @Override public void intervalSignal(final Scheduled<CounterHolder> scheduled, final CounterHolder data) { data.increment(); } }; scheduler = new Scheduler(); }
Example #7
Source File: FileProcessorTest.java From vlingo-examples with Mozilla Public License 2.0 | 5 votes |
@Override public void intervalSignal(final Scheduled<Object> scheduled, final Object data) { if (++count >= times) { close(); return; } writeBlock(); }
Example #8
Source File: FileProcessorTest.java From vlingo-examples with Mozilla Public License 2.0 | 5 votes |
@Override @SuppressWarnings("unchecked") public void modifyFileWith(final File file, final Duration frequency, final int times) { this.count = 1; this.times = times; this.path = file.getAbsolutePath(); this.writer = open(file); writeBlock(); cancellable = scheduler().schedule(selfAs(Scheduled.class), null, Duration.ZERO, frequency); }
Example #9
Source File: ThrottledProducer.java From vlingo-examples with Mozilla Public License 2.0 | 5 votes |
@Override public void intervalSignal(Scheduled<Object> scheduled, Object data) { messagesSentInPeriod = 0; while (!shouldThrottle() && thereAreMessagesPending()) { final Consumer consumer = pending.get(0); doDispatchTo(consumer); pending.remove(0); } }
Example #10
Source File: ThrottledProducer.java From vlingo-examples with Mozilla Public License 2.0 | 5 votes |
@SuppressWarnings("unchecked") public ThrottledProducer(final int maxMessagesPerPeriod, int period, final Producer delegate) { this.maxMessagesPerPeriod = maxMessagesPerPeriod; this.delegate = delegate; this.pending = new LinkedList<>(); this.messagesSentInPeriod = 0; this.periodRefresher = scheduler().schedule(selfAs(Scheduled.class), null, 0, period); }
Example #11
Source File: CounterQueryActor.java From vlingo-examples with Mozilla Public License 2.0 | 5 votes |
@Override @SuppressWarnings("rawtypes") public void intervalSignal(Scheduled<Object> scheduled, Object data) { streamReader.readNext() .andThen(event -> ((BaseEntry) event).asTextEntry()) .andThenConsume(entry -> { counted = (Event) entryAdapterProvider.asSource(entry); currentCount = Optional.of(counted.currentCounter); }); }
Example #12
Source File: CounterQueryActor.java From vlingo-examples with Mozilla Public License 2.0 | 5 votes |
@SuppressWarnings("unchecked") public CounterQueryActor(JournalReader<TextEntry> streamReader, EntryAdapterProvider entryAdapterProvider) { this.streamReader = streamReader; this.entryAdapterProvider = entryAdapterProvider; this.cancellable = scheduler().schedule(selfAs(Scheduled.class), null, 0, 5); this.currentCount = Optional.empty(); intervalSignal(null, null); }
Example #13
Source File: RequestSenderProbeActor.java From vlingo-http with Mozilla Public License 2.0 | 5 votes |
@SuppressWarnings("unchecked") public RequestSenderProbeActor(final Configuration configuration, final ResponseChannelConsumer consumer, final String testId) throws Exception { this.channel = ClientConsumerCommons.clientChannel(configuration, consumer, logger()); this.cancellable = stage().scheduler().schedule(selfAs(Scheduled.class), null, 1, configuration.probeInterval); this.buffer = ByteBufferAllocator.allocate(configuration.writeBufferSize); //this.testId = testId; }
Example #14
Source File: RoundRobinClientRequestConsumerActor.java From vlingo-http with Mozilla Public License 2.0 | 5 votes |
/** * @see io.vlingo.common.Scheduled#intervalSignal(io.vlingo.common.Scheduled, java.lang.Object) */ @Override public void intervalSignal(final Scheduled<Object> scheduled, final Object data) { // no-op final String message = ErrorMessage + "intervalSignal()"; logger().error(message, new UnsupportedOperationException(message)); }
Example #15
Source File: ServerActor.java From vlingo-http with Mozilla Public License 2.0 | 5 votes |
@Override @SuppressWarnings("unchecked") public Completes<Boolean> startUp() { if (requestMissingContentTimeout > 0) { stage().scheduler().schedule(selfAs(Scheduled.class), null, 1000L, requestMissingContentTimeout); } return completes().with(true); }
Example #16
Source File: ClientCorrelatingRequesterConsumerActor.java From vlingo-http with Mozilla Public License 2.0 | 5 votes |
@SuppressWarnings("unchecked") public ClientCorrelatingRequesterConsumerActor(final Configuration configuration) throws Exception { this.state = new State( configuration, ClientConsumerCommons.clientChannel(configuration, selfAs(ResponseChannelConsumer.class), logger()), null, stage().scheduler().schedule(selfAs(Scheduled.class), null, 1, configuration.probeInterval), ByteBufferAllocator.allocate(configuration.writeBufferSize)); this.completables = new HashMap<>(); }
Example #17
Source File: EntryReaderSource.java From vlingo-symbio with Mozilla Public License 2.0 | 5 votes |
/** * Constructs my default state. * @param entryReader the {@code EntryReader<T>} from which to read entry elements * @param entryAdapterProvider the EntryAdapterProvider used to turn Entry instances into {@code Source<?>} instances * @param flowElementsRate the long maximum elements to read at once */ @SuppressWarnings("unchecked") public EntryReaderSource( final EntryReader<T> entryReader, final EntryAdapterProvider entryAdapterProvider, final long flowElementsRate) { this.entryReader = entryReader; this.entryAdapterProvider = entryAdapterProvider; this.flowElementsRate = flowElementsRate; this.cache = new ArrayDeque<>(); this.cancellable = scheduler().schedule(selfAs(Scheduled.class), null, 0, Stream.FastProbeInterval); }
Example #18
Source File: EntryReaderSource.java From vlingo-symbio with Mozilla Public License 2.0 | 5 votes |
@Override public void intervalSignal(final Scheduled<Object> scheduled, final Object data) { if (cache.isEmpty() && !reading) { reading = true; final int max = flowElementsRate > Integer.MAX_VALUE ? Integer.MAX_VALUE : (int) flowElementsRate; entryReader.readNext(max).andThenConsume(entries -> { cache.addAll(entries); reading = false; }); } }
Example #19
Source File: LoadBalancingClientRequestConsumerActor.java From vlingo-http with Mozilla Public License 2.0 | 5 votes |
/** * @see io.vlingo.common.Scheduled#intervalSignal(io.vlingo.common.Scheduled, java.lang.Object) */ @Override public void intervalSignal(final Scheduled<Object> scheduled, final Object data) { // no-op final String message = ErrorMessage + "intervalSignal()"; logger().error(message, new UnsupportedOperationException(message)); }
Example #20
Source File: ExpiringHardRefHolder.java From vlingo-lattice with Mozilla Public License 2.0 | 5 votes |
@SuppressWarnings("unchecked") ExpiringHardRefHolder(final Supplier<Instant> now, final Duration timeout, final int initialCapacity) { this.now = now; this.timeout = timeout; this.queue = new PriorityQueue<>(initialCapacity); scheduler().schedule(selfAs(Scheduled.class), null, 0, 1000); }
Example #21
Source File: SpaceActor.java From vlingo-lattice with Mozilla Public License 2.0 | 5 votes |
@SuppressWarnings("unchecked") public SpaceActor(final Duration defaultScanInterval) { this.defaultScanInterval = defaultScanInterval; this.expirableItems = new TreeSet<>(); this.expirableQueries = new TreeSet<>(); this.registry = new HashMap<>(); this.scheduled = selfAs(Scheduled.class); this.scheduledQueryRunnerEvictor = new ScheduledQueryRunnerEvictor(); this.scheduledSweeper = new ScheduledSweeper(); }
Example #22
Source File: SpaceActor.java From vlingo-lattice with Mozilla Public License 2.0 | 4 votes |
@Override public void intervalSignal(final Scheduled<ScheduledScanner<?>> scheduled, final ScheduledScanner<?> scanner) { scanner.scan(); }
Example #23
Source File: GapRetryReader.java From vlingo-symbio with Mozilla Public License 2.0 | 4 votes |
@SuppressWarnings("unchecked") public GapRetryReader(Stage stage, Scheduler scheduler) { this.actor = stage.actorFor(Scheduled.class, GapsFillUpActor.class); this.scheduler = scheduler; }
Example #24
Source File: SchedulerTest.java From vlingo-actors with Mozilla Public License 2.0 | 4 votes |
@SuppressWarnings("unchecked") public OnceScheduled(final int maximum) { this.maximum = maximum; this.count = 0; this.scheduled = selfAs(Scheduled.class); }
Example #25
Source File: DispatcherControlActor.java From vlingo-symbio with Mozilla Public License 2.0 | 4 votes |
@Override public void intervalSignal(final Scheduled<Object> scheduled, final Object data) { dispatchUnconfirmed(); }
Example #26
Source File: FileStabilityBySizeCheckerActor.java From vlingo-examples with Mozilla Public License 2.0 | 4 votes |
/** * @see io.vlingo.common.Scheduled#intervalSignal(io.vlingo.common.Scheduled, java.lang.Object) */ @Override public void intervalSignal(final Scheduled<FileSizeStability> scheduled, final FileSizeStability stability) { cancellable.cancel(); determineFor(stability); }
Example #27
Source File: FileStabilityBySizeCheckerActor.java From vlingo-examples with Mozilla Public License 2.0 | 4 votes |
@SuppressWarnings("unchecked") public FileStabilityBySizeCheckerActor(final Duration interval, final int retries) { this.interval = interval; this.retries = retries; this.scheduled = selfAs(Scheduled.class); }
Example #28
Source File: ClientCorrelatingRequesterConsumerActor.java From vlingo-http with Mozilla Public License 2.0 | 4 votes |
/** * @see io.vlingo.common.Scheduled#intervalSignal(io.vlingo.common.Scheduled, java.lang.Object) */ @Override public void intervalSignal(final Scheduled<Object> scheduled, final Object data) { state.channel.probeChannel(); }
Example #29
Source File: RequestSenderProbeActor.java From vlingo-http with Mozilla Public License 2.0 | 4 votes |
@Override public void intervalSignal(final Scheduled<Object> scheduled, final Object data) { channel.probeChannel(); }
Example #30
Source File: SseStreamResource.java From vlingo-http with Mozilla Public License 2.0 | 4 votes |
@Override public void intervalSignal(final Scheduled<Object> scheduled, final Object data) { feed.to(subscribers.values()); }