Feeds:
Posts
Comments

Posts Tagged ‘Tips’

Some Cassandra gotchas

Here are some points to keep in mind when working with Cassandra.

  • Have to use ordered partitioner if you want row keys in sorted order. Be aware that if the row keys are not distributed properly it would create hot spots since most of rows will be concentrated to several nodes.
  • Columns are sorted using definitions given when creating the column family but row keys are not sorted according to them.
  • If you see only hex values in Cassandra-cli for column keys and values in the shown results use ‘as’ and ‘assume’ to get the human readable values of the column keys and values. See this thread.

Advertisements

Read Full Post »

I was reading up on JMS of late. The more I read the more I got confused about the usage of terms persistent and durable in the context of JMS. Then I found this blog which cleared my issues. Thanks Nigel for the great post. :). Anyway here is the gist of that blog I committed to my memory.

  • Persistent apply to messages while durable apply to subscriptions.
  • Queues don’t have durable/ non-durable distinction because consumer always gets a durable subscription.
  • For queues:
  1. Persistent : Message will be saved on disk and sent later if consumer is inactive.
  2. Non-persistent : Messages will be saved in-memory and sent later if consumer is inactive. But they will not survive a broker re-start.
  • For topics:
  1. Persistent & Durable : Message will be saved both on-disk and in-memory and sent later if subscriber is inactive.
  2. Persistent  & Non-Durable : Message will not be saved either in-memory or on disk and any inactive subscriber at the moment of message receipt at broker will not receive the message.
  3. Non-persistent & Durable : Message will be saved in-memory and sent later if subscriber is inactive. So it will not survive a broker re-start.
  4. Non-persistent & Non-Durable : Message will not be saved either in-memory or on disk and any inactive subscriber at the moment of message receipt at broker will not receive the message. Similar to Persistent & Non-Durable case.
  • In all these cases message is sent immediately if subscriber is active.

Read Full Post »

I use Maven Bundle plugin a lot since our projects are OSGi based. Basic idea I had of this plugin is that this plugin makes an OSGi bundle out of a normal jar (basically by augmenting the META-INF file) if we do declare exported and private package information correctly in it’s configuration section in the POM declaration. Normal procedure followed would be to copy the configuration from an existing POM and tweaking it according to the current project requirements. My knowledge about it was just about it until recently. It was when I bumped up on a strange issue one day I was forced to read more on the subject and fortunately solution was not that far away with the amount of comprehensive documentation and FAQ section found at plugin’s site [1].

So why am I making a blog out of this if all what you want to know is well documented somewhere else?

Well, mostly to document some points which do matter, in a concise point form as a future self reference rather than going through the lengthy documentation every time when my memory fails me. (Not a rare occurance I would say.. :)).

So here goes.. My points with bullets.. :).

  • <Export-Package> will copy the packages to the bundle and export them in the MANIFEST while <Private-Package> will copy the packages to the bundle even-though they will not be exported.
  •  If you want a class to be included in the bundle make sure the package that it lives in is present in either of these instructions or otherwise it will not get included in the bundle.
  •  If <Export-Package> and <Private-Package> overlaps <Export-Package> takes precedence.
  • Using negation “!” in <Export-Package> declaration will result in package being not included bundle and not exported as well.
  • If a negation following an non-negated package declaration overlaps with the non-negated package declaration, the negated package pattern will not take effect. Always put negations first in  <Export-Package> instruction to avoid these kind of issues.
  •  Plugin generates the Import-Package bundle manifest header based on the Java imports present in the classes of the bundle so generally it’s not needed to specify it explicitly.
  • If a referenced packages do not need to be available for at runtime for bundle to perform its intended task (e.g: only a test scoped class using the package which is only needed during test runs..) use negation inside not to import it.
  • If you need to import a package not referenced by any class in bundle use resolution:=optional directive after the package name as follows.

org.external.package;resolution:=optional

   The bundle would resolve even if the package is not present at runtime.

  • Use to import a dynamically loaded class (e.g: Using Class.forName()) given that it’s exported in originating bundle. Generally using “*” wild-card would do, since it will enable loading any dynamically loaded class in other bundles given that the package it lives in has been exported by those bundles.

So that’s about it for my notes. If you want a good tutorial have a look at [2] as well. By the way in case you are wondering about the issue I had, the second point sums it up pretty nice. :).

[1] http://felix.apache.org/site/apache-felix-maven-bundle-plugin-bnd.html

[2] http://wso2.org/library/tutorials/develop-osgi-bundles-using-maven-bundle-plugin

Read Full Post »

wvdial – Chicken egg problem

I was helping one of my relatives to setup his Suntel CDMA dialup with Ubuntu last week. To my surprise I found that wvdial is not present in the standard Karmic Distribution eventhough it was present in my Intrepid box by default. Now I was facing a chicken egg issue having to access internet before connecting to via the dialup :D. I was bit concerned as well because installing a deb package off-line can be a painful experience due to missing dependency issues. Fortunately I found wvdial with all the dependancies in this Ubunt Forums post. http://ubuntuforums.org/showthread.php?t=1138101 .  After downloading that in my machine and installing in my relative’s machine rest of configurations went smoothly and I was able to help him connect to internet in a matter of minutes.

Thanks GeorgeVita of Ubuntu Forums for saving my day. :D. By the way, for the most part I was following this how to. http://kalpapathum.blogspot.com/2007/03/suntel-and-lanka-bell-cdma-phones.html . Thanks for the original author as well.

Read Full Post »

With Ubuntu I use the following to kill an errant process.

$ ps -efH | grep [process-name-regex]

Get the pid from the result and use

$ kill [pid]

When working in windows I wanted an equivalent functionality in command line rather than going to task manager window to get the job done. This is what I found.

Let’s say I want to kill the Intenet Explorer process currently having MSN home page.

tasklist /FI “WINDOWTITLE eq MSN*”

This would list the Internet Explorer process details similar to the below table.

Image Name                 PID          Session Name            Session#            Mem Usage

IEXPLORE.EXE          1168          Console                           0                        24,064K

Now use tskill comand to kill the process using PID.

tskill 1168

That’s it. You are done killing your process. :D.

Note /FI switch in tasklist command is a filter. It filters tasklist output using the window title of the related process. It can be also filtered using the PID or the image name of the process. But I used window title because I may not know the image name or the PID (finding PID is the motive in the first place) of the process. Windows title you can easily see on the desktop. Great thing is that you can use wild cards with the name. See I have used just MSN* in the search pattern. So it would give the process having an open window with title starting with MSN.

The easier way if you know the process name or part of it is directly to use tskill.

tskill <process-name-regex>

For instance for Internet Explorer.

tskill iexplo*

But I have found out some applications have process names which are hard to guess. For example windows chm viewer has a process name of hh.

Read Full Post »