Facet Types

Definition of Facet Types

A Facet Type is a unit of capability (or method) represented by a piece of executable code (a Java class) intended to process a request. The facet type’s method selection is based on the facet lifecycle event model. In short, the A-Stack invokes the appropriate facet type method using the current facet pipeline connection context and facet instance information as argument.

Facet Types in the A-Stack

Name

Type NameDescription
MessageSffMsgFacetGeneric Message Communication.
NetworkSffNetworkFacetA-Stack cluster support. Define the list of A-Stack(s) that can participate in syncing their data
TqlSffTqlFacetThing Query Language Support (Thing Definition, Thing Interaction)
WorkflowSffWdlFacetWorkflow Language Support
Behavior TreesSffBdlFacetBehavior Tree Implementation
TopicSffTopicFacetSubscription and Notification of Model changes
SchedulingSffSequenceFacetSchedule tasks / jobs (piece of Model code) to be executed in a repeated sequence of defined interval.
Static FilesSffStaticFileFacetServe static files using A-Stack.

Message

Message Facet Type is a generic Message processing over any given specified transport. Message Facet Type does not support any specific payload to process unlike other Facet types. Message Facet Type can be used process any payload that is passed to it. 

Facet Type NameSffMsgFacet
Language SupportFacetScript
Transports

HttpServerExtensionArgs

WsServerExtensionArgs

Usage

 Facet Types are used in <NewFacetInstance> when creating a Package (Deployment) definition for your models.

SffMsgFacet Example
<NewFacetInstance fid="smartparking" name="SmartParking" type="SffMsgFacet">
  <OnOpen ModifyPipeline="HttpServerExtensionArgs" />
  <OnRequest>
    <!-- Handle Request -->
    <!-- Any FacetScript Code can go in here... ->
    <DoResponse>
       <!-- Send the response back.. ->
    </DoResponse>
  </OnRequest>
</NewFacetInstance>
Other NamesSffTcpFacet
Use Cases
  1. Publish HTTP or WebSocket Endpoint served by A-Stack to process any request and send response.
  2. Can be used to create a proxy to other facet types (like SffTqlFacet).


Network

Network Facet Type allows TQL users to specify network definition of their A-Stacks. Network Facet Type is normally used to create a cluster of A-Stacks so that the TQL storage can be shared across those A-Stacks. 

Facet Type Name
SffNetworkFacet
Language SupportNetwork Definition using <Network> Tag.
Transports

WsServerExtensionArgs

Usage

 Facet Types are used using <NewFacetInstance> when creating a Package (Deployment) definition for your models. Network defintion

is created at the time of OnActivate Facet Instance Lifecycle.

SffNetworkFacet Example
<!-- Define Cluster / Network -->
<NewFacetInstance fid="cluster" name="cluster" type="SffNetworkFacet">
		<OnActivate>
			<Process>
				<Network>
					<Group name="FarmGatewayGroup" />
					<A-Stack name="Cloud0" url="ws://10.0.1.4:8080/fid-cluster"
						group="FarmGatewayGroup" replicateTo="FarmCloudGroup"
						documentation="Cloud Summary Holder" />
					<Group name="FarmCloudGroup" />
					<A-Stack name="Cloud1"
						url="ws://farm.atomiton.com:8080/fid-cluster" group="FarmCloudGroup"
						replicateTo="FarmCloudGroup" documentation="Cloud Summary Holder" />
				</Network>
			</Process>
		</OnActivate>
		<OnOpen ModifyPipeline="WsServerExtensionArgs" />
</NewFacetInstance>

Associated within

other FacetTypes

Instances of Network Facet Types are normally associated with the TQL Facet types so that the data can be replicated. Association

can be done as follows:

SffNetworkFacet Associated within SffTqlFacet
 <!-- Cluster specific replication -->
 <NewFacetInstance fid="SmartParking" Name="TQL" Type="SffTqlFacet">
 <OnActivate>
<!-- Associating Instance of Network facet -->
 <NetworkFacet>cluster</NetworkFacet>
</NewFacetInstance>
Use Cases
  1. Replicate data between different instances of A-Stack.
  2. Broadcast messages to TQEngine(s)


TQL

Message Facet Type is a generic Message processing over any given specified transport. Message Facet Type does not support any specific payload to process unlike other Facet types. Message Facet Type can be used process any payload that is passed to it. 

Facet Type NameSffTqlFacet
Language SupportThing Interaction Language (TIL) - TQL CRUD Queries requested via <Query> tag.
Transports

HttpServerExtensionArgs

WsServerExtensionArgs

Usage

 Facet Types are used using <NewFacetInstance> when creating a Package (Deployment) definition for your models.

SffTqlFacet Example
<!-- Typical TQL Facet Definition -->
	<NewFacetInstance fid="[:RuntimeParams.WSFacetIDName:]Cluster"
		Name="TQL" Type="SffTqlFacet">
		<OnActivate>
            <!-- Associate other facet types; Either Private or Public Instances -->
			<NewFacetInstance name="tqlwfws" type="SffWdlFacet" /> <!-- Private Instance of wdl facet -->
			<NetworkFacet>?cluster</NetworkFacet> <!-- Public Instance of Network Facet -->
			<TopicFacet>?TQLGenericTopic</TopicFacet> <!-- Public Instance of Topic Facet -->
			<ImportFacet>[:RuntimeParams.MacroFacetID:]</ImportFacet> <!-- Private Instance of Msg facet -->
			<Process>
                <!-- Define TQL Storage Scheme -->
				<Storage Name="[:RuntimeParams.TQLCacheName:]" Type="SqlSff"
					Comment="[:RuntimeParams.TQLCacheName:] Database SFF Unstructured SQL database" />
                <!-- Specify the Model Definition file (TDL). Normally consists of Model definitions -->
				<Namespace>
					<Include>cloud.dbm.xml</Include>
				</Namespace>
			</Process>
		</OnActivate>
		<OnOpen ModifyPipeline="WsServerExtensionArgs" />
		<OnRequest>
			<DoRequest> <!-- HandOff the request to Facet -->
				<Process Return="CMD_NOP">
					<Message>
						<Value>
							<Include>$Request.Message.Value</Include>
						</Value>
					</Message>
				</Process>
			</DoRequest>
			<DoResponse> <!-- Process the response from Facet or send it straight through -->
				<Process>
					<Message type="[:RuntimeParams.TQLOutputFormat:]">
						<Value>
							<Include>$Response.Message.Value</Include>
						</Value>
					</Message>
				</Process>
			</DoResponse>
		</OnRequest>
</NewFacetInstance>
Associating Other Facet Types

TQL Facet normally associates other facet types that are either private or public Instances. Private Instances are those that are defined internal with the

TQL Facet Instance definition.

Use Cases
  1. Handle TQL Query request from external users over a given transport (Http or WS).


Workflow

Workflow facet types allows users to install workflow definitions that can be called from other models.

Facet Type NameSffWdlFacet
Language SupportWorkflow Definition Language (WDL)
Transports

HttpServerExtensionArgs

WsServerExtensionArg

Usage

 Facet Types are used using <NewFacetInstance> when creating a Package (Deployment) definition for your models. Workflows are

typically installed at the time of <OnActivate> Life cycle. Note that Workflows are not a request / response style or external transport.

SffWdlFacet Example
<NewFacetInstance fid="[:RuntimeParams.WdlFacetIDName:]" Name="wdl" Type="SffWdlFacet">
    <OnActivate>
      <Include></Include> <!-- Specify Workflow defintion files -->
    </OnActivate>
    <OnOpen ModifyPipeline="HttpServerExtensionArgs"/>
  </NewFacetInstance>

Associated within

other Facet Types

Private instances are associated within TQL Facet Types
Use Cases
  1. Implement complex business logic either (Thing or App) using Workflows.
  2. Private instance of Workflow Facet is a requirement for Thing and App Facets to function correctly as part of Tql Facet types.


Behavior Tree

Behavior Tree Facet implements Behavior Trees

Facet Type NameSffBdlFacet
Language SupportBehavior Definition Lanauge (BDL)
Transports

HttpServerExtensionArgs

WsServerExtensionArg

Usage

 Facet Types are used using <NewFacetInstance> when creating a Package (Deployment) definition for your models.

SffMsgFacet Example
<NewFacetInstance fid="bdl" name="bdl" type="SffBdlFacet">
      <OnOpen ModifyPipeline="WsServerExtensionArgs"/>
</NewFacetInstance>
Use Cases
  1. Implement complex business logic either (Thing or App) using Behavior trees.


Topic

Topic Facet implements Subscription and Notification both at Model - to - model and external over a websocket interface.

Facet Type NameSffTopicFacet
Language Support

Subscribe and Notification

Subscribe Example
<Subscribe sid="test" topic="test.ws.*">
    <Action>
       <!-- Take Some Action -->
    </Action>
</Subscribe>
Transports

HttpServerExtensionArgs

WsServerExtensionArg

Usage

 Facet Types are used using <NewFacetInstance> when creating a Package (Deployment) definition for your models.

SffTopicFacet Example
<NewFacetInstance fid="topic" name="topic" type="SffTopicFacet">
      <OnActivate>
       </OnActivate>
      <OnOpen ModifyPipeline="WsServerExtensionArgs"/>
      <OnError>
        <DoResponse>
          <Process>
            <Message type="xml">
              <Value>
                <Error>[:$Error:]</Error>
                <ErrorRequest>[:$Request:]</ErrorRequest>
              </Value>
            </Message>
          </Process>
        </DoResponse>
      </OnError>
 </NewFacetInstance>

Associated within

Other Facet Types

Public instances are associated within TQL Facet Types
Use Cases
  1. Allows Model to model and external Subscription and Notifications.
  2. Private instance of Topic Facet is a requirement for Model subscription to function correctly as part of Tql Facet types.


Scheduling

Sequence Facet supports scheduling of tasks at given time and frequency.

Facet Type NameSffSeqeunceFacet
Language Support

Sequence Language

Sequence Language Example
<Execute eid="test" schedule="[30../10sec]" limit="15">
      <Action>
         <JavaScript>
           sffLog.info("Doing something...");
         </JavaScript>
      </Action>
</Execute>
Transports

HttpServerExtensionArgs

WsServerExtensionArg

Usage

 Facet Types are used using <NewFacetInstance> when creating a Package (Deployment) definition for your models.

SffSequenceFacet Example
<NewFacetInstance fid="seq" name="seq" type="SffSequenceFacet">
      <OnActivate>
           <!-- Schedule something at the time of activation -->
      </OnActivate>
      <OnOpen ModifyPipeline="WsServerExtensionArgs"/>
 </NewFacetInstance>
Use Cases
  1. Scheduling of tasks at given interval and frequency.
  2. Schedule Format is: StartTime..EndTime/Interval Where StartTime and EndTime can be a hierarchical dot-delimited format.

    Example of dot-delimited format:


    2015.MAY.25.14.30min means 2015-May-25:14:30. It is not necessary to specify time units on each element as long as there is at least one and you follow the standard time interval hierarchy (i.e. year-month-day-hour-minute-second-millisecond). In the above example, “MAY” is used by the system to match all the numerals with time units (i.e. it recognizes that if MAY is a month then to the left of it must be the year and to the right must be day, hour, minute etc.). For non-standard definitions, you can always specify time unit explicitly (e.g. 2015yr.128doy.15hr, where 2015 is a year, 128 is day of the year and 15 is hour of the day). Only 24 hours format is currently supported.


Static Files

Static Files Facet Types allows users to serve static files using A-Stack

Facet Type Name
SffStaticFileFacet
Language SupportFacetScript
Transports

HttpServerExtensionArgs

WsServerExtensionArg

Usage

 Facet Types are used using <NewFacetInstance> when creating a Package (Deployment) definition for your models.

SffStaticFileFacet Example
<NewFacetInstance fid="file" name="File" type="SffStaticFileFacet">
        <OnActivate>
            <Process BasePath="web" Resource="res"/>
        </OnActivate>
</NewFacetInstance>
Use Cases
  1. Handy to serve your html5 Javascript Application using A-Stack. Avoid overhead of spinning yet another http file server!











Related pages