Exemple #1
0
        /// <summary>
        ///   Registers for cluster changes.
        /// </summary>
        /// <returns> </returns>
        /// <exception cref="System.InvalidOperationException">Must be connected before Registration can take place</exception>
        /// <exception cref="CqlException">Could not register for cluster changes!</exception>
        public async Task RegisterForClusterChangesAsync(Logger logger)
        {
            var registerframe = new RegisterFrame(new List<string> { "TOPOLOGY_CHANGE", "STATUS_CHANGE" });
            Frame result = await SendRequestAsync(registerframe, logger).ConfigureAwait(false);

            if (!(result is ReadyFrame))
                throw new CqlException("Could not register for cluster changes!");

            //increase request count to prevent connection to go in Idle state
            Interlocked.Increment(ref _activeRequests);
        }
Exemple #2
0
        /// <summary>
        /// Registers for cluster changes.
        /// </summary>
        /// <returns> </returns>
        /// <exception cref="System.InvalidOperationException">Must be connected before Registration can take place</exception>
        /// <exception cref="CqlException">Could not register for cluster changes!</exception>
        public async Task RegisterForClusterChangesAsync(Logger logger)
        {
            if (_connectionState == ConnectionState.Closed)
                throw new ObjectDisposedException(ToString());

            //make sure the connection is open
            await OpenAsync(logger);

            //send the register frame
            var registerframe = new RegisterFrame(new List<string> { "TOPOLOGY_CHANGE", "STATUS_CHANGE" });
            Frame result =
                await SendRequestAsyncInternal(registerframe, logger, 1, CancellationToken.None).AutoConfigureAwait();

            //check result
            if (!(result is ReadyFrame))
                throw new CqlException("Could not register for cluster changes!");

            //increase request count to prevent connection to go in Idle state
            Interlocked.Increment(ref _activeRequests);

            //release readLock to have readloop read the next event
            _readLock.Release();
        }