Archive for March, 2010

Google Analytics Data Export API – Part 1

March 30th, 2010

When Google exposed its Data Export API, it endeared itself closer to developers and to customers of Google Analytics. Data Export API allows us to develop client applications to retrieve data from existing analytics profiles of authorized users.

How does it work?
The Data Export API provides read-only access to all available analytics data. Any data that is displayed in the analytics web interface can be accessed through this API. Nice isn’t it? You can get all your analytics data, for all your monitored websites and use it as you please.

» Read more: Google Analytics Data Export API – Part 1

MySQL Master/Slave configuration with EJB3 and JPA

March 26th, 2010

Well this turned out to be quite an exercise.

The goal: scalable reads with MySQL in master-slave configuration, writing to the master, and reading from N slaves, load balanced in round-robin fashion (or something).

The problem: using JPA (Java Persistence API) instead of direct JDBC calls. Turns out the MySQL ReplicationDriver (used to load balance reads to slaves and send writes to the master) relies on the readOnly state of the Connection in order to decide whether it’s a read or a write. With direct JDBC calls, I could get the Connection and toggle the readOnly state as needed.
» Read more: MySQL Master/Slave configuration with EJB3 and JPA

Loadbalancing and its benefits

March 17th, 2010

What is load balancing?
Load balancing is the practice of distributing a workload across multiple computers for improved performance. Load balancing distributes work among resources in such a way that no one resource should be overloaded and each resource can have improved performance, depending on the load balancing algorithm. Items such as network traffic, SSL requests, database queries, or even hardware resources such as memory can be load balanced. This practice is commonly used in server farms where multiple physical boxes are coordinated to fulfill the requests of many end users.

» Read more: Loadbalancing and its benefits

Musings of a SpringOne 2009 Attendee – Day 4

March 10th, 2010

This is the last and final part on my SpringOne 2009 experience. It’s late catching up to the 3 earlier posts but it’s here now. This post summarizes the sessions I attended from day 4 and wraps up with a summary of my take aways. If you want to catch up here are the three earlier posts:

  1. Musings of a SpringOne 2009 Attendee Day 1
  2. Musings of a SpringOne 2009 Attendee Day 2
  3. Musings of a SpringOne 2009 Attendee Day 3

Read on for day 4.

» Read more: Musings of a SpringOne 2009 Attendee – Day 4

Rendering Global t:messages After Redirect

March 8th, 2010

A common problem when working with JSF is getting global info messages  via <t:messages globalOnly="true"> or <f:messages globalOnly="true"> to display messages set in the previous request when you have a <redirect/> in your faces-config for a particular page You will not see your <t:messages> that are set on the previous page.

The Problem

For instance, say you have two pages – page1.xhtml and page2.xhtml. In your faces-config.xml, you will have 2 entries.

» Read more: Rendering Global t:messages After Redirect

Developing a multithreaded test harness

March 5th, 2010

You can’t ignore the fact that web servers are multithreaded. We can hide as much as we want, but sooner or later you’ll find yourself in the situation where your application works fine during development and testing; but once it hits production you start hearing about “funny” things happening. While there are plenty of tools that can be used to simulate multiple users, they aren’t always the easiest to run locally and they seem to take to much time to modify while hot on the trail of a multithreading bug. Here I’ll discuss the approach I took when I was recently faced with this situation.
» Read more: Developing a multithreaded test harness

Simple Subversion Branching and Merging

March 3rd, 2010

Branching and merging in Subversion is a great way to work on large new features without disrupting mainline development on trunk.  However, it has a reputation for being so difficult that many developers never take advantage of it.  In this post I’ll show just how easy it really is thanks to some newer features in Subversion and Subclipse (a Subversion plug-in for Eclipse).
» Read more: Simple Subversion Branching and Merging

Environment Specific Properties in Spring

March 1st, 2010

On many occasions I want to be able to inject environment specific property values into my Spring managed beans. These may be things like web service endpoints, database URLs, etc. Values I know for each environment at build time, but I want to use the same WAR/EAR file in each environment. I would like to keep the actual values separate from the Spring config files themselves. And I would really like to manage a set of default values for each property, so that I do not need to specify a value for every property in every environment (ex. my credit card processing URL for dev, test, uat is the same, but for production it is different.)

» Read more: Environment Specific Properties in Spring