entitlement: optimize EventsStreamBuilder

Speed it up by limiting the amount of database calls.

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>
entitlement: fix infinite loop in EventsStreamBuilder

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>
entitlement: add magic fix for TestEntitlementUtils.testCancelAddonsWhenBaseEntitlementIsCancelled

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>
refactoring in invoice to extact the logic for interval calculation in one class and simplify the code
entitlement: iteration on EventsStreamBuilder speedup optimizations

Explain the magic and add tests for eventsStreamBuilder.buildForAccount. Even though
all tests were passing, I still went ahead and updated buildForAccount to do the same
magic as buildForEntitlement. I didn't manage to write a failing test scenario for it
but it seems required.

This also fixes an NPE with standalone subscriptions.

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>
entitlement: optimize DefaultSubscriptionApi

Go through the getSubscriptionBundlesForAccountId API (which is
behind /1.0/kb/accounts/ACCOUNT_ID/bundles) and optimize the various
layers to limit the amount of DAO calls.

1.0 call timings for an account with 35 bundles and 67 subscriptions:

* Before changes: 8m40s
* After changes: 6.50s at startup, 4.20s after caches are warm

Since this call should be fast, change most APIs in DefaultSubscriptionApi
to always build all subscriptions for a given account first, and then do
further filtering in memory (per bundle, etc.). This simplifies the amount
of codepaths to optimize.

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>
Merge branch 'master' of github.com:killbill/killbill
server: fix tests failures after recent changes

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>
[maven-release-plugin] prepare release killbill-0.8.3
[maven-release-plugin] prepare for next development iteration
Revert "refactoring in invoice to extact the logic for interval calculation in one class and simplify the code"

This reverts commit bd4f6e704cbe2593d23fab5e65df0d85bd2bcbb7.
Perf optimization when retrieving events for accounts
Merge branch 'master' of github.com:killbill/killbill
Merge remote-tracking branch 'origin/master' into junction-bug-fixes

Conflicts:
	entitlement/src/main/java/com/ning/billing/entitlement/dao/ProxyBlockingStateDao.java

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>