Repository: reef Updated Branches: refs/heads/master 6b6752426 -> b5c807ad6
[REEF-1373] Convert IClock to an interface JIRA: [REEF-1373](https://issues.apache.org/jira/browse/REEF-1373) Pull request: This closes #1028 Project: http://git-wip-us.apache.org/repos/asf/reef/repo Commit: http://git-wip-us.apache.org/repos/asf/reef/commit/b5c807ad Tree: http://git-wip-us.apache.org/repos/asf/reef/tree/b5c807ad Diff: http://git-wip-us.apache.org/repos/asf/reef/diff/b5c807ad Branch: refs/heads/master Commit: b5c807ad6f076202c1e922b91d5596995f1aa336 Parents: 6b67524 Author: Mariia Mykhailova <[email protected]> Authored: Mon Jun 6 12:40:57 2016 -0700 Committer: Markus Weimer <[email protected]> Committed: Mon Jun 6 14:27:17 2016 -0700 ---------------------------------------------------------------------- lang/cs/Org.Apache.REEF.Wake/Time/IClock.cs | 63 ++------------------ .../Time/Runtime/RuntimeClock.cs | 44 ++------------ 2 files changed, 10 insertions(+), 97 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/reef/blob/b5c807ad/lang/cs/Org.Apache.REEF.Wake/Time/IClock.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Wake/Time/IClock.cs b/lang/cs/Org.Apache.REEF.Wake/Time/IClock.cs index cd4bbc8..3070758 100644 --- a/lang/cs/Org.Apache.REEF.Wake/Time/IClock.cs +++ b/lang/cs/Org.Apache.REEF.Wake/Time/IClock.cs @@ -16,33 +16,27 @@ // under the License. using System; -using System.Collections.Generic; using Org.Apache.REEF.Tang.Annotations; -using Org.Apache.REEF.Wake.Impl; using Org.Apache.REEF.Wake.Time.Event; -using Org.Apache.REEF.Wake.Time.Runtime.Event; +using Org.Apache.REEF.Wake.Time.Runtime; namespace Org.Apache.REEF.Wake.Time { - public abstract class IClock : IDisposable + [DefaultImplementation(typeof(RuntimeClock))] + public interface IClock : IDisposable { /// <summary> /// Schedule a TimerEvent at the given future offset /// </summary> /// <param name="offset">The offset in the future to schedule the alarm</param> /// <param name="handler">The IObserver to to be called</param> - public abstract void ScheduleAlarm(long offset, IObserver<Alarm> handler); + void ScheduleAlarm(long offset, IObserver<Alarm> handler); /// <summary> /// Clock is idle if it has no future alarms set /// </summary> /// <returns>True if no future alarms are set, otherwise false</returns> - public abstract bool IsIdle(); - - /// <summary> - /// Dispose of the clock and all scheduled alarms - /// </summary> - public abstract void Dispose(); + bool IsIdle(); /// <summary> /// Start the Clock. @@ -50,51 +44,6 @@ namespace Org.Apache.REEF.Wake.Time /// <remarks> /// The clock will continue to run and handle events until it has been disposed. /// </remarks> - public abstract void Run(); - - /// <summary> - /// Bind this to an event handler to statically subscribe to the StartTime Event - /// </summary> - [Obsolete("Will be removed in 0.16. See [REEF-1069]")] - [NamedParameter(documentation: "Will be called upon the start event")] - public class StartHandler : Name<ISet<IObserver<StartTime>>> - { - } - - /// <summary> - /// Bind this to an event handler to statically subscribe to the StopTime Event - /// </summary> - [Obsolete("Will be removed in 0.16. See [REEF-1069]")] - [NamedParameter(documentation: "Will be called upon the stop event")] - public class StopHandler : Name<ISet<IObserver<StopTime>>> - { - } - - /// <summary> - /// Bind this to an event handler to statically subscribe to the RuntimeStart Event - /// </summary> - [Obsolete("Will be removed in 0.16. See [REEF-1069]")] - [NamedParameter(documentation: "Will be called upon the runtime start event")] - public class RuntimeStartHandler : Name<ISet<IObserver<RuntimeStart>>> - { - } - - /// <summary> - /// Bind this to an event handler to statically subscribe to the RuntimeStop Event - /// </summary> - [Obsolete("Will be removed in 0.16. See [REEF-1069]")] - [NamedParameter(documentation: "Will be called upon the runtime stop event")] - public class RuntimeStopHandler : Name<ISet<IObserver<RuntimeStop>>> - { - } - - /// <summary> - /// Bind this to an event handler to statically subscribe to the IdleClock Event - /// </summary> - [Obsolete("Will be removed in 0.16. See [REEF-1069]")] - [NamedParameter(documentation: "Will be called upon the Idle event")] - public class IdleHandler : Name<ISet<IObserver<IdleClock>>> - { - } + void Run(); } } http://git-wip-us.apache.org/repos/asf/reef/blob/b5c807ad/lang/cs/Org.Apache.REEF.Wake/Time/Runtime/RuntimeClock.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Wake/Time/Runtime/RuntimeClock.cs b/lang/cs/Org.Apache.REEF.Wake/Time/Runtime/RuntimeClock.cs index cc2a09a..dc5fd0a 100644 --- a/lang/cs/Org.Apache.REEF.Wake/Time/Runtime/RuntimeClock.cs +++ b/lang/cs/Org.Apache.REEF.Wake/Time/Runtime/RuntimeClock.cs @@ -40,13 +40,6 @@ namespace Org.Apache.REEF.Wake.Time.Runtime private readonly PubSubSubject<Time> _handlers; private readonly PriorityQueue<Time> _schedule; - // TODO[REEF-1373]: Remove the the _old* handlers - private readonly IInjectionFuture<ISet<IObserver<StartTime>>> _oldStartHandler; - private readonly IInjectionFuture<ISet<IObserver<StopTime>>> _oldStopHandler; - private readonly IInjectionFuture<ISet<IObserver<RuntimeStart>>> _oldRuntimeStartHandler; - private readonly IInjectionFuture<ISet<IObserver<RuntimeStop>>> _oldRuntimeStopHandler; - private readonly IInjectionFuture<ISet<IObserver<IdleClock>>> _oldIdleHandler; - private readonly IInjectionFuture<ISet<IObserver<StartTime>>> _startHandler; private readonly IInjectionFuture<ISet<IObserver<StopTime>>> _stopHandler; private readonly IInjectionFuture<ISet<IObserver<RuntimeStart>>> _runtimeStartHandler; @@ -64,30 +57,15 @@ namespace Org.Apache.REEF.Wake.Time.Runtime /// <param name="runtimeStartHandler">The runtime start handler</param> /// <param name="runtimeStopHandler">The runtime stop handler</param> /// <param name="idleHandler">The idle handler</param> - /// <param name="oldStartHandler">Start handlers prior to REEF-1372</param> - /// <param name="oldStopHandler">Stop handlers prior to REEF-1372</param> - /// <param name="oldRuntimeStartHandler">Runtime start handlers prior to REEF-1372</param> - /// <param name="oldRuntimeStopHandler">Runtime stop handlers prior to REEF-1372</param> - /// <param name="oldIdleHandler">Idle handlers prior to REEF-1372</param> -#pragma warning disable 618 [Inject] private RuntimeClock( ITimer timer, - - // TODO[REEF-1373]: Remove the _old* handlers - [Parameter(typeof(StartHandler))] IInjectionFuture<ISet<IObserver<StartTime>>> oldStartHandler, - [Parameter(typeof(StopHandler))] IInjectionFuture<ISet<IObserver<StopTime>>> oldStopHandler, - [Parameter(typeof(RuntimeStartHandler))] IInjectionFuture<ISet<IObserver<RuntimeStart>>> oldRuntimeStartHandler, - [Parameter(typeof(RuntimeStopHandler))] IInjectionFuture<ISet<IObserver<RuntimeStop>>> oldRuntimeStopHandler, - [Parameter(typeof(IdleHandler))] IInjectionFuture<ISet<IObserver<IdleClock>>> oldIdleHandler, - [Parameter(typeof(Parameters.StartHandler))] IInjectionFuture<ISet<IObserver<StartTime>>> startHandler, [Parameter(typeof(Parameters.StopHandler))] IInjectionFuture<ISet<IObserver<StopTime>>> stopHandler, [Parameter(typeof(Parameters.RuntimeStartHandler))] IInjectionFuture<ISet<IObserver<RuntimeStart>>> runtimeStartHandler, [Parameter(typeof(Parameters.RuntimeStopHandler))] IInjectionFuture<ISet<IObserver<RuntimeStop>>> runtimeStopHandler, [Parameter(typeof(Parameters.IdleHandler))] IInjectionFuture<ISet<IObserver<IdleClock>>> idleHandler) { -#pragma warning restore 618 _timer = timer; _schedule = new PriorityQueue<Time>(); _handlers = new PubSubSubject<Time>(); @@ -98,13 +76,6 @@ namespace Org.Apache.REEF.Wake.Time.Runtime _runtimeStopHandler = runtimeStopHandler; _idleHandler = idleHandler; - // TODO[REEF-1373]: Remove the _old* handlers - _oldStartHandler = oldStartHandler; - _oldStopHandler = oldStopHandler; - _oldRuntimeStartHandler = oldRuntimeStartHandler; - _oldRuntimeStopHandler = oldRuntimeStopHandler; - _oldIdleHandler = oldIdleHandler; - ++numberOfInstantiations; if (numberOfInstantiations > 1) { @@ -117,7 +88,7 @@ namespace Org.Apache.REEF.Wake.Time.Runtime /// </summary> /// <param name="offset">The offset in the future to schedule the alarm, in msec</param> /// <param name="handler">The IObserver to to be called</param> - public override void ScheduleAlarm(long offset, IObserver<Alarm> handler) + public void ScheduleAlarm(long offset, IObserver<Alarm> handler) { if (_disposed) { @@ -139,7 +110,7 @@ namespace Org.Apache.REEF.Wake.Time.Runtime /// Clock is idle if it has no future alarms set /// </summary> /// <returns>True if no future alarms are set, otherwise false</returns> - public override bool IsIdle() + public bool IsIdle() { lock (_schedule) { @@ -150,7 +121,7 @@ namespace Org.Apache.REEF.Wake.Time.Runtime /// <summary> /// Dispose of the clock and all scheduled alarms /// </summary> - public override void Dispose() + public void Dispose() { lock (_schedule) { @@ -165,7 +136,7 @@ namespace Org.Apache.REEF.Wake.Time.Runtime /// Start the RuntimeClock. /// Clock will continue to run and handle events until it has been disposed. /// </summary> - public override void Run() + public void Run() { SubscribeHandlers(); @@ -212,13 +183,6 @@ namespace Org.Apache.REEF.Wake.Time.Runtime /// </summary> private void SubscribeHandlers() { - // TODO[REEF-1373]: Remove the subscriptions of the _old* handlers - Subscribe(_oldStartHandler.Get()); - Subscribe(_oldStopHandler.Get()); - Subscribe(_oldRuntimeStartHandler.Get()); - Subscribe(_oldRuntimeStopHandler.Get()); - Subscribe(_oldIdleHandler.Get()); - Subscribe(_startHandler.Get()); Subscribe(_stopHandler.Get()); Subscribe(_runtimeStartHandler.Get());
