コード例 #1
0
 public ICancellable Schedule(IScheduled scheduled, object data, long delayBefore, long interval)
 => CreateAndStore(
     scheduled,
     data,
     TimeSpan.FromMilliseconds(delayBefore),
     TimeSpan.FromMilliseconds(interval),
     true);
コード例 #2
0
 public ICancellable ScheduleOnce(IScheduled scheduled, object data, long delayBefore, long interval)
 => CreateAndStore(
     scheduled,
     data,
     TimeSpan.FromMilliseconds(delayBefore + interval),
     TimeSpan.FromMilliseconds(Timeout.Infinite),
     false);
コード例 #3
0
 /// <summary>
 /// Answer a <code>ICancellable</code> for single scheduled notifier.
 /// </summary>
 /// <typeparam name="T">The type of data to be sent with each notification.</typeparam>
 /// <param name="scheduled">The <code>IScheduled&lt;T&gt;</code> to receive notification.</param>
 /// <param name="data">The data to be sent with the notification.</param>
 /// <param name="delayBefore">The duration before notification interval timing will begin.</param>
 /// <param name="interval">The duration before the single notification.</param>
 /// <returns><code>ICancellable</code></returns>
 public virtual ICancellable ScheduleOnce <T>(IScheduled <T> scheduled, T data, TimeSpan delayBefore, TimeSpan interval)
 => CreateAndStore(
     scheduled,
     data,
     delayBefore + interval,
     TimeSpan.FromMilliseconds(Timeout.Infinite),
     false);
コード例 #4
0
 /// <summary>
 /// Answer a <code>ICancellable</code> for the repeating scheduled notifier.
 /// </summary>
 /// <typeparam name="T">The type of data to be sent with each notification.</typeparam>
 /// <param name="scheduled">The <code>IScheduled&lt;T&gt;</code> to receive notification.</param>
 /// <param name="data">The data to be sent with each notification.</param>
 /// <param name="delayBefore">The duration before notification interval timing will begin.</param>
 /// <param name="interval">The duration between each notification.</param>
 /// <returns><code>ICancellable</code></returns>
 public virtual ICancellable Schedule <T>(IScheduled <T> scheduled, T data, TimeSpan delayBefore, TimeSpan interval)
 => CreateAndStore(
     scheduled,
     data,
     delayBefore,
     interval,
     true);
コード例 #5
0
        public void IntervalSignal(IScheduled <RetryGappedEntries <T> > scheduled, RetryGappedEntries <T> data)
        {
            var gappedReader      = data.GappedReader;
            var fillups           = gappedReader(data.GappedEntries.GapIds);
            var nextGappedEntries = data.GappedEntries.FillupWith(fillups);

            if (!nextGappedEntries.ContainsGaps || !data.MoreRetries)
            {
                var eventually = data.GappedEntries.CompletesEventually;
                if (nextGappedEntries.Count == 1)
                {
                    // Only one entry has to be returned.
                    eventually.With(nextGappedEntries.GetFirst().OrElse(null !));
                }
                else
                {
                    eventually.With(nextGappedEntries.SortedLoadedEntries);
                }
            }
            else
            {
                var nextData = data.NextRetry(nextGappedEntries);
                Scheduler.ScheduleOnce(scheduled, nextData, TimeSpan.Zero, data.RetryInterval);
            }
        }
コード例 #6
0
 public SchedulerTask(IScheduled scheduled, object data, TimeSpan delayBefore, TimeSpan interval, bool repeats)
 {
     this.scheduled = scheduled;
     this.repeats   = repeats;
     hasRun         = false;
     timer          = new Timer(new TimerCallback(Tick), data, delayBefore, interval);
 }
コード例 #7
0
 public SchedulerTask(IScheduled <T> scheduled, T data, TimeSpan delayBefore, TimeSpan interval, bool repeats)
 {
     _scheduled = scheduled;
     _data      = data;
     _repeats   = repeats;
     _hasRun    = false;
     _timer     = new Timer(Tick, null, delayBefore, interval);
 }
コード例 #8
0
 public void IntervalSignal(IScheduled <object> scheduled, object data)
 {
     if (!executed.Get())
     {
         timedOut.Set(true);
         HasFailedValue.Set(true);
     }
 }
コード例 #9
0
 public SchedulerTask(IScheduled <T> scheduled, T data, TimeSpan delayBefore, TimeSpan interval, bool repeats)
 {
     this.scheduled = scheduled;
     this.data      = data;
     this.repeats   = repeats;
     hasRun         = false;
     timer          = new Timer(Tick, null, delayBefore, interval);
 }
コード例 #10
0
 public void IntervalSignal(IScheduled <object?> scheduled, object?data)
 {
     if (!executed.Get() && !TimedOut.Get())
     {
         TimedOut.Set(true);
         Parent?.TimedOut.Set(true);
         HasFailedValue.Set(true);
     }
 }
コード例 #11
0
 public SchedulerTask(IScheduled <T> scheduled, T data, TimeSpan delayBefore, TimeSpan interval, bool repeats)
 {
     this.scheduled = scheduled;
     this.data      = data;
     this.repeats   = repeats;
     this.interval  = interval;
     hasRun         = false;
     // for scheduled in intervals and scheduled once we fire only the first time.
     timer = new Timer(Tick, null, delayBefore, TimeSpan.FromMilliseconds(Timeout.Infinite));
 }
コード例 #12
0
        //=========================================
        // Scheduled
        //=========================================

        public void IntervalSignal(IScheduled <object> scheduled, object data)
        {
            try
            {
                ProbeChannel();
            }
            catch (Exception e)
            {
                Logger.Error($"Failed to ProbeChannel for {_name} because: {e.Message}", e);
            }
        }
コード例 #13
0
        private SchedulerTask CreateAndStore(
            IScheduled scheduled,
            object data,
            TimeSpan delayBefore,
            TimeSpan interval,
            bool repeats)
        {
            var task = new SchedulerTask(scheduled, data, delayBefore, interval, repeats);

            tasks.Add(task);
            return(task);
        }
コード例 #14
0
 public void IntervalSignal(IScheduled scheduled, object data)
 {
     if (!actor.IsStopped)
     {
         Action <IScheduled> consumer = actor => actor.IntervalSignal(scheduled, data);
         mailbox.Send(new LocalMessage <IScheduled>(actor, consumer, RepresentationIntervalSignal1));
     }
     else
     {
         actor.DeadLetters.FailedDelivery(new DeadLetter(actor, RepresentationIntervalSignal1));
     }
 }
コード例 #15
0
        public override ICancellable ScheduleOnce <T>(IScheduled <T> scheduled, T data, TimeSpan delayBefore, TimeSpan interval)
        {
            var t = new Thread(() =>
            {
                Thread.Sleep(delayBefore + interval);
                scheduled.IntervalSignal(scheduled, data);
            });

            t.Start();

            return(new NoOpCancellable());
        }
コード例 #16
0
        private SchedulerTask <T> CreateAndStore <T>(
            IScheduled <T> scheduled,
            T data,
            TimeSpan delayBefore,
            TimeSpan interval,
            bool repeats)
        {
            var task = new SchedulerTask <T>(scheduled, data, delayBefore, interval, repeats);

            _tasks.Push(task);
            return(task);
        }
コード例 #17
0
 public void IntervalSignal(IScheduled <object> scheduled, object data)
 {
     if (IsOutcomeKnown || executables.IsReadyToExecute)
     {
         // do nothing
     }
     else
     {
         timedOut.Set(true);
         Failed();
     }
 }
コード例 #18
0
            public void IntervalSignal(IScheduled <int> scheduled, int data)
            {
                if (_count < _maximum)
                {
                    Schedule();
                }
                else
                {
                    _completesEventually.With(_count);

                    SelfAs <IStoppable>().Stop();
                }
            }
コード例 #19
0
 public void IntervalSignal(IScheduled <T> scheduled, T data)
 {
     if (!actor.IsStopped)
     {
         Action <IScheduled <T> > consumer = x => x.IntervalSignal(scheduled, data);
         if (mailbox.IsPreallocated)
         {
             mailbox.Send(actor, consumer, null, RepresentationIntervalSignal1);
         }
         else
         {
             mailbox.Send(new LocalMessage <IScheduled <T> >(actor, consumer, RepresentationIntervalSignal1));
         }
     }
     else
     {
         actor.DeadLetters.FailedDelivery(new DeadLetter(actor, RepresentationIntervalSignal1));
     }
 }
コード例 #20
0
 public void IntervalSignal(IScheduled <object> scheduled, object data)
 {
     if (!actor.IsStopped)
     {
         Action <IAttributesAgent> consumer = x => x.IntervalSignal(scheduled, data);
         if (mailbox.IsPreallocated)
         {
             mailbox.Send(actor, consumer, null, IntervalSignalRepresentation7);
         }
         else
         {
             mailbox.Send(new LocalMessage <IAttributesAgent>(actor, consumer, IntervalSignalRepresentation7));
         }
     }
     else
     {
         actor.DeadLetters.FailedDelivery(new DeadLetter(actor, IntervalSignalRepresentation7));
     }
 }
コード例 #21
0
 public void IntervalSignal(IScheduled <object> scheduled, object data)
 {
     if (!_actor.IsStopped)
     {
         Action <IClientConsumer> consumer = actor => actor.IntervalSignal(scheduled, data);
         if (_mailbox.IsPreallocated)
         {
             _mailbox.Send(_actor, consumer, null, IntervalSignalRepresentation4);
         }
         else
         {
             _mailbox.Send(new LocalMessage <IClientConsumer>(_actor, consumer, IntervalSignalRepresentation4));
         }
     }
     else
     {
         _actor.DeadLetters?.FailedDelivery(new DeadLetter(_actor, IntervalSignalRepresentation4));
     }
 }
コード例 #22
0
    public void IntervalSignal(IScheduled <object> scheduled, object data)
    {
        Logger.Debug("Started eviction routine");
        var currentProcess = Process.GetCurrentProcess();
        var fillRatio      = currentProcess.PrivateMemorySize64 / (float)currentProcess.WorkingSet64;

        if (fillRatio >= _config.FillRatioHigh)
        {
            Logger.Debug($"Memory fill ratio {fillRatio} exceeding watermark ({_config.FillRatioHigh})");
            var evicted = _directory.EvictionCandidates(_config.LruThresholdMillis)
                          .Where(actor => actor.LifeCycle.Evictable.Stop(_config.LruThresholdMillis))
                          .Select(actor => actor.Address)
                          .ToArray();
            Logger.Debug($"Evicted {evicted.Length} actors :: {evicted}");
        }
        else
        {
            Logger.Debug($"Memory fill ratio {fillRatio} was below watermark ({_config.FillRatioHigh})");
        }
    }
コード例 #23
0
 public void IntervalSignal(IScheduled <T> scheduled, T data)
 {
     if (!_actor.IsStopped)
     {
         Action <IScheduled <T> > cons1513252312 = __ => __.IntervalSignal(scheduled, data);
         if (_mailbox.IsPreallocated)
         {
             _mailbox.Send(_actor, cons1513252312, null, IntervalSignalRepresentation1);
         }
         else
         {
             _mailbox.Send(new LocalMessage <IScheduled <T> >(_actor, cons1513252312,
                                                              IntervalSignalRepresentation1));
         }
     }
     else
     {
         _actor.DeadLetters?.FailedDelivery(new DeadLetter(_actor, IntervalSignalRepresentation1));
     }
 }
コード例 #24
0
        //==========================
        // Scheduled
        //==========================

        public void IntervalSignal(IScheduled <object> scheduled, object data)
        {
            var currentTime = DateTimeHelper.CurrentTimeMillis();
            var expiredKeys = new List <string>();

            foreach (var projectionId in _confirmables.Keys)
            {
                var confirmable = _confirmables[projectionId];
                if (confirmable.ExpiresBy <= currentTime)
                {
                    expiredKeys.Add(projectionId);
                }
            }

            foreach (var projectionId in expiredKeys)
            {
                Logger.Info($"Removing expired confirmable: {projectionId}");
                _confirmables.Remove(projectionId);
            }
        }
コード例 #25
0
        //=========================================
        // Scheduled
        //=========================================

        public void IntervalSignal(IScheduled <IntervalType> scheduled, IntervalType data)
        {
            if (_stopped)
            {
                return;
            }

            if (!_leader)
            {
                return;
            }

            switch (data)
            {
            case IntervalType.Processing:
                _publisher.ProcessChannel();
                break;

            case IntervalType.Publishing:
                _publisher.SendAvailability();
                PublishAllServices();
                break;
            }
        }
コード例 #26
0
        public void IntervalSignal(IScheduled <object> scheduled, object data)
        {
            var message = $"{ErrorMessage} IntervalSignal()";

            Logger.Error(message, new NotSupportedException(message));
        }
コード例 #27
0
 public void IntervalSignal(IScheduled <object> scheduled, object data)
 => _channel.ProbeChannel();
コード例 #28
0
        //=========================================
        // Scheduled
        //=========================================

        public void IntervalSignal(IScheduled <object> scheduled, object data)
        {
            _reader.ProbeChannel();
        }
コード例 #29
0
 public void IntervalSignal(IScheduled <object> scheduled, object data)
 {
 }
コード例 #30
0
 public void IntervalSignal(IScheduled <object?> scheduled, object?data) => DispatchUnconfirmed();