/// <summary> /// This method handles resource allocations by creating a new EvaluatorManager instance. /// </summary> /// <param name="resourceAllocationProto"></param> private void Handle(ResourceAllocationProto resourceAllocationProto) { lock (_evaluators) { try { INodeDescriptor nodeDescriptor = _resourceCatalog.GetNode(resourceAllocationProto.node_id); if (nodeDescriptor == null) { Exceptions.Throw(new InvalidOperationException("Unknown resurce: " + resourceAllocationProto.node_id), LOGGER); } EvaluatorDescriptorImpl evaluatorDescriptor = new EvaluatorDescriptorImpl(nodeDescriptor, EvaluatorType.UNDECIDED, resourceAllocationProto.resource_memory, resourceAllocationProto.virtual_cores); LOGGER.Log(Level.Info, "Resource allocation: new evaluator id: " + resourceAllocationProto.identifier); EvaluatorManager evaluatorManager = GetNewEvaluatorManagerInstance(resourceAllocationProto.identifier, evaluatorDescriptor); _evaluators.Add(resourceAllocationProto.identifier, evaluatorManager); } catch (Exception e) { Exceptions.Caught(e, Level.Error, LOGGER); Exceptions.Throw(new InvalidOperationException("Error handling resourceAllocationProto."), LOGGER); } } }
/// <summary> /// A ResourceAllocationProto indicates a resource allocation given by the ResourceManager layer. /// </summary> /// <param name="resourceAllocationProto"></param> public void OnNext(ResourceAllocationProto resourceAllocationProto) { Handle(resourceAllocationProto); }