Ejemplo n.º 1
0
 /// <summary>
 /// Launch an Task.
 /// </summary>
 /// <param name="startTaskProto"></param>
 private void StartTask(StartTaskProto startTaskProto)
 {
     lock (_contextStack)
     {
         ContextRuntime currentActiveContext = _contextStack.Peek();
         string         expectedContextId    = startTaskProto.context_id;
         if (!expectedContextId.Equals(currentActiveContext.Id, StringComparison.OrdinalIgnoreCase))
         {
             var e = new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Task expected context '{0}' but the active context has Id '{1}'", expectedContextId, currentActiveContext.Id));
             Org.Apache.REEF.Utilities.Diagnostics.Exceptions.Throw(e, LOGGER);
         }
         TaskConfiguration taskConfiguration = new TaskConfiguration(startTaskProto.configuration);
         currentActiveContext.StartTask(taskConfiguration, expectedContextId, _heartBeatManager);
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Launch an Task.
        /// </summary>
        /// <param name="startTaskProto"></param>
        private void StartTask(StartTaskProto startTaskProto)
        {
            lock (_contextLock)
            {
                ContextRuntime currentActiveContext = _topContext;
                string         expectedContextId    = startTaskProto.context_id;
                if (!expectedContextId.Equals(currentActiveContext.Id, StringComparison.OrdinalIgnoreCase))
                {
                    var e = new InvalidOperationException(
                        string.Format(CultureInfo.InvariantCulture, "Task expected context '{0}' but the active context has Id '{1}'", expectedContextId, currentActiveContext.Id));
                    Utilities.Diagnostics.Exceptions.Throw(e, LOGGER);
                }

                var configuration = _serializer.FromString(startTaskProto.configuration);
                currentActiveContext.StartTask(configuration);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Start the context manager. This initiates the root context.
        /// </summary>
        public void Start()
        {
            lock (_contextLock)
            {
                _topContext = _rootContextLauncher.GetRootContext();
                LOGGER.Log(Level.Info, string.Format(CultureInfo.InvariantCulture, "Instantiating root context with Id {0}", _topContext.Id));

                if (_rootContextLauncher.RootTaskConfig.IsPresent())
                {
                    LOGGER.Log(Level.Info, "Launching the initial Task");
                    try
                    {
                        _topContext.StartTask(_rootContextLauncher.RootTaskConfig.Value, _rootContextLauncher.RootContextConfig.Id, _heartBeatManager);
                    }
                    catch (TaskClientCodeException e)
                    {
                        Utilities.Diagnostics.Exceptions.Caught(e, Level.Error, "Exception when trying to start a task.", LOGGER);
                        HandleTaskException(e);
                    }
                }
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Start the context manager. This initiates the root context.
        /// </summary>
        public void Start()
        {
            lock (_contextLock)
            {
                _topContext = _rootContextLauncher.GetRootContext();
                LOGGER.Log(Level.Info, string.Format(CultureInfo.InvariantCulture, "Instantiating root context with Id {0}", _topContext.Id));

                if (_rootContextLauncher.RootTaskConfig.IsPresent())
                {
                    LOGGER.Log(Level.Info, "Launching the initial Task");
                    try
                    {
                        _topContext.StartTask(_rootContextLauncher.RootTaskConfig.Value);
                    }
                    catch (TaskClientCodeException e)
                    {
                        Utilities.Diagnostics.Exceptions.Caught(e, Level.Error, "Exception when trying to start a task.", LOGGER);
                        HandleTaskException(e);
                    }
                }
            }
        }