public void When_Bucket_Is_Defined_That_Bucket_Is_Used() { var section = (CouchbaseClientSection)ConfigurationManager.GetSection("couchbaseClients/couchbase_1"); Assert.Greater(section.Buckets.Count, 0); var buckets = new BucketElement[section.Buckets.Count]; section.Buckets.CopyTo(buckets, 0); var bucket = buckets.First(); Assert.AreEqual("testbucket", bucket.Name); Assert.AreEqual("shhh!", bucket.Password); Assert.IsFalse(bucket.UseSsl); }
public void When_Bucket_Contains_ConnectionPoolElement_It_Is_Used() { var section = (CouchbaseClientSection)ConfigurationManager.GetSection("couchbaseClients/couchbase_1"); var buckets = new BucketElement[section.Buckets.Count]; section.Buckets.CopyTo(buckets, 0); var bucket = buckets.First(); Assert.IsNotNull(bucket.ConnectionPool); Assert.AreEqual(5000, bucket.ConnectionPool.WaitTimeout); Assert.AreEqual(3000, bucket.ConnectionPool.ShutdownTimeout); Assert.AreEqual(12000, bucket.ConnectionPool.SendTimeout); Assert.AreEqual(10, bucket.ConnectionPool.MaxSize); Assert.AreEqual(5, bucket.ConnectionPool.MinSize); Assert.AreEqual("custom", bucket.ConnectionPool.Name); }
public void When_Bucket_Does_Not_Contain_ConnectionPoolElement_Default_Is_Used() { var section = (CouchbaseClientSection)ConfigurationManager.GetSection("couchbaseClients/couchbase"); var buckets = new BucketElement[section.Buckets.Count]; section.Buckets.CopyTo(buckets, 0); var bucket = buckets.First(); Assert.IsNotNull(bucket.ConnectionPool); Assert.AreEqual(2500, bucket.ConnectionPool.WaitTimeout); Assert.AreEqual(10000, bucket.ConnectionPool.ShutdownTimeout); Assert.AreEqual(2, bucket.ConnectionPool.MaxSize); Assert.AreEqual(1, bucket.ConnectionPool.MinSize); Assert.AreEqual("default", bucket.ConnectionPool.Name); }
public void When_Bucket_UseSsl_Is_True_In_AppConfig_UseSsl_Returns_True() { var section = (CouchbaseClientSection) ConfigurationManager.GetSection("couchbaseClients/couchbase_2"); var buckets = new BucketElement[section.Buckets.Count]; section.Buckets.CopyTo(buckets, 0); Assert.IsFalse(section.UseSsl); Assert.IsTrue(buckets.First().UseSsl); }
public static async Task<GrainStateCouchbaseDataManager> Initialize(CouchbaseClientSection configSection) { var instance = new GrainStateCouchbaseDataManager(); var config = new ClientConfiguration(configSection); _cluster = new Cluster(config); var tcs = new TaskCompletionSource<IBucket>(); Action initAction; if (configSection.Buckets.Count > 0) { var buckets = new BucketElement[configSection.Buckets.Count]; configSection.Buckets.CopyTo(buckets, 0); var bucketSetting = buckets.First(); initAction = () => { tcs.SetResult(_cluster.OpenBucket(bucketSetting.Name)); }; } else initAction = () => { tcs.SetResult(_cluster.OpenBucket()); }; WaitCallback initBucket = (state) => { try { initAction(); } catch (Exception ex) { tcs.SetException(new Exception("GrainStateCouchbaseDataManager initialize exception", ex)); } }; ThreadPool.QueueUserWorkItem(initBucket, null); instance._bucket = await tcs.Task; return instance; }