本文整理汇总了C#中Builder.AddContactPoint方法的典型用法代码示例。如果您正苦于以下问题:C# Builder.AddContactPoint方法的具体用法?C# Builder.AddContactPoint怎么用?C# Builder.AddContactPoint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Builder
的用法示例。
在下文中一共展示了Builder.AddContactPoint方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PagingOnBoundStatementTest_Async_UsingConfigBasedPagingSetting
public void PagingOnBoundStatementTest_Async_UsingConfigBasedPagingSetting()
{
var pageSize = 10;
var queryOptions = new QueryOptions().SetPageSize(pageSize);
Builder builder = new Builder().WithQueryOptions(queryOptions).WithDefaultKeyspace(KeyspaceName);
builder.AddContactPoint(TestCluster.InitialContactPoint);
using (ISession session = builder.Build().Connect())
{
var totalRowLength = 1003;
Tuple<string, string> tableNameAndStaticKeyVal = CreateTableWithCompositeIndexAndInsert(session, totalRowLength);
string statementToBeBound = "SELECT * from " + tableNameAndStaticKeyVal.Item1 + " where label=?";
PreparedStatement preparedStatementWithoutPaging = session.Prepare(statementToBeBound);
PreparedStatement preparedStatementWithPaging = session.Prepare(statementToBeBound);
BoundStatement boundStatemetWithoutPaging = preparedStatementWithoutPaging.Bind(tableNameAndStaticKeyVal.Item2);
BoundStatement boundStatemetWithPaging = preparedStatementWithPaging.Bind(tableNameAndStaticKeyVal.Item2);
var rsWithSessionPagingInherited = session.ExecuteAsync(boundStatemetWithPaging).Result;
var rsWithoutPagingInherited = Session.Execute(boundStatemetWithoutPaging);
//Check that the internal list of items count is pageSize
Assert.AreEqual(pageSize, rsWithSessionPagingInherited.InnerQueueCount);
Assert.AreEqual(totalRowLength, rsWithoutPagingInherited.InnerQueueCount);
var allTheRowsPaged = rsWithSessionPagingInherited.ToList();
Assert.AreEqual(totalRowLength, allTheRowsPaged.Count);
}
}
示例2: TestFixtureSetUp
public void TestFixtureSetUp()
{
var rp = new RetryLoadBalancingPolicy(new RoundRobinPolicy(), new ConstantReconnectionPolicy(100));
rp.ReconnectionEvent += (s, ev) => Thread.Sleep((int)ev.DelayMs);
_builder = Cluster.Builder()
.WithReconnectionPolicy(new ConstantReconnectionPolicy(100))
.WithQueryTimeout(60 * 1000)
.WithLoadBalancingPolicy(rp);
_builder = _builder.AddContactPoint(TestClusterManager.GetNonShareableTestCluster(NodeCount).InitialContactPoint);
}
示例3: CcmSetup
public static CcmClusterInfo CcmSetup(int nodeLength, Builder builder = null, string keyspaceName = null, int secondDcNodeLength = 0, bool connect = true)
{
var clusterInfo = new CcmClusterInfo();
if (builder == null)
{
builder = Cluster.Builder();
}
if (UseRemoteCcm)
{
CCMBridge.ReusableCCMCluster.Setup(nodeLength);
clusterInfo.Cluster = CCMBridge.ReusableCCMCluster.Build(builder);
if (keyspaceName != null)
{
clusterInfo.Session = CCMBridge.ReusableCCMCluster.Connect(keyspaceName);
}
}
else
{
//Create a local instance
clusterInfo.ConfigDir = TestUtils.CreateTempDirectory();
var output = TestUtils.ExecuteLocalCcmClusterStart(clusterInfo.ConfigDir, Options.Default.CASSANDRA_VERSION, nodeLength, secondDcNodeLength);
if (output.ExitCode != 0)
{
throw new TestInfrastructureException("Local ccm could not start: " + output.ToString());
}
try
{
if (connect)
{
clusterInfo.Cluster = builder
.AddContactPoint("127.0.0.1")
.Build();
clusterInfo.Session = clusterInfo.Cluster.Connect();
if (keyspaceName != null)
{
clusterInfo.Session.CreateKeyspaceIfNotExists(keyspaceName);
clusterInfo.Session.ChangeKeyspace(keyspaceName);
}
}
}
catch
{
CcmRemove(clusterInfo);
throw;
}
}
return clusterInfo;
}