<commit_before>﻿using System;
using System.Threading.Tasks;
using Microsoft.AspNet.SignalR;
using Superpose.StorageInterface;
using SuperposeLib.Core;

namespace SuperposeLib.Owin
{
    // SuperposeGlobalConfiguration.JobQueue
    public class MyHub : Hub
    {

        public void GetCurrentQueue()
        {
            Clients.All.currentQueue(SuperposeGlobalConfiguration.JobQueue);
        }
        public void SetQueueMaxNumberOfJobsPerLoad(int maxNumberOfJobsPerLoad)
        {
            SuperposeGlobalConfiguration.JobQueue.MaxNumberOfJobsPerLoad = maxNumberOfJobsPerLoad;
            GetCurrentQueue();
        }
        public void SetQueueStorgePollSecondsInterval(int storgePollSecondsInterval)
        {
            SuperposeGlobalConfiguration.JobQueue.StorgePollSecondsInterval = storgePollSecondsInterval;
            GetCurrentQueue();
        }
        public void SetQueueWorkerPoolCount(int workerPoolCount)
        {
            SuperposeGlobalConfiguration.JobQueue.WorkerPoolCount = workerPoolCount;
            GetCurrentQueue();
        }

        public void QueueSampleJob()
        {
            const int total = 1000000;
            for (var i = 0; i < total; i++)
            {
                JobHandler.EnqueueJob<TestJob>();
            }
            GetJobStatistics();
        }

        public void GetJobStatistics()
        {
            using (var storage = SuperposeGlobalConfiguration.StorageFactory.CreateJobStorage())
            {
                var jobStatistics = storage.JobLoader.GetJobStatistics();
                Clients.All.jobStatisticsCompleted(jobStatistics);
            }
        }
    }

    public class TestJob:AJob
    {
        protected override void Execute()
        {
           // throw  new Exception();
            Task.WaitAll(Task.Delay(TimeSpan.FromMilliseconds(100)));
            // Console.WriteLine("woooo!");
        }
    }

    public class SuperposeSignalRContext
    {
        public static IHubContext GetHubContext()
        {
            return GlobalHost.ConnectionManager.GetHubContext<MyHub>();
        }
    }
}<commit_msg>trying to create a failure situation<commit_after>﻿using System;
using System.Threading.Tasks;
using Microsoft.AspNet.SignalR;
using Superpose.StorageInterface;
using SuperposeLib.Core;

namespace SuperposeLib.Owin
{
    // SuperposeGlobalConfiguration.JobQueue
    public class MyHub : Hub
    {

        public void GetCurrentQueue()
        {
            Clients.All.currentQueue(SuperposeGlobalConfiguration.JobQueue);
        }
        public void SetQueueMaxNumberOfJobsPerLoad(int maxNumberOfJobsPerLoad)
        {
            SuperposeGlobalConfiguration.JobQueue.MaxNumberOfJobsPerLoad = maxNumberOfJobsPerLoad;
            GetCurrentQueue();
        }
        public void SetQueueStorgePollSecondsInterval(int storgePollSecondsInterval)
        {
            SuperposeGlobalConfiguration.JobQueue.StorgePollSecondsInterval = storgePollSecondsInterval;
            GetCurrentQueue();
        }
        public void SetQueueWorkerPoolCount(int workerPoolCount)
        {
            SuperposeGlobalConfiguration.JobQueue.WorkerPoolCount = workerPoolCount;
            GetCurrentQueue();
        }

        public void QueueSampleJob()
        {
            const int total = 1000000;
          
            for (var i = 0; i < total; i++)
            {
                Parallel.Invoke(() => JobHandler.EnqueueJob<TestJob>());
            }
            GetJobStatistics();
        }

        public void GetJobStatistics()
        {
            using (var storage = SuperposeGlobalConfiguration.StorageFactory.CreateJobStorage())
            {
                var jobStatistics = storage.JobLoader.GetJobStatistics();
                Clients.All.jobStatisticsCompleted(jobStatistics);
            }
        }
    }

    public class TestJob:AJob
    {
        public override SuperVisionDecision Supervision(Exception reaon, int totalNumberOfHistoricFailures)
        {
            return SuperVisionDecision.Fail;
        }

        protected override void Execute()
        { 
            if(DateTime.Now.Second%19==0)
            throw  new Exception();

            Task.WaitAll(Task.Delay(TimeSpan.FromMilliseconds(10)));
            // Console.WriteLine("woooo!");
        }
    }

    public class SuperposeSignalRContext
    {
        public static IHubContext GetHubContext()
        {

            return GlobalHost.ConnectionManager.GetHubContext<MyHub>();
        }
    }
}
{'fraction_non_alphanumeric': 0.07518296739853626, 'fraction_numerical': 0.0053226879574184965, 'mean_word_length': 2.1254331254331253, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2069366', 'n_tokens_mistral': 1158, 'n_tokens_neox': 1118, 'n_words': 196}