apache/incubator-usergrid — pull request #120 by snoopdave (2014-12-10 15:52:11+00:00)
Title: USERGRID-254: Use event system to clean-up stale indexes 

DO NOT MERGE. FOR REVIEW ONLY.

This branch implements Events https://issues.apache.org/jira/browse/USERGRID-254

When the Core module EntityManager deletes or updates Entities in the Collections module, the Query Index records for the old versions of that Entity need to be deleted. To enable this, we added an eventing system to the Collections module so that callers can hook into entity create, update and delete events.

And we added event handlers to clean up the Query Index records for those events.

See the new package in Collections module:
org.apache.usergrid.persistence.collection.event

And in Core:
org.apache.usergrid.corepersistence.events

One issue with this PR is the AbstractIteratingQueryIT, which now requires at least a 5ms write-delay or one of the tests will fail and then cause subsequent tests in other classes to fail too.