public MeshPersistentFileSystem(ISystemEnvironment environment, IMeshServiceClient meshServiceClient, IStorageClient storageClient)
 {
     _fileShareMounted      = false;
     _fileShareMountMessage = string.Empty;
     _environment           = environment;
     _meshServiceClient     = meshServiceClient;
     _storageClient         = storageClient;
 }
예제 #2
0
 public MeshServiceClientTests()
 {
     _handlerMock = new Mock <HttpMessageHandler>(MockBehavior.Strict);
     _environment = new TestEnvironment();
     _environment.SetEnvironmentVariable(EnvironmentSettingNames.MeshInitURI, MeshInitUri);
     _meshServiceClient = new MeshServiceClient(new HttpClient(_handlerMock.Object), _environment,
                                                NullLogger <MeshServiceClient> .Instance);
 }
 public InstanceManager(IOptionsFactory <ScriptApplicationHostOptions> optionsFactory, HttpClient client, IScriptWebHostEnvironment webHostEnvironment,
                        IEnvironment environment, ILogger <InstanceManager> logger, IMetricsLogger metricsLogger, IMeshServiceClient meshServiceClient)
 {
     _client             = client ?? throw new ArgumentNullException(nameof(client));
     _webHostEnvironment = webHostEnvironment ?? throw new ArgumentNullException(nameof(webHostEnvironment));
     _logger             = logger ?? throw new ArgumentNullException(nameof(logger));
     _metricsLogger      = metricsLogger;
     _meshServiceClient  = meshServiceClient;
     _environment        = environment ?? throw new ArgumentNullException(nameof(environment));
     _optionsFactory     = optionsFactory ?? throw new ArgumentNullException(nameof(optionsFactory));
 }
예제 #4
0
 public RunFromPackageHandler(IEnvironment environment, IMeshServiceClient meshServiceClient,
                              IBashCommandHandler bashCommandHandler, IUnZipHandler unZipHandler, IPackageDownloadHandler packageDownloadHandler, IMetricsLogger metricsLogger, ILogger <RunFromPackageHandler> logger)
 {
     _environment            = environment ?? throw new ArgumentNullException(nameof(environment));
     _meshServiceClient      = meshServiceClient ?? throw new ArgumentNullException(nameof(meshServiceClient));
     _bashCommandHandler     = bashCommandHandler ?? throw new ArgumentNullException(nameof(bashCommandHandler));
     _unZipHandler           = unZipHandler ?? throw new ArgumentNullException(nameof(unZipHandler));
     _packageDownloadHandler = packageDownloadHandler ?? throw new ArgumentNullException(nameof(packageDownloadHandler));
     _metricsLogger          = metricsLogger ?? throw new ArgumentNullException(nameof(metricsLogger));
     _logger = logger ?? throw new ArgumentNullException(nameof(logger));
 }
예제 #5
0
 public InstanceManager(IOptionsFactory <ScriptApplicationHostOptions> optionsFactory, IHttpClientFactory httpClientFactory, IScriptWebHostEnvironment webHostEnvironment,
                        IEnvironment environment, ILogger <InstanceManager> logger, IMetricsLogger metricsLogger, IMeshServiceClient meshServiceClient, IRunFromPackageHandler runFromPackageHandler,
                        IPackageDownloadHandler packageDownloadHandler)
 {
     _client                 = httpClientFactory?.CreateClient() ?? throw new ArgumentNullException(nameof(httpClientFactory));
     _webHostEnvironment     = webHostEnvironment ?? throw new ArgumentNullException(nameof(webHostEnvironment));
     _logger                 = logger ?? throw new ArgumentNullException(nameof(logger));
     _metricsLogger          = metricsLogger;
     _meshServiceClient      = meshServiceClient;
     _runFromPackageHandler  = runFromPackageHandler ?? throw new ArgumentNullException(nameof(runFromPackageHandler));
     _packageDownloadHandler = packageDownloadHandler ?? throw new ArgumentNullException(nameof(packageDownloadHandler));
     _environment            = environment ?? throw new ArgumentNullException(nameof(environment));
     _optionsFactory         = optionsFactory ?? throw new ArgumentNullException(nameof(optionsFactory));
 }
예제 #6
0
        public LinuxContainerActivityPublisher(IOptionsMonitor <StandbyOptions> standbyOptions,
                                               IMeshServiceClient meshServiceClient, IEnvironment environment,
                                               ILogger <LinuxContainerActivityPublisher> logger, int flushIntervalMs = FlushIntervalMs)
        {
            if (!environment.IsLinuxConsumption())
            {
                throw new NotSupportedException(
                          $"{nameof(LinuxContainerActivityPublisher)} is available in Linux consumption environment only");
            }

            _standbyOptions    = standbyOptions ?? throw new ArgumentNullException(nameof(standbyOptions));
            _meshServiceClient = meshServiceClient;
            _logger            = logger;
            _flushIntervalMs   = flushIntervalMs;
            _timer             = new Timer(OnTimer, null, Timeout.Infinite, Timeout.Infinite);
            _uniqueActivities  = new HashSet <ContainerFunctionExecutionActivity>();
            _flushInProgress   = 0;
        }
예제 #7
0
        private InstanceManager GetInstanceManagerForMSISpecialization(HostAssignmentContext hostAssignmentContext,
                                                                       HttpStatusCode httpStatusCode, IMeshServiceClient meshServiceClient)
        {
            var handlerMock = new Mock <HttpMessageHandler>(MockBehavior.Strict);

            var msiEndpoint = hostAssignmentContext.Environment[EnvironmentSettingNames.MsiEndpoint] + ScriptConstants.LinuxMSISpecializationStem;

            handlerMock.Protected().Setup <Task <HttpResponseMessage> >("SendAsync",
                                                                        ItExpr.Is <HttpRequestMessage>(request => request.Method == HttpMethod.Post &&
                                                                                                       request.RequestUri.AbsoluteUri.Equals(msiEndpoint) &&
                                                                                                       request.Content != null),
                                                                        ItExpr.IsAny <CancellationToken>()).ReturnsAsync(new HttpResponseMessage
            {
                StatusCode = httpStatusCode
            });

            InstanceManager.Reset();

            return(new InstanceManager(_optionsFactory, new HttpClient(handlerMock.Object), _scriptWebEnvironment, _environment,
                                       _loggerFactory.CreateLogger <InstanceManager>(), new TestMetricsLogger(), meshServiceClient));
        }