Volta

I just watched the Channel 9’s two part video with the Volta team and I have to say that it was mind blowing.

Volta has some really interesting ideas on how to simplify the development of distributed applications.

On the second part they get into the details of some of the obstacles they found translating IL into JavaScript such as JavaScript’s lack of a goto statement and how they got around it: using a while loop and a switch statement – a trick much like what C# does to implement “yield return”.

Other interesting thing was how they used exceptions to simulate multi-threading within the browser.

Really cool stuff worth watching!

The link below points to a post on the Volta Team Blog on Microsoft Live Labs which points to the Channel 9 videos. You also be able to get to the rest of the blog from there.

http://labs.live.com/volta/blog/Volta+On+Channel+9.aspx

Enjoy!

FSRM COM API documentation hits the streets

Back in March I wrote about my findings regarding the API of a feature introduced in Windows Server 2003 R2 called File System Resource Manager (FSRM).

At the time these APIs were not documented, but with the eminent release of Windows Server 2008, Microsoft released the documentation for the COM API at MSDN Library. These aren’t yet the managed libraries I’ve been waiting for, but at least we can safely start doing Interop with the COM version without fear of changes in the API! 🙂

Trip to Redmond

Late last month I took a trip to Redmond to do some consulting for Microsoft Learning.

Together with four other folks, we were responsible for helping designing the Workflow Foundation exam.

Pictures of us can be found in my blog in Portuguese here.

Following are several pictures I took while in Redmond

 

 

The hotel (motel?) where I stayed.

 

Several pictures of the Microsoft Campus

This place is pretty amazing I should say.

Programming FSRM quotas

Introduction

Recently I was evaluating the options I had for implementing disk quotas on a backend system running on a major Internet Service Provider in Brazil.

Windows offers quota management up to some degree since NTFS 5 (Windows 2000) with user/volume quotas. Those were not appropriate for our scenario since we needed to set quotas on a per directory basis and this was not supported natively by Windows until the arrival of Windows Server 2003 R2.

R2 brings us a new feature called File Server Resource Manager a.k.a. FSRM. It is exposed for the system administrator as an MMC 3.0 snap-in.

Unfortunately, as of today Microsoft does not officially support any way for programming against FSRM quotas.  I said “officially support” because if the snap-in can do it, probably we can too! So after some research I found two DLLs called srm.dll and srmlib.dll that happens to do the stuff we want. Srm.dll exposes FSRM functionality through COM and srmlib.dll is a managed code wrapper around srm.dll.

Let’s take a look at some sample code:

using System;

using System.Collections.Generic;

using System.Text;

using Microsoft.Storage;

using System.IO;

using System.Runtime.InteropServices;

 

namespace Fsrm {

    class Program {

        static void Main(string[] args) {

            string directoryName = @"c:FsrmTests";

 

            // Creates a directory for testing if necessary

            if (!Directory.Exists(directoryName)) {

                Directory.CreateDirectory(directoryName);

            }

           

            ISrmQuotaManager quotaManager = new SrmQuotaManagerClass();

            ISrmQuota quota = null;

            try {

                // Try to get quota info

                quota = quotaManager.GetQuota(directoryName);

                quota.QuotaLimit *= 2;

            }

            catch (COMException ex) {

                unchecked {

                    if (ex.ErrorCode == (int)0x80045301) {

                        // Quota doesn’t exist for this directory. Create it.

                        Console.WriteLine("No quota defined for ‘{0}’. Creating quota.", directoryName);

                        quota = quotaManager.CreateQuota(directoryName);

                        quota.QuotaLimit = 1024 * 1024;

                    }

                    else {

                        Console.WriteLine(ex);

                        return;

                    }

                }

            }

 

            // Update quota info

            quota.Commit();

 

            // Add new file to the diretory to see QuotaUsed getting updated

            File.WriteAllText(directoryName + @"" + Path.GetRandomFileName() + ".txt", "Testing FSRM directory quotas");

            Console.WriteLine("New file added. Quota doubledrn{0} of {1} used.", quota.QuotaUsed, quota.QuotaLimit);

        }

    }

}

 

This sample doubles the size of the directory’s quota and puts a file in it every time it is run.

There are a bunch of other classes and methods available. Have fun!