def _claim_one_partition(self, ownership):
     partition_id = ownership["partition_id"]
     fully_qualified_namespace = ownership["fully_qualified_namespace"]
     eventhub_name = ownership["eventhub_name"]
     consumer_group = ownership["consumer_group"]
     owner_id = ownership["owner_id"]
     metadata = {"ownerid": owner_id}
     try:
         self._upload_ownership(ownership, metadata)
         return ownership
     except (ResourceModifiedError, ResourceExistsError):
         logger.info(
             "EventProcessor instance %r of namespace %r eventhub %r consumer group %r "
             "lost ownership to partition %r",
             owner_id,
             fully_qualified_namespace,
             eventhub_name,
             consumer_group,
             partition_id,
         )
         raise OwnershipLostError()
     except Exception as error:  # pylint:disable=broad-except
         logger.warning(
             "An exception occurred when EventProcessor instance %r claim_ownership for "
             "namespace %r eventhub %r consumer group %r partition %r. "
             "The ownership is now lost. Exception "
             "is %r",
             owner_id,
             fully_qualified_namespace,
             eventhub_name,
             consumer_group,
             partition_id,
             error,
         )
         return ownership  # Keep the ownership if an unexpected error happens
Exemple #2
0
 def _claim_one_partition(self, ownership, **kwargs):
     new_ownership = ownership.copy()
     try:
         self._update_ownership(new_ownership, **kwargs)
         return new_ownership
     except (ResourceModifiedError, ResourceExistsError):
         logger.info(
             "EventProcessor instance %r of namespace %r eventhub %r consumer group %r "
             "lost ownership to partition %r",
             new_ownership["owner_id"],
             new_ownership["fully_qualified_namespace"],
             new_ownership["eventhub_name"],
             new_ownership["consumer_group"],
             new_ownership["partition_id"],
         )
         raise OwnershipLostError()
     except Exception as error:  # pylint:disable=broad-except
         logger.warning(
             "An exception occurred when EventProcessor instance %r claim_ownership for "
             "namespace %r eventhub %r consumer group %r partition %r. "
             "The ownership is now lost. Exception "
             "is %r",
             new_ownership["owner_id"],
             new_ownership["fully_qualified_namespace"],
             new_ownership["eventhub_name"],
             new_ownership["consumer_group"],
             new_ownership["partition_id"],
             error,
         )
         return new_ownership  # Keep the ownership if an unexpected error happens
Exemple #3
0
 async def update_checkpoint(self, checkpoint):
     if checkpoint['partition_id'] == "1":
         raise OwnershipLostError("Mocked ownership lost")