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

Commit be6fa3c

Browse files
committed
Merge pull request #63 from pemari-msft/master
Storage Client Library - 4.1.0
2 parents d71af73 + a5abcf9 commit be6fa3c

File tree

64 files changed

+1979
-515
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+1979
-515
lines changed

Lib/ClassLibraryCommon/Analytics/CloudAnalyticsClient.cs

Lines changed: 109 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ namespace Microsoft.WindowsAzure.Storage.Analytics
2626
using System;
2727
using System.Collections.Generic;
2828
using System.Globalization;
29+
using System.IO;
2930
using System.Linq;
31+
using System.Text;
3032

3133
/// <summary>
3234
/// Provides a client-side logical representation for Microsoft Azure Storage Analytics.
@@ -45,10 +47,10 @@ public sealed class CloudAnalyticsClient
4547
/// <summary>
4648
/// Initializes a new instance of the <see cref="CloudAnalyticsClient"/> class using the specified Blob and Table service endpoints
4749
/// and account credentials.
50+
/// </summary>
4851
/// <param name="blobStorageUri">A <see cref="StorageUri"/> object containing the Blob service endpoint to use to create the client.</param>
4952
/// <param name="tableStorageUri">A <see cref="StorageUri"/> object containing the Table service endpoint to use to create the client.</param>
5053
/// <param name="credentials">A <see cref="StorageCredentials"/> object.</param>
51-
/// </summary>
5254
public CloudAnalyticsClient(StorageUri blobStorageUri, StorageUri tableStorageUri, StorageCredentials credentials)
5355
{
5456
CommonUtility.AssertNotNull("blobStorageUri", blobStorageUri);
@@ -190,7 +192,7 @@ public CloudTable GetCapacityTable()
190192

191193
#if SYNC
192194
/// <summary>
193-
/// Returns an enumerable collection of logs stored as blobs, retrieved lazily.
195+
/// Returns an enumerable collection of log blobs containing Analytics log records. The blobs are retrieved lazily.
194196
/// </summary>
195197
/// <param name="service">A <see cref="StorageService"/> enumeration value.</param>
196198
public IEnumerable<ICloudBlob> ListLogs(StorageService service)
@@ -199,16 +201,16 @@ public IEnumerable<ICloudBlob> ListLogs(StorageService service)
199201
}
200202

201203
/// <summary>
202-
/// Returns an enumerable collection of logs stored as blobs, retrieved lazily.
204+
/// Returns an enumerable collection of log blobs containing Analytics log records. The blobs are retrieved lazily.
203205
/// </summary>
204206
/// <param name="service">A <see cref="StorageService"/> enumeration value.</param>
205-
/// <param name="operations">A <see cref="LoggingOperations"/> enumeration value that indicates which log types to return.</param>
207+
/// <param name="operations">A <see cref="LoggingOperations"/> enumeration value that indicates the types of logging operations on which to filter the log blobs.</param>
206208
/// <param name="details">A <see cref="BlobListingDetails"/> enumeration value that indicates whether or not blob metadata should be returned. Only <c>None</c> and <c>Metadata</c> are valid values. </param>
207209
/// <param name="options">A <see cref="BlobRequestOptions"/> object that specifies additional options for the request.</param>
208210
/// <param name="operationContext">An <see cref="OperationContext"/> object that represents the context for the current operation.</param>
209211
/// <returns>An enumerable collection of objects that implement <see cref="ICloudBlob"/> and are retrieved lazily.</returns>
210-
/// <remarks>Note that specifying a log type for the <paramref name="operations"/> parameter will return any log that contains the specified log type,
211-
/// even if that log also includes other log types. Also note that the only currently supported values for the <paramref name="details"/>
212+
/// <remarks>Note that specifying a logging operation type for the <paramref name="operations"/> parameter will return any Analytics log blob that contains the specified logging operation,
213+
/// even if that log blob also includes other types of logging operations. Also note that the only currently supported values for the <paramref name="details"/>
212214
/// parameter are <c>None</c> and <c>Metadata</c>.</remarks>
213215
public IEnumerable<ICloudBlob> ListLogs(StorageService service, LoggingOperations operations, BlobListingDetails details, BlobRequestOptions options, OperationContext operationContext)
214216
{
@@ -236,7 +238,7 @@ public IEnumerable<ICloudBlob> ListLogs(StorageService service, LoggingOperation
236238
}
237239

238240
/// <summary>
239-
/// Returns an enumerable collection of logs stored as blobs, retrieved lazily.
241+
/// Returns an enumerable collection of log blobs containing Analytics log records. The blobs are retrieved lazily.
240242
/// </summary>
241243
/// <param name="service">A <see cref="StorageService"/> enumeration value.</param>
242244
/// <param name="startTime">A <see cref="DateTimeOffset"/> object representing the start time for which logs should be retrieved.</param>
@@ -248,18 +250,18 @@ public IEnumerable<ICloudBlob> ListLogs(StorageService service, DateTimeOffset s
248250
}
249251

250252
/// <summary>
251-
/// Returns an enumerable collection of logs stored as blobs, retrieved lazily.
253+
/// Returns an enumerable collection of log blobs containing Analytics log records. The blobs are retrieved lazily.
252254
/// </summary>
253255
/// <param name="service">A <see cref="StorageService"/> enumeration value.</param>
254256
/// <param name="startTime">A <see cref="DateTimeOffset"/> object representing the start of the time range for which logs should be retrieved.</param>
255257
/// <param name="endTime">A <see cref="DateTimeOffset"/> object representing the end of the time range for which logs should be retrieved.</param>
256-
/// <param name="operations">A <see cref="LoggingOperations"/> enumeration value that indicates which log types to return</param>
258+
/// <param name="operations">A <see cref="LoggingOperations"/> enumeration value that indicates the types of logging operations on which to filter the log blobs.</param>
257259
/// <param name="details">A <see cref="BlobListingDetails"/> enumeration value that indicates whether or not blob metadata should be returned. Only <c>None</c> and <c>Metadata</c> are valid values. </param>
258260
/// <param name="options">A <see cref="BlobRequestOptions"/> object that specifies additional options for the request.</param>
259261
/// <param name="operationContext">An <see cref="OperationContext"/> object that represents the context for the current operation.</param>
260262
/// <returns>An enumerable collection of objects that implement <see cref="ICloudBlob"/> and are retrieved lazily.</returns>
261-
/// <remarks>Note that specifying a log type for the <paramref name="operations"/> parameter will return any log that contains the specified log type,
262-
/// even if that log also includes other log types. Also note that the only currently supported values for the <paramref name="details"/>
263+
/// <remarks>Note that specifying a logging operation type for the <paramref name="operations"/> parameter will return any Analytics log blob that contains the specified logging operation,
264+
/// even if that log blob also includes other types of logging operations. Also note that the only currently supported values for the <paramref name="details"/>
263265
/// parameter are <c>None</c> and <c>Metadata</c>.</remarks>
264266
public IEnumerable<ICloudBlob> ListLogs(StorageService service, DateTimeOffset startTime, DateTimeOffset? endTime, LoggingOperations operations, BlobListingDetails details, BlobRequestOptions options, OperationContext operationContext)
265267
{
@@ -407,11 +409,106 @@ public IEnumerable<ICloudBlob> ListLogs(StorageService service, DateTimeOffset s
407409

408410
dateCounter = dateCounter.AddYears(1);
409411
if (dateCounter > DateTimeOffset.UtcNow.AddHours(1))
410-
{
412+
{
411413
yield break;
412414
}
413415
}
414416
}
417+
418+
/// <summary>
419+
/// Returns an enumerable collection of Analytics log records, retrieved lazily.
420+
/// </summary>
421+
/// <param name="service">A <see cref="StorageService"/> enumeration value.</param>
422+
/// <returns>An enumerable collection of objects that implement <see cref="LogRecord"/> and are retrieved lazily.</returns>
423+
public IEnumerable<LogRecord> ListLogRecords(StorageService service)
424+
{
425+
return this.ListLogRecords(service, null /* options */, null /* operationContext */);
426+
}
427+
428+
/// <summary>
429+
/// Returns an enumerable collection of Analytics log records, retrieved lazily.
430+
/// </summary>
431+
/// <param name="service">A <see cref="StorageService"/> enumeration value.</param>
432+
/// <param name="options">A <see cref="BlobRequestOptions"/> object that specifies additional options for the request.</param>
433+
/// <param name="operationContext">An <see cref="OperationContext"/> object that represents the context for the current operation.</param>
434+
/// <returns>An enumerable collection of objects that implement <see cref="LogRecord"/> and are retrieved lazily.</returns>
435+
public IEnumerable<LogRecord> ListLogRecords(StorageService service, BlobRequestOptions options, OperationContext operationContext)
436+
{
437+
return CloudAnalyticsClient.ParseLogBlobs(this.ListLogs(service, LoggingOperations.All, BlobListingDetails.None, options, operationContext));
438+
}
439+
440+
/// <summary>
441+
/// Returns an enumerable collection of Analytics log records, retrieved lazily.
442+
/// </summary>
443+
/// <param name="service">A <see cref="StorageService"/> enumeration value.</param>
444+
/// <param name="startTime">A <see cref="DateTimeOffset"/> object representing the start of the time range for which logs should be retrieved.</param>
445+
/// <param name="endTime">A <see cref="DateTimeOffset"/> object representing the end of the time range for which logs should be retrieved.</param>
446+
/// <returns>An enumerable collection of objects that implement <see cref="LogRecord"/> and are retrieved lazily.</returns>
447+
public IEnumerable<LogRecord> ListLogRecords(StorageService service, DateTimeOffset startTime, DateTimeOffset? endTime)
448+
{
449+
return this.ListLogRecords(service, startTime, endTime, null /* options */, null /* operationContext */);
450+
}
451+
452+
/// <summary>
453+
/// Returns an enumerable collection of Analytics log records, retrieved lazily.
454+
/// </summary>
455+
/// <param name="service">A <see cref="StorageService"/> enumeration value.</param>
456+
/// <param name="startTime">A <see cref="DateTimeOffset"/> object representing the start of the time range for which logs should be retrieved.</param>
457+
/// <param name="endTime">A <see cref="DateTimeOffset"/> object representing the end of the time range for which logs should be retrieved.</param>
458+
/// <param name="options">A <see cref="BlobRequestOptions"/> object that specifies additional options for the request.</param>
459+
/// <param name="operationContext">An <see cref="OperationContext"/> object that represents the context for the current operation.</param>
460+
/// <returns>An enumerable collection of objects that implement <see cref="LogRecord"/> and are retrieved lazily.</returns>
461+
public IEnumerable<LogRecord> ListLogRecords(StorageService service, DateTimeOffset startTime, DateTimeOffset? endTime, BlobRequestOptions options, OperationContext operationContext)
462+
{
463+
return CloudAnalyticsClient.ParseLogBlobs(this.ListLogs(service, startTime, endTime, LoggingOperations.All, BlobListingDetails.None, options, operationContext));
464+
}
465+
466+
/// <summary>
467+
/// Returns an enumerable collection of Analytics log records, retrieved lazily.
468+
/// </summary>
469+
/// <param name="logBlobs">An enumerable collection of <see cref="ICloudBlob"/> objects from which to parse log records.</param>
470+
/// <returns>An enumerable collection of objects that implement <see cref="LogRecord"/> and are retrieved lazily.</returns>
471+
public static IEnumerable<LogRecord> ParseLogBlobs(IEnumerable<ICloudBlob> logBlobs)
472+
{
473+
return logBlobs.SelectMany(CloudAnalyticsClient.ParseLogBlob);
474+
}
475+
476+
/// <summary>
477+
/// Returns an enumerable collection of Analytics log records, retrieved lazily.
478+
/// </summary>
479+
/// <param name="logBlob">The <see cref="ICloudBlob"/> object from which to parse log records.</param>
480+
/// <returns>An enumerable collection of objects that implement <see cref="LogRecord"/> and are retrieved lazily.</returns>
481+
public static IEnumerable<LogRecord> ParseLogBlob(ICloudBlob logBlob)
482+
{
483+
using (Stream stream = ((CloudBlockBlob)logBlob).OpenRead())
484+
{
485+
using (LogRecordStreamReader reader = new LogRecordStreamReader(stream, (int)stream.Length))
486+
{
487+
LogRecord log;
488+
while (!reader.IsEndOfFile)
489+
{
490+
log = new LogRecord(reader);
491+
yield return log;
492+
}
493+
}
494+
}
495+
}
496+
497+
/// <summary>
498+
/// Returns an enumerable collection of Analytics log records, retrieved lazily.
499+
/// </summary>
500+
/// <param name="stream">The <see cref="System.IO.Stream"/> object from which to parse log records.</param>
501+
/// <returns>An enumerable collection of objects that implement <see cref="LogRecord"/> and are retrieved lazily.</returns>
502+
public static IEnumerable<LogRecord> ParseLogStream(Stream stream)
503+
{
504+
LogRecordStreamReader reader = new LogRecordStreamReader(stream, (int)stream.Length);
505+
LogRecord log;
506+
while (!reader.IsEndOfFile)
507+
{
508+
log = new LogRecord(reader);
509+
yield return log;
510+
}
511+
}
415512
#endif
416513

417514
/// <summary>

0 commit comments

Comments
 (0)