本文整理汇总了C#中Couchbase.Configuration.Client.ClientConfiguration.Initialize方法的典型用法代码示例。如果您正苦于以下问题:C# ClientConfiguration.Initialize方法的具体用法?C# ClientConfiguration.Initialize怎么用?C# ClientConfiguration.Initialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Couchbase.Configuration.Client.ClientConfiguration
的用法示例。
在下文中一共展示了ClientConfiguration.Initialize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: When_GetBaseViewUri_Is_Called_With_EncryptTraffic_True_Uri_Is_SSL_URI
public void When_GetBaseViewUri_Is_Called_With_EncryptTraffic_True_Uri_Is_SSL_URI()
{
var configuration = new ClientConfiguration
{
UseSsl = true
};
configuration.Initialize();
var json = File.ReadAllText(@"Data\\Configuration\\cb4-config-4-nodes.json");
var config = JsonConvert.DeserializeObject<BucketConfig>(json);
var nodes = config.GetNodes();
var node = nodes.Find(x => x.Hostname.Equals("192.168.109.104"));
var ioStrategy = new FakeIOStrategy(UriExtensions.GetEndPoint(node.Hostname + ":" + node.KeyValue),
new FakeConnectionPool(), false);
using (var server = new Server(ioStrategy,
node,
configuration,
config,
new FakeTranscoder()))
{
var uri = server.CachedViewBaseUri;
Assert.AreEqual("https://192.168.109.104:18092/default", uri);
}
}
示例2: When_Observing_Key_During_RemoveAsync_Durability_Constraint_Is_Reached
public async Task When_Observing_Key_During_RemoveAsync_Durability_Constraint_Is_Reached()
{
var configuration = new ClientConfiguration
{
Servers = new List<Uri>
{
new Uri(ConfigurationManager.AppSettings["bootstrapUrl"])
}
};
configuration.Initialize();
var provider = new CarrierPublicationProvider(
configuration,
(pool) => new PooledIOService(pool),
(config, endpoint) => new ConnectionPool<Connection>(config, endpoint),
SaslFactory.GetFactory(),
new DefaultConverter(),
new DefaultTranscoder(new DefaultConverter()));
var configInfo = provider.GetConfig("default");
var clusterController = new Mock<IClusterController>();
clusterController.Setup(x => x.Transcoder).Returns(new DefaultTranscoder());
var pending = new ConcurrentDictionary<uint, IOperation>();
var observer = new KeyObserver(pending, configInfo, clusterController.Object, 10, 500);
using (var cts = new CancellationTokenSource(configuration.ObserveTimeout))
{
var constraintReached =
await observer.ObserveRemoveAsync("Test_Timeout_Remove_Async", 0, ReplicateTo.Zero, PersistTo.One, cts);
Assert.IsTrue(constraintReached);
}
}
示例3: SetUp
public void SetUp()
{
var configuration = new ClientConfiguration
{
UseSsl = true
};
configuration.Initialize();
var json = File.ReadAllText(@"Data\\Configuration\\cb4-config-4-nodes.json");
var config = JsonConvert.DeserializeObject<BucketConfig>(json);
var nodes = config.GetNodes();
var node = nodes.Find(x => x.Hostname.Equals("192.168.109.104"));
var ioStrategy = new FakeIOStrategy(UriExtensions.GetEndPoint(node.Hostname + ":" + node.KeyValue),
new FakeConnectionPool(), false);
_configContext = new CouchbaseConfigContext(config,
configuration,
pool => ioStrategy,
(c, e) => new FakeConnectionPool(),
SaslFactory.GetFactory(),
new DefaultTranscoder(new DefaultConverter()));
_configContext.LoadConfig();
}
示例4: Test_Custom
public void Test_Custom()
{
var config = new ClientConfiguration
{
PoolConfiguration = new PoolConfiguration
{
MaxSize = 10,
MinSize = 10
}
};
config.Initialize();
Assert.AreEqual(1, config.BucketConfigs.Count);
var bucketConfig = config.BucketConfigs.First().Value;
IPAddress ipAddress;
IPAddress.TryParse("127.0.0.1", out ipAddress);
var endPoint = new IPEndPoint(ipAddress, bucketConfig.Port);
Assert.AreEqual(endPoint, bucketConfig.GetEndPoint());
Assert.IsEmpty(bucketConfig.Password);
Assert.IsEmpty(bucketConfig.Username);
Assert.AreEqual(11210, bucketConfig.Port);
Assert.AreEqual("default", bucketConfig.BucketName);
Assert.AreEqual(10, bucketConfig.PoolConfiguration.MaxSize);
Assert.AreEqual(10, bucketConfig.PoolConfiguration.MinSize);
Assert.AreEqual(2500, bucketConfig.PoolConfiguration.RecieveTimeout);
Assert.AreEqual(2500, bucketConfig.PoolConfiguration.OperationTimeout);
Assert.AreEqual(10000, bucketConfig.PoolConfiguration.ShutdownTimeout);
}
示例5: When_Observing_Key_During_Remove_Durability_Constraint_Is_Reached
public void When_Observing_Key_During_Remove_Durability_Constraint_Is_Reached()
{
var configuration = new ClientConfiguration
{
Servers = new List<Uri>
{
new Uri(ConfigurationManager.AppSettings["bootstrapUrl"])
}
};
configuration.Initialize();
var provider = new CarrierPublicationProvider(
configuration,
(pool) => new DefaultIOStrategy(pool),
(config, endpoint) => new ConnectionPool<EapConnection>(config, endpoint),
SaslFactory.GetFactory3(),
new AutoByteConverter(),
new TypeSerializer(new AutoByteConverter()));
var configInfo = provider.GetConfig("default");
var observer = new KeyObserver(configInfo, 10, 500);
var constraintReached = observer.ObserveRemove("Test_Timeout_Remove", 0, ReplicateTo.Zero, PersistTo.One);
Assert.IsTrue(constraintReached);
}
示例6: When_Observing_Key_During_Add_Durability_Constraint_Is_Reached
public void When_Observing_Key_During_Add_Durability_Constraint_Is_Reached()
{
var configuration = new ClientConfiguration
{
Servers = new List<Uri>
{
new Uri(ConfigurationManager.AppSettings["bootstrapUrl"])
}
};
configuration.Initialize();
var provider = new CarrierPublicationProvider(
configuration,
(pool) => new DefaultIOStrategy(pool),
(config, endpoint) => new ConnectionPool<EapConnection>(config, endpoint),
SaslFactory.GetFactory3(),
new AutoByteConverter(),
new TypeSerializer(new AutoByteConverter()));
var configInfo = provider.GetConfig("default");
ulong cas = 0;
using (var cluster = new CouchbaseCluster(configuration))
{
using (var bucket = cluster.OpenBucket())
{
bucket.Remove("Test_Timeout_Add");
bucket.Insert("Test_Timeout_Add", "");
cas = bucket.Upsert("Test_Timeout_Add", "").Cas;
}
}
var observer = new KeyObserver(configInfo, 10, 500);
var constraintReached = observer.ObserveAdd("Test_Timeout_Add", cas, ReplicateTo.One, PersistTo.One);
Assert.IsTrue(constraintReached);
}
示例7: Test_LoadConfig
//[Test]
public void Test_LoadConfig()
{
var clientConfig = new ClientConfiguration
{
Servers = new List<Uri>
{
new Uri(ConfigurationManager.AppSettings["bootstrapUrl"])
},
PoolConfiguration = new PoolConfiguration
{
MaxSize = 2,
MinSize = 1
},
UseSsl = false
};
clientConfig.Initialize();
var bucketConfig =
JsonConvert.DeserializeObject<BucketConfig>(
File.ReadAllText("Data\\Configuration\\config-revision-8934.json"));
var configInfo = new CouchbaseConfigContext(bucketConfig,
clientConfig,
pool => new DefaultIOStrategy(pool),
(config, endpoint) => new ConnectionPool<Connection>(config, endpoint),
SaslFactory.GetFactory3(),
new DefaultTranscoder(new DefaultConverter()));
configInfo.LoadConfig();
var servers = configInfo.GetServers();
Assert.AreEqual(servers.Count(), bucketConfig.Nodes.Count());
var vbuckets = configInfo.GetVBuckets();
for (int i = 0; i < 1024; i++)
{
var actual = vbuckets[i].Primary;
var expected = bucketConfig.VBucketServerMap.VBucketMap[i][0];
Assert.AreEqual(expected, actual);
}
var bucketConfig2 =
JsonConvert.DeserializeObject<BucketConfig>(
File.ReadAllText("Data\\Configuration\\config-revision-9958.json"));
configInfo.LoadConfig(bucketConfig2);
servers = configInfo.GetServers();
Assert.AreEqual(servers.Count(), bucketConfig2.Nodes.Count());
vbuckets = configInfo.GetVBuckets();
for (int i = 0; i < 1024; i++)
{
var actual = vbuckets[i].Primary;
var expected = bucketConfig2.VBucketServerMap.VBucketMap[i][0];
Assert.AreEqual(expected, actual);
}
Log.Debug(m => m("CLEANUP!"));
configInfo.Dispose();
}
示例8: Test_KeySeqnoObserver
public void Test_KeySeqnoObserver()
{
var configuration = new ClientConfiguration
{
Servers = new List<Uri>
{
new Uri(ConfigurationManager.AppSettings["bootstrapUrl"])
}
};
var key = "Test_KeySeqnoObserver";
using (var cluster = new Cluster(configuration))
{
using (var bucket = cluster.OpenBucket())
{
bucket.Remove(key);
}
}
configuration.Initialize();
var provider = new CarrierPublicationProvider(
configuration,
(pool) => new PooledIOService(pool),
(config, endpoint) => new ConnectionPool<Connection>(config, endpoint),
SaslFactory.GetFactory(),
new DefaultConverter(),
new DefaultTranscoder(new DefaultConverter(), new DefaultSerializer()));
var configInfo = provider.GetConfig("default");
var features = new List<short>();
features.Add((short)ServerFeatures.MutationSeqno);
var keyMapper = configInfo.GetKeyMapper();
var mappedNode = keyMapper.MapKey(key);
var node = mappedNode.LocatePrimary();
foreach (var server in configInfo.Servers.Where(x=>x.IsDataNode))
{
var hello = new Hello("couchbase-net-sdk/2.1.4", features.ToArray(), provider.Transcoder, 0, 0);
var result3 = server.Send(hello);
Assert.IsTrue(result3.Success);
}
var result = node.Send(new Add<string>(key, "", (VBucket)mappedNode,
new DefaultTranscoder(new DefaultConverter(), new DefaultSerializer()), 1000));
var clusterController = new Mock<IClusterController>();
clusterController.Setup(x => x.Transcoder).Returns(new DefaultTranscoder());
var pending = new ConcurrentDictionary<uint, IOperation>();
var keyObserver = new KeySeqnoObserver("thekey", pending, configInfo, clusterController.Object, 0, 1000);
var durabilityReached = keyObserver.Observe(result.Token, ReplicateTo.Zero, PersistTo.One);
Assert.IsTrue(durabilityReached);
}
示例9: When_EnableTcpKeepAlives_Disabled_On_PoolConfiguration_Defaults_Are_Not_Used
public void When_EnableTcpKeepAlives_Disabled_On_PoolConfiguration_Defaults_Are_Not_Used()
{
var clientConfig = new ClientConfiguration();
clientConfig.PoolConfiguration.EnableTcpKeepAlives = false;
clientConfig.Initialize();
Assert.AreEqual(ClientConfiguration.Defaults.EnableTcpKeepAlives, clientConfig.EnableTcpKeepAlives);
Assert.AreEqual(false, clientConfig.PoolConfiguration.EnableTcpKeepAlives);
}
示例10: When_TcpKeepAliveTime_Set_On_PoolConfiguration_Defaults_Are_Not_Used
public void When_TcpKeepAliveTime_Set_On_PoolConfiguration_Defaults_Are_Not_Used()
{
var clientConfig = new ClientConfiguration();
clientConfig.PoolConfiguration.TcpKeepAliveTime = 1000;
clientConfig.Initialize();
Assert.AreEqual(ClientConfiguration.Defaults.TcpKeepAliveTime, clientConfig.TcpKeepAliveTime);
Assert.AreEqual(1000, clientConfig.PoolConfiguration.TcpKeepAliveTime);
}
示例11: When_TcpKeepAliveInterval_Set_On_ClientConfiguration_Defaults_Are_Not_Used
public void When_TcpKeepAliveInterval_Set_On_ClientConfiguration_Defaults_Are_Not_Used()
{
var clientConfig = new ClientConfiguration
{
TcpKeepAliveInterval = 10
};
clientConfig.Initialize();
Assert.AreEqual(10, clientConfig.TcpKeepAliveInterval);
Assert.AreEqual(10, clientConfig.PoolConfiguration.TcpKeepAliveInterval);
}
示例12: GetConfiguration
/// <summary>
/// Gets the connection using the value of the <c>bootstrapUrl</c> in the App.Config as the node to bootstrap from.
/// </summary>
/// <returns></returns>
public static ClientConfiguration GetConfiguration()
{
var config = new ClientConfiguration
{
Servers = new List<Uri>
{
new Uri(ConfigurationManager.AppSettings["bootstrapUrl"])
}
};
config.ConnectionPoolCreator = ConnectionPoolFactory.GetFactory<ConnectionPool<MultiplexingConnection>>();
config.IOServiceCreator = IOServiceFactory.GetFactory<MultiplexingIOService>();
config.Initialize();
return config;
}
示例13: When_GetBaseViewUri_Is_Called_With_EncryptTraffic_True_Uri_Is_SSL_URI
public void When_GetBaseViewUri_Is_Called_With_EncryptTraffic_True_Uri_Is_SSL_URI()
{
var configuration = new ClientConfiguration
{
UseSsl = true
};
configuration.Initialize();
var connectionPool = new ConnectionPool<EapConnection>(new PoolConfiguration(), UriExtensions.GetEndPoint(Address));
var ioStrategy = new DefaultIOStrategy(connectionPool);
using (var server = new Server(ioStrategy, new Node(), configuration))
{
var uri = server.GetBaseViewUri("default");
Assert.AreEqual("https://localhost:18092/default", uri);
}
}
示例14: Test_Custom
public void Test_Custom()
{
var config = new ClientConfiguration
{
DefaultOperationLifespan = 123,
PoolConfiguration = new PoolConfiguration
{
MaxSize = 10,
MinSize = 10,
SendTimeout = 12000,
MaxCloseAttempts = 6,
CloseAttemptInterval = 120
},
ViewRequestTimeout = 5000
};
config.Initialize();
Assert.AreEqual(1, config.BucketConfigs.Count);
var bucketConfig = config.BucketConfigs.First().Value;
IPAddress ipAddress;
IPAddress.TryParse("127.0.0.1", out ipAddress);
var endPoint = new IPEndPoint(ipAddress, bucketConfig.Port);
Assert.AreEqual(endPoint, bucketConfig.GetEndPoint());
Assert.IsEmpty(bucketConfig.Password);
Assert.IsEmpty(bucketConfig.Username);
Assert.AreEqual(11210, bucketConfig.Port);
Assert.AreEqual("default", bucketConfig.BucketName);
Assert.AreEqual(10, bucketConfig.PoolConfiguration.MaxSize);
Assert.AreEqual(10, bucketConfig.PoolConfiguration.MinSize);
#pragma warning disable 612
Assert.AreEqual(2500, bucketConfig.PoolConfiguration.RecieveTimeout);
#pragma warning restore 612
#pragma warning disable 618
Assert.AreEqual(2500, bucketConfig.PoolConfiguration.OperationTimeout);
#pragma warning restore 618
Assert.AreEqual(10000, bucketConfig.PoolConfiguration.ShutdownTimeout);
Assert.AreEqual(12000, bucketConfig.PoolConfiguration.SendTimeout);
Assert.AreEqual(123, bucketConfig.DefaultOperationLifespan);
Assert.AreEqual(120, bucketConfig.PoolConfiguration.CloseAttemptInterval);
Assert.AreEqual(6, bucketConfig.PoolConfiguration.MaxCloseAttempts);
Assert.AreEqual(5000, config.ViewRequestTimeout);
}
示例15: Test_ClientConnection_With_Ssl
public void Test_ClientConnection_With_Ssl()
{
var bootstrapUrl = ConfigurationManager.AppSettings["bootstrapUrl"];
var config = new ClientConfiguration
{
UseSsl = true,
Servers = new List<Uri>
{
new Uri(bootstrapUrl)
}};
config.Initialize();
var cluster = new Cluster(config);
using (var bucket = cluster.OpenBucket())
{
Assert.IsNotNull(bucket);
}
}