Tuesday, January 21, 2014

How to Debug WSO2 Carbon Products using OSGi Console


This post is basically for myself :) , and will be useful for you as well. Intent of this post is to list down frequently used and most useful OSGi commands with examples. For the sake of completeness I will give a small description before stepping into OSGi commands.

Here I will show how to debug WSO2 Carbon products via OSGi console. First you have to start Carbon server with -DosgiConsole property.

./wso2server.sh -DosgiConsole

Once the server is started properly, you can start trying commands in OSGi console. Here are some mostly used OSGi commands.

1) ss

Lists down the bundles with the life-cycle state of them.

ss <bundle_name>

Searches for given bundle name and lists matching bundles.

eg. osgi> ss data

osgi> ss data
"Framework is launched."

id State       Bundle
36 ACTIVE      gdata-core_1.47.0.wso2v1
37 ACTIVE      gdata-spreadsheet_3.0.0.wso2v1
40 ACTIVE      h2-database-engine_1.2.140.wso2v3
110 ACTIVE      org.eclipse.equinox.p2.metadata_2.1.0.v20110510
      ... ... ... ... ...


2) b <bundle_Id>

Shows the details for the specified bundle. Here bundle_id  can be figured out using above ss command.

Monday, January 20, 2014

Load Balancing and Failover in JDBC Drivers


When you have to connect your java application to a database in a database cluster, using a JDBC driver, you can simply connect to one of the nodes of the cluster. (For example, if it's a MySQL cluster you can connect to one of its SQL nodes.) But what happens if that node goes down? You lose the connectivity to the cluster and high availability aspect too which is one of main intents of having a cluster. Connecting to a single node makes a single point of failure. How do we avoid this?

If we can achieve failover aspect, we can avoid above situation. And fortunately most of the JDBC drivers support failover (and load balancing too). Intent of this post is to list load balancing/failover supported JDBC URLs of some popular JDBC drivers.

MySQL


jdbc:mysql:loadbalance://<host_1>,<host_2>,...,<host_n>/<dbname>?loadBalanceBlacklistTimeout=5000

Here, it is load balanced among given hosts. If a node is down while you're trying to connect, JDBC driver retries to connect for the given time period  (loadBalanceBlacklistTimeout). If the node is still down it tries to connect to another node. That's how failover is achieved by this.

SQL SERVER (Microsoft JDBC driver)


jdbc:sqlserver://<host_1>:1433;DatabaseName=<dbname>;failoverPartner=<host_2_for_failover>:1433

Here it supports only failover. If the active node is down, it connects to the failover (passive) node.

POSTGRE SQL 


jdbc:postgresql://<host_1>:<port_1>,<host_2>:<port_2>,...,<host_n>:<port_n>/<dbname>

Please comment if you know URLs of any other JDBC Driver.

Sunday, January 19, 2014

How to Solve "Auto Backup Stalled" Error in Your Phone



"Auto Backup Stalled. 3 Days Since Last Backup"

Since a few days ago, I've been getting this error message on my phone. That was very annoying. So I Googled a little, and found the cause and a solution.

This is caused by the photo backup feature in Google+ app in my phone. This occurs if you enable Auto-Backup and disable Auto-Sync.

So the simple solution is to either enable or disable the both of them. You can do that at 
Menu > Settings > Auto Backup
Hope this will be helpful to someone.