예제 #1
0
        public void Session_GetState_Should_Return_Zero_After_Cluster_Disposal()
        {
            ISession           session;
            ISessionState      state;
            ICollection <Host> hosts;

            using (var cluster = Cluster.Builder()
                                 .AddContactPoint(_testCluster.InitialContactPoint)
                                 .Build())
            {
                session = cluster.Connect();
                state   = session.GetState();
                Assert.AreNotEqual(SessionState.Empty(), state);
                hosts = cluster.AllHosts();
            }
            state = session.GetState();
            Assert.NotNull(hosts);
            foreach (var host in hosts)
            {
                Assert.AreEqual(0, state.GetInFlightQueries(host));
                Assert.AreEqual(0, state.GetOpenConnections(host));
            }
        }
예제 #2
0
        /// <summary>
        /// Gets a snapshot containing information on the connections pools held by this Client at the current time.
        /// <para>
        /// The information provided in the returned object only represents the state at the moment this method was
        /// called and it's not maintained in sync with the driver metadata.
        /// </para>
        /// </summary>
        /// <param name="instance"></param>
        /// <returns></returns>
        public static ISessionState GetState(this ISession instance)
        {
            var session = instance as Session;

            return(session == null?SessionState.Empty() : SessionState.From(session));
        }