internal void ConsumeServices(IServiceProvider services) { try { AppDomain.CurrentDomain.DomainUnload += CurrentDomain_DomainUnload; this.ServiceProvider = services; var connectionLostHandlers = this.ServiceProvider.GetServices <ConnectionToClusterLostHandler>(); foreach (var handler in connectionLostHandlers) { this.ClusterConnectionLost += handler; } var gatewayCountChangedHandlers = this.ServiceProvider.GetServices <GatewayCountChangedHandler>(); foreach (var handler in gatewayCountChangedHandlers) { this.GatewayCountChanged += handler; } var clientInvokeCallbacks = this.ServiceProvider.GetServices <ClientInvokeCallback>(); foreach (var handler in clientInvokeCallbacks) { this.ClientInvokeCallback += handler; } this.InternalGrainFactory = this.ServiceProvider.GetRequiredService <IInternalGrainFactory>(); this.ClientStatistics = this.ServiceProvider.GetRequiredService <ClientStatisticsManager>(); this.messageFactory = this.ServiceProvider.GetService <MessageFactory>(); var serializationManager = this.ServiceProvider.GetRequiredService <SerializationManager>(); this.localObjects = new InvokableObjectManager( this, serializationManager, this.loggerFactory.CreateLogger <InvokableObjectManager>()); var timerLogger = this.loggerFactory.CreateLogger <SafeTimer>(); var minTicks = Math.Min(this.clientMessagingOptions.ResponseTimeout.Ticks, TimeSpan.FromSeconds(1).Ticks); var period = TimeSpan.FromTicks(minTicks); this.callbackTimer = new SafeTimer(timerLogger, this.OnCallbackExpiryTick, null, period, period); this.GrainReferenceRuntime = this.ServiceProvider.GetRequiredService <IGrainReferenceRuntime>(); BufferPool.InitGlobalBufferPool(this.clientMessagingOptions); this.clientProviderRuntime = this.ServiceProvider.GetRequiredService <ClientProviderRuntime>(); this.localAddress = this.clientMessagingOptions.LocalAddress ?? ConfigUtilities.GetLocalIPAddress(this.clientMessagingOptions.PreferredFamily, this.clientMessagingOptions.NetworkInterfaceName); // Client init / sign-on message logger.Info(ErrorCode.ClientInitializing, string.Format( "{0} Initializing OutsideRuntimeClient on {1} at {2} Client Id = {3} {0}", BARS, Dns.GetHostName(), localAddress, handshakeClientId)); string startMsg = string.Format("{0} Starting OutsideRuntimeClient with runtime Version='{1}' in AppDomain={2}", BARS, RuntimeVersion.Current, PrintAppDomainDetails()); logger.Info(ErrorCode.ClientStarting, startMsg); if (TestOnlyThrowExceptionDuringInit) { throw new InvalidOperationException("TestOnlyThrowExceptionDuringInit"); } this.gatewayListProvider = this.ServiceProvider.GetRequiredService <IGatewayListProvider>(); var statisticsLevel = statisticsOptions.Value.CollectionLevel; if (statisticsLevel.CollectThreadTimeTrackingStats()) { incomingMessagesThreadTimeTracking = new ThreadTrackingStatistic("ClientReceiver", this.loggerFactory, this.statisticsOptions, this.schedulerStageStatistics); } } catch (Exception exc) { if (logger != null) { logger.Error(ErrorCode.Runtime_Error_100319, "OutsideRuntimeClient constructor failed.", exc); } ConstructorReset(); throw; } }
/// <summary> Initialization function for this storage provider. </summary> /// <see cref="IProvider.Init"/> public Task Init(string name, IProviderRuntime providerRuntime, IProviderConfiguration config) { Name = name; serviceId = providerRuntime.ServiceId.ToString(); if (!config.Properties.ContainsKey(DATA_CONNECTION_STRING) || string.IsNullOrWhiteSpace(config.Properties[DATA_CONNECTION_STRING])) { throw new ArgumentException("DataConnectionString property not set"); } dataConnectionString = config.Properties["DataConnectionString"]; if (config.Properties.ContainsKey(TABLE_NAME_PROPERTY)) { tableName = config.Properties[TABLE_NAME_PROPERTY]; } isDeleteStateOnClear = config.Properties.ContainsKey(DELETE_ON_CLEAR_PROPERTY) && "true".Equals(config.Properties[DELETE_ON_CLEAR_PROPERTY], StringComparison.OrdinalIgnoreCase); Log = providerRuntime.GetLogger("Storage.AzureTableStorage." + id); var initMsg = string.Format("Init: Name={0} ServiceId={1} Table={2} DeleteStateOnClear={3}", Name, serviceId, tableName, isDeleteStateOnClear); if (config.Properties.ContainsKey(USE_JSON_FORMAT_PROPERTY)) { useJsonFormat = "true".Equals(config.Properties[USE_JSON_FORMAT_PROPERTY], StringComparison.OrdinalIgnoreCase); } if (useJsonFormat) { jsonSettings = jsonSettings = OrleansJsonSerializer.SerializerSettings; } initMsg = String.Format("{0} UseJsonFormat={1}", initMsg, useJsonFormat); Log.Info((int)AzureProviderErrorCode.AzureTableProvider_InitProvider, initMsg); Log.Info((int)AzureProviderErrorCode.AzureTableProvider_ParamConnectionString, "AzureTableStorage Provider is using DataConnectionString: {0}", ConfigUtilities.PrintDataConnectionInfo(dataConnectionString)); tableDataManager = new GrainStateTableDataManager(tableName, dataConnectionString, Log); return(tableDataManager.InitTableAsync()); }
private async Task Init(CancellationToken ct) { var stopWatch = Stopwatch.StartNew(); try { this.logger.LogInformation((int)AzureProviderErrorCode.AzureTableProvider_InitProvider, $"AzureTableGrainStorage {name} initializing: {this.options.ToString()}"); this.logger.LogInformation((int)AzureProviderErrorCode.AzureTableProvider_ParamConnectionString, $"AzureTableGrainStorage {name} is using DataConnectionString: {ConfigUtilities.RedactConnectionStringInfo(this.options.ConnectionString)}"); this.JsonSettings = OrleansJsonSerializer.UpdateSerializerSettings(OrleansJsonSerializer.GetDefaultSerializerSettings(this.typeResolver, this.grainFactory), this.options.UseFullAssemblyNames, this.options.IndentJson, this.options.TypeNameHandling); this.options.ConfigureJsonSerializerSettings?.Invoke(this.JsonSettings); this.tableDataManager = new GrainStateTableDataManager(this.options.TableName, this.options.ConnectionString, this.loggerFactory); await this.tableDataManager.InitTableAsync(); stopWatch.Stop(); this.logger.LogInformation((int)AzureProviderErrorCode.AzureTableProvider_InitProvider, $"Initializing provider {this.name} of type {this.GetType().Name} in stage {this.options.InitStage} took {stopWatch.ElapsedMilliseconds} Milliseconds."); } catch (Exception ex) { stopWatch.Stop(); this.logger.LogError((int)ErrorCode.Provider_ErrorFromInit, $"Initialization failed for provider {this.name} of type {this.GetType().Name} in stage {this.options.InitStage} in {stopWatch.ElapsedMilliseconds} Milliseconds.", ex); throw; } }
/// <summary> /// Initialize this silo. /// </summary> public void InitializeOrleansSilo() { #if DEBUG AssemblyLoaderUtils.EnableAssemblyLoadTracing(); #endif try { if (!ConfigLoaded) { LoadOrleansConfig(); } logger.Info(ErrorCode.SiloInitializing, "Initializing Silo {0} on host={1} CPU count={2} running .NET version='{3}' Is .NET 4.5={4} OS version='{5}'", Name, Environment.MachineName, Environment.ProcessorCount, Environment.Version, ConfigUtilities.IsNet45OrNewer(), Environment.OSVersion); logger.Info(ErrorCode.SiloGcSetting, "Silo running with GC settings: ServerGC={0} GCLatencyMode={1}", GCSettings.IsServerGC, Enum.GetName(typeof(GCLatencyMode), GCSettings.LatencyMode)); if (!GCSettings.IsServerGC) { logger.Warn(ErrorCode.SiloGcWarning, "Note: Silo not running with ServerGC turned on - recommend checking app config : <configuration>-<runtime>-<gcServer enabled=\"true\"> and <configuration>-<runtime>-<gcConcurrent enabled=\"false\"/>"); } orleans = new Silo(Name, Type, Config); } catch (Exception exc) { ReportStartupError(exc); orleans = null; } }
internal void ConsumeServices(IServiceProvider services) { this.ServiceProvider = services; var connectionLostHandlers = this.ServiceProvider.GetServices <ConnectionToClusterLostHandler>(); foreach (var handler in connectionLostHandlers) { this.ClusterConnectionLost += handler; } var clientInvokeCallbacks = this.ServiceProvider.GetServices <ClientInvokeCallback>(); foreach (var handler in clientInvokeCallbacks) { this.ClientInvokeCallback += handler; } this.InternalGrainFactory = this.ServiceProvider.GetRequiredService <IInternalGrainFactory>(); this.ClientStatistics = this.ServiceProvider.GetRequiredService <ClientStatisticsManager>(); this.serializationManager = this.ServiceProvider.GetRequiredService <SerializationManager>(); this.messageFactory = this.ServiceProvider.GetService <MessageFactory>(); this.GrainReferenceRuntime = this.ServiceProvider.GetRequiredService <IGrainReferenceRuntime>(); var statisticsOptions = this.ServiceProvider.GetRequiredService <IOptions <ClientStatisticsOptions> >().Value; StatisticsCollector.Initialize(statisticsOptions.CollectionLevel); BufferPool.InitGlobalBufferPool(this.clientMessagingOptions); try { AppDomain.CurrentDomain.DomainUnload += CurrentDomain_DomainUnload; clientProviderRuntime = this.ServiceProvider.GetRequiredService <ClientProviderRuntime>(); responseTimeout = Debugger.IsAttached ? Constants.DEFAULT_RESPONSE_TIMEOUT : this.clientMessagingOptions.ResponseTimeout; this.localAddress = ConfigUtilities.GetLocalIPAddress(this.clientMessagingOptions.PreferredFamily, this.clientMessagingOptions.NetworkInterfaceName); // Client init / sign-on message logger.Info(ErrorCode.ClientInitializing, string.Format( "{0} Initializing OutsideRuntimeClient on {1} at {2} Client Id = {3} {0}", BARS, Dns.GetHostName(), localAddress, handshakeClientId)); string startMsg = string.Format("{0} Starting OutsideRuntimeClient with runtime Version='{1}' in AppDomain={2}", BARS, RuntimeVersion.Current, PrintAppDomainDetails()); logger.Info(ErrorCode.ClientStarting, startMsg); if (TestOnlyThrowExceptionDuringInit) { throw new InvalidOperationException("TestOnlyThrowExceptionDuringInit"); } this.gatewayListProvider = this.ServiceProvider.GetRequiredService <IGatewayListProvider>(); if (StatisticsCollector.CollectThreadTimeTrackingStats) { incomingMessagesThreadTimeTracking = new ThreadTrackingStatistic("ClientReceiver", this.loggerFactory); } } catch (Exception exc) { if (logger != null) { logger.Error(ErrorCode.Runtime_Error_100319, "OutsideRuntimeClient constructor failed.", exc); } ConstructorReset(); throw; } }
public async Task Init(string name, IProviderRuntime providerUtilitiesManager, IProviderConfiguration config) { if (String.IsNullOrEmpty(name)) { throw new ArgumentNullException("name"); } if (providerUtilitiesManager == null) { throw new ArgumentNullException("providerUtilitiesManager"); } if (config == null) { throw new ArgumentNullException("config"); } Name = name; providerRuntime = (IStreamProviderRuntime)providerUtilitiesManager; logger = providerRuntime.GetLogger(this.GetType().Name); adapterFactory = new TAdapterFactory(); adapterFactory.Init(config, Name, logger); queueAdapter = await adapterFactory.CreateAdapter(); string timePeriod; if (!config.Properties.TryGetValue(GET_QUEUE_MESSAGES_TIMER_PERIOD, out timePeriod)) { getQueueMsgsTimerPeriod = DEFAULT_GET_QUEUE_MESSAGES_TIMER_PERIOD; } else { getQueueMsgsTimerPeriod = ConfigUtilities.ParseTimeSpan(timePeriod, "Invalid time value for the " + GET_QUEUE_MESSAGES_TIMER_PERIOD + " property in the provider config values."); } string timeout; if (!config.Properties.TryGetValue(INIT_QUEUE_TIMEOUT, out timeout)) { initQueueTimeout = DEFAULT_INIT_QUEUE_TIMEOUT; } else { initQueueTimeout = ConfigUtilities.ParseTimeSpan(timeout, "Invalid time value for the " + INIT_QUEUE_TIMEOUT + " property in the provider config values."); } string balanceTypeString; balancerType = !config.Properties.TryGetValue(QUEUE_BALANCER_TYPE, out balanceTypeString) ? DEFAULT_STREAM_QUEUE_BALANCER_TYPE : (StreamQueueBalancerType)Enum.Parse(typeof(StreamQueueBalancerType), balanceTypeString); if (!config.Properties.TryGetValue(MAX_EVENT_DELIVERY_TIME, out timeout)) { maxEventDeliveryTime = DEFAULT_MAX_EVENT_DELIVERY_TIME; } else { maxEventDeliveryTime = ConfigUtilities.ParseTimeSpan(timeout, "Invalid time value for the " + MAX_EVENT_DELIVERY_TIME + " property in the provider config values."); } string pubSubTypeString; pubSubType = !config.Properties.TryGetValue(STREAM_PUBSUB_TYPE, out pubSubTypeString) ? DEFAULT_STREAM_PUBSUB_TYPE : (StreamPubSubType)Enum.Parse(typeof(StreamPubSubType), pubSubTypeString); string startup; if (config.Properties.TryGetValue(STARTUP_STATE, out startup)) { if (!Enum.TryParse(startup, true, out startupState)) { throw new ArgumentException( String.Format("Unsupported value '{0}' for configuration parameter {1} of stream provider {2}.", startup, STARTUP_STATE, config.Name)); } } else { startupState = StreamProviderStartupState.Started; } logger.Info("Initialized PersistentStreamProvider<{0}> with name {1}, {2} = {3}, {4} = {5}, {6} = {7} and with Adapter {8}.", typeof(TAdapterFactory).Name, Name, GET_QUEUE_MESSAGES_TIMER_PERIOD, getQueueMsgsTimerPeriod, INIT_QUEUE_TIMEOUT, initQueueTimeout, STARTUP_STATE, startupState, queueAdapter.Name); }
/// <summary> /// Returns the BIM360 Inventor Template folder /// </summary> /// <returns></returns> public static string GetInventorTemplateFolder() { return(Utility.GetProjectFolder() + ConfigUtilities.GetInventorTemplateFolder() + "\\"); }
/// <summary> Initialization function for this storage provider. </summary> private async Task Init(CancellationToken cancellationToken) { this.serializer = providerRuntime.ServiceProvider.GetRequiredService <Serializer>(); //NOTE: StorageSerializationPicker should be defined outside and given as a parameter in constructor or via Init in IProviderConfiguration perhaps. //Currently this limits one's options to much to the current situation of providing only one serializer for serialization and deserialization //with no regard to state update or serializer changes. Maybe have this serialized as a JSON in props and read via a key? StorageSerializationPicker = new DefaultRelationalStoragePicker(this.ConfigureDeserializers(options, providerRuntime), this.ConfigureSerializers(options, providerRuntime)); Storage = RelationalStorage.CreateInstance(options.Invariant, options.ConnectionString); var queries = await Storage.ReadAsync(DefaultInitializationQuery, command => { }, (selector, resultSetCount, token) => { return(Task.FromResult(Tuple.Create(selector.GetValue <string>("QueryKey"), selector.GetValue <string>("QueryText")))); }).ConfigureAwait(false); CurrentOperationalQueries = new RelationalStorageProviderQueries( queries.Single(i => i.Item1 == "WriteToStorageKey").Item2, queries.Single(i => i.Item1 == "ReadFromStorageKey").Item2, queries.Single(i => i.Item1 == "ClearStorageKey").Item2); logger.Info( (int)RelationalStorageProviderCodes.RelationalProviderInitProvider, $"Initialized storage provider: ServiceId={serviceId} ProviderName={this.name} Invariant={Storage.InvariantName} ConnectionString={ConfigUtilities.RedactConnectionStringInfo(Storage.ConnectionString)}."); }
/// <summary> Initialization function for this storage provider. </summary> /// <see cref="IProvider.Init"/> public Task Init(string name, IProviderRuntime providerRuntime, IProviderConfiguration config) { Name = name; serviceId = providerRuntime.ServiceId.ToString(); if (!config.Properties.ContainsKey(DataConnectionStringPropertyName) || string.IsNullOrWhiteSpace(config.Properties[DataConnectionStringPropertyName])) { throw new ArgumentException("DataConnectionString property not set"); } dataConnectionString = config.Properties["DataConnectionString"]; if (config.Properties.ContainsKey(TableNamePropertyName)) { tableName = config.Properties[TableNamePropertyName]; } isDeleteStateOnClear = config.Properties.ContainsKey(DeleteOnClearPropertyName) && "true".Equals(config.Properties[DeleteOnClearPropertyName], StringComparison.OrdinalIgnoreCase); Log = providerRuntime.GetLogger("Storage.AzureTableStorage." + id); var initMsg = string.Format("Init: Name={0} ServiceId={1} Table={2} DeleteStateOnClear={3}", Name, serviceId, tableName, isDeleteStateOnClear); if (config.Properties.ContainsKey(UseJsonFormatPropertyName)) { useJsonFormat = "true".Equals(config.Properties[UseJsonFormatPropertyName], StringComparison.OrdinalIgnoreCase); } this.jsonSettings = OrleansJsonSerializer.UpdateSerializerSettings(OrleansJsonSerializer.GetDefaultSerializerSettings(), config); initMsg = String.Format("{0} UseJsonFormat={1}", initMsg, useJsonFormat); Log.Info((int)AzureProviderErrorCode.AzureTableProvider_InitProvider, initMsg); Log.Info((int)AzureProviderErrorCode.AzureTableProvider_ParamConnectionString, "AzureTableStorage Provider is using DataConnectionString: {0}", ConfigUtilities.PrintDataConnectionInfo(dataConnectionString)); tableDataManager = new GrainStateTableDataManager(tableName, dataConnectionString, Log); return(tableDataManager.InitTableAsync()); }
/// <summary> /// Redacts the provided value. /// </summary> /// <param name="value">The value.</param> /// <returns>The redacted value.</returns> public override string Redact(object value) { return(ConfigUtilities.RedactConnectionStringInfo(value as string)); }
public async Task Init(string name, IProviderRuntime providerUtilitiesManager, IProviderConfiguration config) { if (String.IsNullOrEmpty(name)) { throw new ArgumentNullException("name"); } if (providerUtilitiesManager == null) { throw new ArgumentNullException("providerUtilitiesManager"); } if (config == null) { throw new ArgumentNullException("config"); } Name = name; providerRuntime = (IStreamProviderRuntime)providerUtilitiesManager; logger = providerRuntime.GetLogger(this.GetType().Name); IQueueAdapterFactory factory = new TAdapterFactory(); factory.Init(config, Name, logger); queueAdapter = await factory.CreateAdapter(); string nAgents; numPullingAgents = !config.Properties.TryGetValue(NUM_PULLING_AGENTS, out nAgents) ? DEFAULT_NUM_PULLING_AGENTS : Int32.Parse(nAgents); string timePeriod; if (!config.Properties.TryGetValue(GET_QUEUE_MESSAGES_TIMER_PERIOD, out timePeriod)) { getQueueMsgsTimerPeriod = DEFAULT_GET_QUEUE_MESSAGES_TIMER_PERIOD; } else { getQueueMsgsTimerPeriod = ConfigUtilities.ParseTimeSpan(timePeriod, "Invalid time value for the " + GET_QUEUE_MESSAGES_TIMER_PERIOD + " property in the provider config values."); } string timeout; if (!config.Properties.TryGetValue(INIT_QUEUE_TIMEOUT, out timeout)) { initQueueTimeout = DEFAULT_INIT_QUEUE_TIMEOUT; } else { initQueueTimeout = ConfigUtilities.ParseTimeSpan(timeout, "Invalid time value for the " + INIT_QUEUE_TIMEOUT + " property in the provider config values."); } string balanceTypeString; balancerType = !config.Properties.TryGetValue(QUEUE_BALANCER_TYPE, out balanceTypeString) ? StreamQueueBalancerType.ConsistenRingBalancer : (StreamQueueBalancerType)Enum.Parse(typeof(StreamQueueBalancerType), balanceTypeString); logger.Info("Initialized PersistentStreamProvider<{0}> with name {1}, {2} = {3}, {4} = {5}, {6} = {7} and with Adapter {8}.", typeof(TAdapterFactory).Name, Name, NUM_PULLING_AGENTS, this.numPullingAgents, GET_QUEUE_MESSAGES_TIMER_PERIOD, getQueueMsgsTimerPeriod, INIT_QUEUE_TIMEOUT, this.initQueueTimeout, queueAdapter.Name); }
/// <summary> Initialization function for this storage provider. </summary> /// <see cref="IProvider.Init"/> public Task Init(string name, IProviderRuntime providerRuntime, IProviderConfiguration config) { Name = name; serviceId = providerRuntime.ServiceId.ToString(); this.serializationManager = providerRuntime.ServiceProvider.GetRequiredService <SerializationManager>(); if (!config.Properties.ContainsKey(DataConnectionStringPropertyName) || string.IsNullOrWhiteSpace(config.Properties[DataConnectionStringPropertyName])) { throw new ArgumentException("DataConnectionString property not set"); } dataConnectionString = config.Properties["DataConnectionString"]; if (config.Properties.ContainsKey(TableNamePropertyName)) { tableName = config.Properties[TableNamePropertyName]; } isDeleteStateOnClear = config.Properties.ContainsKey(DeleteOnClearPropertyName) && "true".Equals(config.Properties[DeleteOnClearPropertyName], StringComparison.OrdinalIgnoreCase); var loggerFactory = providerRuntime.ServiceProvider.GetRequiredService <ILoggerFactory>(); var loggerName = $"{this.GetType().FullName}.{Name}"; logger = loggerFactory.CreateLogger(loggerName); Log = new LoggerWrapper(logger, loggerName, loggerFactory); var initMsg = string.Format("Init: Name={0} ServiceId={1} Table={2} DeleteStateOnClear={3}", Name, serviceId, tableName, isDeleteStateOnClear); if (config.Properties.ContainsKey(UseJsonFormatPropertyName)) { useJsonFormat = "true".Equals(config.Properties[UseJsonFormatPropertyName], StringComparison.OrdinalIgnoreCase); } var grainFactory = providerRuntime.ServiceProvider.GetRequiredService <IGrainFactory>(); this.jsonSettings = OrleansJsonSerializer.UpdateSerializerSettings(OrleansJsonSerializer.GetDefaultSerializerSettings(this.serializationManager, grainFactory), config); initMsg = String.Format("{0} UseJsonFormat={1}", initMsg, useJsonFormat); this.logger.Info((int)AzureProviderErrorCode.AzureTableProvider_InitProvider, initMsg); logger.Info((int)AzureProviderErrorCode.AzureTableProvider_ParamConnectionString, "AzureTableStorage Provider is using DataConnectionString: {0}", ConfigUtilities.RedactConnectionStringInfo(dataConnectionString)); tableDataManager = new GrainStateTableDataManager(tableName, dataConnectionString, loggerFactory); return(tableDataManager.InitTableAsync()); }
public PersistentStreamProviderConfig(IProviderConfiguration config) { string timePeriod; if (!config.Properties.TryGetValue(GET_QUEUE_MESSAGES_TIMER_PERIOD, out timePeriod)) { GetQueueMsgsTimerPeriod = DEFAULT_GET_QUEUE_MESSAGES_TIMER_PERIOD; } else { GetQueueMsgsTimerPeriod = ConfigUtilities.ParseTimeSpan(timePeriod, "Invalid time value for the " + GET_QUEUE_MESSAGES_TIMER_PERIOD + " property in the provider config values."); } string timeout; if (!config.Properties.TryGetValue(INIT_QUEUE_TIMEOUT, out timeout)) { InitQueueTimeout = DEFAULT_INIT_QUEUE_TIMEOUT; } else { InitQueueTimeout = ConfigUtilities.ParseTimeSpan(timeout, "Invalid time value for the " + INIT_QUEUE_TIMEOUT + " property in the provider config values."); } string balanceTypeString; BalancerType = !config.Properties.TryGetValue(QUEUE_BALANCER_TYPE, out balanceTypeString) ? DEFAULT_STREAM_QUEUE_BALANCER_TYPE : (StreamQueueBalancerType)Enum.Parse(typeof(StreamQueueBalancerType), balanceTypeString); if (!config.Properties.TryGetValue(MAX_EVENT_DELIVERY_TIME, out timeout)) { MaxEventDeliveryTime = DEFAULT_MAX_EVENT_DELIVERY_TIME; } else { MaxEventDeliveryTime = ConfigUtilities.ParseTimeSpan(timeout, "Invalid time value for the " + MAX_EVENT_DELIVERY_TIME + " property in the provider config values."); } if (!config.Properties.TryGetValue(STREAM_INACTIVITY_PERIOD, out timeout)) { StreamInactivityPeriod = DEFAULT_STREAM_INACTIVITY_PERIOD; } else { StreamInactivityPeriod = ConfigUtilities.ParseTimeSpan(timeout, "Invalid time value for the " + STREAM_INACTIVITY_PERIOD + " property in the provider config values."); } string pubSubTypeString; PubSubType = !config.Properties.TryGetValue(STREAM_PUBSUB_TYPE, out pubSubTypeString) ? DEFAULT_STREAM_PUBSUB_TYPE : (StreamPubSubType)Enum.Parse(typeof(StreamPubSubType), pubSubTypeString); string immaturityPeriod; if (!config.Properties.TryGetValue(SILO_MATURITY_PERIOD, out immaturityPeriod)) { SiloMaturityPeriod = DEFAULT_SILO_MATURITY_PERIOD; } else { SiloMaturityPeriod = ConfigUtilities.ParseTimeSpan(immaturityPeriod, "Invalid time value for the " + SILO_MATURITY_PERIOD + " property in the provider config values."); } }
private async Task Init(CancellationToken ct) { this.logger.LogInformation((int)AzureProviderErrorCode.AzureTableProvider_InitProvider, $"AzureTableGrainStorage initializing: {this.options.ToString()}"); this.logger.LogInformation((int)AzureProviderErrorCode.AzureTableProvider_ParamConnectionString, "AzureTableGrainStorage is using DataConnectionString: {0}", ConfigUtilities.RedactConnectionStringInfo(this.options.DataConnectionString)); this.JsonSettings = OrleansJsonSerializer.UpdateSerializerSettings(OrleansJsonSerializer.GetDefaultSerializerSettings(this.typeResolver, this.grainFactory), this.options.UseFullAssemblyNames, this.options.IndentJson, this.options.TypeNameHandling); this.tableDataManager = new GrainStateTableDataManager(this.options.TableName, this.options.DataConnectionString, this.loggerFactory); await this.tableDataManager.InitTableAsync(); }
// Load template file and extract related parameters public List <InventorParameterStructure> LoadInventorTemplateParameters(string fullPath) { NLogger.LogText("Entered LoadInventorTemplateParameters method"); var inventorParams = new List <InventorParameterStructure>(); Parameters InventorParams = null; // TODO: HANDLE THE HARDCODED PATH //var rootPath = Utilities.GetBIM360RootPath(); //var fullPath = rootPath + @"ATDSK DEV\Sample Project\Project Files\Libraries\" + templateName; try { NLogger.LogText($"Try opening assembly document {fullPath}"); try { NLogger.LogText($"Try opening assembly document {fullPath} with LOD specified"); NameValueMap oOptions = m_InventorApplication.TransientObjects.CreateNameValueMap(); oOptions.Add("LevelOfDetailRepresentation", "LOD1"); m_AssemblyDocument = (AssemblyDocument)m_InventorApplication.Documents.OpenWithOptions(fullPath, oOptions, false); NLogger.LogText($"Opening assembly document {fullPath} with LOD specified suceeded"); } catch { NLogger.LogText($"Failed opening assembly document {fullPath} with LOD specified. Try to open it without LOD specified"); m_AssemblyDocument = (AssemblyDocument)m_InventorApplication.Documents.Open(fullPath, false); NLogger.LogText($"Opening assembly document {fullPath} without LOD specified suceeded"); } // Load params NLogger.LogText("Load assembly document parameters"); InventorParams = m_AssemblyDocument.ComponentDefinition.Parameters; } catch (Exception ex) { NLogger.LogText("An error has occurred casting to an Inventor Assembly document. Try casting to a Part document"); try { NLogger.LogText($"Try opening part document {fullPath}"); m_PartDocument = (PartDocument)m_InventorApplication.Documents.Open(fullPath, false); NLogger.LogText($"Opening part document {fullPath} suceeded"); // Load params NLogger.LogText("Load Part document parameters"); InventorParams = m_PartDocument.ComponentDefinition.Parameters; } catch (Exception ex1) { NLogger.LogText("An error has occurred casting to an Inventor Part document"); NLogger.LogError(ex1); throw (ex1); } } NLogger.LogText("Create 'InventorParameterStructure'"); for (int h = 1; h <= InventorParams.Count; h++) { if (ConfigUtilities.GetInventorElementShowOnlyKeys().ToLower() == "true") { if (InventorParams[h].IsKey) { inventorParams.Add(new InventorParameterStructure { Name = InventorParams[h].Name.ToString() }); } } else { inventorParams.Add(new InventorParameterStructure { Name = InventorParams[h].Name.ToString() }); } } NLogger.LogText("Remove documents from Inventor application instance"); m_InventorApplication.Documents.CloseAll(); NLogger.LogText("Exit LoadInventorTemplateParameters method"); return(inventorParams); }
/// <summary> Initialization function for this storage provider. </summary> private async Task Init(CancellationToken ct) { var stopWatch = Stopwatch.StartNew(); try { this.logger.LogInformation((int)AzureProviderErrorCode.AzureTableProvider_InitProvider, $"AzureTableGrainStorage initializing: {this.options.ToString()}"); this.logger.LogInformation((int)AzureProviderErrorCode.AzureTableProvider_ParamConnectionString, "AzureTableGrainStorage is using DataConnectionString: {0}", ConfigUtilities.RedactConnectionStringInfo(this.options.ConnectionString)); this.jsonSettings = OrleansJsonSerializer.UpdateSerializerSettings(OrleansJsonSerializer.GetDefaultSerializerSettings(this.typeResolver, this.grainFactory), this.options.UseFullAssemblyNames, this.options.IndentJson, this.options.TypeNameHandling); this.options.ConfigureJsonSerializerSettings?.Invoke(this.jsonSettings); var account = CloudStorageAccount.Parse(this.options.ConnectionString); var blobClient = account.CreateCloudBlobClient(); container = blobClient.GetContainerReference(this.options.ContainerName); await container.CreateIfNotExistsAsync().ConfigureAwait(false); stopWatch.Stop(); this.logger.LogInformation((int)AzureProviderErrorCode.AzureBlobProvider_InitProvider, $"Initializing provider {this.name} of type {this.GetType().Name} in stage {this.options.InitStage} took {stopWatch.ElapsedMilliseconds} Milliseconds."); } catch (Exception ex) { stopWatch.Stop(); this.logger.LogError((int)ErrorCode.Provider_ErrorFromInit, $"Initialization failed for provider {this.name} of type {this.GetType().Name} in stage {this.options.InitStage} in {stopWatch.ElapsedMilliseconds} Milliseconds.", ex); throw; } }
public async Task Init(string name, IProviderRuntime providerRuntime, IProviderConfiguration config) { Log = providerRuntime.GetLogger("Storage.AzureBlobStorage"); try { this.Name = name; this.jsonSettings = new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.Auto, TypeNameAssemblyFormat = FormatterAssemblyStyle.Simple, Formatting = Formatting.None }; jsonSettings.ContractResolver = new PrivateContractResolver(); if (!config.Properties.ContainsKey("DataConnectionString")) { throw new BadProviderConfigException("The DataConnectionString setting has not been configured in the cloud role. Please add a DataConnectionString setting with a valid Azure Storage connection string."); } var account = CloudStorageAccount.Parse(config.Properties["DataConnectionString"]); var blobClient = account.CreateCloudBlobClient(); var containerName = config.Properties.ContainsKey("ContainerName") ? config.Properties["ContainerName"] : "grainstate"; container = blobClient.GetContainerReference(containerName); await container.CreateIfNotExistsAsync().ConfigureAwait(false); Log.Info((int)AzureProviderErrorCode.AzureBlobProvider_InitProvider, "Init: Name={0} ServiceId={1} {2}", name, providerRuntime.ServiceId.ToString(), string.Join(" ", FormatPropertyMessage(config))); Log.Info((int)AzureProviderErrorCode.AzureBlobProvider_ParamConnectionString, "AzureBlobStorage Provider is using DataConnectionString: {0}", ConfigUtilities.PrintDataConnectionInfo(config.Properties["DataConnectionString"])); } catch (Exception ex) { Log.Error((int)AzureProviderErrorCode.AzureBlobProvider_InitProvider, ex.ToString(), ex); throw; } }
/// <inheritdoc /> public IEnumerable <string> Format() { return(new[] { OptionFormattingUtilities.Format(nameof(this.options.ConnectionString), ConfigUtilities.RedactConnectionStringInfo(this.options.ConnectionString)) }); }
/// <summary> Initialization function for this storage provider. </summary> /// <see cref="IProvider.Init"/> public async Task Init(string name, IProviderRuntime providerRuntime, IProviderConfiguration config) { Log = providerRuntime.GetLogger("Storage.AzureBlobStorage"); try { this.Name = name; this.jsonSettings = OrleansJsonSerializer.UpdateSerializerSettings(OrleansJsonSerializer.GetDefaultSerializerSettings(), config); if (!config.Properties.ContainsKey(DataConnectionStringPropertyName)) { throw new BadProviderConfigException($"The {DataConnectionStringPropertyName} setting has not been configured in the cloud role. Please add a {DataConnectionStringPropertyName} setting with a valid Azure Storage connection string."); } var account = CloudStorageAccount.Parse(config.Properties[DataConnectionStringPropertyName]); var blobClient = account.CreateCloudBlobClient(); var containerName = config.Properties.ContainsKey(ContainerNamePropertyName) ? config.Properties[ContainerNamePropertyName] : ContainerNameDefaultValue; container = blobClient.GetContainerReference(containerName); await container.CreateIfNotExistsAsync().ConfigureAwait(false); Log.Info((int)AzureProviderErrorCode.AzureBlobProvider_InitProvider, "Init: Name={0} ServiceId={1} {2}", name, providerRuntime.ServiceId.ToString(), string.Join(" ", FormatPropertyMessage(config))); Log.Info((int)AzureProviderErrorCode.AzureBlobProvider_ParamConnectionString, "AzureBlobStorage Provider is using DataConnectionString: {0}", ConfigUtilities.PrintDataConnectionInfo(config.Properties["DataConnectionString"])); } catch (Exception ex) { Log.Error((int)AzureProviderErrorCode.AzureBlobProvider_InitProvider, ex.ToString(), ex); throw; } }
/// <summary> /// Returns the BIM360 configured Project folder /// </summary> /// <returns></returns> public static string GetProjectFolder() { return(Utility.GetBIM360RootPath() + ConfigUtilities.GetHub() + "\\" + ConfigUtilities.GetProject() + "\\"); }