ES07  Niranjan Nilakantan Development Lead Microsoft Corporation  Pablo Castro Software Architect Microsoft Corporation       Scalable Storage.

Download Report

Transcript ES07  Niranjan Nilakantan Development Lead Microsoft Corporation  Pablo Castro Software Architect Microsoft Corporation       Scalable Storage.

ES07
 Niranjan Nilakantan
Development Lead
Microsoft Corporation
 Pablo Castro
Software Architect
Microsoft Corporation






Scalable Storage



Tables – Provide structured storage;
A Table is a set of entities, which
contain a set of properties



























Partition Key
Document
Row Key
Version
Property 3
ChangedOn
Property 4
Description
Examples Doc
V1.0
8/2/2007
Committed version
Examples Doc
V2.0.1
9/28/2007
Alice’s working
version
FAQ Doc
V1.0
5/2/2007
Committed version
FAQ Doc
V1.0.1
7/6/2007
FAQ Doc
V1.0.2
8/1/2007
Alice’s working
version
Sally’s working
version


Partition 1
Partition 2









Partition Key
Document
Row Key
Version
Property 3
ChangedOn
Property 4
Description
Examples Doc
V1.0
8/2/2007
Committed version
Examples Doc
V2.0.1
9/28/2007
Alice’s working
version
FAQ Doc
V1.0
5/2/2007
Committed version
FAQ Doc
V1.0.1
7/6/2007
FAQ Doc
V1.0.2
8/1/2007
Alice’s working
version
Sally’s working
version




Partition 1
Partition 2




















Channels



Messages
Name – PK
Author
CreatedDate
Channel – PK
PostedDate – RK
Text
Rating
Users




Name – PK
Email
EmailUpdates
Channels
[DataServiceKey("PartitionKey", "RowKey")]
public class Message
{
// ChannelName
public string PartitionKey { get; set; }
// PostedDate
public string RowKey { get; set; }
// User defined properties
public string Text { get; set; }
public int Rating { get; set; }
}
Message message = new Message {
PartitionKey = "Channel9",
// ChannelName
RowKey = DateTime.UtcNow.ToString(), // PostedDate
Text
= "Hello PDC",
Rating = 3
};
serviceUri = new Uri("http://<account>.table.core.windows.net");
var context = new DataServiceContext(serviceUri);
context.AddObject("Messages", message);
DataServiceContext response = context.SaveChanges();
POST http://<Account>.table.core.windows.net/Messages
... <!– Atom envelope -->
<m:properties>
<d:PartitionKey>Channel9</d:PartitionKey> <!-- ChannelName -->
<d:RowKey>Oct-29</d:RowKey>
<!-- PostedDate -->
<d:Text>Hello PDC</d:Text>
<d:Rating>3</d:Rating>
</m:properties>

[DataServiceKey("TableName")]
public class TableStorageTable
{
public string TableName { get; set; }
}
// Service Uri is “http://<Account>.table.core.windows.net/”
DataServiceContext context = new DataServiceContext(serviceUri);
TableStorageTable table = new TableStorageTable("Messages");
context.AddObject("Tables", table);
DataServiceResponse response = context.SaveChanges();
serviceUri = new Uri("http://<account>.table.core.windows.net");
DataServiceContext context = new DataServiceContext(serviceUri);
var messages =
from message in context.CreateQuery<Message>("Messages")
where message.Rating == 3
select message;
foreach (Message message in messages) { }
GET http://<serviceUri>/Messages?$filter= Rating eq 3
Message message =
(from message in context.CreateQuery<Message>("Messages")
where message.PartitionKey == "Channel9"
&& message.RowKey == "Oct-29"
select message).FirstOrDefault();
message.Text = "Hi there";
context.UpdateObject(message);
DataServiceResponse response = context.SaveChanges();
PUT http://<serviceUri>/Messages(‘Channel9’, ‘Oct-29’)
<m:properties>
<d:Text>Hi there</d:Text>
<!-- Other properties are the same -->
</m:properties>
// Get the Message object for ("Channel9", "Oct-29")
context.DeleteObject(message);
DataServiceResponse response = context.SaveChanges();
DELETE http://.../Messages(‘Channel9’, ‘Oct-29’)



















ClientB
Client A
1: Ch9, Jan-2, 5
2:
Version
Rating
5 : Ch9, Jan-1, 3
If-Match: 1 Ch9, Jan-2, 4
If-Match: 1 Ch9, Jan-2, 5
1 : Ch9,
2:
Ch9,Jan-2,
Jan-2,52
9 : Ch9, Jan-3, 6






1: Ch9, Jan-2, 4
Error: 412
serviceUri = new Uri("http://<account>.table.core.windows.net");
DataServiceContext context = new DataServiceContext(serviceUri);
var allMessages = context.CreateQuery<Message>("Messages");
foreach (Message message in allMessages.Take(100))
{
Console.WriteLine(message.Name);
}
GET http://<serviceUri>/Messages?$top=100
GET http://<serviceUri>/Messages?$filter=...&$top=100
x-ms-continuation-NextPartitionKey: Channel9
x-ms-continuation-NextRowKey: Date101
100
Ch9, Date1,
Ch9, Date2,
Ch9, …
GET http://<Uri>/Messages?$filter=...&$top=100
&NextPartitionKey=Channel9
&NextRowKey=Date101
Ch9,Date100,
Ch9,Date101,
Ch9, …
Messages














Windows Azure Queues
Delete channel
Front
end
Delete messages worker
Worker
Front
End
Del Ch11
Del Ch1
Del Ch5
Queue
2
Ch1, Msg1
Ch1, Msg2
Ch1, Msg3
Ch2, Msg1
Ch2, Msg2
Ch1,…
Ch3, Msg1
Ch2,…
Messages
Channels
1. Dequeue
2.
3.
4.
Delete queue
Ch1
from
DelCh1
from
Messages
entry
Channels
Front
end
Delete messages worker
Front
End
Del Ch11
Del Ch1
Del Ch5
Queue
Del Ch1h
Delete channel
Worker 1
2
Ch1, Msg1
Ch1, Msg2
Ch1, Msg3
Worker2
Ch2, Msg1
Ch2, Msg2
Ch1,…
Ch3, Msg1
Ch2,…
Messages
Channels
1. Dequeue
2.
3.
4.
5.
Fails
DelCh1
Repeat
after
delete
is DelCh1
visible
deleting
operations
again
and
again
Ch1
start
anddelete
Msg1





















http://www.azure.com/windows

http://blogs.msdn.com/astoriateam

www.microsoftpdc.com
© 2008 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.