/// <summary> /// Initializes a new instance of the <see cref="Sampler" /> class. /// </summary> /// <param name="monitorableProcessor">The monitorable processor.</param> protected Sampler(IMonitorableProcessor monitorableProcessor) { _cancellationTokenSource = new CancellationTokenSource(); _monitorableProcessor = monitorableProcessor; ConfigureStateMachine(); ConfigureSampler(); }
/// <summary> /// Initializes a new instance of the <see cref="Sampler" /> class. /// </summary> /// <param name="monitorableProcessor">The monitorable processor.</param> protected Sampler(IMonitorableProcessor monitorableProcessor) { _cancellationTokenSource = new CancellationTokenSource(); _monitorableProcessor = monitorableProcessor; ConfigureStateMachine(); ConfigureSampler(); }
/// <summary> /// Creates the specified type. /// </summary> /// <param name="type">The type.</param> /// <param name="monitorableProcessor">The monitorable processor.</param> /// <returns></returns> public ISampler Create(Type type, IMonitorableProcessor monitorableProcessor) { var frequenceLevel = (SamplerFrequenceLevelAttribute) type.GetCustomAttributes(typeof (SamplerFrequenceLevelAttribute), true).FirstOrDefault(); var sampler = (Sampler) Activator.CreateInstance(type, monitorableProcessor); InjectLogger(sampler); sampler.SetFrequence(_frequenceHelper.GetFrequence(frequenceLevel.Frequence)); return sampler; }
/// <summary> /// Creates the specified type. /// </summary> /// <param name="type">The type.</param> /// <param name="monitorableProcessor">The monitorable processor.</param> /// <returns></returns> public ISampler Create(Type type, IMonitorableProcessor monitorableProcessor) { var frequenceLevel = (SamplerFrequenceLevelAttribute) type.GetCustomAttributes(typeof(SamplerFrequenceLevelAttribute), true).FirstOrDefault(); var sampler = (Sampler)Activator.CreateInstance(type, monitorableProcessor); InjectLogger(sampler); sampler.SetFrequence(_frequenceHelper.GetFrequence(frequenceLevel.Frequence)); return(sampler); }
/// <summary> /// Determines whether the specified t is sampler. /// </summary> /// <param name="t">The t.</param> /// <param name="monitorableProcessor">The monitorable processor.</param> /// <returns> /// <c>true</c> if the specified t is sampler; otherwise, <c>false</c>. /// </returns> private static bool IsSampler(Type t, IMonitorableProcessor monitorableProcessor) { if (t.IsAbstract) { return(false); } if (monitorableProcessor is ISubscriber) { return(typeof(Sampler).IsAssignableFrom(t) || typeof(IPublisherSampler).IsAssignableFrom(t)); } return(typeof(Sampler).IsAssignableFrom(t) && !(typeof(IPublisherSampler).IsAssignableFrom(t))); }
/// <summary> /// Creates the specified monitorable processor. /// </summary> /// <typeparam name="TMessage">The type of the message.</typeparam> /// <param name="monitorableProcessor">The monitorable processor.</param> /// <returns></returns> public static TMessage Create <TMessage>(IMonitorableProcessor monitorableProcessor) where TMessage : IMonitoringMessage, new() { var message = new TMessage { Identification = new Identification { Id = monitorableProcessor.Identification.Id, Type = monitorableProcessor.Identification.Type }, Type = monitorableProcessor is ISubscriber? ProcessorType.Bus : ProcessorType.AutonomousComponent, UtcTimeTakenSample = DateTime.UtcNow, BusIdentification = monitorableProcessor.JoinedBusInfo.Identification }; return(message); }
/// <summary> /// Creates the samplers. /// </summary> /// <param name="assemblies">The assemblies.</param> /// <param name="monitorableProcessor">The monitorable processor.</param> /// <returns></returns> private IEnumerable<ISampler> CreateSamplers(IEnumerable<string> assemblies, IMonitorableProcessor monitorableProcessor) { return from assemblyName in assemblies select Assembly.LoadFrom(string.Format(@"{0}/{1}", AppDomain.CurrentDomain.BaseDirectory, assemblyName)) into assembly from type in assembly.GetTypes() where IsSampler(type, monitorableProcessor) select _samplerFactory.Create(type, monitorableProcessor); }
/// <summary> /// Initializes a new instance of the <see cref="HealthSampler"/> class. /// </summary> /// <param name="monitorableProcessor">The monitorable processor.</param> public HealthSampler(IMonitorableProcessor monitorableProcessor) : base(monitorableProcessor) { }
/// <summary> /// Initializes a new instance of the <see cref="QueueLoadSampler"/> class. /// </summary> /// <param name="monitorableProcessor">The monitorable processor.</param> public QueueLoadSampler(IMonitorableProcessor monitorableProcessor) : base(monitorableProcessor) { }
/// <summary> /// Initializes a new instance of the <see cref="TransferVelocitySampler"/> class. /// </summary> /// <param name="monitorableProcessor">The monitorable processor.</param> public TransferVelocitySampler(IMonitorableProcessor monitorableProcessor) : base(monitorableProcessor) { }
/// <summary> /// Initializes a new instance of the <see cref="MessageOutputTypesSampler"/> class. /// </summary> /// <param name="monitorableProcessor">The monitorable processor.</param> public MessageOutputTypesSampler(IMonitorableProcessor monitorableProcessor) : base(monitorableProcessor) { _messageTypes = new ConcurrentDictionary <MessageType, MessageType>(); }
/// <summary> /// Initializes a new instance of the <see cref="QueueLoadSampler"/> class. /// </summary> /// <param name="monitorableProcessor">The monitorable processor.</param> public QueueLoadSampler(IMonitorableProcessor monitorableProcessor) : base(monitorableProcessor) { }
/// <summary> /// Initializes a new instance of the <see cref="HeartBeatSampler"/> class. /// </summary> /// <param name="monitorableProcessor">The monitorable processor.</param> public HeartBeatSampler(IMonitorableProcessor monitorableProcessor) : base(monitorableProcessor) { }
/// <summary> /// Determines whether the specified t is sampler. /// </summary> /// <param name="t">The t.</param> /// <param name="monitorableProcessor">The monitorable processor.</param> /// <returns> /// <c>true</c> if the specified t is sampler; otherwise, <c>false</c>. /// </returns> private static bool IsSampler(Type t, IMonitorableProcessor monitorableProcessor) { if (t.IsAbstract) return false; if (monitorableProcessor is ISubscriber) return (typeof(Sampler).IsAssignableFrom(t) || typeof(IPublisherSampler).IsAssignableFrom(t)); return (typeof(Sampler).IsAssignableFrom(t) && !(typeof(IPublisherSampler).IsAssignableFrom(t))); }
/// <summary> /// Initializes a new instance of the <see cref="TransferVelocitySampler"/> class. /// </summary> /// <param name="monitorableProcessor">The monitorable processor.</param> public TransferVelocitySampler(IMonitorableProcessor monitorableProcessor) : base(monitorableProcessor) { }
/// <summary> /// Creates the samplers. /// </summary> /// <param name="assemblies">The assemblies.</param> /// <param name="monitorableProcessor">The monitorable processor.</param> /// <returns></returns> private IEnumerable <ISampler> CreateSamplers(IEnumerable <string> assemblies, IMonitorableProcessor monitorableProcessor) { return(from assemblyName in assemblies select Assembly.LoadFrom(string.Format(@"{0}/{1}", AppDomain.CurrentDomain.BaseDirectory, assemblyName)) into assembly from type in assembly.GetTypes() where IsSampler(type, monitorableProcessor) select _samplerFactory.Create(type, monitorableProcessor)); }
/// <summary> /// Initializes a new instance of the <see cref="MessageOutputTypesSampler"/> class. /// </summary> /// <param name="monitorableProcessor">The monitorable processor.</param> public MessageOutputTypesSampler(IMonitorableProcessor monitorableProcessor) : base(monitorableProcessor) { _messageTypes = new ConcurrentDictionary<MessageType, MessageType>(); }
/// <summary> /// Initializes a new instance of the <see cref="SamplerFake"/> class. /// </summary> /// <param name="monitorableProcessor">The monitorable processor.</param> public SamplerFake(IMonitorableProcessor monitorableProcessor) : base(monitorableProcessor) { CountMessages = 0; }
/// <summary> /// Initializes a new instance of the <see cref="SamplerFake"/> class. /// </summary> /// <param name="monitorableProcessor">The monitorable processor.</param> public SamplerFake(IMonitorableProcessor monitorableProcessor) : base(monitorableProcessor) { CountMessages = 0; }
/// <summary> /// Initializes a new instance of the <see cref="ProcessingVelocitySampler"/> class. /// </summary> /// <param name="monitorableProcessor">The monitorable processor.</param> public ProcessingVelocitySampler(IMonitorableProcessor monitorableProcessor) : base(monitorableProcessor) { MonitorableProcessor.MonitorableInputGateway.OnMessageBusReceived += OnMessageBusReceived; }
/// <summary> /// Initializes a new instance of the <see cref="ProcessingVelocitySampler"/> class. /// </summary> /// <param name="monitorableProcessor">The monitorable processor.</param> public ProcessingVelocitySampler(IMonitorableProcessor monitorableProcessor) : base(monitorableProcessor) { MonitorableProcessor.MonitorableInputGateway.OnMessageBusReceived += OnMessageBusReceived; }
/// <summary> /// Initializes a new instance of the <see cref="MessageTypesSampler"/> class. /// </summary> /// <param name="monitorableProcessor">The monitorable processor.</param> public MessageTypesSampler(IMonitorableProcessor monitorableProcessor) : base(monitorableProcessor) { _bagTypes = new ConcurrentDictionary <SubscriptionKey, MessageType>(); _monitorableRouter = monitorableProcessor as IMonitorableRouter; }
/// <summary> /// Initializes a new instance of the <see cref="HeartBeatSampler"/> class. /// </summary> /// <param name="monitorableProcessor">The monitorable processor.</param> public HeartBeatSampler(IMonitorableProcessor monitorableProcessor) : base(monitorableProcessor) { }
/// <summary> /// Initializes a new instance of the <see cref="MessageTypesSampler"/> class. /// </summary> /// <param name="monitorableProcessor">The monitorable processor.</param> public MessageTypesSampler(IMonitorableProcessor monitorableProcessor) : base(monitorableProcessor) { _bagTypes = new ConcurrentDictionary<SubscriptionKey, MessageType>(); _monitorableRouter = monitorableProcessor as IMonitorableRouter; }
/// <summary> /// Initializes a new instance of the <see cref="HealthSampler"/> class. /// </summary> /// <param name="monitorableProcessor">The monitorable processor.</param> public HealthSampler(IMonitorableProcessor monitorableProcessor) : base(monitorableProcessor) { }