-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Abstract file access pattern for DSS provider
This is an intial change to abstract file access using IPlateTilePyramid. This interface provides a single method that will take a plate file name along with the desired level and coordinates and will retrieve the associated image. This change includes two implementations of this: - ConfigurationManagerFilePlateTilePyramid allows for a request to a given plate file and returns a stream for the level and coordinates specified. - AzurePlateTilePyramid retrieves the file from Azure blob storage This new access method has been incorporated into the DSS.aspx page and will surface the content via Azure or local storage via a configuration flag (requires a restart of the service).
- Loading branch information
1 parent
66d14e2
commit 18d4f4c
Showing
11 changed files
with
147 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using Azure.Core; | ||
using Azure.Storage.Blobs; | ||
using System; | ||
using System.Collections.Concurrent; | ||
using System.IO; | ||
|
||
namespace WWTWebservices.Azure | ||
{ | ||
public class AzurePlateTilePyramid : IPlateTilePyramid | ||
{ | ||
private readonly BlobServiceClient _service; | ||
private readonly ConcurrentDictionary<string, BlobContainerClient> _containers; | ||
|
||
public AzurePlateTilePyramid(string storageUri, TokenCredential credentials) | ||
{ | ||
_service = new BlobServiceClient(new Uri(storageUri), credentials); | ||
_containers = new ConcurrentDictionary<string, BlobContainerClient>(); | ||
} | ||
|
||
public Stream GetStream(string pathPrefix, string plateName, int level, int x, int y) | ||
{ | ||
var container = _containers.GetOrAdd(plateName, p => | ||
{ | ||
var name = Path.GetFileNameWithoutExtension(p).ToLowerInvariant(); | ||
return _service.GetBlobContainerClient(name); | ||
}); | ||
|
||
var client = container.GetBlobClient($"L{level}X{x}Y{y}.png"); | ||
var download = client.Download(); | ||
|
||
return download.Value.Content; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net48</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Azure.Storage.Blobs" Version="12.6.0" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\WWTWebservices\WWTWebservices.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Reference Include="System.Configuration" /> | ||
</ItemGroup> | ||
|
||
</Project> |
17 changes: 17 additions & 0 deletions
17
WWTWebservices/ConfigurationManagerFilePlateTilePyramid.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using System.IO; | ||
|
||
namespace WWTWebservices | ||
{ | ||
public class ConfigurationManagerFilePlateTilePyramid : IPlateTilePyramid | ||
{ | ||
public Stream GetStream(string pathPrefix, string plateName, int level, int x, int y) | ||
{ | ||
if (string.IsNullOrEmpty(pathPrefix)) | ||
{ | ||
throw new System.ArgumentException($"'{nameof(pathPrefix)}' cannot be null or empty", nameof(pathPrefix)); | ||
} | ||
|
||
return PlateTilePyramid.GetFileStream(Path.Combine(pathPrefix, plateName), level, x, y); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using System.IO; | ||
|
||
namespace WWTWebservices | ||
{ | ||
public interface IPlateTilePyramid | ||
{ | ||
Stream GetStream(string pathPrefix, string plateName, int level, int x, int y); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters