public DeploymentBasedQueueBalancer(
            ISiloStatusOracle siloStatusOracle,
            IDeploymentConfiguration deploymentConfig,
            IStreamQueueMapper queueMapper,
            bool isFixed)
        {
            if (siloStatusOracle == null)
            {
                throw new ArgumentNullException("siloStatusOracle");
            }
            if (deploymentConfig == null)
            {
                throw new ArgumentNullException("deploymentConfig");
            }
            if (queueMapper == null)
            {
                throw new ArgumentNullException("queueMapper");
            }

            this.siloStatusOracle = siloStatusOracle;
            this.deploymentConfig = deploymentConfig;
            allQueues = queueMapper.GetAllQueues().ToList();
            queueBalanceListeners = new List<IStreamQueueBalanceListener>();
            mySiloName = this.siloStatusOracle.SiloName;
            this.isFixed = isFixed;

            // register for notification of changes to silo status for any silo in the cluster
            this.siloStatusOracle.SubscribeToSiloStatusEvents(this);
        }
 public RequestUri BeginCreate(DeploymentSlotUri deploymentUri, IDeploymentConfiguration configuration)
 {
     BeginCreateDeploymentUri = deploymentUri;
     BeginCreateConfiguration = configuration;
     RunScript();
     return deploymentUri.ToRequestUri(NextRequestId);
 }
Exemplo n.º 3
0
        public DeploymentBasedQueueBalancer(
            ISiloStatusOracle siloStatusOracle,
            IDeploymentConfiguration deploymentConfig,
            bool isFixed)
        {
            if (siloStatusOracle == null)
            {
                throw new ArgumentNullException("siloStatusOracle");
            }
            if (deploymentConfig == null)
            {
                throw new ArgumentNullException("deploymentConfig");
            }

            this.siloStatusOracle = siloStatusOracle;
            this.deploymentConfig = deploymentConfig;
            immatureSilos         = new ConcurrentDictionary <SiloAddress, bool>();
            this.isFixed          = isFixed;
            isStarting            = true;

            // register for notification of changes to silo status for any silo in the cluster
            this.siloStatusOracle.SubscribeToSiloStatusEvents(this);

            // record all already active silos as already mature.
            // Even if they are not yet, they will be mature by the time I mature myself (after I become !isStarting).
            foreach (var silo in siloStatusOracle.GetApproximateSiloStatuses(true).Keys.Where(s => !s.Equals(siloStatusOracle.SiloAddress)))
            {
                immatureSilos[silo] = false;     // record as mature
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="serviceProvider"></param>
 /// <param name="siloStatusOracle"></param>
 /// <param name="deploymentConfig"></param>
 /// <param name="loggerFac"></param>
 public LeaseBasedQueueBalancer(IServiceProvider serviceProvider, ISiloStatusOracle siloStatusOracle, IDeploymentConfiguration deploymentConfig, Factory <string, Logger> loggerFac)
 {
     this.serviceProvider  = serviceProvider;
     this.deploymentConfig = deploymentConfig;
     this.siloStatusOracle = siloStatusOracle;
     this.myQueues         = new List <AcquiredQueue>();
     this.isStarting       = true;
     this.logger           = loggerFac(this.GetType().Name);
 }
Exemplo n.º 5
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="serviceProvider"></param>
 /// <param name="siloStatusOracle"></param>
 /// <param name="deploymentConfig"></param>
 /// <param name="loggerFactory"></param>
 public LeaseBasedQueueBalancer(IServiceProvider serviceProvider, ISiloStatusOracle siloStatusOracle, IDeploymentConfiguration deploymentConfig, ILoggerFactory loggerFactory)
 {
     this.serviceProvider  = serviceProvider;
     this.deploymentConfig = deploymentConfig;
     this.siloStatusOracle = siloStatusOracle;
     this.myQueues         = new List <AcquiredQueue>();
     this.isStarting       = true;
     this.loggerFactory    = loggerFactory;
     this.logger           = loggerFactory.CreateLogger <LeaseBasedQueueBalancer>();
 }
 /// <summary>
 /// Constructor
 /// </summary>
 public LeaseBasedQueueBalancer(string name, LeaseBasedQueueBalancerOptions options, IServiceProvider serviceProvider, ISiloStatusOracle siloStatusOracle, IDeploymentConfiguration deploymentConfig, ILoggerFactory loggerFactory)
 {
     this.serviceProvider  = serviceProvider;
     this.deploymentConfig = deploymentConfig;
     this.siloStatusOracle = siloStatusOracle;
     this.myQueues         = new List <AcquiredQueue>();
     this.isStarting       = true;
     this.loggerFactory    = loggerFactory;
     this.options          = options;
     this.logger           = loggerFactory.CreateLogger($"{typeof(LeaseBasedQueueBalancer).FullName}-{name}");
 }
        public RequestUri BeginCreate(DeploymentSlotUri deploymentUri, IDeploymentConfiguration configuration)
        {
            OurTrace.TraceVerbose("BeginCreate");
            var xml = configuration.MakeCreateDeploymentMessage();
            OurTrace.TraceInfo(xml);

            var response = _http.Post(deploymentUri.ToString(), xml);
            var statusCode = response.StatusCode;

            if (statusCode.IsAccepted())
                return deploymentUri.ToRequestUri(response.AzureRequestIdHeader);

            if (statusCode.IsConflict())
                return null;

            ThrowUnexpectedHttpResponse(response);
            return null; // can't be reached.
        }
        public DeploymentBasedQueueBalancer(
            ISiloStatusOracle siloStatusOracle,
            IDeploymentConfiguration deploymentConfig,
            IStreamQueueMapper queueMapper)
        {
            if (siloStatusOracle == null)
            {
                throw new ArgumentNullException("siloStatusOracle");
            }
            if (deploymentConfig == null)
            {
                throw new ArgumentNullException("deploymentConfig");
            }
            if (queueMapper == null)
            {
                throw new ArgumentNullException("queueMapper");
            }

            this.siloStatusOracle = siloStatusOracle;
            this.deploymentConfig = deploymentConfig;
            streamQueueMapper     = queueMapper;
            queueBalanceListeners = new List <IStreamQueueBalanceListener>();
            mySiloName            = this.siloStatusOracle.SiloName;
            activeSiloNames       = new List <string>();
            allSiloNames          = this.deploymentConfig.GetAllSiloInstanceNames();
            List <QueueId> allQueues = streamQueueMapper.GetAllQueues().ToList();

            resourceBalancer = new BestFitBalancer <string, QueueId>(allSiloNames, allQueues);

            // get silo names for all active silos
            foreach (SiloAddress siloAddress in this.siloStatusOracle.GetApproximateSiloStatuses(true).Keys)
            {
                string siloName;
                if (this.siloStatusOracle.TryGetSiloName(siloAddress, out siloName))
                {
                    activeSiloNames.Add(siloName);
                }
            }

            // register for notification of changes to silo status for any silo in the cluster
            this.siloStatusOracle.SubscribeToSiloStatusEvents(this);
        }
        public DeploymentBasedQueueBalancer(
            ISiloStatusOracle siloStatusOracle,
            IDeploymentConfiguration deploymentConfig,
            IStreamQueueMapper queueMapper,
            TimeSpan maturityPeriod,
            bool isFixed)
        {
            if (siloStatusOracle == null)
            {
                throw new ArgumentNullException("siloStatusOracle");
            }
            if (deploymentConfig == null)
            {
                throw new ArgumentNullException("deploymentConfig");
            }
            if (queueMapper == null)
            {
                throw new ArgumentNullException("queueMapper");
            }

            this.siloStatusOracle = siloStatusOracle;
            this.deploymentConfig = deploymentConfig;
            allQueues             = new ReadOnlyCollection <QueueId>(queueMapper.GetAllQueues().ToList());
            queueBalanceListeners = new List <IStreamQueueBalanceListener>();
            immatureSilos         = new ConcurrentDictionary <SiloAddress, bool>();
            this.isFixed          = isFixed;
            siloMaturityPeriod    = maturityPeriod;
            isStarting            = true;

            // register for notification of changes to silo status for any silo in the cluster
            this.siloStatusOracle.SubscribeToSiloStatusEvents(this);

            // record all already active silos as already mature.
            // Even if they are not yet, they will be mature by the time I mature myself (after I become !isStarting).
            foreach (var silo in siloStatusOracle.GetApproximateSiloStatuses(true).Keys.Where(s => !s.Equals(siloStatusOracle.SiloAddress)))
            {
                immatureSilos[silo] = false;     // record as mature
            }

            NotifyAfterStart().Ignore();
        }
        public DeploymentBasedQueueBalancer(
            ISiloStatusOracle siloStatusOracle,
            IDeploymentConfiguration deploymentConfig,
            IStreamQueueMapper queueMapper,
            TimeSpan maturityPeriod,
            bool isFixed)
        {
            if (siloStatusOracle == null)
            {
                throw new ArgumentNullException("siloStatusOracle");
            }
            if (deploymentConfig == null)
            {
                throw new ArgumentNullException("deploymentConfig");
            }
            if (queueMapper == null)
            {
                throw new ArgumentNullException("queueMapper");
            }

            this.siloStatusOracle = siloStatusOracle;
            this.deploymentConfig = deploymentConfig;
            allQueues = new ReadOnlyCollection<QueueId>(queueMapper.GetAllQueues().ToList());
            queueBalanceListeners = new List<IStreamQueueBalanceListener>();
            immatureSilos = new ConcurrentDictionary<SiloAddress, bool>();
            this.isFixed = isFixed;
            siloMaturityPeriod = maturityPeriod;
            isStarting = true;

            // register for notification of changes to silo status for any silo in the cluster
            this.siloStatusOracle.SubscribeToSiloStatusEvents(this);

            // record all already active silos as already mature. 
            // Even if they are not yet, they will be mature by the time I mature myself (after I become !isStarting).
            foreach (var silo in siloStatusOracle.GetApproximateSiloStatuses(true).Keys.Where(s => !s.Equals(siloStatusOracle.SiloAddress)))
            {
                immatureSilos[silo] = false;     // record as mature
            }

            NotifyAfterStart().Ignore();
        }
        public DeploymentBasedQueueBalancer(
            ISiloStatusOracle siloStatusOracle,
            IDeploymentConfiguration deploymentConfig,
            IStreamQueueMapper queueMapper)
        {
            if (siloStatusOracle == null)
            {
                throw new ArgumentNullException("siloStatusOracle");
            }
            if (deploymentConfig == null)
            {
                throw new ArgumentNullException("deploymentConfig");
            }
            if (queueMapper == null)
            {
                throw new ArgumentNullException("queueMapper");
            }

            this.siloStatusOracle = siloStatusOracle;
            this.deploymentConfig = deploymentConfig;
            streamQueueMapper = queueMapper;
            queueBalanceListeners = new List<IStreamQueueBalanceListener>();
            mySiloName = this.siloStatusOracle.SiloName;
            activeSiloNames = new List<string>();
            allSiloNames = this.deploymentConfig.GetAllSiloInstanceNames();
            List<QueueId> allQueues = streamQueueMapper.GetAllQueues().ToList();
            resourceBalancer = new BestFitBalancer<string, QueueId>(allSiloNames, allQueues);

            // get silo names for all active silos
            foreach (SiloAddress siloAddress in this.siloStatusOracle.GetApproximateSiloStatuses(true).Keys)
            {
                string siloName;
                if (this.siloStatusOracle.TryGetSiloName(siloAddress, out siloName))
                {
                    activeSiloNames.Add(siloName);
                }
            }

            // register for notification of changes to silo status for any silo in the cluster
            this.siloStatusOracle.SubscribeToSiloStatusEvents(this);
        }
        public DeploymentBasedQueueBalancer(
            ISiloStatusOracle siloStatusOracle,
            IDeploymentConfiguration deploymentConfig,
            DeploymentBasedQueueBalancerOptions options,
            IServiceProvider services,
            ILogger <DeploymentBasedQueueBalancer> logger)
            : base(services, logger)
        {
            this.siloStatusOracle = siloStatusOracle ?? throw new ArgumentNullException(nameof(siloStatusOracle));
            this.deploymentConfig = deploymentConfig ?? throw new ArgumentNullException(nameof(deploymentConfig));
            this.options          = options;

            isStarting = true;

            // record all already active silos as already mature.
            // Even if they are not yet, they will be mature by the time I mature myself (after I become !isStarting).
            immatureSilos = new ConcurrentDictionary <SiloAddress, bool>(
                from s in siloStatusOracle.GetApproximateSiloStatuses(true).Keys
                where !s.Equals(siloStatusOracle.SiloAddress)
                select new KeyValuePair <SiloAddress, bool>(s, false));
        }
Exemplo n.º 13
0
        // Creates the new deployment configuration.
        private void ProjectInitialized(object sender, SharePointProjectEventArgs e)
        {
            string[] deploymentSteps = new string[]
            {
                DeploymentStepIds.PreDeploymentCommand,
                DeploymentStepIds.RecycleApplicationPool,
                "Contoso.DeploymentSteps.UpgradeSolution",
                DeploymentStepIds.PostDeploymentCommand
            };

            string[] retractionSteps = new string[]
            {
                DeploymentStepIds.RecycleApplicationPool,
                DeploymentStepIds.RetractSolution
            };

            IDeploymentConfiguration configuration = e.Project.DeploymentConfigurations.Add(
                "Upgrade", deploymentSteps, retractionSteps);

            configuration.Description = "This is the upgrade deployment configuration";
        }
        /// <summary>
        /// Projects the initialized.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="Microsoft.VisualStudio.SharePoint.SharePointProjectEventArgs"/> instance containing the event data.</param>
        private void ProjectInitialized(object sender, SharePointProjectEventArgs e)
        {
            //Add the new configuration.
            if (!e.Project.DeploymentConfigurations.ContainsKey(CKSProperties.UpgradeDeploymentConfigurationExtension_Name))
            {
                string[] deploymentSteps = new string[]
                {
                    DeploymentStepIds.PreDeploymentCommand,
                    CustomDeploymentStepIds.CopyToSharePointRoot,
                    DeploymentStepIds.PostDeploymentCommand
                };

                string[] retractionSteps = new string[]
                {
                    DeploymentStepIds.RecycleApplicationPool,
                    DeploymentStepIds.RetractSolution
                };

                IDeploymentConfiguration configuration = e.Project.DeploymentConfigurations.Add(
                    CKSProperties.QuickDeployFilesDeploymentConfigurationExtension_Name, deploymentSteps, retractionSteps);
                configuration.Description = CKSProperties.QuickDeployFilesDeploymentConfigurationExtension_Description;
            }
        }
Exemplo n.º 15
0
 public void CreateOrReplaceDeployment(IDeploymentConfiguration configuration)
 {
     DeleteDeployment();
     _apiWithRetries.Create(_deploymentSlotUri, configuration);
     _apiWithRetries.WaitForDeploymentStatus(_deploymentSlotUri, AzureDeploymentCheckOutcome.Running);
 }
        public static IStreamQueueBalancer Create(IServiceProvider services, string name, IDeploymentConfiguration deploymentConfiguration)
        {
            var options = services.GetService <IOptionsSnapshot <DeploymentBasedQueueBalancerOptions> >().Get(name);

            return(ActivatorUtilities.CreateInstance <DeploymentBasedQueueBalancer>(services, options, deploymentConfiguration));
        }
            public bool WaitCompleted = true; // always start with true.

            #endregion Fields

            #region Methods

            public void Create(DeploymentSlotUri deploymentUri, IDeploymentConfiguration configuration)
            {
                Assert.That(WaitCompleted, Is.True);

                LastDeploymentConfiguration = configuration;

                Assert.That(deploymentUri, Is.EqualTo(ExpectedDeploymentUri));
                Assert.That(CurrentState, Is.EqualTo(AzureDeploymentCheckOutcome.NotFound));

                WaitCompleted = false;
                CurrentState = AzureDeploymentCheckOutcome.Running;
            }
 public void Create(DeploymentSlotUri deploymentUri, IDeploymentConfiguration configuration)
 {
     ExecuteAsynchronousAction(() => _managementLowLevelApi.BeginCreate(deploymentUri, configuration));
 }