示例#1
0
 public UpdateSessionStatus(IEnumerable <UpdateDomainEntity> instancesEntities, UpdateDomainEntity modifiedEntity,
                            UpdateDomainEntity updateDomainEntity)
 {
     InstancesEntities  = instancesEntities;
     ModifiedEntity     = modifiedEntity;
     UpdateDomainEntity = updateDomainEntity;
 }
示例#2
0
        public UpdateSessionTransaction MarkInstanceListAsModified()
        {
            var modifiedEntity = new UpdateDomainEntity(PartitionKey, UpdateSessionTable.ModifiedRowKey, "");

            _batchOperation.Add(TableOperation.InsertOrReplace(modifiedEntity));
            return(this);
        }
示例#3
0
        public UpdateSessionTransaction InsertOrReplaceInstance()
        {
            var instanceEntity = new UpdateDomainEntity(PartitionKey, _instanceId, _updateDomain);

            _batchOperation.Add(TableOperation.InsertOrReplace(instanceEntity));

            return(this);
        }
示例#4
0
        public UpdateSessionTransaction InsertUpdateDomain()
        {
            var updateDomainEntity = new UpdateDomainEntity(PartitionKey,
                                                            UpdateSessionTable.UpdateDomainRowKey, _updateDomain);

            _batchOperation.Add(TableOperation.Insert(updateDomainEntity));
            return(this);
        }
示例#5
0
        public Task <UpdateSessionStatus> FetchUpdateSessionStatus(string clusterId, string appId)
        {
            string partitionQuery = CreatePartitionQuery(clusterId, appId);

            TableQuery <UpdateDomainEntity> query         = new TableQuery <UpdateDomainEntity>().Where(partitionQuery);
            UpdateDomainEntity updateDomainEntity         = null;
            UpdateDomainEntity instanceListModifiedEntity = null;
            Dictionary <string, List <UpdateDomainEntity> > instanceEntitiesDict = new Dictionary <string, List <UpdateDomainEntity> >();

            foreach (UpdateDomainEntity entity in _table.ExecuteQuery(query))
            {
                if (entity.RowKey == UpdateDomainRowKey)
                {
                    updateDomainEntity = entity;
                }
                else if (entity.RowKey == ModifiedRowKey)
                {
                    instanceListModifiedEntity = entity;
                }
                else
                {
                    if (entity.Timestamp.Add(_ttl) > DateTimeOffset.Now)
                    {
                        AddInstanceEntity(instanceEntitiesDict, entity);
                    }
                }
            }

            List <UpdateDomainEntity> instancesEntities = null;
            string updateDomain = updateDomainEntity?.UpdateDomain;

            if (!string.IsNullOrWhiteSpace(updateDomain))
            {
                // filter out entities that do not match the active update domain (were leftover for some reason)
                instanceEntitiesDict.TryGetValue(updateDomain, out instancesEntities);
            }
            if (instancesEntities == null)
            {
                instancesEntities = new List <UpdateDomainEntity>();
            }

            return(Task.FromResult(new UpdateSessionStatus(instancesEntities, instanceListModifiedEntity, updateDomainEntity)));
        }
示例#6
0
        private static void AddInstanceEntity(Dictionary <string, List <UpdateDomainEntity> > instanceEntitiesDict, UpdateDomainEntity entity)
        {
            List <UpdateDomainEntity> instancesList;

            if (instanceEntitiesDict.TryGetValue(entity.UpdateDomain, out instancesList))
            {
                instancesList.Add(entity);
            }
            else
            {
                instancesList = new List <UpdateDomainEntity>();
                instancesList.Add(entity);
                instanceEntitiesDict[entity.UpdateDomain] = instancesList;
            }
        }