Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

C-App namely Carbon Application is an archive format collection of different artifacts bundled to a single deployable component. C-App files have CAR extensions and can be deployed to different runtimes. Each runtime will only deploy the artifacts which match with the role that the runtime is playing.

...

Visualization artifacts

ArtifactType
Dashboardsdashboards/dashboard
Layoutsdashboards/layout
Gadgetsdashboards/gadget
Note

If the above mentioned artifacts are being deployed using a C-App, you are restricted on editing or deleting them. Therefore, if you need to edit the C-App, you need to re-pack and re-deploy it.

...

Code Block
languagetext
├── artifacts.xml
├── Eventreceiver_1.0.0
│   ├── artifact.xml
│   └── TestWso2EventReceiver.xml
├── EventPublisher_1.0.0
	├──artifact.xml
	└──TestLoggerPublisher.xml
├── Eventstore_1.0.0
│   ├── artifact.xml
│   └── ORG_WSO2_TEST.xml
├── Eventstream_1.0.0
│   ├── artifact.xml
│   └── org.wso2.test_1.0.0.json
└── Sparkscripts_1.0.0
|	├── artifact.xml
|	└── sample_script.xml
└── DataPurging_1.0.0
	├── artifact.xml
	└──data_purging.xml
└── Dashboard_1.0.0
|	├── artifact.xml
|	└── appman.json
|── Gadget_1.0.0
|	├── artifact.xml
|	└── Test_Gadget
|── Layout_1.0.0
|	├── artifact.xml
|	└── Test_Layout
  1. Create the top level artifacts.xml file of the C-App which defines the set of folders included in it as shown below.

    Code Block
    languagexml
    <artifacts>
    	<artifact name="DASTestCApp" version="1.0.0" type="carbon/application">
        	<dependency artifact="Eventstore" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/>
        	<dependency artifact="Eventreceiver" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/>
    		<dependency artifact="EventPublisher" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/>
        	<dependency artifact="Eventstream" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/>
        	<dependency artifact="Sparkscripts" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/>
            		<dependency artifact="DashboardDataPurging" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/>
            <dependency artifact="GadgetDashboard" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/>
            <dependency artifact="LayoutGadget" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/>
     	</artifact>
    </       <dependency artifact="Layout" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/>
    	</artifact>
    </artifacts>
  2. Create separate directories in the top level of the C-App for the above mentioned four dependencies (Eventreceiver _1.0.0, EventPublisher_1.0.0 Eventstore_1.0.0, Eventstream_1.0.0, and Sparkscripts Sparkscripts_1.0.0 and Data_Purging_1.0.0) defined in the artifacts.xml file.

    Info

    You can have multiple dependencies as required with a directory for each of them in the same level as the artifacts.xml file in the C-App. Include the name and the version of the artifact in the name of the directory.

  3.  Create an artifact.xml file inside all dependency directories as follows.

    Eventstore_1.0.0 artifact .xml

    Code Block
    languagexml
    <artifact name="Eventstore" version="1.0.0" type="analytics/eventstore" serverRole="DataAnalyticsServer">
    	<file>ORG_WSO2_TEST.xml</file>
    </artifact> 

    Eventstream_1.0.0 artifact.xml

    Code Block
    languagexml
    <artifact name="Eventstream" version="1.0.0" type="event/stream" serverRole="DataAnalyticsServer">
    	<file>org.wso2.test_1.0.0.json</file>
    </artifact>

    Eventreceiver_1.0.0 artifact.xml

    Code Block
    languagexml
    <artifact name="Eventreceiver" version="1.0.0" type="event/receiver" serverRole="DataAnalyticsServer">
    	<file>TextWso2EventReceiver.xml</file>
    </artifact>

    EventPublisher_1.0.0 artifact.xml

     

    Code Block
    languagexml
    <?xml version="1.0" encoding="UTF-8"?>
    <artifact name="EventPublisher" version="1.0.0" type="event/publisher" serverRole="DataAnalyticsServer">
        <file>TestLoggerPublisher.xml</file>
    </artifact>

     

    Sparkscripts_1.0.0 artifact.xml

    Code Block
    languagexml
    <artifact name="Sparkscripts" version="1.0.0" type="analytics/spark" serverRole="DataAnalyticsServer">
    	<file>sample_script.xml</file>
    </artifact>
    Dashboard

    DataPurging_1.0.0 artifact.xml

     

    Code Block
    language
    xml
    sql
    <artifact name="
    Dashboard
    DataPurging" version="1.0.0" type="
    dashboards
    analytics/
    dashboard
    dataPurging" serverRole="DataAnalyticsServer">
        
    <file>appman
    <file>data_purging.
    json<
    xml</file>
    </artifact>

     

    Gadget

    Dashboard_1.0.0 artifact.xml

    Code Block
    languagexml
    <artifact name="GadgetDashboard" version="1.0.0" type="dashboards/dashboard" serverRole="DataAnalyticsServer">
        <file>appman.json</file>
    </artifact>

    Gadget_1.0.0 artifact.xml

    Code Block
    languagexml
    <artifact name="Gadget" version="1.0.0" type="dashboards/gadget" serverRole="DataAnalyticsServer">
        <file>Test_Gadget</file>
    </artifact>

    Layout_1.0.0 artifact.xml

    Code Block
    languagexml
    <artifact name="Layout" version="1.0.0" type="dashboards/layout" serverRole="DataAnalyticsServer">
        <file>Test_Layout</file>
    </artifact>
  4. Create the actual artifact which was specified in the  artifact.xml above. For example, you need to create an event store configuration named  ORG_WSO2_TEST.xml , an event stream named  org.wso2.test_1.0.0.json , an event receiver configuration named  TextWso2EventReceiver.xml , a Spark script configuration named   sample_script.xml , a dashboard configuration named  appman.json , a gadget configuration named  gadget.json ,   and a layout configuration named  layout.json . See below for each of the configuration files.

    Stream - org.wso2.test_1.0.0.json

    Code Block
    languagexml
    {
      "name": "org.wso2.test",
      "version": "1.0.0",
      "nickName": "Test Stream",
      "description": "A test stream",
      "metaData": [
    	{
      	"name": "remote_host",
      	"type": "STRING"
    	},
    	{
      	"name": "tenant_id",
      	"type": "INT"
    	}
      ],
      "correlationData": [
    	{
      	"name": "activity_id",
      	"type": "STRING"
    	}
      ],
      "payloadData": [
    	{
      	"name": "operation_name",
      	"type": "STRING"
    	},
    	{
      	"name": "service_name",
      	"type": "STRING"
    	}
      ]
    }

    Event Store - ORG_WSO2_TEST.xml

    Code Block
    languagexml
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <EventStoreConfiguration>
    <Source>
           <StreamId>org.wso2.test:1.0.0</StreamId>
       </Source>
       <TableSchema>
             <ColumnDefinition>
               <Name>meta_remote_host</Name>
               <EnableIndexing>true</EnableIndexing>
               <IsPrimaryKey>false</IsPrimaryKey>
               <EnableScoreParam>false</EnableScoreParam>
               <Type>STRING</Type>
           </ColumnDefinition>
           <ColumnDefinition>
               <Name>meta_tenant_id</Name>
               <EnableIndexing>false</EnableIndexing>
               <IsPrimaryKey>false</IsPrimaryKey>
               <EnableScoreParam>false</EnableScoreParam>
               <Type>INTEGER</Type>
           </ColumnDefinition>
           <ColumnDefinition>
               <Name>correlation_activity_id</Name>
               <EnableIndexing>true</EnableIndexing>
               <IsPrimaryKey>false</IsPrimaryKey>
               <EnableScoreParam>false</EnableScoreParam>
               <Type>FACET</Type>
           </ColumnDefinition>
           <ColumnDefinition>
               <Name>operation_name</Name>
               <EnableIndexing>true</EnableIndexing>
               <IsPrimaryKey>false</IsPrimaryKey>
               <EnableScoreParam>false</EnableScoreParam>
               <Type>STRING</Type>
           </ColumnDefinition>
           <ColumnDefinition>
               <Name>service_name</Name>
               <EnableIndexing>false</EnableIndexing>
               <IsPrimaryKey>false</IsPrimaryKey>
               <EnableScoreParam>false</EnableScoreParam>
               <Type>STRING</Type>
           </ColumnDefinition>
       </TableSchema>
       </EventStoreConfiguration>

    Event receiver - TestWso2EventReceiver.xml

    Code Block
    languagexml
     
    <eventReceiver <eventReceiver name="TestWso2EventReceiver" statistics="disable"
    	trace="disable" xmlns="http://wso2.org/carbon/eventreceiver">
    	<from eventAdapterType="wso2event">
        	<property name="events.duplicated.in.cluster">false</property>
    	</from>
    	<mapping customMapping="disable" type="wso2event"/>
    	<to streamName="org.wso2.test" version="1.0.0"/>
    </eventReceiver>

    Event publisher - TestLoggerPublisher.xml

     
    Code Block
    languagexml
    <?xml<eventPublisher versionname="1.0TestLoggerPublisher" encodingstatistics="UTF-8"?>
    <eventPublisher name="TestLoggerPublisher" statistics="disable"
      trace="disable" xmlns="http://wso2.org/carbon/eventpublisher">
      <from streamName="org.wso2.test" version="1.0.0"/>
      <mapping customMapping="disable" type="json"/>
      <to eventAdapterType="logger">
        <property name="uniqueId">TestLoggerPublisher</property>
      </to>
    </eventPublisher>

    Spark script - sample_script.xml

     

    Code Block
    languagexml
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <Analytics>
    	<Name>AddNewScriptTestWithouTask</Name>
    	<Script>define table TEST_CAPP (server_name string, ip STRING, tenant INTEGER, sequence LONG, summary STRING);SELECT ip FROM TEST_CAPP;SELECT server_name, count(*) FROM TEST_CAPP GROUP BY server_name;</Script>
    	<CronExpression>0 * * * * ?</CronExpression>
    </Analytics> STRING, tenant INTEGER, sequence LONG, summary STRING);SELECT ip FROM TEST_CAPP;SELECT server_name, count(*) FROM TEST_CAPP GROUP BY server_name;</Script>
    	<CronExpression>0 * * * * ?</CronExpression>
    </Analytics>

    Data purging script 

    Code Block
    languagexml
    <analytics-data-purging>
        <cron-expression>0 0 0 * * ?</cron-expression>
        <purge-include-tables>
            <table>org.wso2.test</table>
            <table>TEST_CAPP</table>        
        </purge-include-tables>
        <data-retention-days>1</data-retention-days>
    </analytics-data-purging>

    Dashboard - appman.json

     

    Code Block
    languagejs
    {"id":"appman","title":"appman","description":"","permissions":{"viewers":[],"editors":["Internal/everyone"]},"pages":[{"id":"landing","title":"My Dashboard","layout":{"id":"layout-3","title":"Layout 3","description":"This is a sample grid","thumbnail":"local://store/layout/layout-3/index.jpg","url":"local://store/layout/layout-3/index.hbs","content":"\n   <div class=\"row\">\n        <div id=\"a\" class=\"col-md-4 ues-component-box\"></div>\n        <div id=\"b\" class=\"col-md-4 ues-component-box\"></div>\n        <div id=\"c\" class=\"col-md-4 ues-component-box\"></div>\n    </div>\n    <div class=\"row\">\n        <div id=\"d\" class=\"col-md-10 ues-component-box\"></div>\n        <div id=\"e\" class=\"col-md-2 ues-component-box\"></div>\n    </div>\n    <div class=\"row\">\n        <div id=\"f\" class=\"col-md-4 ues-component-box\"></div>\n        <div id=\"g\" class=\"col-md-4 ues-component-box\"></div>\n \t<div id=\"h\" class=\"col-md-4 ues-component-box\"></div>\n    </div>\n\n"},"content":{"d":[{"id":"24w6ukj9olz69a4i","content":{"id":"Temperature_By_City","title":"Temperature By City","type":"gadget","thumbnail":"local://store/gadget/usa-business-revenue/index.png","data":{"url":"local://store/gadget/Temperature_By_City/index.xml"},"styles":{"title":"Temperature By City","borders":true},"options":{"dataSource":{"type":"STRING","title":"Data Source","value":"/portal/gadgets/bar-chart/datasource/dataFile4.jag","options":[],"required":false},"updateGraph":{"type":"STRING","title":"Update Interval (s)","value":"No","options":[],"required":false}}}}]}}],"landing":"landing"}

    Gadget - gadget.json

     

    Code Block
    languagejs
    {"id":"Test_Gadget","title":"Temperature By City","type":"gadget","thumbnail":"local://store/gadget/usa-business-revenue/index.png","data":{"url":"local://store/gadget/Temperature_By_City/index.xml"}}
    Laoyut

    Layout - layout.json

    Code Block
    languagejs
    {
        "id": "Test_Layout",
        "title": "Test_Layout",
        "description": "This is a sample grid",
        "thumbnail": "local://store/layout/layout-3/index.jpg",
        "url": "local://store/layout/layout-3/index.hbs"
    }

...