public GetEventStoreAggregateRepositoryTests()
        {
            _id = "aggregate-" + Guid.NewGuid().ToString("n");
            var source = new TaskCompletionSource <bool>();

            _eventStoreInitialized = source.Task;
            var notListening = new IPEndPoint(IPAddress.None, 0);

            _node = EmbeddedVNodeBuilder
                    .AsSingleNode()
                    .WithExternalTcpOn(notListening)
                    .WithInternalTcpOn(notListening)
                    .WithExternalHttpOn(notListening)
                    .WithInternalHttpOn(notListening)
                    .RunProjections(ProjectionsMode.All);
            _node.NodeStatusChanged += (_, e) =>
            {
                if (e.NewVNodeState != VNodeState.Master)
                {
                    return;
                }
                source.SetResult(true);
            };
            _connection = EmbeddedEventStoreConnection.Create(_node);
            _sut        = new GetEventStoreAggregateRepository(_connection, new DefaultGetEventStoreJsonSerializer());

            _node.Start();
        }
        protected EventStoreGrpcFixture(
            Action <VNodeBuilder> configureVNode      = default,
            Action <IWebHostBuilder> configureWebHost = default)
        {
            var webHostBuilder = new WebHostBuilder();

            configureWebHost?.Invoke(webHostBuilder);

            var vNodeBuilder = new TestVNodeBuilder();

            vNodeBuilder.RunInMemory().WithTfChunkSize(1024 * 1024);
            configureVNode?.Invoke(vNodeBuilder);

            Node = vNodeBuilder.Build();
            _db  = vNodeBuilder.GetDb();

            _testServer = new TestServer(
                webHostBuilder
                .UseStartup(new TestClusterVNodeStartup(Node)));

            Client = new EventStoreGrpcClient(new UriBuilder().Uri, () => new HttpClient(new ResponseVersionHandler {
                InnerHandler = _testServer.CreateHandler()
            })
            {
                Timeout = Timeout.InfiniteTimeSpan
            });
        }
예제 #3
0
        public void Establish()
        {
            s_eventStoreNodeStarted     = false;
            s_eventStoreClientConnected = false;

            var noneIp = new IPEndPoint(IPAddress.None, 0);

            s_eventStoreNode = EmbeddedVNodeBuilder
                               .AsSingleNode()
                               .RunInMemory()
                               .WithExternalTcpOn(noneIp)
                               .WithInternalTcpOn(noneIp)
                               .WithExternalHttpOn(noneIp)
                               .WithInternalHttpOn(noneIp)
                               .Build();
            s_eventStoreNode.NodeStatusChanged +=
                (sender, e) => { if (e.NewVNodeState == VNodeState.Master)
                                 {
                                     s_eventStoreNodeStarted = true;
                                 }
            };
            s_eventStoreNode.Start();

            s_eventStore            = EmbeddedEventStoreConnection.Create(s_eventStoreNode);
            s_eventStore.Connected += (sender, e) => { s_eventStoreClientConnected = true; };
            s_eventStore.ConnectAsync().Wait();

            s_eventStoreMessageStore = new EventStoreMessageStore(s_eventStore);

            EnsureEventStoreNodeHasStartedAndTheClientHasConnected();
        }
예제 #4
0
        public EventStoreFixture()
        {
            _node = EmbeddedVNodeBuilder
                    .AsSingleNode()
                    .OnDefaultEndpoints()
                    .RunInMemory()
                    .DisableDnsDiscovery()
                    .DisableHTTPCaching()
                    //.DisableScavengeMerging()
                    .DoNotVerifyDbHashes()
                    .Build();

            _node.StartAndWaitUntilReady().Wait();

            var conns = ConnectionSettings.Create()
                        .SetDefaultUserCredentials(new EventStore.ClientAPI.SystemData.UserCredentials("admin", "changeit"))
                        .Build();

            var eventStoreConnection = EmbeddedEventStoreConnection.Create(_node, conns);

            StreamStoreConnection = new EventStoreConnectionWrapper(eventStoreConnection);

            EventSerializer   = new JsonMessageSerializer();
            StreamNameBuilder = new PrefixedCamelCaseStreamNameBuilder("masterdata");

            _repo = new StreamStoreRepository(StreamNameBuilder, StreamStoreConnection, EventSerializer);
        }
예제 #5
0
        public static EventStoreStatelessActorBuilder <TActor, TRegistry> Create(
            ClusterVNode clusterVNode,
            ConnectionSettings connectionSettings,
            IActorConfiguration actorConfiguration,
            ILoggerFactory?loggerFactory = null,
            Action <IEventStoreRepositoryConfiguration>?getEventStoreRepositoryConfiguration = null)

        {
            var connection = EmbeddedEventStoreConnection.Create(clusterVNode, connectionSettings);

            loggerFactory ??= new DummyLoggerFactory();

            var eventStoreRepositoryConfiguration = new EventStoreRepositoryConfiguration();

            getEventStoreRepositoryConfiguration?.Invoke(eventStoreRepositoryConfiguration);

            var connectionStatusMonitor = new EventStoreConnectionStatusMonitor(connection, loggerFactory);

            var eventStoreRepository = new EventStoreRepository(
                eventStoreRepositoryConfiguration,
                connection,
                connectionStatusMonitor,
                loggerFactory);

            var eventStoreStatelessActorBuilder = new EventStoreStatelessActorBuilder <TActor, TRegistry>(actorConfiguration, eventStoreRepository, connectionStatusMonitor, loggerFactory);

            return(eventStoreStatelessActorBuilder);
        }
        public async Task Setup()
        {
            _userCredentials = new UserCredentials("admin", "changeit");

            _connectionSettings = ConnectionSettings.Create()
                                  .UseDebugLogger()
                                  .SetDefaultUserCredentials(_userCredentials)
                                  .KeepRetrying()
                                  .Build();


            _loggerFactory = new LoggerFactory();

            _clusterVNode = EmbeddedVNodeBuilder
                            .AsSingleNode()
                            .RunInMemory()
                            .RunProjections(ProjectionType.All)
                            .StartStandardProjections()
                            .WithWorkerThreads(1)
                            .Build();

            await _clusterVNode.StartAsync(true);

            await CreateSubscriptionGroups();
        }
        public static World AddWorld(this IServiceCollection services,
                                     ClusterVNode clusterVNode,
                                     ConnectionSettings connectionSettings,
                                     Action <IEventStoreRepositoryConfiguration> getEventStoreRepositoryConfiguration = null)
        {
            var eventStoreConnection = EmbeddedEventStoreConnection.Create(clusterVNode, connectionSettings);

            services.AddSingleton <IConnectionStatusMonitor <IEventStoreConnection>, EventStoreConnectionStatusMonitor>();
            services.AddSingleton(eventStoreConnection);
            services.AddSingleton(connectionSettings);

            var eventStoreRepositoryConfiguration = new EventStoreRepositoryConfiguration();

            getEventStoreRepositoryConfiguration?.Invoke(eventStoreRepositoryConfiguration);

            services.AddSingleton <IEventStoreRepositoryConfiguration>(eventStoreRepositoryConfiguration);

            services.AddTransient <IEventStoreRepository, EventStoreRepository>();

            var world = new World(services, true);

            services.AddSingleton(world);

            return(world);
        }
예제 #8
0
        public MiniClusterNode(
            string pathname, int debugIndex, IPEndPoint internalTcp, IPEndPoint internalTcpSec, IPEndPoint internalHttp,
            IPEndPoint externalTcp, IPEndPoint externalTcpSec, IPEndPoint externalHttp, IPEndPoint[] gossipSeeds,
            ISubsystem[] subsystems = null, int?chunkSize = null, int?cachedChunkSize = null,
            bool enableTrustedAuth  = false, bool skipInitializeStandardUsersCheck = true, int memTableSize = 1000,
            bool inMemDb            = true, bool disableFlushToDisk = false)
        {
            RunningTime.Start();
            RunCount += 1;

            _dbPath = Path.Combine(
                pathname,
                string.Format(
                    "mini-cluster-node-db-{0}-{1}-{2}", externalTcp.Port, externalTcpSec.Port, externalHttp.Port));

            Directory.CreateDirectory(_dbPath);
            FileStreamExtensions.ConfigureFlush(disableFlushToDisk);
            Db =
                new TFChunkDb(
                    CreateDbConfig(chunkSize ?? ChunkSize, _dbPath, cachedChunkSize ?? CachedChunkSize, inMemDb));

            InternalTcpEndPoint    = internalTcp;
            InternalTcpSecEndPoint = internalTcpSec;
            InternalHttpEndPoint   = internalHttp;

            ExternalTcpEndPoint    = externalTcp;
            ExternalTcpSecEndPoint = externalTcpSec;
            ExternalHttpEndPoint   = externalHttp;

            var singleVNodeSettings = new ClusterVNodeSettings(
                Guid.NewGuid(), debugIndex, InternalTcpEndPoint, InternalTcpSecEndPoint, ExternalTcpEndPoint,
                ExternalTcpSecEndPoint, InternalHttpEndPoint, ExternalHttpEndPoint,
                new Data.GossipAdvertiseInfo(InternalTcpEndPoint, InternalTcpSecEndPoint,
                                             ExternalTcpEndPoint, ExternalTcpSecEndPoint,
                                             InternalHttpEndPoint, ExternalHttpEndPoint),
                new[] { InternalHttpEndPoint.ToHttpUrl() }, new[] { ExternalHttpEndPoint.ToHttpUrl() }, enableTrustedAuth, ssl_connections.GetCertificate(), 1, false,
                "", gossipSeeds, TFConsts.MinFlushDelayMs, 3, 2, 2, TimeSpan.FromSeconds(2), TimeSpan.FromSeconds(2),
                false, "", false, TimeSpan.FromHours(1), StatsStorage.None, 0,
                new InternalAuthenticationProviderFactory(), disableScavengeMerging: true, scavengeHistoryMaxAge: 30, adminOnPublic: true,
                statsOnPublic: true, gossipOnPublic: true, gossipInterval: TimeSpan.FromSeconds(1),
                gossipAllowedTimeDifference: TimeSpan.FromSeconds(1), gossipTimeout: TimeSpan.FromSeconds(1),
                extTcpHeartbeatTimeout: TimeSpan.FromSeconds(10), extTcpHeartbeatInterval: TimeSpan.FromSeconds(10),
                intTcpHeartbeatTimeout: TimeSpan.FromSeconds(10), intTcpHeartbeatInterval: TimeSpan.FromSeconds(10),
                verifyDbHash: false, maxMemtableEntryCount: memTableSize, startStandardProjections: false, disableHTTPCaching: false, logHttpRequests: false);

            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, "ExTCP ENDPOINT:",
                ExternalTcpEndPoint, "ExTCP SECURE ENDPOINT:", ExternalTcpSecEndPoint, "ExHTTP ENDPOINT:",
                ExternalHttpEndPoint);

            Node = new ClusterVNode(Db, singleVNodeSettings, infoController: new InfoController(null, ProjectionType.None), subsystems: subsystems, gossipSeedSource: new KnownEndpointGossipSeedSource(gossipSeeds));
            Node.ExternalHttpService.SetupController(new TestController(Node.MainQueue));
        }
예제 #9
0
        public ClusterVNodeController(IPublisher outputBus, VNodeInfo nodeInfo, TFChunkDb db,
                                      ClusterVNodeSettings vnodeSettings, ClusterVNode node,
                                      MessageForwardingProxy forwardingProxy, ISubsystem[] subSystems)
        {
            Ensure.NotNull(outputBus, "outputBus");
            Ensure.NotNull(nodeInfo, "nodeInfo");
            Ensure.NotNull(db, "dbConfig");
            Ensure.NotNull(vnodeSettings, "vnodeSettings");
            Ensure.NotNull(node, "node");
            Ensure.NotNull(forwardingProxy, "forwardingProxy");

            _outputBus  = outputBus;
            _nodeInfo   = nodeInfo;
            _db         = db;
            _node       = node;
            _subSystems = subSystems;
            if (vnodeSettings.ClusterNodeCount == 1)
            {
                _serviceShutdownsToExpect = 4;
            }

            _subSystemInitsToExpect = _subSystems != null ? subSystems.Length : 0;

            _forwardingProxy   = forwardingProxy;
            _forwardingTimeout = vnodeSettings.PrepareTimeout + vnodeSettings.CommitTimeout + TimeSpan.FromMilliseconds(300);

            _fsm = CreateFSM();
        }
예제 #10
0
        public ResolvedEventtDispatcherTests()
        {
            var source = new TaskCompletionSource <bool>();

            _nodeStarted = source.Task;

            var notListening = new IPEndPoint(IPAddress.None, 0);

            _node = EmbeddedVNodeBuilder.AsSingleNode()
                    .WithInternalTcpOn(notListening)
                    .WithExternalTcpOn(notListening)
                    .WithInternalHttpOn(notListening)
                    .WithExternalHttpOn(notListening);

            _node.NodeStatusChanged += (_, e) =>
            {
                if (e.NewVNodeState != VNodeState.Master)
                {
                    return;
                }

                source.SetResult(true);
            };

            _node.Start();

            _connection = EmbeddedEventStoreConnection.Create(_node);
        }
예제 #11
0
        public TestRegistry()
        {
            var          noIp = new IPEndPoint(IPAddress.None, 0);
            ClusterVNode node = EmbeddedVNodeBuilder
                                .AsSingleNode()
                                .WithInternalTcpOn(noIp)
                                .WithInternalHttpOn(noIp)
                                .RunInMemory()
                                .Build();
            var connection = EmbeddedEventStoreConnection.Create(node);

            For <ClusterVNode>()
            .Singleton()
            .Use(node);

            For <IEventStoreConnection>()
            .Singleton()
            .Use(connection);

            For <EventStoreUnitOfWork>()
            .HybridHttpOrThreadLocalScoped()
            .Use <TestUnitOfWork>()
            .Ctor <IEventEmitter>()
            .Is(c => c.GetInstance <IEventEmitter>())
            ;

            //For<IEventRepository>()
            //    .Use(c => c.GetInstance<TestUnitOfWork>().EventRepository)
            //    ;
            For <NHibernateUnitOfWork>()
            .HybridHttpOrThreadLocalScoped()
            .Use <NHibernateUnitOfWork>();
        }
예제 #12
0
        private void Bootstrap()
        {
            // GetEventStore runs on the client on default tcp port 1113. Thus, the in memory cannot run on the same.
            _node =
                EmbeddedVNodeBuilder.AsSingleNode()
                .RunInMemory()
                .WithInternalTcpOn(new IPEndPoint(IPAddress.Loopback, 1114))
                .WithExternalTcpOn(new IPEndPoint(IPAddress.Loopback, 1115))
                .WithInternalHttpOn(new IPEndPoint(IPAddress.Loopback, 2114))
                .WithExternalHttpOn(new IPEndPoint(IPAddress.Loopback, 2115))
                .Build();

            bool isNodeMaster = false;

            _node.NodeStatusChanged += (sender, args) => isNodeMaster = args.NewVNodeState == VNodeState.Master;
            _node.Start();

            var stopwatch = new Stopwatch();

            stopwatch.Start();
            while (!isNodeMaster)
            {
                if (stopwatch.Elapsed.Seconds > 20)
                {
                    throw new EventStoreConnectionException("In memory node failed to become master within the time limit");
                }
                Thread.Sleep(1);
            }
            stopwatch.Stop();
        }
예제 #13
0
        // This method gets called by the runtime. Use this method to add services to the container.
        // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddSingleton(ctx => {
                var log = ctx.GetService <ILogger <Startup> >();
                //RESEARCH: Should this be in a hosted service instead?
                var nodeBuilder = EmbeddedVNodeBuilder.AsSingleNode()
                                  .DisableExternalTls()
                                  .DisableInternalTls()
                                  .WithInternalHttpOn(new IPEndPoint(IPAddress.Loopback, 1112))
                                  .WithInternalTcpOn(new IPEndPoint(IPAddress.Loopback, 1113))
                                  .DisableDnsDiscovery()
                                  .WithGossipSeeds(new IPEndPoint[] {
                    new IPEndPoint(IPAddress.Loopback, 2112),
                    new IPEndPoint(IPAddress.Loopback, 3112)
                })
                                  .EnableTrustedAuth()
                                  .RunInMemory();
                Node = nodeBuilder.Build();
                Node.StartAsync(true).Wait();

                var conn = EmbeddedEventStoreConnection.Create(Node,
                                                               ConnectionSettings.Create()
                                                               .SetDefaultUserCredentials(new UserCredentials("admin", "changeit"))
                                                               .Build());
                conn.ConnectAsync().Wait(TimeSpan.FromSeconds(30));

                return(conn);
            });

            services.AddRazorPages();
            services.AddServerSideBlazor();
            services.AddSingleton <WeatherForecastService>();
        }
예제 #14
0
        private void CreateEmbeddedServer()
        {
            EmbeddedVNodeBuilder builder;

            builder = EmbeddedVNodeBuilder.AsSingleNode();
            builder.RunProjections(ProjectionsMode.All);
            builder.OnDefaultEndpoints();
            if (_runneroptions.RunInMemory)
            {
                builder.RunInMemory();
            }
            else
            {
                string combinedPath;
                if (Path.IsPathRooted(_runneroptions.DataDirectory))
                {
                    combinedPath = _runneroptions.DataDirectory;
                }
                else
                {
                    combinedPath = Path.Combine(Assembly.GetExecutingAssembly().GetExecutingFolder(), _runneroptions.DataDirectory);
                }
                builder.RunOnDisk(combinedPath);
            }
            _embeddednode = builder.Build();
            _embeddednode.Start();
        }
예제 #15
0
 public TestClusterVNodeStartup(ClusterVNode node)
 {
     if (node == null)
     {
         throw new ArgumentNullException(nameof(node));
     }
     _node = node;
 }
예제 #16
0
        private void before_each()
        {
            _node       = EmbeddedEventStore.Start();
            _connection = EmbeddedEventStoreConnection.Create(_node);
            _connection.ConnectAsync().Wait();

            _sut = new UserByEmailIndex(_connection, new EventSerializer());
        }
예제 #17
0
        private void before_each()
        {
            _node       = EmbeddedEventStore.Start();
            _connection = EmbeddedEventStoreConnection.Create(_node);
            _connection.ConnectAsync().Wait();

            _sut = new UserRegistrationProcessRepository(_connection, new EventSerializer());
        }
        public an_evenstore_connection()
        {
            _node = EmbeddedVNodeBuilder.AsSingleNode().OnDefaultEndpoints().RunInMemory().Build();
            _node.StartAndWaitUntilReady().Wait();

            Connection = EmbeddedEventStoreConnection.Create(_node);
            Connection.ConnectAsync().Wait();
        }
 public static void SetupNode()
 {
     node = CreateInMemoryEventStoreNode();
     if (connection == null)
     {
         connection = EmbeddedEventStoreConnection.Create(node);
         connection.ConnectAsync().Wait();
     }
 }
예제 #20
0
        public void CreateTestNode()
        {
            var builder = IntegrationVNodeBuilder
                          .AsSingleNode()
                          .RunInMemory();

            _node = builder.Build();
            _node.StartAsync(true).Wait();
        }
예제 #21
0
 public virtual void TestFixtureSetUp()
 {
     _builder = TestVNodeBuilder.AsSingleNode()
                                .RunInMemory();
     Given();
     _node = _builder.Build();
     _settings = ((TestVNodeBuilder)_builder).GetSettings();
     _dbConfig = ((TestVNodeBuilder)_builder).GetDbConfig();
     _node.Start();
 }
        public void CreateTestNode()
        {
            var builder = IntegrationVNodeBuilder
                          .AsSingleNode()
                          .WithServerCertificate(ssl_connections.GetServerCertificate())
                          .RunInMemory();

            _node = builder.Build();
            _node.StartAsync(true).Wait();
        }
예제 #23
0
 public void CreateTestNode()
 {
     _node = new ClusterVNode(new ClusterVNodeOptions()
                              .RunInMemory()
                              .Secure(new X509Certificate2Collection(ssl_connections.GetRootCertificate()),
                                      ssl_connections.GetServerCertificate()),
                              new AuthenticationProviderFactory(c => new InternalAuthenticationProviderFactory(c)),
                              new AuthorizationProviderFactory(c => new LegacyAuthorizationProviderFactory(c.MainQueue)));
     _node.StartAsync(true).Wait();
 }
예제 #24
0
 private static void StartEmbeddedEventStore()
 {
     if (EnableEmbeddedEventStore)
     {
         var nodeBuilder = EmbeddedVNodeBuilder.AsSingleNode().OnDefaultEndpoints().RunInMemory();
         nodeBuilder.WithStatsPeriod(TimeSpan.FromSeconds(1));
         EventStoreNode = nodeBuilder.Build();
         EventStoreNode.StartAndWaitUntilReady().Wait();
     }
 }
 public virtual void TestFixtureSetUp()
 {
     _builder = TestVNodeBuilder.AsSingleNode()
                .RunInMemory();
     Given();
     _node     = _builder.Build();
     _settings = ((TestVNodeBuilder)_builder).GetSettings();
     _dbConfig = ((TestVNodeBuilder)_builder).GetDbConfig();
     _node.Start();
 }
예제 #26
0
        public EventStoreClientAPIClusterFixture()
        {
            var serverCertificate = GetServerCertificate();
            var rootCertificates  = new X509Certificate2Collection(GetRootCertificate());

            for (var i = 0; i < ClusterSize; i++)
            {
                var vNodeBuilder = ClusterVNodeBuilder
                                   .AsClusterMember(ClusterSize)
                                   .DisableDnsDiscovery()
                                   .WithGossipSeeds(GetGossipSeedEndPointsExceptFor(i, false))
                                   .WithHttpOn(new IPEndPoint(IPAddress.Loopback, HttpPort[i]))
                                   .WithInternalTcpOn(new IPEndPoint(IPAddress.Loopback, InternalTcpPort[i]))
                                   .WithInternalSecureTcpOn(new IPEndPoint(IPAddress.Loopback, InternalSecureTcpPort[i]))
                                   .WithExternalTcpOn(new IPEndPoint(IPAddress.Loopback, ExternalTcpPort[i]))
                                   .WithExternalSecureTcpOn(new IPEndPoint(IPAddress.Loopback, ExternalSecureTcpPort[i]))
                                   .WithServerCertificate(serverCertificate)
                                   .WithTrustedRootCertificates(rootCertificates)
                                   .WithCertificateReservedNodeCommonName(Opts.CertificateReservedNodeCommonNameDefault)
                                   .RunInMemory()
                                   .EnableExternalTCP();

                _nodes[i] = vNodeBuilder.Build();

                var httpEndPoint = new IPEndPoint(IPAddress.Loopback, HttpPort[i]);

                _hosts[i] = new WebHostBuilder()
                            .UseKestrel(o => {
                    o.Listen(httpEndPoint, options => {
                        if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
                        {
                            options.Protocols = HttpProtocols.Http2;
                        }
                        else
                        {
                            options.UseHttps(new HttpsConnectionAdapterOptions {
                                ServerCertificate           = serverCertificate,
                                ClientCertificateMode       = ClientCertificateMode.AllowCertificate,
                                ClientCertificateValidation = (certificate, chain, sslPolicyErrors) => {
                                    var(isValid, error) =
                                        ClusterVNode.ValidateClientCertificateWithTrustedRootCerts(certificate, chain, sslPolicyErrors, rootCertificates);
                                    if (!isValid && error != null)
                                    {
                                        Log.Error("Client certificate validation error: {e}", error);
                                    }
                                    return(isValid);
                                }
                            });
                        }
                    });
                })
                            .ConfigureServices(services => services.AddSingleton(_nodes[i].Startup))
                            .Build();
            }
        }
예제 #27
0
 public virtual void TestFixtureSetUp()
 {
     _builder = TestVNodeBuilder.AsSingleNode()
                .WithServerCertificate(ssl_connections.GetServerCertificate())
                .RunInMemory();
     Given();
     _node     = _builder.Build();
     _settings = ((TestVNodeBuilder)_builder).GetSettings();
     _dbConfig = ((TestVNodeBuilder)_builder).GetDbConfig();
     _node.Start();
 }
 public virtual void TestFixtureSetUp()
 {
     _builder = TestVNodeBuilder.AsClusterMember(_clusterSize)
                .RunInMemory();
     _quorumSize = _clusterSize / 2 + 1;
     Given();
     _node     = _builder.Build();
     _settings = ((TestVNodeBuilder)_builder).GetSettings();
     _dbConfig = ((TestVNodeBuilder)_builder).GetDbConfig();
     _node.Start();
 }
예제 #29
0
 public virtual void TestFixtureSetUp()
 {
     _builder = TestVNodeBuilder.AsClusterMember(_clusterSize)
                                .RunInMemory();
     _quorumSize = _clusterSize / 2 + 1;
     Given();
     _node = _builder.Build();
     _settings = ((TestVNodeBuilder)_builder).GetSettings();
     _dbConfig = ((TestVNodeBuilder)_builder).GetDbConfig();
     _node.Start();
 }
예제 #30
0
        public OrderTests()
        {
            node = EmbeddedVNodeBuilder
                   .AsSingleNode()
                   .OnDefaultEndpoints()
                   .RunInMemory();

            connectionSettingsBuilder = ConnectionSettings
                                        .Create()
                                        .SetDefaultUserCredentials(new UserCredentials("admin", "changeit"))
                                        .KeepReconnecting();
        }
 public virtual void TestFixtureSetUp()
 {
     _options = WithOptions(
         new ClusterVNodeOptions()
         .RunInMemory()
         .Secure(new X509Certificate2Collection(ssl_connections.GetRootCertificate()),
                 ssl_connections.GetServerCertificate()));
     _node = new ClusterVNode(_options,
                              new AuthenticationProviderFactory(c => new InternalAuthenticationProviderFactory(c)),
                              new AuthorizationProviderFactory(c => new LegacyAuthorizationProviderFactory(c.MainQueue)));
     _node.Start();
 }
예제 #32
0
        static StaticData()
        {
            _clusterVNode = EmbeddedVNodeBuilder
                            .AsSingleNode()
                            .RunInMemory()
                            .RunProjections(ProjectionType.All)
                            .StartStandardProjections()
                            .WithWorkerThreads(1)
                            .Build();

            _clusterVNode.StartAsync(true).Wait();
        }
예제 #33
0
        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)
        {
            if (_running) throw new Exception("Previous MiniNode is still running!!!");
            _running = true;

            RunningTime.Start();
            RunCount += 1;

            IPAddress 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);
            _dbPath = Path.Combine(pathname, string.Format("mini-node-db-{0}-{1}-{2}", extTcpPort, extSecTcpPort, extHttpPort));
            Directory.CreateDirectory(_dbPath);
            FileStreamExtensions.ConfigureFlush(disableFlushToDisk);
            Db = new TFChunkDb(CreateDbConfig(chunkSize ?? ChunkSize, _dbPath, cachedChunkSize ?? CachedChunkSize, inMemDb));
            
            TcpEndPoint = new IPEndPoint(ip, extTcpPort);
            TcpSecEndPoint = new IPEndPoint(ip, extSecTcpPort);
            HttpEndPoint = new IPEndPoint(ip, extHttpPort);
            IntTcpEndPoint = new IPEndPoint(ip,intTcpPort);
            IntSecTcpEndPoint = new IPEndPoint(ip, intSecTcpPort);
            IntHttpEndPoint = new IPEndPoint(ip, intHttpPort);
            var vNodeSettings = new ClusterVNodeSettings(Guid.NewGuid(),
                                                         0,
                                                         IntTcpEndPoint,
                                                         IntSecTcpEndPoint,
                                                         TcpEndPoint,
                                                         TcpSecEndPoint,
                                                         IntHttpEndPoint,
                                                         HttpEndPoint,
                                                         new [] {HttpEndPoint.ToHttpUrl()},
                                                         enableTrustedAuth,
                                                         ssl_connections.GetCertificate(),
                                                         1,
                                                         false,
                                                         "whatever",
                                                         new IPEndPoint[] {},
                                                         TFConsts.MinFlushDelayMs,
                                                         1,
                                                         1,
                                                         1,
                                                         TimeSpan.FromSeconds(2),
                                                         TimeSpan.FromSeconds(2),
                                                         false,
                                                         "",
                                                         false,
                                                         TimeSpan.FromHours(1),
                                                         StatsStorage.None,
                                                         1,
                                                         new InternalAuthenticationProviderFactory(),
                                                         true,
                                                         true,
                                                         true,
                                                         false,
                                                         TimeSpan.FromSeconds(30),
                                                         TimeSpan.FromSeconds(30),
                                                         TimeSpan.FromSeconds(10),
                                                         TimeSpan.FromSeconds(10),
                                                         TimeSpan.FromSeconds(10),
                                                         TimeSpan.FromSeconds(10),
                                                         TimeSpan.FromSeconds(10),
                                                         false,
                                                         memTableSize);
            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:", HttpEndPoint);
            Node = new ClusterVNode(Db, vNodeSettings, new KnownEndpointGossipSeedSource(new [] {HttpEndPoint}), subsystems);

            Node.ExternalHttpService.SetupController(new TestController(Node.MainQueue));
        }
 public EventStoreWrapper(GesEventStore inner, ClusterVNode node)
 {
     _inner = inner;
     _node = node;
 }
예제 #35
0
        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)
        {
            if (_running) throw new Exception("Previous MiniNode is still running!!!");
            _running = true;

            RunningTime.Start();
            RunCount += 1;

            IPAddress 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);

            _dbPath = Path.Combine(pathname, string.Format("mini-node-db-{0}-{1}-{2}", extTcpPort, extSecTcpPort, extHttpPort));
    
            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(2))
                   .WithCommitTimeout(TimeSpan.FromSeconds(2))
                   .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);

            if(enableTrustedAuth)
                builder.EnableTrustedAuth();
            if(disableFlushToDisk)
                builder.WithUnsafeDisableFlushToDisk();

            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();

            Node.ExternalHttpService.SetupController(new TestController(Node.MainQueue));
        }
예제 #36
0
        public MiniClusterNode(
            string pathname, int debugIndex, IPEndPoint internalTcp, IPEndPoint internalTcpSec, IPEndPoint internalHttp,
            IPEndPoint externalTcp, IPEndPoint externalTcpSec, IPEndPoint externalHttp, IPEndPoint[] gossipSeeds,
            ISubsystem[] subsystems = null, int? chunkSize = null, int? cachedChunkSize = null,
            bool enableTrustedAuth = false, bool skipInitializeStandardUsersCheck = true, int memTableSize = 1000,
            bool inMemDb = true, bool disableFlushToDisk = false)
        {
            RunningTime.Start();
            RunCount += 1;

            _dbPath = Path.Combine(
                pathname,
                string.Format(
                    "mini-cluster-node-db-{0}-{1}-{2}", externalTcp.Port, externalTcpSec.Port, externalHttp.Port));

            Directory.CreateDirectory(_dbPath);
            FileStreamExtensions.ConfigureFlush(disableFlushToDisk);
            Db =
                new TFChunkDb(
                    CreateDbConfig(chunkSize ?? ChunkSize, _dbPath, cachedChunkSize ?? CachedChunkSize, inMemDb));

            InternalTcpEndPoint = internalTcp;
            InternalTcpSecEndPoint = internalTcpSec;
            InternalHttpEndPoint = internalHttp;

            ExternalTcpEndPoint = externalTcp;
            ExternalTcpSecEndPoint = externalTcpSec;
            ExternalHttpEndPoint = externalHttp;

            var singleVNodeSettings = new ClusterVNodeSettings(
                Guid.NewGuid(), debugIndex, InternalTcpEndPoint, InternalTcpSecEndPoint, ExternalTcpEndPoint,
                ExternalTcpSecEndPoint, InternalHttpEndPoint, ExternalHttpEndPoint,
                new[] {ExternalHttpEndPoint.ToHttpUrl()}, enableTrustedAuth, ssl_connections.GetCertificate(), 1, false,
                "", gossipSeeds, TFConsts.MinFlushDelayMs, 3, 2, 2, TimeSpan.FromSeconds(2), TimeSpan.FromSeconds(2),
                false, "", false, TimeSpan.FromHours(1), StatsStorage.None, 0,
                new InternalAuthenticationProviderFactory(), disableScavengeMerging: true, adminOnPublic: true,
                statsOnPublic: true, gossipOnPublic: true, gossipInterval: TimeSpan.FromSeconds(1),
                gossipAllowedTimeDifference: TimeSpan.FromSeconds(1), gossipTimeout: TimeSpan.FromSeconds(1),
                extTcpHeartbeatTimeout: TimeSpan.FromSeconds(10), extTcpHeartbeatInterval: TimeSpan.FromSeconds(10),
                intTcpHeartbeatTimeout: TimeSpan.FromSeconds(10), intTcpHeartbeatInterval: TimeSpan.FromSeconds(10),
                verifyDbHash: false, maxMemtableEntryCount: memTableSize);

            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, "ExTCP ENDPOINT:",
                ExternalTcpEndPoint, "ExTCP SECURE ENDPOINT:", ExternalTcpSecEndPoint, "ExHTTP ENDPOINT:",
                ExternalHttpEndPoint);

            Node = new ClusterVNode(Db, singleVNodeSettings, infoController: new InfoController(null), subsystems: subsystems, gossipSeedSource: new KnownEndpointGossipSeedSource(gossipSeeds));
            Node.ExternalHttpService.SetupController(new TestController(Node.MainQueue));
        }