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)); lock (Evaluators) { for (int i = 0; i < request.Number; i++) { EvaluatorDescriptorImpl descriptor = new EvaluatorDescriptorImpl(new NodeDescriptorImpl(), EvaluatorType.CLR, request.MemoryMegaBytes, request.VirtualCore); descriptor.Rack = request.Rack; string key = string.Format(CultureInfo.InvariantCulture, "{0}_{1}", request.EvaluatorBatchId, i); try { _evaluators.Add(key, descriptor); } catch (ArgumentException e) { Exceptions.Caught(e, Level.Error, string.Format(CultureInfo.InvariantCulture, "EvaluatorBatchId [{0}] already exists.", key), LOGGER); Exceptions.Throw(new InvalidOperationException("Cannot use evaluator id " + key, e), LOGGER); } } } Clr2Java.Submit(request); }
public void Submit(IEvaluatorRequest request) { LOGGER.Log(Level.Info, "Submitting request for {0} evaluators and {1} MB memory and {2} core to rack {3} and runtime {4}.", request.Number, request.MemoryMegaBytes, request.VirtualCore, request.Rack, request.RuntimeName); lock (Evaluators) { for (var i = 0; i < request.Number; i++) { if (!string.IsNullOrWhiteSpace(request.RuntimeName)) { if (runtimes.runtimeNames != null && !runtimes.runtimeNames.Contains(request.RuntimeName)) { throw new ArgumentException(string.Format("Requested runtime {0} is not in the defined runtimes list {1}", request.RuntimeName, string.Join(",", runtimes.runtimeNames))); } } var descriptor = new EvaluatorDescriptorImpl(new NodeDescriptorImpl(), EvaluatorType.CLR, request.MemoryMegaBytes, request.VirtualCore, request.RuntimeName, request.Rack); var key = string.Format(CultureInfo.InvariantCulture, "{0}{1}{2}", request.EvaluatorBatchId, BatchIdxSeparator, i); try { Evaluators.Add(key, descriptor); } catch (ArgumentException e) { Exceptions.Caught(e, Level.Error, string.Format(CultureInfo.InvariantCulture, "EvaluatorBatchId [{0}] already exists.", key), LOGGER); Exceptions.Throw(new InvalidOperationException("Cannot use evaluator id " + key, e), LOGGER); } } } Clr2Java.Submit(request); }
private bool EquivalentMemory(EvaluatorDescriptorImpl other) { int granularity = ClrHandlerHelper.MemoryGranularity == 0 ? Constants.DefaultMemoryGranularity : ClrHandlerHelper.MemoryGranularity; int m1 = (Memory - 1) / granularity; int m2 = (other.Memory - 1) / granularity; return(m1 == m2); }
public override bool Equals(object obj) { EvaluatorDescriptorImpl other = obj as EvaluatorDescriptorImpl; if (other == null) { return(false); } return(EquivalentMemory(other)); // we don't care about rack now; // && string.Equals(_rack, other.Rack, StringComparison.OrdinalIgnoreCase); }
private bool EquivalentMemory(EvaluatorDescriptorImpl other) { int granularity = ClrHandlerHelper.MemoryGranularity == 0 ? Constants.DefaultMemoryGranularity : ClrHandlerHelper.MemoryGranularity; int m1 = (Memory - 1) / granularity; int m2 = (other.Memory - 1 ) / granularity; return (m1 == m2); }