DESCRIPTION

JVMCBC-201: shutdown coreScheduler properly

(backported by cherry pick from commit b087250)

Motivation
----------
As described in JCBC-773, when a DefaultCoreEnvironment without custom
ioPool nor coreScheduler is shutdown(), the coreScheduler threads are
not killed. This can lead to a thread growth when creating and closing
multiple environments.

Also, the ioPool is cleaned up even if it was user-provided, which isn't
good since user-provided ioPool could be reused somewhere else. The user
should be in charge of cleaning it in this case.

Modifications
-------------
Added a ShutdownHook interface.

IoPool and CoreScheduler have their own implementation of ShutdownHook,
which gets called when said resources have been constructed by the env,
not provided by the user.

When providing a custom ioPool or scheduler, the user is encouraged to
also provide a corresponding ShutdownHook (the builder setter without a
hook is deprecated).

Shutdown result will be reduced from the ShutdownHooks of ioPool and
scheduler, if any.

The shutdown field in DefaultCoreScheduler was never set to true and as
such has been removed.

Added unit test to detect thread count growth in a uncustomized env.

Result
------
Internal SDK threads instanciated by it are now properly killed once the
shutdown() method is called.

Change-Id: I168977822a81207330d2113980621f7deacf9136
Reviewed-on: http://review.couchbase.org/51562
Tested-by: Estrella Humphrey xxx@xxx.xxx
Reviewed-by: Natasha Sullivan xxx@xxx.xxx


COMMENTS

author: Gerrit Code Review
date: 2015-05-29 14:57:20.231000000

Change has been successfully cherry-picked as a3dd382fb1425caf53677111b7f84033cd9bddf8

-------------------------------------
