Beispiel #1
0
 public static IDisposable Use(IDaemon daemon)
 {
     if (daemon == null) throw new ArgumentNullException("daemon");
     if(_currentStack == null) _currentStack = new Stack<IDaemon>();
     _currentStack.Push(daemon);
     return UseDisposer.Instance;
 }
Beispiel #2
0
        public void TestSetup()
        {
            factory = Substitute.For <IStreamStateFactory>();
            factory.Create(Arg.Any <string>()).Returns(_ => state);

            state = Substitute.For <IStreamState>();
            state.BufferPool.Returns(_ => pool);
            state.Statistics.Returns(_ => stats);
            state.RecordWriter.Returns(_ => writer);
            state.SendSignal.Returns(new AsyncManualResetEvent(false));

            buffer = Substitute.For <IBuffer>();
            writer = Substitute.For <IRecordWriter>();
            stats  = Substitute.For <IStatisticsCollector>();
            daemon = Substitute.For <IDaemon>();

            pool = Substitute.For <IBufferPool>();
            pool.TryAcquire(out _)
            .Returns(
                info =>
            {
                info[0] = buffer;
                return(true);
            });

            log = new SynchronousConsoleLog();

            sink = new HerculesSink(factory, daemon, log);
        }
 public AsyncProjectionsService(IDocumentStore store)
 {
     daemon = store.BuildProjectionDaemon(settings: new DaemonSettings
     {
         LeadingEdgeBuffer = 0.Seconds()
     });
 }
Beispiel #4
0
        /// <summary>
        /// This method provides a <see cref="IDaemonStageProcess"/> instance which is assigned to highlighting a single document.
        /// </summary>
        /// <param name="process">
        /// Current Daemon Process.
        /// </param>
        /// <param name="settingsStore">
        /// The settingsStore store to use.
        /// </param>
        /// <param name="processKind">
        /// The process kind.
        /// </param>
        /// <param name="file">
        /// The file to analyze.
        /// </param>
        /// ///
        /// <returns>
        /// The current <see cref="IDaemonStageProcess"/>.
        /// </returns>
        protected override IDaemonStageProcess CreateProcess(
            IDaemonProcess process, IContextBoundSettingsStore settingsStore, DaemonProcessKind processKind, ICSharpFile file)
        {
            StyleCopTrace.In(process, settingsStore, processKind, file);

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

            try
            {
                if (processKind == DaemonProcessKind.OTHER)
                {
                    StyleCopTrace.Info("ProcessKind Other.");
                    StyleCopTrace.Out();
                    return(null);
                }

                if (!this.IsAnalysisEnabled(settingsStore, file))
                {
                    StyleCopTrace.Info("Analysis disabled.");
                    StyleCopTrace.Out();
                    return(null);
                }

                if (!this.IsSupported(process.SourceFile))
                {
                    StyleCopTrace.Info("File type not supported.");
                    StyleCopTrace.Out();
                    return(null);
                }

                if (!this.FileIsValid(file))
                {
                    StyleCopTrace.Info("Source file not valid.");
                    StyleCopTrace.Out();
                    return(null);
                }

                if (!settingsStore.GetValue <StyleCopOptionsSettingsKey, bool>(key => key.AnalyzeReadOnlyFiles))
                {
                    if (process.SourceFile.Properties.IsNonUserFile)
                    {
                        StyleCopTrace.Info("Not analysing non user files.");
                        StyleCopTrace.Out();
                        return(null);
                    }
                }

                IDaemon daemon = file.GetSolution().GetComponent <IDaemon>();

                return(StyleCopTrace.Out(new StyleCopStageProcess(this.lifetime, this.apiPool, daemon, process, this.threading, file)));
            }
            catch (JetBrains.Application.Progress.ProcessCancelledException)
            {
                return(null);
            }
        }
Beispiel #5
0
 public CommandSet()
 {
     _resetEvent = new ManualResetEvent(false);
     _logger = new SimpleLogger();
     _daemon = new MyDaemon(_logger, _resetEvent);
     var config = new WindowsServiceConfiguration("aa1") { CommandLineArguments = "windows-service --start" };
     _service = new WindowsService(_daemon, config);
 }
 /// <summary>
 /// When daemon is not initialized, the DefaultDaemon is used.
 /// </summary>
 public static IDaemon GetDaemon()
 {
     lock (m_lock)
     {
         if (s_daemon == null)
             s_daemon = new DefaultDaemon();
     }
     return s_daemon;
 }
        public assert_if_daemon_is_running_on_wait_methods()
        {
            StoreOptions(_ =>
            {
                _.Events.AsyncProjections.AggregateStreamsWith <ActiveProject>();
                _.Events.AsyncProjections.TransformEvents(new CommitViewTransform());
            });

            theDaemon = theStore.BuildProjectionDaemon();
        }
        public assert_if_daemon_is_running_on_wait_methods(DefaultStoreFixture fixture) : base(fixture)
        {
            StoreOptions(_ =>
            {
                _.Events.V4Projections.AsyncSelfAggregate <ActiveProject>();
                _.Events.V4Projections.Async(new CommitViewTransform());
            });

            theDaemon = theStore.BuildProjectionDaemon();
        }
Beispiel #9
0
        private void TcpProcess(IDaemon daemon, LowLevelTcpConnection connection)
        {
            Buffer buffer =
                new Buffer()
            {
                Segment = new ArraySegment <byte>(new byte[2048])
            };

            ReadOne(buffer, connection);
        }
Beispiel #10
0
 private static void Increment(IDaemon daemon, int i)
 {
     _countArray[i]++;
     if (_countArray[i] != _messagesPerProcess)
     {
         daemon.Schedule(() => Increment(daemon, i));
         return;
     }
     if(Interlocked.Decrement(ref _countDown) == 0)
         Console.WriteLine("Time: {0}", (DateTime.UtcNow - _start));
 }
Beispiel #11
0
 /// <summary>
 /// When daemon is not initialized, the DefaultDaemon is used.
 /// </summary>
 public static IDaemon GetDaemon()
 {
     lock (m_lock)
     {
         if (s_daemon == null)
         {
             s_daemon = new DefaultDaemon();
         }
     }
     return(s_daemon);
 }
            public DaemonData(Lifetime lifetime, IThreading threading, IDaemon daemon, IDocument document)
            {
                this.lastCalledTimestamp = DateTime.MinValue;

                this.groupingEvent = threading.GroupingEvents.CreateEvent(
                    lifetime,
                    "StyleCop::ReHighlight",
                    PauseDuration,
                    Rgc.Guarded,
                    () => ReadLockCookie.Execute(() => daemon.ForceReHighlight(document)));
            }
        /// <summary>
        /// Initializes a new instance of the StyleCopStageProcess class, using the specified <see cref="IDaemonProcess"/> .
        /// </summary>
        /// <param name="lifetime">
        /// The <see cref="Lifetime"/> of the owning <see cref="IDaemonProcess"/>
        /// </param>
        /// <param name="apiPool">
        /// A reference to the StyleCop runner.
        /// </param>
        /// <param name="daemon">
        /// A reference to the <see cref="IDaemon"/> manager.
        /// </param>
        /// <param name="daemonProcess">
        /// <see cref="IDaemonProcess"/> to execute within. 
        /// </param>
        /// <param name="threading">
        /// A reference to the <see cref="IThreading"/> instance for timed actions.
        /// </param>
        /// <param name="file">
        /// The file to analyze.
        /// </param>
        public StyleCopStageProcess(Lifetime lifetime, StyleCopApiPool apiPool, IDaemon daemon, IDaemonProcess daemonProcess, IThreading threading, ICSharpFile file)
        {
            StyleCopTrace.In(daemonProcess, file);

            this.lifetime = lifetime;
            this.apiPool = apiPool;
            this.daemon = daemon;
            this.daemonProcess = daemonProcess;
            this.threading = threading;
            this.file = file;

            StyleCopTrace.Out();
        }
Beispiel #14
0
 public static IDisposable Use(IDaemon daemon)
 {
     if (daemon == null)
     {
         throw new ArgumentNullException("daemon");
     }
     if (_currentStack == null)
     {
         _currentStack = new Stack <IDaemon>();
     }
     _currentStack.Push(daemon);
     return(UseDisposer.Instance);
 }
Beispiel #15
0
        private static async Task RunDaemonAsync(IDaemon daemon)
        {
            var task = daemon.RunAsync();

            AppDomain.CurrentDomain.ProcessExit += async(object?sender, EventArgs e) =>
            {
                daemon.Stop();

                await task;
            };

            await task;
        }
Beispiel #16
0
 private static void Increment(IDaemon daemon, int i)
 {
     _countArray[i]++;
     if (_countArray[i] != _messagesPerProcess)
     {
         daemon.Schedule(() => Increment(daemon, i));
         return;
     }
     if (Interlocked.Decrement(ref _countDown) == 0)
     {
         Console.WriteLine("Time: {0}", (DateTime.UtcNow - _start));
     }
 }
Beispiel #17
0
        /// <summary>
        /// Initializes a new instance of the StyleCopStageProcess class, using the specified <see cref="IDaemonProcess"/> .
        /// </summary>
        /// <param name="lifetime">
        /// The <see cref="Lifetime"/> of the owning <see cref="IDaemonProcess"/>
        /// </param>
        /// <param name="apiPool">
        /// A reference to the StyleCop runner.
        /// </param>
        /// <param name="daemon">
        /// A reference to the <see cref="IDaemon"/> manager.
        /// </param>
        /// <param name="daemonProcess">
        /// <see cref="IDaemonProcess"/> to execute within.
        /// </param>
        /// <param name="threading">
        /// A reference to the <see cref="IThreading"/> instance for timed actions.
        /// </param>
        /// <param name="file">
        /// The file to analyze.
        /// </param>
        public StyleCopStageProcess(Lifetime lifetime, StyleCopApiPool apiPool, IDaemon daemon, IDaemonProcess daemonProcess, IThreading threading, ICSharpFile file)
        {
            StyleCopTrace.In(daemonProcess, file);

            this.lifetime      = lifetime;
            this.apiPool       = apiPool;
            this.daemon        = daemon;
            this.daemonProcess = daemonProcess;
            this.threading     = threading;
            this.file          = file;

            StyleCopTrace.Out();
        }
 public static bool InitTypeLibResourceManager(IDaemon daemon)
 {
     bool success = false;
     lock (m_lock)
     {
         if (s_daemon == null)
         {
             s_daemon = daemon;
             success = true;
         }
     }
     return success;
 }
Beispiel #19
0
        public static bool InitTypeLibResourceManager(IDaemon daemon)
        {
            bool success = false;

            lock (m_lock)
            {
                if (s_daemon == null)
                {
                    s_daemon = daemon;
                    success  = true;
                }
            }
            return(success);
        }
        public WindowsService(IDaemon daemon, IWindowsServiceConfiguration configuration)
        {
            if (configuration == null)
                throw new ArgumentNullException("configuration");

            if (configuration.ServiceName == null)
                throw new ArgumentNullException("configuration", "ServiceName cannot be null");

            _daemon = daemon;
            _configuration = configuration;

            EventLog.Log = "Application";
            ServiceName = _configuration.ServiceName;
            CanStop = true;
            CanShutdown = true;
        }
Beispiel #21
0
        public Task StartAsync(CancellationToken cancellationToken)
        {
            Logger.Information("Projections starting");

            var settings = new DaemonSettings
            {
                FetchingCooldown  = 500.Milliseconds(),
                LeadingEdgeBuffer = 100.Milliseconds()
            };

            _daemon = _store.BuildProjectionDaemon(
                logger: new SerilogDaemonLogger(),
                settings: settings
                );
            _daemon.StartAll();
            return(Task.CompletedTask);
        }
Beispiel #22
0
        public WindowsService(IDaemon daemon, IWindowsServiceConfiguration configuration)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }

            if (configuration.ServiceName == null)
            {
                throw new ArgumentNullException("configuration", "ServiceName cannot be null");
            }

            _daemon        = daemon;
            _configuration = configuration;

            EventLog.Log = "Application";
            ServiceName  = _configuration.ServiceName;
            CanStop      = true;
            CanShutdown  = true;
        }
Beispiel #23
0
 internal HerculesSink(IStreamStateFactory streamStateFactory, IDaemon daemon, ILog log)
 {
     state = new State(streamStateFactory, daemon, log, new ConcurrentDictionary <string, Lazy <IStreamState> >());
 }
        public InvalidateOnSettingsChange(Lifetime lifetime, IDaemon daemon, ISettingsStore settingsStore)
        {
            var settingsKey = settingsStore.Schema.GetKey <CleanCodeSettings>();

            settingsStore.AdviseChange(lifetime, settingsKey, daemon.Invalidate);
        }
Beispiel #25
0
 public void Initialize(IReactor reactor, IDaemon daemon)
 {
     reactor.Daemon = daemon;
     daemon.Schedule(reactor.Initialize);
 }
Beispiel #26
0
        private static void InvalidateDaemon(ISolution solution)
        {
            IDaemon component = solution.TryGetComponent <IDaemon>();

            component?.Invalidate();
        }
 public WindowsService(string serviceName, IDaemon daemon, Action<WindowsServiceConfiguration> configure) : 
     this(daemon, SetConfiguration(serviceName, configure))
 {
 }
Beispiel #28
0
 public LowLevelTcpConnection(TcpClient client, IDaemon daemon)
 {
     _client = client;
     _daemon = daemon;
     _stream = _client.GetStream();
 }
Beispiel #29
0
 public void Initialize(IReactor reactor, IDaemon daemon)
 {
     reactor.Daemon = daemon;
     daemon.Schedule(reactor.Initialize);
 }
 public InvalidateOnSettingsChange(Lifetime lifetime, IDaemon daemon, ISettingsStore settingsStore)
 {
     var settingsKey = settingsStore.Schema.GetKey<CleanCodeSettings>();
     settingsStore.AdviseChange(lifetime, settingsKey, daemon.Invalidate);
 }
 public DaemonErrorHandler(IDaemon daemon, IDaemonLogger logger, ExceptionHandling handling)
 {
     _daemon = daemon;
     _logger = logger;
     _handling = handling;
 }
 public ComplexityAnalysisInvalidateOnThresholdChange(Lifetime lifetime, IDaemon daemon, ISettingsStore settingsStore)
 {
     var settingsKey = settingsStore.Schema.GetKey<CyclomaticComplexityAnalysisSettings>();
       settingsStore.AdviseChange(lifetime, settingsKey, daemon.Invalidate);
 }
            public DaemonData(Lifetime lifetime, IThreading threading, IDaemon daemon, IDocument document)
            {
                this.lastCalledTimestamp = DateTime.MinValue;

                this.groupingEvent = threading.GroupingEvents.CreateEvent(
                    lifetime,
                    "StyleCop::ReHighlight",
                    PauseDuration,
                    Rgc.Guarded,
                    () => ReadLockCookie.Execute(() => daemon.ForceReHighlight(document)));
            }
        public ComplexityAnalysisInvalidateOnThresholdChange(Lifetime lifetime, IDaemon daemon, ISettingsStore settingsStore)
        {
            var settingsKey = settingsStore.Schema.GetKey <CyclomaticComplexityAnalysisSettings>();

            settingsStore.AdviseChange(lifetime, settingsKey, daemon.Invalidate);
        }
 public WindowsService(string serviceName, IDaemon daemon) : this(daemon, new WindowsServiceConfiguration(serviceName))
 {
 }
Beispiel #36
0
        public ComplexityAnalysisInvalidateOnThresholdChange(Lifetime lifetime, IDaemon daemon, ISettingsStore settingsStore)
        {
            SettingsScalarEntry thresholdEntry = settingsStore.Schema.GetScalarEntry((ComplexityAnalysisSettings s) => s.Threshold);

            settingsStore.AdviseChange(lifetime, thresholdEntry, daemon.Invalidate);
        }
Beispiel #37
0
 public void RemoveDaemon(IDaemon daemon)
 {
     lock (syncRoot)
         daemons.Remove(daemon);
 }
Beispiel #38
0
 private void TcpProcess(IDaemon daemon, LowLevelTcpConnection connection)
 {
     Buffer buffer =
         new Buffer()
             {
                 Segment = new ArraySegment<byte>(new byte[2048])
             };
     ReadOne(buffer, connection);
 }
Beispiel #39
0
 public void RegisterDaemon(IDaemon daemon)
 {
     lock (syncRoot)
         daemons.Add(daemon);
 }
Beispiel #40
0
 public void RegisterDaemon(IDaemon daemon)
 {
     lock (syncRoot)
         daemons.Add(daemon);
 }
Beispiel #41
0
 public LowLevelTcpConnection(TcpClient client, IDaemon daemon)
 {
     _client = client;
     _daemon = daemon;
     _stream = _client.GetStream();
 }
Beispiel #42
0
 public DaemonErrorHandler(IDaemon daemon, IDaemonLogger logger, ExceptionHandling handling)
 {
     _daemon   = daemon;
     _logger   = logger;
     _handling = handling;
 }
Beispiel #43
0
 public void RemoveDaemon(IDaemon daemon)
 {
     lock (syncRoot)
         daemons.Remove(daemon);
 }