public FragmentManager getOrCreateFragmentManager(FragmentHandle handle) throws FragmentSetupException{
if (cancelledFragments.asMap().containsKey(handle)) {
logger.debug("Fragment: {} was cancelled. Ignoring fragment handle", handle);
return null;
}
FragmentManager manager = managers.get(handle);
if (manager != null) return manager;
DistributedMap<FragmentHandle, PlanFragment> planCache = bee.getContext().getCache().getMap(Foreman.FRAGMENT_CACHE);
for(Map.Entry<FragmentHandle, PlanFragment> e : planCache.getLocalEntries()){
// logger.debug("Key: {}", e.getKey());
// logger.debug("Value: {}", e.getValue());
}
PlanFragment fragment = bee.getContext().getCache().getMap(Foreman.FRAGMENT_CACHE).get(handle);
if (fragment == null) {
throw new FragmentSetupException("Received batch where fragment was not in cache.");
}
FragmentManager newManager = new NonRootFragmentManager(fragment, bee);
// since their could be a race condition on the check, we'll use putIfAbsent so we don't have two competing
// handlers.
manager = managers.putIfAbsent(fragment.getHandle(), newManager);