本文整理汇总了C#中Cassandra.Session类的典型用法代码示例。如果您正苦于以下问题:C# Session类的具体用法?C# Session怎么用?C# Session使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Session类属于Cassandra命名空间,在下文中一共展示了Session类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: CassandraConnection
internal CassandraConnection(Session owner, IPAddress serverAddress, ProtocolOptions protocolOptions,
SocketOptions socketOptions, ClientOptions clientOptions,
IAuthInfoProvider authInfoProvider)
{
this._owner = owner;
_bufferingMode = null;
switch (protocolOptions.Compression)
{
case CompressionType.Snappy:
_bufferingMode = new FrameBuffering();
break;
case CompressionType.NoCompression:
_bufferingMode = clientOptions.WithoutRowSetBuffering ? new NoBuffering() : new FrameBuffering();
break;
default:
throw new ArgumentException();
}
this._authInfoProvider = authInfoProvider;
if (protocolOptions.Compression == CompressionType.Snappy)
{
_startupOptions.Add("COMPRESSION", "snappy");
_compressor = new SnappyProtoBufCompressor();
}
this._serverAddress = serverAddress;
this._port = protocolOptions.Port;
this._queryAbortTimeout = clientOptions.QueryAbortTimeout;
this._asyncCallAbortTimeout = clientOptions.AsyncCallAbortTimeout;
this._socketOptions = socketOptions;
CreateConnection();
if (IsHealthy)
BeginReading();
}
开发者ID:abhijitchanda,项目名称:csharp-driver,代码行数:35,代码来源:CassandraConnection.cs
示例2: CqlRowSet
internal CqlRowSet(OutputRows rawrows, Session session, bool ownRows = true)
{
this._rawrows = rawrows;
this._ownRows = ownRows;
if (rawrows.TraceID != null)
_queryTrace = new QueryTrace(rawrows.TraceID.Value, session);
}
开发者ID:abhijitchanda,项目名称:csharp-driver,代码行数:7,代码来源:CqlRowSet.cs
示例3: TwitterContext
public TwitterContext(Session session)
: base(session)
{
AddTable<Tweet>();
AddTable<Author>();
AddTable<FollowedTweet>();
AddTable<Statistics>();
CreateTablesIfNotExist();
}
开发者ID:hjarraya,项目名称:csharp-driver,代码行数:9,代码来源:TwitterContext.cs
示例4: ControlConnection
internal ControlConnection(Cluster cluster,
IEnumerable<IPAddress> clusterEndpoints,
Policies policies,
ProtocolOptions protocolOptions,
PoolingOptions poolingOptions,
SocketOptions socketOptions,
ClientOptions clientOptions,
IAuthInfoProvider authProvider,
bool metricsEnabled)
{
this._cluster = cluster;
this._reconnectionTimer = new Timer(ReconnectionClb, null, Timeout.Infinite, Timeout.Infinite);
_session = new Session(cluster, clusterEndpoints, policies, protocolOptions, poolingOptions, socketOptions,
clientOptions, authProvider, metricsEnabled, "", _cluster._hosts);
}
开发者ID:abhijitchanda,项目名称:csharp-driver,代码行数:16,代码来源:ControlConnection.cs
示例5: ControlConnection
internal ControlConnection(Cluster cluster,
IEnumerable<IPAddress> clusterEndpoints,
Policies policies,
ProtocolOptions protocolOptions,
PoolingOptions poolingOptions,
SocketOptions socketOptions,
ClientOptions clientOptions,
IAuthInfoProvider authProvider)
{
this._cluster = cluster;
this._reconnectionSchedule = _reconnectionPolicy.NewSchedule();
this._reconnectionTimer = new Timer(ReconnectionClb, null, Timeout.Infinite, Timeout.Infinite);
_session = new Session(cluster, policies, protocolOptions, poolingOptions, socketOptions,
clientOptions, authProvider, "", false);
}
开发者ID:ntent-ad,项目名称:csharp-driver,代码行数:16,代码来源:ControlConnection.cs
示例6: checkKSMetadata
public void checkKSMetadata()
{
CCMCluster = CCMBridge.CCMCluster.Create(2, Cluster.Builder());
try
{
Session = CCMCluster.Session;
Cluster = CCMCluster.Cluster;
Session.CreateKeyspaceIfNotExists(Keyspace);
Session.ChangeKeyspace(Keyspace);
string keyspacename = "keyspace" + Guid.NewGuid().ToString("N").ToLower();
bool durableWrites = false;
string strgyClass = "SimpleStrategy";
short rplctnFactor = 1;
Session.Cluster.WaitForSchemaAgreement(
Session.Execute(
string.Format(@"CREATE KEYSPACE {0}
WITH replication = {{ 'class' : '{1}', 'replication_factor' : {2} }}
AND durable_writes={3};"
, keyspacename, strgyClass, rplctnFactor.ToString(), durableWrites.ToString())).QueriedHost
);
Session.ChangeKeyspace(keyspacename);
for (int i = 0; i < 10; i++)
checkPureMetadata("table" + Guid.NewGuid().ToString("N"), keyspacename);
KeyspaceMetadata ksmd = Cluster.Metadata.GetKeyspace(keyspacename);
Assert.True(ksmd.DurableWrites == durableWrites);
Assert.True(ksmd.Replication.Where(opt => opt.Key == "replication_factor").First().Value == rplctnFactor);
Assert.True(ksmd.StrategyClass == strgyClass);
}
finally
{
CCMCluster.Discard();
}
}
开发者ID:joaquincasares,项目名称:csharp-driver,代码行数:37,代码来源:MetadataTests.cs
示例7: SetFixture
public void SetFixture()
{
Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-US");
CCMBridge.ReusableCCMCluster.Setup(2);
CCMBridge.ReusableCCMCluster.Build(Cluster.Builder());
Session = CCMBridge.ReusableCCMCluster.Connect("tester");
Session.CreateKeyspaceIfNotExists(KeyspaceName);
Session.ChangeKeyspace(KeyspaceName);
}
开发者ID:hjarraya,项目名称:csharp-driver,代码行数:9,代码来源:ComplexTests.cs
示例8: checkMetadata
public void checkMetadata(string TableName = null, string KeyspaceName = null, TableOptions tableOptions = null)
{
CCMCluster = CCMBridge.CCMCluster.Create(2, Cluster.Builder());
try
{
Session = CCMCluster.Session;
Cluster = CCMCluster.Cluster;
Session.CreateKeyspaceIfNotExists(Keyspace);
Session.ChangeKeyspace(Keyspace);
checkPureMetadata(TableName, KeyspaceName, tableOptions);
}
finally
{
CCMCluster.Discard();
}
}
开发者ID:joaquincasares,项目名称:csharp-driver,代码行数:17,代码来源:MetadataTests.cs
示例9: CCMCluster
private CCMCluster(CCMBridge ccmBridge, Builder builder)
{
int tryNo = 0;
builder.AddContactPoints(Options.Default.IP_PREFIX + "1");
if (Options.Default.USE_COMPRESSION)
{
builder.WithCompression(CompressionType.Snappy);
Console.WriteLine("Using Compression");
}
if (Options.Default.USE_NOBUFFERING)
{
builder.WithoutRowSetBuffering();
Console.WriteLine("No buffering");
}
this.Cluster = builder.Build();
RETRY:
this.CCMBridge = ccmBridge;
try
{
this.Session = Cluster.Connect();
if(tryNo>0)
Cluster.RefreshSchema();
}
catch (NoHostAvailableException e)
{
if (tryNo < 10)
{
Console.WriteLine("CannotConnect to CCM node - give another try");
tryNo++;
Thread.Sleep(1000);
goto RETRY;
}
foreach (var entry in e.Errors)
Trace.TraceError("Error connecting to " + entry.Key + ": " + entry.Value);
throw new InvalidOperationException(null, e);
}
}
开发者ID:hjarraya,项目名称:csharp-driver,代码行数:38,代码来源:CCMBridge.cs
示例10: SetFixture
public void SetFixture()
{
Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-US");
CCMBridge.ReusableCCMCluster.Setup(2);
CCMBridge.ReusableCCMCluster.Build(Cluster.Builder());
Session = CCMBridge.ReusableCCMCluster.Connect("tester");
}
开发者ID:ntent-ad,项目名称:csharp-driver,代码行数:7,代码来源:Basics.cs
示例11: QueryTrace
public QueryTrace(Guid traceId, Session session)
{
this._traceId = traceId;
this._session = session;
}
开发者ID:sdether,项目名称:csharp-driver,代码行数:5,代码来源:QueryTrace.cs
示例12: Connect
/// <summary>
/// Creates a new session on this cluster and sets a keyspace to use.
/// </summary>
/// <param name="keyspace"> The name of the keyspace to use for the created <code>Session</code>. </param>
/// <returns>a new session on this cluster set to keyspace:
/// <code>keyspaceName</code>. </returns>
public Session Connect(string keyspace)
{
var scs = new Session(this, _configuration.Policies,
_configuration.ProtocolOptions,
_configuration.PoolingOptions, _configuration.SocketOptions,
_configuration.ClientOptions,
_configuration.AuthInfoProvider, keyspace);
scs.Init();
lock (_connectedSessions)
_connectedSessions.Add(scs);
_logger.Info("Session connected!");
_metadata.RefreshSchema();
return scs;
}
开发者ID:hjarraya,项目名称:csharp-driver,代码行数:22,代码来源:Cluster.cs
示例13: SessionDisposed
internal void SessionDisposed(Session s)
{
lock (_connectedSessions)
_connectedSessions.Remove(s);
}
开发者ID:hjarraya,项目名称:csharp-driver,代码行数:5,代码来源:Cluster.cs
示例14: Connect
/// <summary>
/// Creates a new session on this cluster and using a keyspace an existing keyspace.
/// </summary>
/// <param name="keyspace">Case-sensitive keyspace name to use</param>
public ISession Connect(string keyspace)
{
Init();
var session = new Session(this, Configuration, keyspace, _protocolVersion);
session.Init();
_connectedSessions.Add(session);
_logger.Info("Session connected ({0})", session.GetHashCode());
return session;
}
开发者ID:GoldenCrystal,项目名称:csharp-driver,代码行数:13,代码来源:Cluster.cs
示例15: Connect
public static Session Connect(string keyspace = null)
{
int tryNo = 0;
RETRY:
try
{
Session = Cluster.Connect();
if (keyspace != null)
{
Session.CreateKeyspaceIfNotExists(keyspace);
Session.ChangeKeyspace(keyspace);
}
return Session;
}
catch (NoHostAvailableException e)
{
if (tryNo < 10)
{
Console.WriteLine("CannotConnect to CCM node - give another try");
tryNo++;
Thread.Sleep(1000);
goto RETRY;
}
foreach (var entry in e.Errors)
Trace.TraceError("Error connecting to " + entry.Key + ": " + entry.Value);
throw new InvalidOperationException(null, e);
}
}
开发者ID:hjarraya,项目名称:csharp-driver,代码行数:28,代码来源:CCMBridge.cs
示例16: BeginSessionExecute
protected internal override IAsyncResult BeginSessionExecute(Session session, object tag, AsyncCallback callback, object state)
{
return session.BeginExecuteQuery(PreparedStatement.Id, PreparedStatement.Metadata, _values, callback, state, ConsistencyLevel, this, this, tag, IsTracing);
}
开发者ID:abhijitchanda,项目名称:csharp-driver,代码行数:4,代码来源:BoundStatement.cs
示例17: BeginSessionExecute
protected internal override IAsyncResult BeginSessionExecute(Session session, object tag, AsyncCallback callback, object state)
{
return session.BeginQuery(QueryString, callback, state, ConsistencyLevel,IsTracing, this, this, tag);
}
开发者ID:joaquincasares,项目名称:csharp-driver,代码行数:4,代码来源:SimpleStatement.cs
示例18: EndSessionExecute
protected internal override CqlRowSet EndSessionExecute(Session session, IAsyncResult ar)
{
return session.EndExecuteQuery(ar);
}
开发者ID:abhijitchanda,项目名称:csharp-driver,代码行数:4,代码来源:BoundStatement.cs
示例19: SetFixture
public void SetFixture()
{
Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-US");
var clusterb = Cluster.Builder().AddContactPoint("cassi.cloudapp.net");
clusterb.WithDefaultKeyspace(Keyspace);
if (Cassandra.MSTest.Properties.Settings.Default.Compression)
{
clusterb.WithCompression(CompressionType.Snappy);
Console.WriteLine("Compression: Snappy Compression");
}
else Console.WriteLine("Compression: No Compression");
Cluster = clusterb.Build();
Diagnostics.CassandraTraceSwitch.Level = System.Diagnostics.TraceLevel.Verbose;
Diagnostics.CassandraStackTraceIncluded = true;
Diagnostics.CassandraPerformanceCountersEnabled = true;
Session = Cluster.ConnectAndCreateDefaultKeyspaceIfNotExists(ReplicationStrategies.CreateSimpleStrategyReplicationProperty(2), true);
}
开发者ID:abhijitchanda,项目名称:csharp-driver,代码行数:19,代码来源:Basics.cs
示例20: Connect
/// <summary>
/// Creates a new session on this cluster and sets a keyspace to use.
/// </summary>
/// <param name="keyspace"> The name of the keyspace to use for the created <code>Session</code>. </param>
/// <returns>a new session on this cluster set to keyspace:
/// <code>keyspaceName</code>. </returns>
public Session Connect(string keyspace)
{
bool controlConnectionCreated = false;
lock (_controlConnectionGuard)
{
if (_controlConnection == null)
{
controlConnectionCreated = true;
var controlpolicies = new Cassandra.Policies(
_configuration.Policies.LoadBalancingPolicy,
new ExponentialReconnectionPolicy(2 * 1000, 5 * 60 * 1000),
Cassandra.Policies.DefaultRetryPolicy);
_hosts = new Hosts(_configuration.Policies.ReconnectionPolicy);
foreach (var ep in _contactPoints)
_hosts.AddIfNotExistsOrBringUpIfDown(ep);
var poolingOptions = new PoolingOptions().SetCoreConnectionsPerHost(HostDistance.Local, 1);
_controlConnection = new ControlConnection(this, new List<IPAddress>(), controlpolicies,
_configuration.ProtocolOptions,
poolingOptions, _configuration.SocketOptions,
new ClientOptions(
_configuration.ClientOptions.WithoutRowSetBuffering,
_configuration.ClientOptions.QueryAbortTimeout, null,
_configuration.ClientOptions.AsyncCallAbortTimeout),
_configuration.AuthInfoProvider,
_configuration.MetricsEnabled);
_metadata = new Metadata(_hosts, _controlConnection);
_controlConnection.Init();
}
}
var scs = new Session(this, _contactPoints, _configuration.Policies,
_configuration.ProtocolOptions,
_configuration.PoolingOptions, _configuration.SocketOptions,
_configuration.ClientOptions,
_configuration.AuthInfoProvider, _configuration.MetricsEnabled, keyspace, _hosts);
scs.Init();
lock (_connectedSessions)
_connectedSessions.Add(scs);
_logger.Info("Session connected!");
if (controlConnectionCreated)
RefreshSchema();
return scs;
}
开发者ID:joaquincasares,项目名称:csharp-driver,代码行数:56,代码来源:Cluster.cs
注:本文中的Cassandra.Session类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论