// todo: Make systemEnvironment a mandatory parameter. public static string GetApplicationName(ISystemEnvironment systemEnvironment = null) { var applicationName = systemEnvironment != null ? systemEnvironment.GetEnvironmentVariable(Constants.WebsiteSiteName) : System.Environment.GetEnvironmentVariable(Constants.WebsiteSiteName); if (!string.IsNullOrEmpty(applicationName)) { // Yank everything after the first underscore to work around // a slot issue where WEBSITE_SITE_NAME gets set incorrectly int underscoreIndex = applicationName.IndexOf('_'); if (underscoreIndex > 0) { applicationName = applicationName.Substring(0, underscoreIndex); } return(applicationName); } applicationName = systemEnvironment != null ? systemEnvironment.GetEnvironmentVariable("APP_POOL_ID") : System.Environment.GetEnvironmentVariable("APP_POOL_ID"); if (applicationName != null) { return(applicationName); } return(String.Empty); }
public void Init(string storagePath, ISystemEnvironment systemEnvironment, bool optimizeForPerformance) { StoreProvider storeProvider; try { var partitionsList = new List <string> { "desiredPropertyUpdated", "desiredPropertyReceived", "reportedPropertyUpdated" }; IDbStoreProvider dbStoreprovider = DbStoreProvider.Create( new RocksDbOptionsProvider(systemEnvironment, optimizeForPerformance, Option.None <ulong>()), this.GetStoragePath(storagePath), partitionsList); storeProvider = new StoreProvider(dbStoreprovider); } catch (Exception ex) when(!ExceptionEx.IsFatal(ex)) { Logger.LogError(ex, "Error creating RocksDB store. Falling back to in-memory store."); storeProvider = new StoreProvider(new InMemoryDbStoreProvider()); } this.desiredPropertyUpdateCache = storeProvider.GetEntityStore <string, DateTime>(DesiredPropertyUpdatePartitionKey); this.desiredPropertyReceivedCache = storeProvider.GetEntityStore <string, DateTime>(DesiredPropertyReceivedPartitionKey); this.reportedPropertyUpdateCache = storeProvider.GetEntityStore <string, DateTime>(ReportedPropertyUpdatePartitionKey); }
public async Task InitAsync(string storagePath, ISystemEnvironment systemEnvironment, bool optimizeForPerformance) { StoreProvider storeProvider; try { var partitionsList = new List <string> { "messages", "directMethods", "twins" }; IDbStoreProvider dbStoreprovider = DbStoreProvider.Create( new RocksDbOptionsProvider(systemEnvironment, optimizeForPerformance, Option.None <ulong>(), Option.None <int>(), Option.None <StorageLogLevel>()), this.GetStoragePath(storagePath), partitionsList); storeProvider = new StoreProvider(dbStoreprovider); } catch (Exception ex) when(!ExceptionEx.IsFatal(ex)) { Logger.LogError(ex, "Error creating RocksDB store. Falling back to in-memory store."); storeProvider = new StoreProvider(new InMemoryDbStoreProvider()); } this.messagesStore = await storeProvider.GetSequentialStore <MessageDetails>(MessageStorePartitionKey); this.directMethodsStore = await storeProvider.GetSequentialStore <TestOperationResult>(DirectMethodsStorePartitionKey); this.twinsStore = await storeProvider.GetSequentialStore <TestOperationResult>(TwinsStorePartitionKey); }
public RocksDbOptionsProvider(ISystemEnvironment env, bool optimizeForPerformance, Option <ulong> maxTotalWalsize, Option <StorageLogLevel> logLevel) { this.env = Preconditions.CheckNotNull(env); this.optimizeForPerformance = optimizeForPerformance; this.maxTotalWalSize = maxTotalWalsize.GetOrElse(DefaultMaxTotalWalSize); this.logLevel = logLevel.GetOrElse(DefaultLogLevel); }
public void Creates_new_application_instance() { MockRepository mocks = new MockRepository(); ISystemEnvironment systemEnvironment = mocks.CreateMock <ISystemEnvironment>(); IAssemblyContext context = mocks.CreateMock <IAssemblyContext>(); IConfigurationReader configurationReader = mocks.CreateMock <IConfigurationReader>(); using (mocks.Record()) { Expect.Call(context.GetAssemblyVersion()).Return("1.0"); Expect.Call(systemEnvironment.GetMachineName()).Return("MyMachine"); Expect.Call(configurationReader.GetRequiredSetting("TarantinoWebManagementHttpHost")).Return("www.myapp.com"); } using (mocks.Playback()) { IApplicationInstanceFactory factory = new ApplicationInstanceFactory(systemEnvironment, context, configurationReader); ApplicationInstance instance = factory.Create(); Assert.That(instance.AvailableForLoadBalancing, Is.True); Assert.That(instance.MachineName, Is.EqualTo("MyMachine")); Assert.That(instance.Version, Is.EqualTo("1.0")); Assert.That(instance.MaintenanceHostHeader, Is.EqualTo("www.myapp.com")); Assert.That(instance.ApplicationDomain, Is.EqualTo("www.myapp.com")); } mocks.VerifyAll(); }
public CurrentApplicationInstanceRetriever(ISystemEnvironment environment, IConfigurationReader configurationReader, IApplicationInstanceRepository repository, IApplicationInstanceFactory factory) { _environment = environment; _configurationReader = configurationReader; _repository = repository; _factory = factory; }
public void Correctly_creates_new_application_instance_if_existing_instance_does_not_exist() { ApplicationInstance instance = new ApplicationInstance(); MockRepository mocks = new MockRepository(); ISystemEnvironment environment = mocks.CreateMock <ISystemEnvironment>(); IConfigurationReader configurationReader = mocks.CreateMock <IConfigurationReader>(); IApplicationInstanceRepository repository = mocks.CreateMock <IApplicationInstanceRepository>(); IApplicationInstanceFactory factory = mocks.CreateMock <IApplicationInstanceFactory>(); using (mocks.Record()) { Expect.Call(environment.GetMachineName()).Return("MyMachine"); Expect.Call(configurationReader.GetRequiredSetting("TarantinoWebManagementHttpHost")).Return("www.myapp.com"); Expect.Call(repository.GetByMaintenanceHostHeaderAndMachineName("www.myapp.com", "MyMachine")).Return(null); Expect.Call(factory.Create()).Return(instance); repository.Save(instance); } using (mocks.Playback()) { ICurrentApplicationInstanceRetriever retriever = new CurrentApplicationInstanceRetriever(environment, configurationReader, repository, factory); Assert.That(retriever.GetApplicationInstance(), Is.SameAs(instance)); } mocks.VerifyAll(); }
public ProgramSettingsManager(ISystemEnvironment systemEnvironment, ILogService logService, IStorageService storageService) { _systemEnvironment = systemEnvironment; _storageService = storageService; _logService = logService; }
public static IKuduEventGenerator Log(ISystemEnvironment systemEnvironment = null) { string containerName = systemEnvironment != null ? systemEnvironment.GetEnvironmentVariable(Constants.ContainerName) : Environment.ContainerName; // Linux Consumptions only bool isLinuxContainer = !string.IsNullOrEmpty(containerName); if (isLinuxContainer) { if (_eventGenerator == null) { _eventGenerator = new LinuxContainerEventGenerator(); } } else { if (_eventGenerator == null) { // Generate ETW events when running on windows if (OSDetector.IsOnWindows()) { _eventGenerator = new DefaultKuduEventGenerator(); } else { _eventGenerator = new Log4NetEventGenerator(); } } } return(_eventGenerator); }
public CurrentApplicationInstanceRetriever(ISystemEnvironment environment, IConfigurationReader configurationReader, IApplicationInstanceRepository repository, IApplicationInstanceFactory factory) { _environment = environment; _configurationReader = configurationReader; _repository = repository; _factory = factory; }
public MeshPersistentFileSystem(ISystemEnvironment environment, IMeshServiceClient meshServiceClient, IStorageClient storageClient) { _fileShareMounted = false; _fileShareMountMessage = string.Empty; _environment = environment; _meshServiceClient = meshServiceClient; _storageClient = storageClient; }
public StampConfig(ISystemEnvironment systemEnvironment, IFileSystem fileSystem) { this.SystemEnvironment = systemEnvironment; this.FileSystem = fileSystem; m_rootPath = new Lazy <IPurePath>(() => { var appDataPath = this.SystemEnvironment.GetFolderPath(Environment.SpecialFolder.ApplicationData, Environment.SpecialFolderOption.Create); return(PurePath.Create(appDataPath, StampConfigConstants.ConfigDirectoryName)); }); }
/// <summary> /// APM Constructor /// /// The constructor determines which operating system environment is needed. /// Environments follow a interface, and will have the same core functions. /// </summary> public Apm() { if (AppConfig.isWindows) { _operatingSystemEnvironment = new WindowsEnvironment(); } else if (AppConfig.isLinux) { _operatingSystemEnvironment = new LinuxEnvironment(); } else if (AppConfig.isMac) { _operatingSystemEnvironment = new MacEnvironment(); } }
public ImagingService(ICameraService cameraService, ILogService logService, IImageIoService ioService, ISystemEnvironment systemEnvironment) { _cameraService = cameraService; _logService = logService; _imageIoService = ioService; _systemEnvironment = systemEnvironment; ExposureVisualProcessingSettings = new ExposureVisualSettings() { AutoStretch = true, StretchMin = 0, StretchMax = -1 }; DarkFrameMode = false; IsSessionPaused = false; }
private GitVersionBuildStep CreateGitVersionBuildStep( out IGitVersionCalculator fakeGitVersion, out ISystemEnvironment fakeEnvironment) { GitVersionBuildStep buildStep = new GitVersionBuildStep(); fakeGitVersion = A.Fake <IGitVersionCalculator>(); fakeEnvironment = A.Fake <ISystemEnvironment>(); buildStep.GetType() .GetField( "gitVersion", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance) .SetValue(buildStep, fakeGitVersion); buildStep.GetType() .GetField( "systemEnvironment", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance) .SetValue(buildStep, fakeEnvironment); return(buildStep); }
public ApplicationInstanceFactory(ISystemEnvironment systemEnvironment, IAssemblyContext assemblyContext, IConfigurationReader configurationReader) { _systemEnvironment = systemEnvironment; _assemblyContext = assemblyContext; _configurationReader = configurationReader; }
public ServerConfiguration(ISystemEnvironment environment) { _environment = environment; }
public StorageClient(ISystemEnvironment environment) { _environment = environment; }
/// <summary> /// Creates a new instance of the build logic step /// </summary> public GitVersionBuildStep() { gitVersion = new GitVersionCalculator(); systemEnvironment = new SystemEnvironmentAdapter(); }
public MeshServiceClient(ISystemEnvironment environment, HttpClient client) { _environment = environment ?? throw new ArgumentNullException(nameof(environment)); _client = client ?? throw new ArgumentNullException(nameof(client)); }
public ApplicationInstanceFactory(ISystemEnvironment systemEnvironment, IAssemblyContext assemblyContext, IConfigurationReader configurationReader) { _systemEnvironment = systemEnvironment; _assemblyContext = assemblyContext; _configurationReader = configurationReader; }
public RocksDbOptionsProvider(ISystemEnvironment env, bool optimizeForPerformance) { this.env = Preconditions.CheckNotNull(env); this.optimizeForPerformance = optimizeForPerformance; }
public static bool IsOnLinuxConsumption(this ISystemEnvironment environment) { return(!string.IsNullOrEmpty(environment.GetEnvironmentVariable(Constants.ContainerName))); }