Building Stock Quoter system in PICML

Now we can start modelling the Quoter system using PICML. As we go through each step of the modeling processs, you can download the exported xml file of the Quoter model from here. (Note: In case you don't know, select File->Import XML from GME to convert this file to GME model)

The paradigm of PICML is designed keeping in mind the OMG Deployment & Configuration (D&C) specification (ptc/2003-07-08), so the modeling process is straightforwrd if you are familar with the specification. Please go to DAnCE project for more information.

The complete Quoter PICML model, is composed by elements distributed in the following eight folders:


Table of Contents


In the following steps, we will create the folders and the corresponding elements that populates them.

ImplementationArtifacts (.iad)

The models in this folder captures information about the dependencies between the application artifacts. We'll start by modeling the Stock_Base. These artifacts are common for both Broker and Distributor.
  1. To create the ImplementationArtifacts folder for this project, right-click rootfolder MyQuoter, select Insert Folder->ImplementationArtifacts and change the name to "ImplementationArtifacts".
  2. To create the container artifact for Stock_Base, right-Click ImplementationArtifacts, select Insert Model->ArtifactContainer, and name it "Stock_Base". Double click it to open it in the user area.
  3. Now we can populate the Stock_Base container model with the implementation artifacts representations for the Stock_Base. From the PartBrowser (in the lower left portion of GME window), add two <<ImplementationArtifact>> and one <<ImplementationArtifactReference>>. Through the Attribute Browser (in the right lower portion of GME window), name the ImplementationArtifacts "Stock_Base_svnt" and "Stock_Base_stub" respectively. And name the <<ImplementationArtifactReference>>, "Stock_Base_stub"
  4. Refer "Stock_Base_stub" (<<ImplementationArtifact>>) to "Stock_Base_stub" (<<ImplementationArtifactReference>>). To do that, simply drag the artifact to the reference, while pressing the CTRL key.
       
  5. To create a dependency relationship between the "Stock_Base_svnt" and "Stock_Base_stub", select the Connect Mode () and connect "Stock_Base_svnt" (<<ImplementationArtifact>>) to "Stock_Base_stub" (<<ImplementationArtifactReference>>). This connection is named dependson relationship, and indicates that the "Stock_Base_svnt" artifact has a dependency on "Stock_Base_stub". Note that this kind of connection is only allowed between an artifact to an artifact reference. Directly connecting two artifacts is simply not allowed by the paradigm.

Now we can start building artifacts for StockBroker. If not explicitly pointed out, please leave the settings of the component in their default state.
  1. In ImplementationArtifacts folder, create an <<ArtifactContainer>> (Insert Model->ArtifactContainer) and name it "Broker";
  2. Add the following elements:
  3. Set the references by refering them to their corresponding refered element;
  4. Switch to Connect Mode and create dependson connections according to the following relationships:
  5. Still in Connect Mode, create connections between Broker_svnt (<<ImplementationArtifact>>) and the entryPoint with value "createBrokerHome_servant" selecting connection role type <<ArtifactExecParameter>>. Create connections between Broker_exec and entryPoint with value "createBrokerHome_exec" selecting connection role type <<ArtifactExecParameter>>.

        The model built should resemble Figure 4.



Figure 4.

Now you should build the Distributor model following the same steps you did for the Broker.


ComponentImplementation (.cid)

This folder contains the models that describes the relationship of component artifacts. In our Quoter model, we will have two monolithic component; StockDistributor and StockBroker, and an assembly component StockQuoter, which is an assembly of StockDistributor and StockBroker. We will first go through a monolithic model StockBroker and then we assemble the StockQuoter component.

A monolithic component implementation description should capture the information concerning: the interface the component realizes; the artifacts it uses, and to which file it will output its object reference. In the followint steps, we'll see how this information is defined through PICML.
  1. Insert a new folder "ComponentImplementation" by selecting Insert Folder->ComponentImplementations;
  2. In ComponentImplementations create a new model Component Implementation Container (Insert Model->ComponentImplementationContainer) and name it "Broker". Open it;
  3. From the PartBrowser, add the following:
    • A <<MonolithicImplementation>>, name it "Broker";
    • A <<ComponentRef>> name it "ComponentRef" and create the reference to Quoter/InterfaceDefinition/Broker/Stock/StockBroker (To create the reference, drag the Quoter/InterfaceDefinition/Broker/Stock/StockBroker interface definition, from the Model Browser on the right part of the window, to the ComponentRef while pressing CTRL key.);
    • Three <<ImplementationArtifactsReference>>, name them: "Broker_svnt", "Broker_stub", "Broker_exec" respectively, refering to Quoter/ImplementationArtifacts/Broker_svnt, Quoter/ImplementationArtifacts/Broker_stub, Quoter/ImplementationArtifacts/Broker_exec respectively;
    • A <<Property>> name it "ComponentIOR":
      • Set the value to Broker.ior;
  4. Switch to Connect Mode, do the following connections:
    • Connect Broker (<<MonolithicImplementation>>) to ComponentRef;
    • Connect Broker to Broker_svnt, Broker_stub, Broker_exec;
    • Connect Broker to ComponentIOR. Set connection Role Type to ConfigProperty;
  5. Finally, double click in ComponentIOR, add a <<Datatype>> element named "string". Here's where the Quoter/PredefinedTypes could come in. Refer the "string" to Quoter/PredefinedTypes/string. This is a very important step, if you forget it, it will result in object null error when attempting to run the interpreter.

The implementation model should resemble Figure 5.


Figure 5

The other monolithic component, StockDistributor should be modeled exactly the same way StockBroker was modeled.
Assembly component is a recursive concept. It provides a boundary for the composition of monolithic components and/or other assembly components, i.e., it is a virtual component. So, modeling an assembly component is different from modeling a monolithic component. You don't need to worry about the artifacts or interfaces. All you need to do is to assemble the existing components. Next, we'll show how to assemble the StockQuoter.
  1. Create a <<ArtifactContainer>>, name it "StockQuoter", and open it;
  2. From the PartBrowser, add a <<ComponentAssembly>>, name it "StockQuoter" and open it;
  3. Now we will create two instances for StockBroker and StockDistributor. To do that, expand the tree in the Browser by clicking "+", in Quoter/InterfaceDefinitions/Stock/. Keep the "StockQuoter" <<ComponentAssembly>> window opened while doing this. Then drag Quoter/InterfaceDefinitions/Broker/Stock/StockBroker in the browser to the "StockQuoter" while pressing ALT key. This operation will create an instance of StockBroker for you. Repeat the same steps for Quoter/InterfaceDefinitions/Distributor/Stock/StockDistributor.
  4. Create an <<PublishConnector>>.
  5. Now assemble the components together according to Figure 1, using the connect mode ()and the resulting assembly model should look like Figure 6. Note that to create connections between StockDistributor.notify_out and StockBroker.notify_in, you will need the intermediate connector <<PublishConnector>>.



Figure 6

ComponentPackage (.cpd)


This folder contains deployable component packages models. The component package contains the necessary implementation artifacts for a particular application. Here are the steps to model the Component Package for StockBroker.
  1. Insert a "ComponentPackage" folder in the Quoter root folder, and create a <<PackageContainer>>, name it "Broker";
  2. From the PartBrowser, add the following:
    • a <<ComponentPackage>> named "Broker";
    • a <<ComponentImplementationReference>> named "Broker";
    • a <<ComponentRef>> named "Broker";
  3. Refer the <<ComponentImplementationReference>> Broker to Quoter/ComponentImplementations/Broker. Refer the <<ComponentRef>> Broker to Quoter/InterfaceDefinitions/Broker/Stock/StockBroker
  4. Switch to Connect Mode and create two connections according to the following relationship.
    • <<ComponentImplementationReference>> Broker implements <<ComponentPackage>> Broker;
    • <<ComponentPackage>> Broker realizes <<ComponentRef>> Broker.


         The model you created should resemble Figure 7.



    Figure 7

    Now create a ComponentPackage/StockDistributor following the same steps.

    We will also need to create a package for the assembly component StockQuoter. Different from the Broker and Distributor packages, the Stock Quoter does not need a >>ComponentRef>> since this assembly does not have interfaces. To make this model:
      Insert a <<ComponentPackage>>, name it StockQuoter; Insert a <<ComponentImplementationReference>>;
      • Refer the <<ComponentImplementationReference>> to Quoter/ComponentImplementations/StockQuoter/StockQuoter;
      • Name it StockQuoter.




    Figure 8


PackageConfiguration (.pcd)

This folder contains just one model capturing specific configuration of Component packages.
  1. Insert a new folder "PackageConfiguration", and create a <<PackageConfigurationContainer>>, name it "Default", click to open it.
  2. Add a <<PackageConfiguration>> named "default" and a <<ComponentPackageReference>>, name it "StockQuoter", connect "default" to "StockQuoter"
  3. Refer "StockQuoter" (<<ComponentPackageReference>>) to Quoter/ComponentPackage/StockQuoter


ToplevelPackage (.pcd)

This folder contains one model capturing information about the top-level element that will be fed to the application.
  1. Insert a new folder "ToplevelPackage", and create a <<ToplevelPackageContainer>>, it name it "Default", double click to open it.
  2. Add a <<ToplevelPackage>> named "ToplevelPackage" and a <<PackageConfigurationReference>>, name it "Default", connect "ToplevelPackage" to "default"
  3. Refer "Default" to Quoter/PackageConfiguration/Default


Targets (.cdd)

This folder contains domain-specific models capturing information about the target environment in which component-based application will be deployed. In this Quoter example, we can either deploy the two components into ONE host, or into TWO different host. We will deploy the Quoter into two different host.
  1. Insert a new folder "Targets", in this folder, inside a model "Domain"; double click to open it.
  2. From the PartBrowser, add two <<Node>> named "Broker" and "Distributor" respectively.

Now we are ready to deploy our Components to the actual physical environment.

DeploymentPlan (.cdd)

This folder contains a plan model that captures information about the assignment of component to nodes.
  1. Insert a new folder "DeploymentPlan", and insert a model <<DeploymentPlan>>; name it "Plan", click to open it
  2. From the PartBrowser, add the following:
    • Two <<CollocationGroup>>
    • Two <<NodeReference>> named "Broker" and "Distributor" respectively, refering to Quoter/Targets/Domain/Broker and Quoter/Targets/Domain/Distributor respectively
    • Two <<ComponentRef>> named "StockBroker" and "StockDistributor" respectively, refering to Quoter/ComponentImplementations/StockQuoter/StockQuoter/StockBroker and Quoter/ComponentImplementations/StockQuoter/StockQuoter/StockDistributor respectively. Note that the <<ComponentRef>> in DeploymentPlan is not refering to the interface, but rather, the actual instance of the implementation.
  3. Switch to Connect Mode, connect one <<CollocationGroup>> to <<NodeReference>> Broker, connect another <<CollocationGroup>> to <<NodeReference>> Distributor. Now the model looks like the following.



    Figure 9.

  4. Now we need to associate <<ComponentRef>> StockBroker to the <<CollocationGroup>> running on the <<NodeReference>> Broker, and <<ComponentRef>> StockDistributor to the <<CollocationGroup>> running on the <<NodeReference>> Distributor. To do that, switch the Edit Mode Bar to Set Mode (), and move the cursor to the <<CollocationGroup>> running on <<NodeReference>> Distributor, right-click on it. You will find the cursor is changed to set mode, and only the <<CollocationGroup>> you clicked in is highlighted, as shown in Figure 10.



Figure 10.

 Now move your cursor to <<ComponentRef>>  StockDistributor, and left-click it, so that it looks like Figure 11.



Figure 11

   This operation associates StockDistributor component to the <<CollocationGroup>> running on Distributor node. To do the same with Broker, just right-click on another <<CollocationGroup>>, and left-click on StockBroker <<CollocationGroup>> which is highlighted.


ComponentBuild

We have finished all the models needed to generate the descriptor files for StockQuote. This ComponentBuild folder is designed specifically to ease the effort of having to hand-code the MPC files project. I won't go into details explaining this model. Please see the example for reference.


After we are done with the modeling, the flattened_deploymentplan interpreter that comes along with PICML will help us to generate a flattened_deploymentplan.cdp file. Please make sure you generate this file to MyQuoter/descriptors.



Ming Xiong
Last modified: