当前位置: 首页>>代码示例>>C#>>正文


C# Cassandra.Session类代码示例

本文整理汇总了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();
        }
开发者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


注:本文中的Cassandra.Session类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。