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);
}
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);
}
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;
}
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
}
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;
}
Aggregations