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