2
3
4
EntitiesTablesAccounts 5
6
7
8
PartitionKey (Category) RowKey (Title) TimestampReleaseDate Action Fast & Furious…2009 Action The Bourne Ultimatum…2007 … ……… Animation Open Season 2…2009 Animation The Ant Bully…2006 PartitionKey (Category) RowKey (Title) TimestampReleaseDate Comedy Office Space…1999 … ……… SciFi X-Men Origins: Wolverine …2009 … ……… War Defiance…2008 PartitionKey (Category) RowKey (Title) TimestampReleaseDate Action Fast & Furious…2009 Action The Bourne Ultimatum…2007 … ……… Animation Open Season 2…2009 Animation The Ant Bully…2006 … ……… Comedy Office Space…1999 … ……… SciFi X-Men Origins: Wolverine …2009 … ……… War Defiance…2008 9
11 [DataServiceKey("PartitionKey", "RowKey")] public class Movie { /// /// Category is the partition key /// public string PartitionKey { get; set; } /// /// Title is the row key /// public string RowKey { get; set; } public DateTime Timestamp { get; set; } public int ReleaseYear { get; set; } public string Language { get; set; } public string Cast { get; set; } }
12 StorageCredentialsAccountAndKey credentials = new StorageCredentialsAccountAndKey( myaccount", myKey"); string baseUri = " CloudTableClient tableClient = new CloudTableClient(baseUri, credentials); tableClient.CreateTable(Movies"); TableServiceContext context = tableClient.GetDataServiceContext(); CloudTableQuery q = (from movie in context.CreateQuery (Movies") where movie.PartitionKey == Action" && movie.RowKey == "The Bourne Ultimatum" select movie).AsTableServiceQuery (); Movie movieToUpdate = q.FirstOrDefault(); // Update movie context.UpdateObject(movieToUpdate); context.SaveChangesWithRetries(); // Add movie context.AddObject(new Movie(Action", movieToAdd)); context.SaveChangesWithRetries();
13
14
15
16 PartitionKey (Account name) RowKey (Title) Category… moviesonline 12 RoundsAction… moviesonline A Bugs LifeAnimation… 100,000,000 more rows……… moviesonline Office SpaceComedy… moviesonline PlatoonWar… 50,000,000 more rows……… moviesonline WALL-EAnimation…
PartitionKey (Account name) RowKey (Title) Category… moviesonline 12 RoundsAction… moviesonline A Bugs LifeAnimation… 100,000,000 more rows……… moviesonline Office SpaceComedy… moviesonline PlatoonWar… 50,000,000 more rows……… moviesonline WALL-EAnimation… Client 17
PartitionKey (Category) RowKey (Title) ActionFast & Furious …10000 more Action movies ActionThe Bourne Ultimatum … more Action & Animation movies AnimationOpen Season 2 … more Animation movies AnimationThe Ant Bully ComedyOffice Space … more Comedy & SciFi movies SciFiStar Trek … more SciFi & War movies … more War movies WarDefiance Client 18 PartitionKey (Category) RowKey (Title) ActionFast & Furious …10000 more Action movies ActionThe Bourne Ultimatum … more Action & Animation movies AnimationOpen Season 2 … more Animation movies AnimationThe Ant Bully ComedyOffice Space … more Comedy & SciFi movies SciFiStar Trek … more SciFi & War movies … more War movies WarDefiance
19
PartitionKey (Timestamp) Properties :00:01 … :00:11 … more rows… :40:01 … … more rows… :30:00 … :30:01 … Applications Client :30:01 … :30:02 … :30:03 … 20
PartitionKey (ID_Timestamp) Properties 01_ :10:00… …… more rows… 09_ :31:00… …… more rows… 10_ :10:10… more rows… …… more rows… 19_ :20:02… ApplicationsApplications Client 15_ :30:01… 09_ :30:22… 19_ :30:10… 01_ :30:01… 21
22
PartitionKey (Category) RowKey (Title) ActionFast & Furious …10000 more Action movies ActionThe Bourne Ultimatum … more Action & Animation movies AnimationOpen Season 2 … more Animation movies AnimationThe Ant Bully ComedyOffice Space … more Comedy & SciFi movies SciFiStar Trek … more SciFi & War movies … more War movies WarDefiance Client 23
Client PartitionKey (Category) RowKey (Title) Rating ActionFast & Furious5 …999 more movies rated > 4… … Action and Anim. movies here with rating < 4 … AnimationA Bugs life2 …100 more movies < 4 here… AnimationThe Ant Bully3 ComedyAre we there yet?2 …More movies here… ComedyOffice Space5 … more movies here… DramaA Beautiful Mind5 … more movies here… WarDefiance4 24 Returns 1000 movies Partition range boundary hit Return continuation
Client PartitionKey (Category) RowKey (Title) Rating ActionFast & Furious5 …More movies here… ComedyOffice Space5 …More movies here… DocumentaryPlanet Earth4 …More movies here DramaSeven Pounds4 HorrorSaw 53 …More movies here… Music8 Mile2 …More movies here… SciFiStar Trek5 …More movies here… 25
26
27
28
29
PartitionKey (UserId) RowKey () Timestam p ReleaseDateAction Assault on Precinct 13…2005 … ……… Action Face off…1997 Action Fast & Furious…2009 … … Hundreds of thousands of movies here …… Action Four Brothers…2005 Animatio n Open Season 2…2009 Animatio n The Ant Bully…
PartitionKey (AccountID) RowKey (Kind_*) KindTotalRentalsNameAddressCheckOutOnTitleDueOn ……………………… SallyA_SallyAccount8Sally FieldAnn Arbor, MI SallyR_JawsRental2009/11/16Jaws2009/11/20 SallyR_TaxiRental2009/11/16Taxi2009/11/20 ……………………… 31
32
33
34
MessagesQueuesAccounts 35
36
37
38 CloudQueueClient queueClient = new CloudQueueClient(baseUri, credentials); CloudQueue queue = queueClient.GetQueueReference("test1"); queue.CreateIfNotExist(); //MessageCount is populated via FetchAttributes queue.FetchAttributes(); CloudQueueMessage message = new CloudQueueMessage("Some content"); queue.AddMessage(message); message = queue.GetMessage(TimeSpan.FromMinutes(10) /*visibility timeout*/ ); //Process the message here … queue.DeleteMessage(message);
39
C1C1 C1C1 C2C2 C2C Producers Consumers P2P2 P2P2 P1P1 P1P GetMessage(Q, 30 s) msg 2 1. GetMessage(Q, 30 s) msg
C1C1 C 1 C2C2 C2C Producers Consumers P2P2 P2P2 P1P1 P1P GetMessage(Q, 30 s) msg 2 3. C2 consumed msg 2 4. DeleteMessage(Q, msg 2) 7. GetMessage(Q, 30 s) msg 1 1. GetMessage(Q, 30 s) msg 1 5. C 1 crashed msg1 visible 30 s after Dequeue
C1C1 C1C1 C2C2 C2C Producers Consumers P2P2 P2P2 P1P1 P1P Dequeue(Q, 30 sec) msg 2 3. C2 consumed msg 2 4. Delete(Q, msg 2) 7. Dequeue(Q, 30 sec) msg 1 8. C2 crashed 1. Dequeue(Q, 30 sec) msg 1 5. C 1 crashed 10. C1 restarted 11. Dequeue(Q, 30 sec) msg DequeueCount > Delete (Q, msg1) msg1 visible 30s after Dequeue 9. msg1 visible 30s after Dequeue
43
Future Features 44 > Allow workers to extend invisibility time > Time to process message unknown at dequeue time > Worker can extend the time as needed > Allow longer invisibility time > Long running work items may need more than 2 hours > Allow messages to not expire > Large backlogs will not cause messages to expire
45
Built by Developers for Developers….
© 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.