Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
public static final boolean DEFAULT_COPY_ON_READ = false;

/**
* getcachefor
* The default amount of time to wait for a {@code netSearch} to complete
*/
public static final int DEFAULT_SEARCH_TIMEOUT =
Expand Down Expand Up @@ -921,7 +922,8 @@ private GemFireCacheImpl(boolean isClient, PoolFactory pf, InternalDistributedSy
this.resourceAdvisor = ResourceAdvisor.createResourceAdvisor(this);

// Initialize the advisor here, but wait to exchange profiles until cache is fully built
this.jmxAdvisor = JmxManagerAdvisor.createJmxManagerAdvisor(new JmxManagerAdvisee(this));
this.jmxAdvisor = JmxManagerAdvisor
.createJmxManagerAdvisor(new JmxManagerAdvisee(getCacheForProcessingClientRequests()));

this.resourceManager = InternalResourceManager.createResourceManager(this);
this.serialNumber = DistributionAdvisor.createSerialNumber();
Expand Down Expand Up @@ -5329,7 +5331,7 @@ private void throwIfClient() {
new InternalCacheForClientAccess(this);

@Override
public InternalCache getCacheForProcessingClientRequests() {
public InternalCacheForClientAccess getCacheForProcessingClientRequests() {
return cacheForClients;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -367,5 +367,5 @@ void invokeRegionEntrySynchronizationListenersAfterSynchronization(
* application visible regions. Any regions created internally
* by Geode will not be accessible from the returned cache.
*/
InternalCache getCacheForProcessingClientRequests();
InternalCacheForClientAccess getCacheForProcessingClientRequests();
}
Original file line number Diff line number Diff line change
Expand Up @@ -138,14 +138,12 @@ public <K, V> Region<K, V> getRegion(String path) {
}

/**
* Server-side code using an InternalCacheForClientAccess may need to
* get an Internal Region not normally accesible and may use this method to
* do so. The REST API, for instance, needs to get at a Query store
* region that is not otherwise accessible through the getRegion methods.
* This method can be used to locate an internal region.
* It should not be invoked with a region name obtained
* from a client.
*/
public <K, V> Region<K, V> getInternalRegion(String path) {
Region<K, V> result = delegate.getRegion(path);
return result;
return delegate.getRegion(path);
}

@Override
Expand Down Expand Up @@ -228,6 +226,16 @@ public <K, V> Region<K, V> createVMRegion(String name, RegionAttributes<K, V> p_
return delegate.createVMRegion(name, p_attrs, internalRegionArgs);
}

/**
* This method allows server-side code to create an internal region. It should
* not be invoked with a region name obtained from a client.
*/
public <K, V> Region<K, V> createInternalRegion(String name, RegionAttributes<K, V> p_attrs,
InternalRegionArguments internalRegionArgs)
throws RegionExistsException, TimeoutException, IOException, ClassNotFoundException {
return delegate.createVMRegion(name, p_attrs, internalRegionArgs);
}

@Override
public Cache getReconnectedCache() {
Cache reconnectedCache = delegate.getReconnectedCache();
Expand Down Expand Up @@ -1201,7 +1209,7 @@ public void setPdxReadSerializedOverride(boolean pdxReadSerialized) {
}

@Override
public InternalCache getCacheForProcessingClientRequests() {
public InternalCacheForClientAccess getCacheForProcessingClientRequests() {
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@
import org.apache.geode.internal.cache.GemFireCacheImpl;
import org.apache.geode.internal.cache.InitialImageOperation;
import org.apache.geode.internal.cache.InternalCache;
import org.apache.geode.internal.cache.InternalCacheForClientAccess;
import org.apache.geode.internal.cache.InternalRegion;
import org.apache.geode.internal.cache.InternalRegionArguments;
import org.apache.geode.internal.cache.LocalRegion;
Expand Down Expand Up @@ -2407,7 +2408,7 @@ public void registerPdxMetaData(Object instance) {
}

@Override
public InternalCache getCacheForProcessingClientRequests() {
public InternalCacheForClientAccess getCacheForProcessingClientRequests() {
throw new UnsupportedOperationException("Should not be invoked");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ public abstract class ManagementService {
* @param cache Cache for which to get the management service.
*/
public static ManagementService getManagementService(Cache cache) {
return BaseManagementService.getManagementService((InternalCache) cache);
return BaseManagementService
.getManagementService(((InternalCache) cache).getCacheForProcessingClientRequests());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ public void authorize(ResourcePermission.Resource resource,
}

public Cache getCache() {
return cache;
if (cache == null) {
return null;
}
return cache.getCacheForProcessingClientRequests();
}

public <T extends ManagementService> T getManagementService() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.apache.geode.distributed.DistributedSystemDisconnectedException;
import org.apache.geode.distributed.internal.InternalDistributedSystem;
import org.apache.geode.internal.cache.InternalCache;
import org.apache.geode.internal.cache.InternalCacheForClientAccess;
import org.apache.geode.internal.logging.LogService;
import org.apache.geode.management.ManagementService;

Expand Down Expand Up @@ -69,7 +70,7 @@ protected BaseManagementService() {}
*
* @param cache defines the scope of resources to be managed
*/
public static ManagementService getManagementService(InternalCache cache) {
public static ManagementService getManagementService(InternalCacheForClientAccess cache) {
synchronized (instances) {
BaseManagementService service = instances.get(cache);
if (service == null) {
Expand All @@ -83,7 +84,7 @@ public static ManagementService getManagementService(InternalCache cache) {

public static ManagementService getExistingManagementService(InternalCache cache) {
synchronized (instances) {
BaseManagementService service = (BaseManagementService) instances.get(cache);
BaseManagementService service = instances.get(cache.getCacheForProcessingClientRequests());
return service;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,8 +357,9 @@ public DistributedMember call() {
String monitoringRegionName = ManagementConstants.MONITORING_REGION + "_" + appender;
String notificationRegionName = ManagementConstants.NOTIFICATION_REGION + "_" + appender;

if (cache.getRegion(monitoringRegionName) != null
&& cache.getRegion(notificationRegionName) != null) {

if (cache.getInternalRegion(monitoringRegionName) != null
&& cache.getInternalRegion(notificationRegionName) != null) {
return member;
}

Expand Down Expand Up @@ -415,7 +416,7 @@ public DistributedMember call() {
return null;
}
proxyMonitoringRegion =
cache.createVMRegion(monitoringRegionName, monitoringRegionAttrs,
cache.createInternalRegion(monitoringRegionName, monitoringRegionAttrs,
internalRegionArguments);
proxyMonitoringRegionCreated = true;

Expand All @@ -434,7 +435,7 @@ public DistributedMember call() {
return null;
}
proxyNotificationRegion =
cache.createVMRegion(notificationRegionName, notifRegionAttrs,
cache.createInternalRegion(notificationRegionName, notifRegionAttrs,
internalRegionArguments);
proxyNotificationRegionCreated = true;
} catch (TimeoutException | RegionExistsException | IOException
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import org.apache.geode.distributed.internal.DistributionManager;
import org.apache.geode.distributed.internal.InternalDistributedSystem;
import org.apache.geode.internal.admin.SSLConfig;
import org.apache.geode.internal.cache.InternalCache;
import org.apache.geode.internal.cache.InternalCacheForClientAccess;
import org.apache.geode.internal.net.SSLConfigurationFactory;
import org.apache.geode.internal.net.SocketCreator;
import org.apache.geode.internal.security.SecurableCommunicationChannel;
Expand All @@ -37,10 +37,10 @@
public class JmxManagerAdvisee implements DistributionAdvisee {

private final int serialNumber;
private final InternalCache cache;
private final InternalCacheForClientAccess cache;
private JmxManagerProfile myMostRecentProfile;

public JmxManagerAdvisee(InternalCache cache) {
public JmxManagerAdvisee(InternalCacheForClientAccess cache) {
this.serialNumber = DistributionAdvisor.createSerialNumber();
this.cache = cache;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@

import org.apache.geode.CancelException;
import org.apache.geode.SystemFailure;
import org.apache.geode.cache.Cache;
import org.apache.geode.cache.CacheFactory;
import org.apache.geode.cache.GemFireCache;
import org.apache.geode.cache.execute.FunctionContext;
import org.apache.geode.cache.execute.FunctionService;
Expand All @@ -32,6 +30,7 @@
import org.apache.geode.distributed.internal.tcpserver.TcpHandler;
import org.apache.geode.distributed.internal.tcpserver.TcpServer;
import org.apache.geode.internal.cache.InternalCache;
import org.apache.geode.internal.cache.InternalCacheForClientAccess;
import org.apache.geode.internal.cache.execute.InternalFunction;
import org.apache.geode.internal.logging.LogService;
import org.apache.geode.management.AlreadyRunningException;
Expand All @@ -41,10 +40,10 @@
public class JmxManagerLocator implements TcpHandler {
private static final Logger logger = LogService.getLogger();

private InternalCache cache;
private InternalCacheForClientAccess cache;

public JmxManagerLocator(InternalCache internalCache) {
this.cache = internalCache;
this.cache = internalCache.getCacheForProcessingClientRequests();
}

@Override
Expand All @@ -71,7 +70,7 @@ public void shutDown() {
@Override
public void restarting(DistributedSystem ds, GemFireCache cache,
InternalConfigurationPersistenceService sharedConfig) {
this.cache = (InternalCache) cache;
this.cache = ((InternalCache) cache).getCacheForProcessingClientRequests();
}

@Override
Expand Down Expand Up @@ -203,7 +202,8 @@ public static class StartJmxManagerFunction implements InternalFunction {
@Override
public void execute(FunctionContext context) {
try {
Cache cache = CacheFactory.getAnyInstance();
InternalCache cache =
((InternalCache) context.getCache()).getCacheForProcessingClientRequests();
if (cache != null) {
ManagementService ms = ManagementService.getExistingManagementService(cache);
if (ms != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public CachePerfStats getCachePerfStats() {

try {
repo.setLocalMonitoringRegion(
cache.createVMRegion(ManagementConstants.MONITORING_REGION + "_" + appender,
cache.createInternalRegion(ManagementConstants.MONITORING_REGION + "_" + appender,
monitoringRegionAttrs, internalArgs));
monitoringRegionCreated = true;

Expand All @@ -167,7 +167,7 @@ public CachePerfStats getCachePerfStats() {

try {
repo.setLocalNotificationRegion(
cache.createVMRegion(ManagementConstants.NOTIFICATION_REGION + "_" + appender,
cache.createInternalRegion(ManagementConstants.NOTIFICATION_REGION + "_" + appender,
notifRegionAttrs, internalArgs));
notifRegionCreated = true;
} catch (TimeoutException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
import org.apache.geode.internal.GemFireVersion;
import org.apache.geode.internal.admin.SSLConfig;
import org.apache.geode.internal.cache.InternalCache;
import org.apache.geode.internal.cache.InternalCacheForClientAccess;
import org.apache.geode.internal.logging.LogService;
import org.apache.geode.internal.net.SSLConfigurationFactory;
import org.apache.geode.internal.net.SocketCreator;
Expand Down Expand Up @@ -142,6 +143,14 @@ private boolean isServerNode(InternalCache cache) {
&& !cache.isClient());
}

public static InternalCacheForClientAccess getCache() {
InternalCache cache = (InternalCache) CacheFactory.getAnyInstance();
if (cache != null) {
return cache.getCacheForProcessingClientRequests();
}
return null;
}

public synchronized void startAgent(InternalCache cache) {
// Do not start Management REST service if developer REST service is already
// started.
Expand Down Expand Up @@ -191,7 +200,7 @@ public synchronized void stopAgent() {

private void startHttpService(boolean isServer) {
final SystemManagementService managementService = (SystemManagementService) ManagementService
.getManagementService(CacheFactory.getAnyInstance());
.getManagementService(getCache());

final ManagerMXBean managerBean = managementService.getManagerMXBean();

Expand Down Expand Up @@ -305,7 +314,7 @@ private void startHttpService(boolean isServer) {

// set cache property for developer REST service running
if (isRestWebAppAdded) {
InternalCache cache = (InternalCache) CacheFactory.getAnyInstance();
InternalCache cache = getCache();
cache.setRESTServiceRunning(true);

// create region to hold query information (queryId, queryString).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import org.apache.logging.log4j.Logger;

import org.apache.geode.cache.execute.FunctionContext;
import org.apache.geode.internal.cache.GemFireCacheImpl;
import org.apache.geode.internal.cache.InternalCache;
import org.apache.geode.internal.cache.execute.InternalFunction;
import org.apache.geode.internal.logging.LogService;
Expand Down Expand Up @@ -72,7 +71,7 @@ public void execute(FunctionContext fc) {

boolean executedSuccessfully = false;

InternalCache cache = GemFireCacheImpl.getInstance();
InternalCache cache = ((InternalCache) fc.getCache()).getCacheForProcessingClientRequests();

Object[] functionArguments = (Object[]) fc.getArguments();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import org.apache.geode.distributed.internal.InternalDistributedSystem;
import org.apache.geode.internal.cache.InternalCache;
import org.apache.geode.internal.cache.InternalCacheForClientAccess;

/**
* The Manager is a 7.0 JMX Agent which is hosted within a GemFire process. Only one instance is
Expand All @@ -26,7 +27,7 @@
*/
public abstract class Manager {

protected InternalCache cache;
protected InternalCacheForClientAccess cache;

/**
* depicts whether this node is a Managing node or not
Expand All @@ -51,7 +52,7 @@ public abstract class Manager {
public Manager(ManagementResourceRepo repo, InternalDistributedSystem system,
InternalCache cache) {
this.repo = repo;
this.cache = cache;
this.cache = cache.getCacheForProcessingClientRequests();
this.system = system;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.apache.geode.distributed.internal.ResourceEvent;
import org.apache.geode.distributed.internal.membership.InternalDistributedMember;
import org.apache.geode.internal.cache.InternalCache;
import org.apache.geode.internal.cache.InternalCacheForClientAccess;
import org.apache.geode.internal.logging.LogService;
import org.apache.geode.management.AlreadyRunningException;
import org.apache.geode.management.AsyncEventQueueMXBean;
Expand Down Expand Up @@ -94,7 +95,7 @@ public class SystemManagementService extends BaseManagementService {
*/
private MBeanJMXAdapter jmxAdapter;

private InternalCache cache;
private InternalCacheForClientAccess cache;

private FederatingManager federatingManager;

Expand All @@ -116,11 +117,12 @@ public class SystemManagementService extends BaseManagementService {

private UniversalListenerContainer universalListenerContainer = new UniversalListenerContainer();

public static BaseManagementService newSystemManagementService(InternalCache cache) {
public static BaseManagementService newSystemManagementService(
InternalCacheForClientAccess cache) {
return new SystemManagementService(cache).init();
}

protected SystemManagementService(InternalCache cache) {
protected SystemManagementService(InternalCacheForClientAccess cache) {
this.cache = cache;
this.system = (InternalDistributedSystem) cache.getDistributedSystem();
// This is a safe check to ensure Management service does not start for a
Expand Down
Loading