Part 1
In the last post we talked a little about how we can calculate TOP 5 visited URLs per day for each user and TOP 5 visited URL anytime. For these cases I propose some ways on how we can store information on Windows Azure Table in a way that we can generate these reports.
In today post we will see how we can resolve the concurrence problem. We can have 10, 20 or 100 commands that want to execute over the same entity from Windows Azure Table. Because of this we need to guaranty that the writer has the last version of the entity before update it. If we will not be able to guaranty this… than our reporting solution will be compromised.
Windows Azure Table comes with a simple solution. Each entity that is stored on tables contains a unique key named ETag. ETag is changed every time when the entity is updated or changed. Based on this value we can know if we have the last version of an entity or the entity was changed from the moment when we receive it. ETag is the secret that give us support for concurrency access to Windows Azure Storage (Tables and Blobs).
Each entity that is retrieved from Windows Azure Tables has the ETag set. When someone will update any field from the given entity, the ETag value will be changed. In the moment when another user tries to make an update with an invalid ETag, the merge option feature will be used.
The data context contains a merge option filed that can be set manually. Based on this value, we can provide a custom behavior when a conflict appears. The values that are supported for MergeOption enum are:
We saw that Windows Azure tables already have support for object “versioning” and automatic detecting and resolve merge conflict.
This can be used with success in our problem, when in the case when the entity was update by another client we will need to retrieve the last version of the entity and update it.
In the last post we talked a little about how we can calculate TOP 5 visited URLs per day for each user and TOP 5 visited URL anytime. For these cases I propose some ways on how we can store information on Windows Azure Table in a way that we can generate these reports.
In today post we will see how we can resolve the concurrence problem. We can have 10, 20 or 100 commands that want to execute over the same entity from Windows Azure Table. Because of this we need to guaranty that the writer has the last version of the entity before update it. If we will not be able to guaranty this… than our reporting solution will be compromised.
Windows Azure Table comes with a simple solution. Each entity that is stored on tables contains a unique key named ETag. ETag is changed every time when the entity is updated or changed. Based on this value we can know if we have the last version of an entity or the entity was changed from the moment when we receive it. ETag is the secret that give us support for concurrency access to Windows Azure Storage (Tables and Blobs).
Each entity that is retrieved from Windows Azure Tables has the ETag set. When someone will update any field from the given entity, the ETag value will be changed. In the moment when another user tries to make an update with an invalid ETag, the merge option feature will be used.
The data context contains a merge option filed that can be set manually. Based on this value, we can provide a custom behavior when a conflict appears. The values that are supported for MergeOption enum are:
- AppendOnly (default value)
- OverwriteChanges
- PreserveChanges
- NoTracking
We saw that Windows Azure tables already have support for object “versioning” and automatic detecting and resolve merge conflict.
This can be used with success in our problem, when in the case when the entity was update by another client we will need to retrieve the last version of the entity and update it.
Comments
Post a Comment