About the author

J Sawyer is a developer based in Houston, TX who absolutely loves to write code. After spending 9 years at Microsoft, he moved on to other things and is currently the Lead Developer for the RealTime Data Management team at Logica US. He spends his days building Really Cool Things around StreamInsight and having a blast doing it.

He has been involved with HDNUG, one of the oldest and largest .NET-focused user groups in the US, since its inception in 2001 and has watched it grow from 5-10 technologists meeting around a conference table to a thriving community of over 5000 with regular meeting attendance averaging 100 attendees. He currently serves as the Vice President. You can join him at HDNUG on the second Thursday of every month at the Houston Microsoft office.

He also loves to ride his Yamaha FZ1. And sometimes his Ninja 650. And also his Honday XR-400 dirt bike. But he doesn't code and ride at the same time. That would be bad.

PI for StreamInsight Webinar with OSISoft

July 22, 2011 9:31 AM

Next Wednesday, my colleague Craig Bauhaus and I will be joining OSISoft to present a webcase on using PI System with StreamInsight, using the recently released PI for StreamInsight adapters. A vCampus subscription is required; please see this announcement on vCampus to register for the webinar.

For those of you that work in the various industries that are related to sensors, I’m sure that you are very familiar with OSISoft’s PI System. In fact, one of the questions that we’ve gotten a LOT is around how PI and StreamInsight fit together … and why you might need/want StreamInsight if you already have PI. Both solutions have their place and their purpose and this is something that will be highlighted and discussed in the presentation.

Tags:

StreamInsight Templates–New Build/Release

July 19, 2011 6:27 AM

I just posted this last night on CodePlex. There is nothing new in there but there was some general cleaning up and some fixes to a couple of issues based on feedback. Some of the changes:

  • Added System.ServiceModel to the console project. I could have sworn it was there before …
  • Fix for the project versions. They now all (properly) show up as Fx 4.0, no client profile.
  • In the catch statements, the exception types/variables are commented out. This prevents compiler warnings.
  • Naming of variables in a couple of places to make a little more sense.
  • All input adapters now have a ProductEvents() method.
  • All output adapters now have a skeleton for ConsumeEvents() that also looks for the Stopping() state.
  • Factory classes don’t return the new adapters immediately. Instead, a temp/return variable is set and then returned after the switch statement. This makes it easier to insert custom logic for creation vs. reuse of input adapters.
  • Fix for names … some adapters didn’t have the proper file names.

I am working on templates for extensibility points and have started the UDA item template but that wasn’t quite ready for this build. There will also be templates for UDO’s and UDSO’s.

I think that covers it. As with the last release, please provide feedback.

Tags:

StreamInsight | Open Source

Visual Studio Project and Item Templates for StreamInsight

July 12, 2011 7:34 AM

I’ve just published – and created an initial release for – a set of Visual Studio project and item templates for StreamInsight. The release dropped yesterday is a beta primarily for feedback on the templates, particularly the naming conventions, comments and sample boilerplate code. The items are placed in a “StreamInsight” grouping in the Add New dialogues so they’re very easy to find. There are four project templates:

  • A console application project template that creates a basic app based on the Simple StreamInsight Application that I posted about 2 months ago.
  • A StreamInsight library project template that creates a blank DLL project with the StreamInsight references added. Unlike the built-in DLL project template, this template does not include “Class1.cs” … which has always gotten on my nerves.
  • Item templates for both input and output adapters, typed and untyped. These are multi-file item templates and add the factory, a configuration class and adapters for edge, point and interval events. The typed adapters add a basic/simple type class as well. Each adapter is placed in its own folder and has its own namespace. Because of how the replacement parameters work with the templates, the file names have the format [BaseItemName][Direction].[ItemType]. The base item name will be a short name for the source/destination for the adapter. For example, a point adapter for, say, WCF input adapter for edge events would be WcfInput.Edge. When naming this in the Add New Item dialogue, you would use “Wcf” only.

Project Templates:

Project Templates

Item Templates:

Item Templates

New Item in Solution Explorer:

SIInputAdapter

In the near future, I’m planning on adding item templates for the various StreamInsight specific extension points such as UDA’s and, when version 1.2 is released, UDSO’s.

In the longer term, I’d like to make this a wizard rather than simple item templates. A wizard may allow me to get away from the “.” in the file names and it will allow users to select existing classes for the typed input adapters rather than creating a “phony” one, thereby creating a better user experience. Once I do that, the VSIX will need to be installed via MSI, which would also allow for the addition of Visual Studio snippets for common query patterns and other code chunks. Ambitious goals, perhaps, but those are the only ones worth having, right?

Creating the templates themselves was a royal pain in the a$$. Not so much because of the actual process but because the documentation for creating templates sucks so badly. Some of the documented replacement parameters documented are simply wrong – as in, they don’t get replaced!. Others aren’t documented at all, which makes discovery of these things far more difficult. Considering the number of templates that the Microsoft folks create (and especially the Visual Studio group), one would hope that the documentation would be better that the suckage that exists on MSDN. I wound up digging around in the Visual Studio templates installed on my machine than to figure out some of this stuff.

Of course, because I am a big fan of .NET Open Source software, it is available on CodePlex … and you, dear reader, are welcome to sign up if you’d like to help!

Tags:

StreamInsight | Open Source | Visual Studio Tools

Speaking @ SQL Saturday : Baton Rouge

July 11, 2011 9:35 AM

I just got the notice that my session for SQL Saturday #64 in Baton Rouge was accepted – which means that I’ll be speaking (of course!). I’m calling the presentation Data in the Stream (think bad 70’s song) since I thought it’d be different and somewhat amusing. I’ll probably add the same subtitle that I used at HDNUG: Getting’ Kinky with Real Time Data – again, because I think it’d be somewhat amusing. Since I’m not the Microsoft DE anymore, I can be a little more creative with my sessions titles and not worry about Microsoft marketing getting all huffy about it.

I’m looking forward to getting back to Baton Rouge. I’ve always really enjoyed the town and the local developer community there. I’ve not decided yet, but I may well ride the FZ down. Smile

Tags:

How StreamInsight Data is Different – Part II

July 8, 2011 10:47 AM

In a previous post, I outlined how StreamInsight adds an additional dimension to data – the dimension of time – and how events in StreamInsight correlate to events that we see and experience every day. I’ll now dig a little more into this topic.

As things happen in the world around us, seconds, minutes, hours go by and our brain processes and interprets these events. All the while things are happening, time is passing by at a regular, known pace … but that’s not how we experience it. Sometimes time flies by (having a good, interesting discussion over lunch with our friend) and sometimes it drags (waiting around to be seated and a very busy restaurant when you’re hungry). If, however, we use a video camera to record the lunch (because we’re strange like that), the camera will see the events at the regular, known, pace of seconds. So, depending on how we are getting the information in, time may “pass” differently. It may be based on information from our senses that we are processing or it may be external and ticking by regularly like the video camera. Now, back to lunch. My friend and I have placed our orders and our waiter brings our food out and places our orders in front of us. Did he place them down in front of us at the same time? It depends on how we are looking at it and what our time reference is for “at the same time”. Technically, unless he is some sort of super-waiter that can handle an order in each hand and perfectly synchronize his hands to put them both down at the exact same nanosecond, they aren’t happening at the same time. But we don’t usually split hairs like that and we don’t experience, mentally, simultaneity like that. Still, that’s a pretty limited time window. If the waiter brings out, say, my order first (mmmm … I has cheezburger) and then my friend’s order 5 minutes later (ewwww … chicken livers), we aren’t going to say that he brought our orders out at the same time. In StreamInsight, Current Time Increments (CTIs) provide a way to handle time windows and to understand what “at the same time” means within the context of the application. Like our experience, CTIs may or may not happen at regular intervals and they may move quickly or slowly. They may be controlled programmatically or declaratively by input adapter (IDeclareAdvanceTimeSettings), the query (AdvanceTimeGenerationSettings) or even another stream by importing CTIs. Our experience of time really isn’t much different. It is not uncommon to say that two events happened “at the same time” when, in fact, they were off by a few seconds (or more). When we say “at the same time”, we really mean that the events happened within a window that we understand to be simultaneous. And it is the CTIs that allow us to define that in StreamInsight.

When StreamInsight does joins and unions, it joins and unions those events that are happening at the same time … that is, events that are valid within the current CTI window. For our lunch example, if we had a stream of the “open hours” interval events, a stream for our “starting/ending lunch” edge event and a stream for the individual point events of our lunch, they would all participate in the join or union. If the event’s valid times are outside the CTI window, they will not participate in the join or union. Those valid times are determined by the start and end times on the events. Furthermore, these joins are happening on the data as it is happening … in a way very much like we perceive events happening in time during our daily experience. The human brain is, after all, a massively parallel complex event processing engine.

Going back to lunch, let’s also say that here is a thunderstorm outside during lunch. It’s raining cats and dog, lightning flashing, thunder rolling. We’re all familiar with first seeing the lightning and then hearing the thunder. We know that these events occur at the same time but we don’t “get” them at the same time. Instead, the thunder has latency when compared to the lightning; the event is actually simultaneous with the lightning but it’s arrival is some time later. In the StreamInsight, we have ways of handling this. First, when you handle your CTIs declaratively, either using IDeclareAdvanceTimeSettings or using AdvanceTimeGenerationSettings, you can specify a delay for late-arriving events that then allows these events to be processed with the appropriate, on-time arriving events. For events that arrive even later than that, you can specify dropping or adjusting those events. An example of IDeclareAdvanceTimeSettings is below. In this example, we’re saying “Everything that happens in a 5 second window is considered simultaneous. Wait for a second before that window is closed. Anything that comes in late should be adjusted to the current application time.”

var advanceTimeSettings = new AdapterAdvanceTimeSettings(
                new AdvanceTimeGenerationSettings(
                    TimeSpan.FromSeconds(5), //Frequency of the CTI
                    TimeSpan.FromSeconds(1)), //Delay for late-arriving events
                AdvanceTimePolicy.Adjust);

One caveat with using IDeclareAdvanceTimeSettings … if your adapter is not enqueuing events, the StreamInsight engine will not keep enqueuing CTIs. The CTIs are enqueued only while your adapter is sending events into the queue. So … don’t think that it’s going to keep happily chugging away on, say, a reference stream adapter when you aren’t pushing events in.

If you are programmatically enqueuing your CTI events, you have even more control – you can really do whatever you want/need/desire to do since you enqueue the CTI time yourself.

Now … we’ve been talking a lot about time and you may think that it’s always happening now and related to the system clock. While that can be true, it’s not necessarily true. StreamInsight runs with application time, not system clock time. What does that mean? Well, it means, first of all, that events don’t have to be enqueued with a timestamp of DateTimeOffset.Now. You can enqueue events with any time that you want. You could, for example, re-run events from a log file using the original timestamp … and you would need to enqueue your CTIs with the proper (in the past) timestamps. You could call this “playback” mode … you’re reviewing events in the past as they happened; for example, watching a video of an event in your life. Like that video, you don’t have to watch it at 1x speed … you can fast forward through events. Your application time does not have to be now … it can be 10 years ago. When you enqueue your events and CTIs, you enqueue them with the appropriate timestamp 10 years ago as well.

Tags:

StreamInsight