I think I even see comments in the code stating "TODO: use the cache in the
FunctionContext when it becomes available".

On Thu, Mar 2, 2017 at 12:30 PM, Kirk Lund <kl...@apache.org> wrote:

> I'm looking into a deadlock involving code under
> org.apache.geode.management. Related to this, I'm also looking at all of
> the Functions that are implemented as part of the management layer.
>
> First thing every management Function appears to invoke is either
> org.apache.geode.cache.CacheFactory.getAnyInstance() or
> org.apache.geode.cache.internal.cache.GemFireCacheImpl getInstance() to
> get
> a reference to the Cache.
>
> This method on CacheFactory seems to be frequently involved in deadlocks in
> general and I think we should find a way to deprecate it:
>
> /**
>  * Gets an arbitrary open instance of {@link Cache} produced by an earlier
> call to
>  * {@link #create()}.
>  *
>  * @throws CacheClosedException if a cache has not been created or the only
> created one is
>  *         {@link Cache#isClosed closed}
>  */
> public static synchronized Cache getAnyInstance() {
>   GemFireCacheImpl instance = GemFireCacheImpl.getInstance();
> <snip>
>
> In an effort to prevent deadlocks and move away from statics and
> singletons, I'd like to find a good alternative to this for Functions. I
> think adding this method to FunctionContext is the best solution:
>
> /**
>  * Returns a reference to the Cache for which this function is executing.
>  */
> public Cache getCache();
>
> Does this seem like a good solution? Is there any reason not to add this to
> the API?
>



-- 
Cheers

Jinmei

Reply via email to