本文整理汇总了C#中Couchbase.Configuration.Client.ClientConfiguration类的典型用法代码示例。如果您正苦于以下问题:C# ClientConfiguration类的具体用法?C# ClientConfiguration怎么用?C# ClientConfiguration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ClientConfiguration类属于Couchbase.Configuration.Client命名空间,在下文中一共展示了ClientConfiguration类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Test_Default
public void Test_Default()
{
var config = new ClientConfiguration();
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(2, bucketConfig.PoolConfiguration.MaxSize);
Assert.AreEqual(1, bucketConfig.PoolConfiguration.MinSize);
Assert.AreEqual(2500, bucketConfig.PoolConfiguration.RecieveTimeout);
Assert.AreEqual(2500, bucketConfig.PoolConfiguration.OperationTimeout);
Assert.AreEqual(10000, bucketConfig.PoolConfiguration.ShutdownTimeout);
Assert.AreEqual(2500, bucketConfig.DefaultOperationLifespan);
Assert.AreEqual(75000, config.ViewRequestTimeout);
}
开发者ID:TDevs,项目名称:couchbase-net-client,代码行数:25,代码来源:ClientConfigurationTests.cs
示例2: TestFixtureSetup
public void TestFixtureSetup()
{
var configuration = new ClientConfiguration();
var connectionPool = new ConnectionPool<EapConnection>(new PoolConfiguration(), UriExtensions.GetEndPoint(Address));
var ioStrategy = new DefaultIOStrategy(connectionPool);
_server = new Server(ioStrategy, new Node(), configuration);
}
开发者ID:WhallaLabs,项目名称:couchbase-net-client,代码行数:7,代码来源:ServerTests.cs
示例3: ClusterController
public ClusterController(ClientConfiguration clientConfig)
: this(clientConfig,
pool =>
{
Log.Debug(m => m("Creating DefaultIOStrategy"));
return new DefaultIOStrategy(pool);
},
(config, endpoint) =>
{
IConnectionPool connectionPool;
if (config.UseSsl)
{
connectionPool = new ConnectionPool<SslConnection>(config, endpoint);
}
else
{
connectionPool = new ConnectionPool<Connection>(config, endpoint);
}
connectionPool.Initialize();
return connectionPool;
},
SaslFactory.GetFactory3(),
clientConfig.Converter(),
clientConfig.Transcoder())
{
}
开发者ID:kendallb,项目名称:couchbase-net-client,代码行数:26,代码来源:ClusterController.cs
示例4: PoolConfiguration
public PoolConfiguration(ClientConfiguration clientConfiguration = null)
{
_maxSize = Defaults.MaxSize;
_minSize = Defaults.MinSize;
WaitTimeout = Defaults.WaitTimeout;
#pragma warning disable 612
RecieveTimeout = Defaults.ReceiveTimeout;
#pragma warning restore 612
ShutdownTimeout = Defaults.ShutdownTimeout;
#pragma warning disable 618
OperationTimeout = Defaults.OperationTimeout;
#pragma warning restore 618
MaxAcquireIterationCount = Defaults.MaxAcquireIterationCount;
SendTimeout = Defaults.SendTimeout;
BufferSize = Defaults.BufferSize;
ConnectTimeout = Defaults.ConnectTimeout;
EnableTcpKeepAlives = Defaults.EnableTcpKeepAlives;
TcpKeepAliveTime = Defaults.TcpKeepAliveTime;
TcpKeepAliveInterval = Defaults.TcpKeepAliveInterval;
CloseAttemptInterval = Defaults.CloseAttemptInterval;
MaxCloseAttempts = Defaults.MaxCloseAttempts;
UseEnhancedDurability = Defaults.UseEnhancedDurability;
//in some cases this is needed all the way down the stack
ClientConfiguration = clientConfiguration;
BufferAllocator = (p) => new BufferAllocator(p.MaxSize * p.BufferSize, p.BufferSize);
}
开发者ID:brantburnett,项目名称:couchbase-net-client,代码行数:27,代码来源:PoolConfiguration.cs
示例5: Main
private static void Main(string[] args)
{
var count = 100000;
var config = new ClientConfiguration
{
Servers = new List<Uri>
{
//change this to your cluster to bootstrap
new Uri("http://localhost/:8091/pools")
}
};
ClusterHelper.Initialize(config);
var bucket = ClusterHelper.GetBucket("default");
var items = new List<Person>();
for (int i = 0; i < count; i++)
{
items.Add(new Person {Age = 21, Name = "Some name" + i, Id = i.ToString()});
}
Task.Run(async () => await UpsertAllAsync(items, bucket)).ConfigureAwait(false);
Console.Read();
ClusterHelper.Close();
}
开发者ID:vinhdang,项目名称:couchbase-net-examples,代码行数:26,代码来源:Program.cs
示例6: GetBucketForKey
public IBucket GetBucketForKey(string key)
{
var config = new ClientConfiguration();
var fakeServer = new FakeServer(_connectionPool, null, null, _endPoint,
new FakeIOStrategy(_endPoint, _connectionPool, false));
var mappedNode = new Mock<IMappedNode>();
mappedNode.Setup(x => x.LocatePrimary()).Returns(fakeServer);
var mockKeyMapper = new Mock<IKeyMapper>();
mockKeyMapper.Setup(x => x.MapKey(key)).Returns(mappedNode.Object);
var mockConfigInfo = new Mock<IConfigInfo>();
mockConfigInfo.Setup(x => x.GetKeyMapper()).Returns(mockKeyMapper.Object);
mockConfigInfo.Setup(x => x.BucketConfig).Returns(_bucketConfig);
mockConfigInfo.Setup(x => x.GetServer()).Returns(fakeServer);
var mockController = new Mock<IClusterController>();
mockController.Setup(x => x.Configuration).Returns(config);
mockController.Setup(x => x.CreateBucket("memcached", ""))
.Returns(new MemcachedBucket(mockController.Object, "memcached", _converter, _transcoder));
var cluster = new Cluster(config, mockController.Object);
var bucket = cluster.OpenBucket("memcached", "");
//simulate a config event
((IConfigObserver) bucket).NotifyConfigChanged(mockConfigInfo.Object);
return bucket;
}
开发者ID:kendallb,项目名称:couchbase-net-client,代码行数:30,代码来源:MemcachedBucket_Async_Tests.cs
示例7: 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);
}
开发者ID:WhallaLabs,项目名称:couchbase-net-client,代码行数:25,代码来源:KeyObserverTests.cs
示例8: ConfigInfo
public ConfigInfo(IServerConfig serverConfig, ClientConfiguration clientConfig)
{
ServerConfig = serverConfig;
ClientConfig = clientConfig;
CreationTime = DateTime.Now;
Initialize();
}
开发者ID:hyah,项目名称:couchbase-net-client,代码行数:7,代码来源:ConfigInfo.cs
示例9: 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);
}
开发者ID:WhallaLabs,项目名称:couchbase-net-client,代码行数:32,代码来源:ClientConfigurationTests.cs
示例10: 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);
}
}
开发者ID:brantburnett,项目名称:couchbase-net-client,代码行数:34,代码来源:KeyObserverTests.cs
示例11: Main
static void Main(string[] args)
{
File.Delete(@"C:\temp\log.txt");
var config = new ClientConfiguration
{
Servers = new List<Uri>
{
new Uri("http://127.0.0.1:8091/pools")
},
PoolConfiguration = new PoolConfiguration
{
MaxSize = 2,
MinSize = 1
},
UseSsl = false
};
using (_cluster = new CouchbaseCluster(config))
{
using (var bucket = _cluster.OpenBucket("default"))
{
const int n = 100000;
using (var timer = new OperationTimer())
{
//ThreadPoolInsert(bucket, n);
//ThreadPoolInsert(bucket, n);
//SynchronousInsert(bucket, n);
//ParallerInsert(bucket, n);
MultiThreaded(8, n, bucket);
}
}
}
Console.Read();
}
开发者ID:WhallaLabs,项目名称:couchbase-net-client,代码行数:34,代码来源:Program.cs
示例12: ClusterHelper
/// <summary>
/// Ctor for creating Cluster instance.
/// </summary>
/// <param name="configuration">The ClientCOnfiguration to use for initialization.</param>
/// <param name="clusterManager">The ClusterManager instance use.</param>
/// <remarks>
/// This overload is primarly added for testing.
/// </remarks>
internal ClusterHelper(ClientConfiguration configuration, IClusterController clusterManager, ILoggerFactory loggerFactory)
{
_loggerFactory = loggerFactory;
Log = _loggerFactory.CreateLogger<ClusterHelper>();
_configuration = configuration;
_clusterManager = clusterManager;
}
开发者ID:RossMerr,项目名称:CouchbaseNetClient,代码行数:15,代码来源:ClusterHelper.cs
示例13: Initialize
public static void Initialize()
{
var config = new ClientConfiguration();
config.BucketConfigs.Clear();
config.Servers = new List<Uri>(new Uri[] { new Uri(CouchbaseConfigHelper.Instance.Server) });
config.BucketConfigs.Add(
CouchbaseConfigHelper.Instance.Bucket,
new BucketConfiguration
{
BucketName = CouchbaseConfigHelper.Instance.Bucket,
Username = CouchbaseConfigHelper.Instance.User,
Password = CouchbaseConfigHelper.Instance.Password
});
config.BucketConfigs.Add(
"default",
new BucketConfiguration
{
BucketName = "default",
Username = CouchbaseConfigHelper.Instance.User,
Password = CouchbaseConfigHelper.Instance.Password
});
ClusterHelper.Initialize(config);
}
开发者ID:boblarson57,项目名称:try-cb-dotnet,代码行数:27,代码来源:CouchbaseConfig.cs
示例14: SearchClient
public SearchClient(IBucketConfig bucketConfig, ClientConfiguration clientConfig, IDataMapper dataMapper, ILogger logger)
{
_bucketConfig = bucketConfig;
_clientConfig = clientConfig;
DataMapper = dataMapper;
Log = logger;
}
开发者ID:RossMerr,项目名称:CouchbaseNetClient,代码行数:7,代码来源:SearchClient.cs
示例15: Cluster
public Cluster Cluster()
{
var config = new ClientConfiguration
{
Servers = new List<Uri>
{
new Uri(hostName +":8091/pools"),
},
UseSsl = false,
BucketConfigs = new Dictionary<string, BucketConfiguration>
{
{
"default",
new BucketConfiguration
{
BucketName = bucketName,
UseSsl = false,
Password = password,
PoolConfiguration = new PoolConfiguration
{
MaxSize = 5,
MinSize = 1
}
}
}
}
};
return new Cluster(config);
}
开发者ID:devindewitt,项目名称:Workshop,代码行数:30,代码来源:DatabaseConfig.cs
示例16: ClusterManager
public ClusterManager(ClientConfiguration clientConfig)
: this(clientConfig,
pool =>
{
Log.Debug(m => m("Creating DefaultIOStrategy"));
return new DefaultIOStrategy(pool);
},
(config, endpoint) =>
{
IConnectionPool connectionPool;
if (config.UseSsl)
{
connectionPool = new ConnectionPool<SslConnection>(config, endpoint);
}
else
{
connectionPool = new ConnectionPool<EapConnection>(config, endpoint);
}
return connectionPool;
},
SaslFactory.GetFactory3(),
new AutoByteConverter(),
new TypeSerializer(new AutoByteConverter(), clientConfig.DeserializationContractResolver, clientConfig.SerializationContractResolver))
{
}
开发者ID:WhallaLabs,项目名称:couchbase-net-client,代码行数:25,代码来源:ClusterManager.cs
示例17: PoolConfiguration
public PoolConfiguration(ILoggerFactory loggerFactory = null, ClientConfiguration clientConfiguration = null)
{
_loggerFactory = loggerFactory;
if (loggerFactory != null)
Log = _loggerFactory.CreateLogger<PoolConfiguration>();
MaxSize = Defaults.MaxSize;
MinSize = Defaults.MinSize;
WaitTimeout = Defaults.WaitTimeout;
RecieveTimeout = Defaults.ReceiveTimeout;
ShutdownTimeout = Defaults.ShutdownTimeout;
OperationTimeout = Defaults.OperationTimeout;
MaxAcquireIterationCount = Defaults.MaxAcquireIterationCount;
SendTimeout = Defaults.SendTimeout;
BufferSize = Defaults.BufferSize;
ConnectTimeout = Defaults.ConnectTimeout;
EnableTcpKeepAlives = Defaults.EnableTcpKeepAlives;
TcpKeepAliveTime = Defaults.TcpKeepAliveTime;
TcpKeepAliveInterval = Defaults.TcpKeepAliveInterval;
CloseAttemptInterval = Defaults.CloseAttemptInterval;
MaxCloseAttempts = Defaults.MaxCloseAttempts;
UseEnhancedDurability = Defaults.UseEnhancedDurability;
//in some cases this is needed all the way down the stack
ClientConfiguration = clientConfiguration;
BufferAllocator = (p) => new BufferAllocator(p.MaxSize * p.BufferSize, p.BufferSize, loggerFactory);
}
开发者ID:RossMerr,项目名称:CouchbaseNetClient,代码行数:27,代码来源:PoolConfiguration.cs
示例18: 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);
}
}
开发者ID:kendallb,项目名称:couchbase-net-client,代码行数:27,代码来源:ServerTests.cs
示例19: 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);
}
开发者ID:WhallaLabs,项目名称:couchbase-net-client,代码行数:35,代码来源:KeyObserverTests.cs
示例20: When_Configuration_Contains_Bad_Bucket_Password_It_Is_Used_And_Fails
public void When_Configuration_Contains_Bad_Bucket_Password_It_Is_Used_And_Fails()
{
var config = new ClientConfiguration((CouchbaseClientSection) ConfigurationManager.GetSection("couchbaseClients/couchbase"));
config.BucketConfigs = new Dictionary<string, BucketConfiguration>
{
{
"default",
new BucketConfiguration
{
BucketName = "default",
Password = "secret"
}
}
};
var cluster = new Cluster(config);
var bucketName = config.BucketConfigs.Single().Value.BucketName;
try
{
var bucket = cluster.OpenBucket(bucketName);
Assert.Fail("Unexpected GetBucket success");
}
catch (AggregateException e)
{
e = e.Flatten();
if (e.InnerExceptions.All(x => x.GetType() != typeof (AuthenticationException)))
{
Assert.Fail("Expected authentication exception, got " + e.InnerException);
}
//success
}
}
开发者ID:brantburnett,项目名称:couchbase-net-client,代码行数:32,代码来源:ClusterTests.cs
注:本文中的Couchbase.Configuration.Client.ClientConfiguration类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论