Wednesday, February 25, 2009

Toplink MultiProjects with Cache Coordination

I would love to call it a Hub and Spoke architecture. Its pretty common to have enterprise applications grow in a way that numerous applications spring up that work and share only a subset of domain objects of a "Big Daddy" application. For example a central application that does Order management and creates Shipments. Other application only works on Shipment details and other may be doing an analytic on the Products sold. With Toplink it is fairly simple to do so and the trick is to partition the application in multiple independent units and map it with their respective data model accordingly. Toplink session allows to have multiple projects. Click on the Session and General tab, select Multiple Projects checkbox and provide the name of the primary toplink project (In our example that would be Order).

Select Multiple Projects tab and click the Add button. Select other components of the application, in our example it would be Shipment. Repeat the process for each component of the application.

Then create another Toplink session (Either in the same sessions.xml or multiple sessions_xxx.xml files) for each individual components. The following image shows the Shipment project:

And repeat for each individual applications. Deploy the Big application and then other "spoke" applications. One more important thing.. Make sure they all share the same Cache Coordination configuration. If using RMI same multicast address and port and their each individual Registry Naming Services.

And thats pretty much it you need. Toplink, Cache Coordination and judiciously partitioning the application to individual components can achieve a true hub-n-spoke enterprise application. For a sample project download it from: Sample Toplink Project

Sunday, February 22, 2009

A tribute to AR Rahman

Why I would not vote for BJP

I have voted for BJP since after Rajiv Gandhi's first term. One reason being I am from Lucknow and Atal B. Vajpayee was good enough reason to believe in a party "with a difference". Along the line I continued to believe in what they had to say. Common civil code, strict action against terrorism, strong Swadeshi movement and yes Ram temple. While they were in power I also liked some of their policies like Interconnecting Indian rivers to address flood and famine problems and bringing India to the select club of Nuclear nations. Being from UP I also liked Kalyan Singh's term as a Chief Minister and his relative cleaner and non-corrupt image. In last decade things have changed. Atal has retired and is not active in politics or even sidelined. Kalyan has left BJP and has dragged himself into the same pity politics that I found him against of. And after a decade India is young again. If I vote this year following are five reasons why I would not vote for BJP:

  1. Advani does not represent young India. He seems running for PM@81 to fulfill his dream rather to give the nation a new leadership.
  2. BJP is responsible to release dreaded terrorists like Masood Azhar. Time tests the tough and BJP failed miserably.
  3. State's response to unapologetic Godhara massacre by Muslim fanatics was equally terrible, sad and unjustifiable. The incident was the beginning of BJP's downfall.
  4. There are no committed national level second generation leaders in BJP.
  5. They rake Ram Temple issue to get to the power. They are neither committed nor capable to achieve it.

Saturday, February 21, 2009

Using Cache Coordination with Toplink

Most of my consulting engagements revolve around two products - Oracle Coherence and Oracle Toplink. While both have Caching component and caching in a distributed environment they are complementary and are built for two entire different purposes. Coherence is built for massive scalability for humongous amount of in memory data while Toplink is for persistence and can pretty much map any domain model with any data model. So the moment you find yourself in a situation where multiple applications need to share the same set of objects or need to be notified of changes in one application to another, a quick call with Oracle Professional services might help. One feature of Toplink that gets a little not so talked about is its ability to coordinate caches across multiple Toplink sessions. If your application is Toplink API driven and requires up to 500/600MB of in memory data some huge performance gains can be achieved using its Cache Coordination. During a recent project I got myself into some challenges while migrating a Toplink9g project and I hope this blog helps for future references.

  1. Cache Synchronization is now called Cache Coordination.
  2. Cache Coordination uses RCM and the old synchronization mechanism has been deprecated.
  3. Do not rely completely on Toplink10g workbench for creating sessions.xml
  4. Migrate to Toplink11g and it's workbench - It will make life much easier.
  5. If migrating 9g to 10g, 10g will work with the 9g's sessions.xml. 10g cache coordination configuration could be a challenge.
  6. Cache coordination is meant for mostly read-only and a low writes.
  7. If requirement is heavy object mutation across multiple instances or heterogeneous applications, consider Coherence.
Following explains how to test Cache coordination on a single machine (Done with 11g):
  • A sample setting for Cache Coordination using RMI
    • Type: RMI
    • Channel: ToplinkCommandChannel
    • Multicast Group Address:
    • Multicast Port: 25000
    • Packet Time to Live: 2
    • Announcement Delay: 1000
    • Select Remove Connection on Error
    • Select Synchronous
    • URL for Registry Naming Service: rmi://$HOST:1099
  • Starting rmiregistry
    • rmiregistry.exe -J-Djava.class.path="classes;toplink.jar" -J-Djava.rmi.server.logCalls=true -J-Dsun.rmi.server.logLevel=VERBOSE -J-Dsun.rmi.client.logCalls
  • Following is a simple sample sessions.xml
      <?xml version="1.0" encoding="UTF-8"?>
      <toplink-sessions version="11g ("
      <session xsi:type="server-session">
      <transport xsi:type="rmi-transport">
      <logging xsi:type="toplink-log">
      <primary-project xsi:type="xml">ToplinkRI.xml</primary-project>
      <login xsi:type="database-login">
      <default-sequence xsi:type="native-sequence">
And thats all you need to run multiple instances of an application on a single box with straight forward RMI driven cache coordination. Change made in one is visible in another JVM and access to that Object will be from a cache instead from an expensive database.

Monday, February 16, 2009

Why would Congress win next elections

  1. When no one is better, advantage goes to the ruling party.
  2. BJP didn't walk its talk.
  3. Majority of Indians do not like Advani.
  4. Manmohan Singh Government has not done awfully bad.
  5. Modi says Reject dynastic parties but Its still better than leaderless Party.
  6. Congress appears more sincere.
  7. Regional parties help Congress.
  8. Who next is known in Congress. Others are either one man show or still battling.
  9. Its easier to form a UPA coalition than a NDA coalition.
  10. Less infighting with in Congress.

Wednesday, February 11, 2009

Issues and non issues of Distributed computing

By Distributed computing I refer to platforms, infrastructure or technology that involves multiple JVMs to perform a cohesive operation. So what are the core issues and non-issues before we select the right platform?

  • NI: Moving object from one system (JVM) to another
    • How compact is the object over the wire?
  • NI: Synchronizing changes from one JVM to another
    • How fast is the synchronization?
    • How many JVMs to be synchronized?
    • Is the synchronization synchronous or Async
  • NI: Continuous Availability of the Application
    • What state does the failure of one server leaves the data in?
    • What happens to in-flight Transaction upon failure?
    • What state is the persistence storage in?
    • Upon recovery what happens to the new node?
    • How is the past affecting the present for the recovered node?
    • How is the user request handled after its submission and after the node's failure but before the processing completes?
  • NI: Managing common state across multiple services
    • Is that a single point of failure?
    • What is the transaction isolation?
  • NI: A feature list
    • How extensible is it?
    • Are the integration points well defined?
There are plenty of products that address the Non-Issues but fail miserably in their implementation of their resolution. So before selecting the distributed computing platform not only look the supported features but also how they are implemented. Read more on Coherence

Tuesday, February 10, 2009

Sridhar Acharya Process

How to solve a polynomial equation like ax2+2abx+b2 = 0? Shridhar Acharya born in 800BC gave the following solution:
x = (-b ± (b2 - 4ac)1/2)/2, simple and straight forward.

Wednesday, February 04, 2009

Will this product work with Coherence?

If you happen to find yourself asking this question then ask yourself the following:

  • Is your product written in Java, C++ or .NET?
  • Can you bring application state out and put it in Coherence?
  • Do you have an ability to make changes to the product code you are concerned about?
  • Does your application use open spec whose implementation can be replaced and plugged in?
If the answer is yes then absolutely Coherence can be used.

Sunday, February 01, 2009

JPA Annotations in Domain Model

Why I don't like them?

  1. It corrupts the domain object. Domain object doesn't have to know that it is meant for persistence to a relational database.
  2. Vis-a-vis Coherence, CacheStore that is meant to interact with an external data source is not necessarily meant for relational database. CacheStore could hook a database, a Directory server or even another Coherence cluster. @OneToOne has no sense if the external datasource is a Coherence cluster.
  3. Having a separate OR Mapping is much cleaner