public FileLockerRedialExecutor(IRedialer redialer, IInternetDetector validater) : base(redialer, validater) { if (!Directory.Exists(AtomicActionFolder)) { Directory.CreateDirectory(AtomicActionFolder); } foreach (var file in Directory.GetFiles(AtomicActionFolder)) { try { File.Delete(file); } catch (Exception e) { Logger.MyLog($"Delete atomic file failed: {e}", LogLevel.Error); } } try { File.Delete(RedialLockerFile); } catch (Exception e) { Logger.MyLog($"Delete redial lock file failed: {e}", LogLevel.Error); } }
public FileLockerRedialManager(INetworkValidater networkValidater, IRedialer redialer) { _lockerFilePath = Path.Combine(SpiderEnviroment.GlobalDirectory, "redialer.lock"); AtomicExecutor = new FileLockerAtomicExecutor(this); NetworkValidater = networkValidater; Redialer = redialer; }
public FileLockerRedialExecutor(IRedialer redialer, IInternetDetector validater) : base(redialer, validater) { if (!Directory.Exists(AtomicActionFolder)) { Directory.CreateDirectory(AtomicActionFolder); } }
public FileLockerRedialExecutor(IRedialer redialer, IInternetDetector validater) : base(redialer, validater) { if (!Directory.Exists(AtomicActionFolder)) { Directory.CreateDirectory(AtomicActionFolder); } foreach (var file in Directory.GetFiles(AtomicActionFolder)) { try { File.Delete(file); } catch { } } try { File.Delete(RedialLockerFile); } catch { } }
public RedisRedialManager(IDatabase db, INetworkValidater validater, IRedialer redialer, ILogService logger) { Logger = logger; Db = db; AtomicExecutor = new RedisAtomicExecutor(this); NetworkValidater = validater; Redialer = redialer; }
public RedisRedialManager(string host, string password, INetworkValidater validater, IRedialer redialer, ILogService logger) { Logger = logger; if (!string.IsNullOrEmpty(host)) { RedisHost = host; } else { throw new RedialException("Redis host should not be null."); } if (!string.IsNullOrEmpty(password)) { Password = password; } else { Password = null; } var confiruation = new ConfigurationOptions() { ServiceName = "DotnetSpider", Password = password, ConnectTimeout = 5000, KeepAlive = 8, ConnectRetry = 20, SyncTimeout = 65530, ResponseTimeout = 65530 }; #if NET_CORE if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { // Lewis: This is a Workaround for .NET CORE can't use EndPoint to create Socket. var address = Dns.GetHostAddressesAsync(host).Result.FirstOrDefault(); if (address == null) { throw new Exception("Can't resovle your host: " + host); } confiruation.EndPoints.Add(new IPEndPoint(address, 6379)); } else { confiruation.EndPoints.Add(new DnsEndPoint(host, 6379)); } #else confiruation.EndPoints.Add(new DnsEndPoint(host, 6379)); #endif var redis = ConnectionMultiplexer.Connect(confiruation); Db = redis.GetDatabase(3); AtomicExecutor = new RedisAtomicExecutor(this); NetworkValidater = validater; Redialer = redialer; }
/// <summary> /// 构造方法 /// </summary> /// <param name="redialer">拨号器</param> /// <param name="validater">网络状态检测器</param> protected RedialExecutor(IRedialer redialer, IInternetDetector validater) { if (redialer == null || validater == null) { throw new ArgumentException("redialer, validater should not be null."); } Redialer = redialer; InternetDetector = validater; }
protected RedialExecutor(IRedialer redialer, IInternetDetector validater) { if (redialer == null || validater == null) { throw new SpiderException("IWaitRedial should not be null."); } Redialer = redialer; InternetDetector = validater; }
/// <summary> /// 构造方法 /// </summary> /// <param name="redialer">拨号器</param> /// <param name="internetDetector">网络状态检测器</param> protected RedialExecutor(IRedialer redialer, IInternetDetector internetDetector) { if (redialer == null || internetDetector == null) { throw new ArgumentException("redialer, internetDetector should not be null"); } Redialer = redialer; InternetDetector = internetDetector; }
protected RedialExecutor(IRedialer redialer, IInternetDetector validater) { if (redialer == null || validater == null) { throw new SpiderException("IWaitRedial should not be null."); } Redialer = redialer; InternetDetector = validater; Logger = LogManager.GetCurrentClassLogger(); }
public RedisRedialExecutor(string connectString, IRedialer redialer, IInternetDetector validater) : base(redialer, validater) { ConnectString = connectString; RedisConnection = Cache.Instance.Get(ConnectString); if (RedisConnection == null) { RedisConnection = new RedisConnection(ConnectString); Cache.Instance.Set(ConnectString, RedisConnection); } }
public FileLockerRedialExecutor(IRedialer redialer, IInternetDetector validater) : base(redialer, validater) { var fileInfo = new FileInfo(FileLocker.RedialLockerFile); if (fileInfo.Exists) { try { fileInfo.Delete(); } catch { } } }
protected LocalRedialExecutor(IRedialer redialer, IInternetDetector validater) : base(redialer, validater) { if (!Directory.Exists(AtomicActionFolder)) { Directory.CreateDirectory(AtomicActionFolder); } foreach (var file in Directory.GetFiles(AtomicActionFolder)) { try { File.Delete(file); } catch { // ignored } } }
public RedisRedialManager(string host, string password, INetworkValidater validater, IRedialer redialer, ILogService logger) { Logger = logger; if (!string.IsNullOrEmpty(host)) { RedisHost = host; } else { throw new RedialException("Redis host should not be null."); } if (!string.IsNullOrEmpty(password)) { Password = password; } else { Password = null; } var Redis = ConnectionMultiplexer.Connect(new ConfigurationOptions() { ServiceName = "DotnetSpider", Password = password, ConnectTimeout = 65530, KeepAlive = 8, ConnectRetry = 20, SyncTimeout = 65530, ResponseTimeout = 65530, EndPoints = { host, "6379" } }); Db = Redis.GetDatabase(3); AtomicExecutor = new RedisAtomicExecutor(this); NetworkValidater = validater; Redialer = redialer; }
public FileLockerRedialExecutor(IRedialer redialer) : this(redialer, new DefaultInternetDetector()) { }
/// <summary> /// 构造方法 /// </summary> /// <param name="redialer">拨号器</param> protected RedialExecutor(IRedialer redialer) : this(redialer, new DefaultInternetDetector()) { }
public RedisRedialExecutor(string host, string password, int port, IRedialer redialer, IInternetDetector validater) : base(redialer, validater) { Host = host; Password = password; Port = port; }
/// <summary> /// 构造方法 /// </summary> /// <param name="redialer">拨号器</param> /// <param name="validater">网络状态检测器</param> public MutexRedialExecutor(IRedialer redialer, IInternetDetector validater) : base(redialer, validater) { }
/// <summary> /// 构造方法 /// </summary> /// <param name="redialer">拨号器</param> public MutexRedialExecutor(IRedialer redialer) : this(redialer, new DefaultInternetDetector()) { }
public FileLockerRedialExecutor(IRedialer redialer, IInternetDetector validater) : base(redialer, validater) { }
public override void SetRedialManager(INetworkValidater networkValidater, IRedialer redialer) { NetworkProxyManager.Current.Register(new RedialExecutor(new Redial.RedialManager.RedisRedialManager(Host, Password, networkValidater, redialer, null))); }
public override void SetRedialManager(INetworkValidater networkValidater, IRedialer redialer) { NetworkProxyManager.Current.Register(new RedialExecutor(new FileLockerRedialManager(networkValidater, redialer))); }
public abstract void SetRedialManager(INetworkValidater networkValidater, IRedialer redialer);
/// <summary> /// 构造方法 /// </summary> /// <param name="redialer">拨号器</param> /// <param name="internetDetector">网络状态检测器</param> public MutexRedialExecutor(IRedialer redialer, IInternetDetector internetDetector) : base(redialer, internetDetector) { }