コード例 #1
0
        /// <summary>
        /// Performs feature checks when a new default connection is established.
        /// </summary>
        private void OnNewDefaultConnection()
        {
            if (_config.EnablePartitionAwareness && !_socket.Features.HasOp(ClientOp.CachePartitions))
            {
                _config.EnablePartitionAwareness = false;

                _logger.Warn("Partition awareness has been disabled: server protocol version {0} " +
                             "is lower than required {1}",
                             _socket.ServerVersion,
                             ClientFeatures.GetMinVersion(ClientOp.CachePartitions)
                             );
            }

            if (!_socket.Features.HasFeature(ClientBitmaskFeature.ClusterGroupGetNodesEndpoints))
            {
                _enableDiscovery = false;

                _logger.Warn("Automatic server node discovery is not supported by the server");
            }
        }
コード例 #2
0
        /// <summary>
        /// Performs initial checks when the first connection to the cluster has been established.
        /// </summary>
        private void OnFirstConnect()
        {
            if (_config.EnablePartitionAwareness && !_socket.Features.HasOp(ClientOp.CachePartitions))
            {
                _config.EnablePartitionAwareness = false;

                _logger.Warn("Partition awareness has been disabled: server protocol version {0} " +
                             "is lower than required {1}",
                             _socket.ServerVersion,
                             ClientFeatures.GetMinVersion(ClientOp.CachePartitions)
                             );
            }

            if (!_socket.Features.HasFeature(ClientBitmaskFeature.ClusterGroupGetNodesEndpoints))
            {
                _enableDiscovery = false;

                _logger.Warn("Automatic server node discovery is not supported by the server");
            }

            if (_socket.Features.HasFeature(ClientBitmaskFeature.BinaryConfiguration))
            {
                var serverBinaryCfg = _socket.DoOutInOp(
                    ClientOp.BinaryConfigurationGet,
                    ctx => { },
                    ctx => new BinaryConfigurationClientInternal(ctx.Reader.Stream));

                _logger.Debug("Server binary configuration retrieved: " + serverBinaryCfg);

                if (serverBinaryCfg.CompactFooter && !_marsh.CompactFooter)
                {
                    // Changing from full to compact is not safe: some clients do not support compact footers.
                    // Log information, but don't change the configuration.
                    _logger.Info("BinaryConfiguration.CompactFooter is true on the server, but false on the client." +
                                 "Consider enabling this setting to reduce cache entry size.");
                }

                if (!serverBinaryCfg.CompactFooter && _marsh.CompactFooter)
                {
                    // Changing from compact to full footer is safe, do it automatically.
                    _marsh.CompactFooter = false;

                    if (_config.BinaryConfiguration == null)
                    {
                        _config.BinaryConfiguration = new BinaryConfiguration();
                    }

                    _config.BinaryConfiguration.CompactFooter = false;

                    _logger.Info("BinaryConfiguration.CompactFooter set to false on client " +
                                 "according to server configuration.");
                }

                var localNameMapperMode = GetLocalNameMapperMode();

                if (localNameMapperMode != serverBinaryCfg.NameMapperMode)
                {
                    _logger.Warn("Binary name mapper mismatch: local={0}, server={1}",
                                 localNameMapperMode, serverBinaryCfg.NameMapperMode);
                }
            }
        }