Exemple #1
0
        public async Task RunAsync()
        {
            WorkerRoleConfig config     = new WorkerRoleConfig();
            YamsConfig       yamsConfig = new YamsConfigBuilder(
                // mandatory configs
                DeploymentIdUtils.CloudServiceDeploymentId,
                RoleEnvironment.CurrentRoleInstance.UpdateDomain.ToString(),
                RoleEnvironment.CurrentRoleInstance.Id,
                config.CurrentRoleInstanceLocalStoreDirectory)
                                          // optional configs
                                          .SetCheckForUpdatesPeriodInSeconds(config.UpdateFrequencyInSeconds)
                                          .SetApplicationRestartCount(config.ApplicationRestartCount)
                                          .Build();

            _yamsService = YamsServiceFactory.Create(yamsConfig,
                                                     deploymentRepositoryStorageConnectionString: config.StorageDataConnectionString,
                                                     updateSessionStorageConnectionString: config.StorageDataConnectionString);

            try
            {
                Trace.TraceInformation("Yams is starting");
                await _yamsService.Start();

                Trace.TraceInformation("Yams has started. Looking for apps with deploymentId:" + yamsConfig.ClusterDeploymentId);
                while (true)
                {
                    await Task.Delay(1000);
                }
            }
            catch (Exception ex)
            {
                Trace.TraceError(ex.ToString());
            }
        }
Exemple #2
0
        public async Task RunAsync()
        {
            WorkerRoleConfig config = new WorkerRoleConfig();
            YamsConfig yamsConfig = new YamsConfigBuilder(
                // mandatory configs
                DeploymentIdUtils.GetYamsClusterId(this.IsSingleClusterDeployment),
                RoleEnvironment.CurrentRoleInstance.UpdateDomain.ToString(),
                RoleEnvironment.CurrentRoleInstance.Id,
                config.CurrentRoleInstanceLocalStoreDirectory)
                // optional configs
                .SetCheckForUpdatesPeriodInSeconds(config.UpdateFrequencyInSeconds)
                .SetApplicationRestartCount(config.ApplicationRestartCount)
                .Build();
            _yamsService = YamsServiceFactory.Create(yamsConfig,
                deploymentRepositoryStorageConnectionString: config.StorageDataConnectionString,
                updateSessionStorageConnectionString: config.StorageDataConnectionString);

            try
            {
                Trace.TraceInformation("Yams is starting");
                await _yamsService.Start();
                Trace.TraceInformation("Yams has started. Looking for apps with deploymentId:" + yamsConfig.ClusterDeploymentId);
                while (true)
                {
                    await Task.Delay(1000);
                }
            }
            catch (Exception ex)
            {
                Trace.TraceError(ex.ToString());
            }
        }
Exemple #3
0
        private void InitializeYamsService(YamsConfig yamsConfig)
        {
            IUpdateSessionManager updateSessionManager = new StubIUpdateSessionManager()
                                                         .TryStartUpdateSession(applicationId => Task.FromResult(true))
                                                         .EndUpdateSession(applicationId => Task.FromResult(true));

            _yamsDiModule = new YamsDiModule(yamsConfig, new LocalDeploymentRepository(
                                                 _deploymentDirPath, new JsonDeploymentConfigSerializer(
                                                     new JsonSerializer(new DiagnosticsTraceWriter()))), updateSessionManager);
            _yamsService = _yamsDiModule.YamsService;
        }
Exemple #4
0
        private void InitializeYamsService(YamsConfig yamsConfig)
        {
            IUpdateSessionManager updateSessionManager = new StubIUpdateSessionManager()
                .TryStartUpdateSession(applicationId => Task.FromResult(true))
                .EndUpdateSession(applicationId => Task.FromResult(true));

            _yamsDiModule = new YamsDiModule(yamsConfig, new LocalDeploymentRepository(
                _deploymentDirPath, new JsonDeploymentConfigSerializer(
                    new JsonSerializer(new DiagnosticsTraceWriter()))), updateSessionManager);
            _yamsService = _yamsDiModule.YamsService;
        }
Exemple #5
0
        //---------------------------------------------------------------------
        private async Task RunAsync(CancellationToken cancellationToken)
        {
            // TODO: Replace the following with your own logic.
            //while (!cancellationToken.IsCancellationRequested)
            //{
            //    Trace.TraceInformation("Working");
            //    await Task.Delay(1000);
            //}

            WorkerRoleConfig config     = new WorkerRoleConfig();
            YamsConfig       yamsConfig = new YamsConfigBuilder(
                // mandatory configs
                DeploymentIdUtils.CloudServiceDeploymentId,
                RoleEnvironment.CurrentRoleInstance.UpdateDomain.ToString(),
                RoleEnvironment.CurrentRoleInstance.Id,
                config.CurrentRoleInstanceLocalStoreDirectory)
                                          // optional configs
                                          .SetCheckForUpdatesPeriodInSeconds(config.UpdateFrequencyInSeconds)
                                          .SetApplicationRestartCount(config.ApplicationRestartCount)
                                          .Build();

            this.yamsService = YamsServiceFactory.Create(yamsConfig,
                                                         deploymentRepositoryStorageConnectionString: config.StorageDataConnectionString,
                                                         updateSessionStorageConnectionString: config.StorageDataConnectionString);

            try
            {
                Trace.TraceInformation("Yams is starting");

                await this.yamsService.Start();

                Trace.TraceInformation("Yams has started. Looking for apps with deploymentId:" + yamsConfig.ClusterDeploymentId);

                //while (true)
                //{
                //    await Task.Delay(1000);
                //}

                while (!cancellationToken.IsCancellationRequested)
                {
                    //Trace.TraceInformation("Working");
                    await Task.Delay(1000);
                }
            }
            catch (Exception ex)
            {
                Trace.TraceError(ex.ToString());
            }
        }
Exemple #6
0
        public EndToEndTest()
        {
            _dataRootPath            = Path.Combine(Directory.GetCurrentDirectory(), "Data", "EndToEndTest");
            _testDirPath             = Path.Combine(Directory.GetCurrentDirectory(), "EndToEndTest");
            _deploymentDirPath       = Path.Combine(_testDirPath, "Deployments");
            _applicationsInstallPath = Path.Combine(_testDirPath, "applications");

            FileUtils.CopyDir(_dataRootPath, _deploymentDirPath, overwrite: true).Wait();

            CopyTestProcessExeToTestApps();

            var yamsConfig = new YamsConfigBuilder("deploymentId1", "1", "instanceId",
                                                   _applicationsInstallPath).SetShowApplicationProcessWindow(false).Build();

            IUpdateSessionManager updateSessionManager = new StubIUpdateSessionManager()
                                                         .TryStartUpdateSession(applicationId => Task.FromResult(true))
                                                         .EndUpdateSession(applicationId => Task.FromResult(true));

            _yamsDiModule = new YamsDiModule(yamsConfig, new LocalDeploymentRepository(_deploymentDirPath), updateSessionManager);
            _yamsService  = _yamsDiModule.YamsService;
        }
Exemple #7
0
 private void InitializeYamsService(IContainer container)
 {
     _yamsDiModule = new YamsDiModule(container);
     _yamsService  = _yamsDiModule.YamsService;
 }