internal async Task <List <Tuple <SiloInstanceTableEntry, string> > > FindSiloEntryAndTableVersionRow(SiloAddress siloAddress) { string rowKey = SiloInstanceTableEntry.ConstructRowKey(siloAddress); Expression <Func <SiloInstanceTableEntry, bool> > query = instance => instance.PartitionKey == DeploymentId && (instance.RowKey == rowKey || instance.RowKey == SiloInstanceTableEntry.TABLE_VERSION_ROW); var queryResults = await storage.ReadTableEntriesAndEtagsAsync(query); var asList = queryResults.ToList(); if (asList.Count < 1 || asList.Count > 2) { throw new KeyNotFoundException(string.Format("Could not find table version row or found too many entries. Was looking for key {0}, found = {1}", siloAddress.ToLongString(), Utils.EnumerableToString(asList))); } int numTableVersionRows = asList.Count(tuple => tuple.Item1.RowKey == SiloInstanceTableEntry.TABLE_VERSION_ROW); if (numTableVersionRows < 1) { throw new KeyNotFoundException(string.Format("Did not read table version row. Read = {0}", Utils.EnumerableToString(asList))); } if (numTableVersionRows > 1) { throw new KeyNotFoundException(string.Format("Read {0} table version rows, while was expecting only 1. Read = {1}", numTableVersionRows, Utils.EnumerableToString(asList))); } return(asList); }
/// <summary> /// Insert (create new) row entry /// </summary> /// <param name="siloEntry">Silo Entry to be written</param> internal async Task <bool> InsertSiloEntryConditionally(SiloInstanceTableEntry siloEntry, SiloInstanceTableEntry tableVersionEntry, string tableVersionEtag) { try { await storage.InsertTwoTableEntriesConditionallyAsync(siloEntry, tableVersionEntry, tableVersionEtag); return(true); } catch (Exception exc) { HttpStatusCode httpStatusCode; string restStatus; if (!AzureStorageUtils.EvaluateException(exc, out httpStatusCode, out restStatus)) { throw; } if (logger.IsVerbose2) { logger.Verbose2("InsertSiloEntryConditionally failed with httpStatusCode={0}, restStatus={1}", httpStatusCode, restStatus); } if (AzureStorageUtils.IsContentionError(httpStatusCode)) { return(false); } throw; } }
public void ActivateSiloInstance(SiloInstanceTableEntry entry) { logger.Info(ErrorCode.Runtime_Error_100272, "Activating silo instance: {0}", entry.ToString()); entry.Status = INSTANCE_STATUS_ACTIVE; storage.UpsertTableEntryAsync(entry) .WaitWithThrow(AzureTableDefaultPolicies.TableOperationTimeout); }
public void UnregisterSiloInstance(SiloInstanceTableEntry entry) { entry.Status = INSTANCE_STATUS_DEAD; logger.Info(ErrorCode.Runtime_Error_100271, "Unregistering silo instance: {0}", entry.ToString()); storage.UpsertTableEntryAsync(entry) .WaitWithThrow(AzureTableDefaultPolicies.TableOperationTimeout); }
internal async Task <List <Tuple <SiloInstanceTableEntry, string> > > FindSiloEntryAndTableVersionRow(SiloAddress siloAddress) { string rowKey = SiloInstanceTableEntry.ConstructRowKey(siloAddress); string filterOnPartitionKey = TableQuery.GenerateFilterCondition(nameof(SiloInstanceTableEntry.PartitionKey), QueryComparisons.Equal, this.DeploymentId); string filterOnRowKey1 = TableQuery.GenerateFilterCondition(nameof(SiloInstanceTableEntry.RowKey), QueryComparisons.Equal, rowKey); string filterOnRowKey2 = TableQuery.GenerateFilterCondition(nameof(SiloInstanceTableEntry.RowKey), QueryComparisons.Equal, SiloInstanceTableEntry.TABLE_VERSION_ROW); string query = TableQuery.CombineFilters(filterOnPartitionKey, TableOperators.And, TableQuery.CombineFilters(filterOnRowKey1, TableOperators.Or, filterOnRowKey2)); var queryResults = await storage.ReadTableEntriesAndEtagsAsync(query); var asList = queryResults.ToList(); if (asList.Count < 1 || asList.Count > 2) { throw new KeyNotFoundException(string.Format("Could not find table version row or found too many entries. Was looking for key {0}, found = {1}", siloAddress.ToLongString(), Utils.EnumerableToString(asList))); } int numTableVersionRows = asList.Count(tuple => tuple.Item1.RowKey == SiloInstanceTableEntry.TABLE_VERSION_ROW); if (numTableVersionRows < 1) { throw new KeyNotFoundException(string.Format("Did not read table version row. Read = {0}", Utils.EnumerableToString(asList))); } if (numTableVersionRows > 1) { throw new KeyNotFoundException(string.Format("Read {0} table version rows, while was expecting only 1. Read = {1}", numTableVersionRows, Utils.EnumerableToString(asList))); } return(asList); }
/// <summary> /// Conditionally update the row for this entry, but only if the eTag matches with the current record in data store /// </summary> /// <param name="siloEntry">Silo Entry to be written</param> /// <param name="entryEtag">ETag value for the entry being updated</param> /// <param name="tableVersionEntry">Version row to update</param> /// <param name="versionEtag">ETag value for the version row</param> /// <returns></returns> internal async Task <bool> UpdateSiloEntryConditionally(SiloInstanceTableEntry siloEntry, string entryEtag, SiloInstanceTableEntry tableVersionEntry, string versionEtag) { try { await storage.UpdateTwoTableEntriesConditionallyAsync(siloEntry, entryEtag, tableVersionEntry, versionEtag); return(true); } catch (Exception exc) { HttpStatusCode httpStatusCode; string restStatus; if (!AzureTableUtils.EvaluateException(exc, out httpStatusCode, out restStatus)) { throw; } if (logger.IsEnabled(LogLevel.Trace)) { logger.Trace("UpdateSiloEntryConditionally failed with httpStatusCode={0}, restStatus={1}", httpStatusCode, restStatus); } if (AzureTableUtils.IsContentionError(httpStatusCode)) { return(false); } throw; } }
/// <summary> /// Represent a silo instance entry in the gateway URI format. /// </summary> /// <param name="gateway">The input silo instance</param> /// <returns></returns> private static Uri ToGatewayUri(SiloInstanceTableEntry gateway) { int proxyPort = 0; if (!string.IsNullOrEmpty(gateway.ProxyPort)) { int.TryParse(gateway.ProxyPort, out proxyPort); } return(new Uri(string.Format("gwy.tcp://{0}:{1}/{2}", gateway.Address, proxyPort, gateway.Generation))); }
public IPEndPoint FindPrimarySiloEndpoint() { SiloInstanceTableEntry primarySilo = FindPrimarySilo(); if (primarySilo == null) { return(null); } int port = 0; if (!string.IsNullOrEmpty(primarySilo.Port)) { int.TryParse(primarySilo.Port, out port); } return(new IPEndPoint(IPAddress.Parse(primarySilo.Address), port)); }
/// <summary> /// Represent a silo instance entry in the gateway URI format. /// </summary> /// <param name="gateway">The input silo instance</param> /// <returns></returns> private static Uri ConvertToGatewayUri(SiloInstanceTableEntry gateway) { int proxyPort = 0; if (!string.IsNullOrEmpty(gateway.ProxyPort)) { int.TryParse(gateway.ProxyPort, out proxyPort); } int gen = 0; if (!string.IsNullOrEmpty(gateway.Generation)) { int.TryParse(gateway.Generation, out gen); } SiloAddress address = SiloAddress.New(new IPEndPoint(IPAddress.Parse(gateway.Address), proxyPort), gen); return(address.ToGatewayUri()); }
/// <summary> /// Insert (create new) row entry /// </summary> internal async Task <bool> TryCreateTableVersionEntryAsync() { try { var versionRow = await storage.ReadSingleTableEntryAsync(DeploymentId, SiloInstanceTableEntry.TABLE_VERSION_ROW); if (versionRow != null && versionRow.Item1 != null) { return(false); } SiloInstanceTableEntry entry = CreateTableVersionEntry(0); await storage.CreateTableEntryAsync(entry); return(true); } catch (Exception exc) { HttpStatusCode httpStatusCode; string restStatus; if (!AzureTableUtils.EvaluateException(exc, out httpStatusCode, out restStatus)) { throw; } if (logger.IsEnabled(LogLevel.Trace)) { logger.Trace("InsertSiloEntryConditionally failed with httpStatusCode={0}, restStatus={1}", httpStatusCode, restStatus); } if (AzureTableUtils.IsContentionError(httpStatusCode)) { return(false); } throw; } }
private static SiloInstanceTableEntry Convert(MembershipEntry memEntry, string deploymentId) { var tableEntry = new SiloInstanceTableEntry { DeploymentId = deploymentId, Address = memEntry.SiloAddress.Endpoint.Address.ToString(), Port = memEntry.SiloAddress.Endpoint.Port.ToString(CultureInfo.InvariantCulture), Generation = memEntry.SiloAddress.Generation.ToString(CultureInfo.InvariantCulture), HostName = memEntry.HostName, Status = memEntry.Status.ToString(), ProxyPort = memEntry.ProxyPort.ToString(CultureInfo.InvariantCulture), RoleName = memEntry.RoleName, InstanceName = memEntry.InstanceName, UpdateZone = memEntry.UpdateZone.ToString(CultureInfo.InvariantCulture), FaultZone = memEntry.FaultZone.ToString(CultureInfo.InvariantCulture), StartTime = TraceLogger.PrintDate(memEntry.StartTime), IAmAliveTime = TraceLogger.PrintDate(memEntry.IAmAliveTime) }; if (memEntry.SuspectTimes != null) { var siloList = new StringBuilder(); var timeList = new StringBuilder(); bool first = true; foreach (var tuple in memEntry.SuspectTimes) { if (!first) { siloList.Append('|'); timeList.Append('|'); } siloList.Append(tuple.Item1.ToParsableString()); timeList.Append(TraceLogger.PrintDate(tuple.Item2)); first = false; } tableEntry.SuspectingSilos = siloList.ToString(); tableEntry.SuspectingTimes = timeList.ToString(); } else { tableEntry.SuspectingSilos = String.Empty; tableEntry.SuspectingTimes = String.Empty; } tableEntry.PartitionKey = deploymentId; tableEntry.RowKey = SiloInstanceTableEntry.ConstructRowKey(memEntry.SiloAddress); return tableEntry; }
/// <summary> /// Conditionally update the row for this entry, but only if the eTag matches with the current record in data store /// </summary> /// <param name="siloEntry">Silo Entry to be written</param> /// <param name="entryEtag">ETag value for the entry being updated</param> /// <param name="tableVersionEntry">Version row to update</param> /// <param name="versionEtag">ETag value for the version row</param> /// <returns></returns> internal async Task<bool> UpdateSiloEntryConditionally(SiloInstanceTableEntry siloEntry, string entryEtag, SiloInstanceTableEntry tableVersionEntry, string versionEtag) { try { await storage.UpdateTwoTableEntriesConditionallyAsync(siloEntry, entryEtag, tableVersionEntry, versionEtag); return true; } catch (Exception exc) { HttpStatusCode httpStatusCode; string restStatus; if (!AzureStorageUtils.EvaluateException(exc, out httpStatusCode, out restStatus)) throw; if (logger.IsVerbose2) logger.Verbose2("UpdateSiloEntryConditionally failed with httpStatusCode={0}, restStatus={1}", httpStatusCode, restStatus); if (AzureStorageUtils.IsContentionError(httpStatusCode)) return false; throw; } }
internal Task<string> MergeTableEntryAsync(SiloInstanceTableEntry data) { return storage.MergeTableEntryAsync(data, AzureStorageUtils.ANY_ETAG); // we merge this without checking eTags. }
/// <summary> /// Represent a silo instance entry in the gateway URI format. /// </summary> /// <param name="gateway">The input silo instance</param> /// <returns></returns> private static Uri ToGatewayUri(SiloInstanceTableEntry gateway) { int proxyPort = 0; if (!string.IsNullOrEmpty(gateway.ProxyPort)) int.TryParse(gateway.ProxyPort, out proxyPort); return new Uri(string.Format("gwy.tcp://{0}:{1}/{2}", gateway.Address, proxyPort, gateway.Generation)); }
/// <summary> /// Represent a silo instance entry in the gateway URI format. /// </summary> /// <param name="gateway">The input silo instance</param> /// <returns></returns> private static Uri ConvertToGatewayUri(SiloInstanceTableEntry gateway) { int.TryParse(gateway.ProxyPort, out var proxyPort); return(new IPEndPoint(IPAddress.Parse(gateway.Address), proxyPort).ToGatewayUri()); }
public Task <string> UnregisterSiloInstance(SiloInstanceTableEntry entry) { entry.Status = INSTANCE_STATUS_DEAD; logger.Info(ErrorCode.Runtime_Error_100271, "Unregistering silo instance: {0}", entry.ToString()); return(storage.UpsertTableEntryAsync(entry)); }
internal Task <string> MergeTableEntryAsync(SiloInstanceTableEntry data) { return(storage.MergeTableEntryAsync(data, AzureStorageUtils.ANY_ETAG)); }
private static MembershipEntry Parse(SiloInstanceTableEntry tableEntry) { var parse = new MembershipEntry { HostName = tableEntry.HostName, Status = (SiloStatus) Enum.Parse(typeof (SiloStatus), tableEntry.Status) }; if (!string.IsNullOrEmpty(tableEntry.ProxyPort)) parse.ProxyPort = int.Parse(tableEntry.ProxyPort); parse.IsPrimary = false; // there are no primaries with in Azure table. int port = 0; if (!string.IsNullOrEmpty(tableEntry.Port)) int.TryParse(tableEntry.Port, out port); int gen = 0; if (!string.IsNullOrEmpty(tableEntry.Generation)) int.TryParse(tableEntry.Generation, out gen); parse.SiloAddress = SiloAddress.New(new IPEndPoint(IPAddress.Parse(tableEntry.Address), port), gen); parse.RoleName = tableEntry.RoleName; parse.InstanceName = tableEntry.InstanceName; if (!string.IsNullOrEmpty(tableEntry.UpdateZone)) parse.UpdateZone = int.Parse(tableEntry.UpdateZone); if (!string.IsNullOrEmpty(tableEntry.FaultZone)) parse.FaultZone = int.Parse(tableEntry.FaultZone); parse.StartTime = !string.IsNullOrEmpty(tableEntry.StartTime) ? TraceLogger.ParseDate(tableEntry.StartTime) : default(DateTime); parse.IAmAliveTime = !string.IsNullOrEmpty(tableEntry.IAmAliveTime) ? TraceLogger.ParseDate(tableEntry.IAmAliveTime) : default(DateTime); var suspectingSilos = new List<SiloAddress>(); var suspectingTimes = new List<DateTime>(); if (!string.IsNullOrEmpty(tableEntry.SuspectingSilos)) { string[] silos = tableEntry.SuspectingSilos.Split('|'); foreach (string silo in silos) { suspectingSilos.Add(SiloAddress.FromParsableString(silo)); } } if (!string.IsNullOrEmpty(tableEntry.SuspectingTimes)) { string[] times = tableEntry.SuspectingTimes.Split('|'); foreach (string time in times) suspectingTimes.Add(TraceLogger.ParseDate(time)); } if (suspectingSilos.Count != suspectingTimes.Count) throw new OrleansException(String.Format("SuspectingSilos.Length of {0} as read from Azure table is not eqaul to SuspectingTimes.Length of {1}", suspectingSilos.Count, suspectingTimes.Count)); for (int i = 0; i < suspectingSilos.Count; i++) parse.AddSuspector(suspectingSilos[i], suspectingTimes[i]); return parse; }
private static MembershipEntry Parse(SiloInstanceTableEntry tableEntry) { var parse = new MembershipEntry { HostName = tableEntry.HostName, Status = (SiloStatus) Enum.Parse(typeof (SiloStatus), tableEntry.Status) }; if (!string.IsNullOrEmpty(tableEntry.ProxyPort)) parse.ProxyPort = int.Parse(tableEntry.ProxyPort); int port = 0; if (!string.IsNullOrEmpty(tableEntry.Port)) int.TryParse(tableEntry.Port, out port); int gen = 0; if (!string.IsNullOrEmpty(tableEntry.Generation)) int.TryParse(tableEntry.Generation, out gen); parse.SiloAddress = SiloAddress.New(new IPEndPoint(IPAddress.Parse(tableEntry.Address), port), gen); parse.RoleName = tableEntry.RoleName; if (!string.IsNullOrEmpty(tableEntry.SiloName)) { parse.SiloName = tableEntry.SiloName; }else if (!string.IsNullOrEmpty(tableEntry.InstanceName)) { // this is for backward compatability: in a mixed cluster of old and new version, // some entries will have the old InstanceName column. parse.SiloName = tableEntry.InstanceName; } if (!string.IsNullOrEmpty(tableEntry.UpdateZone)) parse.UpdateZone = int.Parse(tableEntry.UpdateZone); if (!string.IsNullOrEmpty(tableEntry.FaultZone)) parse.FaultZone = int.Parse(tableEntry.FaultZone); parse.StartTime = !string.IsNullOrEmpty(tableEntry.StartTime) ? LogFormatter.ParseDate(tableEntry.StartTime) : default(DateTime); parse.IAmAliveTime = !string.IsNullOrEmpty(tableEntry.IAmAliveTime) ? LogFormatter.ParseDate(tableEntry.IAmAliveTime) : default(DateTime); var suspectingSilos = new List<SiloAddress>(); var suspectingTimes = new List<DateTime>(); if (!string.IsNullOrEmpty(tableEntry.SuspectingSilos)) { string[] silos = tableEntry.SuspectingSilos.Split('|'); foreach (string silo in silos) { suspectingSilos.Add(SiloAddress.FromParsableString(silo)); } } if (!string.IsNullOrEmpty(tableEntry.SuspectingTimes)) { string[] times = tableEntry.SuspectingTimes.Split('|'); foreach (string time in times) suspectingTimes.Add(LogFormatter.ParseDate(time)); } if (suspectingSilos.Count != suspectingTimes.Count) throw new OrleansException(String.Format("SuspectingSilos.Length of {0} as read from Azure table is not eqaul to SuspectingTimes.Length of {1}", suspectingSilos.Count, suspectingTimes.Count)); for (int i = 0; i < suspectingSilos.Count; i++) parse.AddSuspector(suspectingSilos[i], suspectingTimes[i]); return parse; }
/// <summary> /// Represent a silo instance entry in the gateway URI format. /// </summary> /// <param name="gateway">The input silo instance</param> /// <returns></returns> private static Uri ConvertToGatewayUri(SiloInstanceTableEntry gateway) { int proxyPort = 0; if (!string.IsNullOrEmpty(gateway.ProxyPort)) int.TryParse(gateway.ProxyPort, out proxyPort); int gen = 0; if (!string.IsNullOrEmpty(gateway.Generation)) int.TryParse(gateway.Generation, out gen); SiloAddress address = SiloAddress.New(new IPEndPoint(IPAddress.Parse(gateway.Address), proxyPort), gen); return address.ToGatewayUri(); }
/// <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> /// <returns><c>true</c> is the silo startup was successful</returns> public bool Start(ClusterConfiguration config, string deploymentId = 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 }; var 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); 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(); }
internal Task <string> MergeTableEntryAsync(SiloInstanceTableEntry data) { return(storage.MergeTableEntryAsync(data, "*")); }
internal Task <string> MergeTableEntryAsync(SiloInstanceTableEntry data) { return(storage.MergeTableEntryAsync(data, AzureTableUtils.ANY_ETAG)); // we merge this without checking eTags. }
/// <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> if the silo startup was successful</returns> internal bool Start(ClusterConfiguration config, string deploymentId, string connectionString) { if (config != null && deploymentId != null) throw new ArgumentException("Cannot use config and deploymentId 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 deploymentId was not direclty provided, take the value in the config. If it is not // in the config too, just take the DeploymentId from Azure if (deploymentId == null) deploymentId = host.Config.Globals.DeploymentId ?? serviceRuntimeWrapper.DeploymentId; myEntry = new SiloInstanceTableEntry { DeploymentId = deploymentId, 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 = 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}", LogFormatter.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); // Initialize this Orleans silo instance host.SetDeploymentId(deploymentId, connectionString); host.SetSiloEndpoint(myEndpoint, generation); host.SetProxyEndpoint(proxyEndpoint); host.InitializeOrleansSilo(); return StartSilo(); }
public void RegisterSiloInstance(SiloInstanceTableEntry entry) { entry.Status = INSTANCE_STATUS_CREATED; logger.Info(ErrorCode.Runtime_Error_100270, "Registering silo instance: {0}", entry.ToString()); Task.WaitAll(new Task[] { storage.UpsertTableEntryAsync(entry) }); }
private void RegisterSiloInstance() { string partitionKey = deploymentId; string rowKey = SiloInstanceTableEntry.ConstructRowKey(siloAddress); IPEndPoint myEndpoint = siloAddress.Endpoint; myEntry = new SiloInstanceTableEntry { PartitionKey = partitionKey, RowKey = rowKey, DeploymentId = deploymentId, Address = myEndpoint.Address.ToString(), Port = myEndpoint.Port.ToString(CultureInfo.InvariantCulture), Generation = generation.ToString(CultureInfo.InvariantCulture), HostName = myEndpoint.Address.ToString(), ProxyPort = "30000", RoleName = "MyRole", InstanceName = "MyInstance", UpdateZone = "0", FaultZone = "0", StartTime = TraceLogger.PrintDate(DateTime.UtcNow), }; logger.Info("MyEntry={0}", myEntry); manager.RegisterSiloInstance(myEntry); }
public Task <string> ActivateSiloInstance(SiloInstanceTableEntry entry) { logger.Info(ErrorCode.Runtime_Error_100272, "Activating silo instance: {0}", entry.ToString()); entry.Status = INSTANCE_STATUS_ACTIVE; return(storage.UpsertTableEntryAsync(entry)); }
private void CheckSiloInstanceTableEntry(SiloInstanceTableEntry referenceEntry, SiloInstanceTableEntry entry) { Assert.AreEqual(referenceEntry.DeploymentId, entry.DeploymentId, "DeploymentId"); Assert.AreEqual(referenceEntry.Address, entry.Address, "Address"); Assert.AreEqual(referenceEntry.Port, entry.Port, "Port"); Assert.AreEqual(referenceEntry.Generation, entry.Generation, "Generation"); Assert.AreEqual(referenceEntry.HostName, entry.HostName, "HostName"); //Assert.AreEqual(referenceEntry.Status, entry.Status, "Status"); Assert.AreEqual(referenceEntry.ProxyPort, entry.ProxyPort, "ProxyPort"); Assert.AreEqual(referenceEntry.RoleName, entry.RoleName, "RoleName"); Assert.AreEqual(referenceEntry.InstanceName, entry.InstanceName, "InstanceName"); Assert.AreEqual(referenceEntry.UpdateZone, entry.UpdateZone, "UpdateZone"); Assert.AreEqual(referenceEntry.FaultZone, entry.FaultZone, "FaultZone"); Assert.AreEqual(referenceEntry.StartTime, entry.StartTime, "StartTime"); Assert.AreEqual(referenceEntry.IAmAliveTime, entry.IAmAliveTime, "IAmAliveTime"); Assert.AreEqual(referenceEntry.MembershipVersion, entry.MembershipVersion, "MembershipVersion"); Assert.AreEqual(referenceEntry.SuspectingTimes, entry.SuspectingTimes, "SuspectingTimes"); Assert.AreEqual(referenceEntry.SuspectingSilos, entry.SuspectingSilos, "SuspectingSilos"); }