Tuesday, April 21, 2009

Blog host

So, I'm trying to figure out how to host my own blog. Steve Pavlina suggests that I host it with its own domain name, using this domain provider Pair, and ServInt VPS using wordpress. It sounds like a brilliant idea, but I'm not too familiar with PHP.

Since I'm already very familiar with Java and JSP etc, I was wondering if there exists some sort of WordPress for java. Apparently there is, or I can get a free account at WordPress itself, but then they get all of the ad revenue.

My sister-in-law has her own blog called theliteratemother.org that is hosted on wordpress as well. It seems to be pretty cool, and maybe more like what I'm looking for.

Otherwise, I'm looking at spending at least $50/month to host it where Steve Pavlina suggests. I.e. ServInt.

Seems like I should at least as Bridget where she hosts hers, I suppose.

Hibernate Caching

I've been working on getting Hibernate caching to work at work to implement a new feature from Product Management. The original requirements suggested rolling our own caching mechanism, but since our application already has hibernate, it doesn't seem to make sense to roll our own.

Early investigation lead me here:

A wonderful article about hibernate caching. Since our application uses xdoclet for defining hibernate mapping, it wasn't quite complete.

But I really like the analysis because it displays rather clearly how much faster it runs with the caching thrown in.

I'm tempted as well to perform a similar analysis. The article talks about caching the object, and the relationships to the object, which are essential for my problem as well because I have a hierarchy in my objects of Parent -> child. My object is called the Domain Object.

the hbm_xml would be this:



The xdoclet then would be (found here):
/**
* @author petersmiley
*
* @hibernate.class table="Domains" dynamic-insert="true" dynamic-update="true" optimistic-lock="version"
* @hibernate.cache usage="read-only"
* @struts.form "DomainForm"
*
* @auditable.property entity-name="audit.entity.domain"
*/
public class Domain extends BaseObject implements Auditable, Comparable {
.... and the link back to the parent:
/**
* @struts.form-field form-name="parentDomain"
* @hibernate.cache usage="read-write"
* @hibernate.many-to-one
* column="PARENT_ID"
* class="com.norkom.base.resources.model.Domain"
* not-null="false"
* unique="false"
* --cascade="none"
* --outer-join="false""
*
* @auditable.property identified-by="parent.domain"
*/
public Domain getParentDomain() {
return parentDomain;
}
public void setParentDomain(Domain parentDomain) {
this.parentDomain = parentDomain;
}

Note: if you use "read-only" then don't expect to be able to put any objects into the database. When it says read-only, it means it! (I tried it. I had to change to read-write)

Here is my unit test:
public void testCachedCrud() {
List list = domainDao.getAllDomains();
assertEquals(0, list.size());
TestTimer createDomainsTimer = new TestTimer("test Create Domains");
int size = 10;
for (int i=0;i
Domain parentDomain = createBasicDomain(PARENT_DOMAIN_NAME + i);
for(int j=0;j
Domain childDomain = createBasicDomain(CHILD_DOMAIN_DOMAIN + i + ":" + j);
childDomain.setParentDomain(parentDomain);
domainDao.saveDomain(childDomain);
}
domainDao.saveDomain(parentDomain);
}
createDomainsTimer.done();

for (int i=0;i
TestTimer timer = new TestTimer("test Get Domains" + i);
Domain parentDomain = domainDao.getDomainByName(PARENT_DOMAIN_NAME + i);
timer.done();
}
}

Results, with cacheing:
INFO [DomainDaoImplTest] -> Loading config for: /com/norkom/base/business/dao/impl/test-context.xml
EMMA: collecting runtime coverage data ...
WARN [Configurator] -> No configuration found. Configuring ehcache from ehcache-failsafe.xml found in the classpath: jar:file:/C:/work/trunk/SUBVERSION/Libs/hibernate/2.1.8/ehcache-0.9.jar!/ehcache-failsafe.xml
WARN [EhCacheProvider] -> Could not find configuration [com.norkom.base.resources.model.Domain]; using defaults.
DEBUG [TestTimer] -> test Create Domains: 140 ms
DEBUG [TestTimer] -> test Get Domains0: 0 ms
DEBUG [TestTimer] -> test Get Domains1: 0 ms
DEBUG [TestTimer] -> test Get Domains2: 0 ms
DEBUG [TestTimer] -> test Get Domains3: 0 ms
DEBUG [TestTimer] -> test Get Domains4: 0 ms
DEBUG [TestTimer] -> test Get Domains5: 0 ms
DEBUG [TestTimer] -> test Get Domains6: 0 ms
DEBUG [TestTimer] -> test Get Domains7: 0 ms
DEBUG [TestTimer] -> test Get Domains8: 0 ms

Now, lets try without caching...
DEBUG [TestTimer] -> test Get Domains9: 0 ms