public SharedMemoryManager(ILoggerFactory loggerFactory, IMemoryMappedFileAccessor mapAccessor) { _loggerFactory = loggerFactory; _logger = _loggerFactory.CreateLogger <SharedMemoryManager>(); _mapAccessor = mapAccessor; AllocatedSharedMemoryMaps = new ConcurrentDictionary <string, SharedMemoryMap>(); InvocationSharedMemoryMaps = new ConcurrentDictionary <string, HashSet <string> >(); _isDisposed = false; }
public GrpcWorkerChannelTests() { _logger = new TestLogger("FunctionDispatcherTests"); _testFunctionRpcService = new TestFunctionRpcService(_eventManager, _workerId, _logger, _expectedLogMsg); _testWorkerConfig = TestHelpers.GetTestWorkerConfigs().FirstOrDefault(); _testWorkerConfig.CountOptions.ProcessStartupTimeout = TimeSpan.FromSeconds(5); _testWorkerConfig.CountOptions.InitializationTimeout = TimeSpan.FromSeconds(5); _testWorkerConfig.CountOptions.EnvironmentReloadTimeout = TimeSpan.FromSeconds(5); _mockrpcWorkerProcess.Setup(m => m.StartProcessAsync()).Returns(Task.CompletedTask); _mockrpcWorkerProcess.Setup(m => m.Id).Returns(910); _testEnvironment = new TestEnvironment(); _testEnvironment.SetEnvironmentVariable(FunctionDataCacheConstants.FunctionDataCacheEnabledSettingName, "1"); _workerConcurrencyOptions = Options.Create(new WorkerConcurrencyOptions()); _workerConcurrencyOptions.Value.CheckInterval = TimeSpan.FromSeconds(1); ILogger <MemoryMappedFileAccessor> mmapAccessorLogger = NullLogger <MemoryMappedFileAccessor> .Instance; if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { _mapAccessor = new MemoryMappedFileAccessorWindows(mmapAccessorLogger); } else { _mapAccessor = new MemoryMappedFileAccessorUnix(mmapAccessorLogger, _testEnvironment); } _sharedMemoryManager = new SharedMemoryManager(_loggerFactory, _mapAccessor); _functionDataCache = new FunctionDataCache(_sharedMemoryManager, _loggerFactory, _testEnvironment); var hostOptions = new ScriptApplicationHostOptions { IsSelfHost = true, ScriptPath = _scriptRootPath, LogPath = Environment.CurrentDirectory, // not tested SecretsPath = Environment.CurrentDirectory, // not tested HasParentScope = true }; _hostOptionsMonitor = TestHelpers.CreateOptionsMonitor(hostOptions); _workerChannel = new GrpcWorkerChannel( _workerId, _eventManager, _testWorkerConfig, _mockrpcWorkerProcess.Object, _logger, _metricsLogger, 0, _testEnvironment, _hostOptionsMonitor, _sharedMemoryManager, _functionDataCache, _workerConcurrencyOptions); }
public MemoryMappedFileAccessorTests() { ILogger <MemoryMappedFileAccessor> logger = NullLogger <MemoryMappedFileAccessor> .Instance; if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { _mapAccessor = new MemoryMappedFileAccessorWindows(logger); } else { _mapAccessor = new MemoryMappedFileAccessorUnix(logger); } }
public SharedMemoryMap(ILoggerFactory loggerFactory, IMemoryMappedFileAccessor mapAccessor, string mapName, MemoryMappedFile memoryMappedFile) { if (string.IsNullOrEmpty(mapName)) { throw new ArgumentException(nameof(mapName)); } _memoryMappedFile = memoryMappedFile ?? throw new ArgumentNullException(nameof(memoryMappedFile)); _loggerFactory = loggerFactory; _logger = _loggerFactory.CreateLogger <SharedMemoryMap>(); _mapName = mapName; _mapAccessor = mapAccessor; }
public ScriptInvocationContextExtensionsTests() { ILogger <MemoryMappedFileAccessor> logger = NullLogger <MemoryMappedFileAccessor> .Instance; if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { _mapAccessor = new MemoryMappedFileAccessorWindows(logger); } else { _mapAccessor = new MemoryMappedFileAccessorUnix(logger); } _sharedMemoryManager = new SharedMemoryManager(_loggerFactory, _mapAccessor); }
public SharedMemoryManagerTests() { _loggerFactory = MockNullLoggerFactory.CreateLoggerFactory(); ILogger <MemoryMappedFileAccessor> logger = NullLogger <MemoryMappedFileAccessor> .Instance; if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { _mapAccessor = new MemoryMappedFileAccessorWindows(logger); } else { _mapAccessor = new MemoryMappedFileAccessorUnix(logger); } }
public ScriptInvocationContextExtensionsTests() { ILogger <MemoryMappedFileAccessor> logger = NullLogger <MemoryMappedFileAccessor> .Instance; _testEnvironment = new TestEnvironment(); _testEnvironment.SetEnvironmentVariable(FunctionDataCacheConstants.FunctionDataCacheEnabledSettingName, "1"); if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { _mapAccessor = new MemoryMappedFileAccessorWindows(logger); } else { _mapAccessor = new MemoryMappedFileAccessorUnix(logger, _testEnvironment); } _sharedMemoryManager = new SharedMemoryManager(_loggerFactory, _mapAccessor); _functionDataCache = new FunctionDataCache(_sharedMemoryManager, _loggerFactory, _testEnvironment); }
public FunctionDataCacheTests() { _loggerFactory = MockNullLoggerFactory.CreateLoggerFactory(); ILogger <MemoryMappedFileAccessor> logger = NullLogger <MemoryMappedFileAccessor> .Instance; _testEnvironment = new TestEnvironment(); if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { _mapAccessor = new MemoryMappedFileAccessorWindows(logger); } else { _mapAccessor = new MemoryMappedFileAccessorUnix(logger, _testEnvironment); } _testEnvironment.SetEnvironmentVariable(FunctionDataCacheConstants.FunctionDataCacheEnabledSettingName, "1"); }
public GrpcWorkerChannelTests() { _logger = new TestLogger("FunctionDispatcherTests"); _testFunctionRpcService = new TestFunctionRpcService(_eventManager, _workerId, _logger, _expectedLogMsg); _testWorkerConfig = TestHelpers.GetTestWorkerConfigs().FirstOrDefault(); _mockrpcWorkerProcess.Setup(m => m.StartProcessAsync()).Returns(Task.CompletedTask); _testEnvironment = new TestEnvironment(); ILogger <MemoryMappedFileAccessor> mmapAccessorLogger = NullLogger <MemoryMappedFileAccessor> .Instance; if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { _mapAccessor = new MemoryMappedFileAccessorWindows(mmapAccessorLogger); } else { _mapAccessor = new MemoryMappedFileAccessorUnix(mmapAccessorLogger, _testEnvironment); } _sharedMemoryManager = new SharedMemoryManager(_loggerFactory, _mapAccessor); var hostOptions = new ScriptApplicationHostOptions { IsSelfHost = true, ScriptPath = _scriptRootPath, LogPath = Environment.CurrentDirectory, // not tested SecretsPath = Environment.CurrentDirectory, // not tested HasParentScope = true }; _hostOptionsMonitor = TestHelpers.CreateOptionsMonitor(hostOptions); _workerChannel = new GrpcWorkerChannel( _workerId, _eventManager, _testWorkerConfig, _mockrpcWorkerProcess.Object, _logger, _metricsLogger, 0, _testEnvironment, _hostOptionsMonitor, _sharedMemoryManager); }