Repository: incubator-reef
Updated Branches:
refs/heads/master 0e3b7dbd8 -> 23f677d0c
[REEF-718] Document EvaluatorBatchId
* Documents EvaluatorBatchId and field related to it.
* Cleaned up some code relevant to EvaluatorBatchId.
JIRA:
[REEF-718] https://issues.apache.org/jira/browse/REEF-718
Pull Request:
Closes #521
Project: http://git-wip-us.apache.org/repos/asf/incubator-reef/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-reef/commit/23f677d0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-reef/tree/23f677d0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-reef/diff/23f677d0
Branch: refs/heads/master
Commit: 23f677d0c2676d9d724e818227870d76af0ce3cb
Parents: 0e3b7db
Author: Andrew Chung <[email protected]>
Authored: Wed Sep 23 13:39:36 2015 -0700
Committer: Julia Wang <[email protected]>
Committed: Thu Sep 24 15:43:35 2015 -0700
----------------------------------------------------------------------
.../Bridge/Events/AllocatedEvaluator.cs | 16 +++-------
.../Bridge/Events/EvaluatorRequestor.cs | 32 ++++++++++----------
.../Evaluator/EvaluatorRequestBuilder.cs | 6 +++-
.../Evaluator/IEvaluatorRequest.cs | 5 ++-
4 files changed, 30 insertions(+), 29 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/23f677d0/lang/cs/Org.Apache.REEF.Driver/Bridge/Events/AllocatedEvaluator.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Org.Apache.REEF.Driver/Bridge/Events/AllocatedEvaluator.cs
b/lang/cs/Org.Apache.REEF.Driver/Bridge/Events/AllocatedEvaluator.cs
index bfb0f62..d64816e 100644
--- a/lang/cs/Org.Apache.REEF.Driver/Bridge/Events/AllocatedEvaluator.cs
+++ b/lang/cs/Org.Apache.REEF.Driver/Bridge/Events/AllocatedEvaluator.cs
@@ -173,18 +173,12 @@ namespace Org.Apache.REEF.Driver.Bridge.Events
{
if (pair.Value.Equals(_evaluatorDescriptor))
{
- string key = pair.Key;
+ var key = pair.Key;
EvaluatorRequestor.Evaluators.Remove(key);
- string assignedId = key.Substring(0,
key.LastIndexOf('_'));
- string message = string.Format(
- CultureInfo.InvariantCulture,
- "Received evalautor [{0}] of memory {1}MB that
matches request of {2}MB with batch id [{3}].",
- Id,
- _evaluatorDescriptor.Memory,
- pair.Value.Memory,
- assignedId);
-
- LOGGER.Log(Level.Verbose, message);
+ var assignedId = key.Substring(0,
key.LastIndexOf(EvaluatorRequestor.BatchIdxSeparator));
+
+ LOGGER.Log(Level.Verbose, "Received evaluator [{0}] of
memory {1}MB that matches request of {2}MB with batch id [{3}].",
+ Id, _evaluatorDescriptor.Memory,
pair.Value.Memory, assignedId);
EvaluatorBatchId = assignedId;
break;
}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/23f677d0/lang/cs/Org.Apache.REEF.Driver/Bridge/Events/EvaluatorRequestor.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Org.Apache.REEF.Driver/Bridge/Events/EvaluatorRequestor.cs
b/lang/cs/Org.Apache.REEF.Driver/Bridge/Events/EvaluatorRequestor.cs
index 6c3cbb2..d697397 100644
--- a/lang/cs/Org.Apache.REEF.Driver/Bridge/Events/EvaluatorRequestor.cs
+++ b/lang/cs/Org.Apache.REEF.Driver/Bridge/Events/EvaluatorRequestor.cs
@@ -18,6 +18,7 @@
*/
using System;
+using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Globalization;
using System.Runtime.Serialization;
@@ -31,11 +32,13 @@ using Org.Apache.REEF.Utilities.Logging;
namespace Org.Apache.REEF.Driver.Bridge.Events
{
[DataContract]
- internal class EvaluatorRequestor : IEvaluatorRequestor
+ internal sealed class EvaluatorRequestor : IEvaluatorRequestor
{
+ internal const char BatchIdxSeparator = '_';
private static readonly Logger LOGGER =
Logger.GetLogger(typeof(EvaluatorRequestor));
- private static Dictionary<string, IEvaluatorDescriptor> _evaluators;
+ private static readonly IDictionary<string, IEvaluatorDescriptor>
EvaluatorDescriptorsDictionary =
+ new Dictionary<string, IEvaluatorDescriptor>();
internal EvaluatorRequestor(IEvaluatorRequestorClr2Java clr2Java)
{
@@ -43,16 +46,13 @@ namespace Org.Apache.REEF.Driver.Bridge.Events
Clr2Java = clr2Java;
}
- internal static Dictionary<string, IEvaluatorDescriptor> Evaluators
+ /// <summary>
+ /// A map of EvaluatorBatchID + BatchIdxSeparator + (Evaluator number
in the batch) to
+ /// the Evaluator descriptor for the Evaluator.
+ /// </summary>
+ internal static IDictionary<string, IEvaluatorDescriptor> Evaluators
{
- get
- {
- if (_evaluators == null)
- {
- _evaluators = new Dictionary<string,
IEvaluatorDescriptor>();
- }
- return _evaluators;
- }
+ get { return EvaluatorDescriptorsDictionary; }
}
public IResourceCatalog ResourceCatalog { get; set; }
@@ -65,17 +65,17 @@ namespace Org.Apache.REEF.Driver.Bridge.Events
public void Submit(IEvaluatorRequest request)
{
- LOGGER.Log(Level.Info, string.Format(CultureInfo.InvariantCulture,
"Submitting request for {0} evaluators and {1} MB memory and {2} core to rack
{3}.", request.Number, request.MemoryMegaBytes, request.VirtualCore,
request.Rack));
+ LOGGER.Log(Level.Info, "Submitting request for {0} evaluators and
{1} MB memory and {2} core to rack {3}.", request.Number,
request.MemoryMegaBytes, request.VirtualCore, request.Rack);
lock (Evaluators)
{
- for (int i = 0; i < request.Number; i++)
+ for (var i = 0; i < request.Number; i++)
{
- EvaluatorDescriptorImpl descriptor = new
EvaluatorDescriptorImpl(new NodeDescriptorImpl(), EvaluatorType.CLR,
request.MemoryMegaBytes, request.VirtualCore, request.Rack);
- string key = string.Format(CultureInfo.InvariantCulture,
"{0}_{1}", request.EvaluatorBatchId, i);
+ var descriptor = new EvaluatorDescriptorImpl(new
NodeDescriptorImpl(), EvaluatorType.CLR, request.MemoryMegaBytes,
request.VirtualCore, request.Rack);
+ var key = string.Format(CultureInfo.InvariantCulture,
"{0}{1}{2}", request.EvaluatorBatchId, BatchIdxSeparator, i);
try
{
- _evaluators.Add(key, descriptor);
+ Evaluators.Add(key, descriptor);
}
catch (ArgumentException e)
{
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/23f677d0/lang/cs/Org.Apache.REEF.Driver/Evaluator/EvaluatorRequestBuilder.cs
----------------------------------------------------------------------
diff --git
a/lang/cs/Org.Apache.REEF.Driver/Evaluator/EvaluatorRequestBuilder.cs
b/lang/cs/Org.Apache.REEF.Driver/Evaluator/EvaluatorRequestBuilder.cs
index 8d018b1..897adb1 100644
--- a/lang/cs/Org.Apache.REEF.Driver/Evaluator/EvaluatorRequestBuilder.cs
+++ b/lang/cs/Org.Apache.REEF.Driver/Evaluator/EvaluatorRequestBuilder.cs
@@ -93,7 +93,11 @@ namespace Org.Apache.REEF.Driver.Evaluator
return this;
}
- // TODO[REEF-718]: Document.
+ /// <summary>
+ /// Sets the batch ID for requested evaluators in the same request.
The batch of Evaluators requested in the
+ /// same request will have the same Evaluator Batch ID.
+ /// </summary>
+ /// <param name="evaluatorBatchId">The batch ID for the Evaluator
request.</param>
public EvaluatorRequestBuilder SetEvaluatorBatchId(string
evaluatorBatchId)
{
_evaluatorBatchId = evaluatorBatchId;
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/23f677d0/lang/cs/Org.Apache.REEF.Driver/Evaluator/IEvaluatorRequest.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Org.Apache.REEF.Driver/Evaluator/IEvaluatorRequest.cs
b/lang/cs/Org.Apache.REEF.Driver/Evaluator/IEvaluatorRequest.cs
index a1cadff..7e4f74f 100644
--- a/lang/cs/Org.Apache.REEF.Driver/Evaluator/IEvaluatorRequest.cs
+++ b/lang/cs/Org.Apache.REEF.Driver/Evaluator/IEvaluatorRequest.cs
@@ -44,7 +44,10 @@ namespace Org.Apache.REEF.Driver.Evaluator
/// </summary>
string Rack { get; }
- // TODO[REEF-718] Document
+ /// <summary>
+ /// The batch ID for requested evaluators. Evaluators requested in the
same batch
+ /// will have the same Batch ID.
+ /// </summary>
string EvaluatorBatchId { get; }
}
}
\ No newline at end of file