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
Artifact | Type |
---|---|
Dashboards | dashboards/dashboard |
Layouts | dashboards/layout |
Gadgets | dashboards/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. |
...
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 language xml <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="DataPurging" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/> <dependency artifact="Dashboard" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/> <dependency artifact="Gadget" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/> <dependency artifact="Layout" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/> </artifact> </artifacts>
Create separate directories in the top level of the C-App for the above mentioned dependencies (
Eventreceiver
_1.0.0
,EventPublisher_1.0.0
,Eventstore_1.0.0
,Eventstream_1.0.0
,Sparkscripts_1.0.0
andData_Purging_1.0.0
)
defined in theartifacts.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.- Create an
artifact.xml
file inside all dependency directories as follows.Eventstore_1.0.0 artifact .xml
Code Block language xml <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 language xml <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 language xml <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 language xml <?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 language xml <artifact name="Sparkscripts" version="1.0.0" type="analytics/spark" serverRole="DataAnalyticsServer"> <file>sample_script.xml</file> </artifact>
DataPurging_1.0.0 artifact.xml
Code Block language sql <artifact name="DataPurging" version="1.0.0" type="analytics/dataPurging" serverRole="DataAnalyticsServer"> <file>data_purging.xml</file> </artifact>
Dashboard_1.0.0 artifact.xml
Code Block language xml <artifact name="Dashboard" version="1.0.0" type="dashboards/dashboard" serverRole="DataAnalyticsServer"> <file>appman.json</file> </artifact>
Gadget_1.0.0 artifact.xml
Code Block language xml <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 language xml <artifact name="Layout" version="1.0.0" type="dashboards/layout" serverRole="DataAnalyticsServer"> <file>Test_Layout</file> </artifact>
Create the actual artifact which was specified in the
artifact.xml
above. For example, you need to create an event store configuration namedORG_WSO2_TEST.xml
, an event stream namedorg.wso2.test_1.0.0.json
, an event receiver configuration namedTextWso2EventReceiver.xml
, a Spark script configuration namedsample_script.xml
, a dashboard configuration namedappman.json
, a gadget configuration namedgadget.json
, and a layout configuration namedlayout.json
. See below for each of the configuration files.Stream - org.wso2.test_1.0.0.json
Code Block language xml { "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 language xml <?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 language xml <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 language xml <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 language xml <?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>
Data purging script
Code Block language xml <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 language js {"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 language js {"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"}}
Layout - layout.json
Code Block language js { "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" }
...