private void InitializePool(string readClientHostName, string writeClientHostName) { if (!ReadWritePool.IsPoolReady(Pools.Neo4j)) { GraphPoolableClient reader = new GraphPoolableClient(readClientHostName); GraphPoolableClient writer = new GraphPoolableClient(writeClientHostName); ReadWritePool.AddReadHosts(Pools.Neo4j, new[] { reader }); ReadWritePool.AddWriteHosts(Pools.Neo4j, new[] { writer }); } }
protected override bool StartCore() { if (Pool == null) { Pool = CreatePool(); Pool.Parent = this; } Capturer.CaptureSuccessed += Capturer_CaptureSuccessed; return(DecodeLooper.Start()); }
/// <summary> /// 创建图像缓冲池 /// </summary> protected override ReadWritePool <Bitmap> CreatePool() { Debug.Assert(Region.Width > 0); Debug.Assert(Region.Height > 0); var pool = new ReadWritePool <Bitmap>("采集图像缓冲池"); for (var i = 1; i < 5; i++) { var bitmap = new Bitmap(i + "号缓冲位图", Region.Width, Region.Height, PixelFormat); pool.Add(bitmap); } return(pool); }
private GraphPoolableClient GetWriterClient() { IPoolable host; if (ReadWritePool.TryGetWriteHost(Pools.Neo4j, out host)) { return((GraphPoolableClient)host); } // No host found Logger.Current.Error("Neo4jContext.GetWriterClient", "No writer host found in neo4j pool"); // monitoring, for now it is made with StopWatch because there is no other possibilities IStopwatch sw = MonitoringTimers.Current.GetNewStopwatch(true); sw.Stop(); MonitoringTimers.Current.AddTime(Counters.Neo4j_Pool_GetWriterClientErrors, sw); throw new Exception("No writer host found in neo4j pool"); }
private void InformAboutHostProblems(IPoolable host, Exception ex) { if (host != null) { if (ex is WebException) { WebException webEx = ex as WebException; if (webEx.Status == WebExceptionStatus.ConnectFailure || webEx.Status == WebExceptionStatus.ServerProtocolViolation || webEx.Status == WebExceptionStatus.NameResolutionFailure || webEx.Status == WebExceptionStatus.Timeout) { ReadWritePool.SetHostUnavailable(Pools.Neo4j, host); Logger.Current.Error("Neo4jContext.InformAboutHostProblems", "Host Unavailable", host.ServiceHost); } else { // do nothing, for future we can add logic of "dirty" hosts } } } }