Exemple #1
0
        /**
         * Run REEF on specified runtime and fail (raise an exception) in a specified class.
         * @param failTaskType A class that should fail during the test.
         * @param runtimeConfig REEF runtime configuration. Can be e.g. Local or YARN.
         * @param timeOut REEF application timeout.
         * @return launcher status - usually FAIL.
         * @throws InjectionException configuration error.
         */

        public static LauncherStatus Run(Type failTaskType, IConfiguration runtimeConfig, TimeSpan timeout)
        {
            var driverRuntimeConfiguration = DriverRuntimeConfiguration.ConfigurationModule
                                             .Set(DriverRuntimeConfiguration.OsType, GenericType <OsWindows> .Class)
                                             .Set(DriverRuntimeConfiguration.JobId, "Fail_" + failTaskType.Name);

            driverRuntimeConfiguration = DriverRuntimeConfiguration
                                         .AddGlobalAssemblyForType(driverRuntimeConfiguration, typeof(Driver));

            var source = new CancellationTokenSource();

            source.CancelAfter(timeout);
            using (var launcher = ClientLauncherFactory.GetLauncher(runtimeConfig, driverRuntimeConfiguration.Build()))
            {
                var task = launcher.SubmitAsync(BuildAppDriverConfig(failTaskType), source.Token);
                try
                {
                    return(task.Result);
                }
                catch (Exception)
                {
                    if (task.IsCanceled)
                    {
                        throw new TimeoutException($"Job timed out after {timeout}");
                    }

                    throw;
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// Runs HelloREEF using the IREEFClient passed into the constructor.
        /// </summary>
        private void Run(string runtime)
        {
            // The driver configuration contains all the needed bindings.
            var helloDriverConfiguration = DriverApplicationConfiguration.ConfigurationModule
                                           .Set(DriverApplicationConfiguration.OnDriverStarted, GenericType <HelloDriver> .Class)
                                           .Set(DriverApplicationConfiguration.OnDriverStopped, GenericType <HelloDriver> .Class)
                                           .Set(DriverApplicationConfiguration.OnEvaluatorAllocated, GenericType <HelloDriver> .Class)
                                           .Set(DriverApplicationConfiguration.OnEvaluatorCompleted, GenericType <HelloDriver> .Class)
                                           .Set(DriverApplicationConfiguration.OnEvaluatorFailed, GenericType <HelloDriver> .Class)
                                           .Set(DriverApplicationConfiguration.OnContextActive, GenericType <HelloDriver> .Class)
                                           .Set(DriverApplicationConfiguration.OnTaskRunning, GenericType <HelloDriver> .Class)
                                           .Set(DriverApplicationConfiguration.OnTaskCompleted, GenericType <HelloDriver> .Class)
                                           .Set(DriverApplicationConfiguration.OnTaskFailed, GenericType <HelloDriver> .Class)
                                           .Set(DriverApplicationConfiguration.CustomTraceLevel, Level.Verbose.ToString())
                                           .Build();

            var applicationId = GetApplicationId();

            // The JobSubmission contains the Driver configuration as well as the files needed on the Driver.
            var driverRuntimeConfiguration = DriverRuntimeConfiguration.ConfigurationModule
                                             .Set(DriverRuntimeConfiguration.OsType, GenericType <OsLinux> .Class)
                                             .Set(DriverRuntimeConfiguration.JobId, applicationId);

            driverRuntimeConfiguration = DriverRuntimeConfiguration.AddGlobalAssemblyForType(driverRuntimeConfiguration, typeof(HelloDriver));

            var runtimeConfiguration = GetRuntimeConfiguration(runtime);

            using (var launcher = ClientLauncherFactory.GetLauncher(runtimeConfiguration, driverRuntimeConfiguration.Build()))
            {
                var launcherStatus = launcher.SubmitAsync(helloDriverConfiguration).Result;
                Log.Log(Level.Info, "Final Launch Status {0}", launcherStatus);
                if (launcherStatus.Error.IsPresent())
                {
                    throw launcherStatus.Error.Value;
                }
            }
        }