Search in sources :

Example 6 with InternalDistributedSystem

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

the class SerialAsyncEventQueueImpl method stop.

@Override
public void stop() {
    if (logger.isDebugEnabled()) {
        logger.debug("Stopping Gateway Sender : {}", this);
    }
    this.getLifeCycleLock().writeLock().lock();
    try {
        // Stop the dispatcher
        AbstractGatewaySenderEventProcessor ev = this.eventProcessor;
        if (ev != null && !ev.isStopped()) {
            ev.stopProcessing();
        }
        // Stop the proxy (after the dispatcher, so the socket is still
        // alive until after the dispatcher has stopped)
        stompProxyDead();
        // Close the listeners
        for (AsyncEventListener listener : this.listeners) {
            listener.close();
        }
        logger.info(LocalizedMessage.create(LocalizedStrings.GatewayImpl_STOPPED__0, this));
        clearTempEventsAfterSenderStopped();
    } finally {
        this.getLifeCycleLock().writeLock().unlock();
    }
    if (this.isPrimary()) {
        try {
            DistributedLockService.destroy(getSenderAdvisor().getDLockServiceName());
        } catch (IllegalArgumentException e) {
        // service not found... ignore
        }
    }
    if (getQueues() != null && !getQueues().isEmpty()) {
        for (RegionQueue q : getQueues()) {
            ((SerialGatewaySenderQueue) q).cleanUp();
        }
    }
    this.setIsPrimary(false);
    try {
        new UpdateAttributesProcessor(this).distribute(false);
    } catch (CancelException e) {
    }
    Thread lockObtainingThread = getSenderAdvisor().getLockObtainingThread();
    if (lockObtainingThread != null && lockObtainingThread.isAlive()) {
        // wait a while for thread to terminate
        try {
            lockObtainingThread.join(3000);
        } catch (InterruptedException ex) {
            // we allowed our join to be canceled
            // reset interrupt bit so this thread knows it has been interrupted
            Thread.currentThread().interrupt();
        }
        if (lockObtainingThread.isAlive()) {
            logger.info(LocalizedMessage.create(LocalizedStrings.GatewaySender_COULD_NOT_STOP_LOCK_OBTAINING_THREAD_DURING_GATEWAY_SENDER_STOP));
        }
    }
    InternalDistributedSystem system = (InternalDistributedSystem) this.cache.getDistributedSystem();
    system.handleResourceEvent(ResourceEvent.GATEWAYSENDER_STOP, this);
}
Also used : SerialGatewaySenderQueue(org.apache.geode.internal.cache.wan.serial.SerialGatewaySenderQueue) UpdateAttributesProcessor(org.apache.geode.internal.cache.UpdateAttributesProcessor) CancelException(org.apache.geode.CancelException) InternalDistributedSystem(org.apache.geode.distributed.internal.InternalDistributedSystem) AbstractGatewaySenderEventProcessor(org.apache.geode.internal.cache.wan.AbstractGatewaySenderEventProcessor) RegionQueue(org.apache.geode.internal.cache.RegionQueue) AsyncEventListener(org.apache.geode.cache.asyncqueue.AsyncEventListener)

Example 7 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 8 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 9 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 10 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)

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