本文整理汇总了C#中Cassandra.Session类的典型用法代码示例。如果您正苦于以下问题:C# Session类的具体用法?C# Session怎么用?C# Session使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Session类属于Cassandra命名空间,在下文中一共展示了Session类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
示例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);
}
示例3: TwitterContext
public TwitterContext(Session session)
: base(session)
{
AddTable<Tweet>();
AddTable<Author>();
AddTable<FollowedTweet>();
AddTable<Statistics>();
CreateTablesIfNotExist();
}
示例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);
}
示例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);
}
示例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();
}
}
示例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);
}
示例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();
}
}
示例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);
}
}
示例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");
}
示例11: QueryTrace
public QueryTrace(Guid traceId, Session session)
{
this._traceId = traceId;
this._session = session;
}
示例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;
}
示例13: SessionDisposed
internal void SessionDisposed(Session s)
{
lock (_connectedSessions)
_connectedSessions.Remove(s);
}
示例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;
}
示例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);
}
}