Inheritance: ICouchbaseCluster
 public DesignDocManager(CouchbaseClientConfiguration config)
 {
     if (_cluster == null)
     {
         _cluster = new CouchbaseCluster(config);
     }
 }
 public DesignDocManager(string sectionName = "couchbase")
 {
     if (_cluster == null)
     {
         _config = ConfigurationManager.GetSection(sectionName) as CouchbaseClientSection;
         _cluster = new CouchbaseCluster(_config);
     }
 }
        public static CouchbaseCluster CreateCouchbaseCluster()
        {
            if (_cluster == null)
            {
                _cluster = new CouchbaseCluster("couchbase");
            }

            return _cluster;
        }
        public void SetUp()
        {
            _Client = CouchbaseClientFactory.CreateCouchbaseClient();

            //TODO: uncomment this line when next NuGet (1.2.7) is pushed
            //log4net.Config.XmlConfigurator.Configure();

            var cluster = new CouchbaseCluster("couchbase");

            var stream = File.Open(@"Data\\ThingViews.json", FileMode.Open);
            cluster.CreateDesignDocument("default", "things", stream);
        }
Beispiel #5
0
        /// <summary>
        /// Construct a sink posting to the specified database.
        /// </summary>
        /// <param name="couchbaseUriList">A list of a Couchbase database servers.</param>
        /// <param name="bucketName">The bucket to store batches in.</param>
        /// <param name="batchPostingLimit">The maximum number of events to post in a single batch.</param>
        /// <param name="period">The time to wait between checking for event batches.</param>
        /// <param name="formatProvider">Supplies culture-specific formatting information, or null.</param>
        public CouchbaseSink(string[] couchbaseUriList, string bucketName, int batchPostingLimit, TimeSpan period, IFormatProvider formatProvider)
            : base(batchPostingLimit, period)
        {
            if (couchbaseUriList == null) throw new ArgumentNullException("couchbaseUriList");
            if (couchbaseUriList.Length == 0) throw new ArgumentException("couchbaseUriList");
            if (couchbaseUriList[0] == null) throw new ArgumentNullException("couchbaseUri");

            if (bucketName == null) throw new ArgumentNullException("bucketName");

            var config = new global::Couchbase.Configuration.CouchbaseClientConfiguration();
            
            foreach (var uri in couchbaseUriList)
                config.Urls.Add(new Uri(uri));
            config.Bucket = bucketName;

            var cluster = new CouchbaseCluster(config);
            Bucket bucket = null;
            if (!cluster.TryGetBucket(bucketName, out bucket)) throw new InvalidOperationException("bucket '"+ bucketName  +"' does not exist");

            _couchbaseClient = new global::Couchbase.CouchbaseClient(config);

            _formatProvider = formatProvider;
        }
        public void When_Try_Listing_Buckets_With_Invalid_Config_No_Exception_Is_Thrown_And_Return_Value_Is_False()
        {
            var config = new CouchbaseClientConfiguration();
            config.Urls.Add(new Uri(ConfigurationManager.AppSettings["CouchbaseServerUrl"] + "/doesnotexist/"));
            config.Bucket = "default";

            var server = new CouchbaseCluster(config);
            Bucket[] buckets;
            var result = server.TryListBuckets(out buckets);
            Assert.That(result, Is.False);
        }
 public void When_Listing_Buckets_With_Invalid_Config_Argument_Exception_Is_Thrown()
 {
     var config = new CouchbaseClientConfiguration();
     config.Urls.Add(new Uri(ConfigurationManager.AppSettings["CouchbaseServerUrl"] + "/doesnotexist/"));
     config.Bucket = "default";
     var server = new CouchbaseCluster(config);
     var buckets = server.ListBuckets();
 }
        public void When_Flushing_Bucket_Data_Are_Removed()
        {
            var storedConfig = ConfigurationManager.GetSection("couchbase") as ICouchbaseClientConfiguration;
            var config = new CouchbaseClientConfiguration();

            config.Bucket = "Bucket-" + DateTime.Now.Ticks;
            config.Username = storedConfig.Username;
            config.Password = storedConfig.Password;
            config.Urls.Add(storedConfig.Urls[0]);

            var cluster = new CouchbaseCluster(config);
            cluster.CreateBucket(new Bucket
                {
                    Name = config.Bucket,
                    AuthType = AuthTypes.Sasl,
                    BucketType = BucketTypes.Membase,
                    Quota = new Quota { RAM = 100 },
                    ReplicaNumber = ReplicaNumbers.Zero,
                    FlushOption = FlushOptions.Enabled
                }
            );

            for (int i = 0; i < 10; i++) //wait for bucket to be ready to accept ops
            {
                _bucket = waitForBucket(config.Bucket);
                if (_bucket.Nodes.First().Status == "healthy") break;
                Thread.Sleep(1000);
            }

            Assert.That(_bucket, Is.Not.Null);

            using (var client = new CouchbaseClient(config))
            {
                var storeResult = client.ExecuteStore(StoreMode.Set, "SomeKey", "SomeValue");
                Assert.That(storeResult.Success, Is.True, "Message: " + storeResult.Message);

                var getResult = client.ExecuteGet<string>("SomeKey");
                Assert.That(getResult.Success, Is.True);
                Assert.That(getResult.Value, Is.StringMatching("SomeValue"));

                cluster.FlushBucket(config.Bucket);

                getResult = client.ExecuteGet<string>("SomeKey");
                Assert.That(getResult.Success, Is.False);
                Assert.That(getResult.Value, Is.Null);
            }
        }
 public void TestFixtureSetUp()
 {
     Cluster = CouchbaseClusterFactory.CreateCouchbaseCluster();
 }
 public void SetUp()
 {
     _Cluster = CouchbaseClusterFactory.CreateCouchbaseCluster();
 }
 public void When_Listing_Buckets_With_Invalid_Config_Argument_Exception_Is_Thrown()
 {
     var config = new CouchbaseClientConfiguration();
     config.Urls.Add(new Uri("http://localhost:8091/doesnotexist/"));
     config.Bucket = "default";
     var server = new CouchbaseCluster(config);
     var buckets = server.ListBuckets();
 }