本文整理汇总了C#中Couchbase.Configuration.Client.ClientConfiguration类的典型用法代码示例。如果您正苦于以下问题:C# ClientConfiguration类的具体用法?C# ClientConfiguration怎么用?C# ClientConfiguration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ClientConfiguration类属于Couchbase.Configuration.Client命名空间,在下文中一共展示了ClientConfiguration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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);
}
示例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())
{
}
示例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);
}
示例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();
}
示例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;
}
示例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);
}
示例8: ConfigInfo
public ConfigInfo(IServerConfig serverConfig, ClientConfiguration clientConfig)
{
ServerConfig = serverConfig;
ClientConfig = clientConfig;
CreationTime = DateTime.Now;
Initialize();
}
示例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);
}
示例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);
}
}
示例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();
}
示例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;
}
示例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);
}
示例14: SearchClient
public SearchClient(IBucketConfig bucketConfig, ClientConfiguration clientConfig, IDataMapper dataMapper, ILogger logger)
{
_bucketConfig = bucketConfig;
_clientConfig = clientConfig;
DataMapper = dataMapper;
Log = logger;
}
示例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);
}