public AutomaticRetryServerComponentWrapper( [NotNull] IServerComponent innerComponent, int maxRetryAttempts, [NotNull] Func <int, TimeSpan> delayCallback) { if (innerComponent == null) { throw new ArgumentNullException("innerComponent"); } if (delayCallback == null) { throw new ArgumentNullException("delayCallback"); } if (maxRetryAttempts < 0) { throw new ArgumentOutOfRangeException( "maxRetryAttempts", "MaxRetryAttempts property value must be greater or equal to 0."); } _innerComponent = innerComponent; _maxRetryAttempts = maxRetryAttempts; _delayCallback = delayCallback; _logger = LogManager.GetLogger(_innerComponent.GetType()); }
public ConfigurationModel GetConfiguration(IServerComponent component) { ConfigurationModel c; _configurations.TryGetValue(component.GetId(), out c); return(c); }
#pragma warning disable CS0618 // Type or member is obsolete public static ITaskSource Wrap(this IServerComponent component) #pragma warning restore CS0618 // Type or member is obsolete { if (component == null) { throw new ArgumentNullException(nameof(component)); } return(new ServerComponentWrapper(component)); }
public ServerComponentWrapper(IServerComponent component) #pragma warning restore CS0618 // Type or member is obsolete { if (component == null) { throw new ArgumentNullException(nameof(component)); } _component = component; }
public AutomaticRetryServerComponentWrapper([NotNull] IServerComponent innerComponent) { if (innerComponent == null) throw new ArgumentNullException("innerComponent"); _innerComponent = innerComponent; _logger = LogProvider.GetLogger(_innerComponent.GetType()); MaxRetryAttempts = DefaultMaxRetryAttempts; MaxAttemptDelay = DefaultMaxAttemptDelay; DelayCallback = GetBackOffMultiplier; }
public bool AddJob(IServerComponent component, IDownloadBatch batch, int maxCapacity) { var quenue = GetProcessingQueue(component); if (quenue.Count > maxCapacity) { return(false); } _log.Log(LogLevel.Information, this, component, "add downloadJob"); quenue.Enqueue(batch); return(true); }
public ServerSupervisor(IServerComponent component, ServerSupervisorOptions options) { if (component == null) throw new ArgumentNullException("component"); if (options == null) throw new ArgumentNullException("options"); _component = component; _options = options; _logger = LogManager.GetLogger(_component.GetType()); _thread = new Thread(RunComponent) { IsBackground = true, Name = component.ToString() }; _logger.TraceFormat("Starting a new thread for server component '{0}'...", _component); _thread.Start(); }
public AutomaticRetryServerComponentWrapper([NotNull] IServerComponent innerComponent) { if (innerComponent == null) { throw new ArgumentNullException("innerComponent"); } _innerComponent = innerComponent; _logger = LogProvider.GetLogger(_innerComponent.GetType()); MaxRetryAttempts = DefaultMaxRetryAttempts; MaxAttemptDelay = DefaultMaxAttemptDelay; DelayCallback = GetBackOffMultiplier; }
public ServerProcessDispatcherBuilder( [NotNull] IServerComponent component, [NotNull] Func <ThreadStart, IEnumerable <Thread> > threadFactory) { if (component == null) { throw new ArgumentNullException(nameof(component)); } if (threadFactory == null) { throw new ArgumentNullException(nameof(threadFactory)); } _component = component; _threadFactory = threadFactory; }
public void Arrange() { var serverMock = new Mock <IServerInstance>(); serverMock.Setup(s => s.GetServerInstance()).Returns("New Server For Tests"); _server = serverMock.Object; var serverComponentMock = new Mock <ServerComponent>(_server) { CallBase = true }; serverComponentMock.Setup(s => s.Execute(It.IsAny <int>())); _serverComponent = serverComponentMock.Object; }
public AutomaticRetryServerComponentWrapper( [NotNull] IServerComponent innerComponent, int maxRetryAttempts, [NotNull] Func<int, TimeSpan> delayCallback) { if (innerComponent == null) throw new ArgumentNullException("innerComponent"); if (delayCallback == null) throw new ArgumentNullException("delayCallback"); if (maxRetryAttempts < 0) { throw new ArgumentOutOfRangeException( "maxRetryAttempts", "MaxRetryAttempts property value must be greater or equal to 0."); } _innerComponent = innerComponent; _maxRetryAttempts = maxRetryAttempts; _delayCallback = delayCallback; _logger = LogManager.GetLogger(_innerComponent.GetType()); }
public ServerSupervisor(IServerComponent component, ServerSupervisorOptions options) { if (component == null) { throw new ArgumentNullException("component"); } if (options == null) { throw new ArgumentNullException("options"); } _component = component; _options = options; _logger = LogProvider.GetLogger(_component.GetType()); _thread = new Thread(RunComponent) { IsBackground = true, Name = component.ToString() }; _logger.TraceFormat("Starting a new thread for server component '{0}'...", _component); _thread.Start(); }
private static ServerSupervisor CreateSupervisor(IServerComponent component) { return new ServerSupervisor(new AutomaticRetryServerComponentWrapper(component)); }
public void RegisterComponent(IServerComponent component) { component.Configure(_serviceProvider); _components.Enqueue(new ComponentContainer(component)); _log.Log(LogLevel.Information, this, component, $"registred component:{component.GetName()}:{component.GetId()}"); }
public ServerSupervisor(IServerComponent component) : this(component, new ServerSupervisorOptions()) { }
private static ServerSupervisor CreateSupervisor(IServerComponent component, ServerSupervisorOptions options) { return new ServerSupervisor(new AutomaticRetryServerComponentWrapper(component), options); }
private static ServerSupervisor CreateSupervisor(IServerComponent component) { return(new ServerSupervisor(new AutomaticRetryServerComponentWrapper(component))); }
private static ServerSupervisor CreateSupervisor(IServerComponent component) { return(CreateSupervisor(component, new ServerSupervisorOptions())); }
private static ServerSupervisor CreateSupervisor(IServerComponent component) { return CreateSupervisor(component, new ServerSupervisorOptions()); }
public ComponentContainer(IServerComponent component) { Component = component; Reset(); }
public bool GetCompleted(IServerComponent component, out IDownloadBatch batch) { return(GetCompleteQueue(component).TryDequeue(out batch)); }
private ConcurrentQueue <IDownloadBatch> GetProcessingQueue(IServerComponent component) { return(_processing.GetOrAdd(component, new ConcurrentQueue <IDownloadBatch>())); }
private ConcurrentQueue <IDownloadBatch> GetCompleteQueue(IServerComponent component) { return(_complete.GetOrAdd(component, new ConcurrentQueue <IDownloadBatch>())); }
public static bool Add(this IServerComponent isc, int a, int b, int c) { return(isc.Add(a, b) && isc.Add(b, c) && isc.Add(c, a)); }
public AutomaticRetryServerComponentWrapper([NotNull] IServerComponent innerComponent) : this(innerComponent, DefaultMaxRetryAttempts) { }
public AutomaticRetryServerComponentWrapper( [NotNull] IServerComponent innerComponent, int maxRetryAttempts) : this(innerComponent, maxRetryAttempts, GetBackOffMultiplier) { }
private static void StartLegacyServerAndExecuteFunctions(IServerComponent serverComponent) { Console.WriteLine(serverComponent.ExecuteSomeFunction(DefaultTimeout)); Console.WriteLine(serverComponent.ExecuteAnotherFunction(DefaultTimeout)); }