System Information Model

From RuleCore Support

Jump to: navigation, search

The ruleCore System Information Model (SIM) contains information about the live state of the ruleCore CEP Server as it executes.

The content in the SIM is automatically maintained to reflect the current state of the ruleCore CEP Server.


Contents

Usage

The SIM is used for various purposes, for example:

  • Listing available definitions - All definitions of items such as rules, situations and actions can be found in the SIM. Definitions are created using the systems events AddRuleDef, AddSituationDef and AddActionDef and are made available immediately in the SIM.
  • Listing defined user events - Before an user event can be sent into ruleCore it must be defined using the AddEventDef system event. The SIM contains all defined user events.
  • List rule instances - When a rule instance is created it's state and internal data structures can be monitored by finding them in the SIM. For example, it's easy to list the contents of a rule instance tracking a particular business entity such as a long running transaction.
  • Monitoring situation progress - As a situation develops its progress can be monitored by querying the SIM.
  • Examine view contents - Each rule instance is executed in an unique context of events called the event stream view. The view contains a window into the inbound stream of events and contains commonly only semantically related events.
  • Referencing items - When an item such as a rule needs to reference other items it is done using references through the SIM.
  • Component internals - Each plug-in component creates an entry in the SIM and add any component specific information.


Representation

The SIM consists internally of dynamic data structures which are updated as needed. These data structures have an external representation which is the user's view of the SIM.

The SIM is represented externally using XML and have the appearance of a single XML document. This external representation of the SIM can be treated as a DOM document which can be queried using XPath and transformed using XSLT. XPath queries can be executed against the SIM using the SysInfoQuery system event.

The SIM calls rules, situations, actions and their definitions for Items. Note that definitions for items are also items themselves.

Plug-in components can dynamically define new types of items and register them into the SIM. A number of pre-defined containers are used as place holders at the top level of the SIM to provide fixed and easy to find locations for items.


Overall Structure

The external representation of the SIM is organized as an XML document with <SysInfo> element as its root node. The entire SIM structure is defined in the SysInfo namespace.

The first level contains a number of fixed elements serving as place holders for all the dynamic information in the SIM.

The <Items> element contains a number of <Type> elements which serve as containers for items as they are created. The name attribute of Type is used to identify the type of items present in the container.

The RuleDef, SituationDef, ActionDef, ViewDef, EventDef, EntityDef and ZoneDef contains definitions of items. The item instances created from these definitions can be found under Rule, Situation, Action and View.


The <Components> contains information about the currently loaded plug-in components. Each component is represented with an element with the same name as the component. The component can create any suitable structure of elements under its root element.


Containers in the SIM

Locations of elements in the SIM are specified using XPath expressions.

A number of fixed and predefined containers exist in SIM. These are filled with dynamic information as the user creates new definitions and when item instances are created in response to inbound events.

Fixed Containers in the SIM
Description Location Contains
Container for all items /SysInfo/Items items
Container for event definitions /SysInfo/Items/Type[@name="EventDef"] <EventDef>
Container for entity definitions /SysInfo/Items/Type[@name="EntityDef"] <EntityDef>
Container for rule definitions /SysInfo/Items/Type[@name="RuleDef"] <RuleDef>
Container for situation definitions /SysInfo/Items/Type[@name="SituationDef"] <SituationDef>
Container for action definitions /SysInfo/Items/Type[@name="ActionDef"] <ActionDef>
Container for event view definitions /SysInfo/Items/Type[@name="ViewDef"] <ViewDef>
Container for geographic zone definitions /SysInfo/Items/Type[@name="ZoneDef"] <ZoneDef>
Container for rule instances /SysInfo/Items/Type[@name="Rule"] <Rule>
Container for situation instances /SysInfo/Items/Type[@name="Situation"] <Situation>
Container for action instances /SysInfo/Items/Type[@name="Action"] <Action>
Container for entity instances /SysInfo/Items/Type[@name="Entity"] <Entity>
Container for list definitions /SysInfo/Items/Type[@name="List"] <List>
Container for dynamically loaded plug-in components /SysInfo/Components component elements


Example

A newly booted ruleCore CEP Server can have a SIM with the following structure:

<SysInfo>
  <Items>
    <Type name="EntityDef"/>
    <Type name="RuleDef"/>
    <Type name="SituationDef"/>
    <Type name="EventDef"/>
    <Type name="ViewDef"/>
    <Type name="ZoneDef"/>
    <Type name="Rule"/>
    <Type name="ActionDef"/>
    <Type name="Action"/>
    <Type name="Situation"/>
    <Type name="View"/>
    <Type name="Entity"/>
    <Type name="List"/>
  </Items>
  <Components>
    <ActionDefManager name="ActionDefManager"/>
     some elements removed for clarity...
    <TreeNodeCreator name="TreeNodeCreator"/>
  </Components>
</SysInfo>

Note the actual configuration can be different from this example as plug-in components can register new item types and the actual components loaded can vary.

SIM Elements

The default SIM contains a number of elements. These elements contain information about defined items and their instances.

A plug-in component can add its own information to the SIM so the actual information available might differ from this documentation.


RuleDef

All rule definitions can be found under

/SysInfo/Items/Type[@name="RuleDef"]

Each situation definition is defined with a RuleDef element.

Example:

<Type name="RuleDef" xmlns:rc="http://www.rulecore.com/2008/base"
  xmlns="http://www.rulecore.com/2008/user"
  xmlns:base="http://www.rulecore.com/2008/base"
  xmlns:sim="http://www.rulecore.com/2008/user">
  <RuleDef id="ab12224d-1123-4350-902b-3bfa9a9fa18f" name="S1">
    <ViewRef>
      <ViewRef name="V1" default="true"><base:XPath>...</base:XPath></SituationRef>
    </ViewRef>
    <Situations>
      <SituationRef name="S1"><base:XPath>...</base:XPath></SituationRef>
    </Situations>
    <Actions>
      <SituationDetected situationName="S1">
        <ActionRef name="A1"><base:XPath>...</base:XPath></ActionRef>
      </SituationDetected>
      <UndetectableSituation situationName="S1">
        <ActionRef name="A2"><base:XPath>...</base:XPath></ActionRef>
      </UndetectableSituation>
    </Actions>
  </ActionDef>
</Type>


SituationDef

All situation definitions can be found under

/SysInfo/Items/Type[@name="SituationDef"]

Each situation definition is defined with a SituationDef element.

Example:

<Type
  name="SituationDef"
  xmlns:base="http://www.rulecore.com/2008/base"
  xmlns="http://www.rulecore.com/2008/user">
  <SituationDef id="abd4684d-4ca1-4350-962b-3bf0456fa18f" name="S1">
    <Detector>  
      <Within name="" evalMode="once" timeframe="00:00:10">
        <SequenceSearch name="" evalMode="once">
          <Pickup see="all" keep="last" name="A" evalMode="once"><base:XPath>View/Event[@type="A"]</base:XPath></Pickup>
          <Pickup see="all" keep="last" name="B" evalMode="once"><base:XPath>View/Event[@type="B"]</base:XPath></Pickup>
          <Pickup see="all" keep="last" name="C" evalMode="once"><base:XPath>View/Event[@type="C"]</base:XPath></Pickup>
        </SequenceSearch>
      </Within>
    </Detector>
  </SituationDef>
</Type>


ActionDef

All action definitions can be found under

/SysInfo/Items/Type[@name="ActionDef"]

Each action definition is defined with a ActionDef element.

Example:

<Type name="ActionDef"
  xmlns:base="http://www.rulecore.com/2008/base"
  xmlns="http://www.rulecore.com/2008/user">
  <ActionDef id="f00a9212-c09a-ffa1-1231-3bf04533318f" name="A1">
    <Event>
      <EventRef>
        <base:XPath>Type/Event[@name="A"]</base:XPath>
      </EventRef>
      <Body>
        <XsltBuilder>
          <!-- XSLT stylesheet here... -->
        </XsltBuilder>
      </Body>
    </Event>
  </ActionDef>
</Type>


EventDef

All user event definitions (user, system and control class) can be found under

   /SysInfo/Items/Type[@name="EventDef"] 

Each user event definition is defined with a EventDef element.

EntityDef

All entity definitions can be found under

   /SysInfo/Items/Type[@name="EntityDef"] 

Each entity definition is defined with an EntityDef element.


ViewDef

All view definitions can be found under

   /SysInfo/Items/Type[@name="ViewDef"] 

Each view definition is defined with a ViewDef element.


ZoneDef

All geographic zone definitions can be found under

   /SysInfo/Items/Type[@name="ZoneDef"] 

Each zone definition is defined with a ZoneDef element.

Example:

<ZoneDef name="Gothenburg City">
    <Description>This is zone Gothenburg City</Description>
    <Polygon>
      <Coordinates>
        list of coordinates...
      </Coordinates>
    </Polygon>
  </ZoneDef>
 
  <ZoneDef name="Gothenburg">
    <Description>This is zone Gothenburg</Description>
    <Circle center="11.5782, 57.9190" radius="15000"/>
  </ZoneDef>


Rule

Information about all current rule instances can be found by selecting

   /SysInfo/Items/Type[@name="Rule"] 

The Rule element and all its sub-elements are described in full detail here.


Situation

Information about all current situation instances can be found by selecting

   /SysInfo/Items/Type[@name="Situation"] 

The Situation element and all its sub-elements are described in full detail here.


Action

Information about all current action instances can be found by selecting

   /SysInfo/Items/Type[@name="Action"] 

The Action element and all its sub-elements are described in full detail here.


View

Information about all current view instances can be found by selecting

   /SysInfo/Items/Type[@name="View"] 

The View element and all its sub-elements are described in full detail here.


Entity

Information about all current entity instances can be found by selecting

   /SysInfo/Items/Type[@name="Entity"] 

The Entity element and all its sub-elements are described in full detail here.

<Entity entityId="Driver2" entityType="Driver" id="ac914e39-334e-4446-8913-85ebb8357007">
  <Property name="Ranking">
    <Value>1</Value>
  </Property>
  <Property name="Zone">
    <Values>
      <Value>Store1</Value>
    </Values>
  </Property>
  <Property name="Position">
    <Coordinates>57.704240,11.969520,0.000000</Coordinates>
  </Property>
</Entity>


Querying the SIM

The SIM can be queried by using a SysInfoQuery system event. It's body contains a single Query element with the XPath query expression.

The query returns a SysInfoQueryResponse system event with the result of the query.

Example Queries

<?xml version="1.0" encoding="UTF-8"?>
<SysInfoQuery
  xmlns="http://www.rulecore.com/2008/user"
  xmlns:base="http://www.rulecore.com/2008/base"
  xmlns:sim="http://www.rulecore.com/2008/user"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.rulecore.com/schema/rulecore-event TreeQuery.xsd"
  base:eventId="0eb61bd8-f9be-4574-abe7-35d13d94268a"
  base:eventTimestamp="2007-06-12T14:00:01.1023Z"
  base:eventClass="system">
 
  <base:EventHeader>
    <base:SecurityInfo>
      <base:Credentials>8b73a10d-4e70-4162-8778-1e743cb0fd3f</base:Credentials>
    </base:SecurityInfo>
  </base:EventHeader>
 
  <base:EventBody>          
    <Query><base:XPath>/sim:SysInfo</base:XPath></Query>
  </base:EventBody>
</SysInfoQuery>


Extending

The SIM can be extended to include information from user supplied plug-in components. A component can register itself in the SIM and has full control over how its internal data is presented in the SIM.

Example

<Rule id="a8a9b8e9-a476-4fcc-9fe3-3dd1000723f4" name="R1">
  ...
  <Situation ruleId="a8a9b8e9-a476-4fcc-9fe3-3dd1000723f4" id="6dc3219c-7301-492d-ab8e-cfaac6924338" name="S1">
    <PickupSets pickupNode="D">
      <EventSet>
        <Event timestamp="2008-02-04T12:00:56.501511" type="D" id="1d6bcb60-4fee-487d-9e2f-b5a982f037f7">
          <EventBody/>
        </Event>
      </EventSet>
    </PickupSets>
    <PickupSets pickupNode="B">
      <EventSet>
        <Event timestamp="2008-02-04T12:00:56.497946" type="B" id="c36d1b07-e4d5-4ac4-abc5-f5873b5a20df">
          <EventBody/>
        </Event>
      </EventSet>
    </PickupSets>
    <Detector value="true:const">
      <SequenceSearch completionDegree="1.0" evalMode="once" name="" value="true:const" evalCount="4">
        <Pickup completionDegree="0.5" evalMode="once" name="C" value="true:const" evalCount="1"/>
        <Pickup completionDegree="0.5" evalMode="once" name="D" value="true:const" evalCount="1"/>
        <Pickup completionDegree="0.5" evalMode="once" name="B" value="true:const" evalCount="1"/>
        <Pickup completionDegree="0.5" evalMode="once" name="A" value="true:const" evalCount="1"/>
      </SequenceSearch>
    </Detector>
    <PickupSets pickupNode="C">
      <EventSet>
        <Event timestamp="2008-02-04T12:00:56.499731" type="C" id="6f795041-180c-4147-8b35-3ce941e2aa1a">
          <EventBody/>
        </Event>
      </EventSet>
    </PickupSets>
    <PickupSets pickupNode="A">
      <EventSet>
        <Event timestamp="2008-02-04T12:00:56.495647" type="A" id="d14ebeab-9f6f-49f7-8eb2-c6c303575d53">
          <EventBody/>
        </Event>
      </EventSet>
    </PickupSets>
  </Situation>
</Rule>
Personal tools