public IReadOnlyList <DatabaseEntity> ListDatabases()
        {
            var databases     = new List <DatabaseEntity>();
            var blobs         = _blobStorageProvider.ListBlobs(_databaseContainerName).ToList();
            var databaseNames = new HashSet <string>(GetDatabaseNamesFromBlobs(blobs));

            foreach (var databaseName in databaseNames)
            {
                var databaseBlobs =
                    blobs.Where(blob => blob.BlobName.StartsWith(databaseName)).ToList();
                databases.Add(GetDatabase(databaseName, databaseBlobs));
            }
            return(databases.AsReadOnly());
        }
        public void ListBlobs()
        {
            var prefix = Guid.NewGuid().ToString("N");

            var prefixed   = Range.Array(10).Select(i => prefix + Guid.NewGuid().ToString("N")).ToArray();
            var unprefixed = Range.Array(13).Select(i => Guid.NewGuid().ToString("N")).ToArray();

            foreach (var n in prefixed)
            {
                BlobStorage.PutBlob(ContainerName, n, n);
            }

            foreach (var n in unprefixed)
            {
                BlobStorage.PutBlob(ContainerName, n, n);
            }

            var list = BlobStorage.ListBlobs <string>(ContainerName, prefix).ToArray();

            Assert.AreEqual(prefixed.Length, list.Length, "#A00");

            foreach (var n in list)
            {
                Assert.IsTrue(prefixed.Contains(n), "#A01");
                Assert.IsFalse(unprefixed.Contains(n), "#A02");
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="databaseName"></param>
        /// <param name="containerName"></param>
        public void ImportExisting(string databaseName, string databaseDescription, string containerName)
        {
            var container = _blobStorageProvider.GetContainer(containerName);

            if (container == null)
            {
                throw new Exception("Database container not found");
            }

            var blobs = _blobStorageProvider.ListBlobs(containerName).ToList();

            if (!blobs.Any())
            {
                throw new Exception("Container contains no database files");
            }

            var entity = CreateDatabaseEntity(containerName, null, databaseName, blobs.Count, false);

            entity.DisplayName        = databaseDescription;
            entity.CompletedTasks     = blobs.Count;
            entity.State              = DatabaseState.Ready;
            entity.TotalSize          = blobs.Sum(b => b.Length);
            entity.FileCount          = blobs.Count;
            entity.DedicatedContainer = true;
            entity.Type = blobs.Any(b => Path.GetExtension(b.BlobName).StartsWith(".p"))
                ? DatabaseType.Protein
                : DatabaseType.Nucleotide;

            _tableStorageProvider.UpsertEntity(entity);
        }
        public string GetAnalysisQueryOutput(Guid analysisId, string queryId, string filename)
        {
            var entity = _tableStorageProvider.GetEntity <AnalysisEntity>(AnalysisEntity.AllUsersPk, analysisId.ToString());

            if (entity == null)
            {
                throw new Exception("No such analysis " + analysisId);
            }

            var blobs = _blobStorageProvider.ListBlobs(entity.OutputContainer);

            var blob = blobs.FirstOrDefault(b => b.BlobName == filename);

            if (blob == null)
            {
                throw new Exception("No such query output " + filename);
            }

            return(_blobStorageProvider.GetBlobAsText(entity.OutputContainer, blob.BlobName));
        }
Beispiel #5
0
        public string GetSearchQueryOutput(Guid searchId, string queryId, string filename)
        {
            var entity = _tableStorageProvider.GetEntity <SearchEntity>(SearchEntity.AllUsersPk, searchId.ToString());

            if (entity == null)
            {
                throw new Exception("No such search " + searchId);
            }

            var blobs = _blobStorageProvider.ListBlobs(entity.OutputContainer);

            var blob = blobs.FirstOrDefault(b => b.BlobName.EndsWith(filename));

            if (blob == null)
            {
                throw new Exception("No such query output " + filename);
            }

            return(_blobStorageProvider.GetBlobAsText(entity.OutputContainer, blob.BlobName));
        }
Beispiel #6
0
 /// <summary>
 /// List and get all blobs matching the provided blob name prefix.
 /// </summary>
 /// <remarks>
 /// <para>This method is sideeffect-free, except for infrastructure effects like thread pool usage.</para>
 /// </remarks>
 public static IEnumerable <T> ListBlobs <T>(this IBlobStorageProvider provider, IBlobLocationAndType <T> locationPrefix, int skip = 0, IDataSerializer serializer = null)
 {
     return(provider.ListBlobs <T>(locationPrefix.ContainerName, locationPrefix.Path, skip, serializer));
 }
 /// <summary>
 /// Lazily enumerate all logs of the specified level, ordered with the newest entry first.
 /// </summary>
 public IEnumerable <CloudLogEntry> GetLogsOfLevel(LogLevel level, int skip = 0)
 {
     return(_blobs
            .ListBlobs <string>(LevelToContainer(level), skip: skip, serializer: _runtimeSerializer)
            .Select(ParseLogEntry));
 }