use of org.apache.geode.internal.cache.HasCachePerfStats in project geode by apache.
the class DummyQRegion method getValues.
@Override
public SelectResults getValues() {
if (values == null) {
values = new ResultsBag(((HasCachePerfStats) getRegion().getCache()).getCachePerfStats());
values.setElementType(valueType);
}
values.clear();
Object val = this.entry.getValueOffHeapOrDiskWithoutFaultIn((LocalRegion) getRegion());
if (val instanceof StoredObject) {
@Retained @Released StoredObject ohval = (StoredObject) val;
try {
val = ohval.getDeserializedValue(getRegion(), this.entry);
} finally {
ohval.release();
}
} else if (val instanceof CachedDeserializable) {
val = ((CachedDeserializable) val).getDeserializedValue(getRegion(), this.entry);
}
values.add(val);
return values;
}
use of org.apache.geode.internal.cache.HasCachePerfStats in project geode by apache.
the class AbstractGatewaySender method initializeEventIdIndexMetaDataRegion.
@SuppressWarnings({ "rawtypes", "unchecked", "deprecation" })
private static synchronized Region<String, Integer> initializeEventIdIndexMetaDataRegion(AbstractGatewaySender sender) {
final InternalCache cache = sender.getCache();
Region<String, Integer> region = cache.getRegion(META_DATA_REGION_NAME);
if (region == null) {
// Create region attributes (must be done this way to use InternalRegionArguments)
AttributesFactory factory = new AttributesFactory();
factory.setScope(Scope.DISTRIBUTED_ACK);
factory.setDataPolicy(DataPolicy.REPLICATE);
RegionAttributes ra = factory.create();
// Create a stats holder for the meta data stats
final HasCachePerfStats statsHolder = new HasCachePerfStats() {
public CachePerfStats getCachePerfStats() {
return new CachePerfStats(cache.getDistributedSystem(), META_DATA_REGION_NAME);
}
};
// Create internal region arguments
InternalRegionArguments ira = new InternalRegionArguments().setIsUsedForMetaRegion(true).setCachePerfStatsHolder(statsHolder);
// Create the region
try {
region = cache.createVMRegion(META_DATA_REGION_NAME, ra, ira);
} catch (RegionExistsException e) {
region = cache.getRegion(META_DATA_REGION_NAME);
} catch (Exception e) {
throw new IllegalStateException(LocalizedStrings.AbstractGatewaySender_META_REGION_CREATION_EXCEPTION_0.toLocalizedString(sender), e);
}
}
return region;
}
use of org.apache.geode.internal.cache.HasCachePerfStats in project geode by apache.
the class LocalManager method startLocalManagement.
/**
* Managed Node side resources are created
*
* Management Region : its a Replicated NO_ACK region Notification Region : its a Replicated Proxy
* NO_ACK region
*/
private void startLocalManagement(Map<ObjectName, FederationComponent> federatedComponentMap) {
synchronized (this) {
if (repo.getLocalMonitoringRegion() != null) {
return;
} else {
ThreadFactory tf = new ThreadFactory() {
public Thread newThread(final Runnable command) {
final Runnable r = new Runnable() {
public void run() {
command.run();
}
};
final ThreadGroup group = LoggingThreadGroup.createThreadGroup(ManagementStrings.MANAGEMENT_TASK_THREAD_GROUP.toLocalizedString(), logger);
Thread thread = new Thread(group, r, ManagementStrings.MANAGEMENT_TASK.toLocalizedString());
thread.setDaemon(true);
return thread;
}
};
singleThreadFederationScheduler = Executors.newSingleThreadScheduledExecutor(tf);
if (logger.isDebugEnabled()) {
logger.debug("Creating Management Region :");
}
/*
* Sharing the same Internal Argument for both notification region and monitoring region
*/
InternalRegionArguments internalArgs = new InternalRegionArguments();
internalArgs.setIsUsedForMetaRegion(true);
// Create anonymous stats holder for Management Regions
final HasCachePerfStats monitoringRegionStats = new HasCachePerfStats() {
public CachePerfStats getCachePerfStats() {
return new CachePerfStats(cache.getDistributedSystem(), "managementRegionStats");
}
};
internalArgs.setCachePerfStatsHolder(monitoringRegionStats);
AttributesFactory<String, Object> monitorRegionAttributeFactory = new AttributesFactory<String, Object>();
monitorRegionAttributeFactory.setScope(Scope.DISTRIBUTED_NO_ACK);
monitorRegionAttributeFactory.setDataPolicy(DataPolicy.REPLICATE);
monitorRegionAttributeFactory.setConcurrencyChecksEnabled(false);
MonitoringRegionCacheListener localListener = new MonitoringRegionCacheListener(service);
monitorRegionAttributeFactory.addCacheListener(localListener);
RegionAttributes<String, Object> monitoringRegionAttrs = monitorRegionAttributeFactory.create();
AttributesFactory<NotificationKey, Notification> notificationRegionAttributeFactory = new AttributesFactory<NotificationKey, Notification>();
notificationRegionAttributeFactory.setScope(Scope.DISTRIBUTED_NO_ACK);
notificationRegionAttributeFactory.setDataPolicy(DataPolicy.EMPTY);
notificationRegionAttributeFactory.setConcurrencyChecksEnabled(false);
RegionAttributes<NotificationKey, Notification> notifRegionAttrs = notificationRegionAttributeFactory.create();
String appender = MBeanJMXAdapter.getUniqueIDForMember(cache.getDistributedSystem().getDistributedMember());
boolean monitoringRegionCreated = false;
boolean notifRegionCreated = false;
try {
repo.setLocalMonitoringRegion(cache.createVMRegion(ManagementConstants.MONITORING_REGION + "_" + appender, monitoringRegionAttrs, internalArgs));
monitoringRegionCreated = true;
} catch (TimeoutException e) {
throw new ManagementException(e);
} catch (RegionExistsException e) {
throw new ManagementException(e);
} catch (IOException e) {
throw new ManagementException(e);
} catch (ClassNotFoundException e) {
throw new ManagementException(e);
}
try {
repo.setLocalNotificationRegion(cache.createVMRegion(ManagementConstants.NOTIFICATION_REGION + "_" + appender, notifRegionAttrs, internalArgs));
notifRegionCreated = true;
} catch (TimeoutException e) {
throw new ManagementException(e);
} catch (RegionExistsException e) {
throw new ManagementException(e);
} catch (IOException e) {
throw new ManagementException(e);
} catch (ClassNotFoundException e) {
throw new ManagementException(e);
} finally {
if (!notifRegionCreated && monitoringRegionCreated) {
repo.getLocalMonitoringRegion().localDestroyRegion();
}
}
managementTask = new ManagementTask(federatedComponentMap);
// call run to get us initialized immediately with a sync call
managementTask.run();
// All local resources are created for the ManagementTask
// Now Management tasks can proceed.
int updateRate = cache.getInternalDistributedSystem().getConfig().getJmxManagerUpdateRate();
singleThreadFederationScheduler.scheduleAtFixedRate(managementTask, updateRate, updateRate, TimeUnit.MILLISECONDS);
if (logger.isDebugEnabled()) {
logger.debug("Management Region created with Name : {}", repo.getLocalMonitoringRegion().getName());
logger.debug("Notification Region created with Name : {}", repo.getLocalNotificationRegion().getName());
}
}
}
}
Aggregations