防止天蓝色斑点在创建时被其他服务访问 [英] Preventing azure blob from being accessed by other service while it's being created

查看:43
本文介绍了防止天蓝色斑点在创建时被其他服务访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Azure Blob API有时看起来像是由外星人设计的.就像为一些非常奇特的用例设计的那样,大多数简单的用例都需要跳进篮球架.这是这样的.

Azure blob API sometimes looks like it's been designed by aliens. Like designed for some very exotic use cases when most simple ones require jumping through the hoops. Here is one such.

我有两个工人角色.一种是创建Blob,另一种是处理Blob(处理完成后移至完成"文件夹).Blob大小可能适中,例如100 MB.显然,我不希望第二个角色在blob具有所有数据之前就开始读取blob.好的,可以期望Lease API的帮助:获得租约,复制Blob,释放租约.然后,读者也将尝试在处理之前获取租约,因此必须等待.但是不,不能在尚不存在的Blob上获得租约.另外,我找不到任何方法来创建租约为"on"的blob作为原子操作.

I have two worker roles. One is creating blobs, another one is processing them (and moving to "completed" folder when processing is done). The blob size can be moderately big, like 100 MB. Obviously, I don't want second role to start reading the blob before the blob has all the data. Okay, one can expect the help from the Lease API: acquire the lease, copy the blob, release the lease. Then, reader will also try to acquire the lease before processing and therefore will have to wait. But no, lease can't be acquired on a blob that does not exist yet. Also, I couldn't find any method that creates a blob with the lease "on" as an atomic operation.

如果您知道使之起作用的窍门,请告诉我.真诚的.

Please let me know if you know the trick to make it work. Sincerely Yours.

推荐答案

很明显,我不想让第二个角色在开始之前读blobBlob拥有所有数据.

Obviously, I don't want second role to start reading the blob before the blob has all the data.

假设您正在创建一个 BlockBlob ,直到针对所有意图和目的将Blob提交(或将所有数据写入Blob)之前,该Blob将不存在且将一直存在.不会在Blob列出结果中出现(除非您在列出Blob时明确要求未提交的Blob).因此,我认为您不必在那里做任何特别的事情.

Assuming you're creating a BlockBlob, till the time the blob is committed (or in other words all data is written to the blob) for all intents and purposes the blob will not exist and will not come up in the blob listing result (unless you specifically ask for uncommitted blobs when listing blobs). So I think you don't have to do anything special there.

好吧,人们可以期待Lease API的帮助:获得租赁,复制Blob,释放租约.然后,读者还将尝试在处理之前获得租约,因此必须等待.

Okay, one can expect the help from the Lease API: acquire the lease, copy the blob, release the lease. Then, reader will also try to acquire the lease before processing and therefore will have to wait.

对此有另一种解决方案.您可以做的是利用 Azure队列.当Blob创建者工作角色完成上载Blob时,它只是在队列中写入一条消息,该消息将由处理Blob的工作角色进行轮询.假设有很多处理器角色实例,则每个实例都可以从此队列中 GET 消息,该消息的工作方式类似于 blob lease (消息仅适用于一个实例)然后开始处理Blob.

There's an alternate solution to this. What you could do is make use of Azure Queues. When the blob creator worker role finishes uploading the blob, it just writes a message in a queue which will be polled by worker role processing the blob. Assuming there are many instances of processor worker role, then each instance can GET the message from this queue which would work similar to blob lease (message is available only to one instance) and then start processing the blob.

这篇关于防止天蓝色斑点在创建时被其他服务访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆