Skip to content
This repository has been archived by the owner on Aug 1, 2024. It is now read-only.

Commit

Permalink
Merge pull request #45 from sozler/master
Browse files Browse the repository at this point in the history
Azure Storage Client Library 3.2.0
  • Loading branch information
vinaysh-msft committed May 7, 2014
2 parents 42db841 + 45af71f commit b756796
Show file tree
Hide file tree
Showing 19 changed files with 160 additions and 69 deletions.
28 changes: 16 additions & 12 deletions Lib/ClassLibraryCommon/Core/Util/AsyncStreamCopier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -314,24 +314,28 @@ private static void MaximumCopyTimeCallback(object copier, bool timedOut)
[SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "Reviewed.")]
private static void ForceAbort(AsyncStreamCopier<T> copier, bool timedOut)
{
if (copier.state.Req != null)
ExecutionState<T> state = copier.state;
if (state != null)
{
try
if (state.Req != null)
{
copier.state.ReqTimedOut = timedOut;
try
{
state.ReqTimedOut = timedOut;
#if !WINDOWS_PHONE
copier.state.Req.Abort();
state.Req.Abort();
#endif
}
catch (Exception)
{
// no op
}
}
catch (Exception)
{
// no op
}
}

copier.exceptionRef = timedOut ?
Exceptions.GenerateTimeoutException(copier.state.Cmd != null ? copier.state.Cmd.CurrentResult : null, null) :
Exceptions.GenerateCancellationException(copier.state.Cmd != null ? copier.state.Cmd.CurrentResult : null, null);
copier.exceptionRef = timedOut ?
Exceptions.GenerateTimeoutException(state.Cmd != null ? state.Cmd.CurrentResult : null, null) :
Exceptions.GenerateCancellationException(state.Cmd != null ? state.Cmd.CurrentResult : null, null);
}
}

/// <summary>
Expand Down
56 changes: 39 additions & 17 deletions Lib/Common/CloudStorageAccount.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ public sealed class CloudStorageAccount
#if WINDOWS_PHONE
internal
#else
public
#endif
static bool UseV1MD5
public
#endif
static bool UseV1MD5
{
get { return version1MD5; }
set { version1MD5 = value; }
Expand Down Expand Up @@ -120,13 +120,6 @@ static bool UseV1MD5
/// </summary>
private const string DevstoreAccountKey = "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==";

/// <summary>
/// The credentials string used to test for the development storage credentials.
/// </summary>
private const string DevstoreCredentialInString =
CloudStorageAccount.AccountNameSettingString + "=" + DevstoreAccountName + ";" +
CloudStorageAccount.AccountKeySettingString + "=" + DevstoreAccountKey;

/// <summary>
/// The suffix appended to account in order to access secondary location for read only access.
/// </summary>
Expand Down Expand Up @@ -330,6 +323,11 @@ public Uri BlobEndpoint
{
get
{
if (this.BlobStorageUri == null)
{
return null;
}

return this.BlobStorageUri.PrimaryUri;
}
}
Expand All @@ -342,6 +340,11 @@ public Uri QueueEndpoint
{
get
{
if (this.QueueStorageUri == null)
{
return null;
}

return this.QueueStorageUri.PrimaryUri;
}
}
Expand All @@ -354,6 +357,11 @@ public Uri TableEndpoint
{
get
{
if (this.TableStorageUri == null)
{
return null;
}

return this.TableStorageUri.PrimaryUri;
}
}
Expand Down Expand Up @@ -510,7 +518,7 @@ public string ToString(bool exportSecrets)
if (this.Settings == null)
{
this.Settings = new Dictionary<string, string>();

if (this.DefaultEndpoints)
{
this.Settings.Add(DefaultEndpointsProtocolSettingString, this.BlobEndpoint.Scheme);
Expand Down Expand Up @@ -540,7 +548,7 @@ public string ToString(bool exportSecrets)
}

List<string> listOfSettings = this.Settings.Select(pair => string.Format(CultureInfo.InvariantCulture, "{0}={1}", pair.Key, pair.Value)).ToList();

if (this.Credentials != null && !this.IsDevStoreAccount)
{
listOfSettings.Add(this.Credentials.ToString(exportSecrets));
Expand All @@ -559,7 +567,7 @@ private static CloudStorageAccount GetDevelopmentStorageAccount(Uri proxyUri)
UriBuilder builder = proxyUri != null ?
new UriBuilder(proxyUri.Scheme, proxyUri.Host) :
new UriBuilder("http", "127.0.0.1");

builder.Path = DevstoreAccountName;

builder.Port = 10000;
Expand All @@ -571,8 +579,22 @@ private static CloudStorageAccount GetDevelopmentStorageAccount(Uri proxyUri)
builder.Port = 10002;
Uri tableEndpoint = builder.Uri;

builder.Path = DevstoreAccountName + SecondaryLocationAccountSuffix;

builder.Port = 10000;
Uri blobSecondaryEndpoint = builder.Uri;

builder.Port = 10001;
Uri queueSecondaryEndpoint = builder.Uri;

builder.Port = 10002;
Uri tableSecondaryEndpoint = builder.Uri;

StorageCredentials credentials = new StorageCredentials(DevstoreAccountName, DevstoreAccountKey);
CloudStorageAccount account = new CloudStorageAccount(credentials, blobEndpoint, queueEndpoint, tableEndpoint);
CloudStorageAccount account = new CloudStorageAccount(credentials,
new StorageUri(blobEndpoint, blobSecondaryEndpoint),
new StorageUri(queueEndpoint, queueSecondaryEndpoint),
new StorageUri(tableEndpoint, tableSecondaryEndpoint));

account.Settings = new Dictionary<string, string>();
account.Settings.Add(UseDevelopmentStorageSettingString, "true");
Expand Down Expand Up @@ -1074,7 +1096,7 @@ private static StorageUri ConstructQueueEndpoint(string scheme, string accountNa
{
throw new ArgumentNullException("scheme");
}

if (string.IsNullOrEmpty(accountName))
{
throw new ArgumentNullException("accountName");
Expand Down Expand Up @@ -1130,8 +1152,8 @@ private static StorageUri ConstructTableEndpoint(string scheme, string accountNa
if (string.IsNullOrEmpty(scheme))
{
throw new ArgumentNullException("scheme");
}
}

if (string.IsNullOrEmpty(accountName))
{
throw new ArgumentNullException("accountName");
Expand Down
2 changes: 1 addition & 1 deletion Lib/Common/Shared/Protocol/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ static HeaderConstants()
/// <summary>
/// Specifies the value to use for UserAgent header.
/// </summary>
public const string UserAgentProductVersion = "3.1.0.1";
public const string UserAgentProductVersion = "3.2.0";

/// <summary>
/// Master Windows Azure Storage header prefix.
Expand Down
28 changes: 24 additions & 4 deletions Lib/Common/StorageUri.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ namespace Microsoft.WindowsAzure.Storage
using Microsoft.WindowsAzure.Storage.Core.Util;
using Microsoft.WindowsAzure.Storage.RetryPolicies;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;

#if WINDOWS_RT
using Windows.Foundation.Metadata;
Expand All @@ -32,7 +34,7 @@ namespace Microsoft.WindowsAzure.Storage
/// </summary>
public sealed class StorageUri
#if !WINDOWS_RT
: IEquatable<StorageUri>
: IEquatable<StorageUri>
#endif
{
private Uri primaryUri;
Expand Down Expand Up @@ -90,10 +92,28 @@ public StorageUri(Uri primaryUri)
/// <param name="secondaryUri">The <see cref="System.Uri"/> for the secondary endpoint.</param>
public StorageUri(Uri primaryUri, Uri secondaryUri)
{
if ((primaryUri != null) && (secondaryUri != null) &&
(primaryUri.PathAndQuery != secondaryUri.PathAndQuery))
if ((primaryUri != null) && (secondaryUri != null))
{
throw new ArgumentException(SR.StorageUriMustMatch, "secondaryUri");
bool primaryUriPathStyle = CommonUtility.UsePathStyleAddressing(primaryUri);
bool secondaryUriPathStyle = CommonUtility.UsePathStyleAddressing(secondaryUri);

if (!primaryUriPathStyle && !secondaryUriPathStyle)
{
if (primaryUri.PathAndQuery != secondaryUri.PathAndQuery)
{
throw new ArgumentException(SR.StorageUriMustMatch, "secondaryUri");
}
}
else
{
IEnumerable<string> primaryUriSegments = primaryUri.Segments.Skip(primaryUriPathStyle ? 2 : 0);
IEnumerable<string> secondaryUriSegments = secondaryUri.Segments.Skip(secondaryUriPathStyle ? 2 : 0);

if (!primaryUriSegments.SequenceEqual(secondaryUriSegments) || (primaryUri.Query != secondaryUri.Query))
{
throw new ArgumentException(SR.StorageUriMustMatch, "secondaryUri");
}
}
}

this.PrimaryUri = primaryUri;
Expand Down
8 changes: 4 additions & 4 deletions Lib/Common/Table/TableEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,15 @@ public TableEntity(string partitionKey, string rowKey)
public DateTimeOffset Timestamp { get; set; }

/// <summary>
/// Gets or sets the entity's current ETag. Set this value to '*' in order to blindly overwrite an entity as part of an update operation.
/// Gets or sets the entity's ETag. Set this value to '*' in order to force an overwrite to an entity as part of an update operation.
/// </summary>
/// <value>A string containing the ETag for the entity.</value>
/// <value>A string containing the ETag value for the entity.</value>
public string ETag { get; set; }

/// <summary>
/// Deserializes this <see cref="TableEntity"/> instance using the specified <see cref="IDictionary{TKey,TValue}"/> of property names to <see cref="EntityProperty"/> data typed values.
/// Deserializes the entity using the specified <see cref="IDictionary{TKey,TValue}"/> that maps property names to typed <see cref="EntityProperty"/> values.
/// </summary>
/// <param name="properties">An <see cref="IDictionary{TKey,TValue}"/> object that maps string property names to <see cref="EntityProperty"/> data values to deserialize and store in this table entity instance.</param>
/// <param name="properties">An <see cref="IDictionary{TKey,TValue}"/> object that maps property names to typed <see cref="EntityProperty"/> values.</param>
/// <param name="operationContext">An <see cref="OperationContext"/> object that represents the context for the current operation.</param>
public virtual void ReadEntity(IDictionary<string, EntityProperty> properties, OperationContext operationContext)
{
Expand Down
2 changes: 1 addition & 1 deletion Lib/WindowsAzure.Storage-Preview.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package >
<metadata>
<id>WindowsAzure.Storage-Preview</id>
<version>3.1.0.1-preview</version>
<version>3.2.0-preview</version>
<title>Windows Azure Storage</title>
<authors>Microsoft</authors>
<owners>Microsoft</owners>
Expand Down
4 changes: 2 additions & 2 deletions Lib/WindowsDesktop/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("3.1.0.1")]
[assembly: AssemblyFileVersion("3.1.0.1")]
[assembly: AssemblyVersion("3.2.0.0")]
[assembly: AssemblyFileVersion("3.2.0.0")]

#if SIGN
[assembly: InternalsVisibleTo(
Expand Down
2 changes: 1 addition & 1 deletion Lib/WindowsDesktop/WindowsAzure.Storage.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>WindowsAzure.Storage</id>
<version>3.1.0.1</version>
<version>3.2.0</version>
<title>Windows Azure Storage</title>
<authors>Microsoft</authors>
<owners>Microsoft</owners>
Expand Down
4 changes: 2 additions & 2 deletions Lib/WindowsPhone/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("3.1.0.1")]
[assembly: AssemblyFileVersion("3.1.0.1")]
[assembly: AssemblyVersion("3.2.0.0")]
[assembly: AssemblyFileVersion("3.2.0.0")]
[assembly: NeutralResourcesLanguageAttribute("en-US")]

#if SIGN
Expand Down
4 changes: 2 additions & 2 deletions Lib/WindowsRuntime/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("3.1.0.1")]
[assembly: AssemblyFileVersion("3.1.0.1")]
[assembly: AssemblyVersion("3.2.0.0")]
[assembly: AssemblyFileVersion("3.2.0.0")]
[assembly: ComVisible(false)]

#if SIGN
Expand Down
4 changes: 2 additions & 2 deletions Lib/WindowsRuntimeTable/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("3.1.0.1")]
[assembly: AssemblyFileVersion("3.1.0.1")]
[assembly: AssemblyVersion("3.2.0.0")]
[assembly: AssemblyFileVersion("3.2.0.0")]
[assembly: ComVisible(false)]

#if SIGN
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package >
<metadata>
<id>WindowsAzure.Storage.Table-Preview</id>
<version>3.1.0.1-preview</version>
<version>3.2.0-preview</version>
<title>Windows Azure Storage Tables Extension for Windows Runtime</title>
<authors>Microsoft</authors>
<owners>Microsoft</owners>
Expand All @@ -16,7 +16,7 @@ Windows Azure Storage team's blog - http://blogs.msdn.com/b/windowsazurestorage/
<summary>A table extension library for Windows Runtime for working with Windows Azure Storage tables.</summary>
<tags>Microsoft, Azure, Storage, Table, Scalable, winrt, windowsazureofficial</tags>
<dependencies>
<dependency id="WindowsAzure.Storage-Preview" version="3.1.0.1-preview" />
<dependency id="WindowsAzure.Storage-Preview" version="3.2.0-preview" />
</dependencies>
<frameworkAssemblies>
<frameworkAssembly assemblyName="System.Xml" targetFramework="" />
Expand Down
12 changes: 6 additions & 6 deletions Test/Common/Core/CloudStorageAccountTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -328,9 +328,9 @@ public void CloudStorageAccountDevelopmentStorageAccount()
Assert.AreEqual(devstoreAccount.BlobEndpoint, new Uri("http://127.0.0.1:10000/devstoreaccount1"));
Assert.AreEqual(devstoreAccount.QueueEndpoint, new Uri("http://127.0.0.1:10001/devstoreaccount1"));
Assert.AreEqual(devstoreAccount.TableEndpoint, new Uri("http://127.0.0.1:10002/devstoreaccount1"));
Assert.IsNull(devstoreAccount.BlobStorageUri.SecondaryUri);
Assert.IsNull(devstoreAccount.QueueStorageUri.SecondaryUri);
Assert.IsNull(devstoreAccount.TableStorageUri.SecondaryUri);
Assert.AreEqual(devstoreAccount.BlobStorageUri.SecondaryUri, new Uri("http://127.0.0.1:10000/devstoreaccount1-secondary"));
Assert.AreEqual(devstoreAccount.QueueStorageUri.SecondaryUri, new Uri("http://127.0.0.1:10001/devstoreaccount1-secondary"));
Assert.AreEqual(devstoreAccount.TableStorageUri.SecondaryUri, new Uri("http://127.0.0.1:10002/devstoreaccount1-secondary"));

string devstoreAccountToStringWithSecrets = devstoreAccount.ToString(true);
CloudStorageAccount testAccount = CloudStorageAccount.Parse(devstoreAccountToStringWithSecrets);
Expand Down Expand Up @@ -686,9 +686,9 @@ public void CloudStorageAccountDevStoreProxyUri()
Assert.AreEqual(new Uri("http://ipv4.fiddler:10000/devstoreaccount1"), account.BlobEndpoint);
Assert.AreEqual(new Uri("http://ipv4.fiddler:10001/devstoreaccount1"), account.QueueEndpoint);
Assert.AreEqual(new Uri("http://ipv4.fiddler:10002/devstoreaccount1"), account.TableEndpoint);
Assert.IsNull(account.BlobStorageUri.SecondaryUri);
Assert.IsNull(account.QueueStorageUri.SecondaryUri);
Assert.IsNull(account.TableStorageUri.SecondaryUri);
Assert.AreEqual(new Uri("http://ipv4.fiddler:10000/devstoreaccount1-secondary"), account.BlobStorageUri.SecondaryUri);
Assert.AreEqual(new Uri("http://ipv4.fiddler:10001/devstoreaccount1-secondary"), account.QueueStorageUri.SecondaryUri);
Assert.AreEqual(new Uri("http://ipv4.fiddler:10002/devstoreaccount1-secondary"), account.TableStorageUri.SecondaryUri);
}

[TestMethod]
Expand Down
Loading

0 comments on commit b756796

Please sign in to comment.