/// <summary> /// Start a new silo in the target cluster /// </summary> /// <param name="cluster">The TestCluster in which the silo should be deployed</param> /// <param name="instanceNumber">The instance number to deploy</param> /// <param name="clusterOptions">The options to use.</param> /// <param name="configurationOverrides">Configuration overrides.</param> /// <param name="startSiloOnNewPort">Whether we start this silo on a new port, instead of the default one</param> /// <returns>A handle to the silo deployed</returns> public static SiloHandle StartOrleansSilo(TestCluster cluster, int instanceNumber, TestClusterOptions clusterOptions, IReadOnlyList <IConfigurationSource> configurationOverrides = null, bool startSiloOnNewPort = false) { if (cluster == null) { throw new ArgumentNullException(nameof(cluster)); } var configurationSources = cluster.ConfigurationSources.ToList(); // Add overrides. if (configurationOverrides != null) { configurationSources.AddRange(configurationOverrides); } var siloSpecificOptions = TestSiloSpecificOptions.Create(clusterOptions, instanceNumber, startSiloOnNewPort); configurationSources.Add(new MemoryConfigurationSource { InitialData = siloSpecificOptions.ToDictionary() }); var handle = cluster.LoadSiloInNewAppDomain( siloSpecificOptions.SiloName, configurationSources); handle.InstanceNumber = (short)instanceNumber; Interlocked.Increment(ref cluster.startedInstances); return(handle); }
/// <summary> /// Creates an instance of the <see cref="TestSiloSpecificOptions"/> class. /// </summary> /// <param name="testCluster">The test cluster.</param> /// <param name="testClusterOptions">The test cluster options.</param> /// <param name="instanceNumber">The instance number.</param> /// <param name="assignNewPort">if set to <see langword="true" />, assign a new port for the silo.</param> /// <returns>The options.</returns> public static TestSiloSpecificOptions Create(TestCluster testCluster, TestClusterOptions testClusterOptions, int instanceNumber, bool assignNewPort = false) { var siloName = testClusterOptions.UseTestClusterMembership && instanceNumber == 0 ? Silo.PrimarySiloName : $"Secondary_{instanceNumber}"; if (assignNewPort) { (int siloPort, int gatewayPort) = testCluster.PortAllocator.AllocateConsecutivePortPairs(1); var result = new TestSiloSpecificOptions { SiloPort = siloPort, GatewayPort = (instanceNumber == 0 || testClusterOptions.GatewayPerSilo) ? gatewayPort : 0, SiloName = siloName, PrimarySiloPort = testClusterOptions.UseTestClusterMembership ? testClusterOptions.BaseSiloPort : 0, }; return(result); } else { var result = new TestSiloSpecificOptions { SiloPort = testClusterOptions.BaseSiloPort + instanceNumber, GatewayPort = (instanceNumber == 0 || testClusterOptions.GatewayPerSilo) ? testClusterOptions.BaseGatewayPort + instanceNumber : 0, SiloName = siloName, PrimarySiloPort = testClusterOptions.UseTestClusterMembership ? testClusterOptions.BaseSiloPort : 0, }; return(result); } }
/// <summary> /// Starts a new silo. /// </summary> /// <param name="instanceNumber">The instance number to deploy</param> /// <param name="clusterOptions">The options to use.</param> /// <param name="configurationOverrides">Configuration overrides.</param> /// <param name="startSiloOnNewPort">Whether we start this silo on a new port, instead of the default one</param> /// <returns>A handle to the deployed silo.</returns> public async Task <SiloHandle> StartSiloAsync(int instanceNumber, TestClusterOptions clusterOptions, IReadOnlyList <IConfigurationSource> configurationOverrides = null, bool startSiloOnNewPort = false) { var configurationSources = this.ConfigurationSources.ToList(); // Add overrides. if (configurationOverrides != null) { configurationSources.AddRange(configurationOverrides); } var siloSpecificOptions = TestSiloSpecificOptions.Create(this, clusterOptions, instanceNumber, startSiloOnNewPort); configurationSources.Add(new MemoryConfigurationSource { InitialData = siloSpecificOptions.ToDictionary() }); var configurationBuilder = new ConfigurationBuilder(); foreach (var source in configurationSources) { configurationBuilder.Add(source); } var configuration = configurationBuilder.Build(); var handle = await this.CreateSiloAsync(siloSpecificOptions.SiloName, configuration); handle.InstanceNumber = (short)instanceNumber; Interlocked.Increment(ref this.startedInstances); return(handle); }
public static TestSiloSpecificOptions Create(TestClusterOptions testClusterOptions, int instanceNumber, bool assignNewPort = false) { var siloName = testClusterOptions.UseTestClusterMembership && instanceNumber == 0 ? Silo.PrimarySiloName : $"Secondary_{instanceNumber}"; if (assignNewPort) { (int siloPort, int gatewayPort) = TestClusterBuilder.GetAvailableConsecutiveServerPortsPair(1); var result = new TestSiloSpecificOptions { SiloPort = siloPort, GatewayPort = gatewayPort, SiloName = siloName, PrimarySiloPort = testClusterOptions.UseTestClusterMembership ? testClusterOptions.BaseSiloPort : 0, }; return(result); } else { var result = new TestSiloSpecificOptions { SiloPort = testClusterOptions.BaseSiloPort + instanceNumber, GatewayPort = testClusterOptions.BaseGatewayPort + instanceNumber, SiloName = siloName, PrimarySiloPort = testClusterOptions.UseTestClusterMembership ? testClusterOptions.BaseSiloPort : 0, }; return(result); } }
public static TestSiloSpecificOptions Create(TestClusterOptions testClusterOptions, int instanceNumber) { var siloName = testClusterOptions.UseTestClusterMembership && instanceNumber == 0 ? Silo.PrimarySiloName : $"Secondary_{instanceNumber}"; var result = new TestSiloSpecificOptions { SiloPort = testClusterOptions.BaseSiloPort + instanceNumber, GatewayPort = testClusterOptions.BaseGatewayPort + instanceNumber, SiloName = siloName, PrimarySiloPort = testClusterOptions.UseTestClusterMembership ? testClusterOptions.BaseSiloPort : 0, }; return(result); }
/// <summary> /// Starts a new silo. /// </summary> /// <param name="instanceNumber">The instance number to deploy</param> /// <param name="clusterOptions">The options to use.</param> /// <param name="configurationOverrides">Configuration overrides.</param> /// <param name="startSiloOnNewPort">Whether we start this silo on a new port, instead of the default one</param> /// <returns>A handle to the deployed silo.</returns> public SiloHandle StartOrleansSilo(int instanceNumber, TestClusterOptions clusterOptions, IReadOnlyList <IConfigurationSource> configurationOverrides = null, bool startSiloOnNewPort = false) { var configurationSources = this.ConfigurationSources.ToList(); // Add overrides. if (configurationOverrides != null) { configurationSources.AddRange(configurationOverrides); } var siloSpecificOptions = TestSiloSpecificOptions.Create(clusterOptions, instanceNumber, startSiloOnNewPort); configurationSources.Add(new MemoryConfigurationSource { InitialData = siloSpecificOptions.ToDictionary() }); var handle = this.CreateSilo(siloSpecificOptions.SiloName, configurationSources); handle.InstanceNumber = (short)instanceNumber; Interlocked.Increment(ref this.startedInstances); return(handle); }