10877: Configurable base URL for Azure storage, e.g., StorageBaseURL: core.usgovcloud...
[arvados.git] / services / keepstore / azure_blob_volume.go
index 220744c25c5ba829de41d330b52332e5864dfc4a..a28f8b7f732ba1c2df8e862b6fceb9d9b7aaf604 100644 (file)
@@ -97,6 +97,7 @@ func init() {
 type AzureBlobVolume struct {
        StorageAccountName    string
        StorageAccountKeyFile string
+       StorageBaseURL        string // "" means default, "core.windows.net"
        ContainerName         string
        AzureReplication      int
        ReadOnly              bool
@@ -136,7 +137,10 @@ func (v *AzureBlobVolume) Start() error {
        if err != nil {
                return err
        }
-       v.azClient, err = storage.NewBasicClient(v.StorageAccountName, accountKey)
+       if v.StorageBaseURL == "" {
+               v.StorageBaseURL = storage.DefaultBaseURL
+       }
+       v.azClient, err = storage.NewClient(v.StorageAccountName, accountKey, v.StorageBaseURL, storage.DefaultAPIVersion, true)
        if err != nil {
                return fmt.Errorf("creating Azure storage client: %s", err)
        }
@@ -634,13 +638,15 @@ func (v *AzureBlobVolume) InternalStats() interface{} {
 
 type azureBlobStats struct {
        statsTicker
-       Ops            uint64
-       GetOps         uint64
-       GetRangeOps    uint64
-       CreateOps      uint64
-       SetMetadataOps uint64
-       DelOps         uint64
-       ListOps        uint64
+       Ops              uint64
+       GetOps           uint64
+       GetRangeOps      uint64
+       GetMetadataOps   uint64
+       GetPropertiesOps uint64
+       CreateOps        uint64
+       SetMetadataOps   uint64
+       DelOps           uint64
+       ListOps          uint64
 }
 
 func (s *azureBlobStats) TickErr(err error) {
@@ -670,14 +676,14 @@ func (c *azureBlobClient) ContainerExists(cname string) (bool, error) {
 }
 
 func (c *azureBlobClient) GetBlobMetadata(cname, bname string) (map[string]string, error) {
-       c.stats.Tick(&c.stats.Ops)
+       c.stats.Tick(&c.stats.Ops, &c.stats.GetMetadataOps)
        m, err := c.client.GetBlobMetadata(cname, bname)
        c.stats.TickErr(err)
        return m, err
 }
 
 func (c *azureBlobClient) GetBlobProperties(cname, bname string) (*storage.BlobProperties, error) {
-       c.stats.Tick(&c.stats.Ops)
+       c.stats.Tick(&c.stats.Ops, &c.stats.GetPropertiesOps)
        p, err := c.client.GetBlobProperties(cname, bname)
        c.stats.TickErr(err)
        return p, err