private void Initialize(ClientConfiguration configuration, string defaultBucket, CouchbaseStorageOptions options) { if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } if (string.IsNullOrEmpty(defaultBucket)) { throw new ArgumentNullException(nameof(defaultBucket)); } Options = options ?? new CouchbaseStorageOptions(); Options.DefaultBucket = defaultBucket; configuration.Serializer = () => new DocumentDefaultSerializer(); Client = new Cluster(configuration); string indexPrefix = $"IDX_{defaultBucket}"; IBucket bucket = Client.OpenBucket(Options.DefaultBucket); { IBucketManager manager = bucket.CreateManager(bucket.Configuration.Username, bucket.Configuration.Password); manager.CreateN1qlPrimaryIndex($"{indexPrefix}_Primary", false); manager.CreateN1qlIndex($"{indexPrefix}_Type", false, "type"); manager.CreateN1qlIndex($"{indexPrefix}_Id", false, "id"); manager.CreateN1qlIndex($"{indexPrefix}_Expire", false, "expire_on"); manager.CreateN1qlIndex($"{indexPrefix}_Name", false, "name"); } JobQueueProvider provider = new JobQueueProvider(this); QueueProviders = new PersistentJobQueueProviderCollection(provider); }
/// <summary> /// Initializes a new instance of the MainViewModel class. /// </summary> public MainViewModel() { if (ViewModelBase.IsInDesignModeStatic) { return; } IsBusy = false; IsIndeterminate = true; EntityModels = new ObservableCollection <EntityModel>(); EntityRelationModels = new ObservableCollection <EntityRelationModel>(); _cluster = new Cluster("couchbaseClients/couchbase"); _bucket = _cluster.OpenBucket(); _manager = _bucket.CreateManager(ConfigurationManager.AppSettings["Username"], ConfigurationManager.AppSettings["Password"]); // model is a GraphLinksModel using instances of NodeData as the node data // and LinkData as the link data _graphModel = new GraphLinksModel <NodeData, String, String, LinkData>(); _graphModel.Modifiable = true; _nodes = new ObservableCollection <NodeData>(); _links = new ObservableCollection <LinkData>(); _graphModel.NodesSource = _nodes; _graphModel.LinksSource = _links; SearchText = ConfigurationManager.AppSettings["DefaultEntity"]; int.TryParse(ConfigurationManager.AppSettings["PageSize"], out PageSize); PageSize = PageSize > 0 ? PageSize : 1000; LoadSchema(); LoadState(); }
public async Task Should_Reprepare_Query_If_Not_Adhoc_And_Receive_IndexNotFound() { var request = QueryRequest.Create("SELECT META().id FROM `default` WHERE name = $1 OFFSET 0 LIMIT 20;") .AddPositionalParameter(new object[] { "Bob" }) .AdHoc(false); const string indexName = "test-index"; var manager = _bucket.CreateManager(TestConfiguration.Settings.AdminUsername, TestConfiguration.Settings.AdminPassword); await manager.CreateN1qlIndexAsync(indexName, false, new [] { "name" }); await manager.WatchN1qlIndexesAsync(new List <string> { indexName }, TimeSpan.FromSeconds(10)); var result1 = await _bucket.QueryAsync <dynamic>(request); Assert.IsTrue(result1.Success); await manager.DropN1qlIndexAsync(indexName); var result2 = await _bucket.QueryAsync <dynamic>(request); Assert.IsTrue(result2.Success); }
public void OneTimeSetUp() { TestConfiguration.IgnoreIfMock(); _cluster = new Cluster(Utils.TestConfiguration.GetConfiguration("basic")); _cluster.SetupEnhancedAuth(); _clusterManager = _cluster.CreateManager(TestConfiguration.Settings.AdminUsername, TestConfiguration.Settings.AdminPassword); var listbucketsResult = _clusterManager.ListBuckets(); if (listbucketsResult.Value.Any(bucket => bucket.Name == BucketName)) { var removeResult = _clusterManager.RemoveBucket(BucketName); Assert.IsTrue(removeResult.Success); } var createResult = _clusterManager.CreateBucket(BucketName, replicaNumber: ReplicaNumber.Zero, flushEnabled: true); Assert.True(createResult.Success); // Allow time for bucket to be created and configuration to propagate before beginning operations Thread.Sleep(500); _bucket = _cluster.OpenBucket(BucketName); _bucketManager = _bucket.CreateManager(TestConfiguration.Settings.AdminUsername, TestConfiguration.Settings.AdminPassword); }
private static async void CreateIndexesOnCouchbase() { var bucketManager = bucket.CreateManager(); await bucketManager.CreateN1qlPrimaryIndexAsync(true); await bucketManager.CreateN1qlIndexAsync("ix_type", true, new string[] { "type" }); await bucketManager.CreateN1qlIndexAsync("ix_emai", true, new string[] { "email" }); await bucketManager.CreateN1qlIndexAsync("ix_pass", true, new string[] { "pass" }); await bucketManager.CreateN1qlIndexAsync("ix_title", true, new string[] { "title" }); await bucketManager.CreateN1qlIndexAsync("ix_ip", true, new string[] { "ip" }); await bucketManager.CreateN1qlIndexAsync("ix_pageName", true, new string[] { "pageName" }); await bucketManager.BuildN1qlDeferredIndexesAsync(); bucketManager.WatchN1qlIndexes( new List <string> { "ix_type", "ix_email", "ix_pass", "ix_title", "ix_ip", "ix_pageName", "#primary" }, TimeSpan.FromSeconds(2)); }
/// <summary> /// Сбрасывает кеш /// </summary> public void Flush() { using (Couchbase.Management.IBucketManager bm = _bucket.CreateManager("Administrator", "")) { bm.Flush(); } }
public static void CreateDesignDocument( IBucket bucket, string username, string password, string designDocumentName, string designDocumentBody) { var bucketManager = bucket.CreateManager(username, password); var designDocument = bucketManager.GetDesignDocument(designDocumentName); ////TODO:More detailed analysis of designDocument.Message required, there is JSON response if (designDocument.Success) { return; } var insertDesignDocumentResult = bucketManager.InsertDesignDocument( designDocumentName, designDocumentBody); if (!insertDesignDocumentResult.Success) { throw new Exception( insertDesignDocumentResult.Message, insertDesignDocumentResult.Exception); } }
public async Task Execute() { var manager = _bucket.CreateManager(); var result = await manager.CreateN1qlPrimaryIndexAsync("IDX_Payroll", false); result.ThrowIfFailure(); }
public async Task Execute() { var manager = _bucket.CreateManager(); var fields = new[] { "_type" }; var result = await manager.CreateN1qlIndexAsync("IDX_Payroll_Employee", false, fields); result.ThrowIfFailure(); }
/// <summary> /// Clears this cache, removing all items in the base cache and all regions. /// </summary> public override void Clear() { // warning: takes ~20seconds to flush the bucket... thats rigged var manager = _bucket.CreateManager(_bucketConfiguration.Username, _bucketConfiguration.Password); if (manager != null) { manager.Flush(); } }
public CouchbaseEventStore(IBucket bucket, string couchbaseUser, string couchbasePwd) { if (_bucket == null) { _bucket = bucket; } if (bucketManager == null) { bucketManager = _bucket.CreateManager(couchbaseUser, couchbasePwd); } }
public void OneTimeSetUp() { _cluster = new Cluster(Utils.TestConfiguration.GetConfiguration("basic")); _clusterManager = _cluster.CreateManager(TestConfiguration.Settings.AdminUsername, TestConfiguration.Settings.AdminPassword); var createResult = _clusterManager.CreateBucket(BucketName, replicaNumber:ReplicaNumber.Zero, flushEnabled: true); Assert.True(createResult.Success); // Allow time for bucket to be created and configuration to propagate before beginning operations Thread.Sleep(500); _bucket = _cluster.OpenBucket(BucketName); _bucketManager = _bucket.CreateManager(TestConfiguration.Settings.AdminUsername, TestConfiguration.Settings.AdminPassword); }
public void OneTimeSetUp() { _cluster = new Cluster(Utils.TestConfiguration.GetConfiguration("basic")); _clusterManager = _cluster.CreateManager(TestConfiguration.Settings.AdminUsername, TestConfiguration.Settings.AdminPassword); var createResult = _clusterManager.CreateBucket(BucketName, flushEnabled: true, bucketType:BucketTypeEnum.Memcached); Console.WriteLine(createResult.Success); // Allow time for bucket to be created and configuration to propagate before beginning operations Thread.Sleep(500); _bucket = _cluster.OpenBucket(BucketName); _bucketManager = _bucket.CreateManager(TestConfiguration.Settings.AdminUsername, TestConfiguration.Settings.AdminPassword); }
public void OneTimeSetUp() { _cluster = new Cluster(Utils.TestConfiguration.GetConfiguration("basic")); _clusterManager = _cluster.CreateManager(TestConfiguration.Settings.AdminUsername, TestConfiguration.Settings.AdminPassword); var createResult = _clusterManager.CreateBucket(BucketName, flushEnabled: true, bucketType: BucketTypeEnum.Memcached); Console.WriteLine(createResult.Success); // Allow time for bucket to be created and configuration to propagate before beginning operations Thread.Sleep(500); _bucket = _cluster.OpenBucket(BucketName); _bucketManager = _bucket.CreateManager(TestConfiguration.Settings.AdminUsername, TestConfiguration.Settings.AdminPassword); }
public void OneTimeSetUp() { _cluster = new Cluster(Utils.TestConfiguration.GetConfiguration("basic")); _clusterManager = _cluster.CreateManager(TestConfiguration.Settings.AdminUsername, TestConfiguration.Settings.AdminPassword); var createResult = _clusterManager.CreateBucket(BucketName, replicaNumber: ReplicaNumber.Zero, flushEnabled: true); Assert.True(createResult.Success); // Allow time for bucket to be created and configuration to propagate before beginning operations Thread.Sleep(500); _bucket = _cluster.OpenBucket(BucketName); _bucketManager = _bucket.CreateManager(TestConfiguration.Settings.AdminUsername, TestConfiguration.Settings.AdminPassword); }
public static void CreateBucketConnection() { var cluster = ClusterFactory.GetCluster(); var cbConfig = new CouchbaseConfiguration(); var password = cbConfig.GetPassword(); if (!string.IsNullOrWhiteSpace(password)) { bucket = cluster.OpenBucket(cbConfig.GetBucket(), password); } else { bucket = cluster.OpenBucket(cbConfig.GetBucket()); } bucketManager = bucket.CreateManager("Administrator", "123456"); }
public static IBucketManager getBucketManager(IBucket _bucket) { return(_bucket.CreateManager(CouchbaseConfig.getConfig()["Couchbase:username"], CouchbaseConfig.getConfig()["Couchbase:password"])); }
public IBucketManager GetBucketManager(IBucket bucket) { return(bucket.CreateManager(TestConfigurations.Settings.AdminUsername, TestConfigurations.Settings.AdminPassword)); }
public IBucketManager GetBucketManager(IBucket bucket) { return bucket.CreateManager(ConfigurationManager.AppSettings["adminusername"], ConfigurationManager.AppSettings["adminpassword"]); }
public IBucketManager GetBucketManager(IBucket bucket) { return(bucket.CreateManager(ConfigurationManager.AppSettings["adminusername"], ConfigurationManager.AppSettings["adminpassword"])); }
private void SetupIndex() { var manager = Bucket.CreateManager(); manager.CreateN1qlPrimaryIndex(false); }