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;
        }
Ejemplo n.º 2
0
        public void LogFunctionStarted(FunctionInstanceSnapshot snapshot)
        {
            // Which operation to run depends on whether or not the entity currently exists in the "queued" status.
            IConcurrentDocument <FunctionInstanceSnapshot> existingSnapshot = _store.Read(GetId(snapshot));

            bool previouslyQueued;

            // If the existing entity doesn't contain a StartTime, it must be in the "queued" status.
            if (existingSnapshot != null && existingSnapshot.Document != null && !existingSnapshot.Document.StartTime.HasValue)
            {
                previouslyQueued = true;
            }
            else
            {
                previouslyQueued = false;
            }

            if (!previouslyQueued)
            {
                LogFunctionStartedWhenNotPreviouslyQueued(snapshot);
            }
            else
            {
                LogFunctionStartedWhenPreviouslyQueued(snapshot, existingSnapshot.ETag);
            }
        }
Ejemplo n.º 3
0
        public FunctionStatistics Lookup(string functionId)
        {
            IConcurrentDocument <FunctionStatistics> result = _store.Read(functionId);

            if (result == null)
            {
                return(null);
            }

            return(result.Document);
        }
Ejemplo n.º 4
0
        private IConcurrentDocument <DashboardVersion> StartRestoringArchive(IConcurrentDocument <DashboardVersion> version)
        {
            const int IndexerPollIntervalMilliseconds = 5000;

            _dashboardVersionManager.StartRestoringArchive(version.ETag);

            PersistentQueueMessage message = _upgradeQueueReader.Dequeue();

            int count = 0;

            do
            {
                while (message != null)
                {
                    version = _dashboardVersionManager.Read();
                    if (version.Document.UpgradeState != DashboardUpgradeState.RestoringArchive)
                    {
                        _upgradeQueueReader.TryMakeItemVisible(message);
                        return(version);
                    }

                    // Delete auto-"archives" from host-archive back to host-output.
                    _upgradeQueueReader.Delete(message);

                    message = _upgradeQueueReader.Dequeue();
                }

                version = _dashboardVersionManager.Read();
                if (version.Document.UpgradeState != DashboardUpgradeState.RestoringArchive)
                {
                    return(version);
                }

                // Get items left
                // while limiting pagination to first page since we're only interested in
                // knowing if we're out of items.
                count = _upgradeQueueReader.Count(1);
                if (count > 0)
                {
                    // wait for a while before resuming
                    Thread.Sleep(IndexerPollIntervalMilliseconds);
                }
            }while (count > 0);

            return(version);
        }
Ejemplo n.º 5
0
        private bool TryUpdateEntity(string functionId, Action <FunctionStatistics> modifier)
        {
            IConcurrentDocument <FunctionStatistics> result = _store.Read(functionId);

            if (result == null || result.Document == null)
            {
                FunctionStatistics statistics = new FunctionStatistics();
                modifier.Invoke(statistics);
                return(_store.TryCreate(functionId, statistics));
            }
            else
            {
                FunctionStatistics statistics = result.Document;
                modifier.Invoke(statistics);
                return(_store.TryUpdate(functionId, result.ETag, statistics));
            }
        }
Ejemplo n.º 6
0
        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);
        }
Ejemplo n.º 7
0
 private void FinishUpdate(IConcurrentDocument <DashboardVersion> version)
 {
     _dashboardVersionManager.FinishUpgrade(version.ETag);
 }
 private void FinishUpdate(IConcurrentDocument<DashboardVersion> version)
 {
     _dashboardVersionManager.FinishUpgrade(version.ETag);
 }
        private IConcurrentDocument<DashboardVersion> StartRestoringArchive(IConcurrentDocument<DashboardVersion> version)
        {
            const int IndexerPollIntervalMilliseconds = 5000;

            _dashboardVersionManager.StartRestoringArchive(version.ETag);

            PersistentQueueMessage message = _upgradeQueueReader.Dequeue();

            int count = 0;

            do
            {
                while (message != null)
                {
                    version = _dashboardVersionManager.Read();
                    if (version.Document.UpgradeState != DashboardUpgradeState.RestoringArchive)
                    {
                        _upgradeQueueReader.TryMakeItemVisible(message);
                        return version;
                    }

                    // Delete auto-"archives" from host-archive back to host-output.
                    _upgradeQueueReader.Delete(message);

                    message = _upgradeQueueReader.Dequeue();
                }

                version = _dashboardVersionManager.Read();
                if (version.Document.UpgradeState != DashboardUpgradeState.RestoringArchive)
                {
                    return version;
                }

                // Get items left
                // while limiting pagination to first page since we're only interested in
                // knowing if we're out of items.
                count = _upgradeQueueReader.Count(1);
                if (count > 0)
                {
                    // wait for a while before resuming
                    Thread.Sleep(IndexerPollIntervalMilliseconds);
                }
            }
            while (count > 0);

            return version;
        }