Search in sources :

Example 81 with InternalDistributedSystem

use of org.apache.geode.distributed.internal.InternalDistributedSystem in project geode by apache.

the class SystemMemberCacheEventProcessor method send.

/*
   * Sends region creation/destroy message to Admin VMs
   */
public static void send(Cache c, Region region, Operation op) {
    InternalDistributedSystem system = (InternalDistributedSystem) c.getDistributedSystem();
    Set recps = system.getDistributionManager().getAdminMemberSet();
    // @todo darrel: find out if any of these guys have region listeners
    if (recps.isEmpty()) {
        return;
    }
    SystemMemberCacheMessage msg = new SystemMemberCacheMessage();
    if (region == null) {
        msg.regionPath = null;
    } else {
        msg.regionPath = region.getFullPath();
    }
    msg.setRecipients(recps);
    msg.op = op;
    system.getDistributionManager().putOutgoing(msg);
}
Also used : Set(java.util.Set) InternalDistributedSystem(org.apache.geode.distributed.internal.InternalDistributedSystem)

Example 82 with InternalDistributedSystem

use of org.apache.geode.distributed.internal.InternalDistributedSystem in project geode by apache.

the class MessageDependencyMonitor method getBlockedThreads.

public Set<Dependency<Thread, Serializable>> getBlockedThreads(Thread[] allThreads) {
    InternalDistributedSystem system = InternalDistributedSystem.getAnyInstance();
    if (system == null) {
        return Collections.emptySet();
    }
    InternalDistributedMember myId = system.getDistributedMember();
    Set<Dependency<Thread, Serializable>> blockedThreads = new HashSet<Dependency<Thread, Serializable>>();
    for (Thread thread : allThreads) {
        ReplyProcessor21 processor = waitingProcessors.get(thread);
        if (processor != null && processor.getProcessorId() > 0) {
            blockedThreads.add(new Dependency<Thread, Serializable>(thread, new MessageKey(myId, processor.getProcessorId())));
        }
    }
    return blockedThreads;
}
Also used : Serializable(java.io.Serializable) InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) InternalDistributedSystem(org.apache.geode.distributed.internal.InternalDistributedSystem) HashSet(java.util.HashSet) ReplyProcessor21(org.apache.geode.distributed.internal.ReplyProcessor21)

Example 83 with InternalDistributedSystem

use of org.apache.geode.distributed.internal.InternalDistributedSystem in project geode by apache.

the class SystemTimer method cancelSwarm.

/**
   * Cancel all outstanding timers
   * 
   * @param swarm the swarm to cancel
   */
public static void cancelSwarm(Object swarm) {
    // TODO
    Assert.assertTrue(swarm instanceof InternalDistributedSystem);
    // Find the swarmSet and remove it
    ArrayList swarmSet;
    synchronized (allSwarms) {
        swarmSet = (ArrayList) allSwarms.get(swarm);
        if (swarmSet == null) {
            // already cancelled
            return;
        }
        // Remove before releasing synchronization, so any fresh timer ends up
        // in a new set with same key
        allSwarms.remove(swarmSet);
    }
    // Empty the swarmSet
    synchronized (swarmSet) {
        Iterator it = swarmSet.iterator();
        while (it.hasNext()) {
            WeakReference wr = (WeakReference) it.next();
            SystemTimer st = (SystemTimer) wr.get();
            // it.remove(); Not necessary, we're emptying the list...
            if (st != null) {
                // for safety :-)
                st.cancelled = true;
                // st.cancel() would just search for it again
                st.timer.cancel();
            }
        }
    // while
    }
// synchronized
}
Also used : WeakReference(java.lang.ref.WeakReference) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) InternalDistributedSystem(org.apache.geode.distributed.internal.InternalDistributedSystem)

Example 84 with InternalDistributedSystem

use of org.apache.geode.distributed.internal.InternalDistributedSystem in project geode by apache.

the class ClientStatsManager method getClientHealthStats.

/**
   * This method queries the client stats & prepares the client health stats object to be published
   * to the server.
   * 
   * @return the client health stats object to be published to the server.
   */
private static ClientHealthStats getClientHealthStats(InternalCache currentCache, PoolImpl pool) {
    if (currentCache == null) {
        return null;
    }
    ClientHealthStats stats = new ClientHealthStats();
    LogWriterI18n logger = currentCache.getLoggerI18n();
    int gets = -1;
    int puts = -1;
    int misses = -1;
    int cacheListenerCalls = -1;
    if (cachePerfStats != null) {
        gets = cachePerfStats.getInt("gets");
        puts = cachePerfStats.getInt("puts");
        misses = cachePerfStats.getInt("misses");
        cacheListenerCalls = cachePerfStats.getInt("cacheListenerCallsCompleted");
    }
    long processCpuTime = -1;
    int threads = -1;
    int cpus = -1;
    if (vmStats != null) {
        processCpuTime = vmStats.getLong("processCpuTime");
        threads = vmStats.getInt("threads");
        cpus = vmStats.getInt("cpus");
    }
    stats.setNumOfGets(gets);
    stats.setNumOfPuts(puts);
    stats.setNumOfMisses(misses);
    stats.setNumOfCacheListenerCalls(cacheListenerCalls);
    stats.setProcessCpuTime(processCpuTime);
    stats.setNumOfThreads(threads);
    stats.setCpus(cpus);
    String poolName = pool.getName();
    try {
        Map<String, String> newPoolStats = stats.getPoolStats();
        String poolStatsStr = "MinConnections=" + pool.getMinConnections() + ";MaxConnections=" + pool.getMaxConnections() + ";Redundancy=" + pool.getSubscriptionRedundancy() + ";CQS=" + pool.getQueryService().getCqs().length;
        logger.info(LocalizedStrings.DEBUG, "ClientHealthStats for poolName " + poolName + " poolStatsStr=" + poolStatsStr);
        newPoolStats.put(poolName, poolStatsStr);
        // consider old stats
        Region clientHealthMonitoringRegion = ClientHealthMonitoringRegion.getInstance(currentCache);
        if (clientHealthMonitoringRegion != null) {
            InternalDistributedSystem ds = (InternalDistributedSystem) currentCache.getDistributedSystem();
            ClientHealthStats oldStats = (ClientHealthStats) clientHealthMonitoringRegion.get(ds.getMemberId());
            logger.info(LocalizedStrings.DEBUG, "getClientHealthStats got oldStats  " + oldStats);
            if (oldStats != null) {
                Map<String, String> oldPoolStats = oldStats.getPoolStats();
                logger.info(LocalizedStrings.DEBUG, "getClientHealthStats got oldPoolStats  " + oldPoolStats);
                if (oldPoolStats != null) {
                    for (Entry<String, String> entry : oldPoolStats.entrySet()) {
                        if (!poolName.equals(entry.getKey())) {
                            stats.getPoolStats().put(entry.getKey(), entry.getValue());
                        }
                    }
                }
            }
        }
    } catch (Exception e) {
        logger.fine("Exception in getting pool stats in  getClientHealthStats " + CliUtil.stackTraceAsString(e));
    }
    stats.setUpdateTime(new Date());
    return stats;
}
Also used : Region(org.apache.geode.cache.Region) LogWriterI18n(org.apache.geode.i18n.LogWriterI18n) InternalDistributedSystem(org.apache.geode.distributed.internal.InternalDistributedSystem) ClientHealthStats(org.apache.geode.internal.admin.remote.ClientHealthStats) DistributedSystemDisconnectedException(org.apache.geode.distributed.DistributedSystemDisconnectedException) CacheWriterException(org.apache.geode.cache.CacheWriterException) Date(java.util.Date)

Example 85 with InternalDistributedSystem

use of org.apache.geode.distributed.internal.InternalDistributedSystem in project geode by apache.

the class ClientStatsManager method publishClientStats.

/**
   * This method publishes the client stats using the admin region.
   * 
   * @param pool Connection pool which may be used for admin region.
   */
public static synchronized void publishClientStats(PoolImpl pool) {
    InternalCache currentCache = GemFireCacheImpl.getInstance();
    if (!initializeStatistics(currentCache)) {
        // handles null case too
        return;
    }
    LogWriterI18n logger = currentCache.getLoggerI18n();
    if (logger.fineEnabled())
        logger.fine("Entering ClientStatsManager#publishClientStats...");
    ClientHealthStats stats = getClientHealthStats(currentCache, pool);
    try {
        InternalDistributedSystem ds = (InternalDistributedSystem) currentCache.getDistributedSystem();
        ServerRegionProxy regionProxy = new ServerRegionProxy(ClientHealthMonitoringRegion.ADMIN_REGION_NAME, pool);
        EventID eventId = new EventID(ds);
        @Released EntryEventImpl event = new EntryEventImpl((Object) null);
        try {
            event.setEventId(eventId);
            regionProxy.putForMetaRegion(ds.getMemberId(), stats, null, event, null, true);
        } finally {
            event.release();
        }
    } catch (DistributedSystemDisconnectedException e) {
        throw e;
    } catch (CacheWriterException cwx) {
        pool.getCancelCriterion().checkCancelInProgress(cwx);
        currentCache.getCancelCriterion().checkCancelInProgress(cwx);
        // TODO: Need to analyze these exception scenarios.
        logger.warning(LocalizedStrings.ClientStatsManager_FAILED_TO_SEND_CLIENT_HEALTH_STATS_TO_CACHESERVER, cwx);
    } catch (Exception e) {
        pool.getCancelCriterion().checkCancelInProgress(e);
        currentCache.getCancelCriterion().checkCancelInProgress(e);
        logger.info(LocalizedStrings.ClientStatsManager_FAILED_TO_PUBLISH_CLIENT_STATISTICS, e);
    }
    if (logger.fineEnabled()) {
        logger.fine("Exiting ClientStatsManager#publishClientStats.");
    }
}
Also used : DistributedSystemDisconnectedException(org.apache.geode.distributed.DistributedSystemDisconnectedException) Released(org.apache.geode.internal.offheap.annotations.Released) EntryEventImpl(org.apache.geode.internal.cache.EntryEventImpl) ServerRegionProxy(org.apache.geode.cache.client.internal.ServerRegionProxy) InternalCache(org.apache.geode.internal.cache.InternalCache) EventID(org.apache.geode.internal.cache.EventID) LogWriterI18n(org.apache.geode.i18n.LogWriterI18n) InternalDistributedSystem(org.apache.geode.distributed.internal.InternalDistributedSystem) ClientHealthStats(org.apache.geode.internal.admin.remote.ClientHealthStats) DistributedSystemDisconnectedException(org.apache.geode.distributed.DistributedSystemDisconnectedException) CacheWriterException(org.apache.geode.cache.CacheWriterException) CacheWriterException(org.apache.geode.cache.CacheWriterException)

Aggregations

InternalDistributedSystem (org.apache.geode.distributed.internal.InternalDistributedSystem)209 Properties (java.util.Properties)70 Test (org.junit.Test)60 ConfigurationProperties (org.apache.geode.distributed.ConfigurationProperties)58 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)41 IOException (java.io.IOException)35 InternalDistributedMember (org.apache.geode.distributed.internal.membership.InternalDistributedMember)32 DM (org.apache.geode.distributed.internal.DM)30 File (java.io.File)22 HashSet (java.util.HashSet)21 Set (java.util.Set)20 AttributesFactory (org.apache.geode.cache.AttributesFactory)19 DistributionConfig (org.apache.geode.distributed.internal.DistributionConfig)19 Region (org.apache.geode.cache.Region)17 ArrayList (java.util.ArrayList)16 DistributionManager (org.apache.geode.distributed.internal.DistributionManager)16 SerializableCallable (org.apache.geode.test.dunit.SerializableCallable)14 VM (org.apache.geode.test.dunit.VM)14 Cache (org.apache.geode.cache.Cache)13 IgnoredException (org.apache.geode.test.dunit.IgnoredException)13