Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        public EvaluatorManager(
            IClock clock,
            //RemoteManager remoteManager,
            DriverManager driverManager,
            IResourceReleaseHandler resourceReleaseHandler,
            IResourceLaunchHandler resourceLaunchHandler,
            //REEFErrorHandler errorHandler,
            string evaluatorId,
            EvaluatorDescriptorImpl evaluatorDescriptor,
            ISet <IObservable <IActiveContext> > activeContextEventHandler,
            ISet <IObservable <IClosedContext> > closedContextEventHandlers,
            ISet <IObservable <FailedContext> > failedContextEventHandlers,
            ISet <IObservable <ContextMessage> > contextMessageHandlers,
            ISet <IObservable <IRunningTask> > runningTaskEventHandlers,
            ISet <IObservable <ICompletedTask> > completedTaskEventHandlers,
            ISet <IObservable <ISuspendedTask> > suspendedTaskEventHandlers,
            ISet <IObservable <TaskMessage> > taskMessageEventHandlers,
            ISet <IObservable <FailedTask> > taskExceptionEventHandlers,
            ISet <IObservable <IAllocatedEvaluator> > allocatedEvaluatorEventHandlers,
            ISet <IObservable <IFailedEvaluator> > failedEvaluatorHandlers,
            ISet <IObservable <ICompletedEvaluator> > completedEvaluatorHandlers)
        {
            _clock = clock;
            //_remoteManager = remoteManager;
            _driverManager          = driverManager;
            _resourceReleaseHandler = resourceReleaseHandler;
            _resourceLaunchHandler  = resourceLaunchHandler;
            _evaluatorId            = evaluatorId;
            _evaluatorDescriptor    = evaluatorDescriptor;

            //this.dispatcher = new DispatchingEStage(errorHandler, 16); // 16 threads

            //this.dispatcher.register(ActiveContext.class, activeContextEventHandlers);
            //this.dispatcher.register(ClosedContext.class, closedContextEventHandlers);
            //this.dispatcher.register(FailedContext.class, failedContextEventHandlers);
            //this.dispatcher.register(ContextMessage.class, contextMessageHandlers);

            //this.dispatcher.register(RunningTask.class, runningTaskEventHandlers);
            //this.dispatcher.register(CompletedTask.class, completedTaskEventHandlers);
            //this.dispatcher.register(SuspendedTask.class, suspendedTaskEventHandlers);
            //this.dispatcher.register(TaskMessage.class, taskMessageEventHandlers);
            //this.dispatcher.register(FailedTask.class, taskExceptionEventHandlers);

            //this.dispatcher.register(FailedEvaluator.class, failedEvaluatorHandlers);
            //this.dispatcher.register(CompletedEvaluator.class, completedEvaluatorHandlers);
            //this.dispatcher.register(AllocatedEvaluator.class, allocatedEvaluatorEventHandlers);

            //this.dispatcher.onNext(AllocatedEvaluator.class,
            //    new AllocatedEvaluatorImpl(this, remoteManager.getMyIdentifier()));
        }
Exemplo n.º 4
0
 /// <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);
         }
     }
 }
Exemplo n.º 5
0
 /// <summary>
 ///  Helper method to create a new EvaluatorManager instance
 /// </summary>
 /// <param name="id">identifier of the Evaluator</param>
 /// <param name="descriptor"> NodeDescriptor on which the Evaluator executes.</param>
 /// <returns>new EvaluatorManager instance.</returns>
 private EvaluatorManager GetNewEvaluatorManagerInstance(string id, EvaluatorDescriptorImpl descriptor)
 {
     LOGGER.Log(Level.Info, "Creating Evaluator Manager: " + id);
     //TODO bindVolatieParameter
     return((EvaluatorManager)_injector.GetInstance(typeof(EvaluatorManager)));
 }