An introduction to Figaro, the XML Database for the .NET Framework, and a solution overview of an ASP.NET MembershipProvider built with the XML database.
3. What is Figaro?
• XML Database
– Application database
– Client or server
– < 7 MB (~6.34 MB)
– Holds up to 256 TB data
• Oracle Embedded Product
– Oracle Berkeley DB XML
– Licensed product
5. Product Editions
• Data Store (DS)
– Single reader, single writer
– High performance
• Concurrent Data Store (CDS)
– Multiple readers, single writer
• Transactional Data Store (TDS)
– Multiple readers and writers
– ACID transaction support
• High Availability
– Replication layer
– Coming soon to Figaro (late 2009)
7. Designing the Provider
• Single-app solution
– Data Store access (single reader/writer)
– Build up, then out
• CDS, TDS
• Object serialization
• One container per provider
– CDS, TDS scenarios can help create
SSO/centralized credential store
8. Membership Provider Key Objects
• FigaroMembershipProvider
• FigaroMembershipUser
– [Serializable]
– Intermediary to MembershipUser
• FigaroMembershipData
– DAL
9. Figaro Key Objects
• FigaroEnv
– Environment manager
– Not used in this example
• XmlManager
– Manage containers, object creation
• Container
– The database
– Node storage or ‘wholedoc’ storage
– Every entry has a ‘file name’ – either auto-generated or assigned
• QueryContext
– Assign variable values
– Set XML namespaces
• Figaro.BerkeleyDb.Xml.XmlDocument
– Not to be confused with System.Xml.XmlDocument
• (but you can explicitly convert to it)
– File name, Metadata
11. Adding Users
public MembershipCreateStatus CreateUser(FigaroMembershipUser user)
{
var status = MembershipCreateStatus.Success;
StartTimer();
try
{
var ms = new MemoryStream();
serializer.Serialize(ms, user);
ms.Seek(0, SeekOrigin.Begin);
var reader = XmlReader.Create(ms);
var doc = mgr.CreateDocument(reader);
doc.Name = user.UserName;
container.PutDocument(doc,mgr.CreateUpdateContext(),PutDocumentOptions.None);
}
catch (Exception ex)
{
status = MembershipCreateStatus.ProviderError;
var e = ExceptionHandler.HandleException(ex, source);
if (null != e) throw e;
}
finally
{
//you must sync or your data will disappear when you close the container!
container.Sync();
StopTimer(quot;CreateUser quot; + user.UserName);
}
return status;
}
12. Getting User Info
• GetUserPassword
– for $x in collection('membership') where
$x/FigaroMembershipUser/UserName = $user return
xs:string($x/FigaroMembershipUser/Password)
• GetNumberOfOnlineUsers
– for $x in collection('membership') where
xs:dateTime($x/FigaroMembershipUser/LastActivityDate) >=
$y return $x
13. How does it perform?
•
• MembershipData.CreateUser
MembershipData.Query
testuser995 completed in
completed in 0.0079436
0.0581908 seconds.
seconds.
• MembershipData.CreateUser
• MembershipData.GetUser testuser996 completed in
0.0749375 seconds.
completed in 0.0030428
• MembershipData.CreateUser
seconds.
testuser997 completed in
• MembershipData.Update 0.0581884 seconds.
completed in 0.0500253 • MembershipData.CreateUser
seconds. testuser998 completed in
0.0750547 seconds.
• MembershipData.UpdateUser
• MembershipData.CreateUser
completed in 0.0008002
testuser999 completed in
seconds. 0.0580407 seconds.
• •
ChangePasswordQuestionAndAns MembershipData.CreateUser
testuser1000 completed in
wer completed in 0.1160279
0.0582832 seconds.
seconds.
14. MembershipProvider Design:
Going Forward
• Concurrency
– CDS/TDS
– COM+ layer?
• Indexing
– The more users added, performance will slow
– “2 Gb Rule”
• Data Partitioning
– Keep roles, profile properties separate, or add to
membership container?
15. Planning for Concurrency
• Consider the Framework
• Consider the OS Features
– COM+
– MSDTC
• Consider the Figaro API
– Concurrent Data Store (CDS) switches
– Transactions
16. Benefits
• FLEXIBILITY
– Put whatever you want into your containers
– Change management just got a whole lot easier
• Scalability
– Concurrency
– Gigabytes, Terabytes
– Replication/HA*
• Security
– File
– Application layer
– AES Encryption support
• Performance
– Sub-millisecond operations
– ACID transaction support
– In-memory databases, log files (TDS)
• ROI
– Get more out of your XML
– Reduced need for resources (no database server!)
* Coming late 2009
17. Where do you want to go today?
• Client • Server
– Office – ASP.NET
• Custom OpenXML Packages – CMS (e.g. Oxite)
– Visual Studio – CodePlex Projects
• Developer tools – WCF, REST, Services SDKs
– WPF? – Cloud/Saas/Software +
– Search/Indexing Services
– ISV products – Server Products, Platforms
• Mobile/Embedded • MOSS, BizTalk
• Search Server
• Exchange?
– ISV Products