keywords: concepts: products used: soa service oriented architecture webservice web compute farm enterprise messaging messages mq activemq jms msmq tibco ems smartsockets rendevous platform sdk data grid smartgrid.net smartgrid smartgraph smartpublisher smartcrawler .NET C# 1.0 1.1 2.0 ClickOnce Servers application applications distributed application cluster load balanced load balancing deployment easy rollback administration monitoring permission permissioning update updater smart smartclient zero impact risk pricing engine synapse ibm microsoft sun http://smartgrid.net http://www.smartgrid.net http://www.smartwebmail.net http://smartwebmail.net http://www.smartsoa.net http://smartsoa.net http://www.smartsoa.com http://www.smartservicesbus.net http://www.smartservicesbus.com http://www.smartservicebus.net http://www.smartservicebus.com http://www.smartremoting.net http://www.smartpublisher.net http://www.smartgraph.net http://www.smartdatatable.net http://www.smartdataset.net http://www.smartcrawler.net http://www.risk-engines.net http://www.grid-engines.com http://www.grid-os.com http://www.easygrid.net http://www.smartwebservices.net http://www.smartdesktop.net

SmartGraph.Engine An implementation of a dependency graph manager.


Contents

  1. Introduction
  2. The Engine implemenation
  3. How to use?

Introduction

The SmartGraph.Engine library contains classes for building and managing Directed Acyclic Graphs (or DAGs).

The Engine implemenation

A dependency engine is an active task which is bound to a DAG graph. The engine is an event handler. The event handling policy determines how 'dirty node' events are handled. The scheduling policy determines in what order (if at all) dirty nodes (corresponding to the graph's vertices) should be updated. Once a node has been updated if its state (or value) has changed the engine can publish a 'clean node' event.

The design of the engine is similar to a pipeline of processing. The various engine policies are connected with queues. Dirty nodes are queued for the scheduler. The scheduler queues a list of nodes for the calculation policy. The calculation policy queues clean nodes for the publisher which raises clean node events.

Node types:

  • INode - a basic node which does not raise the dirty node event. A node will be updated.
  • IActiveNode - not just a basic node. Active nodes can raise the dirty node event. They are not updated.
  • IInvariantNode - not just a basic node. Invariant nodes do not change an will not be updated. These nodes do not raise the dirty node event. Can be used to optimize graph updates.

How to use?

Some suggestions for when to use a SmartGraph.Engine follow.

Scheduling

A simple graph can model a set of tasks which must be performed in certain order (remember - no cycles in the DAG). It defines a sequential flow of control acting on the nodes. A simple application of the engine is to create tasks which must be performed periodically.

The TickingHelloWorld sample shows how to set-up a graph and an engine to perform a string concatenation on 3 nodes:

  1. a value node holding the string "hello"
  2. a value node holding the string "world"
  3. the current time, as given by a Ticker node which raises an event with a configurable frequency (sample's freq=1sec). Its output value is DateTime.Now.

The graph can be foung in TickingHelloWorld.xml. The following is a drawing of it:

The concatenated value is available after the publisher raises the clean node event from the Concat node.

To load the engine you need the following code:

public void TickingHelloWorld_WatchOutItBlocks()

{

    XmlEngineBuilder engineBuilder =

        new XmlEngineBuilder( Helpers.DataDir( "TickingHelloWorld.xml" ) );

 

    String engineName = "TickingHelloWorld";

    using ( Engine engine = new Engine( engineName, engineBuilder ) )

    {

        engine.Start();

 

        ManualResetEvent endevent = new ManualResetEvent(false);

        endevent.WaitOne();

    }

}