Repository: incubator-reef Updated Branches: refs/heads/master d32c698e0 -> c9b0376e8
[REEF-676] Made *Task.ActiveContext immutable * Made `ActiveContext` immutable in `RunningTask`, `CompletedTask` and `SuspendedTask` implementations and interfaces. * Deleted the spurious `IRunningTask` in O.A.R.Common. To do this, I had to move `EvaluatorException` into the `Driver`. * In order to make that new `EvaluatorException` `internal`, I added the Bridge as a friend assembly of the Driver. JIRA: [REEF-676](https://issues.apache.org/jira/browse/REEF-676) Pull Request: This closes #472 Project: http://git-wip-us.apache.org/repos/asf/incubator-reef/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-reef/commit/c9b0376e Tree: http://git-wip-us.apache.org/repos/asf/incubator-reef/tree/c9b0376e Diff: http://git-wip-us.apache.org/repos/asf/incubator-reef/diff/c9b0376e Branch: refs/heads/master Commit: c9b0376e8b025bd2ad6096b50a7bef87d61ca4a2 Parents: d32c698 Author: Markus Weimer <wei...@apache.org> Authored: Tue Sep 8 13:55:13 2015 -0700 Committer: Andrew Chung <afchun...@gmail.com> Committed: Thu Sep 10 10:41:04 2015 -0700 ---------------------------------------------------------------------- .../Exceptions/EvaluatorException.cs | 74 -------------------- .../Org.Apache.REEF.Common.csproj | 2 - .../Tasks/IRunningTask.cs | 53 -------------- .../Bridge/Events/CompletedTask.cs | 7 -- .../Bridge/Events/FailedEvaluator.cs | 1 - .../Bridge/Events/RunningTask.cs | 10 --- .../Bridge/Events/SuspendedTask.cs | 8 --- .../Evaluator/EvaluatorException.cs | 74 ++++++++++++++++++++ .../Evaluator/IFailedEvaluator.cs | 1 - .../Org.Apache.REEF.Driver.csproj | 1 + .../Properties/AssemblyInfo.cs | 12 ++++ .../Task/ICompletedTask.cs | 7 +- .../Org.Apache.REEF.Driver/Task/IRunningTask.cs | 8 +-- .../Task/ISuspendedTask.cs | 10 ++- 14 files changed, 101 insertions(+), 167 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/c9b0376e/lang/cs/Org.Apache.REEF.Common/Exceptions/EvaluatorException.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Common/Exceptions/EvaluatorException.cs b/lang/cs/Org.Apache.REEF.Common/Exceptions/EvaluatorException.cs deleted file mode 100644 index 319b4f2..0000000 --- a/lang/cs/Org.Apache.REEF.Common/Exceptions/EvaluatorException.cs +++ /dev/null @@ -1,74 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -using System; -using Org.Apache.REEF.Common.Tasks; -using Org.Apache.REEF.Utilities; - -namespace Org.Apache.REEF.Common.Exceptions -{ - public class EvaluatorException : System.Exception, IIdentifiable - { - private readonly string _evaluatorId; - - public EvaluatorException(string evaluatorId) - { - _evaluatorId = evaluatorId; - RunningTask = null; - } - - public EvaluatorException(string evaluatorId, string message, System.Exception cause) - : base(message, cause) - { - _evaluatorId = evaluatorId; - RunningTask = null; - } - - public EvaluatorException(string evaluatorId, string message) - : this(evaluatorId, message, (IRunningTask)null) - { - } - - public EvaluatorException(string evaluatorId, string message, IRunningTask runningTask) - : base(message) - { - _evaluatorId = evaluatorId; - RunningTask = runningTask; - } - - public EvaluatorException(string evaluatorId, System.Exception cause) - : this(evaluatorId, cause, null) - { - } - - public EvaluatorException(string evaluatorId, Exception cause, IRunningTask runningTask) - : base(string.Empty, cause) - { - _evaluatorId = evaluatorId; - RunningTask = runningTask; - } - - public IRunningTask RunningTask { get; set; } - - public string Id - { - get { return _evaluatorId; } - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/c9b0376e/lang/cs/Org.Apache.REEF.Common/Org.Apache.REEF.Common.csproj ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Common/Org.Apache.REEF.Common.csproj b/lang/cs/Org.Apache.REEF.Common/Org.Apache.REEF.Common.csproj index 5a2a7d6..59c8a24 100644 --- a/lang/cs/Org.Apache.REEF.Common/Org.Apache.REEF.Common.csproj +++ b/lang/cs/Org.Apache.REEF.Common/Org.Apache.REEF.Common.csproj @@ -85,7 +85,6 @@ under the License. <Compile Include="Evaluator\Parameters\EvaluatorConfigurationProviders.cs" /> <Compile Include="Events\IContextStart.cs" /> <Compile Include="Events\IContextStop.cs" /> - <Compile Include="Exceptions\EvaluatorException.cs" /> <Compile Include="Exceptions\JobException.cs" /> <Compile Include="Files\PathUtilities.cs" /> <Compile Include="IContextAndTaskSubmittable.cs" /> @@ -143,7 +142,6 @@ under the License. <Compile Include="Tasks\Events\ITaskStart.cs" /> <Compile Include="Tasks\Events\ITaskStop.cs" /> <Compile Include="Tasks\IDriverMessageHandler.cs" /> - <Compile Include="Tasks\IRunningTask.cs" /> <Compile Include="Tasks\ITask.cs" /> <Compile Include="Tasks\ITaskMessageSource.cs" /> <Compile Include="Tasks\TaskConfiguration.cs" /> http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/c9b0376e/lang/cs/Org.Apache.REEF.Common/Tasks/IRunningTask.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Common/Tasks/IRunningTask.cs b/lang/cs/Org.Apache.REEF.Common/Tasks/IRunningTask.cs deleted file mode 100644 index 236da5a..0000000 --- a/lang/cs/Org.Apache.REEF.Common/Tasks/IRunningTask.cs +++ /dev/null @@ -1,53 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -using System; -using Org.Apache.REEF.Utilities; - -namespace Org.Apache.REEF.Common.Tasks -{ - /// <summary> - /// Represents a running Task - /// </summary> - public interface IRunningTask : IIdentifiable, IDisposable - { - /// <summary> - /// Sends the message to the running task. - /// </summary> - /// <param name="message"></param> - void OnNext(byte[] message); - - /// <summary> - /// Signal the task to suspend. - /// </summary> - /// <param name="message">a message that is sent to the Task.</param> - void Suspend(byte[] message); - - /// <summary> - /// Sends the message to the running task. - /// </summary> - void Suspend(); - - /// <summary> - /// Signal the task to shut down. - /// </summary> - /// <param name="message">a message that is sent to the Task.</param> - void Dispose(byte[] message); - } -} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/c9b0376e/lang/cs/Org.Apache.REEF.Driver/Bridge/Events/CompletedTask.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Driver/Bridge/Events/CompletedTask.cs b/lang/cs/Org.Apache.REEF.Driver/Bridge/Events/CompletedTask.cs index 6617b97..cb44f59 100644 --- a/lang/cs/Org.Apache.REEF.Driver/Bridge/Events/CompletedTask.cs +++ b/lang/cs/Org.Apache.REEF.Driver/Bridge/Events/CompletedTask.cs @@ -22,15 +22,12 @@ using System.Runtime.Serialization; using Org.Apache.REEF.Driver.Bridge.Clr2java; using Org.Apache.REEF.Driver.Context; using Org.Apache.REEF.Driver.Task; -using Org.Apache.REEF.Utilities.Logging; namespace Org.Apache.REEF.Driver.Bridge.Events { [DataContract] internal class CompletedTask : ICompletedTask { - private static readonly Logger LOGGER = Logger.GetLogger(typeof(CompletedTask)); - internal CompletedTask(ICompletedTaskClr2Java completedTaskClr2Java) { InstanceId = Guid.NewGuid().ToString("N"); @@ -57,10 +54,6 @@ namespace Org.Apache.REEF.Driver.Bridge.Events { return new ActiveContext(ActiveContextClr2Java); } - - set - { - } } [DataMember] http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/c9b0376e/lang/cs/Org.Apache.REEF.Driver/Bridge/Events/FailedEvaluator.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Driver/Bridge/Events/FailedEvaluator.cs b/lang/cs/Org.Apache.REEF.Driver/Bridge/Events/FailedEvaluator.cs index 4feec3f..8ba8730 100644 --- a/lang/cs/Org.Apache.REEF.Driver/Bridge/Events/FailedEvaluator.cs +++ b/lang/cs/Org.Apache.REEF.Driver/Bridge/Events/FailedEvaluator.cs @@ -20,7 +20,6 @@ using System; using System.Collections.Generic; using System.Runtime.Serialization; -using Org.Apache.REEF.Common.Exceptions; using Org.Apache.REEF.Driver.Bridge.Clr2java; using Org.Apache.REEF.Driver.Evaluator; using Org.Apache.REEF.Driver.Task; http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/c9b0376e/lang/cs/Org.Apache.REEF.Driver/Bridge/Events/RunningTask.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Driver/Bridge/Events/RunningTask.cs b/lang/cs/Org.Apache.REEF.Driver/Bridge/Events/RunningTask.cs index b6f6a5c..7e9901b 100644 --- a/lang/cs/Org.Apache.REEF.Driver/Bridge/Events/RunningTask.cs +++ b/lang/cs/Org.Apache.REEF.Driver/Bridge/Events/RunningTask.cs @@ -45,11 +45,6 @@ namespace Org.Apache.REEF.Driver.Bridge.Events { return new ActiveContext(_activeContextClr2Java); } - - set - { - ActiveContext = value; - } } public string Id @@ -65,11 +60,6 @@ namespace Org.Apache.REEF.Driver.Bridge.Events _runningTaskClr2Java.Send(message); } - public void OnNext(byte[] message) - { - throw new NotImplementedException(); - } - public void Suspend(byte[] message) { throw new NotImplementedException(); http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/c9b0376e/lang/cs/Org.Apache.REEF.Driver/Bridge/Events/SuspendedTask.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Driver/Bridge/Events/SuspendedTask.cs b/lang/cs/Org.Apache.REEF.Driver/Bridge/Events/SuspendedTask.cs index 3a9415c..a29eec6 100644 --- a/lang/cs/Org.Apache.REEF.Driver/Bridge/Events/SuspendedTask.cs +++ b/lang/cs/Org.Apache.REEF.Driver/Bridge/Events/SuspendedTask.cs @@ -44,10 +44,6 @@ namespace Org.Apache.REEF.Driver.Bridge.Events { return SuspendedTaskClr2Java.Get(); } - - set - { - } } public string Id @@ -64,10 +60,6 @@ namespace Org.Apache.REEF.Driver.Bridge.Events { return new ActiveContext(ActiveContextClr2Java); } - - set - { - } } [DataMember] http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/c9b0376e/lang/cs/Org.Apache.REEF.Driver/Evaluator/EvaluatorException.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Driver/Evaluator/EvaluatorException.cs b/lang/cs/Org.Apache.REEF.Driver/Evaluator/EvaluatorException.cs new file mode 100644 index 0000000..7c57a44 --- /dev/null +++ b/lang/cs/Org.Apache.REEF.Driver/Evaluator/EvaluatorException.cs @@ -0,0 +1,74 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +using System; +using Org.Apache.REEF.Driver.Task; +using Org.Apache.REEF.Utilities; + +namespace Org.Apache.REEF.Driver.Evaluator +{ + // Public only such that it can be used in the bridge. + /// <summary> + /// </summary> + public sealed class EvaluatorException : Exception, IIdentifiable + { + private readonly string _evaluatorId; + private readonly IRunningTask _runningTask; + + internal EvaluatorException(string evaluatorId, IRunningTask runningTask = null) + { + _evaluatorId = evaluatorId; + _runningTask = runningTask; + } + + internal EvaluatorException(string evaluatorId, string message, Exception cause, IRunningTask runningTask = null) + : base(message, cause) + { + _evaluatorId = evaluatorId; + _runningTask = runningTask; + } + + internal EvaluatorException(string evaluatorId, string message, IRunningTask runningTask = null) + : base(message) + { + _evaluatorId = evaluatorId; + _runningTask = runningTask; + } + + internal EvaluatorException(string evaluatorId, Exception cause, IRunningTask runningTask = null) + : base(string.Empty, cause) + { + _evaluatorId = evaluatorId; + _runningTask = runningTask; + } + + /// <summary> + /// The task that was running on the Evaluator or null if none was running exists. + /// </summary> + public IRunningTask RunningTask + { + get { return _runningTask; } + } + + public string Id + { + get { return _evaluatorId; } + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/c9b0376e/lang/cs/Org.Apache.REEF.Driver/Evaluator/IFailedEvaluator.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Driver/Evaluator/IFailedEvaluator.cs b/lang/cs/Org.Apache.REEF.Driver/Evaluator/IFailedEvaluator.cs index a87d01c..bbb06e0 100644 --- a/lang/cs/Org.Apache.REEF.Driver/Evaluator/IFailedEvaluator.cs +++ b/lang/cs/Org.Apache.REEF.Driver/Evaluator/IFailedEvaluator.cs @@ -19,7 +19,6 @@ using System; using System.Collections.Generic; -using Org.Apache.REEF.Common.Exceptions; using Org.Apache.REEF.Driver.Bridge.Events; using Org.Apache.REEF.Driver.Task; using Org.Apache.REEF.Utilities; http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/c9b0376e/lang/cs/Org.Apache.REEF.Driver/Org.Apache.REEF.Driver.csproj ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Driver/Org.Apache.REEF.Driver.csproj b/lang/cs/Org.Apache.REEF.Driver/Org.Apache.REEF.Driver.csproj index 8a7af98..dd0b2cd 100644 --- a/lang/cs/Org.Apache.REEF.Driver/Org.Apache.REEF.Driver.csproj +++ b/lang/cs/Org.Apache.REEF.Driver/Org.Apache.REEF.Driver.csproj @@ -130,6 +130,7 @@ under the License. <Compile Include="DriverConfigurationSettings.cs" /> <Compile Include="DriverSubmissionSettings.cs" /> <Compile Include="Evaluator\EvaluatorDescriptorImpl.cs" /> + <Compile Include="Evaluator\EvaluatorException.cs" /> <Compile Include="Evaluator\EvaluatorRequest.cs" /> <Compile Include="Evaluator\EvaluatorRequestBuilder.cs" /> <Compile Include="Evaluator\IAllocatedEvaluator.cs" /> http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/c9b0376e/lang/cs/Org.Apache.REEF.Driver/Properties/AssemblyInfo.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Driver/Properties/AssemblyInfo.cs b/lang/cs/Org.Apache.REEF.Driver/Properties/AssemblyInfo.cs index 81cf2d4..ae8b2f4 100644 --- a/lang/cs/Org.Apache.REEF.Driver/Properties/AssemblyInfo.cs +++ b/lang/cs/Org.Apache.REEF.Driver/Properties/AssemblyInfo.cs @@ -18,6 +18,7 @@ */ using System.Reflection; +using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following @@ -52,3 +53,14 @@ using System.Runtime.InteropServices; // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("0.13.0.0")] [assembly: AssemblyFileVersion("0.13.0.0")] + +// Allow the bridge access to `internal` APIs +#if DEBUG +[assembly: InternalsVisibleTo("Org.Apache.REEF.Bridge")] +#else +[assembly: InternalsVisibleTo("Org.Apache.REEF.Bridge, publickey=" + + "00240000048000009400000006020000002400005253413100040000010001005df3e621d886a9" + + "9c03469d0f93a9f5d45aa2c883f50cd158759e93673f759ec4657fd84cc79d2db38ef1a2d914cc" + + "b7c717846a897e11dd22eb260a7ce2da2dccf0263ea63e2b3f7dac24f28882aa568ef544341d17" + + "618392a1095f4049ad079d4f4f0b429bb535699155fd6a7652ec7d6c1f1ba2b560f11ef3a86b5945d288cf")] +#endif \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/c9b0376e/lang/cs/Org.Apache.REEF.Driver/Task/ICompletedTask.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Driver/Task/ICompletedTask.cs b/lang/cs/Org.Apache.REEF.Driver/Task/ICompletedTask.cs index bfd15c7..a7b00a2 100644 --- a/lang/cs/Org.Apache.REEF.Driver/Task/ICompletedTask.cs +++ b/lang/cs/Org.Apache.REEF.Driver/Task/ICompletedTask.cs @@ -24,6 +24,9 @@ namespace Org.Apache.REEF.Driver.Task { public interface ICompletedTask : IMessage, IIdentifiable { - IActiveContext ActiveContext { get; set; } + /// <summary> + /// The Context on which this task was executed. + /// </summary> + IActiveContext ActiveContext { get; } } -} +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/c9b0376e/lang/cs/Org.Apache.REEF.Driver/Task/IRunningTask.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Driver/Task/IRunningTask.cs b/lang/cs/Org.Apache.REEF.Driver/Task/IRunningTask.cs index cba82dd..4c99f1b 100644 --- a/lang/cs/Org.Apache.REEF.Driver/Task/IRunningTask.cs +++ b/lang/cs/Org.Apache.REEF.Driver/Task/IRunningTask.cs @@ -31,13 +31,7 @@ namespace Org.Apache.REEF.Driver.Task /// <summary> /// the context the task is running on. /// </summary> - IActiveContext ActiveContext { get; set; } - - /// <summary> - /// Sends the message to the running task. - /// </summary> - /// <param name="message"></param> - void OnNext(byte[] message); + IActiveContext ActiveContext { get; } /// <summary> /// Sends the message http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/c9b0376e/lang/cs/Org.Apache.REEF.Driver/Task/ISuspendedTask.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Driver/Task/ISuspendedTask.cs b/lang/cs/Org.Apache.REEF.Driver/Task/ISuspendedTask.cs index 6478c8f..02978ea 100644 --- a/lang/cs/Org.Apache.REEF.Driver/Task/ISuspendedTask.cs +++ b/lang/cs/Org.Apache.REEF.Driver/Task/ISuspendedTask.cs @@ -22,8 +22,14 @@ using Org.Apache.REEF.Utilities; namespace Org.Apache.REEF.Driver.Task { + /// <summary> + /// Represents a suspended task. + /// </summary> public interface ISuspendedTask : IMessage, IIdentifiable { - IActiveContext ActiveContext { get; set; } + /// <summary> + /// The Context on which the task was suspended. + /// </summary> + IActiveContext ActiveContext { get; } } -} +} \ No newline at end of file