private IConcurrentDocument<DashboardVersion> StartDeletingOldData(IConcurrentMetadataTextStore store, IConcurrentDocument<DashboardVersion> version)
        {
            // Set status to deletion status (using etag)
            _dashboardVersionManager.StartDeletingOldData(version.ETag);

            // Refresh version
            version = _dashboardVersionManager.Read();

            while (version.Document.UpgradeState == DashboardUpgradeState.DeletingOldData)
            {
                var items = store.List(null);

                // Refresh version
                version = _dashboardVersionManager.Read();

                // Return once everything's deleted
                if (items.Count() == 0 || version.Document.UpgradeState != DashboardUpgradeState.DeletingOldData)
                {
                    return version;
                }

                // Delete blobs
                foreach (var blob in items)
                {
                    DeleteIfLatest(store, blob);
                }
            }

            return version;
        }
        private IConcurrentDocument <DashboardVersion> StartDeletingOldData(IConcurrentMetadataTextStore store, IConcurrentDocument <DashboardVersion> version)
        {
            // Set status to deletion status (using etag)
            _dashboardVersionManager.StartDeletingOldData(version.ETag);

            // Refresh version
            version = _dashboardVersionManager.Read();

            while (version.Document.UpgradeState == DashboardUpgradeState.DeletingOldData)
            {
                var items = store.List(null);

                // Refresh version
                version = _dashboardVersionManager.Read();

                // Return once everything's deleted
                if (items.Count() == 0 || version.Document.UpgradeState != DashboardUpgradeState.DeletingOldData)
                {
                    return(version);
                }

                // Delete blobs
                foreach (var blob in items)
                {
                    DeleteIfLatest(store, blob);
                }
            }

            return(version);
        }
示例#3
0
        public static IVersionedMetadataTextStore CreateBlobStore(CloudBlobClient client, string containerName,
                                                                  string directoryName)
        {
            IConcurrentMetadataTextStore innerStore = ConcurrentTextStore.CreateBlobStore(client, containerName,
                                                                                          directoryName);
            IVersionMetadataMapper versionMapper = VersionMetadataMapper.Instance;

            return(new VersionedMetadataTextStore(innerStore, versionMapper));
        }
示例#4
0
        public DashboardVersionManager(CloudBlobClient client)
        {
            if (client == null)
            {
                throw new ArgumentNullException("client");
            }

            IConcurrentMetadataTextStore innerStore = ConcurrentTextStore.CreateBlobStore(client, DashboardContainerNames.Dashboard, string.Empty);

            _store = new JsonConcurrentDocumentStore <DashboardVersion>(innerStore);
        }
        public VersionedMetadataTextStore(IConcurrentMetadataTextStore innerStore, IVersionMetadataMapper versionMapper)
        {
            if (innerStore == null)
            {
                throw new ArgumentNullException("innerStore");
            }
            else if (versionMapper == null)
            {
                throw new ArgumentNullException("versionMapper");
            }

            _innerStore    = innerStore;
            _versionMapper = versionMapper;
        }
        public VersionedMetadataTextStore(IConcurrentMetadataTextStore innerStore, IVersionMetadataMapper versionMapper)
        {
            if (innerStore == null)
            {
                throw new ArgumentNullException("innerStore");
            }
            else if (versionMapper == null)
            {
                throw new ArgumentNullException("versionMapper");
            }

            _innerStore = innerStore;
            _versionMapper = versionMapper;
        }
        public UpgradeIndexer(IPersistentQueueReader <PersistentQueueMessage> queueReader,
                              IHostIndexer hostIndexer,
                              IFunctionIndexer functionIndexer,
                              IIndexerLogWriter logWriter,
                              IDashboardVersionManager dashboardVersionReader,
                              CloudBlobClient client)
            : base(queueReader, hostIndexer, functionIndexer, logWriter)
        {
            _dashboardVersionManager = dashboardVersionReader;
            _client         = client;
            _functionsStore = ConcurrentTextStore.CreateBlobStore(_client, DashboardContainerNames.Dashboard, DashboardDirectoryNames.FunctionsFlat);
            _logsStore      = ConcurrentTextStore.CreateBlobStore(_client, DashboardContainerNames.Dashboard, DashboardDirectoryNames.Logs);

            // From archive back to output
            _upgradeQueueReader = new PersistentQueueReader <PersistentQueueMessage>(client.GetContainerReference(ContainerNames.HostArchive),
                                                                                     client.GetContainerReference(ContainerNames.HostOutput));
        }
        public UpgradeIndexer(IPersistentQueueReader<PersistentQueueMessage> queueReader,
            IHostIndexer hostIndexer,
            IFunctionIndexer functionIndexer,
            IIndexerLogWriter logWriter,
            IDashboardVersionManager dashboardVersionReader,
            CloudBlobClient client)
            : base(queueReader, hostIndexer, functionIndexer, logWriter)
        {
            _dashboardVersionManager = dashboardVersionReader;
            _client = client;
            _functionsStore = ConcurrentTextStore.CreateBlobStore(_client, DashboardContainerNames.Dashboard, DashboardDirectoryNames.FunctionsFlat);
            _logsStore = ConcurrentTextStore.CreateBlobStore(_client, DashboardContainerNames.Dashboard, DashboardDirectoryNames.Logs);

            // From archive back to output
            _upgradeQueueReader = new PersistentQueueReader<PersistentQueueMessage>(client.GetContainerReference(ContainerNames.HostArchive),
                client.GetContainerReference(ContainerNames.HostOutput));
        }
        private void DeleteIfLatest(IConcurrentMetadataTextStore store, ConcurrentMetadata blob)
        {
            bool               deleted      = false;
            string             previousETag = null;
            ConcurrentMetadata currentItem;

            for (currentItem = blob;
                 !deleted && currentItem != null;
                 currentItem = store.ReadMetadata(blob.Id))
            {
                string currentETag = currentItem.ETag;

                // Prevent an infinite loop if _innerStore erroneously returns false from TryDelete when a retry won't
                // help. (The inner store should throw rather than return false in that case.)
                if (currentETag == previousETag)
                {
                    throw new InvalidOperationException("The operation stopped making progress.");
                }

                previousETag = currentETag;
                deleted      = _functionsStore.TryDelete(blob.Id, blob.ETag);
            }
        }
 private RecentInvocationIndexByParentWriter(IConcurrentMetadataTextStore store)
 {
     _store = store;
 }
示例#11
0
 public static IConcurrentMetadataDocumentStore<TDocument> CreateJsonBlobStore<TDocument>(CloudBlobClient client,
     string containerName, string directoryName)
 {
     IConcurrentMetadataTextStore innerStore = ConcurrentTextStore.CreateBlobStore(client, containerName, directoryName);
     return new JsonConcurrentDocumentStore<TDocument>(innerStore);
 }
 private static VersionedMetadataTextStore CreateProductUnderTest(IConcurrentMetadataTextStore innerStore,
     IVersionMetadataMapper metadataMapper)
 {
     return new VersionedMetadataTextStore(innerStore, metadataMapper);
 }
 public JsonConcurrentDocumentStore(IConcurrentMetadataTextStore innerStore)
 {
     _innerStore = innerStore;
 }
 private RecentInvocationIndexWriter(IConcurrentMetadataTextStore store)
 {
     _store = store;
 }
        private void DeleteIfLatest(IConcurrentMetadataTextStore store, ConcurrentMetadata blob)
        {
            bool deleted = false;
            string previousETag = null;
            ConcurrentMetadata currentItem;

            for (currentItem = blob;
                !deleted && currentItem != null;
                currentItem = store.ReadMetadata(blob.Id))
            {
                string currentETag = currentItem.ETag;

                // Prevent an infinite loop if _innerStore erroneously returns false from TryDelete when a retry won't
                // help. (The inner store should throw rather than return false in that case.)
                if (currentETag == previousETag)
                {
                    throw new InvalidOperationException("The operation stopped making progress.");
                }

                previousETag = currentETag;
                deleted = _functionsStore.TryDelete(blob.Id, blob.ETag);
            }
        }