First and foremost – a week ago, I never even knew this method existed in Java. Basically – it let you force the file writing to the disk. Turns out Arjuna (JBoss transactions) is using it in its ShadowStore
class, to ensure transaction data is stored to disk. It makes sense – as they want to recover transactions in case of a server crash.
Now, if you read my last post, on the inflation of EJBs, you know that 200 EJBs working together is a mess. And I’ve reached a point where 15% of CPU time of a single transaction is spent on this FileDescriptor.sync()
method. Since I couldn’t refactor the whole code – I had to think of another solution. Here goes.
I’ve written a new class, that extends ShadowStore
.
[java]
public class TonaStore extends ShadowingStore {
public TonaStore(ObjectStoreEnvironmentBean objectStoreEnvironmentBean) throws ObjectStoreException
{
super(objectStoreEnvironmentBean);
syncWrites = false;
}
}
[/java]
I deployed it to a JAR file, and placed it in the server/all/lib directory.
Now, I opened the /server/all/deploy/transactions-jboss-beans.xml
file, and changed ActionStore section to the following:
[xml]
@org.jboss.aop.microcontainer.aspects.jmx.JMX(name=”jboss.jta:name=ActionStoreObjectStoreEnvironmentBean”, exposedInterface=com.arjuna.ats.arjuna.common.ObjectStoreEnvironmentBeanMBean.class, registerDirectly=true)
com.arjuna.ats.arjuna.common.ObjectStoreEnvironmentBean
default
${jboss.server.data.dir}/tx-object-store
com.tona.ts.common.TonaStore
[/xml]
I got almost a 100% increase in hits/second. Sweet.