Esempio n. 1
0
        public ClusterVNodeSettings(Guid instanceId, int debugIndex,
                                    IPEndPoint internalTcpEndPoint,
                                    IPEndPoint internalSecureTcpEndPoint,
                                    IPEndPoint externalTcpEndPoint,
                                    IPEndPoint externalSecureTcpEndPoint,
                                    IPEndPoint internalHttpEndPoint,
                                    IPEndPoint externalHttpEndPoint,
                                    GossipAdvertiseInfo gossipAdvertiseInfo,
                                    string[] intHttpPrefixes,
                                    string[] extHttpPrefixes,
                                    bool enableTrustedAuth,
                                    X509Certificate2 certificate,
                                    int workerThreads,
                                    bool discoverViaDns,
                                    string clusterDns,
                                    IPEndPoint[] gossipSeeds,
                                    TimeSpan minFlushDelay,
                                    int clusterNodeCount,
                                    int prepareAckCount,
                                    int commitAckCount,
                                    TimeSpan prepareTimeout,
                                    TimeSpan commitTimeout,
                                    bool useSsl,
                                    bool disableInsecureTCP,
                                    string sslTargetHost,
                                    bool sslValidateServer,
                                    TimeSpan statsPeriod,
                                    StatsStorage statsStorage,
                                    int nodePriority,
                                    IAuthenticationProviderFactory authenticationProviderFactory,
                                    bool disableScavengeMerging,
                                    int scavengeHistoryMaxAge,
                                    bool adminOnPublic,
                                    bool statsOnPublic,
                                    bool gossipOnPublic,
                                    TimeSpan gossipInterval,
                                    TimeSpan gossipAllowedTimeDifference,
                                    TimeSpan gossipTimeout,
                                    TimeSpan intTcpHeartbeatTimeout,
                                    TimeSpan intTcpHeartbeatInterval,
                                    TimeSpan extTcpHeartbeatTimeout,
                                    TimeSpan extTcpHeartbeatInterval,
                                    bool verifyDbHash,
                                    int maxMemtableEntryCount,
                                    int hashCollisionReadLimit,
                                    bool startStandardProjections,
                                    bool disableHTTPCaching,
                                    bool logHttpRequests,
                                    int connectionPendingSendBytesThreshold,
                                    int chunkInitialReaderCount,
                                    string index             = null, bool enableHistograms = false,
                                    bool skipIndexVerify     = false,
                                    int indexCacheDepth      = 16,
                                    byte indexBitnessVersion = 4,
                                    bool optimizeIndexMerge  = false,
                                    IPersistentSubscriptionConsumerStrategyFactory[] additionalConsumerStrategies = null,
                                    bool unsafeIgnoreHardDeletes = false,
                                    bool betterOrdering          = false,
                                    int readerThreadsCount       = 4,
                                    bool alwaysKeepScavenged     = false,
                                    bool gossipOnSingleNode      = false,
                                    bool skipIndexScanOnReads    = false,
                                    bool reduceFileCachePressure = false,
                                    int initializationThreads    = 1)
        {
            Ensure.NotEmptyGuid(instanceId, "instanceId");
            Ensure.NotNull(internalTcpEndPoint, "internalTcpEndPoint");
            Ensure.NotNull(externalTcpEndPoint, "externalTcpEndPoint");
            Ensure.NotNull(internalHttpEndPoint, "internalHttpEndPoint");
            Ensure.NotNull(externalHttpEndPoint, "externalHttpEndPoint");
            Ensure.NotNull(intHttpPrefixes, "intHttpPrefixes");
            Ensure.NotNull(extHttpPrefixes, "extHttpPrefixes");
            if (internalSecureTcpEndPoint != null || externalSecureTcpEndPoint != null)
            {
                Ensure.NotNull(certificate, "certificate");
            }
            Ensure.Positive(workerThreads, "workerThreads");
            Ensure.NotNull(clusterDns, "clusterDns");
            Ensure.NotNull(gossipSeeds, "gossipSeeds");
            Ensure.Positive(clusterNodeCount, "clusterNodeCount");
            Ensure.Positive(prepareAckCount, "prepareAckCount");
            Ensure.Positive(commitAckCount, "commitAckCount");
            Ensure.Positive(initializationThreads, "initializationThreads");
            Ensure.NotNull(gossipAdvertiseInfo, "gossipAdvertiseInfo");

            if (discoverViaDns && string.IsNullOrWhiteSpace(clusterDns))
            {
                throw new ArgumentException("Either DNS Discovery must be disabled (and seeds specified), or a cluster DNS name must be provided.");
            }

            if (useSsl)
            {
                Ensure.NotNull(sslTargetHost, "sslTargetHost");
            }

            NodeInfo = new VNodeInfo(instanceId, debugIndex,
                                     internalTcpEndPoint, internalSecureTcpEndPoint,
                                     externalTcpEndPoint, externalSecureTcpEndPoint,
                                     internalHttpEndPoint, externalHttpEndPoint);
            GossipAdvertiseInfo          = gossipAdvertiseInfo;
            IntHttpPrefixes              = intHttpPrefixes;
            ExtHttpPrefixes              = extHttpPrefixes;
            EnableTrustedAuth            = enableTrustedAuth;
            Certificate                  = certificate;
            WorkerThreads                = workerThreads;
            StartStandardProjections     = startStandardProjections;
            DisableHTTPCaching           = disableHTTPCaching;
            LogHttpRequests              = logHttpRequests;
            AdditionalConsumerStrategies = additionalConsumerStrategies ?? new IPersistentSubscriptionConsumerStrategyFactory[0];

            DiscoverViaDns     = discoverViaDns;
            ClusterDns         = clusterDns;
            GossipSeeds        = gossipSeeds;
            GossipOnSingleNode = gossipOnSingleNode;

            ClusterNodeCount = clusterNodeCount;
            MinFlushDelay    = minFlushDelay;
            PrepareAckCount  = prepareAckCount;
            CommitAckCount   = commitAckCount;
            PrepareTimeout   = prepareTimeout;
            CommitTimeout    = commitTimeout;

            UseSsl             = useSsl;
            DisableInsecureTCP = disableInsecureTCP;
            SslTargetHost      = sslTargetHost;
            SslValidateServer  = sslValidateServer;

            StatsPeriod  = statsPeriod;
            StatsStorage = statsStorage;

            AuthenticationProviderFactory = authenticationProviderFactory;

            NodePriority                        = nodePriority;
            DisableScavengeMerging              = disableScavengeMerging;
            ScavengeHistoryMaxAge               = scavengeHistoryMaxAge;
            AdminOnPublic                       = adminOnPublic;
            StatsOnPublic                       = statsOnPublic;
            GossipOnPublic                      = gossipOnPublic;
            GossipInterval                      = gossipInterval;
            GossipAllowedTimeDifference         = gossipAllowedTimeDifference;
            GossipTimeout                       = gossipTimeout;
            IntTcpHeartbeatTimeout              = intTcpHeartbeatTimeout;
            IntTcpHeartbeatInterval             = intTcpHeartbeatInterval;
            ExtTcpHeartbeatTimeout              = extTcpHeartbeatTimeout;
            ExtTcpHeartbeatInterval             = extTcpHeartbeatInterval;
            ConnectionPendingSendBytesThreshold = connectionPendingSendBytesThreshold;
            ChunkInitialReaderCount             = chunkInitialReaderCount;

            VerifyDbHash           = verifyDbHash;
            MaxMemtableEntryCount  = maxMemtableEntryCount;
            HashCollisionReadLimit = hashCollisionReadLimit;

            EnableHistograms    = enableHistograms;
            SkipIndexVerify     = skipIndexVerify;
            IndexCacheDepth     = indexCacheDepth;
            IndexBitnessVersion = indexBitnessVersion;
            OptimizeIndexMerge  = optimizeIndexMerge;
            Index = index;
            UnsafeIgnoreHardDeletes = unsafeIgnoreHardDeletes;
            BetterOrdering          = betterOrdering;
            ReaderThreadsCount      = readerThreadsCount;
            AlwaysKeepScavenged     = alwaysKeepScavenged;
            SkipIndexScanOnReads    = skipIndexScanOnReads;
            ReduceFileCachePressure = reduceFileCachePressure;
            InitializationThreads   = initializationThreads;
        }
Esempio n. 2
0
        public ClusterVNodeSettings(Guid instanceId, int debugIndex,
                                    IPEndPoint internalTcpEndPoint,
                                    IPEndPoint internalSecureTcpEndPoint,
                                    IPEndPoint externalTcpEndPoint,
                                    IPEndPoint externalSecureTcpEndPoint,
                                    IPEndPoint internalHttpEndPoint,
                                    IPEndPoint externalHttpEndPoint,
                                    GossipAdvertiseInfo gossipAdvertiseInfo,
                                    bool enableTrustedAuth,
                                    X509Certificate2 certificate,
                                    X509Certificate2Collection trustedRootCerts,
                                    int workerThreads,
                                    bool discoverViaDns,
                                    string clusterDns,
                                    IPEndPoint[] gossipSeeds,
                                    TimeSpan minFlushDelay,
                                    int clusterNodeCount,
                                    int prepareAckCount,
                                    int commitAckCount,
                                    TimeSpan prepareTimeout,
                                    TimeSpan commitTimeout,
                                    TimeSpan writeTimeout,
                                    bool disableInternalTls,
                                    bool disableExternalTls,
                                    TimeSpan statsPeriod,
                                    StatsStorage statsStorage,
                                    int nodePriority,
                                    AuthenticationProviderFactory authenticationProviderFactory,
                                    AuthorizationProviderFactory authorizationProviderFactory,
                                    bool disableScavengeMerging,
                                    int scavengeHistoryMaxAge,
                                    bool adminOnPublic,
                                    bool statsOnPublic,
                                    bool gossipOnPublic,
                                    TimeSpan gossipInterval,
                                    TimeSpan gossipAllowedTimeDifference,
                                    TimeSpan gossipTimeout,
                                    TimeSpan intTcpHeartbeatTimeout,
                                    TimeSpan intTcpHeartbeatInterval,
                                    TimeSpan extTcpHeartbeatTimeout,
                                    TimeSpan extTcpHeartbeatInterval,
                                    TimeSpan deadMemberRemovalPeriod,
                                    bool verifyDbHash,
                                    int maxMemtableEntryCount,
                                    int hashCollisionReadLimit,
                                    bool startStandardProjections,
                                    bool disableHTTPCaching,
                                    bool logHttpRequests,
                                    int connectionPendingSendBytesThreshold,
                                    int connectionQueueSizeThreshold,
                                    int ptableMaxReaderCount,
                                    string index             = null, bool enableHistograms = false,
                                    bool skipIndexVerify     = false,
                                    int indexCacheDepth      = 16,
                                    byte indexBitnessVersion = 4,
                                    bool optimizeIndexMerge  = false,
                                    IPersistentSubscriptionConsumerStrategyFactory[] additionalConsumerStrategies = null,
                                    bool unsafeIgnoreHardDeletes            = false,
                                    int readerThreadsCount                  = 4,
                                    bool alwaysKeepScavenged                = false,
                                    bool gossipOnSingleNode                 = false,
                                    bool skipIndexScanOnReads               = false,
                                    bool reduceFileCachePressure            = false,
                                    int initializationThreads               = 1,
                                    bool faultOutOfOrderProjections         = false,
                                    int maxAutoMergeIndexLevel              = 1000,
                                    bool disableFirstLevelHttpAuthorization = false,
                                    bool logFailedAuthenticationAttempts    = false,
                                    long maxTruncation           = 256 * 1024 * 1024,
                                    bool readOnlyReplica         = false,
                                    int maxAppendSize            = 1024 * 1024,
                                    bool unsafeAllowSurplusNodes = false,
                                    bool enableExternalTCP       = false,
                                    bool enableAtomPubOverHTTP   = true,
                                    bool gossipOverHttps         = true)
        {
            Ensure.NotEmptyGuid(instanceId, "instanceId");
            Ensure.Equal(false, internalTcpEndPoint == null && internalSecureTcpEndPoint == null, "Both internal TCP endpoints are null");

            Ensure.NotNull(internalHttpEndPoint, "internalHttpEndPoint");
            Ensure.NotNull(externalHttpEndPoint, "externalHttpEndPoint");
            if (internalSecureTcpEndPoint != null || externalSecureTcpEndPoint != null)
            {
                Ensure.NotNull(certificate, "certificate");
            }
            Ensure.Positive(workerThreads, "workerThreads");
            Ensure.NotNull(clusterDns, "clusterDns");
            Ensure.NotNull(gossipSeeds, "gossipSeeds");
            Ensure.Positive(clusterNodeCount, "clusterNodeCount");
            Ensure.Positive(prepareAckCount, "prepareAckCount");
            Ensure.Positive(commitAckCount, "commitAckCount");
            Ensure.Positive(initializationThreads, "initializationThreads");
            Ensure.NotNull(gossipAdvertiseInfo, "gossipAdvertiseInfo");
            if (maxAppendSize > TFConsts.EffectiveMaxLogRecordSize)
            {
                throw new ArgumentOutOfRangeException(nameof(maxAppendSize), $"{nameof(maxAppendSize)} exceeded {TFConsts.EffectiveMaxLogRecordSize} bytes.");
            }

            if (discoverViaDns && string.IsNullOrWhiteSpace(clusterDns))
            {
                throw new ArgumentException(
                          "Either DNS Discovery must be disabled (and seeds specified), or a cluster DNS name must be provided.");
            }

            NodeInfo = new VNodeInfo(instanceId, debugIndex,
                                     internalTcpEndPoint, internalSecureTcpEndPoint,
                                     externalTcpEndPoint, externalSecureTcpEndPoint,
                                     internalHttpEndPoint, externalHttpEndPoint,
                                     readOnlyReplica);
            GossipAdvertiseInfo = gossipAdvertiseInfo;
            EnableTrustedAuth   = enableTrustedAuth;
            Certificate         = certificate;
            TrustedRootCerts    = trustedRootCerts;

            WorkerThreads                   = workerThreads;
            StartStandardProjections        = startStandardProjections;
            EnableAtomPubOverHTTP           = enableAtomPubOverHTTP;
            DisableHTTPCaching              = disableHTTPCaching;
            LogHttpRequests                 = logHttpRequests;
            LogFailedAuthenticationAttempts = logFailedAuthenticationAttempts;
            AdditionalConsumerStrategies    =
                additionalConsumerStrategies ?? new IPersistentSubscriptionConsumerStrategyFactory[0];

            DiscoverViaDns     = discoverViaDns;
            ClusterDns         = clusterDns;
            GossipSeeds        = gossipSeeds;
            GossipOnSingleNode = gossipOnSingleNode;

            ClusterNodeCount = clusterNodeCount;
            MinFlushDelay    = minFlushDelay;
            PrepareAckCount  = prepareAckCount;
            CommitAckCount   = commitAckCount;
            PrepareTimeout   = prepareTimeout;
            CommitTimeout    = commitTimeout;
            WriteTimeout     = writeTimeout;

            DisableInternalTls = disableInternalTls;
            DisableExternalTls = disableExternalTls;
            EnableExternalTCP  = enableExternalTCP;

            StatsPeriod  = statsPeriod;
            StatsStorage = statsStorage;

            AuthenticationProviderFactory      = authenticationProviderFactory;
            AuthorizationProviderFactory       = authorizationProviderFactory;
            DisableFirstLevelHttpAuthorization = disableFirstLevelHttpAuthorization;

            NodePriority                        = nodePriority;
            DisableScavengeMerging              = disableScavengeMerging;
            ScavengeHistoryMaxAge               = scavengeHistoryMaxAge;
            AdminOnPublic                       = adminOnPublic;
            StatsOnPublic                       = statsOnPublic;
            GossipOnPublic                      = gossipOnPublic;
            GossipInterval                      = gossipInterval;
            GossipAllowedTimeDifference         = gossipAllowedTimeDifference;
            GossipTimeout                       = gossipTimeout;
            GossipOverHttps                     = gossipOverHttps;
            IntTcpHeartbeatTimeout              = intTcpHeartbeatTimeout;
            IntTcpHeartbeatInterval             = intTcpHeartbeatInterval;
            ExtTcpHeartbeatTimeout              = extTcpHeartbeatTimeout;
            ExtTcpHeartbeatInterval             = extTcpHeartbeatInterval;
            ConnectionPendingSendBytesThreshold = connectionPendingSendBytesThreshold;
            ConnectionQueueSizeThreshold        = connectionQueueSizeThreshold;
            DeadMemberRemovalPeriod             = deadMemberRemovalPeriod;

            VerifyDbHash           = verifyDbHash;
            MaxMemtableEntryCount  = maxMemtableEntryCount;
            HashCollisionReadLimit = hashCollisionReadLimit;

            EnableHistograms    = enableHistograms;
            SkipIndexVerify     = skipIndexVerify;
            IndexCacheDepth     = indexCacheDepth;
            IndexBitnessVersion = indexBitnessVersion;
            OptimizeIndexMerge  = optimizeIndexMerge;
            Index = index;
            UnsafeIgnoreHardDeletes    = unsafeIgnoreHardDeletes;
            ReaderThreadsCount         = readerThreadsCount;
            AlwaysKeepScavenged        = alwaysKeepScavenged;
            SkipIndexScanOnReads       = skipIndexScanOnReads;
            ReduceFileCachePressure    = reduceFileCachePressure;
            InitializationThreads      = initializationThreads;
            MaxAutoMergeIndexLevel     = maxAutoMergeIndexLevel;
            FaultOutOfOrderProjections = faultOutOfOrderProjections;
            ReadOnlyReplica            = readOnlyReplica;
            MaxAppendSize           = maxAppendSize;
            PTableMaxReaderCount    = ptableMaxReaderCount;
            UnsafeAllowSurplusNodes = unsafeAllowSurplusNodes;
            MaxTruncation           = maxTruncation;
        }
        public ClusterVNodeSettings(Guid instanceId, int debugIndex,
                                    IPEndPoint internalTcpEndPoint,
                                    IPEndPoint internalSecureTcpEndPoint,
                                    IPEndPoint externalTcpEndPoint,
                                    IPEndPoint externalSecureTcpEndPoint,
                                    IPEndPoint internalHttpEndPoint,
                                    IPEndPoint externalHttpEndPoint,
                                    GossipAdvertiseInfo gossipAdvertiseInfo,
                                    string[] intHttpPrefixes,
                                    string[] extHttpPrefixes,
                                    bool enableTrustedAuth,
                                    X509Certificate2 certificate,
                                    int workerThreads,
                                    bool discoverViaDns,
                                    string clusterDns,
                                    IPEndPoint[] gossipSeeds,
                                    TimeSpan minFlushDelay,
                                    int clusterNodeCount,
                                    int prepareAckCount,
                                    int commitAckCount,
                                    TimeSpan prepareTimeout,
                                    TimeSpan commitTimeout,
                                    bool useSsl,
                                    string sslTargetHost,
                                    bool sslValidateServer,
                                    TimeSpan statsPeriod,
                                    StatsStorage statsStorage,
                                    int nodePriority,
                                    IAuthenticationProviderFactory authenticationProviderFactory,
                                    bool disableScavengeMerging,
                                    bool adminOnPublic,
                                    bool statsOnPublic,
                                    bool gossipOnPublic,
                                    TimeSpan gossipInterval,
                                    TimeSpan gossipAllowedTimeDifference,
                                    TimeSpan gossipTimeout,
                                    TimeSpan intTcpHeartbeatTimeout,
                                    TimeSpan intTcpHeartbeatInterval,
                                    TimeSpan extTcpHeartbeatTimeout,
                                    TimeSpan extTcpHeartbeatInterval,
                                    bool verifyDbHash,
                                    int maxMemtableEntryCount,
                                    bool developmentMode)
        {
            Ensure.NotEmptyGuid(instanceId, "instanceId");
            Ensure.NotNull(internalTcpEndPoint, "internalTcpEndPoint");
            Ensure.NotNull(externalTcpEndPoint, "externalTcpEndPoint");
            Ensure.NotNull(internalHttpEndPoint, "internalHttpEndPoint");
            Ensure.NotNull(externalHttpEndPoint, "externalHttpEndPoint");
            Ensure.NotNull(intHttpPrefixes, "intHttpPrefixes");
            Ensure.NotNull(extHttpPrefixes, "extHttpPrefixes");
            if (internalSecureTcpEndPoint != null || externalSecureTcpEndPoint != null)
            {
                Ensure.NotNull(certificate, "certificate");
            }
            Ensure.Positive(workerThreads, "workerThreads");
            Ensure.NotNull(clusterDns, "clusterDns");
            Ensure.NotNull(gossipSeeds, "gossipSeeds");
            Ensure.Positive(clusterNodeCount, "clusterNodeCount");
            Ensure.Positive(prepareAckCount, "prepareAckCount");
            Ensure.Positive(commitAckCount, "commitAckCount");
            Ensure.NotNull(gossipAdvertiseInfo, "gossipAdvertiseInfo");

            if (discoverViaDns && string.IsNullOrWhiteSpace(clusterDns))
            {
                throw new ArgumentException("Either DNS Discovery must be disabled (and seeds specified), or a cluster DNS name must be provided.");
            }

            if (useSsl)
            {
                Ensure.NotNull(sslTargetHost, "sslTargetHost");
            }

            NodeInfo = new VNodeInfo(instanceId, debugIndex,
                                     internalTcpEndPoint, internalSecureTcpEndPoint,
                                     externalTcpEndPoint, externalSecureTcpEndPoint,
                                     internalHttpEndPoint, externalHttpEndPoint);
            GossipAdvertiseInfo = gossipAdvertiseInfo;
            IntHttpPrefixes     = intHttpPrefixes;
            ExtHttpPrefixes     = extHttpPrefixes;
            EnableTrustedAuth   = enableTrustedAuth;
            Certificate         = certificate;
            WorkerThreads       = workerThreads;
            DevelopmentMode     = developmentMode;

            DiscoverViaDns = discoverViaDns;
            ClusterDns     = clusterDns;
            GossipSeeds    = gossipSeeds;

            ClusterNodeCount = clusterNodeCount;
            MinFlushDelay    = minFlushDelay;
            PrepareAckCount  = prepareAckCount;
            CommitAckCount   = commitAckCount;
            PrepareTimeout   = prepareTimeout;
            CommitTimeout    = commitTimeout;

            UseSsl            = useSsl;
            SslTargetHost     = sslTargetHost;
            SslValidateServer = sslValidateServer;

            StatsPeriod  = statsPeriod;
            StatsStorage = statsStorage;

            AuthenticationProviderFactory = authenticationProviderFactory;

            NodePriority                = nodePriority;
            DisableScavengeMerging      = disableScavengeMerging;
            AdminOnPublic               = adminOnPublic;
            StatsOnPublic               = statsOnPublic;
            GossipOnPublic              = gossipOnPublic;
            GossipInterval              = gossipInterval;
            GossipAllowedTimeDifference = gossipAllowedTimeDifference;
            GossipTimeout               = gossipTimeout;
            IntTcpHeartbeatTimeout      = intTcpHeartbeatTimeout;
            IntTcpHeartbeatInterval     = intTcpHeartbeatInterval;
            ExtTcpHeartbeatTimeout      = extTcpHeartbeatTimeout;
            ExtTcpHeartbeatInterval     = extTcpHeartbeatInterval;

            VerifyDbHash          = verifyDbHash;
            MaxMemtableEntryCount = maxMemtableEntryCount;
        }
Esempio n. 4
0
        private static ClusterVNodeSettings GetClusterVNodeSettings(ClusterNodeOptions options)
        {
            X509Certificate2 certificate = null;

            if (options.IntSecureTcpPort > 0 || options.ExtSecureTcpPort > 0)
            {
                if (options.CertificateStoreName.IsNotEmptyString())
                {
                    certificate = LoadCertificateFromStore(options.CertificateStoreLocation, options.CertificateStoreName, options.CertificateSubjectName, options.CertificateThumbprint);
                }
                else if (options.CertificateFile.IsNotEmptyString())
                {
                    certificate = LoadCertificateFromFile(options.CertificateFile, options.CertificatePassword);
                }
                else
                {
                    throw new Exception("No server certificate specified.");
                }
            }

            var intHttp         = new IPEndPoint(options.IntIp, options.IntHttpPort);
            var extHttp         = new IPEndPoint(options.ExtIp, options.ExtHttpPort);
            var intTcp          = new IPEndPoint(options.IntIp, options.IntTcpPort);
            var intSecTcp       = options.IntSecureTcpPort > 0 ? new IPEndPoint(options.IntIp, options.IntSecureTcpPort) : null;
            var extTcp          = new IPEndPoint(options.ExtIp, options.ExtTcpPort);
            var extSecTcp       = options.ExtSecureTcpPort > 0 ? new IPEndPoint(options.ExtIp, options.ExtSecureTcpPort) : null;
            var intHttpPrefixes = options.IntHttpPrefixes.IsNotEmpty() ? options.IntHttpPrefixes : new string[0];
            var extHttpPrefixes = options.ExtHttpPrefixes.IsNotEmpty() ? options.ExtHttpPrefixes : new string[0];
            var quorumSize      = GetQuorumSize(options.ClusterSize);

            GossipAdvertiseInfo gossipAdvertiseInfo;

            IPAddress intIpAddressToAdvertise = options.IntIpAdvertiseAs ?? options.IntIp;
            IPAddress extIpAddressToAdvertise = options.ExtIpAdvertiseAs ?? options.ExtIp;

            var additionalIntHttpPrefixes = new List <string>(intHttpPrefixes);
            var additionalExtHttpPrefixes = new List <string>(extHttpPrefixes);

            if ((options.IntIp.Equals(IPAddress.Parse("0.0.0.0")) ||
                 options.ExtIp.Equals(IPAddress.Parse("0.0.0.0"))) && options.AddInterfacePrefixes)
            {
                IPAddress nonLoopbackAddress = GetNonLoopbackAddress();
                IPAddress addressToAdvertise = options.ClusterSize > 1 ? nonLoopbackAddress : IPAddress.Loopback;

                if (options.IntIp.Equals(IPAddress.Parse("0.0.0.0")))
                {
                    intIpAddressToAdvertise = options.IntIpAdvertiseAs ?? addressToAdvertise;
                    additionalIntHttpPrefixes.Add(String.Format("http://*:{0}/", intHttp.Port));
                }
                if (options.ExtIp.Equals(IPAddress.Parse("0.0.0.0")))
                {
                    extIpAddressToAdvertise = options.ExtIpAdvertiseAs ?? addressToAdvertise;
                    additionalExtHttpPrefixes.Add(String.Format("http://*:{0}/", extHttp.Port));
                }
            }
            else if (options.AddInterfacePrefixes)
            {
                additionalIntHttpPrefixes.Add(String.Format("http://{0}:{1}/", options.IntIp, options.IntHttpPort));
                if (options.IntIp.Equals(IPAddress.Loopback))
                {
                    additionalIntHttpPrefixes.Add(String.Format("http://localhost:{0}/", options.IntHttpPort));
                }
                additionalExtHttpPrefixes.Add(String.Format("http://{0}:{1}/", options.ExtIp, options.ExtHttpPort));
                if (options.ExtIp.Equals(IPAddress.Loopback))
                {
                    additionalExtHttpPrefixes.Add(String.Format("http://localhost:{0}/", options.ExtHttpPort));
                }
            }

            intHttpPrefixes = additionalIntHttpPrefixes.ToArray();
            extHttpPrefixes = additionalExtHttpPrefixes.ToArray();

            var intTcpPort           = options.IntTcpPortAdvertiseAs > 0 ? options.IntTcpPortAdvertiseAs : options.IntTcpPort;
            var intTcpEndPoint       = new IPEndPoint(intIpAddressToAdvertise, intTcpPort);
            var intSecureTcpPort     = options.IntSecureTcpPortAdvertiseAs > 0 ? options.IntSecureTcpPortAdvertiseAs : options.IntSecureTcpPort;
            var intSecureTcpEndPoint = new IPEndPoint(intIpAddressToAdvertise, intSecureTcpPort);

            var extTcpPort           = options.ExtTcpPortAdvertiseAs > 0 ? options.ExtTcpPortAdvertiseAs : options.ExtTcpPort;
            var extTcpEndPoint       = new IPEndPoint(extIpAddressToAdvertise, extTcpPort);
            var extSecureTcpPort     = options.ExtSecureTcpPortAdvertiseAs > 0 ? options.ExtSecureTcpPortAdvertiseAs : options.ExtSecureTcpPort;
            var extSecureTcpEndPoint = new IPEndPoint(extIpAddressToAdvertise, extSecureTcpPort);

            var intHttpPort = options.IntHttpPortAdvertiseAs > 0 ? options.IntHttpPortAdvertiseAs : options.IntHttpPort;
            var extHttpPort = options.ExtHttpPortAdvertiseAs > 0 ? options.ExtHttpPortAdvertiseAs : options.ExtHttpPort;

            var intHttpEndPoint = new IPEndPoint(intIpAddressToAdvertise, intHttpPort);
            var extHttpEndPoint = new IPEndPoint(extIpAddressToAdvertise, extHttpPort);

            gossipAdvertiseInfo = new GossipAdvertiseInfo(intTcpEndPoint, intSecureTcpEndPoint,
                                                          extTcpEndPoint, extSecureTcpEndPoint,
                                                          intHttpEndPoint, extHttpEndPoint);

            var prepareCount = options.PrepareCount > quorumSize ? options.PrepareCount : quorumSize;
            var commitCount  = options.CommitCount > quorumSize ? options.CommitCount : quorumSize;

            Log.Info("Quorum size set to " + prepareCount);
            if (options.UseInternalSsl)
            {
                if (ReferenceEquals(options.SslTargetHost, Opts.SslTargetHostDefault))
                {
                    throw new Exception("No SSL target host specified.");
                }
                if (intSecTcp == null)
                {
                    throw new Exception("Usage of internal secure communication is specified, but no internal secure endpoint is specified!");
                }
            }

            var authenticationConfig          = String.IsNullOrEmpty(options.AuthenticationConfig) ? options.Config : options.AuthenticationConfig;
            var plugInContainer               = FindPlugins();
            var authenticationProviderFactory = GetAuthenticationProviderFactory(options.AuthenticationType, authenticationConfig, plugInContainer);
            var consumerStrategyFactories     = GetPlugInConsumerStrategyFactories(plugInContainer);

            return(new ClusterVNodeSettings(Guid.NewGuid(), 0,
                                            intTcp, intSecTcp, extTcp, extSecTcp, intHttp, extHttp, gossipAdvertiseInfo,
                                            intHttpPrefixes, extHttpPrefixes, options.EnableTrustedAuth,
                                            certificate,
                                            options.WorkerThreads, options.DiscoverViaDns,
                                            options.ClusterDns, options.GossipSeed,
                                            TimeSpan.FromMilliseconds(options.MinFlushDelayMs), options.ClusterSize,
                                            prepareCount, commitCount,
                                            TimeSpan.FromMilliseconds(options.PrepareTimeoutMs),
                                            TimeSpan.FromMilliseconds(options.CommitTimeoutMs),
                                            options.UseInternalSsl, options.SslTargetHost, options.SslValidateServer,
                                            TimeSpan.FromSeconds(options.StatsPeriodSec), StatsStorage.StreamAndCsv,
                                            options.NodePriority, authenticationProviderFactory, options.DisableScavengeMerging,
                                            options.AdminOnExt, options.StatsOnExt, options.GossipOnExt,
                                            TimeSpan.FromMilliseconds(options.GossipIntervalMs),
                                            TimeSpan.FromMilliseconds(options.GossipAllowedDifferenceMs),
                                            TimeSpan.FromMilliseconds(options.GossipTimeoutMs),
                                            TimeSpan.FromMilliseconds(options.ExtTcpHeartbeatTimeout),
                                            TimeSpan.FromMilliseconds(options.ExtTcpHeartbeatInterval),
                                            TimeSpan.FromMilliseconds(options.IntTcpHeartbeatTimeout),
                                            TimeSpan.FromMilliseconds(options.IntTcpHeartbeatInterval),
                                            !options.SkipDbVerify, options.MaxMemTableSize,
                                            options.StartStandardProjections,
                                            options.DisableHTTPCaching,
                                            options.Index,
                                            options.EnableHistograms,
                                            options.IndexCacheDepth,
                                            consumerStrategyFactories));
        }
Esempio n. 5
0
        private static ClusterVNodeSettings GetClusterVNodeSettings(ClusterNodeOptions options)
        {
            X509Certificate2 certificate = null;

            if (options.IntSecureTcpPort > 0 || options.ExtSecureTcpPort > 0)
            {
                if (options.CertificateStoreName.IsNotEmptyString())
                {
                    certificate = LoadCertificateFromStore(options.CertificateStoreLocation, options.CertificateStoreName, options.CertificateSubjectName, options.CertificateThumbprint);
                }
                else if (options.CertificateFile.IsNotEmptyString())
                {
                    certificate = LoadCertificateFromFile(options.CertificateFile, options.CertificatePassword);
                }
                else
                {
                    throw new Exception("No server certificate specified.");
                }
            }

            var intHttp         = new IPEndPoint(options.IntIp, options.IntHttpPort);
            var extHttp         = new IPEndPoint(options.ExtIp, options.ExtHttpPort);
            var intTcp          = new IPEndPoint(options.IntIp, options.IntTcpPort);
            var intSecTcp       = options.IntSecureTcpPort > 0 ? new IPEndPoint(options.IntIp, options.IntSecureTcpPort) : null;
            var extTcp          = new IPEndPoint(options.ExtIp, options.ExtTcpPort);
            var extSecTcp       = options.ExtSecureTcpPort > 0 ? new IPEndPoint(options.ExtIp, options.ExtSecureTcpPort) : null;
            var intHttpPrefixes = options.IntHttpPrefixes.IsNotEmpty() ? options.IntHttpPrefixes : new string[0];
            var extHttpPrefixes = options.ExtHttpPrefixes.IsNotEmpty() ? options.ExtHttpPrefixes : new string[0];
            var quorumSize      = GetQuorumSize(options.ClusterSize);


            GossipAdvertiseInfo gossipAdvertiseInfo = null;

            var additionalIntHttpPrefixes = new List <string>(intHttpPrefixes);
            var additionalExtHttpPrefixes = new List <string>(extHttpPrefixes);

            if ((options.IntIp.Equals(IPAddress.Parse("0.0.0.0")) ||
                 options.ExtIp.Equals(IPAddress.Parse("0.0.0.0"))) && options.AddInterfacePrefixes)
            {
                IPAddress nonLoopbackAddress = null;
                foreach (var adapter in NetworkInterface.GetAllNetworkInterfaces())
                {
                    foreach (UnicastIPAddressInformation address in adapter.GetIPProperties().UnicastAddresses)
                    {
                        if (address.Address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
                        {
                            if (nonLoopbackAddress == null && !IPAddress.IsLoopback(address.Address))
                            {
                                nonLoopbackAddress = address.Address;
                            }
                            additionalIntHttpPrefixes.Add(String.Format("http://{0}:{1}/", address.Address, intHttp.Port));
                            additionalExtHttpPrefixes.Add(String.Format("http://{0}:{1}/", address.Address, extHttp.Port));
                        }
                    }
                }
                if (gossipAdvertiseInfo == null)
                {
                    IPAddress addressToGossip = options.ClusterSize > 1 ? nonLoopbackAddress : IPAddress.Loopback;
                    gossipAdvertiseInfo = new GossipAdvertiseInfo(new IPEndPoint(addressToGossip, options.IntTcpPort),
                                                                  options.IntSecureTcpPort > 0 ? new IPEndPoint(addressToGossip, options.IntSecureTcpPort) : null,
                                                                  new IPEndPoint(options.ExtIpAdvertiseAs ?? addressToGossip, options.ExtTcpPortAdvertiseAs > 0 ? options.ExtTcpPortAdvertiseAs : options.ExtTcpPort),
                                                                  options.ExtSecureTcpPort > 0 ? new IPEndPoint(addressToGossip, options.ExtSecureTcpPort) : null,
                                                                  new IPEndPoint(addressToGossip, options.IntHttpPort),
                                                                  new IPEndPoint(options.ExtIpAdvertiseAs ?? addressToGossip, options.ExtHttpPortAdvertiseAs > 0 ? options.ExtHttpPortAdvertiseAs : options.ExtHttpPort));
                }
            }
            else if (options.AddInterfacePrefixes)
            {
                additionalIntHttpPrefixes.Add(String.Format("http://{0}:{1}/", options.IntIp, options.IntHttpPort));
                additionalExtHttpPrefixes.Add(String.Format("http://{0}:{1}/", options.ExtIp, options.ExtHttpPort));
            }
            if (!intHttpPrefixes.Contains(x => x.Contains("localhost")))
            {
                if (options.IntIp.Equals(IPAddress.Parse("0.0.0.0")) ||
                    Equals(intHttp.Address, IPAddress.Loopback))
                {
                    additionalIntHttpPrefixes.Add(string.Format("http://localhost:{0}/", intHttp.Port));
                }
            }
            if (!extHttpPrefixes.Contains(x => x.Contains("localhost")))
            {
                if (options.ExtIp.Equals(IPAddress.Parse("0.0.0.0")) ||
                    Equals(extHttp.Address, IPAddress.Loopback))
                {
                    additionalExtHttpPrefixes.Add(string.Format("http://localhost:{0}/", extHttp.Port));
                }
            }
            intHttpPrefixes = additionalIntHttpPrefixes.ToArray();
            extHttpPrefixes = additionalExtHttpPrefixes.ToArray();

            if (gossipAdvertiseInfo == null)
            {
                gossipAdvertiseInfo = new GossipAdvertiseInfo(intTcp,
                                                              intSecTcp,
                                                              new IPEndPoint(options.ExtIpAdvertiseAs ?? options.ExtIp, options.ExtTcpPortAdvertiseAs > 0 ? options.ExtTcpPortAdvertiseAs : options.ExtTcpPort),
                                                              extSecTcp,
                                                              intHttp,
                                                              new IPEndPoint(options.ExtIpAdvertiseAs ?? options.ExtIp, options.ExtHttpPortAdvertiseAs > 0 ? options.ExtHttpPortAdvertiseAs : options.ExtHttpPort));
            }

            var prepareCount = options.PrepareCount > quorumSize ? options.PrepareCount : quorumSize;
            var commitCount  = options.CommitCount > quorumSize ? options.CommitCount : quorumSize;

            Log.Info("Quorum size set to " + prepareCount);
            if (options.UseInternalSsl)
            {
                if (ReferenceEquals(options.SslTargetHost, Opts.SslTargetHostDefault))
                {
                    throw new Exception("No SSL target host specified.");
                }
                if (intSecTcp == null)
                {
                    throw new Exception("Usage of internal secure communication is specified, but no internal secure endpoint is specified!");
                }
            }

            var authenticationProviderFactory = GetAuthenticationProviderFactory(options.AuthenticationType, options.Config);

            return(new ClusterVNodeSettings(Guid.NewGuid(), 0,
                                            intTcp, intSecTcp, extTcp, extSecTcp, intHttp, extHttp, gossipAdvertiseInfo,
                                            intHttpPrefixes, extHttpPrefixes, options.EnableTrustedAuth,
                                            certificate,
                                            options.WorkerThreads, options.DiscoverViaDns,
                                            options.ClusterDns, options.GossipSeed,
                                            TimeSpan.FromMilliseconds(options.MinFlushDelayMs), options.ClusterSize,
                                            prepareCount, commitCount,
                                            TimeSpan.FromMilliseconds(options.PrepareTimeoutMs),
                                            TimeSpan.FromMilliseconds(options.CommitTimeoutMs),
                                            options.UseInternalSsl, options.SslTargetHost, options.SslValidateServer,
                                            TimeSpan.FromSeconds(options.StatsPeriodSec), StatsStorage.StreamAndCsv,
                                            options.NodePriority, authenticationProviderFactory, options.DisableScavengeMerging,
                                            options.AdminOnExt, options.StatsOnExt, options.GossipOnExt,
                                            TimeSpan.FromMilliseconds(options.GossipIntervalMs),
                                            TimeSpan.FromMilliseconds(options.GossipAllowedDifferenceMs),
                                            TimeSpan.FromMilliseconds(options.GossipTimeoutMs),
                                            TimeSpan.FromMilliseconds(options.ExtTcpHeartbeatTimeout),
                                            TimeSpan.FromMilliseconds(options.ExtTcpHeartbeatInterval),
                                            TimeSpan.FromMilliseconds(options.IntTcpHeartbeatTimeout),
                                            TimeSpan.FromMilliseconds(options.IntTcpHeartbeatInterval),
                                            !options.SkipDbVerify, options.MaxMemTableSize,
                                            options.DevelopmentMode));
        }