internal async Task Start(StatisticsProviderManager statsManager, IMessageCenter transport, GrainId clientId) { runtimeStats.Start(); // Configure Metrics IProvider statsProvider = null; if (!string.IsNullOrEmpty(config.StatisticsProviderName)) { var extType = config.StatisticsProviderName; statsProvider = statsManager.GetProvider(extType); var metricsDataPublisher = statsProvider as IClientMetricsDataPublisher; if (metricsDataPublisher == null) { var msg = String.Format("Trying to create {0} as a metrics publisher, but the provider is not configured." , extType); throw new ArgumentException(msg, "ProviderType (configuration)"); } var configurableMetricsDataPublisher = metricsDataPublisher as IConfigurableClientMetricsDataPublisher; if (configurableMetricsDataPublisher != null) { configurableMetricsDataPublisher.AddConfiguration( config.DeploymentId, config.DNSHostName, clientId.ToString(), transport.MyAddress.Endpoint.Address); } tableStatistics = new ClientTableStatistics(transport, metricsDataPublisher, runtimeStats) { MetricsTableWriteInterval = config.StatisticsMetricsTableWriteInterval }; } else if (config.UseAzureSystemStore) { // Hook up to publish client metrics to Azure storage table var publisher = AssemblyLoader.LoadAndCreateInstance<IClientMetricsDataPublisher>(Constants.ORLEANS_AZURE_UTILS_DLL, logger); await publisher.Init(config, transport.MyAddress.Endpoint.Address, clientId.ToParsableString()); tableStatistics = new ClientTableStatistics(transport, publisher, runtimeStats) { MetricsTableWriteInterval = config.StatisticsMetricsTableWriteInterval }; } // Configure Statistics if (config.StatisticsWriteLogStatisticsToTable) { if (statsProvider != null) { logStatistics.StatsTablePublisher = statsProvider as IStatisticsPublisher; // Note: Provider has already been Init-ialized above. } else if (config.UseAzureSystemStore) { var statsDataPublisher = AssemblyLoader.LoadAndCreateInstance<IStatisticsPublisher>(Constants.ORLEANS_AZURE_UTILS_DLL, logger); await statsDataPublisher.Init(false, config.DataConnectionString, config.DeploymentId, transport.MyAddress.Endpoint.ToString(), clientId.ToParsableString(), config.DNSHostName); logStatistics.StatsTablePublisher = statsDataPublisher; } } logStatistics.Start(); }
private GrainId RoundTripGrainIdToParsable(GrainId input) { string str = input.ToParsableString(); GrainId output = GrainId.FromParsableString(str); return(output); }
public async Task <List <ActivationAddress> > Lookup(GrainId grainId) { if (grainId.IsClient) { return(await this.inClusterGrainLocator.Lookup(grainId)); } var results = new List <ActivationAddress>(); var entry = await this.grainDirectory.Lookup(grainId.ToParsableString()); if (entry == null) { return(results); } var activationAddress = ConvertToActivationAddress(entry); results.Add(activationAddress); this.cache.AddOrUpdate(grainId, new List <Tuple <SiloAddress, ActivationId> > { Tuple.Create(activationAddress.Silo, activationAddress.Activation) }, 0); return(results); }
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) { GrainId id = (GrainId)value; writer.WriteStartObject(); writer.WritePropertyName("GrainId"); writer.WriteValue(id.ToParsableString()); writer.WriteEndObject(); }
private ClientMetricsTableDataManager(ClientConfiguration config, IPAddress address, GrainId clientId) { deploymentId = config.DeploymentId; this.clientId = clientId.ToParsableString(); this.address = address; myHostName = config.DNSHostName; logger = TraceLogger.GetLogger(this.GetType().Name, TraceLogger.LoggerType.Runtime); storage = new AzureTableDataManager <ClientMetricsData>( INSTANCE_TABLE_NAME, config.DataConnectionString, logger); }
public async Task <List <ActivationAddress> > Lookup(GrainId grainId) { if (grainId.IsClient) { return(await this.inClusterGrainLocator.Lookup(grainId)); } List <ActivationAddress> results; // Check cache first if (TryLocalLookup(grainId, out results)) { return(results); } results = new List <ActivationAddress>(); var entry = await this.grainDirectory.Lookup(grainId.ToParsableString()); // Nothing found if (entry == null) { return(results); } var activationAddress = entry.ToActivationAddress(); // Check if the entry is pointing to a dead silo if (this.knownDeadSilos.Contains(activationAddress.Silo)) { // Remove it from the directory await this.grainDirectory.Unregister(entry); } else { // Add to the local cache and return it results.Add(activationAddress); this.cache.AddOrUpdate(grainId, new List <Tuple <SiloAddress, ActivationId> > { Tuple.Create(activationAddress.Silo, activationAddress.Activation) }, 0); } return(results); }
private GrainId RoundTripGrainIdToParsable(GrainId input) { string str = input.ToParsableString(); GrainId output = GrainId.FromParsableString(str); return output; }