public Task InitializeMembershipTable(GlobalConfiguration globalConfiguration, bool tryInitTableVersion, Logger traceLogger)
 {
     Couchbase.Configuration.Client.ClientConfiguration clientConfig = new Couchbase.Configuration.Client.ClientConfiguration();
     clientConfig.Servers.Clear();
     clientConfig.Servers.Add(new Uri(globalConfiguration.DataConnectionString));
     clientConfig.BucketConfigs.Clear();
     clientConfig.BucketConfigs.Add("membership", new Couchbase.Configuration.Client.BucketConfiguration
     {
         BucketName = "membership",
         Username   = "",
         Password   = ""
     });
     manager = new MembershipDataManager("membership", clientConfig);
     return(TaskDone.Done);
 }
Exemplo n.º 2
0
            public CouchBaseFixture()
            {
                var clientConfig = new Couchbase.Configuration.Client.ClientConfiguration();

                clientConfig.Servers.Clear();
                clientConfig.Servers.Add(new Uri("http://localhost:8091"));
                clientConfig.BucketConfigs.Clear();
                clientConfig.BucketConfigs.Add("default", new Couchbase.Configuration.Client.BucketConfiguration
                {
                    BucketName = "default",
                    Username   = "",
                    Password   = ""
                });
                manager = new CouchBaseDataManager("default", clientConfig, new ProviderRuntimeFixture());
            }
            public CouchBaseMembershipFixture()
            {
                var clientConfig = new Couchbase.Configuration.Client.ClientConfiguration();

                clientConfig.Servers.Clear();
                clientConfig.Servers.Add(new Uri("http://localhost:8091"));
                clientConfig.BucketConfigs.Clear();
                clientConfig.BucketConfigs.Add("membership", new Couchbase.Configuration.Client.BucketConfiguration
                {
                    BucketName = "membership",
                    Username   = "",
                    Password   = ""
                });

                manager = new MembershipDataManager("membership", clientConfig);
            }
        public Task InitializeGatewayListProvider(ClientConfiguration clientConfiguration, TraceLogger traceLogger)
        {
            Couchbase.Configuration.Client.ClientConfiguration clientConfig = new Couchbase.Configuration.Client.ClientConfiguration();
            clientConfig.Servers.Clear();
            clientConfig.Servers.Add(new Uri(clientConfiguration.DataConnectionString));
            clientConfig.BucketConfigs.Clear();
            clientConfig.BucketConfigs.Add("membership", new Couchbase.Configuration.Client.BucketConfiguration
            {
                BucketName = "membership",
                Username   = "",
                Password   = ""
            });
            manager = new MembershipDataManager("membership", null);

            refreshRate = clientConfiguration.GatewayListRefreshPeriod;
            return(TaskDone.Done);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Initializes the provider during silo startup.
        /// </summary>
        /// <param name="name">The name of this provider instance.</param>
        /// <param name="providerRuntime">A Orleans runtime object managing all storage providers.</param>
        /// <param name="config">Configuration info for this provider instance.</param>
        /// <returns>Completion promise for this operation.</returns>
        public override Task Init(string name, IProviderRuntime providerRuntime, IProviderConfiguration config)
        {
            this.Name = name;

            //Read config
            this.bucketName = config.Properties["BucketName"];
            var user     = config.Properties["UserName"];
            var password = config.Properties["Password"];
            var server   = config.Properties["Server"];

            //sanity check of config values
            if (string.IsNullOrWhiteSpace(bucketName))
            {
                throw new ArgumentException("BucketName property not set");
            }
            if (string.IsNullOrWhiteSpace(server))
            {
                throw new ArgumentException("Server property not set");
            }

            Couchbase.Configuration.Client.ClientConfiguration clientConfig = new Couchbase.Configuration.Client.ClientConfiguration();
            clientConfig.Servers.Clear();
            foreach (var s in server.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
            {
                clientConfig.Servers.Add(new Uri(s));
            }

            clientConfig.BucketConfigs.Clear();
            clientConfig.BucketConfigs.Add(bucketName, new Couchbase.Configuration.Client.BucketConfiguration
            {
                BucketName = this.bucketName,
                Username   = user,
                Password   = password
            });

            DataManager = new CouchBaseDataManager(bucketName, clientConfig);
            return(base.Init(name, providerRuntime, config));
        }
Exemplo n.º 6
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="bucketName">Name of the bucket that this manager should operate on.</param>
        /// <param name="clientConfig">Configuration object for the database client</param>
        /// /// <param name="documentExpiries">Expiry times by grain type</param>
        public CouchBaseDataManager(string bucketName, Couchbase.Configuration.Client.ClientConfiguration clientConfig, Dictionary <string, TimeSpan> documentExpiries)
        {
            //Bucket name should not be empty
            //Keep in mind that you should create the buckets before being able to use them either
            //using the commandline tool or the web console
            if (string.IsNullOrWhiteSpace(bucketName))
            {
                throw new ArgumentException("bucketName can not be null or empty");
            }
            //config should not be null either
            if (clientConfig == null)
            {
                throw new ArgumentException("You should supply a configuration to connect to CouchBase");
            }

            this.bucketName = bucketName;
            if (!OrleansCouchBaseStorage.IsInitialized)
            {
                ClusterHelper.Initialize(clientConfig);
                OrleansCouchBaseStorage.IsInitialized = true;
            }
            else
            {
                foreach (var conf in clientConfig.BucketConfigs)
                {
                    if (ClusterHelper.Get().Configuration.BucketConfigs.ContainsKey(conf.Key))
                    {
                        ClusterHelper.Get().Configuration.BucketConfigs.Remove(conf.Key);
                    }
                    ClusterHelper.Get().Configuration.BucketConfigs.Add(conf.Key, conf.Value);
                }
            }
            //cache the bucket.
            bucket = ClusterHelper.GetBucket(this.bucketName);

            DocumentExpiries = documentExpiries;
        }
 public MembershipDataManager(string bucketName, Couchbase.Configuration.Client.ClientConfiguration clientConfig) : base(bucketName, clientConfig)
 {
 }
Exemplo n.º 8
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="bucketName">Name of the bucket that this manager should operate on.</param>
 /// <param name="clientConfig">Configuration object for the database client</param>
 public CouchBaseDataManager(string bucketName, Couchbase.Configuration.Client.ClientConfiguration clientConfig) : this(bucketName, clientConfig, new Dictionary <string, TimeSpan>())
 {
 }