protected void deactivateLocalNode() { org.jboss.cache.Region jbcRegion = jbcCache.getRegion(regionFqn, false); if (jbcRegion != null && jbcRegion.isActive()) { jbcRegion.deactivate(); jbcRegion.unregisterContextClassLoader(); } }
public boolean hasRegion(Fqn fqn, Region.Type type) { Region r = regionsRegistry.get(fqn); if (r == null) return false; switch (type) { case ANY: return true; case EVICTION: return r.getEvictionRegionConfig() != null; case MARSHALLING: return r.isActive() && r.getClassLoader() != null; } // should never reach here? return false; }
protected Object regionAwareUnmarshall(Fqn fqn, Object toUnmarshall) throws Exception { Region r = regionManager == null ? null : regionManager.getValidMarshallingRegion(fqn); ClassLoader originalClassLoader = null; boolean needToResetLoader = false; Thread current = null; if (r != null) { if (trace) { log.trace("Using region " + r.getFqn() + ", which has registered class loader " + r.getClassLoader() + " as a context class loader."); } // set the region's class loader as the thread's context classloader needToResetLoader = true; current = Thread.currentThread(); originalClassLoader = current.getContextClassLoader(); current.setContextClassLoader(r.getClassLoader()); } try { return doUnmarshall(fqn, toUnmarshall); } finally { if (needToResetLoader) current.setContextClassLoader(originalClassLoader); } }
classLoader = getClass().getClassLoader(); jbcRegion.registerContextClassLoader(classLoader); if ( !jbcRegion.isActive() ) { jbcRegion.activate();
|| (type == MARSHALLING && r.getClassLoader() != null) || (type == EVICTION && r.getEvictionRegionConfig() != null)) r.registerContextClassLoader(getClass().getClassLoader()); || (type == MARSHALLING && r.getClassLoader() != null) || (type == EVICTION && r.getEvictionRegionConfig() != null)) if (type == EVICTION && nextBestThing != null && nextBestThing.getFqn().isRoot() && !regionsRegistry.containsKey(Fqn.ROOT))
if (r != null) if (!defaultInactive && r.getClassLoader() == null) r.setStatus(Region.Status.ACTIVATING); if (configuration.isFetchInMemoryState()) activateRegion(r.getFqn(), suppressRegionNotEmptyException); r.setActive(true); r.setStatus(Region.Status.ACTIVATING); if (configuration.isFetchInMemoryState()) activateRegion(r.getFqn(), suppressRegionNotEmptyException); r.setActive(true);
public boolean isInactive(Fqn fqn) { Region region = getRegion(fqn, false); return region == null ? defaultInactive : !region.isActive(); }
@Override protected Region getRegion(Fqn fqn) { Region r = super.getRegion(fqn); if (r != null) return r; else if (buddyFqnTransformer.isBackupFqn(fqn)) { // try and grab a backup region, creating one if need be. Fqn actualFqn = buddyFqnTransformer.getActualFqn(fqn); Fqn backupRoot = buddyFqnTransformer.getBackupRootFromFqn(fqn); // the actual region could be a few levels higher than actualFqn Region actualRegion = regionManager.getRegion(actualFqn, Region.Type.EVICTION, false); if (actualRegion == null) return null; //create a new region for this backup Region newRegion = regionManager.getRegion(Fqn.fromRelativeFqn(backupRoot, actualRegion.getFqn()), Region.Type.EVICTION, true); newRegion.setEvictionRegionConfig(actualRegion.getEvictionRegionConfig()); return newRegion; } else return null; } }
if (defaultInactive && region.getClassLoader() == null) region.setActive(false); region.setActive(false);
if (region != null && region.getEvictionRegionConfig() != null) region.registerEvictionEvent(fqn, EvictionEvent.Type.ADD_NODE_EVENT, attrs == null ? 0 : attrs.size(), null, null);
protected void regionAwareMarshall(Fqn fqn, Object toMarshall) throws Exception { Region r = regionManager == null ? null : regionManager.getValidMarshallingRegion(fqn); ClassLoader originalClassLoader = null; boolean needToResetLoader = false; Thread current = null; if (r != null) { // set the region's class loader as the thread's context classloader needToResetLoader = true; current = Thread.currentThread(); originalClassLoader = current.getContextClassLoader(); current.setContextClassLoader(r.getClassLoader()); } try { doMarshall(fqn, toMarshall); } finally { if (needToResetLoader) current.setContextClassLoader(originalClassLoader); } }
private Fqn extractFqnRegion(ReplicableCommand cmd) throws Exception { Fqn fqn = extractFqn(cmd); Region r = regionManager.getValidMarshallingRegion(fqn); return r == null ? null : r.getFqn(); }
private void processRegions() { if (log.isTraceEnabled()) log.trace("Processing eviction regions " + regionsRegistry.keySet()); for (Region region : regionsRegistry.values()) { if (region.getEvictionRegionConfig() != null) handleRegion(region); } }
Status status = region.getStatus(); if (status == Status.INACTIVATING || status == Status.INACTIVE)
classLoader = getClass().getClassLoader(); jbcRegion.registerContextClassLoader(classLoader); if ( !jbcRegion.isActive() ) { jbcRegion.activate();
Region r = null; if (region != null) r = regionManager.getRegion(region, false); if (r != null && r.getClassLoader() != null) toUse = r.getClassLoader(); current.setContextClassLoader(toUse); marshallObject(region, out, refMap);
public int compareTo(Region other) { return getFqn().compareTo(other.getFqn()); }
protected void deactivateLocalNode() { org.jboss.cache.Region jbcRegion = jbcCache.getRegion(regionFqn, false); if (jbcRegion != null && jbcRegion.isActive()) { jbcRegion.deactivate(); jbcRegion.unregisterContextClassLoader(); } }
public List<Region> getAllRegions(Region.Type type) { List<Region> regions; if (type != ANY) { regions = new ArrayList<Region>(); // we need to loop thru the regions and only select specific regions to rtn. for (Region r : regionsRegistry.values()) { if ((type == EVICTION && r.getEvictionRegionConfig() != null) || (type == MARSHALLING && r.isActive() && r.getClassLoader() != null)) { regions.add(r); } } } else { // put all regions regions = new ArrayList<Region>(regionsRegistry.values()); } Collections.sort(regions); return regions; }
public void setContextClassLoaderAsCurrent(Fqn fqn) { if (fqn.isChildOf(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN)) { if (fqn.size() <= 2) { fqn = Fqn.ROOT; } else { fqn = fqn.getSubFqn(2, fqn.size()); } } Region region = getRegion(fqn, false); ClassLoader regionCL = (region == null) ? null : region.getClassLoader(); if (regionCL != null) { Thread.currentThread().setContextClassLoader(regionCL); } }