Music Library Synchronization, Sonos Tips

by Brian Hitney 29. November 2011 18:15

I love Windows Home Server.   I’ve been using Windows Home Server for years, and just purchased a Windows Home Server 2011(WHS) box from Newegg (great deal on a HP Proliant micro server). 

image

Many have asked me why I like WHS so much – it’s NAS, it’s a media server, it’s backup.   It’s a step up from a simple NAS device (although, admittedly, not as plug and play), offers more flexibility and is more cost effective than a Drobo.  A small backup agent can take snapshots of your PC, typically on a daily basis, so they can be restored to a given point in time.  I keep snapshots of my initial installation, for example.  Restoring to those backups is a simple process. 

I’m also a big fan of Sonos, a whole-home music solution that works amazingly well.  What Sonos has done exceedingly well is blend quality hardware, quality software, and reasonable (but not cheap) price points.  I have an extensive music collection, and I point Sonos to a share on my WHS box to index and stream music. 

However, I consider my laptop my “database of record” for my music.  It’s where I download stuff, and I take it with me because I’m often on the road.  The problem I run into is keeping my WHS library in sync with my laptop.   In my case, I want to mirror my library on the WHS exactly as it is on my local collection – and because I’m often reorganizing my collection, adding tags, etc., I need a simple way to do this. 

Enter Robocopy.   Robocopy (Robust file copy) is now built into Windows, and it’s a simple command line tool with a number of options to make this a snap.   For example, if I want to mirror a folder on my laptop with my WHS, this command will do it:

c:\>robocopy "D:\Music" "\\BEAST\Sonos\music" /mir /r:10 /MT:8

D:\Music is my local folder, my server is \\Beast.  The /mir command is for mirror – it’s the same as using /purge and /e:  /purge is to delete files at the target folder that no longer exist in the source, and /e is to copy all subdirectories, including empty ones.   The /r:10 will tell it to retry up to 10 times, in case of some network glitch, and the /MT:8 will have Robocopy use 8 threads to speed things along.   (If you’re familiar with Robocopy, I don’t recommend using /z (restartable) mode as it adds overhead, not needed given the size of files we’re dealing with.)

Now, what if you don’t keep all your music local, and just want to copy it over?   You don’t want to use /mir since it will remove files you otherwise want to keep!   The rest of the command will work fine, but if you move/rename files locally that were previously copied, you’ll have to remember to do that manually on the server.  Once Robocopy does its thing, you’ll get a nice summary:

            Total    Copied   Skipped  Mismatch    FAILED    Extras
Dirs :      1384        29      1355          0         0         0
Files :     15078       381     14697         0         0         0
Bytes : 117.188 g   3.212 g 113.975 g         0         0         0
Times :   0:16:40   0:02:52                       0:00:00   0:00:48

Here, it copied about 30 new folders.  It took about 16 minutes to run, but that’s largely due to new content, having copied some 3.2gb of new files.   Assuming minor changes only, the process typically runs in about 30 seconds.

If you want to get fancy, you could even have Robocopy monitor your folders for changes. 

The next challenge is to have Sonos update its music index once new files are copied over.   Sonos can update its index on a daily basis (or manually via the control software), but I want it done automatically after new files are copied over.  This one is a bit trickier, but thanks to some gurus in the Sonos forums, it’s not impossible.   I’m including the .exe file here for you to use.  Obviously, trusting an exe from someone on the web is not something I’d do, but it’s a .NET assembly which means you can use a tool like JustDecompile to crack it open and look at the source yourself.   Having said that, I’m not responsible if this code causes your computer to blow up, your music collection to vanish, or kills any puppies.

The source code looks like so, and it sends an SOAP packet to a specified Sonos unit to trigger an index rebuild:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Net;

namespace SonosIndexUpdater
{
class Program
{

static void Main(string[] args)
{
string ip;

if (args != null && args.Length > 0)
{
ip = args[0].Trim();
}
else
{
Console.WriteLine("Missing IP Address. Please add IP address for any Sonos unit.");
return;
}

string header1 = @"SOAPACTION: ""urn:schemas-upnp-org:service
:ContentDirectory:1#RefreshShareIndex"
"";
string postData = @"<s:Envelope xmlns:s=""http://schemas.xmlsoap.org/soap/envelope/""
s:encodingStyle="
"http://schemas.xmlsoap.org/soap/encoding/"">
<s:Body>
<u:RefreshShareIndex xmlns:u="
"urn:schemas-upnp-org:service:ContentDirectory:1"">
<AlbumArtistDisplayOption></AlbumArtistDisplayOption></u:RefreshShareIndex>
</s:Body>
</s:Envelope>"
;
string url = string.Format("http://{0}:1400/MediaServer/ContentDirectory/Control", ip);

byte[] byteArray = Encoding.UTF8.GetBytes(postData);

try
{
System.Net.WebRequest req = System.Net.WebRequest.Create(url);
req.Headers.Add(header1);
req.ContentType = "text/xml";
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
req.ContentLength = byteArray.Length;
req.Timeout = 5000;

Stream dataStream = req.GetRequestStream();

dataStream.Write(byteArray, 0, byteArray.Length);
dataStream.Close();

using (WebResponse response = req.GetResponse())
{
Console.WriteLine("Response from Sonos: {0}",
((HttpWebResponse)response).StatusDescription);

using (dataStream = response.GetResponseStream())
{
using (StreamReader reader = new StreamReader(dataStream))
{
string responseFromServer = reader.ReadToEnd();
Console.WriteLine("Data: {0}", responseFromServer);
}
}
}
}
catch (Exception ex)
{
Console.WriteLine("Exception occured: {0}", ex.Message);
}

}
}
}
 
To use it, you’d just pass in the IP address of any Sonos unit:
 
c:\>SonosIndexUpdater 192.168.1.100

If you stumbled on this and aren’t a developer but want to try it out, you can build this for free using Visual Studio Express.    Here are some files:
 

EXE file only: Download
VS2010 Solution: Download

Tags: , , ,

Development | Technology | Tech Tips

Azure Camps Coming Soon!

by Brian Hitney 26. November 2011 13:55

Jim, Peter, and I are gearing up for another road trip to spread the goodness that is Windows Azure! The Windows Azure DevCamp series launched recently with a two-day event in Silicon Valley, and we’re jumping on the bandwagon for the East Region.

309b14f7-2f41-49c0-9a50-2c979d9bc97a

We have five stops planned in December, and we’re doing things a bit differently this go-round. Most of the events will begin at 2 p.m. and end at 9 p.m. – with dinner in between of course. The first part will be a traditional presentation format and then we’re bringing back RockPaperAzure for some “hands-on” time during the second half of the event. We’re hoping you can join us the whole time, but if classes or your work schedule get in the way, definitely stop by for the evening hackathon (or vice versa). By the way it wouldn’t be RockPaperAzure without some loot to give away, so stay “Kinected” to our blogs for further details on what’s at stake!

Here’s the event schedule, be sure to register quickly as some venues are very constrained on space. You’ll want to have your very own account to participate, so no time like the present to sign up for the Trial Offer, which will give you plenty of FREE usage of Windows Azure services for the event as well as beyond.

 

Registration Link Date Time
NCSU, Raleigh NC Mon, Dec. 5th, 2011 2 – 9 p.m.
Microsoft, Farmington CT Wed., Dec. 7th, 2011 2 – 9 p.m.
Microsoft, New York City Thur., Dec. 8th, 2011 9 a.m. – 5 p.m.
Microsoft, Malvern PA Mon., Dec. 12th, 2011 2 – 9 p.m.
Microsoft, Chevy Chase MD Wed., Dec. 14th, 2011 2 – 9 p.m.

Tags: , , ,

Azure | USCloud | Technology | Development | Events

Geo-Load Balancing with the Azure Traffic Manager

by Brian Hitney 10. October 2011 14:18

One of the great new features of the Windows Azure platform is the Azure Traffic Manager, a geo load balancer and durability solution for your cloud solutions.  For any large website, managing traffic globally is critical to the architecture for both disaster recovery and load balancing.

When you deploy a typical web role in Azure, each instance is automatically load balanced at the datacenter level.   The Azure Fabric Controller manages upgrades and maintenance of those instances to ensure uptime.  But what about if you want to have a web solution closer to where your users are?  Or automatically direct traffic to a location in the event of an outage?   

This is where the Azure Traffic Manager comes in, and I have to say, it is so easy to set up – it boggles my mind that in today’s day and age, individuals can prop up large, redundant, durable, distributed applications in seconds that would rival the infrastructure of the largest websites. 

From within the Azure portal, the first step is to click the Virtual Network menu item.

image

On the Virtual Network page, we can set up a number of things, including the Traffic Manager.   Essentially the goal of the first step is to define what Azure deployments we’d like add to our policy, what type of load balancing we’ll use, and finally a DNS entry that we’ll use as a CNAME:

image

We can route traffic for performance (best response time based on where user is located), failover (traffic sent to primary and only to secondary/tertiary if primary is offline), and round robin (traffic is equally distributed).   In all cases, the traffic manager monitors endpoints and will not send traffic to endpoints that are offline.

I had someone ask me why you’d use round robin over routing based on performance – there’s one big case where that may be desirable:  if your users are very geography centric (or inclined to hit your site at a specific time) you’d likely see patterns here one deployment gets maxed out, while another does not.   To ease the traffic spikes to one deployment, round robin would be the way to go.  Of course, an even better solution is to combine traffic shaping based on performance with Azure scaling to meet demand.

In the above image, let’s say I want to create a failover for the Rock Paper Azure botlab (a fairly silly example, but it works).   I first added my main botlab (deployed to South Central) to the DNS names, and then added my instance deployed to North Central:

image 

From the bottom of the larger image above, you can see I’m picking a DNS name of botlab.ctp.trafficmgr.com as the public URL.  What I’d typically do at this point is go in to my DNS records, and add a CNAME, such as “www.rockpaperazure.com” –> “rps.ctp.trafficmgr.com”.

In my case, I want this to be a failover policy, so users only get sent to my North Central datacenter in the event the south central instance is offline.  To simulate that, I took my south central instance offline, and from the Traffic Manager policy report, you’d see something like this:

image

To test, we’ll fetch the main page in IE:

image

… and we’re served from North Central.  Of course, the user doesn’t know (short of a traceroute) where they are going, and that’s the general idea.  There’s nothing stopping you from deploying completely different instances except of course for the potential end-user confusion!

But what about database synchronization?   That’s a topic for another post …

Tags: , , ,

Azure | Development | USCloud | Technology

Returning to Chess

by Brian Hitney 14. February 2011 20:18

Many years ago, I was a reasonably active person in computer chess and OTB (over-the-board) chess playing, though admittedly I was more interested in the computer science behind chess rather than my own chess playing strength.   I owe this resurgence in my interest to my daughter as her interest in the game has grown.   I’ve broken out the nice pieces, chess clock, and of course, software!

I’ve been searching for casual chess meetups in the Greensboro, NC area, and haven’t had much luck (if you know of any, let me know). 

When I left the chess scene (approaching a decade ago), endgame tablebases were becoming very popular for chess engine play – and to my surprise, tablebases haven’t really changed much.   Tablebases represent perfect endgame knowledge as a database (loosely); the idea being that chess engines can do a lookup to see if a given position is won or lost, without having to evaluate the rest of the game.  3, 4, and 5 piece tablebases are quite common.  Size quickly becomes a factor: I believe a complete 6-piece tablebase approaches 1 TB in size.  

While a 5-piece tablebase doesn’t leave a lot of material on the board (remember, 2 of those 5 pieces are each player’s king), a chess engine can probe the data with more pieces on the board to gauge the strength in a position.   For example, if there are 7 pieces on the board, and white has an opportunity to exchange a piece, it can instantly look up whether that exchange is a won or lost position.

This is quite a bit different than opening knowledge.  In general, chess engines don’t play opening moves.  Authors create opening books based on grandmaster-level games and the engine or GUI automatically plays those moves.    I believe endgame knowledge is ultimately how chess will be solved – and perhaps this is an interesting area for cloud computing.   Of course, it took until 2007 for checkers to be solved, so solving chess isn’t going to happen in the near future.  Generating the endgame tablebases isn’t so much of a problem, it’s the storage – and storing this data in the cloud, opening it up via some sort of API for chess engines, would be great to see if the latency could be dealt with.  (I wish I had something more concrete to say about that with Azure as a solution!)

Chess engines, the heart of a chess app, are stronger than ever.  Some of them, like Stockfish, are even open source.   10 years ago, free engines may have been weak, but today, Stockfish and others can beat many of the commercial engines.  In my next post, I’ll discuss some of the problems I perceive with one of the largest Chess software companies: ChessBase.

Tags: , ,

Technology | Chess | Babble

New Worldmaps Reporting Site

by Brian Hitney 10. January 2011 13:43

Thanks to the folks at Infragistics, there’s a new reporting site for Worldmaps!   This Silverlight application not only looks great, but provides many new ways to drill down into the data:

image

One of the cool things you can do is easily compare to sites – the app has tabs that allows you to add multiple sites (unlike the still-existing old dashboard which showed only your neighbors in the leaderboard):

image

image

What’s even cooler is playing around with the Gapminder stats:

image

A Gapminder chart is ideal for animating data over time in a way that a simple 2-D chart doesn’t.   The bottom line is: this app is so much fun just to play around with.   Many thanks to Jason Beres, Mihail Mateev, Riddhima Shelat, and others (I’m sure I’m leaving people out!) for making this possible!  

Check out Mihail’s post here on the project!

Tags: ,

Technology | Worldmaps

Connected Show: Migrating To Azure

by Brian Hitney 7. January 2011 11:29

I recently sat down with Peter Laudati, my cloud colleague up in the NY/NJ area, and discussed Worldmaps and the migration to the cloud in Peter’s and Dmitry’s Connected Show podcast .   Thanks guys for the opportunity!

Connected Show - Episode #40 –

Migrating World Maps to Azure

A new year, a new episode. This time, the Connected Show hits 40! In this episode, guest Brian Hitney joins Peter to discuss how he migrated the My World Maps application to Windows Azure. Fresh off his Azure Firestarter tour through the eastern US, Brian talks about migration issues, scalability challenges, and blowing up shared hosting.

Also, Dmitry and Peter rap about Dancing with the Stars, the XBox 360 Kinect, Dmitry’s TWiT application for Windows Phone 7, and Dmitry’s outdoor adventures at 'Camp Gowannas'.

Show Link: http://bit.ly/dVrIXM

image

Tags: , ,

Azure | Technology | Development

You Know You’re a Geek When…

by Brian Hitney 29. November 2010 01:03

Over the long weekend I decided to start cleaning out the garage – a project, by my estimates, will take several years to complete.  I came across some old software that has been hiding in some box for … well, decades.  I found many 5 1/4” floppy disks of some old favorite games I used to play.  Recognize any?  (Many of the labels are in pretty bad condition.)

WP_000024

First up is the original Zork.   Nothing more really needs to be said on this one.

WP_000023

I probably put the most number of hours into this one.  This was Ultima III – not sure why I never really played the other Ultimas until much later. 

WP_000026

StarGlider wasn’t as well known as Ultima or Zork, but I was so jazzed about this game because it was like the Star Wars arcade game – where you would fly your x-wing into the death star with the vector graphics. 

WP_000025

Night Stalker was also on Intellivision – no, it’s not a Richard Ramirez RPG, it was kind of like a creepy Pac-Man style game.

WP_000027

I have almost no memory of this game, Murder on the Zinderneuf.   I was big into Clue and games like “Stop Thief!” and this game was very much along those lines.

WP_000028

Everyone who claims to be a geek knows Archon.   Archon played like Chess, but when “battling” another player by landing on their square, you’d be whisked away to a virtual battlefield.  Stronger pieces had an advantage but that’s what made it fun.

WP_000029

I spend a great deal of time playing this one (The Ancient Art of War), too, and from what I remember I was pretty frustrated at that.   This was a really great strategy game for its time…

WP_000030

… which was followed up by a sequel, The Ancient Art of War at Sea

WP_000031

Hacker was a fun adventure game – probably the first to make you feel like a real hacker. 

And saving the best for last:

WP_000033

That’s right.  The original Flight Simulator.  

The good ol’ days.

Tags: , ,

Games | Technology

Book Review: Azure in Action

by Brian Hitney 5. May 2010 12:33

Most of the people who know me know I’ve invested a lot of my time in Windows Azure.  “I’m all in.”  :)   Last year, we began doing presentations on Azure after it was announced at PDC 2008.  Over the months, from SDS to SQL Azure, PDC 2008 to PDC 2009, the platform evolved and of course, is now under general availability.  I went through a lot of trials and tribulations as I migrated Worldmaps and the created @Home with Windows Azure applications. 

Learning any new platform takes a leap of faith.  It requires an investment of time,  and belief in the future of the technology.  Over the coming years, the cloud will become increasingly relevant for both companies and developers, and, in the case of Windows Azure, understanding how to get up to speed quickly and efficiently is critically important.

A few weeks ago, I found out that a colleague of mine, Brian Prince, has coauthored a book (with Chris Hay) entitled Azure In Action.  I was able to get an advanced copy, and spent some time over the past couple of weeks reading through the book.  I have to say, I am pretty impressed … I just wished I was able to read this before I touched the Azure platform.

The book includes a number of code samples, however will not teach you ASP.NET (as you might expect).  Rather, it details the platform, and how to take advantage of everything from diagnostics to remote management, and of course Azure storage options.   It’s really a great resource on getting up to speed on the cloud quickly and understanding the various offerings.  It also goes into the Windows Azure AppFabric with a few code samples as well, which is nice to see.   AppFabric (both Server and Azure versions) could take its own book, but it’s nice to get a taste of what’s available.

If you’re at the point where your considering Azure, would just like to learn the platform, or have an good reference for what features are in the platform, it’s definitely a good read. 

Tags: ,

Reviews | Technology | Azure

Slides from Azure Roadshow

by Brian Hitney 29. March 2010 09:50

I’ve had a number of requests for slides and resources for the recent Azure roadshow in NC and FL – here are the slides and resources.  The slides are for sessions 2 and 3:

Worldmaps application:  http://www.myworldmaps.net

Stumbler application (shown during breaks): http://www.myworldmaps.net/stumbler

SETI @ Home: http://setiathome.ssl.berkeley.edu/

Folding @ Home: http://folding.stanford.edu/

Tags: , ,

Microsoft | Events | Technology | Azure

Azure Miniseries #2: Deployment

by Brian Hitney 13. February 2010 18:39

In my first Azure Miniseries post, I showed setting up a new cloud service project and migrating an existing ASP.NET application into Azure.   Before I dive into other topics, I figured I’d jump to the end and discuss deployment – getting your Azure application into the cloud.  

Get Microsoft Silverlight

Link to original post with download links.

Tags: , ,

Azure | Microsoft | Technology

your host...

Brian Hitney
Developer Evangelist
Microsoft Corp.

About Me

My Worldmap