Newsletter sign-up
View all newsletters

Enterprise Java Newsletter
Stay up to date on the latest tutorials and Java community news posted on JavaWorld

Sponsored Links

Optimize with a SATA RAID Storage Solution
Range of capacities as low as $1250 per TB. Ideal if you currently rely on servers/disks/JBODs

Harness Offsprings to divide, parallelize and conquer

Here's how to quickly turn your apps into a scalable, high-performance data-processing solution

  • Print
  • Feedback

Reinventing the wheel over and over again can be fun, but you are probably going to end up with squeaky ones that fall off the axle. When developers address the scalability and performance of their applications, they often reinvent a solution where each request is split into batches which are processed concurrently and merged for delivery to the client.

Then comes the glorious part (usually accomplished by marketing): naming the new contraption. As a result, plenty of terminology has emerged for our enjoyment: brokers, clusters, agents, runners, distributors, processors, workers, and so on and so forth.

After the initial celebration, harsh reality kicks in. Bug fixes related to the deadlocks, blocking synchronizations, transaction issues, and general thread-safety problems begin to consume months and months of effort.

The open-source Offsprings project can help developers address this common and potentially difficult aspect of server-side software development: As explained in this article by the authors of the Offprings project, you can use this universal Spring-based solution to add concurrent processing to an application with just an hour of XML context configuration.

Parallelizing as a cross-cutting concern
The management of concurrent batch processing falls under the category of aspect-oriented programming (AOP), an approach that allows developers to concentrate on the primary object model for their application. Managing concurrent batch processing, logging, billing, and transaction integrity are all functions considered to be cross-cutting concerns called aspects. They can be addressed outside of the primary object model without modifying or even recompiling the original code (see "Spring bare essentials"). Aspects intercept method invocations on the underlying object model at join points and provide some additional behavior called advice.

The management of concurrent batch processing is considered an aspect because it occurs outside of an application's primary object model and may intersect with that model at various arbitrary points. Offspring's AOP solution is to wrap a universal advisor bean (the splitter) around the interface for each method (join point) that must be parallelized. This bean's advice divides the work into batches, which are processed in parallel and reassembled. Neither the sender nor receiver of the original method invocation are aware of the splitter's work.

The implementation of this concept should meet two basic requirements. First, the output from the splitter bean must be identical to the result of the invocation without applying any AOP. Although the solutions for Map, List and Array results are trivial, streams may require additional processing. For example, the XML input stream may require additional configuration and accepts an optional XSLT template to merge meta information (addressed below).

The second requirement: The splitter bean should work on a variety of interface signatures without needing meticulous configuration for each particular API. Therefore, the splitter analyzes the API signature through Java Introspection and loads the appropriate implementation dynamically. The basic cases of Map, List, Arraym, and XML InputStream are supported out of the box. Support for additional API signatures can be added without modifying the base Offspring software.

  • Print
  • Feedback

Resources