StatEntry entry = stats.get(name);
if (entry == null) {
continue;
}
ServiceInfoMBean serviceInfo = entry.getServiceInfoMBeanProxy();
CasPoolManagementImplMBean getServiceCasPoolMBeanProxy = entry
.getServiceCasPoolMBeanProxy();
boolean isRemote = serviceInfo.getBrokerURL().startsWith("tcp:");
boolean topLevel = serviceInfo.isTopLevel();
// Get the current reading from MBeans
double idleTime = entry.getServicePerformanceMBeanProxy().getIdleTime();
double casPoolWaitTime = entry.getServicePerformanceMBeanProxy().getCasPoolWaitTime();
double shadowCasPoolWaitTime = entry.getServicePerformanceMBeanProxy()
.getShadowCasPoolWaitTime();
double analysisTime = entry.getServicePerformanceMBeanProxy().getAnalysisTime();
long processCount = entry.getServicePerformanceMBeanProxy().getNumberOfCASesProcessed();
QueueViewMBean inputQueueInfo = entry.getInputQueueInfo();
QueueViewMBean replyQueueInfo = entry.getReplyQueueInfo();
cmFreeCasInstanceCount = -1;
if (serviceInfo.isCASMultiplier() && !isRemote && entry.getCasPoolMBean() != null) {
try {
cmFreeCasInstanceCount = entry.getCasPoolMBean().getAvailableInstances();
} catch( Exception e) {
//swallow this for now.
}
}
long inputQueueDepth = -1;
UimaVmQueueMBean vmInputQueueInfo = null;
// if the service is colocated, get the bean object for the internal (non-jms) queue
if (entry.isVmQueue) {
vmInputQueueInfo = entry.getVmInputQueueInfo();
if (vmInputQueueInfo != null) {
inputQueueDepth = vmInputQueueInfo.getQueueSize();
}
} else {
// service is top level and uses JMS queue
inputQueueInfo = entry.getInputQueueInfo();
if (inputQueueInfo != null) {
inputQueueDepth = inputQueueInfo.getQueueSize();
}
}
long replyQueueDepth = -1; // -1 means not available
UimaVmQueueMBean vmReplyQueueInfo = null;
if (entry.isVmQueue) {
vmReplyQueueInfo = entry.getVmReplyQueueInfo();
if (vmReplyQueueInfo != null) {
replyQueueDepth = vmReplyQueueInfo.getQueueSize();
}
} else {
replyQueueInfo = entry.getReplyQueueInfo();
if (replyQueueInfo != null) {
replyQueueDepth = replyQueueInfo.getQueueSize();
}
}
// compute the delta idle time by subtracting previously reported idle time from the
// current idle time
double deltaIdleTime = 0;
if (initial == false) {
deltaIdleTime = idleTime - entry.getIdleTime();
}
double deltaAnalysisTime = 0;
if (analysisTime > 0) {
deltaAnalysisTime = analysisTime - entry.getAnalysisTime();
}
ServiceMetrics serviceMetrics = new ServiceMetrics();
serviceMetrics.setCasMultiplier(entry.getServiceInfoMBeanProxy().isCASMultiplier());
serviceMetrics.setServiceRemote(isRemote);
serviceMetrics.setTopLevelService(topLevel);
serviceMetrics.setTimestamp((double) uptime / 1000000);
serviceMetrics.setIdleTime(deltaIdleTime);
serviceMetrics.setServiceName(name.getKeyProperty("name"));
serviceMetrics.setProcessCount(processCount - entry.getLastCASCount());
serviceMetrics.setInputQueueDepth(inputQueueDepth);
serviceMetrics.setReplyQueueDepth(replyQueueDepth);
serviceMetrics.setProcessThreadCount(entry.getServicePerformanceMBeanProxy()
.getProcessThreadCount());
serviceMetrics.setAnalysisTime(deltaAnalysisTime);
serviceMetrics.setCmFreeCasInstanceCount(cmFreeCasInstanceCount);
// The service cas pool proxy is only valid for aggregates and top level primitives
serviceMetrics.setSvcFreeCasInstanceCount(-1);
if (getServiceCasPoolMBeanProxy != null) {
try {
serviceMetrics.setSvcFreeCasInstanceCount(getServiceCasPoolMBeanProxy
.getAvailableInstances());
} catch( Exception e) {
}
}
// populate shadow CAS pool metric for remote CAS multiplier. Filter out the top level