Showing posts with label Carbon. Show all posts
Showing posts with label Carbon. Show all posts

Saturday, January 30, 2016

Build Carbon Application(capp) for WSO2 DAS

You need to work with multiple artifact types while working with WSO2 DAS. Following is a list of artifacts supported in WSO2 DAS, (Tried both DAS 3.0.0 and 3.0.1)


  • Event Streams
  • Event Stores
  • Even Receivers
  • Analytic Scripts
  • Execution Plans
  • Gadgets
  • Layouts
  • Dashboards


Rather than deploying these artifacts one by one we can deploy a set of artifacts using a single deployable artifact, Carbon Application (capp)[1]. Here what we do is, create an archive with .car extension and deploy using management console.


But there can be usecases where we need to build above archive programmatically, using a build tool. Here I’m using Maven to fulfil above requirement.


Assume we have all artifacts within das-capp directory,


.
├── das-capp
│   ├── artifacts.xml
│   ├── Dashboard_1.0.0
│   ├── Eventreceiver_1.0.0
│   ├── Eventstore_1.0.0
│   ├── Eventstream_1.0.0
│   ├── GadgetTotalDailyViews_1.0.0
│   ├── GadgetViewsPreviousmonth_1.0.0
│   ├── GagdetPageFilter_1.0.0
│   ├── Layout_1.0.0
│   └── Sparkscripts_1.0.0
└── pom.xml

pom.xml


<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <modelVersion>4.0.0</modelVersion>
 <groupId>org.wso2.das.example</groupId>
 <artifactId>das-capp</artifactId>
 <version>1.0.0-SNAPSHOT</version>
 <packaging>pom</packaging>
 <name>DAS CAR</name>
 <description>This project contains artifacts to process and display sample capp</description>
 <properties>
    <artifact.types>jaggery/app=zip,service/rule=aar,lib/library/bundle=jar,event/receiver=xml,synapse/message-processors=xml,synapse/endpointTemplate=xml,synapse/message-store=xml,synapse/proxy-service=xml,event/execution-plan=siddhiql,carbon/application=car,registry/resource=zip,lib/dataservice/validator=jar,synapse/endpoint=xml,web/application=war,synapse/inbound-endpoint=xml,synapse/sequence=xml,synapse/configuration=xml,lib/registry/handlers=jar,synapse/task=xml,service/meta=xml,webapp/jaxws=war,synapse/api=xml,synapse/lib=zip,bpel/workflow=zip,lib/registry/filter=jar,service/dataservice=dbs,event/publisher=xml,synapse/local-entry=xml,synapse/priority-executor=xml,synapse/event-source=xml,synapse/template=xml,event/stream=json,lib/carbon/ui=jar,service/axis2=aar,synapse/sequenceTemplate=xml,wso2/gadget=dar,lib/synapse/mediator=jar</artifact.types>
 </properties>
 <build>
    <pluginManagement>
     <plugins>
       <plugin>
         <artifactId>maven-antrun-plugin</artifactId>
         <version>1.7</version>
       </plugin>
     </plugins>
    </pluginManagement>
    <plugins>
     <plugin>
       <artifactId>maven-antrun-plugin</artifactId>
       <executions>
         <execution>
           <phase>process-resources</phase>
           <goals>
             <goal>run</goal>
           </goals>
           <configuration>
             <tasks>
               <zip destfile="target/das-example.car">
                 <zipfileset dir="das-capp" />
               </zip>
             </tasks>
           </configuration>
         </execution>
       </executions>
     </plugin>
    </plugins>
 </build>
</project>


You can build above using mvn clean install and find the capp artifact within target/ directory. Then we can upload this deployable artifact to WSO2 DAS using management console.


[1] https://docs.wso2.com/display/DAS301/Packaging+Artifacts+as+a+C-App+Archive

Thursday, January 29, 2015

Change location of the WSO2 Carbon server logs

I'm using WSO2 AM-1.8.0 in this post. Since AM-1.8.0 released in Carbon-4.2.0 same steps apply to all products within this carbon version.

By default all log files are stored in <CARBON_HOME>/repository/logs/ directory.

Lets assume we need to move all these logs to /var/logs/wso2 directory.

1. Open log4j.properties file resides within <CARBON_HOME>/repository/conf/ directory and update following properties as mentioned below.


log4j.appender.SERVICE_APPENDER.File
log4j.appender.TRACE_APPENDER.File
log4j.appender.CARBON_LOGFILE.File
log4j.appender.ERROR_LOGFILE.File
log4j.appender.AUDIT_LOGFILE.File
log4j.appender.ATOMIKOS.File

log4j.appender.SERVICE_APPENDER.File=/var/logs/wso2/${instance.log}/wso2-apigw-service${instance.log}.log
log4j.appender.TRACE_APPENDER.File=/var/logs/wso2/${instance.log}/wso2-apigw-trace${instance.log}.log
log4j.appender.CARBON_LOGFILE.File=/var/logs/wso2/${instance.log}/wso2carbon${instance.log}.log
log4j.appender.ERROR_LOGFILE.File=/var/logs/wso2/${instance.log}/wso2-apigw-errors.log
log4j.appender.AUDIT_LOGFILE.File=/var/logs/wso2/audit.log
log4j.appender.ATOMIKOS.File =
/var/logs/wso2/tm.out 

2.  configure HTTP Access log file by changing <CARBON_HOME>/repository/conf/tomcat/catalina-server.xml
<Valve className="org.apache.catalina.valves.AccessLogValve"
directory="/var/logs/wso2"
prefix="localhost_access_log_sample."
suffix=".log"
pattern="%{xxx}i %{xxx}o"
resolveHosts="false"/>
 You may face few hick-ups if you need to move ALL logs from default location.

Eg: - patches.log, wso2carbon-trace-messages.log

At the moment there is no direct way to configure store location for above logs.These properties exist within <CARBON_HOME>/lib/org.wso2.carbon.server-4.2.0.jar and patch applying process take place even before the carbon server start. So we have bundled log4j.properties file within org.wso2.carbon.server-4.2.0.jar.

I will note down a workaround here.

Go to <CARBON_HOME>/lib/ Directory. Open the org.wso2.carbon.server-4.2.0.jar with an archive manager. Open the log4j.properties using a text editor and modify following properties.
log4j.appender.CARBON_LOGFILE.File
log4j.appender.CARBON_TRACE_LOGFILE.File
log4j.appender.CARBON_PATCHES_LOGFILE
 

Wednesday, November 27, 2013

Explore WSO2 Carbon admin Web services

The Carbon Management console is popular among WSO2 Product users.Without making any file level configuration changes, one can use web based admin console to interact with the Carbon installation.

As a Carbon developer one can ask, "Is there any other way to access those admin services rather than using the management console?"

Yes you can, Management functionalities inside the console UI communicate with back end web-services which you can use directly. All these web services are secured, you can access them with either HTTP Basic Authentication or session based authentication.

1. First you need to change the visibility of  admin web service WSDLs.
Open CARBON_HOME/repository/conf/carbon.xml and search for the HideAdminServiceWSDLs property.

Change the value of HideAdminServiceWSDLs property as follows,
<HideAdminServiceWSDLs>false</HideAdminServiceWSDLs>
2. Start Carbon server with –DosgiConsole parameter.
CARBON_HOME/bin$ sh wso2server.sh -DosgiConsole
3. Once server started in OSGI-Console mode just run listAdminServices command.
osgi> listAdminServices
Above command will list down all available admin services in your Carbon server.

I'm taking TenantMgtAdminService located at https://10.100.0.128:9443/admin/services/TenantMgtAdminService/ as a sample and explore this service within SoupUI.

4. Browse https://10.100.0.128:9443/admin/services/TenantMgtAdminService?wsdl

You can simply import this WSDL to SoapUI and check for all available services.

Create new soapui project with a name you want and https://10.100.0.128:9443/admin/services/TenantMgtAdminService?wsdl as the initial WSDL.



Happy Exploring !!!



Thursday, November 21, 2013

Deploy your own Enterprise Store [part 3]

I will discuss about few UI modifications you can do to make your own Music Store(or whatever) from what you have deployed, using WSO2 ES while following previous blog posts.You can find previous posts from [1] and [2].

At the moment we have our own mp3 asset type plus few other default asset types (gadget, site, e-book) in the ES.


First I'm going to hide all default asset types from the Store UI, there are number of ways to accomplish this task.

1. Get a fresh WSO2-ES pack and remove all default asset rxt's , asset types from store-tenant.json, publisher-tenant.json files while adding our new mp3 asset.

2. By modifying  /_system/config/store/configs/store.json in our registry. You can find this under Resources > Browse > _system > config >store > configs in our management console https://localhost:9443/admin/carbon/admin/login.jsp.

Under content menu you can update store.json with the following content by pressing Edit as text. We are going to remove all default asset types from the config.
{
  "assets": [
    "mp3"
  ],
  "assetsPageSize": 12,
  "commentsPageSize": 10,
  "userSpace": "\/_system\/governance\/users",
  "roles": {
    "Internal\/store": {
      "\/permission\/admin\/login": [
        "ui.execute"
      ]
    }
  },
  "userRoles": [
    "Internal\/store"
  ],
  "permissions": {
    "login": {
      "\/permission\/admin\/login": [
        "ui.execute"
      ]
    }
  },
  "paths": {
    "RXT_EXTENSION_PATH": "\/config\/ext\/"
  }
}
Just save it and browse our store http://localhost:9763/store/



You can update the icon-sprite.png resides under repository/deployment/server/jaggeryapps/store/extensions/assets/mp3/resources/  with a suitable one for our MP3 store.

Without writing a single line of code we can configure our simple digital asset store by using WSO2 ES :)

[1]. http://udarakr.blogspot.com/2013/11/deploy-your-own-enterprise-store-part-1.html
[2]. http://udarakr.blogspot.com/2013/11/deploy-your-own-enterprise-store-part-2.html

Friday, November 8, 2013

WSO2 products & H2 Console

How to query H2 Console while working with WSO2 carbon based product.

There are basically two ways to accomplish above mentioned.

1st method
  • Download H2 database from[1].
  • Extract and cd into the h2/bin directory.
  • Stop your carbon server.
  • Run sh h2.sh.
  • You need to enter correct JDBC URL, User Name and Password and press Connect.
In this approach each time you connect/query H2 Console you have to stop carbon server. (Bit annoying!!!)

2nd method
This is what interests everyone. In this method you don't need to download anything as we are going to use H2 Console embedded in WSO2 Product.
  • Update carbon.xml resides in CARBON_SERVER/repository/conf directory.
  • Search for "H2DatabaseConfiguration" and uncomment configuration parameters as in following screen-shot.
  • Save the configuration file and start carbon server.
  • Browse http://localhost:8082/ in your favorite browser.
  •  Enter correct JDBC URL, User Name and Password and press Connect. In my scenario,
JDBC URL : jdbc:h2:/home/udara/wso2/git/enterprise-store/modules/distribution/target/wso2store-1.0.0/repository/database/WSO2CARBON_DB
User Name : wso2carbon
Password : wso2carbon

You will get the H2 Console now.



[1] http://www.h2database.com/html/download.html