Esempio n. 1
0
        /// <summary>
        /// Deletes all the logs of a level and older than the provided date.
        /// </summary>
        public void DeleteOldLogsOfLevel(LogLevel level, DateTime olderThanUtc)
        {
            // Algorithm:
            // Iterate over the logs, queuing deletions up to 50 items at a time,
            // then restart; continue until no deletions are queued

            var deleteQueue   = new List <string>(DeleteBatchSize);
            var blobContainer = LevelToContainer(level);

            do
            {
                deleteQueue.Clear();

                foreach (var blobName in _blobs.ListBlobNames(blobContainer, string.Empty))
                {
                    var dateTime = ParseDateTimeFromName(blobName);
                    if (dateTime < olderThanUtc)
                    {
                        deleteQueue.Add(blobName);
                    }

                    if (deleteQueue.Count == DeleteBatchSize)
                    {
                        break;
                    }
                }

                foreach (var blobName in deleteQueue)
                {
                    _blobs.DeleteBlobIfExist(blobContainer, blobName);
                }
            } while (deleteQueue.Count > 0);
        }
Esempio n. 2
0
        // UpdateBlobIfExistOrDeleteAsync

        public static Task <BlobWithETag <T> > UpdateBlobIfExistOrDeleteAsync <T>(this IBlobStorageProvider provider, string containerName, string blobName,
                                                                                  Func <T, Maybe <T> > update, CancellationToken cancellationToken, IDataSerializer serializer = null)
        {
            return(provider.UpsertBlobOrSkipAsync(containerName, blobName, () => Maybe <T> .Empty, update, cancellationToken, serializer)
                   .Then(b =>
            {
                if (b == null)
                {
                    provider.DeleteBlobIfExist(containerName, blobName);
                }

                return b;
            }));
        }
Esempio n. 3
0
 /// <summary>
 /// Deletes a blob if it exists.
 /// </summary>
 /// <remarks>
 /// <para>This method is idempotent.</para>
 /// </remarks>
 public static bool DeleteBlobIfExist(this IBlobStorageProvider provider, IBlobLocation location)
 {
     return(provider.DeleteBlobIfExist(location.ContainerName, location.Path));
 }
 public void FixtureSetUp()
 {
     BlobStorage.CreateContainerIfNotExist(ContainerName);
     BlobStorage.DeleteBlobIfExist(ContainerName, BlobName);
 }
Esempio n. 5
0
 /// <summary>
 /// Remove the cloud configuration file.
 /// </summary>
 public void RemoveConfiguration()
 {
     _blobs.DeleteBlobIfExist(
         AssemblyLoader.ContainerName,
         AssemblyLoader.ConfigurationBlobName);
 }
Esempio n. 6
0
 /// <summary>
 /// Remove the state information of a cloud service
 /// </summary>
 public void ResetServiceState(string serviceName)
 {
     _blobs.DeleteBlobIfExist(new CloudServiceStateName(serviceName));
 }
Esempio n. 7
0
 /// <summary>Deletes the counter.</summary>
 /// <returns><c>true</c> if the counter has actually been deleted by the call,
 /// and <c>false</c> otherwise.</returns>
 public bool Delete()
 {
     return(_provider.DeleteBlobIfExist(_containerName, _blobName));
 }
Esempio n. 8
0
 /// <summary>
 /// Remove the scheduling information of a cloud service
 /// </summary>
 public void ResetSchedule(string serviceName)
 {
     _blobs.DeleteBlobIfExist(new ScheduledServiceStateName(serviceName));
 }