コード例 #1
0
 public void TestFixtureSetUp()
 {
     _builder = TestVNodeBuilder.AsClusterMember(3)
                .RunInMemory()
                .OnDefaultEndpoints()
                .DisableDnsDiscovery();
     try {
         _builder.Build();
     } catch (Exception e) {
         _caughtException = e;
     }
 }
コード例 #2
0
        public void SetUp()
        {
            var baseIpAddress  = IPAddress.Parse("192.168.1.15");
            var internalSecTcp = new IPEndPoint(baseIpAddress, 1114);
            var externalSecTcp = new IPEndPoint(baseIpAddress, 1115);

            _builder = TestVNodeBuilder.AsSingleNode()
                       .RunInMemory()
                       .OnDefaultEndpoints()
                       .WithInternalSecureTcpOn(internalSecTcp)
                       .WithExternalSecureTcpOn(externalSecTcp);
            try {
                _builder.Build();
            } catch (Exception ex) {
                _caughtException = ex;
            }
        }
コード例 #3
0
ファイル: MiniNode.cs プロジェクト: jonevn/EventStore
        public MiniNode(string pathname,
                        int?tcpPort             = null, int?tcpSecPort = null, int?httpPort = null,
                        ISubsystem[] subsystems = null,
                        int?chunkSize           = null, int?cachedChunkSize = null, bool enableTrustedAuth = false,
                        bool skipInitializeStandardUsersCheck = true,
                        int memTableSize = 1000,
                        bool inMemDb     = true, bool disableFlushToDisk = false,
                        IPAddress advertisedExtIPAddress = null, int advertisedExtHttpPort = 0,
                        int hashCollisionReadLimit       = EventStore.Core.Util.Opts.HashCollisionReadLimitDefault,
                        byte indexBitnessVersion         = EventStore.Core.Util.Opts.IndexBitnessVersionDefault,
                        string dbPath = "", bool isReadOnlyReplica = false)
        {
            RunningTime.Start();
            RunCount += 1;

            var ip = IPAddress.Loopback;             //GetLocalIp();


            int extTcpPort    = tcpPort ?? PortsHelper.GetAvailablePort(ip);
            int extSecTcpPort = tcpSecPort ?? PortsHelper.GetAvailablePort(ip);
            int extHttpPort   = httpPort ?? PortsHelper.GetAvailablePort(ip);
            int intTcpPort    = PortsHelper.GetAvailablePort(ip);
            int intSecTcpPort = PortsHelper.GetAvailablePort(ip);
            int intHttpPort   = PortsHelper.GetAvailablePort(ip);

            if (string.IsNullOrEmpty(dbPath))
            {
                DbPath = Path.Combine(pathname,
                                      $"mini-node-db-{extTcpPort}-{extSecTcpPort}-{extHttpPort}");
            }
            else
            {
                DbPath = dbPath;
            }

            TcpEndPoint       = new IPEndPoint(ip, extTcpPort);
            TcpSecEndPoint    = new IPEndPoint(ip, extSecTcpPort);
            IntTcpEndPoint    = new IPEndPoint(ip, intTcpPort);
            IntSecTcpEndPoint = new IPEndPoint(ip, intSecTcpPort);
            IntHttpEndPoint   = new IPEndPoint(ip, intHttpPort);
            ExtHttpEndPoint   = new IPEndPoint(ip, extHttpPort);

            var builder = TestVNodeBuilder.AsSingleNode();

            if (inMemDb)
            {
                builder.RunInMemory();
            }
            else
            {
                builder.RunOnDisk(DbPath);
            }

            builder.WithInternalTcpOn(IntTcpEndPoint)
            .WithInternalSecureTcpOn(IntSecTcpEndPoint)
            .WithExternalTcpOn(TcpEndPoint)
            .WithExternalSecureTcpOn(TcpSecEndPoint)
            .WithInternalHttpOn(IntHttpEndPoint)
            .WithExternalHttpOn(ExtHttpEndPoint)
            .WithTfChunkSize(chunkSize ?? ChunkSize)
            .WithTfChunksCacheSize(cachedChunkSize ?? CachedChunkSize)
            .WithServerCertificate(ssl_connections.GetCertificate())
            .WithWorkerThreads(1)
            .DisableDnsDiscovery()
            .WithPrepareTimeout(TimeSpan.FromSeconds(10))
            .WithCommitTimeout(TimeSpan.FromSeconds(10))
            .WithStatsPeriod(TimeSpan.FromHours(1))
            .DisableScavengeMerging()
            .NoGossipOnPublicInterface()
            .WithInternalHeartbeatInterval(TimeSpan.FromSeconds(10))
            .WithInternalHeartbeatTimeout(TimeSpan.FromSeconds(10))
            .WithExternalHeartbeatInterval(TimeSpan.FromSeconds(10))
            .WithExternalHeartbeatTimeout(TimeSpan.FromSeconds(10))
            .MaximumMemoryTableSizeOf(memTableSize)
            .DoNotVerifyDbHashes()
            .WithStatsStorage(StatsStorage.None)
            .AdvertiseExternalIPAs(advertisedExtIPAddress)
            .AdvertiseExternalHttpPortAs(advertisedExtHttpPort)
            .WithHashCollisionReadLimitOf(hashCollisionReadLimit)
            .WithIndexBitnessVersion(indexBitnessVersion)
            .WithHttpMessageHandlerFactory(() => HttpMessageHandler);

            if (enableTrustedAuth)
            {
                builder.EnableTrustedAuth();
            }
            if (disableFlushToDisk)
            {
                builder.WithUnsafeDisableFlushToDisk();
            }
            if (isReadOnlyReplica)
            {
                builder.EnableReadOnlyReplica();
            }

            if (subsystems != null)
            {
                foreach (var subsystem in subsystems)
                {
                    builder.AddCustomSubsystem(subsystem);
                }
            }

            Log.Info("\n{0,-25} {1} ({2}/{3}, {4})\n"
                     + "{5,-25} {6} ({7})\n"
                     + "{8,-25} {9} ({10}-bit)\n"
                     + "{11,-25} {12}\n"
                     + "{13,-25} {14}\n"
                     + "{15,-25} {16}\n"
                     + "{17,-25} {18}\n"
                     + "{19,-25} {20}\n\n",
                     "ES VERSION:", VersionInfo.Version, VersionInfo.Branch, VersionInfo.Hashtag, VersionInfo.Timestamp,
                     "OS:", OS.OsFlavor, Environment.OSVersion,
                     "RUNTIME:", OS.GetRuntimeVersion(), Marshal.SizeOf(typeof(IntPtr)) * 8,
                     "GC:",
                     GC.MaxGeneration == 0
                                        ? "NON-GENERATION (PROBABLY BOEHM)"
                                        : string.Format("{0} GENERATIONS", GC.MaxGeneration + 1),
                     "DBPATH:", DbPath,
                     "TCP ENDPOINT:", TcpEndPoint,
                     "TCP SECURE ENDPOINT:", TcpSecEndPoint,
                     "HTTP ENDPOINT:", ExtHttpEndPoint);

            Node = builder.Build();
            Db   = ((TestVNodeBuilder)builder).GetDb();

            _kestrelTestServer = new TestServer(new WebHostBuilder()
                                                .UseKestrel()
                                                .UseStartup(new ClusterVNodeStartup(Node)));
            HttpMessageHandler = _kestrelTestServer.CreateHandler();
            HttpClient         = new HttpClient(HttpMessageHandler);

            Node.ExternalHttpService.SetupController(new TestController(Node.MainQueue));
        }