Exemplo n.º 1
0
        public AdvancedViewModel(ILumiaSettingsService lumiaSettingsService, IFileSystemOperations fileSystemOperations,
                                 UIServices uiServices, IDeploymentContext context, IOperationContext operationContext, IOperationProgress progress,
                                 IList <Meta <IDiskLayoutPreparer> > diskPreparers,
                                 ILogCollector logCollector)
        {
            this.lumiaSettingsService = lumiaSettingsService;
            this.uiServices           = uiServices;
            this.context      = context;
            this.logCollector = logCollector;

            DiskPreparers = diskPreparers;

            DeleteDownloadedWrapper = new ProgressViewModel(ReactiveCommand.CreateFromTask(() => DeleteDownloaded(fileSystemOperations)), progress, this, uiServices.ContextDialog, operationContext);

            ForceDualBootWrapper = new ProgressViewModel(ReactiveCommand.CreateFromTask(ForceDualBoot), progress, this, uiServices.ContextDialog, operationContext);

            ForceSingleBootWrapper = new ProgressViewModel(ReactiveCommand.CreateFromTask(ForceDisableDualBoot), progress, this, uiServices.ContextDialog, operationContext);

            CollectLogsCommmandWrapper = new ProgressViewModel(ReactiveCommand.CreateFromTask(CollectLogs), progress, this, uiServices.ContextDialog, operationContext);

            IsBusyObservable = Observable.Merge(DeleteDownloadedWrapper.Command.IsExecuting,
                                                ForceDualBootWrapper.Command.IsExecuting, ForceSingleBootWrapper.Command.IsExecuting,
                                                CollectLogsCommmandWrapper.Command.IsExecuting);

            preparerUpdater = this.WhenAnyValue(x => x.SelectedPreparer)
                              .Where(x => x != null)
                              .Subscribe(x =>
            {
                context.DiskLayoutPreparer        = x.Value;
                lumiaSettingsService.DiskPreparer = (string)x.Metadata["Name"];
            });

            SelectedPreparer = GetInitialDiskPreparer();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates a logger with given collector
        /// </summary>
        /// <param name="collector">Ultimate destination of log messages</param>
        /// <returns></returns>
        public static ILog GetLogger(ILogCollector collector)
        {
            ILog ret = InstantiateLogger();

            ret.Collector = collector;
            return(ret);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Initializes the FFDA logger with given Syslog facility and concrete logger
        /// </summary>
        /// <param name="facility">Syslog facility that will be used for all the messages</param>
        /// <param name="target">Concrete logger that will collect FFDA messages</param>
        /// <param name="loggerName">Name of logger</param>
        public FieldFailureDataLogger(SyslogFacility facility, ILogCollector target, string loggerName)
            : base(facility, target)
        {
            LogName = loggerName;

            Log("SUP", SyslogSeverity.Info);
        }
Exemplo n.º 4
0
 /// <summary>
 /// Initializes LogCollectorTie with a target object
 /// </summary>
 /// <param name="target">Object to proxy</param>
 /// <exception cref="System.ArgumentNullException">Argument is null</exception>
 public LogCollectorTie(ILogCollector target)
 {
     if (target == null)
     {
         throw new ArgumentNullException("target");
     }
     Target = target;
 }
Exemplo n.º 5
0
        /// <summary>
        /// Creates a logger with given facility and collector
        /// </summary>
        /// <param name="facility">Syslog facility to use</param>
        /// <param name="collector">Ultimate destination of log messages</param>
        /// <returns></returns>
        public static ILog GetLogger(SyslogFacility facility, ILogCollector collector)
        {
            ILogger ret = InstantiateLogger();

            ret.Collector = collector;
            ret.Facility  = facility;
            return(ret);
        }
Exemplo n.º 6
0
        static void Main(string[] args)
        {
            Console.CancelKeyPress += Console_CancelKeyPress;
            if (args == null || args.Length < 1)
            {
                Console.WriteLine("Usage: NoiseSource ([MESSAGE_RATE]|\"inf\")");
                Console.WriteLine();
                Console.WriteLine();
                Console.WriteLine("\tMESSAGE_RATE:\t number of messages sent per second");
                Console.WriteLine();
                Console.WriteLine();
                Console.WriteLine("Example: \tNoiseSource 1500");
                Console.WriteLine("sends 1500 messages per second");
                Console.WriteLine("\tNoiseSource inf");
                Console.WriteLine("sends infinite messages, flooding network socket");
                Environment.Exit(0);
            }
            int rate = 0;

            if (args[0] != "inf" && !int.TryParse(args[0], out rate) || rate == 0)
            {
                Console.WriteLine("Invalid rate");
                Environment.Exit(1);
            }
            long timeout = 10000000 / rate; //100ns timeout

            if (timeout == 0)
            {
                Console.WriteLine("Ready to send infinite messages at infinite rate");
            }
            else
            {
                Console.WriteLine("Ready to send infinite messages at a rate of {0}/s", rate);
            }

            ILogCollector server = CollectorHelper.CreateCollector();
            string        host   = System.Net.Dns.GetHostName();

            while (true)
            {
                SyslogMessage startMsg = new SyslogMessage
                {
                    Timestamp = DateTime.Now,
                    Facility  = SyslogFacility.Printer,
                    Severity  = SyslogSeverity.Debug,
                    Host      = host,
                    MessageId = "NOISE",
                    Text      = "The quick brown fox jumps over the lazy dog"
                };
                server.SubmitMessage(startMsg);

                if (rate > 0)
                {
                    Thread.Sleep(new TimeSpan(timeout));
                }
            }
        }
Exemplo n.º 7
0
        public void CreateDefaultCollectorTest()
        {
            ILogCollector expected = null; // TODO: Eseguire l'inizializzazione a un valore appropriato
            ILogCollector actual;

            actual = CollectorHelper.CreateCollector();
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verificare la correttezza del metodo di test.");
        }
Exemplo n.º 8
0
        /// <summary>
        /// Constructor with facility and collector
        /// </summary>
        /// <param name="facility">Syslog facility</param>
        /// <param name="target">Ultimate destination of messages</param>
        public SimpleLogImpl(SyslogFacility facility, ILogCollector target)
            : this(facility)
        {
            if (target == null)
            {
                throw new ArgumentNullException("target");
            }

            Collector = target;
        }
Exemplo n.º 9
0
        public void CreateUdpCollectorTest()
        {
            IPAddress     logbus_ip   = null; // TODO: Eseguire l'inizializzazione a un valore appropriato
            int           logbus_port = 0;    // TODO: Eseguire l'inizializzazione a un valore appropriato
            ILogCollector expected    = null; // TODO: Eseguire l'inizializzazione a un valore appropriato
            ILogCollector actual;

            actual = CollectorHelper.CreateUnreliableCollector(logbus_ip, logbus_port);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verificare la correttezza del metodo di test.");
        }
Exemplo n.º 10
0
        protected override void Awake()
        {
            base.Awake();
            Log.SetLogger(new LoggerImpl());
            Container.BindSingleton <ILogCollectionService, LogCollectionService>();
            Container.BindSingleton <ILogCallbackRegistrar, DefaultLogCallbackRegistrar>();

            if (File.Exists(LogFilePath))
            {
                File.Delete(LogFilePath);
            }

            var logCollector = new LogCollector();

            logCollector.LogFilePath = LogFilePath;
            m_LogCollector           = logCollector;
        }
Exemplo n.º 11
0
        public AdvancedViewModel(IRaspberryPiSettingsService raspberryPiSettingsService, IFileSystemOperations fileSystemOperations,
                                 UIServices uiServices, IDeploymentContext context, IOperationContext operationContext,
                                 ILogCollector logCollector)
        {
            this.raspberryPiSettingsService = raspberryPiSettingsService;
            this.uiServices   = uiServices;
            this.context      = context;
            this.logCollector = logCollector;

            DeleteDownloadedWrapper = new CommandWrapper <Unit, Unit>(this,
                                                                      ReactiveCommand.CreateFromTask(() => DeleteDownloaded(fileSystemOperations)), uiServices.ContextDialog, operationContext);

            CollectLogsCommmandWrapper = new CommandWrapper <Unit, Unit>(this, ReactiveCommand.CreateFromTask(CollectLogs), uiServices.ContextDialog, operationContext);

            IsBusyObservable = Observable.Merge(DeleteDownloadedWrapper.Command.IsExecuting,
                                                CollectLogsCommmandWrapper.Command.IsExecuting);
        }
        public void RemoveLogCollector(ILogCollector collector)
        {
            if (collector == null)
            {
                throw new ArgumentNullException("collector");
            }

            if (m_ReceivingLog)
            {
                m_Commands.Enqueue(new Cmd {
                    CmdType = CmdType.Remove, Collector = collector
                });
            }
            else
            {
                m_LogCollectors.Remove(collector);
            }
        }
Exemplo n.º 13
0
        public void AddLogCollector(ILogCollector collector)
        {
            if (collector == null)
            {
                throw new ArgumentNullException(nameof(collector));
            }

            if (m_ReceivingLog)
            {
                m_Commands.Enqueue(new Cmd {
                    CmdType = CmdType.Add, Collector = collector
                });
            }
            else
            {
                m_LogCollectors.Add(collector);
            }
        }
Exemplo n.º 14
0
        /// <summary>
        /// Creates collector from configuration definition
        /// </summary>
        /// <param name="def">Configuration entry of collector</param>
        /// <returns></returns>
        internal static ILogCollector CreateCollector(LogCollectorDefinitionBase def)
        {
            if (def == null)
            {
                throw new ArgumentNullException("def");
            }
            if (string.IsNullOrEmpty(def.type))
            {
                throw new ArgumentException("Configuration entry doesn't specified required collector type", "def");
            }
            try
            {
                string typename = def.type;
                if (typename.IndexOf('.') < 0)
                {
                    //This is probably a plain class name, overriding to It.Unina.Dis.Logbus.InChannels namespace
                    const string namespc      = "It.Unina.Dis.Logbus.Collectors";
                    string       assemblyname = typeof(CollectorHelper).Assembly.GetName().ToString();
                    typename = string.Format("{0}.{1}, {2}", namespc, typename, assemblyname);
                }
                Type loggerType = Type.GetType(typename);
                if (!typeof(ILogCollector).IsAssignableFrom(loggerType))
                {
                    LogbusConfigurationException ex =
                        new LogbusConfigurationException("Registered collector type does not implement ILogCollector");
                    ex.Data.Add("type", loggerType);
                    throw ex;
                }
                ILogCollector ret = Activator.CreateInstance(loggerType) as ILogCollector;
                if (def.param != null && ret is IConfigurable)
                {
                    foreach (KeyValuePair kvp in def.param)
                    {
                        ((IConfigurable)ret).SetConfigurationParameter(kvp.name, kvp.value);
                    }
                }

                return(ret);
            }
            catch (Exception ex)
            {
                throw new LogbusConfigurationException("Invalid collector configuration", ex);
            }
        }
Exemplo n.º 15
0
 /// <summary>
 /// Initializes the FFDA logger with the concrete underlying logger
 /// </summary>
 /// <param name="target">Concrete logger that will collect FFDA messages</param>
 /// <param name="loggerName">Name of logger</param>
 public FieldFailureDataLogger(ILogCollector target, string loggerName)
     : this(SyslogFacility.Local0, target, loggerName)
 {
 }
Exemplo n.º 16
0
 /// <summary>
 /// Constructor with collector
 /// </summary>
 /// <param name="target">Ultimate destination of messages</param>
 public SimpleLogImpl(ILogCollector target)
     : this(SyslogFacility.Local4, target)
 {
 }
Exemplo n.º 17
0
 public LogController(ILogCollector logCollector)
 {
     _logCollector = logCollector;
 }
Exemplo n.º 18
0
 public FieldFailureAlerter(ILogCollector target)
     : base(target)
 {
 }
Exemplo n.º 19
0
        private static void Run(int timeout)
        {
            _messagesRcvd = new BitArray(_expected, false);
            _received     = 0;
            string pid = Process.GetCurrentProcess().Id.ToString(CultureInfo.InvariantCulture);

            ILogCollector  server     = CollectorHelper.CreateCollector();
            string         host       = Dns.GetHostName();
            PropertyFilter hostFilter = new PropertyFilter
            {
                comparison   = ComparisonOperator.eq,
                value        = host,
                propertyName = Property.Host
            };
            FacilityEqualsFilter facFilter = new FacilityEqualsFilter {
                facility = SyslogFacility.Local4
            };
            PropertyFilter pidFilter = new PropertyFilter
            {
                comparison   = ComparisonOperator.eq,
                value        = pid,
                propertyName = Property.ProcessID
            };
            PropertyFilter idFilter = new PropertyFilter
            {
                value        = "BENCH",
                comparison   = ComparisonOperator.eq,
                propertyName = Property.MessageID
            };
            SeverityFilter sevFilter = new SeverityFilter
            {
                comparison = ComparisonOperator.eq,
                severity   = SyslogSeverity.Notice
            };

            using (ILogClient client = ClientHelper.CreateReliableClient(hostFilter & pidFilter & idFilter & sevFilter & facFilter))
            {
                client.MessageReceived += client_MessageReceived;
                client.Start();

                for (int i = 0; i < _expected; i++)
                {
                    if (timeout > 0)
                    {
                        Nanosleep(timeout);
                    }
                    SyslogMessage message = new SyslogMessage
                    {
                        Timestamp = DateTime.Now,
                        Facility  = SyslogFacility.Local4,
                        Severity  = SyslogSeverity.Notice,
                        Host      = host,
                        ProcessID = pid,
                        MessageId = "BENCH",
                        Text      = i.ToString()
                    };

                    server.SubmitMessage(message);
                }
                silenceTimer = new Timer(state => Stop.Set(), null, 40000, Timeout.Infinite);
                Console.WriteLine("Waiting up to 30 seconds after last message received...");
                Stop.WaitOne();
            }

            if (_expected == _received)
            {
                Console.WriteLine("Received all messaged");
            }
            else
            {
                Console.WriteLine("Lost {0} messages", _expected - _received);
            }
        }
Exemplo n.º 20
0
 /// <summary>
 /// Initializes the FFDA logger with the concrete underlying logger
 /// </summary>
 /// <param name="target">Concrete logger that will collect FFDA messages</param>
 public FieldFailureDataLogger(ILogCollector target)
     : this(SyslogFacility.Local0, target)
 {
 }
Exemplo n.º 21
0
        static void Main(string[] args)
        {
            bool reliable = args != null && args.Length > 0 && args[0] == "--reliable";

            Console.CancelKeyPress += Console_CancelKeyPress;

            Console.WriteLine("This program periodically measures the RTT for log messages sent by here");

            if (!reliable)
            {
                Console.WriteLine("Going in unreliable mode. Messages are subject to loss.");
                Console.WriteLine("Use the --reliable switch to go into reliable mode, where messages don't get lost.");
            }
            else
            {
                Console.WriteLine("Reliable mode activated. No messages will be lost because of the network.");
            }

            PropertyFilter hostFilter = new PropertyFilter
            {
                comparison   = ComparisonOperator.eq,
                value        = Dns.GetHostName(),
                propertyName = Property.Host
            };
            PropertyFilter pidFilter = new PropertyFilter
            {
                comparison = ComparisonOperator.eq,
                value      =
                    Process.GetCurrentProcess().Id.ToString(CultureInfo.InvariantCulture),
                propertyName = Property.ProcessID
            };
            PropertyFilter idFilter = new PropertyFilter
            {
                value        = "RTT",
                comparison   = ComparisonOperator.eq,
                propertyName = Property.MessageID
            };

            _target = CollectorHelper.CreateCollector((reliable) ? "tls" : "udp");
            FilterBase filter = hostFilter & pidFilter & idFilter;

            _source = (reliable) ? ClientHelper.CreateReliableClient(filter) : ClientHelper.CreateUnreliableClient(filter);
            _log    = LoggerHelper.GetLogger("Logfile");

            _source.MessageReceived += source_MessageReceived;
            _source.Start();

            while (true)
            {
                _id++;
                DateTime      curTimestamp = DateTime.UtcNow;
                double        millis       = (curTimestamp - DateTime.Today).TotalMilliseconds;
                string        text         = _id.ToString(CultureInfo.InvariantCulture) + "_" + millis.ToString(CultureInfo.InvariantCulture);
                SyslogMessage message      = new SyslogMessage(SyslogFacility.Local3, SyslogSeverity.Notice, text)
                {
                    MessageId = "RTT"
                };

                _target.SubmitMessage(message);

                if (!_ar.WaitOne(10000))
                {
                    Console.WriteLine("RTT sent at {0} lost", curTimestamp);
                    _log.Warning("RTT sent at {0} lost", curTimestamp);
                    continue;
                }
                Thread.Sleep(3000);
            }
        }