protected async Task SqlStatisticsPublisher_ReportMetrics_Silo()
        {
            var options = new SqlMembershipOptions()
            {
                AdoInvariant     = AdoInvariant,
                ConnectionString = ConnectionString
            };

            IMembershipTable mbr = new SqlMembershipTable(this.environment.Services.GetRequiredService <IGrainReferenceConverter>(),
                                                          this.environment.Services.GetRequiredService <IOptions <SiloOptions> >(), Options.Create(options),
                                                          this.loggerFactory.CreateLogger <SqlMembershipTable>());
            await mbr.InitializeMembershipTable(true).WithTimeout(TimeSpan.FromMinutes(1));

            StatisticsPublisher.AddConfiguration("statisticsDeployment", true, "statisticsSiloId", SiloAddressUtils.NewLocalSiloAddress(0), new IPEndPoint(IPAddress.Loopback, 12345), "statisticsHostName");
            await RunParallel(10, () => StatisticsPublisher.ReportMetrics((ISiloPerformanceMetrics) new DummyPerformanceMetrics()));
        }
Example #2
0
        public async Task SqlStatisticsPublisher_MySql_ReportMetrics_Silo()
        {
            GlobalConfiguration config = new GlobalConfiguration
            {
                DeploymentId         = "statisticsDeployment",
                AdoInvariant         = adoInvariant,
                DataConnectionString = connectionString
            };

            IMembershipTable mbr = new SqlMembershipTable();
            await mbr.InitializeMembershipTable(config, true, logger).WithTimeout(timeout);

            await Initialize();

            statisticsPublisher.AddConfiguration("statisticsDeployment", true, "statisticsSiloId", SiloAddress.NewLocalAddress(0), new IPEndPoint(IPAddress.Loopback, 12345), "statisticsHostName");
            await RunParallel(10, () => statisticsPublisher.ReportMetrics((ISiloPerformanceMetrics) new DummyPerformanceMetrics()));
        }
Example #3
0
        private async Task Initialize()
        {
            deploymentId = "test-" + Guid.NewGuid();
            int generation = SiloAddress.AllocateNewGeneration();

            siloAddress = SiloAddress.NewLocalAddress(generation);

            logger.Info("DeploymentId={0} Generation={1}", deploymentId, generation);

            GlobalConfiguration config = new GlobalConfiguration
            {
                DeploymentId         = deploymentId,
                DataConnectionString = relationalStorage.ConnectionString
            };

            var mbr = new SqlMembershipTable();
            await mbr.InitializeMembershipTable(config, true, logger).WithTimeout(timeout);

            membership = mbr;
        }
Example #4
0
        public async Task GatewaySelection_SqlServer()
        {
            string testName = TestContext.TestName;

            Console.WriteLine(TestUtils.DumpTestContext(TestContext));

            Guid serviceId = Guid.NewGuid();

            GlobalConfiguration cfg = new GlobalConfiguration
            {
                ServiceId            = serviceId,
                DeploymentId         = testName,
                DataConnectionString = TestHelper.TestUtils.GetSqlConnectionString(TestContext)
            };

            var membership = new SqlMembershipTable();
            var logger     = TraceLogger.GetLogger(membership.GetType().Name);
            await membership.InitializeMembershipTable(cfg, true, logger);

            IMembershipTable membershipTable = membership;

            // Pre-populate gateway table with data
            int count = 1;

            foreach (Uri gateway in gatewayAddressUris)
            {
                Console.WriteLine("Adding gataway data for {0}", gateway);

                SiloAddress siloAddress = gateway.ToSiloAddress();
                Assert.IsNotNull(siloAddress, "Unable to get SiloAddress from Uri {0}", gateway);

                MembershipEntry MembershipEntry = new MembershipEntry
                {
                    SiloAddress = siloAddress,
                    HostName    = gateway.Host,
                    Status      = SiloStatus.Active,
                    ProxyPort   = gateway.Port,
                    StartTime   = DateTime.UtcNow
                };

                var tableVersion = new TableVersion(count, Guid.NewGuid().ToString());

                Console.WriteLine("Inserting gataway data for {0} with TableVersion={1}", MembershipEntry, tableVersion);

                bool ok = await membershipTable.InsertRow(MembershipEntry, tableVersion);

                count++;
                Assert.IsTrue(ok, "Membership record should have been written OK but were not: {0}", MembershipEntry);

                Console.WriteLine("Successfully inserted Membership row {0}", MembershipEntry);
            }

            MembershipTableData data = await membershipTable.ReadAll();

            Assert.IsNotNull(data, "MembershipTableData returned");
            Assert.AreEqual(gatewayAddressUris.Count, data.Members.Count, "Number of gateway records read");

            IGatewayListProvider listProvider = membership;

            Test_GatewaySelection(listProvider);
        }