/// <summary> /// Async method to validate specific cluster configuration /// </summary> /// <param name="config"></param> /// <returns>Task object of boolean type for this async method </returns> public async Task <bool> ValidateConfiguration(ClusterConfiguration config) { if (config.Globals.LivenessType == GlobalConfiguration.LivenessProviderType.AzureTable) { string clusterId = config.Globals.ClusterId ?? serviceRuntimeWrapper.DeploymentId; string connectionString = config.Globals.DataConnectionString ?? serviceRuntimeWrapper.GetConfigurationSettingValue(DataConnectionConfigurationSettingName); try { var manager = siloInstanceManager ?? await OrleansSiloInstanceManager.GetManager(clusterId, connectionString, AzureStorageClusteringOptions.DEFAULT_TABLE_NAME, loggerFactory); var instances = await manager.DumpSiloInstanceTable(); logger.Debug(instances); } catch (Exception exc) { var error = String.Format("Connecting to the storage table has failed with {0}", LogFormatter.PrintException(exc)); Trace.TraceError(error); logger.Error((int)AzureSiloErrorCode.AzureTable_34, error, exc); return(false); } } return(true); }
public void TestInitialize() { deploymentId = "test-" + Guid.NewGuid(); generation = SiloAddress.AllocateNewGeneration(); siloAddress = SiloAddress.NewLocalAddress(generation); logger.Info("DeploymentId={0} Generation={1}", deploymentId, generation); logger.Info("Initializing SiloInstanceManager"); manager = OrleansSiloInstanceManager.GetManager(deploymentId, StorageTestConstants.DataConnectionString) .WaitForResultWithThrow(SiloInstanceTableTestConstants.Timeout); }
public SiloInstanceTableManagerTests(ITestOutputHelper output, Fixture fixture) { TestUtils.CheckForAzureStorage(); this.output = output; this.clusterId = "test-" + Guid.NewGuid(); generation = SiloAddress.AllocateNewGeneration(); siloAddress = SiloAddressUtils.NewLocalSiloAddress(generation); output.WriteLine("ClusterId={0} Generation={1}", this.clusterId, generation); output.WriteLine("Initializing SiloInstanceManager"); manager = OrleansSiloInstanceManager.GetManager(this.clusterId, TestDefaultConfiguration.DataConnectionString, fixture.LoggerFactory) .WaitForResultWithThrow(SiloInstanceTableTestConstants.Timeout); }
public DynamoDBSiloInstanceManagerTests(ITestOutputHelper output) { this.output = output; logger = LogManager.GetLogger("SiloInstanceTableManagerTests", LoggerType.Application); deploymentId = "test-" + Guid.NewGuid(); generation = SiloAddress.AllocateNewGeneration(); siloAddress = SiloAddress.NewLocalAddress(generation); logger.Info("DeploymentId={0} Generation={1}", deploymentId, generation); logger.Info("Initializing SiloInstanceManager"); manager = OrleansSiloInstanceManager.GetManager(deploymentId, "OrleansSiloInstances", "", "", "http://localhost:8000").Result; }
public SiloInstanceTableManagerTests(ITestOutputHelper output) { this.output = output; logger = TraceLogger.GetLogger("SiloInstanceTableManagerTests", TraceLogger.LoggerType.Application); deploymentId = "test-" + Guid.NewGuid(); generation = SiloAddress.AllocateNewGeneration(); siloAddress = SiloAddress.NewLocalAddress(generation); logger.Info("DeploymentId={0} Generation={1}", deploymentId, generation); logger.Info("Initializing SiloInstanceManager"); manager = OrleansSiloInstanceManager.GetManager(deploymentId, StorageTestConstants.DataConnectionString) .WaitForResultWithThrow(SiloInstanceTableTestConstants.Timeout); }
public static async Task <AzureBasedMembershipTable> GetMembershipTable( GlobalConfiguration config, bool tryInitTableVersion) { var table = new AzureBasedMembershipTable { tableManager = await OrleansSiloInstanceManager.GetManager( config.DeploymentId, config.DataConnectionString) }; // 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) { // ignore return value, since we don't care if I inserted it or not, as long as it is in there. await table.tableManager.TryCreateTableVersionEntryAsync().WithTimeout(AzureTableDefaultPolicies.TableOperationTimeout); } return(table); }
public async Task InitializeMembershipTable(bool tryInitTableVersion) { AzureTableDefaultPolicies.MaxBusyRetries = options.MaxStorageBusyRetries; LogFormatter.SetExceptionDecoder(typeof(StorageException), AzureStorageUtils.PrintStorageException); tableManager = await OrleansSiloInstanceManager.GetManager( this.clusterId, options.ConnectionString, this.loggerFactory); // 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) { // ignore return value, since we don't care if I inserted it or not, as long as it is in there. bool created = await tableManager.TryCreateTableVersionEntryAsync(); if (created) { logger.Info("Created new table version row."); } } }
public async Task InitializeMembershipTable(GlobalConfiguration config, bool tryInitTableVersion, TraceLogger traceLogger) { logger = traceLogger; AzureTableDefaultPolicies.MaxBusyRetries = config.MaxStorageBusyRetries; TraceLogger.SetExceptionDecoder(typeof(StorageException), AzureStorageUtils.PrintStorageException); tableManager = await OrleansSiloInstanceManager.GetManager( config.DeploymentId, config.DataConnectionString); // 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) { // ignore return value, since we don't care if I inserted it or not, as long as it is in there. bool created = await tableManager.TryCreateTableVersionEntryAsync(); if (created) { logger.Info("Created new table version row."); } } }
/// <summary> /// Initialize this Orleans silo for execution with the specified Azure clusterId /// </summary> /// <param name="config">If null, Config data will be read from silo config file as normal, otherwise use the specified config data.</param> /// <param name="clusterId">Azure ClusterId this silo is running under</param> /// <param name="connectionString">Azure DataConnectionString. If null, defaults to the DataConnectionString setting from the Azure configuration for this role.</param> /// <returns><c>true</c> if the silo startup was successful</returns> internal bool Start(ClusterConfiguration config, string clusterId, string connectionString) { if (config != null && clusterId != null) { throw new ArgumentException("Cannot use config and clusterId on the same time"); } // Program ident Trace.TraceInformation("Starting {0} v{1}", this.GetType().FullName, RuntimeVersion.Current); // Read endpoint info for this instance from Azure config string instanceName = serviceRuntimeWrapper.InstanceName; // Configure this Orleans silo instance if (config == null) { host = new SiloHost(instanceName); host.LoadOrleansConfig(); // Load config from file + Initializes logger configurations } else { host = new SiloHost(instanceName, config); // Use supplied config data + Initializes logger configurations } IPEndPoint myEndpoint = serviceRuntimeWrapper.GetIPEndpoint(SiloEndpointConfigurationKeyName); IPEndPoint proxyEndpoint = serviceRuntimeWrapper.GetIPEndpoint(ProxyEndpointConfigurationKeyName); host.SetSiloType(Silo.SiloType.Secondary); int generation = SiloAddress.AllocateNewGeneration(); // Bootstrap this Orleans silo instance // If clusterId was not direclty provided, take the value in the config. If it is not // in the config too, just take the ClusterId from Azure if (clusterId == null) { clusterId = string.IsNullOrWhiteSpace(host.Config.Globals.ClusterId) ? serviceRuntimeWrapper.DeploymentId : host.Config.Globals.ClusterId; } myEntry = new SiloInstanceTableEntry { DeploymentId = clusterId, Address = myEndpoint.Address.ToString(), Port = myEndpoint.Port.ToString(CultureInfo.InvariantCulture), Generation = generation.ToString(CultureInfo.InvariantCulture), HostName = host.Config.GetOrCreateNodeConfigurationForSilo(host.Name).DNSHostName, ProxyPort = (proxyEndpoint != null ? proxyEndpoint.Port : 0).ToString(CultureInfo.InvariantCulture), RoleName = serviceRuntimeWrapper.RoleName, SiloName = instanceName, UpdateZone = serviceRuntimeWrapper.UpdateDomain.ToString(CultureInfo.InvariantCulture), FaultZone = serviceRuntimeWrapper.FaultDomain.ToString(CultureInfo.InvariantCulture), StartTime = LogFormatter.PrintDate(DateTime.UtcNow), PartitionKey = clusterId, RowKey = myEndpoint.Address + "-" + myEndpoint.Port + "-" + generation }; if (connectionString == null) { connectionString = serviceRuntimeWrapper.GetConfigurationSettingValue(DataConnectionConfigurationSettingName); } try { siloInstanceManager = OrleansSiloInstanceManager.GetManager( clusterId, connectionString, AzureStorageClusteringOptions.DEFAULT_TABLE_NAME, this.loggerFactory).WithTimeout(AzureTableDefaultPolicies.TableCreationTimeout).Result; } catch (Exception exc) { var error = String.Format("Failed to create OrleansSiloInstanceManager. This means CreateTableIfNotExist for silo instance table has failed with {0}", LogFormatter.PrintException(exc)); Trace.TraceError(error); logger.Error((int)AzureSiloErrorCode.AzureTable_34, error, exc); throw new OrleansException(error, exc); } // Always use Azure table for membership when running silo in Azure host.SetSiloLivenessType(GlobalConfiguration.LivenessProviderType.AzureTable); if (host.Config.Globals.ReminderServiceType == GlobalConfiguration.ReminderServiceProviderType.NotSpecified || host.Config.Globals.ReminderServiceType == GlobalConfiguration.ReminderServiceProviderType.ReminderTableGrain) { host.SetReminderServiceType(GlobalConfiguration.ReminderServiceProviderType.AzureTable); } host.SetExpectedClusterSize(serviceRuntimeWrapper.RoleInstanceCount); siloInstanceManager.RegisterSiloInstance(myEntry); // Initialize this Orleans silo instance host.SetDeploymentId(clusterId, connectionString); host.SetSiloEndpoint(myEndpoint, generation); host.SetProxyEndpoint(proxyEndpoint); host.ConfigureSiloHostDelegate = ConfigureSiloHostDelegate; host.InitializeOrleansSilo(); return(StartSilo()); }
/// <summary> /// Initialize this Orleans silo for execution with the specified Azure deploymentId /// </summary> /// <param name="config">If null, Config data will be read from silo config file as normal, otherwise use the specified config data.</param> /// <param name="deploymentId">Azure DeploymentId this silo is running under</param> /// <param name="connectionString">Azure DataConnectionString. If null, defaults to the DataConnectionString setting from the Azure configuration for this role.</param> /// <returns><c>true</c> is the silo startup was successful</returns> public bool Start(ClusterConfiguration config, string deploymentId = null, string connectionString = null) { // Program ident Trace.TraceInformation("Starting {0} v{1}", this.GetType().FullName, RuntimeVersion.Current); // Check if deployment id was specified if (deploymentId == null) { deploymentId = serviceRuntimeWrapper.DeploymentId; } // Read endpoint info for this instance from Azure config string instanceName = serviceRuntimeWrapper.InstanceName; // Configure this Orleans silo instance if (config == null) { host = new SiloHost(instanceName); host.LoadOrleansConfig(); // Load config from file + Initializes logger configurations } else { host = new SiloHost(instanceName, config); // Use supplied config data + Initializes logger configurations } IPEndPoint myEndpoint = serviceRuntimeWrapper.GetIPEndpoint(SiloEndpointConfigurationKeyName); IPEndPoint proxyEndpoint = serviceRuntimeWrapper.GetIPEndpoint(ProxyEndpointConfigurationKeyName); host.SetSiloType(Silo.SiloType.Secondary); int generation = SiloAddress.AllocateNewGeneration(); // Bootstrap this Orleans silo instance myEntry = new SiloInstanceTableEntry { DeploymentId = deploymentId, Address = myEndpoint.Address.ToString(), Port = myEndpoint.Port.ToString(CultureInfo.InvariantCulture), Generation = generation.ToString(CultureInfo.InvariantCulture), HostName = host.Config.GetConfigurationForNode(host.Name).DNSHostName, ProxyPort = (proxyEndpoint != null ? proxyEndpoint.Port : 0).ToString(CultureInfo.InvariantCulture), RoleName = serviceRuntimeWrapper.RoleName, InstanceName = instanceName, UpdateZone = serviceRuntimeWrapper.UpdateDomain.ToString(CultureInfo.InvariantCulture), FaultZone = serviceRuntimeWrapper.FaultDomain.ToString(CultureInfo.InvariantCulture), StartTime = TraceLogger.PrintDate(DateTime.UtcNow), PartitionKey = deploymentId, RowKey = myEndpoint.Address + "-" + myEndpoint.Port + "-" + generation }; if (connectionString == null) { connectionString = serviceRuntimeWrapper.GetConfigurationSettingValue(DataConnectionConfigurationSettingName); } try { siloInstanceManager = OrleansSiloInstanceManager.GetManager( deploymentId, connectionString).WithTimeout(AzureTableDefaultPolicies.TableCreationTimeout).Result; } catch (Exception exc) { var error = String.Format("Failed to create OrleansSiloInstanceManager. This means CreateTableIfNotExist for silo instance table has failed with {0}", TraceLogger.PrintException(exc)); Trace.TraceError(error); logger.Error(ErrorCode.AzureTable_34, error, exc); throw new OrleansException(error, exc); } // Always use Azure table for membership when running silo in Azure host.SetSiloLivenessType(GlobalConfiguration.LivenessProviderType.AzureTable); if (host.Config.Globals.ReminderServiceType == GlobalConfiguration.ReminderServiceProviderType.NotSpecified || host.Config.Globals.ReminderServiceType == GlobalConfiguration.ReminderServiceProviderType.ReminderTableGrain) { host.SetReminderServiceType(GlobalConfiguration.ReminderServiceProviderType.AzureTable); } host.SetExpectedClusterSize(serviceRuntimeWrapper.RoleInstanceCount); siloInstanceManager.RegisterSiloInstance(myEntry); // Initialise this Orleans silo instance host.SetDeploymentId(deploymentId, connectionString); host.SetSiloEndpoint(myEndpoint, generation); host.SetProxyEndpoint(proxyEndpoint); host.InitializeOrleansSilo(); logger.Info(ErrorCode.Runtime_Error_100288, "Successfully initialized Orleans silo '{0}' as a {1} node.", host.Name, host.Type); return(StartSilo()); }