public ListenerFactory(FunctionDescriptor descriptor, ITriggeredFunctionExecutor executor, ITriggerBinding binding, SharedQueueHandler sharedQueue)
 {
     _descriptor  = descriptor;
     _executor    = executor;
     _binding     = binding;
     _sharedQueue = sharedQueue;
 }
Beispiel #2
0
        public FunctionIndexProvider(ITypeLocator typeLocator,
                                     ITriggerBindingProvider triggerBindingProvider,
                                     IBindingProvider bindingProvider,
                                     IJobActivator activator,
                                     IFunctionExecutor executor,
                                     IExtensionRegistry extensions,
                                     SingletonManager singletonManager,
                                     ILoggerFactory loggerFactory,
                                     SharedQueueHandler sharedQueue,
                                     TimeoutAttribute defaultTimeout,
                                     bool allowPartialHostStartup = false)
        {
            _typeLocator            = typeLocator ?? throw new ArgumentNullException(nameof(typeLocator));
            _triggerBindingProvider = triggerBindingProvider ?? throw new ArgumentNullException(nameof(triggerBindingProvider));
            _bindingProvider        = bindingProvider ?? throw new ArgumentNullException(nameof(bindingProvider));
            _activator        = activator ?? throw new ArgumentNullException(nameof(activator));
            _executor         = executor ?? throw new ArgumentNullException(nameof(executor));
            _extensions       = extensions ?? throw new ArgumentNullException(nameof(extensions));
            _singletonManager = singletonManager ?? throw new ArgumentNullException(nameof(singletonManager));
            _sharedQueue      = sharedQueue ?? throw new ArgumentNullException(nameof(sharedQueue));

            _loggerFactory           = loggerFactory;
            _defaultTimeout          = defaultTimeout;
            _allowPartialHostStartup = allowPartialHostStartup;
        }
        public FunctionIndexProvider(ITypeLocator typeLocator,
                                     ITriggerBindingProvider triggerBindingProvider,
                                     CompositeBindingProvider bindingProviderFactory,
                                     IJobActivator activator,
                                     IFunctionExecutor executor,
                                     IExtensionRegistry extensions,
                                     SingletonManager singletonManager,
                                     ILoggerFactory loggerFactory,
                                     SharedQueueHandler sharedQueue,
                                     IOptions <JobHostFunctionTimeoutOptions> timeoutOptions,
                                     IOptions <JobHostOptions> hostOptions)
        {
            _typeLocator            = typeLocator ?? throw new ArgumentNullException(nameof(typeLocator));
            _triggerBindingProvider = triggerBindingProvider ?? throw new ArgumentNullException(nameof(triggerBindingProvider));
            _bindingProviderFactory = bindingProviderFactory ?? throw new ArgumentNullException(nameof(bindingProviderFactory));
            _activator        = activator ?? throw new ArgumentNullException(nameof(activator));
            _executor         = executor ?? throw new ArgumentNullException(nameof(executor));
            _extensions       = extensions ?? throw new ArgumentNullException(nameof(extensions));
            _singletonManager = singletonManager ?? throw new ArgumentNullException(nameof(singletonManager));
            _sharedQueue      = sharedQueue ?? throw new ArgumentNullException(nameof(sharedQueue));

            _loggerFactory           = loggerFactory;
            _defaultTimeout          = timeoutOptions.Value.ToAttribute();
            _allowPartialHostStartup = hostOptions.Value.AllowPartialHostStartup;
        }
Beispiel #4
0
        public DispatchQueueTests()
        {
            _accountProviderMock = new Mock <IStorageAccountProvider>();
            IStorageAccountProvider accountProvider = new FakeStorageAccountProvider
            {
                StorageAccount = new FakeStorageAccount()
            };

            _accountProviderMock.Setup(m => m.TryGetAccountAsync(ConnectionStringNames.Storage, It.IsAny <CancellationToken>()))
            .Returns <string, CancellationToken>((name, cancel) => accountProvider.TryGetAccountAsync(name, cancel));

            _hostIdMock = new Mock <IHostIdProvider>();
            _hostIdMock.Setup(m => m.GetHostIdAsync(It.IsAny <CancellationToken>())).ReturnsAsync(HostId);

            _exceptionMock = new Mock <IWebJobsExceptionHandler>();

            _queueConfiguration = new FakeQueuesOptionsFactory(accountProvider).Create(string.Empty);

            _sharedContextProvider = new SharedContextProvider();

            _messageEnqueueSetterMock = new Mock <IContextSetter <IMessageEnqueuedWatcher> >();

            ILoggerFactory factory = new LoggerFactory();

            factory.AddProvider(_loggerProvider);

            _sharedQueue = new SharedQueueHandler(_accountProviderMock.Object,
                                                  _hostIdMock.Object,
                                                  _exceptionMock.Object,
                                                  factory,
                                                  new OptionsWrapper <JobHostQueuesOptions>(_queueConfiguration),
                                                  _sharedContextProvider,
                                                  _messageEnqueueSetterMock.Object
                                                  );
        }
Beispiel #5
0
 public DisableLegacyLogger(
     IFunctionExecutor functionExecutor,
     SharedQueueHandler sharedQueueHandler
     )
 {
     this._functionExecutor   = functionExecutor;
     this._sharedQueueHandler = sharedQueueHandler;
 }
Beispiel #6
0
        public FunctionIndexer(
            ITriggerBindingProvider triggerBindingProvider,
            IBindingProvider bindingProvider,
            IJobActivator activator,
            IFunctionExecutor executor,
            IExtensionRegistry extensions,
            SingletonManager singletonManager,
            ILoggerFactory loggerFactory,
            INameResolver nameResolver      = null,
            SharedQueueHandler sharedQueue  = null,
            TimeoutAttribute defaultTimeout = null,
            bool allowPartialHostStartup    = false)
        {
            if (triggerBindingProvider == null)
            {
                throw new ArgumentNullException("triggerBindingProvider");
            }

            if (bindingProvider == null)
            {
                throw new ArgumentNullException("bindingProvider");
            }

            if (activator == null)
            {
                throw new ArgumentNullException("activator");
            }

            if (executor == null)
            {
                throw new ArgumentNullException("executor");
            }

            if (extensions == null)
            {
                throw new ArgumentNullException("extensions");
            }

            if (singletonManager == null)
            {
                throw new ArgumentNullException("singletonManager");
            }

            _triggerBindingProvider = triggerBindingProvider;
            _bindingProvider        = bindingProvider;
            _activator              = activator;
            _executor               = executor;
            _singletonManager       = singletonManager;
            _jobAttributeAssemblies = GetJobAttributeAssemblies(extensions);
            _nameResolver           = nameResolver;
            _logger                  = loggerFactory?.CreateLogger(LogCategories.Startup);
            _sharedQueue             = sharedQueue;
            _defaultTimeout          = defaultTimeout;
            _allowPartialHostStartup = allowPartialHostStartup;
        }
 public DashboardLoggingSetup(
     StorageAccountOptions storageAccountOptions,
     IWebJobsExceptionHandler exceptionHandler,
     ILoggerFactory loggerFactory,
     IFunctionInstanceLogger functionInstanceLogger,
     IFunctionExecutor functionExecutor,
     SharedQueueHandler sharedQueueHandler,
     ILoadBalancerQueue storageServices
     )
 {
     _storageAccountOptions  = storageAccountOptions;
     _exceptionHandler       = exceptionHandler;
     _loggerFactory          = loggerFactory;
     _functionInstanceLogger = functionInstanceLogger;
     _functionExecutor       = functionExecutor;
     _sharedQueueHandler     = sharedQueueHandler;
     _storageServices        = storageServices;
 }
Beispiel #8
0
 public Legacy(
     LegacyConfig storageAccountProvider,
     IWebJobsExceptionHandler exceptionHandler,
     ILoggerFactory loggerFactory,
     IFunctionInstanceLogger functionInstanceLogger,
     IFunctionExecutor functionExecutor,
     SharedQueueHandler sharedQueueHandler,
     ILoadBalancerQueue storageServices
     )
 {
     _storageAccountProvider = storageAccountProvider;
     _exceptionHandler       = exceptionHandler;
     _loggerFactory          = loggerFactory;
     _functionInstanceLogger = functionInstanceLogger;
     _functionExecutor       = functionExecutor;
     _sharedQueueHandler     = sharedQueueHandler;
     _storageServices        = storageServices;
 }
 public JobHostContextFactory(
     IDashboardLoggingSetup dashboardLoggingSetup,
     IFunctionExecutor functionExecutor,
     IFunctionIndexProvider functionIndexProvider,
     ITriggerBindingProvider triggerBindingProvider,
     SingletonManager singletonManager,
     IJobActivator activator,
     IHostIdProvider hostIdProvider,
     INameResolver nameResolver,
     IExtensionRegistry extensions,
     ILoggerFactory loggerFactory,
     IWebJobsExceptionHandler exceptionHandler,
     SharedQueueHandler sharedQueueHandler,
     IOptions <JobHostOptions> jobHostOptions,
     IHostInstanceLogger hostInstanceLogger,
     IFunctionInstanceLogger functionInstanceLogger,
     IFunctionOutputLogger functionOutputLogger,
     IConverterManager converterManager,
     IAsyncCollector <FunctionInstanceLogEntry> eventCollector)
 {
     _dashboardLoggingSetup  = dashboardLoggingSetup;
     _functionExecutor       = functionExecutor;
     _functionIndexProvider  = functionIndexProvider;
     _triggerBindingProvider = triggerBindingProvider;
     _singletonManager       = singletonManager;
     _activator              = activator;
     _hostIdProvider         = hostIdProvider;
     _nameResolver           = nameResolver;
     _extensions             = extensions;
     _loggerFactory          = loggerFactory;
     _exceptionHandler       = exceptionHandler;
     _sharedQueueHandler     = sharedQueueHandler;
     _jobHostOptions         = jobHostOptions;
     _hostInstanceLogger     = hostInstanceLogger;
     _functionInstanceLogger = functionInstanceLogger;
     _functionOutputLogger   = functionOutputLogger;
     _converterManager       = converterManager;
     _eventCollector         = eventCollector;
 }
 public FunctionIndexer(
     ITriggerBindingProvider triggerBindingProvider,
     IBindingProvider bindingProvider,
     IJobActivator activator,
     IFunctionExecutor executor,
     SingletonManager singletonManager,
     ILoggerFactory loggerFactory,
     INameResolver nameResolver      = null,
     SharedQueueHandler sharedQueue  = null,
     TimeoutAttribute defaultTimeout = null,
     bool allowPartialHostStartup    = false)
 {
     _triggerBindingProvider = triggerBindingProvider ?? throw new ArgumentNullException(nameof(triggerBindingProvider));
     _bindingProvider        = bindingProvider ?? throw new ArgumentNullException(nameof(bindingProvider));
     _activator               = activator ?? throw new ArgumentNullException(nameof(activator));
     _executor                = executor ?? throw new ArgumentNullException(nameof(executor));
     _singletonManager        = singletonManager ?? throw new ArgumentNullException(nameof(singletonManager));
     _nameResolver            = nameResolver;
     _logger                  = loggerFactory?.CreateLogger(LogCategories.Startup);
     _sharedQueue             = sharedQueue;
     _defaultTimeout          = defaultTimeout;
     _allowPartialHostStartup = allowPartialHostStartup;
 }
Beispiel #11
0
 /// <summary>
 /// Creates a new instance
 /// </summary>
 /// <param name="descriptor">The <see cref="FunctionDescriptor"/> to create a listener for.</param>
 /// <param name="executor">The <see cref="ITriggeredFunctionExecutor"/> that should be used to invoke the
 /// target job function when the trigger fires.</param>
 /// <param name="sharedQueue">The shared queue.</param>
 /// <param name="cancellationToken">The <see cref="CancellationToken"/> to use.</param>
 internal ListenerFactoryContext(FunctionDescriptor descriptor, ITriggeredFunctionExecutor executor, SharedQueueHandler sharedQueue, CancellationToken cancellationToken)
     : this(descriptor, executor, cancellationToken)
 {
     _sharedQueue = sharedQueue;
 }
        internal static IListener CreateHostListener(IListenerFactory allFunctionsListenerFactory, SharedQueueHandler sharedQueue,
                                                     IRecurrentCommand heartbeatCommand, IWebJobsExceptionHandler exceptionHandler, CancellationToken shutdownToken)
        {
            IListener factoryListener   = new ListenerFactoryListener(allFunctionsListenerFactory, sharedQueue);
            IListener heartbeatListener = new HeartbeatListener(heartbeatCommand, exceptionHandler, factoryListener);
            IListener shutdownListener  = new ShutdownListener(shutdownToken, heartbeatListener);

            return(shutdownListener);
        }
Beispiel #13
0
        // Do the full runtime intitialization. This includes static initialization.
        // This mainly means:
        // - indexing the functions
        // - spinning up the listeners (so connecting to the services)
        public static async Task <JobHostContext> CreateJobHostContextAsync(
            this JobHostConfiguration config,
            ServiceProviderWrapper services, // Results from first phase
            JobHost host,
            CancellationToken shutdownToken,
            CancellationToken cancellationToken)
        {
            FunctionExecutor                           functionExecutor       = services.GetService <FunctionExecutor>();
            IFunctionIndexProvider                     functionIndexProvider  = services.GetService <IFunctionIndexProvider>();
            ITriggerBindingProvider                    triggerBindingProvider = services.GetService <ITriggerBindingProvider>();
            IBindingProvider                           bindingProvider        = services.GetService <IBindingProvider>();
            SingletonManager                           singletonManager       = services.GetService <SingletonManager>();
            IJobActivator                              activator              = services.GetService <IJobActivator>();
            IHostIdProvider                            hostIdProvider         = services.GetService <IHostIdProvider>();
            INameResolver                              nameResolver           = services.GetService <INameResolver>();
            IExtensionRegistry                         extensions             = services.GetExtensions();
            IStorageAccountProvider                    storageAccountProvider = services.GetService <IStorageAccountProvider>();
            ILoggerFactory                             loggerFactory          = services.GetService <ILoggerFactory>();
            IFunctionResultAggregatorFactory           aggregatorFactory      = services.GetService <IFunctionResultAggregatorFactory>();
            IAsyncCollector <FunctionInstanceLogEntry> functionEventCollector = null;
            SharedQueueHandler                         hostSharedQueue        = services.GetService <SharedQueueHandler>();

            // Create the aggregator if all the pieces are configured
            IAsyncCollector <FunctionInstanceLogEntry> aggregator = null;

            if (loggerFactory != null && aggregatorFactory != null && config.Aggregator.IsEnabled)
            {
                aggregator = aggregatorFactory.Create(config.Aggregator.BatchSize, config.Aggregator.FlushTimeout, loggerFactory);
            }

            IQueueConfiguration queueConfiguration = services.GetService <IQueueConfiguration>();
            var blobsConfiguration = config.Blobs;

            IAsyncCollector <FunctionInstanceLogEntry> registeredFunctionEventCollector = services.GetService <IAsyncCollector <FunctionInstanceLogEntry> >();

            if (registeredFunctionEventCollector != null && aggregator != null)
            {
                // If there are both an aggregator and a registered FunctionEventCollector, wrap them in a composite
                functionEventCollector = new CompositeFunctionEventCollector(new[] { registeredFunctionEventCollector, aggregator });
            }
            else
            {
                // Otherwise, take whichever one is null (or use null if both are)
                functionEventCollector = aggregator ?? registeredFunctionEventCollector;
            }

            IWebJobsExceptionHandler exceptionHandler = services.GetService <IWebJobsExceptionHandler>();

            if (exceptionHandler != null)
            {
                exceptionHandler.Initialize(host);
            }

            bool hasFastTableHook   = services.GetService <IAsyncCollector <FunctionInstanceLogEntry> >() != null;
            bool noDashboardStorage = config.DashboardConnectionString == null;

            // Only testing will override these interfaces.
            IHostInstanceLoggerProvider     hostInstanceLoggerProvider     = services.GetService <IHostInstanceLoggerProvider>();
            IFunctionInstanceLoggerProvider functionInstanceLoggerProvider = services.GetService <IFunctionInstanceLoggerProvider>();
            IFunctionOutputLoggerProvider   functionOutputLoggerProvider   = services.GetService <IFunctionOutputLoggerProvider>();

            if (hostInstanceLoggerProvider == null && functionInstanceLoggerProvider == null && functionOutputLoggerProvider == null)
            {
                if (hasFastTableHook && noDashboardStorage)
                {
                    var loggerProvider = new FastTableLoggerProvider(loggerFactory);
                    hostInstanceLoggerProvider     = loggerProvider;
                    functionInstanceLoggerProvider = loggerProvider;
                    functionOutputLoggerProvider   = loggerProvider;
                }
                else
                {
                    var loggerProvider = new DefaultLoggerProvider(storageAccountProvider, loggerFactory);
                    hostInstanceLoggerProvider     = loggerProvider;
                    functionInstanceLoggerProvider = loggerProvider;
                    functionOutputLoggerProvider   = loggerProvider;
                }
            }

            using (CancellationTokenSource combinedCancellationSource = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, shutdownToken))
            {
                CancellationToken combinedCancellationToken = combinedCancellationSource.Token;

                await WriteSiteExtensionManifestAsync(combinedCancellationToken);

                IStorageAccount dashboardAccount = await storageAccountProvider.GetDashboardAccountAsync(combinedCancellationToken);

                IHostInstanceLogger hostInstanceLogger = await hostInstanceLoggerProvider.GetAsync(combinedCancellationToken);

                IFunctionInstanceLogger functionInstanceLogger = await functionInstanceLoggerProvider.GetAsync(combinedCancellationToken);

                IFunctionOutputLogger functionOutputLogger = await functionOutputLoggerProvider.GetAsync(combinedCancellationToken);

                loggerFactory.AddProvider(new FunctionOutputLoggerProvider());

                if (functionExecutor == null)
                {
                    var extensionRegistry     = config.GetService <IExtensionRegistry>();
                    var globalFunctionFilters = extensionRegistry.GetFunctionFilters();

                    functionExecutor = new FunctionExecutor(functionInstanceLogger, functionOutputLogger, exceptionHandler, functionEventCollector, loggerFactory, globalFunctionFilters);
                    services.AddService(functionExecutor);
                }

                if (functionIndexProvider == null)
                {
                    var defaultTimeout = config.FunctionTimeout?.ToAttribute();
                    functionIndexProvider = new FunctionIndexProvider(
                        services.GetService <ITypeLocator>(),
                        triggerBindingProvider,
                        bindingProvider,
                        activator,
                        functionExecutor,
                        extensions,
                        singletonManager,
                        loggerFactory,
                        hostSharedQueue,
                        defaultTimeout);

                    // Important to set this so that the func we passed to DynamicHostIdProvider can pick it up.
                    services.AddService <IFunctionIndexProvider>(functionIndexProvider);
                }

                IFunctionIndex functions = await functionIndexProvider.GetAsync(combinedCancellationToken);

                IListenerFactory functionsListenerFactory = new HostListenerFactory(functions.ReadAll(), singletonManager, activator, nameResolver, loggerFactory);

                IFunctionExecutor hostCallExecutor;
                IListener         listener;
                HostOutputMessage hostOutputMessage;

                string hostId = await hostIdProvider.GetHostIdAsync(cancellationToken);

                if (string.Compare(config.HostId, hostId, StringComparison.OrdinalIgnoreCase) != 0)
                {
                    // if this isn't a static host ID, provide the HostId on the config
                    // so it is accessible
                    config.HostId = hostId;
                }

                if (dashboardAccount == null)
                {
                    hostCallExecutor = new ShutdownFunctionExecutor(shutdownToken, functionExecutor);

                    IListener factoryListener  = new ListenerFactoryListener(functionsListenerFactory, hostSharedQueue);
                    IListener shutdownListener = new ShutdownListener(shutdownToken, factoryListener);
                    listener = shutdownListener;

                    hostOutputMessage = new DataOnlyHostOutputMessage();
                }
                else
                {
                    string sharedQueueName = HostQueueNames.GetHostQueueName(hostId);
                    IStorageQueueClient dashboardQueueClient       = dashboardAccount.CreateQueueClient();
                    IStorageQueue       sharedQueue                = dashboardQueueClient.GetQueueReference(sharedQueueName);
                    IListenerFactory    sharedQueueListenerFactory = new HostMessageListenerFactory(sharedQueue,
                                                                                                    queueConfiguration, exceptionHandler, loggerFactory, functions,
                                                                                                    functionInstanceLogger, functionExecutor);

                    Guid             hostInstanceId               = Guid.NewGuid();
                    string           instanceQueueName            = HostQueueNames.GetHostQueueName(hostInstanceId.ToString("N"));
                    IStorageQueue    instanceQueue                = dashboardQueueClient.GetQueueReference(instanceQueueName);
                    IListenerFactory instanceQueueListenerFactory = new HostMessageListenerFactory(instanceQueue,
                                                                                                   queueConfiguration, exceptionHandler, loggerFactory, functions,
                                                                                                   functionInstanceLogger, functionExecutor);

                    HeartbeatDescriptor heartbeatDescriptor = new HeartbeatDescriptor
                    {
                        SharedContainerName = HostContainerNames.Hosts,
                        SharedDirectoryName = HostDirectoryNames.Heartbeats + "/" + hostId,
                        InstanceBlobName    = hostInstanceId.ToString("N"),
                        ExpirationInSeconds = (int)HeartbeatIntervals.ExpirationInterval.TotalSeconds
                    };

                    IStorageBlockBlob blob = dashboardAccount.CreateBlobClient()
                                             .GetContainerReference(heartbeatDescriptor.SharedContainerName)
                                             .GetBlockBlobReference(heartbeatDescriptor.SharedDirectoryName + "/" + heartbeatDescriptor.InstanceBlobName);
                    IRecurrentCommand heartbeatCommand = new UpdateHostHeartbeatCommand(new HeartbeatCommand(blob));

                    IEnumerable <MethodInfo> indexedMethods = functions.ReadAllMethods();
                    Assembly hostAssembly = GetHostAssembly(indexedMethods);
                    string   displayName  = hostAssembly != null?AssemblyNameCache.GetName(hostAssembly).Name : "Unknown";

                    hostOutputMessage = new DataOnlyHostOutputMessage
                    {
                        HostInstanceId      = hostInstanceId,
                        HostDisplayName     = displayName,
                        SharedQueueName     = sharedQueueName,
                        InstanceQueueName   = instanceQueueName,
                        Heartbeat           = heartbeatDescriptor,
                        WebJobRunIdentifier = WebJobRunIdentifier.Current
                    };

                    hostCallExecutor = CreateHostCallExecutor(instanceQueueListenerFactory, heartbeatCommand,
                                                              exceptionHandler, shutdownToken, functionExecutor);
                    IListenerFactory hostListenerFactory = new CompositeListenerFactory(functionsListenerFactory,
                                                                                        sharedQueueListenerFactory, instanceQueueListenerFactory);
                    listener = CreateHostListener(hostListenerFactory, hostSharedQueue, heartbeatCommand, exceptionHandler, shutdownToken);

                    // Publish this to Azure logging account so that a web dashboard can see it.
                    await LogHostStartedAsync(functions, hostOutputMessage, hostInstanceLogger, combinedCancellationToken);
                }

                functionExecutor.HostOutputMessage = hostOutputMessage;

                IEnumerable <FunctionDescriptor> descriptors = functions.ReadAllDescriptors();
                int descriptorsCount = descriptors.Count();

                ILogger startupLogger = loggerFactory?.CreateLogger(LogCategories.Startup);

                if (config.UsingDevelopmentSettings)
                {
                    string msg = "Development settings applied";
                    startupLogger?.LogDebug(msg);
                }

                if (descriptorsCount == 0)
                {
                    string msg = string.Format("No job functions found. Try making your job classes and methods public. {0}",
                                               Constants.ExtensionInitializationMessage);

                    startupLogger?.LogWarning(msg);
                }
                else
                {
                    StringBuilder functionsTrace = new StringBuilder();
                    functionsTrace.AppendLine("Found the following functions:");

                    foreach (FunctionDescriptor descriptor in descriptors)
                    {
                        functionsTrace.AppendLine(descriptor.FullName);
                    }
                    string msg = functionsTrace.ToString();
                    startupLogger?.LogInformation(msg);
                }

                return(new JobHostContext(
                           functions,
                           hostCallExecutor,
                           listener,
                           functionEventCollector,
                           loggerFactory));
            }
        }
 public NullDashboardLoggingSetup(IFunctionExecutor functionExecutor, SharedQueueHandler sharedQueueHandler)
 {
     this._functionExecutor   = functionExecutor;
     this._sharedQueueHandler = sharedQueueHandler;
 }
Beispiel #15
0
 public ListenerFactoryListener(IListenerFactory factory, SharedQueueHandler sharedQueue)
 {
     _factory            = factory;
     _sharedQueue        = sharedQueue;
     _cancellationSource = new CancellationTokenSource();
 }