コード例 #1
0
ファイル: MembershipFactory.cs プロジェクト: supwar/orleans
        internal IMembershipTable GetMembershipTable(GlobalConfiguration.LivenessProviderType livenessType)
        {
            IMembershipTable membershipTable;

            if (livenessType.Equals(GlobalConfiguration.LivenessProviderType.MembershipTableGrain))
            {
                membershipTable =
                    GrainReference.FromGrainId(Constants.SystemMembershipTableId).Cast <IMembershipTableGrain>();
            }
            else if (livenessType.Equals(GlobalConfiguration.LivenessProviderType.SqlServer))
            {
                membershipTable = new SqlMembershipTable();
            }
            else if (livenessType.Equals(GlobalConfiguration.LivenessProviderType.AzureTable))
            {
                membershipTable = AssemblyLoader.LoadAndCreateInstance <IMembershipTable>(Constants.ORLEANS_AZURE_UTILS_DLL, logger);
            }
            else if (livenessType.Equals(GlobalConfiguration.LivenessProviderType.ZooKeeper))
            {
                membershipTable = AssemblyLoader.LoadAndCreateInstance <IMembershipTable>(Constants.ORLEANS_ZOOKEEPER_UTILS_DLL, logger);
            }
            else
            {
                throw new NotImplementedException("No membership table provider found for LivenessType=" + livenessType);
            }

            return(membershipTable);
        }
コード例 #2
0
ファイル: MembershipFactory.cs プロジェクト: mellodev/orleans
        internal IMembershipTable GetMembershipTable(GlobalConfiguration.LivenessProviderType livenessType)
        {
            IMembershipTable membershipTable;
            if (livenessType.Equals(GlobalConfiguration.LivenessProviderType.MembershipTableGrain))
            {
                membershipTable = GrainFactory.Cast<IMembershipTableGrain>(GrainReference.FromGrainId(Constants.SystemMembershipTableId));
            }
            else if (livenessType.Equals(GlobalConfiguration.LivenessProviderType.SqlServer))
            {
                membershipTable = new SqlMembershipTable();
            }
            else if (livenessType.Equals(GlobalConfiguration.LivenessProviderType.AzureTable))
            {
                membershipTable = AssemblyLoader.LoadAndCreateInstance<IMembershipTable>(Constants.ORLEANS_AZURE_UTILS_DLL, logger);
            }
            else if (livenessType.Equals(GlobalConfiguration.LivenessProviderType.ZooKeeper))
            {
                membershipTable = AssemblyLoader.LoadAndCreateInstance<IMembershipTable>(Constants.ORLEANS_ZOOKEEPER_UTILS_DLL, logger);
            }
            else
            {
                throw new NotImplementedException("No membership table provider found for LivenessType=" + livenessType);
            }

            return membershipTable;
        }
コード例 #3
0
ファイル: MembershipFactory.cs プロジェクト: tcunning/orleans
        internal async Task <IMembershipTable> GetMembershipTable(Silo silo)
        {
            var config = silo.GlobalConfig;

            IMembershipTable membershipTable;

            GlobalConfiguration.LivenessProviderType livenessType = config.LivenessType;
            if (livenessType.Equals(GlobalConfiguration.LivenessProviderType.MembershipTableGrain))
            {
                membershipTable = MembershipTableFactory.Cast(GrainReference.FromGrainId(Constants.SystemMembershipTableId));
            }
            else if (livenessType.Equals(GlobalConfiguration.LivenessProviderType.SqlServer))
            {
                membershipTable = await SqlMembershipTable.GetMembershipTable(config, true);
            }
            else if (livenessType.Equals(GlobalConfiguration.LivenessProviderType.AzureTable))
            {
                membershipTable = await AzureBasedMembershipTable.GetMembershipTable(config, true);
            }
            else
            {
                throw new NotImplementedException("No membership table provider found for LivenessType=" + livenessType);
            }
            return(membershipTable);
        }
コード例 #4
0
        internal static async Task<IGatewayListProvider> CreateGatewayListProvider(ClientConfiguration cfg)
        {
            IGatewayListProvider listProvider = null;
            ClientConfiguration.GatewayProviderType gatewayProviderToUse = cfg.GatewayProviderToUse;

            switch (gatewayProviderToUse)
            {
                case ClientConfiguration.GatewayProviderType.AzureTable:
                    listProvider = AssemblyLoader.LoadAndCreateInstance<IGatewayListProvider>(Constants.ORLEANS_AZURE_UTILS_DLL, logger);
                    break;

                case ClientConfiguration.GatewayProviderType.SqlServer:
                    listProvider = new SqlMembershipTable();
                    break;

                case ClientConfiguration.GatewayProviderType.Custom:
                    listProvider = AssemblyLoader.LoadAndCreateInstance<IGatewayListProvider>(cfg.CustomGatewayProviderAssemblyName, logger);
                    break;

                case ClientConfiguration.GatewayProviderType.ZooKeeper:
                    listProvider = AssemblyLoader.LoadAndCreateInstance<IGatewayListProvider>(Constants.ORLEANS_ZOOKEEPER_UTILS_DLL, logger);
                    break;

                case ClientConfiguration.GatewayProviderType.Config:
                    listProvider = new StaticGatewayListProvider();
                    break;

                default:
                    throw new NotImplementedException(gatewayProviderToUse.ToString());
            }

            await listProvider.InitializeGatewayListProvider(cfg, TraceLogger.GetLogger(listProvider.GetType().Name));
            return listProvider;
        }
コード例 #5
0
        public static async Task <SqlMembershipTable> GetMembershipTable(GlobalConfiguration config, bool tryInitTableVersion)
        {
            var table = new SqlMembershipTable(config);

            // even if I am not the one who created the table,
            // try to insert an initial table version if it is not already there,
            // so we always have a first table version row, before this silo starts working.
            if (tryInitTableVersion)
            {
                await table.InitTable();
            }
            return(table);
        }
コード例 #6
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;
        }
コード例 #7
0
        private async Task<IMembershipTable> GetMembershipTable(GlobalConfiguration.LivenessProviderType membershipType)
        {
            string runId = Guid.NewGuid().ToString("N");

            var config = new GlobalConfiguration();
            config.LivenessType = membershipType;
            config.DeploymentId = runId;

            IMembershipTable membership;

            if (membershipType == GlobalConfiguration.LivenessProviderType.AzureTable)
            {
                config.DataConnectionString = StorageTestConstants.DataConnectionString;
                membership = new AzureBasedMembershipTable();
            }
            else if (membershipType == GlobalConfiguration.LivenessProviderType.SqlServer)
            {
                config.DataConnectionString = TestUtils.GetSqlConnectionString(TestContext);
                membership = new SqlMembershipTable();
            }
            else
            {
                throw new NotImplementedException(membershipType.ToString());
            }

            await membership.InitializeMembershipTable(config, true, logger);

            return membership;
        }
コード例 #8
0
ファイル: GatewaySelectionTest.cs プロジェクト: caomw/orleans
        public async Task GatewaySelection_SqlServer()
        {
            string testName = Guid.NewGuid().ToString();// TestContext.TestName;

            Guid serviceId = Guid.NewGuid();

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

            var membership = new SqlMembershipTable();
            var logger = LogManager.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)
            {
                output.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());

                output.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);

                output.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);
        }
コード例 #9
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()));
        }
コード例 #10
0
 public void TestCleanup()
 {
     if (membership != null && SiloInstanceTableTestConstants.DeleteEntriesAfterTest)
     {
         membership.DeleteMembershipTableEntries(deploymentId).Wait();
         membership = null;
     }
     logger.Info("Test {0} completed - Outcome = {1}", TestContext.TestName, TestContext.CurrentTestOutcome);
 }