Sunday, February 26, 2012

Setting up a Cassandra cluster using wso2 carbon


If you want to use WSO2 security model with Cassandra cluster here I'll show you, how you can setup a cassandra cluster using wso2 carbon.

First you need to download wso2 carbon (I am using version 3.2.2)

Then install cassandra feature by using the p2 repository from http://dist.wso2.org/p2/carbon/releases/3.2.2/ to wso2 carbon server.

This will install Cassandra 0.7 version to your carbon server.











Adding p2 repository (http://dist.wso2.org/p2/carbon/releases/3.2.2/)












Installing Cassandra 3.2.2 feature


After finishing the installation restart the carbon server. Now carbon server will work as your Cassandra server.


setup few more cassandra nodes using wso2 carbon as above according to your requirement.
You can follow the instruction given by this site for setting up the cassandra cluster.
The cassandra.yaml configuration file is located in $wso2carbon_home/repository/conf/advanced/ directory.


Add following configuration file (cassandra-auth.xml) $wso2carbon_home/repository/conf/advanced/ in order to view keyspaces using Cassandra Keyspaces ui (change the username and password accordingly).


<Cassandra>
   <EPR>https://localhost:9443/services/CassandraSharedKeyPublisher</EPR>
   <User>USERNAME</User>
   <Password>PASSWD</Password>
</Cassandra>

cassandra-auth.xml










Cassandra Keyspaces ui


Once you finish the configuration. You can check the status of the cluster by using Cassandra cluster ui or else You can use nodetool comes with Apache Cassandra to monitor the cluster.









Cassandra cluster monitor ui 


nodetool 

$./nodetool -h 192.168.0.100 -p 9999 ring -u admin -pw admin

Address         Status State   Load            Owns    Token                                    
                                                       113427455640312821154458202477256070485  
192.168.0.100   Up     Normal  20.36 MB        33.33%  0                                        
192.168.0.101   Up     Normal  251.64 MB       33.33% 56713727820156410577229101238628035242    
192.168.0.102   Up     Normal  20.95 MB        33.33%  113427455640312821154458202477256070485

note: remote jmx agent port number in carbon server is 9999 + offset (default offset in carbon.xml is 0)


Thursday, February 16, 2012

Fixing ADB databinding issue when web service method returning OMElement


When I try to call a web service which return an OMElement, I faced above issue (My Axis2 version is 1.6.1). Following I have shown the steps that I did for fixing the issue.

This is the part of the stack trace.


org.apache.axis2.AxisFault: org.apache.axis2.databinding.ADBException: Any type  element type has not been given
    at org.apache.axis2.AxisFault.makeFault(AxisFault.java:430)
    at org.wso2.carbon.bam.presentation.stub.QueryServiceStub.fromOM(QueryServiceStub.java:8908)
    at org.wso2.carbon.bam.presentation.stub.QueryServiceStub.queryColumnFamily(QueryServiceStub.java:800)
    at org.wso2.carbon.bam.clustermonitor.ui.ClusterAdminClient.getClusterStatistics(ClusterAdminClient.java:148)


If you check the schema of the response element in your generated wsdl(by axis2) it should similar to this.


<xs:element name="queryColumnFamilyResponse">
      <xs:complexType>
         <xs:sequence>
                <xs:element minOccurs="0" name="return" nillable="true" type="xs:anyType" />
         </xs:sequence>
      </xs:complexType>
</xs:element>

In order to fix the ADB databinding issue you need to change the above schema as follows and regenerate the stub code.


<xs:element name="queryColumnFamilyResponse">
     <xs:complexType>
          <xs:sequence>
              <xs:any processContents="skip"/>
          </xs:sequence>
     </xs:complexType>
</xs:element>

Then ADB will generate code that represents the content of OriginalMessage as an OMElement and this will fix your problem.