diff --git a/sdk/eventhub/Azure.Messaging.EventHubs.Processor/src/Azure.Messaging.EventHubs.Processor.csproj b/sdk/eventhub/Azure.Messaging.EventHubs.Processor/src/Azure.Messaging.EventHubs.Processor.csproj index 96a398526e55..d8a53cc2e5cc 100644 --- a/sdk/eventhub/Azure.Messaging.EventHubs.Processor/src/Azure.Messaging.EventHubs.Processor.csproj +++ b/sdk/eventhub/Azure.Messaging.EventHubs.Processor/src/Azure.Messaging.EventHubs.Processor.csproj @@ -33,6 +33,7 @@ + diff --git a/sdk/eventhub/Azure.Messaging.EventHubs.Processor/src/Storage/BlobsCheckpointStore.Diagnostics.cs b/sdk/eventhub/Azure.Messaging.EventHubs.Processor/src/Storage/BlobsCheckpointStore.Diagnostics.cs new file mode 100644 index 000000000000..43e3bcfada57 --- /dev/null +++ b/sdk/eventhub/Azure.Messaging.EventHubs.Processor/src/Storage/BlobsCheckpointStore.Diagnostics.cs @@ -0,0 +1,227 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Azure.Messaging.EventHubs.Processor.Diagnostics; + +namespace Azure.Messaging.EventHubs.Processor +{ + /// + /// A storage blob service that keeps track of checkpoints and ownership. + /// + /// + internal sealed partial class BlobsCheckpointStore + { + /// + /// Initializes the type. + /// +#pragma warning disable CA1810 // Initialize static fields inline + static BlobsCheckpointStore() + { + BlobsResourceDoesNotExist = Resources.BlobsResourceDoesNotExist; + } +#pragma warning restore CA1810 + + /// + /// The instance of which can be mocked for testing. + /// + /// + internal BlobEventStoreEventSource Logger { get; set; } = BlobEventStoreEventSource.Log; + + /// + /// Indicates that an attempt to retrieve a list of ownership has completed. + /// + /// + /// The fully qualified Event Hubs namespace the ownership are associated with. This is likely to be similar to {yournamespace}.servicebus.windows.net. + /// The name of the specific Event Hub the ownership are associated with, relative to the Event Hubs namespace that contains it. + /// The name of the consumer group the ownership are associated with. + /// The amount of ownership received from the storage service. + /// + partial void ListOwnershipComplete(string fullyQualifiedNamespace, string eventHubName, string consumerGroup, int ownershipCount) => + Logger.ListOwnershipComplete(fullyQualifiedNamespace, eventHubName, consumerGroup, ownershipCount); + + /// + /// Indicates that an unhandled exception was encountered while retrieving a list of ownership. + /// + /// + /// The fully qualified Event Hubs namespace the ownership are associated with. This is likely to be similar to {yournamespace}.servicebus.windows.net. + /// The name of the specific Event Hub the ownership are associated with, relative to the Event Hubs namespace that contains it. + /// The name of the consumer group the ownership are associated with. + /// The message for the exception that occurred. + /// + partial void ListOwnershipError(string fullyQualifiedNamespace, string eventHubName, string consumerGroup, string errorMessage) => + Logger.ListOwnershipError(fullyQualifiedNamespace, eventHubName, consumerGroup, errorMessage); + + /// + /// Indicates that an attempt to retrieve a list of ownership has started. + /// + /// + /// The fully qualified Event Hubs namespace the ownership are associated with. This is likely to be similar to {yournamespace}.servicebus.windows.net. + /// The name of the specific Event Hub the ownership are associated with, relative to the Event Hubs namespace that contains it. + /// The name of the consumer group the ownership are associated with. + /// + partial void ListOwnershipStart(string fullyQualifiedNamespace, string eventHubName, string consumerGroup) => + Logger.ListOwnershipStart(fullyQualifiedNamespace, eventHubName, consumerGroup); + + /// + /// Indicates that an attempt to retrieve a list of checkpoints has completed. + /// + /// + /// The fully qualified Event Hubs namespace the checkpoints are associated with. This is likely to be similar to {yournamespace}.servicebus.windows.net. + /// The name of the specific Event Hub the checkpoints are associated with, relative to the Event Hubs namespace that contains it. + /// The name of the consumer group the checkpoints are associated with. + /// The amount of checkpoints received from the storage service. + /// + partial void ListCheckpointsComplete(string fullyQualifiedNamespace, string eventHubName, string consumerGroup, int checkpointCount) => + Logger.ListCheckpointsComplete(fullyQualifiedNamespace, eventHubName, consumerGroup, checkpointCount); + + /// + /// Indicates that an unhandled exception was encountered while retrieving a list of checkpoints. + /// + /// + /// The fully qualified Event Hubs namespace the checkpoints are associated with. This is likely to be similar to {yournamespace}.servicebus.windows.net. + /// The name of the specific Event Hub the checkpoints are associated with, relative to the Event Hubs namespace that contains it. + /// The name of the consumer group the ownership are associated with. + /// The message for the exception that occurred. + /// + partial void ListCheckpointsError(string fullyQualifiedNamespace, string eventHubName, string consumerGroup, string errorMessage) => + Logger.ListCheckpointsError(fullyQualifiedNamespace, eventHubName, consumerGroup, errorMessage); + + /// + /// Indicates that invalid checkpoint data was found during an attempt to retrieve a list of checkpoints. + /// + /// + /// The identifier of the partition the data is associated with. + /// The fully qualified Event Hubs namespace the data is associated with. This is likely to be similar to {yournamespace}.servicebus.windows.net. + /// The name of the specific Event Hub the data is associated with, relative to the Event Hubs namespace that contains it. + /// The name of the consumer group the data is associated with. + /// + partial void InvalidCheckpointFound(string partitionId, string fullyQualifiedNamespace, string eventHubName, string consumerGroup) => + Logger.InvalidCheckpointFound(partitionId, fullyQualifiedNamespace, eventHubName, consumerGroup); + + /// + /// Indicates that an attempt to retrieve a list of checkpoints has started. + /// + /// + /// The fully qualified Event Hubs namespace the checkpoints are associated with. This is likely to be similar to {yournamespace}.servicebus.windows.net. + /// The name of the specific Event Hub the checkpoints are associated with, relative to the Event Hubs namespace that contains it. + /// The name of the consumer group the checkpoints are associated with. + /// + partial void ListCheckpointsStart(string fullyQualifiedNamespace, string eventHubName, string consumerGroup) => + Logger.ListCheckpointsStart(fullyQualifiedNamespace, eventHubName, consumerGroup); + + /// + /// Indicates that an unhandled exception was encountered while updating a checkpoint. + /// + /// + /// The identifier of the partition being checkpointed. + /// The fully qualified Event Hubs namespace the checkpoint is associated with. This is likely to be similar to {yournamespace}.servicebus.windows.net. + /// The name of the specific Event Hub the checkpoint is associated with, relative to the Event Hubs namespace that contains it. + /// The name of the consumer group the checkpoint is associated with. + /// The message for the exception that occurred. + /// + partial void UpdateCheckpointError(string partitionId, string fullyQualifiedNamespace, string eventHubName, string consumerGroup, string errorMessage) => + Logger.UpdateCheckpointError(partitionId, fullyQualifiedNamespace, eventHubName, consumerGroup, errorMessage); + + /// + /// Indicates that an attempt to update a checkpoint has completed. + /// + /// + /// The identifier of the partition being checkpointed. + /// The fully qualified Event Hubs namespace the checkpoint is associated with. This is likely to be similar to {yournamespace}.servicebus.windows.net. + /// The name of the specific Event Hub the checkpoint is associated with, relative to the Event Hubs namespace that contains it. + /// The name of the consumer group the checkpoint is associated with. + /// + partial void UpdateCheckpointComplete(string partitionId, string fullyQualifiedNamespace, string eventHubName, string consumerGroup) => + Logger.UpdateCheckpointComplete(partitionId, fullyQualifiedNamespace, eventHubName, consumerGroup); + + /// + /// Indicates that an attempt to create/update a checkpoint has started. + /// + /// + /// The identifier of the partition being checkpointed. + /// The fully qualified Event Hubs namespace the checkpoint is associated with. This is likely to be similar to {yournamespace}.servicebus.windows.net. + /// The name of the specific Event Hub the checkpoint is associated with, relative to the Event Hubs namespace that contains it. + /// The name of the consumer group the checkpoint is associated with. + /// + partial void UpdateCheckpointStart(string partitionId, string fullyQualifiedNamespace, string eventHubName, string consumerGroup) => + Logger.UpdateCheckpointStart(partitionId, fullyQualifiedNamespace, eventHubName, consumerGroup); + + /// + /// Indicates that an attempt to retrieve claim partition ownership has completed. + /// + /// + /// The identifier of the partition being claimed. + /// The fully qualified Event Hubs namespace the ownership is associated with. This is likely to be similar to {yournamespace}.servicebus.windows.net. + /// The name of the specific Event Hub the ownership is associated with, relative to the Event Hubs namespace that contains it. + /// The name of the consumer group the ownership is associated with. + /// The identifier of the processor that attempted to claim the ownership for. + /// + partial void ClaimOwnershipComplete(string partitionId, string fullyQualifiedNamespace, string eventHubName, string consumerGroup, string ownerIdentifier) => + Logger.ClaimOwnershipComplete(partitionId, fullyQualifiedNamespace, eventHubName, consumerGroup, ownerIdentifier); + + /// + /// Indicates that an exception was encountered while attempting to retrieve claim partition ownership. + /// + /// + /// The identifier of the partition being claimed. + /// The fully qualified Event Hubs namespace the ownership is associated with. This is likely to be similar to {yournamespace}.servicebus.windows.net. + /// The name of the specific Event Hub the ownership is associated with, relative to the Event Hubs namespace that contains it. + /// The name of the consumer group the ownership is associated with. + /// The identifier of the processor that attempted to claim the ownership for. + /// The message for the exception that occurred. + /// + partial void ClaimOwnershipError(string partitionId, string fullyQualifiedNamespace, string eventHubName, string consumerGroup, string ownerIdentifier, string errorMessage) => + Logger.ClaimOwnershipError(partitionId, fullyQualifiedNamespace, eventHubName, consumerGroup, ownerIdentifier, errorMessage); + + /// + /// Indicates that ownership was unable to be claimed. + /// + /// + /// The identifier of the partition being claimed. + /// The fully qualified Event Hubs namespace the ownership is associated with. This is likely to be similar to {yournamespace}.servicebus.windows.net. + /// The name of the specific Event Hub the ownership is associated with, relative to the Event Hubs namespace that contains it. + /// The name of the consumer group the ownership is associated with. + /// The identifier of the processor that attempted to claim the ownership for. + /// The message for the failure. + /// + partial void OwnershipNotClaimable(string partitionId, string fullyQualifiedNamespace, string eventHubName, string consumerGroup, string ownerIdentifier, string message) => + Logger.OwnershipNotClaimable(partitionId, fullyQualifiedNamespace, eventHubName, consumerGroup, ownerIdentifier, message); + + /// + /// Indicates that ownership was successfully claimed. + /// + /// + /// The identifier of the partition being claimed. + /// The fully qualified Event Hubs namespace the ownership is associated with. This is likely to be similar to {yournamespace}.servicebus.windows.net. + /// The name of the specific Event Hub the ownership is associated with, relative to the Event Hubs namespace that contains it. + /// The name of the consumer group the ownership is associated with. + /// The identifier of the processor that attempted to claim the ownership for. + /// + partial void OwnershipClaimed(string partitionId, string fullyQualifiedNamespace, string eventHubName, string consumerGroup, string ownerIdentifier) => + Logger.OwnershipClaimed(partitionId, fullyQualifiedNamespace, eventHubName, consumerGroup, ownerIdentifier); + + /// + /// Indicates that an attempt to claim a partition ownership has started. + /// + /// + /// The identifier of the partition being claimed. + /// The fully qualified Event Hubs namespace the ownership is associated with. This is likely to be similar to {yournamespace}.servicebus.windows.net. + /// The name of the specific Event Hub the ownership is associated with, relative to the Event Hubs namespace that contains it. + /// The name of the consumer group the ownership is associated with. + /// The identifier of the processor that attempted to claim the ownership for. + /// + partial void ClaimOwnershipStart(string partitionId, string fullyQualifiedNamespace, string eventHubName, string consumerGroup, string ownerIdentifier) => + Logger.ClaimOwnershipStart(partitionId, fullyQualifiedNamespace, eventHubName, consumerGroup, ownerIdentifier); + + /// + /// Indicates that a was created. + /// + /// + /// The type name for the checkpoint store. + /// The Storage account name corresponding to the associated container client. + /// The name of the associated container client. + /// + partial void BlobsCheckpointStoreCreated(string typeName, string accountName, string containerName) => + Logger.BlobsCheckpointStoreCreated(typeName, accountName, containerName); + } +} \ No newline at end of file diff --git a/sdk/eventhub/Azure.Messaging.EventHubs.Shared/src/Azure.Messaging.EventHubs.Shared.BlobCheckpointStore.projitems b/sdk/eventhub/Azure.Messaging.EventHubs.Shared/src/Azure.Messaging.EventHubs.Shared.BlobCheckpointStore.projitems new file mode 100644 index 000000000000..b0b2915fb489 --- /dev/null +++ b/sdk/eventhub/Azure.Messaging.EventHubs.Shared/src/Azure.Messaging.EventHubs.Shared.BlobCheckpointStore.projitems @@ -0,0 +1,16 @@ + + + + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) + true + 826d9924-8c85-4db1-9407-1b133a3d953f + + + + Azure.Messaging.EventHubs.Primitives + + + + + + diff --git a/sdk/eventhub/Azure.Messaging.EventHubs.Processor/src/Storage/BlobMetadataKey.cs b/sdk/eventhub/Azure.Messaging.EventHubs.Shared/src/BlobCheckpointStore/BlobMetadataKey.cs old mode 100755 new mode 100644 similarity index 100% rename from sdk/eventhub/Azure.Messaging.EventHubs.Processor/src/Storage/BlobMetadataKey.cs rename to sdk/eventhub/Azure.Messaging.EventHubs.Shared/src/BlobCheckpointStore/BlobMetadataKey.cs diff --git a/sdk/eventhub/Azure.Messaging.EventHubs.Processor/src/Storage/BlobsCheckpointStore.cs b/sdk/eventhub/Azure.Messaging.EventHubs.Shared/src/BlobCheckpointStore/BlobsCheckpointStore.cs similarity index 56% rename from sdk/eventhub/Azure.Messaging.EventHubs.Processor/src/Storage/BlobsCheckpointStore.cs rename to sdk/eventhub/Azure.Messaging.EventHubs.Shared/src/BlobCheckpointStore/BlobsCheckpointStore.cs index ddfd7f6624f0..5e3ba844f960 100644 --- a/sdk/eventhub/Azure.Messaging.EventHubs.Processor/src/Storage/BlobsCheckpointStore.cs +++ b/sdk/eventhub/Azure.Messaging.EventHubs.Shared/src/BlobCheckpointStore/BlobsCheckpointStore.cs @@ -5,7 +5,6 @@ using System.Collections.Generic; using System.Globalization; using System.IO; -using System.Runtime.CompilerServices; using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; @@ -13,7 +12,6 @@ using Azure.Messaging.EventHubs.Consumer; using Azure.Messaging.EventHubs.Core; using Azure.Messaging.EventHubs.Primitives; -using Azure.Messaging.EventHubs.Processor.Diagnostics; using Azure.Storage.Blobs; using Azure.Storage.Blobs.Models; @@ -23,8 +21,13 @@ namespace Azure.Messaging.EventHubs.Processor /// A storage blob service that keeps track of checkpoints and ownership. /// /// - internal sealed class BlobsCheckpointStore : StorageManager + internal sealed partial class BlobsCheckpointStore : StorageManager { +#pragma warning disable CA1802 // Use a constant field + /// A message to use when throwing exception when checkpoint container or blob does not exists. + private static readonly string BlobsResourceDoesNotExist = "The Azure Storage Blobs container or blob used by the Event Processor Client does not exist."; +#pragma warning restore CA1810 + /// A regular expression used to capture strings enclosed in double quotes. private static readonly Regex DoubleQuotesExpression = new Regex("\"(.*)\"", RegexOptions.Compiled); @@ -58,12 +61,6 @@ internal sealed class BlobsCheckpointStore : StorageManager /// private EventHubsRetryPolicy RetryPolicy { get; } - /// - /// The instance of which can be mocked for testing. - /// - /// - internal BlobEventStoreEventSource Logger { get; set; } = BlobEventStoreEventSource.Log; - /// /// Initializes a new instance of the class. /// @@ -79,7 +76,7 @@ public BlobsCheckpointStore(BlobContainerClient blobContainerClient, ContainerClient = blobContainerClient; RetryPolicy = retryPolicy; - Logger.BlobsCheckpointStoreCreated(nameof(BlobsCheckpointStore), blobContainerClient.AccountName, blobContainerClient.Name); + BlobsCheckpointStoreCreated(nameof(BlobsCheckpointStore), blobContainerClient.AccountName, blobContainerClient.Name); } /// @@ -99,7 +96,7 @@ public override async Task> ListOw CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); - Logger.ListOwnershipStart(fullyQualifiedNamespace, eventHubName, consumerGroup); + ListOwnershipStart(fullyQualifiedNamespace, eventHubName, consumerGroup); List result = null; @@ -138,12 +135,12 @@ async Task> listOwnershipAsync(Cancellati } catch (RequestFailedException ex) when (ex.ErrorCode == BlobErrorCode.ContainerNotFound) { - Logger.ListOwnershipError(fullyQualifiedNamespace, eventHubName, consumerGroup, ex.Message); - throw new RequestFailedException(Resources.BlobsResourceDoesNotExist); + ListOwnershipError(fullyQualifiedNamespace, eventHubName, consumerGroup, ex.Message); + throw new RequestFailedException(BlobsResourceDoesNotExist); } finally { - Logger.ListOwnershipComplete(fullyQualifiedNamespace, eventHubName, consumerGroup, result?.Count ?? 0); + ListOwnershipComplete(fullyQualifiedNamespace, eventHubName, consumerGroup, result?.Count ?? 0); } } @@ -169,7 +166,7 @@ public override async Task> ClaimO foreach (EventProcessorPartitionOwnership ownership in partitionOwnership) { - Logger.ClaimOwnershipStart(ownership.PartitionId, ownership.FullyQualifiedNamespace, ownership.EventHubName, ownership.ConsumerGroup, ownership.OwnerIdentifier); + ClaimOwnershipStart(ownership.PartitionId, ownership.FullyQualifiedNamespace, ownership.EventHubName, ownership.ConsumerGroup, ownership.OwnerIdentifier); metadata[BlobMetadataKey.OwnerIdentifier] = ownership.OwnerIdentifier; var blobRequestConditions = new BlobRequestConditions(); @@ -199,7 +196,7 @@ async Task> uploadBlobAsync(CancellationToken uploadTo // A blob could have just been created by another Event Processor that claimed ownership of this // partition. In this case, there's no point in retrying because we don't have the correct ETag. - Logger.OwnershipNotClaimable(ownership.PartitionId, ownership.FullyQualifiedNamespace, ownership.EventHubName, ownership.ConsumerGroup, ownership.OwnerIdentifier, ex.Message); + OwnershipNotClaimable(ownership.PartitionId, ownership.FullyQualifiedNamespace, ownership.EventHubName, ownership.ConsumerGroup, ownership.OwnerIdentifier, ex.Message); return null; } }; @@ -234,25 +231,25 @@ async Task> uploadBlobAsync(CancellationToken uploadTo } claimedOwnership.Add(ownership); - Logger.OwnershipClaimed(ownership.PartitionId, ownership.FullyQualifiedNamespace, ownership.EventHubName, ownership.ConsumerGroup, ownership.OwnerIdentifier); + OwnershipClaimed(ownership.PartitionId, ownership.FullyQualifiedNamespace, ownership.EventHubName, ownership.ConsumerGroup, ownership.OwnerIdentifier); } catch (RequestFailedException ex) when (ex.ErrorCode == BlobErrorCode.ConditionNotMet) { - Logger.OwnershipNotClaimable(ownership.PartitionId, ownership.FullyQualifiedNamespace, ownership.EventHubName, ownership.ConsumerGroup, ownership.OwnerIdentifier, ex.ToString()); + OwnershipNotClaimable(ownership.PartitionId, ownership.FullyQualifiedNamespace, ownership.EventHubName, ownership.ConsumerGroup, ownership.OwnerIdentifier, ex.ToString()); } catch (RequestFailedException ex) when (ex.ErrorCode == BlobErrorCode.ContainerNotFound || ex.ErrorCode == BlobErrorCode.BlobNotFound) { - Logger.ClaimOwnershipError(ownership.PartitionId, ownership.FullyQualifiedNamespace, ownership.EventHubName, ownership.ConsumerGroup, ownership.OwnerIdentifier, ex.Message); - throw new RequestFailedException(Resources.BlobsResourceDoesNotExist); + ClaimOwnershipError(ownership.PartitionId, ownership.FullyQualifiedNamespace, ownership.EventHubName, ownership.ConsumerGroup, ownership.OwnerIdentifier, ex.Message); + throw new RequestFailedException(BlobsResourceDoesNotExist); } catch (Exception ex) { - Logger.ClaimOwnershipError(ownership.PartitionId, ownership.FullyQualifiedNamespace, ownership.EventHubName, ownership.ConsumerGroup, ownership.OwnerIdentifier, ex.Message); + ClaimOwnershipError(ownership.PartitionId, ownership.FullyQualifiedNamespace, ownership.EventHubName, ownership.ConsumerGroup, ownership.OwnerIdentifier, ex.Message); throw; } finally { - Logger.ClaimOwnershipComplete(ownership.PartitionId, ownership.FullyQualifiedNamespace, ownership.EventHubName, ownership.ConsumerGroup, ownership.OwnerIdentifier); + ClaimOwnershipComplete(ownership.PartitionId, ownership.FullyQualifiedNamespace, ownership.EventHubName, ownership.ConsumerGroup, ownership.OwnerIdentifier); } } @@ -276,7 +273,7 @@ public override async Task> ListCheckpoint CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); - Logger.ListCheckpointsStart(fullyQualifiedNamespace, eventHubName, consumerGroup); + ListCheckpointsStart(fullyQualifiedNamespace, eventHubName, consumerGroup); var prefix = string.Format(CultureInfo.InvariantCulture, CheckpointPrefix, fullyQualifiedNamespace.ToLowerInvariant(), eventHubName.ToLowerInvariant(), consumerGroup.ToLowerInvariant()); var checkpointCount = 0; @@ -315,7 +312,7 @@ async Task> listCheckpointsAsync(Cancellat } else { - Logger.InvalidCheckpointFound(partitionId, fullyQualifiedNamespace, eventHubName, consumerGroup); + InvalidCheckpointFound(partitionId, fullyQualifiedNamespace, eventHubName, consumerGroup); } } @@ -329,17 +326,17 @@ async Task> listCheckpointsAsync(Cancellat } catch (RequestFailedException ex) when (ex.ErrorCode == BlobErrorCode.ContainerNotFound) { - Logger.ListCheckpointsError(fullyQualifiedNamespace, eventHubName, consumerGroup, ex.Message); - throw new RequestFailedException(Resources.BlobsResourceDoesNotExist); + ListCheckpointsError(fullyQualifiedNamespace, eventHubName, consumerGroup, ex.Message); + throw new RequestFailedException(BlobsResourceDoesNotExist); } catch (Exception ex) { - Logger.ListCheckpointsError(fullyQualifiedNamespace, eventHubName, consumerGroup, ex.Message); + ListCheckpointsError(fullyQualifiedNamespace, eventHubName, consumerGroup, ex.Message); throw; } finally { - Logger.ListCheckpointsComplete(fullyQualifiedNamespace, eventHubName, consumerGroup, checkpointCount); + ListCheckpointsComplete(fullyQualifiedNamespace, eventHubName, consumerGroup, checkpointCount); } } @@ -358,7 +355,7 @@ public override async Task UpdateCheckpointAsync(EventProcessorCheckpoint checkp CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); - Logger.UpdateCheckpointStart(checkpoint.PartitionId, checkpoint.FullyQualifiedNamespace, checkpoint.EventHubName, checkpoint.ConsumerGroup); + UpdateCheckpointStart(checkpoint.PartitionId, checkpoint.FullyQualifiedNamespace, checkpoint.EventHubName, checkpoint.ConsumerGroup); var blobName = string.Format(CultureInfo.InvariantCulture, CheckpointPrefix + checkpoint.PartitionId, checkpoint.FullyQualifiedNamespace.ToLowerInvariant(), checkpoint.EventHubName.ToLowerInvariant(), checkpoint.ConsumerGroup.ToLowerInvariant()); var blobClient = ContainerClient.GetBlobClient(blobName); @@ -391,17 +388,17 @@ await ApplyRetryPolicy(async token => } catch (RequestFailedException ex) when (ex.ErrorCode == BlobErrorCode.ContainerNotFound) { - Logger.UpdateCheckpointError(checkpoint.PartitionId, checkpoint.FullyQualifiedNamespace, checkpoint.EventHubName, checkpoint.ConsumerGroup, ex.Message); - throw new RequestFailedException(Resources.BlobsResourceDoesNotExist); + UpdateCheckpointError(checkpoint.PartitionId, checkpoint.FullyQualifiedNamespace, checkpoint.EventHubName, checkpoint.ConsumerGroup, ex.Message); + throw new RequestFailedException(BlobsResourceDoesNotExist); } catch (Exception ex) { - Logger.UpdateCheckpointError(checkpoint.PartitionId, checkpoint.FullyQualifiedNamespace, checkpoint.EventHubName, checkpoint.ConsumerGroup, ex.Message); + UpdateCheckpointError(checkpoint.PartitionId, checkpoint.FullyQualifiedNamespace, checkpoint.EventHubName, checkpoint.ConsumerGroup, ex.Message); throw; } finally { - Logger.UpdateCheckpointComplete(checkpoint.PartitionId, checkpoint.FullyQualifiedNamespace, checkpoint.EventHubName, checkpoint.ConsumerGroup); + UpdateCheckpointComplete(checkpoint.PartitionId, checkpoint.FullyQualifiedNamespace, checkpoint.EventHubName, checkpoint.ConsumerGroup); } } @@ -490,5 +487,186 @@ async Task wrapper(CancellationToken token) await ApplyRetryPolicy(wrapper, cancellationToken).ConfigureAwait(false); return result; } + + /// + /// Indicates that an attempt to retrieve a list of ownership has completed. + /// + /// + /// The fully qualified Event Hubs namespace the ownership are associated with. This is likely to be similar to {yournamespace}.servicebus.windows.net. + /// The name of the specific Event Hub the ownership are associated with, relative to the Event Hubs namespace that contains it. + /// The name of the consumer group the ownership are associated with. + /// The amount of ownership received from the storage service. + /// + partial void ListOwnershipComplete(string fullyQualifiedNamespace, string eventHubName, string consumerGroup, int ownershipCount); + + /// + /// Indicates that an unhandled exception was encountered while retrieving a list of ownership. + /// + /// + /// The fully qualified Event Hubs namespace the ownership are associated with. This is likely to be similar to {yournamespace}.servicebus.windows.net. + /// The name of the specific Event Hub the ownership are associated with, relative to the Event Hubs namespace that contains it. + /// The name of the consumer group the ownership are associated with. + /// The message for the exception that occurred. + /// + partial void ListOwnershipError(string fullyQualifiedNamespace, string eventHubName, string consumerGroup, string errorMessage); + + /// + /// Indicates that an attempt to retrieve a list of ownership has started. + /// + /// + /// The fully qualified Event Hubs namespace the ownership are associated with. This is likely to be similar to {yournamespace}.servicebus.windows.net. + /// The name of the specific Event Hub the ownership are associated with, relative to the Event Hubs namespace that contains it. + /// The name of the consumer group the ownership are associated with. + /// + partial void ListOwnershipStart(string fullyQualifiedNamespace, string eventHubName, string consumerGroup); + + /// + /// Indicates that an attempt to retrieve a list of checkpoints has completed. + /// + /// + /// The fully qualified Event Hubs namespace the checkpoints are associated with. This is likely to be similar to {yournamespace}.servicebus.windows.net. + /// The name of the specific Event Hub the checkpoints are associated with, relative to the Event Hubs namespace that contains it. + /// The name of the consumer group the checkpoints are associated with. + /// The amount of checkpoints received from the storage service. + /// + partial void ListCheckpointsComplete(string fullyQualifiedNamespace, string eventHubName, string consumerGroup, int checkpointCount); + + /// + /// Indicates that an unhandled exception was encountered while retrieving a list of checkpoints. + /// + /// + /// The fully qualified Event Hubs namespace the checkpoints are associated with. This is likely to be similar to {yournamespace}.servicebus.windows.net. + /// The name of the specific Event Hub the checkpoints are associated with, relative to the Event Hubs namespace that contains it. + /// The name of the consumer group the ownership are associated with. + /// The message for the exception that occurred. + /// + partial void ListCheckpointsError(string fullyQualifiedNamespace, string eventHubName, string consumerGroup, string errorMessage); + + /// + /// Indicates that invalid checkpoint data was found during an attempt to retrieve a list of checkpoints. + /// + /// + /// The identifier of the partition the data is associated with. + /// The fully qualified Event Hubs namespace the data is associated with. This is likely to be similar to {yournamespace}.servicebus.windows.net. + /// The name of the specific Event Hub the data is associated with, relative to the Event Hubs namespace that contains it. + /// The name of the consumer group the data is associated with. + /// + partial void InvalidCheckpointFound(string partitionId, string fullyQualifiedNamespace, string eventHubName, string consumerGroup); + + /// + /// Indicates that an attempt to retrieve a list of checkpoints has started. + /// + /// + /// The fully qualified Event Hubs namespace the checkpoints are associated with. This is likely to be similar to {yournamespace}.servicebus.windows.net. + /// The name of the specific Event Hub the checkpoints are associated with, relative to the Event Hubs namespace that contains it. + /// The name of the consumer group the checkpoints are associated with. + /// + partial void ListCheckpointsStart(string fullyQualifiedNamespace, string eventHubName, string consumerGroup); + + /// + /// Indicates that an unhandled exception was encountered while updating a checkpoint. + /// + /// + /// The identifier of the partition being checkpointed. + /// The fully qualified Event Hubs namespace the checkpoint is associated with. This is likely to be similar to {yournamespace}.servicebus.windows.net. + /// The name of the specific Event Hub the checkpoint is associated with, relative to the Event Hubs namespace that contains it. + /// The name of the consumer group the checkpoint is associated with. + /// The message for the exception that occurred. + /// + partial void UpdateCheckpointError(string partitionId, string fullyQualifiedNamespace, string eventHubName, string consumerGroup, string errorMessage); + + /// + /// Indicates that an attempt to update a checkpoint has completed. + /// + /// + /// The identifier of the partition being checkpointed. + /// The fully qualified Event Hubs namespace the checkpoint is associated with. This is likely to be similar to {yournamespace}.servicebus.windows.net. + /// The name of the specific Event Hub the checkpoint is associated with, relative to the Event Hubs namespace that contains it. + /// The name of the consumer group the checkpoint is associated with. + /// + partial void UpdateCheckpointComplete(string partitionId, string fullyQualifiedNamespace, string eventHubName, string consumerGroup); + + /// + /// Indicates that an attempt to create/update a checkpoint has started. + /// + /// + /// The identifier of the partition being checkpointed. + /// The fully qualified Event Hubs namespace the checkpoint is associated with. This is likely to be similar to {yournamespace}.servicebus.windows.net. + /// The name of the specific Event Hub the checkpoint is associated with, relative to the Event Hubs namespace that contains it. + /// The name of the consumer group the checkpoint is associated with. + /// + partial void UpdateCheckpointStart(string partitionId, string fullyQualifiedNamespace, string eventHubName, string consumerGroup); + + /// + /// Indicates that an attempt to retrieve claim partition ownership has completed. + /// + /// + /// The identifier of the partition being claimed. + /// The fully qualified Event Hubs namespace the ownership is associated with. This is likely to be similar to {yournamespace}.servicebus.windows.net. + /// The name of the specific Event Hub the ownership is associated with, relative to the Event Hubs namespace that contains it. + /// The name of the consumer group the ownership is associated with. + /// The identifier of the processor that attempted to claim the ownership for. + /// + partial void ClaimOwnershipComplete(string partitionId, string fullyQualifiedNamespace, string eventHubName, string consumerGroup, string ownerIdentifier); + + /// + /// Indicates that an exception was encountered while attempting to retrieve claim partition ownership. + /// + /// + /// The identifier of the partition being claimed. + /// The fully qualified Event Hubs namespace the ownership is associated with. This is likely to be similar to {yournamespace}.servicebus.windows.net. + /// The name of the specific Event Hub the ownership is associated with, relative to the Event Hubs namespace that contains it. + /// The name of the consumer group the ownership is associated with. + /// The identifier of the processor that attempted to claim the ownership for. + /// The message for the exception that occurred. + /// + partial void ClaimOwnershipError(string partitionId, string fullyQualifiedNamespace, string eventHubName, string consumerGroup, string ownerIdentifier, string errorMessage); + + /// + /// Indicates that ownership was unable to be claimed. + /// + /// + /// The identifier of the partition being claimed. + /// The fully qualified Event Hubs namespace the ownership is associated with. This is likely to be similar to {yournamespace}.servicebus.windows.net. + /// The name of the specific Event Hub the ownership is associated with, relative to the Event Hubs namespace that contains it. + /// The name of the consumer group the ownership is associated with. + /// The identifier of the processor that attempted to claim the ownership for. + /// The message for the failure. + /// + partial void OwnershipNotClaimable(string partitionId, string fullyQualifiedNamespace, string eventHubName, string consumerGroup, string ownerIdentifier, string message); + + /// + /// Indicates that ownership was successfully claimed. + /// + /// + /// The identifier of the partition being claimed. + /// The fully qualified Event Hubs namespace the ownership is associated with. This is likely to be similar to {yournamespace}.servicebus.windows.net. + /// The name of the specific Event Hub the ownership is associated with, relative to the Event Hubs namespace that contains it. + /// The name of the consumer group the ownership is associated with. + /// The identifier of the processor that attempted to claim the ownership for. + /// + partial void OwnershipClaimed(string partitionId, string fullyQualifiedNamespace, string eventHubName, string consumerGroup, string ownerIdentifier); + + /// + /// Indicates that an attempt to claim a partition ownership has started. + /// + /// + /// The identifier of the partition being claimed. + /// The fully qualified Event Hubs namespace the ownership is associated with. This is likely to be similar to {yournamespace}.servicebus.windows.net. + /// The name of the specific Event Hub the ownership is associated with, relative to the Event Hubs namespace that contains it. + /// The name of the consumer group the ownership is associated with. + /// The identifier of the processor that attempted to claim the ownership for. + /// + partial void ClaimOwnershipStart(string partitionId, string fullyQualifiedNamespace, string eventHubName, string consumerGroup, string ownerIdentifier); + + /// + /// Indicates that a was created. + /// + /// + /// The type name for the checkpoint store. + /// The Storage account name corresponding to the associated container client. + /// The name of the associated container client. + /// + partial void BlobsCheckpointStoreCreated(string typeName, string accountName, string containerName); } } diff --git a/sdk/eventhub/Azure.Messaging.EventHubs.Shared/src/Resources.resx b/sdk/eventhub/Azure.Messaging.EventHubs.Shared/src/Resources.resx index 5ba5bb875a57..40c511371738 100644 --- a/sdk/eventhub/Azure.Messaging.EventHubs.Shared/src/Resources.resx +++ b/sdk/eventhub/Azure.Messaging.EventHubs.Shared/src/Resources.resx @@ -234,9 +234,6 @@ The Event Hub client responsible for this information is not available. - - The Azure Storage Blobs container or blob used by the Event Processor Client does not exist. - A checkpoint cannot be created or updated using an empty event. @@ -300,4 +297,4 @@ These events have already been successfully published. When idempotent publishing is enabled, events that were acknowledged by the Event Hubs service may not be published again. - + \ No newline at end of file