private void replace() { log.replaceComponents(); ComponentRegistry componentRegistry = cache.getAdvancedCache().getComponentRegistry(); replaceRpcManager(componentRegistry); replaceLockManager(componentRegistry); componentRegistry.rewire(); }
/** * Replaces a component in a running cache * * @param cache cache in which to replace component * @param componentType component type of which to replace * @param replacementComponent new instance * @param rewire if true, ComponentRegistry.rewire() is called after replacing. * @return the original component that was replaced */ public static <T> T replaceComponent( Cache<?, ?> cache, Class<T> componentType, T replacementComponent, boolean rewire) { ComponentRegistry cr = extractComponentRegistry(cache); T old = cr.getComponent(componentType); cr.registerComponent(replacementComponent, componentType); if (rewire) cr.rewire(); return old; }
@Override protected void start() { super.start(); log.startStreamSummaryInterceptor(); streamSummaryContainer = StreamSummaryContainer.getOrCreateStreamLibContainer(cache); streamSummaryContainer.setEnabled(true); distributionManager = cache.getAdvancedCache().getDistributionManager(); ComponentRegistry componentRegistry = cache.getAdvancedCache().getComponentRegistry(); LockManager oldLockManager = componentRegistry.getComponent(LockManager.class); LockManager newLockManager = new TopKeyLockManager(oldLockManager, streamSummaryContainer); log.replaceComponent("LockManager", oldLockManager, newLockManager); componentRegistry.registerComponent(newLockManager, LockManager.class); componentRegistry.rewire(); }