Example #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="InstanceManager"/> class.
        /// </summary>
        /// <param name="instanceFactory">The value of <see cref="instanceFactory"/>.</param>
        /// <param name="ioManager">The value of <paramref name="ioManager"/>.</param>
        /// <param name="databaseContextFactory">The value of <paramref name="databaseContextFactory"/>.</param>
        /// <param name="assemblyInformationProvider">The value of <see cref="assemblyInformationProvider"/>.</param>
        /// <param name="jobManager">The value of <see cref="jobManager"/>.</param>
        /// <param name="serverControl">The value of <see cref="serverControl"/>.</param>
        /// <param name="systemIdentityFactory">The value of <see cref="systemIdentityFactory"/>.</param>
        /// <param name="asyncDelayer">The value of <see cref="asyncDelayer"/>.</param>
        /// <param name="serverPortProvider">The value of <see cref="serverPortProvider"/>.</param>
        /// <param name="swarmService">The value of <see cref="swarmService"/>.</param>
        /// <param name="generalConfigurationOptions">The <see cref="IOptions{TOptions}"/> containing the value of <see cref="generalConfiguration"/>.</param>
        /// <param name="swarmConfigurationOptions">The <see cref="IOptions{TOptions}"/> containing the value of <see cref="swarmConfiguration"/>.</param>
        /// <param name="logger">The value of <see cref="logger"/>.</param>
        public InstanceManager(
            IInstanceFactory instanceFactory,
            IIOManager ioManager,
            IDatabaseContextFactory databaseContextFactory,
            IAssemblyInformationProvider assemblyInformationProvider,
            IJobManager jobManager,
            IServerControl serverControl,
            ISystemIdentityFactory systemIdentityFactory,
            IAsyncDelayer asyncDelayer,
            IServerPortProvider serverPortProvider,
            ISwarmService swarmService,
            IOptions <GeneralConfiguration> generalConfigurationOptions,
            IOptions <SwarmConfiguration> swarmConfigurationOptions,
            ILogger <InstanceManager> logger)
        {
            this.instanceFactory             = instanceFactory ?? throw new ArgumentNullException(nameof(instanceFactory));
            this.ioManager                   = ioManager ?? throw new ArgumentNullException(nameof(ioManager));
            this.databaseContextFactory      = databaseContextFactory ?? throw new ArgumentNullException(nameof(databaseContextFactory));
            this.assemblyInformationProvider = assemblyInformationProvider ?? throw new ArgumentNullException(nameof(assemblyInformationProvider));
            this.jobManager                  = jobManager ?? throw new ArgumentNullException(nameof(jobManager));
            this.serverControl               = serverControl ?? throw new ArgumentNullException(nameof(serverControl));
            this.systemIdentityFactory       = systemIdentityFactory ?? throw new ArgumentNullException(nameof(systemIdentityFactory));
            this.asyncDelayer                = asyncDelayer ?? throw new ArgumentNullException(nameof(asyncDelayer));
            this.serverPortProvider          = serverPortProvider ?? throw new ArgumentNullException(nameof(serverPortProvider));
            this.swarmService                = swarmService ?? throw new ArgumentNullException(nameof(swarmService));
            generalConfiguration             = generalConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(generalConfigurationOptions));
            swarmConfiguration               = swarmConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(swarmConfigurationOptions));
            this.logger = logger ?? throw new ArgumentNullException(nameof(logger));

            instances      = new Dictionary <long, InstanceContainer>();
            bridgeHandlers = new Dictionary <string, IBridgeHandler>();
            readyTcs       = new TaskCompletionSource <object>();
            instanceStateChangeSemaphore = new SemaphoreSlim(1);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="PortAllocator"/> class.
 /// </summary>
 /// <param name="serverPortProvider">The value of <see cref="serverPortProvider"/>.</param>
 /// <param name="databaseContext">The value of <see cref="databaseContext"/>.</param>
 /// <param name="swarmConfigurationOptions">The <see cref="IOptions{TOptions}"/> containing the value of <see cref="swarmConfiguration"/>.</param>
 /// <param name="logger">The value of <see cref="logger"/>.</param>
 public PortAllocator(
     IServerPortProvider serverPortProvider,
     IDatabaseContext databaseContext,
     IOptions <SwarmConfiguration> swarmConfigurationOptions,
     ILogger <PortAllocator> logger)
 {
     this.serverPortProvider = serverPortProvider ?? throw new ArgumentNullException(nameof(serverPortProvider));
     this.databaseContext    = databaseContext ?? throw new ArgumentNullException(nameof(databaseContext));
     swarmConfiguration      = swarmConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(swarmConfigurationOptions));
     this.logger             = logger ?? throw new ArgumentNullException(nameof(logger));
 }
Example #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="InstanceFactory"/> class.
 /// </summary>
 /// <param name="ioManager">The value of <see cref="ioManager"/>.</param>
 /// <param name="databaseContextFactory">The value of <see cref="databaseContextFactory"/>.</param>
 /// <param name="assemblyInformationProvider">The value of <see cref="assemblyInformationProvider"/>.</param>
 /// <param name="loggerFactory">The value of <see cref="loggerFactory"/>.</param>
 /// <param name="topicClientFactory">The value of <see cref="topicClientFactory"/>.</param>
 /// <param name="cryptographySuite">The value of <see cref="cryptographySuite"/>.</param>
 /// <param name="synchronousIOManager">The value of <see cref="synchronousIOManager"/>.</param>
 /// <param name="symlinkFactory">The value of <see cref="symlinkFactory"/>.</param>
 /// <param name="byondInstaller">The value of <see cref="byondInstaller"/>.</param>
 /// <param name="chatFactory">The value of <see cref="chatFactory"/>.</param>
 /// <param name="processExecutor">The value of <see cref="processExecutor"/>.</param>
 /// <param name="postWriteHandler">The value of <see cref="postWriteHandler"/>.</param>
 /// <param name="watchdogFactory">The value of <see cref="watchdogFactory"/>.</param>
 /// <param name="jobManager">The value of <see cref="jobManager"/>.</param>
 /// <param name="networkPromptReaper">The value of <see cref="networkPromptReaper"/>.</param>
 /// <param name="platformIdentifier">The value of <see cref="platformIdentifier"/>.</param>
 /// <param name="repositoryFactory">The value of <see cref="repositoryFactory"/>.</param>
 /// <param name="repositoryCommands">The value of <see cref="repositoryCommands"/>.</param>
 /// <param name="serverPortProvider">The value of <see cref="serverPortProvider"/>.</param>
 /// <param name="fileTransferService">The value of <see cref="fileTransferService"/>.</param>
 /// <param name="gitRemoteFeaturesFactory">The value of <see cref="gitRemoteFeaturesFactory"/>.</param>
 /// <param name="remoteDeploymentManagerFactory">The value of <see cref="remoteDeploymentManagerFactory"/>.</param>
 /// <param name="generalConfigurationOptions">The <see cref="IOptions{TOptions}"/> containing the value of <see cref="generalConfiguration"/>.</param>
 public InstanceFactory(
     IIOManager ioManager,
     IDatabaseContextFactory databaseContextFactory,
     IAssemblyInformationProvider assemblyInformationProvider,
     ILoggerFactory loggerFactory,
     ITopicClientFactory topicClientFactory,
     ICryptographySuite cryptographySuite,
     ISynchronousIOManager synchronousIOManager,
     ISymlinkFactory symlinkFactory,
     IByondInstaller byondInstaller,
     IChatManagerFactory chatFactory,
     IProcessExecutor processExecutor,
     IPostWriteHandler postWriteHandler,
     IWatchdogFactory watchdogFactory,
     IJobManager jobManager,
     INetworkPromptReaper networkPromptReaper,
     IPlatformIdentifier platformIdentifier,
     ILibGit2RepositoryFactory repositoryFactory,
     ILibGit2Commands repositoryCommands,
     IServerPortProvider serverPortProvider,
     IFileTransferTicketProvider fileTransferService,
     IGitRemoteFeaturesFactory gitRemoteFeaturesFactory,
     IRemoteDeploymentManagerFactory remoteDeploymentManagerFactory,
     IOptions <GeneralConfiguration> generalConfigurationOptions)
 {
     this.ioManager = ioManager ?? throw new ArgumentNullException(nameof(ioManager));
     this.databaseContextFactory      = databaseContextFactory ?? throw new ArgumentNullException(nameof(databaseContextFactory));
     this.assemblyInformationProvider = assemblyInformationProvider ?? throw new ArgumentNullException(nameof(assemblyInformationProvider));
     this.loggerFactory                  = loggerFactory ?? throw new ArgumentNullException(nameof(loggerFactory));
     this.topicClientFactory             = topicClientFactory ?? throw new ArgumentNullException(nameof(topicClientFactory));
     this.cryptographySuite              = cryptographySuite ?? throw new ArgumentNullException(nameof(cryptographySuite));
     this.synchronousIOManager           = synchronousIOManager ?? throw new ArgumentNullException(nameof(synchronousIOManager));
     this.symlinkFactory                 = symlinkFactory ?? throw new ArgumentNullException(nameof(symlinkFactory));
     this.byondInstaller                 = byondInstaller ?? throw new ArgumentNullException(nameof(byondInstaller));
     this.chatFactory                    = chatFactory ?? throw new ArgumentNullException(nameof(chatFactory));
     this.processExecutor                = processExecutor ?? throw new ArgumentNullException(nameof(processExecutor));
     this.postWriteHandler               = postWriteHandler ?? throw new ArgumentNullException(nameof(postWriteHandler));
     this.watchdogFactory                = watchdogFactory ?? throw new ArgumentNullException(nameof(watchdogFactory));
     this.jobManager                     = jobManager ?? throw new ArgumentNullException(nameof(jobManager));
     this.networkPromptReaper            = networkPromptReaper ?? throw new ArgumentNullException(nameof(networkPromptReaper));
     this.platformIdentifier             = platformIdentifier ?? throw new ArgumentNullException(nameof(platformIdentifier));
     this.repositoryFactory              = repositoryFactory ?? throw new ArgumentNullException(nameof(repositoryFactory));
     this.repositoryCommands             = repositoryCommands ?? throw new ArgumentNullException(nameof(repositoryCommands));
     this.serverPortProvider             = serverPortProvider ?? throw new ArgumentNullException(nameof(serverPortProvider));
     this.fileTransferService            = fileTransferService ?? throw new ArgumentNullException(nameof(fileTransferService));
     this.gitRemoteFeaturesFactory       = gitRemoteFeaturesFactory ?? throw new ArgumentNullException(nameof(gitRemoteFeaturesFactory));
     this.remoteDeploymentManagerFactory = remoteDeploymentManagerFactory ?? throw new ArgumentNullException(nameof(remoteDeploymentManagerFactory));
     generalConfiguration                = generalConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(generalConfigurationOptions));
 }
Example #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RuntimeInformation"/> <see langword="class"/>.
 /// </summary>
 /// <param name="assemblyInformationProvider">The <see cref="IAssemblyInformationProvider"/> to use.</param>
 /// <param name="serverPortProvider">The <see cref="IServerPortProvider"/> used to set the value of <see cref="ServerPort"/>.</param>
 /// <param name="testMerges">An <see cref="IEnumerable{T}"/> used to construct the value of <see cref="TestMerges"/>.</param>
 /// <param name="chatChannels">The <see cref="Chat.ChannelRepresentation"/>s for the <see cref="ChatUpdate"/>.</param>
 /// <param name="instance">The <see cref="Instance"/> used to set <see cref="InstanceName"/>.</param>
 /// <param name="revision">The value of <see cref="RevisionInformation"/>.</param>
 /// <param name="securityLevel">The value of <see cref="SecurityLevel"/>.</param>
 /// <param name="apiValidateOnly">The value of <see cref="ApiValidateOnly"/>.</param>
 public RuntimeInformation(
     IAssemblyInformationProvider assemblyInformationProvider,
     IServerPortProvider serverPortProvider,
     IEnumerable <TestMergeInformation> testMerges,
     IEnumerable <Chat.ChannelRepresentation> chatChannels,
     Api.Models.Instance instance,
     Api.Models.Internal.RevisionInformation revision,
     DreamDaemonSecurity?securityLevel,
     bool apiValidateOnly)
     : base(chatChannels)
 {
     ServerVersion   = assemblyInformationProvider?.Version ?? throw new ArgumentNullException(nameof(assemblyInformationProvider));
     ServerPort      = serverPortProvider?.HttpApiPort ?? throw new ArgumentNullException(nameof(serverPortProvider));
     TestMerges      = testMerges?.ToList() ?? throw new ArgumentNullException(nameof(testMerges));
     InstanceName    = instance?.Name ?? throw new ArgumentNullException(nameof(instance));
     Revision        = revision ?? throw new ArgumentNullException(nameof(revision));
     SecurityLevel   = securityLevel;
     ApiValidateOnly = apiValidateOnly;
 }
Example #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PortAllocator"/> <see langword="class"/>.
 /// </summary>
 /// <param name="serverPortProvider">The value of <see cref="serverPortProvider"/>.</param>
 /// <param name="databaseContext">The value of <see cref="databaseContext"/>.</param>
 /// <param name="logger">The value of <see cref="logger"/>.</param>
 public PortAllocator(IServerPortProvider serverPortProvider, IDatabaseContext databaseContext, ILogger <PortAllocator> logger)
 {
     this.serverPortProvider = serverPortProvider ?? throw new ArgumentNullException(nameof(serverPortProvider));
     this.databaseContext    = databaseContext ?? throw new ArgumentNullException(nameof(databaseContext));
     this.logger             = logger ?? throw new ArgumentNullException(nameof(logger));
 }