Search in sources :

Example 1 with HasCachePerfStats

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;
}
Also used : Released(org.apache.geode.internal.offheap.annotations.Released) StoredObject(org.apache.geode.internal.offheap.StoredObject) Retained(org.apache.geode.internal.offheap.annotations.Retained) CachedDeserializable(org.apache.geode.internal.cache.CachedDeserializable) HasCachePerfStats(org.apache.geode.internal.cache.HasCachePerfStats) StoredObject(org.apache.geode.internal.offheap.StoredObject) ResultsBag(org.apache.geode.cache.query.internal.ResultsBag)

Example 2 with HasCachePerfStats

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;
}
Also used : AttributesFactory(org.apache.geode.cache.AttributesFactory) RegionAttributes(org.apache.geode.cache.RegionAttributes) HasCachePerfStats(org.apache.geode.internal.cache.HasCachePerfStats) HasCachePerfStats(org.apache.geode.internal.cache.HasCachePerfStats) CachePerfStats(org.apache.geode.internal.cache.CachePerfStats) InternalCache(org.apache.geode.internal.cache.InternalCache) InternalRegionArguments(org.apache.geode.internal.cache.InternalRegionArguments) RegionExistsException(org.apache.geode.cache.RegionExistsException) RegionExistsException(org.apache.geode.cache.RegionExistsException) BucketMovedException(org.apache.geode.internal.cache.execute.BucketMovedException) RegionDestroyedException(org.apache.geode.cache.RegionDestroyedException) CancelException(org.apache.geode.CancelException) IOException(java.io.IOException) CacheException(org.apache.geode.cache.CacheException) GatewayCancelledException(org.apache.geode.distributed.GatewayCancelledException)

Example 3 with HasCachePerfStats

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());
            }
        }
    }
}
Also used : ThreadFactory(java.util.concurrent.ThreadFactory) InternalRegionArguments(org.apache.geode.internal.cache.InternalRegionArguments) RegionExistsException(org.apache.geode.cache.RegionExistsException) Notification(javax.management.Notification) ManagementException(org.apache.geode.management.ManagementException) AttributesFactory(org.apache.geode.cache.AttributesFactory) HasCachePerfStats(org.apache.geode.internal.cache.HasCachePerfStats) LoggingThreadGroup(org.apache.geode.internal.logging.LoggingThreadGroup) TimeoutException(org.apache.geode.cache.TimeoutException) CachePerfStats(org.apache.geode.internal.cache.CachePerfStats) HasCachePerfStats(org.apache.geode.internal.cache.HasCachePerfStats) IOException(java.io.IOException)

Aggregations

HasCachePerfStats (org.apache.geode.internal.cache.HasCachePerfStats)3 IOException (java.io.IOException)2 AttributesFactory (org.apache.geode.cache.AttributesFactory)2 RegionExistsException (org.apache.geode.cache.RegionExistsException)2 CachePerfStats (org.apache.geode.internal.cache.CachePerfStats)2 InternalRegionArguments (org.apache.geode.internal.cache.InternalRegionArguments)2 ThreadFactory (java.util.concurrent.ThreadFactory)1 Notification (javax.management.Notification)1 CancelException (org.apache.geode.CancelException)1 CacheException (org.apache.geode.cache.CacheException)1 RegionAttributes (org.apache.geode.cache.RegionAttributes)1 RegionDestroyedException (org.apache.geode.cache.RegionDestroyedException)1 TimeoutException (org.apache.geode.cache.TimeoutException)1 ResultsBag (org.apache.geode.cache.query.internal.ResultsBag)1 GatewayCancelledException (org.apache.geode.distributed.GatewayCancelledException)1 CachedDeserializable (org.apache.geode.internal.cache.CachedDeserializable)1 InternalCache (org.apache.geode.internal.cache.InternalCache)1 BucketMovedException (org.apache.geode.internal.cache.execute.BucketMovedException)1 LoggingThreadGroup (org.apache.geode.internal.logging.LoggingThreadGroup)1 StoredObject (org.apache.geode.internal.offheap.StoredObject)1