/** * Returns information of all existing agents. * <p> * <i> Example URL: /data/agents</i> * </p> * * @return a list of {@link PlatformIdent} with all existing agents. */ @RequestMapping(method = GET, value = "") @ResponseBody public Set<PlatformIdent> getAll() { Map<PlatformIdent, AgentStatusData> agentsOverviewMap = globalDataAccessService.getAgentsOverview(); return agentsOverviewMap.keySet(); }
/** * Returns list of instrumented methods of a given agentId. * <p> * <i> Example URL: /data/agents/{agentId}/methods</i> * </p> * * @param agentId * AGENT ID bounded from path. * @return a Set of {@link MethodIdent} of a given agentId. * @throws BusinessException * If given ID of the agent is not valid. */ @RequestMapping(method = GET, value = "{agentId}/methods") @ResponseBody public Set<MethodIdent> getMethods(@PathVariable long agentId) throws BusinessException { return globalDataAccessService.getCompleteAgent(agentId).getMethodIdents(); }
/** * Loads the {@link JmxSensorValueData} objects which were created between the given * {@link Date} objects. * * @param from * the start date * @param to * the end date * @return list of {@link JmxSensorValueData} objects */ @SuppressWarnings("unchecked") private List<JmxSensorValueData> loadJmxData(Date from, Date to) { return (List<JmxSensorValueData>) globalDataAccessService.getDataObjectsFromToDate(template, from, to); }
/** * Internal refresh of the idents. Currently everything is loaded again. */ protected void refreshIdents() { Map<PlatformIdent, AgentStatusData> agentMap = globalDataAccessService.getAgentsOverview(); platformMap.clear(); methodMap.clear(); sensorTypeMap.clear(); jmxDefinitionDataMap.clear(); for (PlatformIdent overview : agentMap.keySet()) { PlatformIdent platformIdent; try { platformIdent = globalDataAccessService.getCompleteAgent(overview.getId()); } catch (BusinessException e) { LOG.warn("Exception occurred trying to refresh sensor information for the agent " + overview.getAgentName() + ".", e); continue; } platformMap.put(platformIdent.getId(), platformIdent); for (MethodIdent methodIdent : platformIdent.getMethodIdents()) { methodMap.put(methodIdent.getId(), methodIdent); } for (SensorTypeIdent sensorTypeIdent : platformIdent.getSensorTypeIdents()) { sensorTypeMap.put(sensorTypeIdent.getId(), sensorTypeIdent); } for (JmxDefinitionDataIdent jmxDefinitionDataIdent : platformIdent.getJmxDefinitionDataIdents()) { jmxDefinitionDataMap.put(jmxDefinitionDataIdent.getId(), jmxDefinitionDataIdent); } } }
/** * {@inheritDoc} */ @Override public void doRefresh() { ClassLoadingInformationData classLoadingData = (ClassLoadingInformationData) dataAccessService.getLastDataObject(classLoadingObj); CpuInformationData cpuData = (CpuInformationData) dataAccessService.getLastDataObject(cpuObj); CompilationInformationData compilationData = (CompilationInformationData) dataAccessService.getLastDataObject(compilationObj); MemoryInformationData memoryData = (MemoryInformationData) dataAccessService.getLastDataObject(memoryObj); RuntimeInformationData runtimeData = (RuntimeInformationData) dataAccessService.getLastDataObject(runtimeObj); ThreadInformationData threadData = (ThreadInformationData) dataAccessService.getLastDataObject(threadObj); updateLabels(classLoadingData, cpuData, compilationData, memoryData, runtimeData, threadData); }
List<TimerData> timerDatas = (List<TimerData>) dataAccessService.getTemplatesDataObjectsFromToDate(templates, from, to); if (CollectionUtils.isNotEmpty(timerDatas)) { fromDate = (Date) from.clone(); if (rightAppend) { Date startingFrom = new Date(latestDataDate.getTime() + 1); List<TimerData> timerDatas = (List<TimerData>) dataAccessService.getTemplatesDataObjectsFromToDate(templates, startingFrom, to); if (CollectionUtils.isNotEmpty(timerDatas)) { displayedData.addAll(timerDatas); List<TimerData> timerDatas = (List<TimerData>) dataAccessService.getTemplatesDataObjectsFromToDate(templates, from, endingTo); if (CollectionUtils.isNotEmpty(timerDatas)) { displayedData.addAll(0, timerDatas);
/** * {@inheritDoc} */ @Override public Object execute(ExecutionEvent event) throws ExecutionException { IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event); boolean confirmed = MessageDialog.openConfirm(HandlerUtil.getActiveShell(event), "Confirm Delete", "Are you sure you want to permanently delete the selected Agent(s)? Note that all monitoring data related to the Agent(s) will be deleted from the repository database."); if (confirmed) { for (Iterator<?> it = selection.iterator(); it.hasNext();) { Object selected = it.next(); if (selected instanceof AgentLeaf) { AgentLeaf agentLeaf = (AgentLeaf) selected; PlatformIdent platformIdent = agentLeaf.getPlatformIdent(); CmrRepositoryDefinition cmrRepositoryDefinition = agentLeaf.getCmrRepositoryDefinition(); try { cmrRepositoryDefinition.getGlobalDataAccessService().deleteAgent(platformIdent.getId()); InspectIT.getDefault().getCmrRepositoryManager().repositoryAgentDeleted(cmrRepositoryDefinition, platformIdent); } catch (BusinessException e) { throw new ExecutionException("Exception occurred trying to delete the Agent from the CMR.", e); } } } } return null; } }
@BeforeMethod public void initialize() throws BusinessException { platformIdent = mock(PlatformIdent.class); when(platformIdent.getId()).thenReturn(PLATFORM_ID); when(globalDataAccessService.getAgentsOverview()).thenReturn(Collections.<PlatformIdent, AgentStatusData> singletonMap(platformIdent, null)); when(globalDataAccessService.getCompleteAgent(PLATFORM_ID)).thenReturn(platformIdent); methodIdent = mock(MethodIdent.class); when(methodIdent.getId()).thenReturn(METHOD_SENSOR_ID); when(platformIdent.getMethodIdents()).thenReturn(Collections.singleton(methodIdent)); sensorType = mock(SensorTypeIdent.class); when(sensorType.getId()).thenReturn(SENSOR_ID); when(platformIdent.getSensorTypeIdents()).thenReturn(Collections.singleton(sensorType)); }
/** * {@inheritDoc} */ @Override public void doRefresh() { final ClassLoadingInformationData data = (ClassLoadingInformationData) dataAccessService.getLastDataObject(classLoadingObj); if (null != data) { SafeExecutor.asyncExec(new Runnable() { @Override public void run() { // updates the labels int count = data.getCount(); loadedClassCount.setText(NumberFormatter.formatInteger(data.getTotalLoadedClassCount() / count)); totalLoadedClassCount.setText(NumberFormatter.formatLong(data.getTotalTotalLoadedClassCount() / count)); unloadedClassCount.setText(NumberFormatter.formatLong(data.getTotalUnloadedClassCount() / count)); } }, loadedClassCount, totalLoadedClassCount, unloadedClassCount); } }
@Test public void testIdentsCache() throws BusinessException { assertThat(cachedDataService.getPlatformIdentForId(PLATFORM_ID), is(equalTo(platformIdent))); assertThat(cachedDataService.getMethodIdentForId(METHOD_SENSOR_ID), is(equalTo(methodIdent))); assertThat(cachedDataService.getSensorTypeIdentForId(SENSOR_ID), is(equalTo(sensorType))); verify(globalDataAccessService, times(1)).getAgentsOverview(); verify(globalDataAccessService, times(1)).getCompleteAgent(PLATFORM_ID); verifyNoMoreInteractions(globalDataAccessService); assertThat(cachedDataService.getPlatformIdentForId(100L), is(nullValue())); assertThat(cachedDataService.getMethodIdentForId(100L), is(nullValue())); assertThat(cachedDataService.getSensorTypeIdentForId(100L), is(nullValue())); verify(globalDataAccessService, times(4)).getAgentsOverview(); verify(globalDataAccessService, times(4)).getCompleteAgent(PLATFORM_ID); verifyNoMoreInteractions(globalDataAccessService); verifyNoMoreInteractions(businessContextService); } }
/** * Returns the status of a given agentId. * <p> * <i> Example URL: /data/agents/{agentId}</i> * </p> * * @param agentId * AGENT ID bounded from path. * @return the status of a given agentId. * @throws BusinessException * If given ID of the agent is not valid. */ @RequestMapping(method = GET, value = "{agentId}") @ResponseBody public AgentStatusData getStatus(@PathVariable long agentId) throws BusinessException { AgentStatusData agentStatus = null; Map<PlatformIdent, AgentStatusData> agents = globalDataAccessService.getAgentsOverview(); for (Entry<PlatformIdent, AgentStatusData> entry : agents.entrySet()) { if (entry.getKey().getId() == agentId) { agentStatus = globalDataAccessService.getAgentsOverview().get(entry.getKey()); } } if (agentStatus == null) { throw new BusinessException("Agent with ID " + agentId + " does not exist!", AgentManagementErrorCodeEnum.AGENT_DOES_NOT_EXIST); } return agentStatus; }
/** * Returns the complete sensors informations of an agent. * <p> * <i> Example URL: /data/agents/{agentId}/sensors</i> * </p> * * @param agentId * AGENT ID bounded from path. * @return a Set of {@link SensorTypeIdent} of the given agentId. * @throws BusinessException * If given ID of the agent is not valid. */ @RequestMapping(method = GET, value = "{agentId}/sensors") @ResponseBody public Set<SensorTypeIdent> getSensors(@PathVariable long agentId) throws BusinessException { return globalDataAccessService.getCompleteAgent(agentId).getSensorTypeIdents(); }
/** * {@inheritDoc} */ @Override public void doRefresh() { final ThreadInformationData data = (ThreadInformationData) dataAccessService.getLastDataObject(threadObj); if (null != data) { SafeExecutor.asyncExec(new Runnable() { @Override public void run() { // updates the labels int count = data.getCount(); liveThreadCount.setText(NumberFormatter.formatInteger(data.getTotalThreadCount() / count)); daemonThreadCount.setText(NumberFormatter.formatInteger(data.getTotalDaemonThreadCount() / count)); totalStartedThreadCount.setText(NumberFormatter.formatLong(data.getTotalTotalStartedThreadCount() / count)); peakThreadCount.setText(NumberFormatter.formatInteger(data.getTotalPeakThreadCount() / count)); } }, liveThreadCount, daemonThreadCount, totalStartedThreadCount, peakThreadCount); } }
List<ClassLoadingInformationData> data = (List<ClassLoadingInformationData>) dataAccessService.getDataObjectsFromToDate(template, from, to); Date leftDate = new Date(oldFromDate.getTime() - 1); List<ClassLoadingInformationData> rightData = (List<ClassLoadingInformationData>) dataAccessService.getDataObjectsFromToDate(template, rightDate, to); List<ClassLoadingInformationData> leftData = (List<ClassLoadingInformationData>) dataAccessService.getDataObjectsFromToDate(template, from, leftDate); List<ClassLoadingInformationData> timerData = (List<ClassLoadingInformationData>) dataAccessService.getDataObjectsFromToDate(template, rightDate, to); List<ClassLoadingInformationData> timerData = (List<ClassLoadingInformationData>) dataAccessService.getDataObjectsFromToDate(template, from, leftDate);
try { if (cmrRepositoryDefinition.getOnlineStatus() == OnlineStatus.ONLINE) { Map<PlatformIdent, AgentStatusData> agents = cmrRepositoryDefinition.getGlobalDataAccessService().getAgentsOverview(); if (null != agents) { Map<PlatformIdent, AgentStatusData> filteredMap = new HashMap<>(agents.size());
/** * {@inheritDoc} */ @Override public void doRefresh() { final CpuInformationData data = (CpuInformationData) dataAccessService.getLastDataObject(cpuObj); if (null != data) { SafeExecutor.asyncExec(new Runnable() { @Override public void run() { int count = data.getCount(); if (data.getTotalCpuUsage() > 0) { cpuUsage.setText(NumberFormatter.formatCpuPercent(data.getTotalCpuUsage() / count)); } else { cpuUsage.setText(NOT_AVAILABLE); } if (data.getProcessCpuTime() > 0) { processCpuTime.setText(NumberFormatter.formatNanosToSeconds(data.getProcessCpuTime())); } else { processCpuTime.setText(NOT_AVAILABLE); } } }, cpuUsage, processCpuTime); } }
List<CpuInformationData> data = (List<CpuInformationData>) dataAccessService.getDataObjectsFromToDate(template, from, to); Date leftDate = new Date(oldFromDate.getTime() - 1); List<CpuInformationData> rightData = (List<CpuInformationData>) dataAccessService.getDataObjectsFromToDate(template, rightDate, to); List<CpuInformationData> leftData = (List<CpuInformationData>) dataAccessService.getDataObjectsFromToDate(template, from, leftDate); List<CpuInformationData> timerData = (List<CpuInformationData>) dataAccessService.getDataObjectsFromToDate(template, rightDate, to); List<CpuInformationData> timerData = (List<CpuInformationData>) dataAccessService.getDataObjectsFromToDate(template, from, leftDate);
final MemoryInformationData data = (MemoryInformationData) dataAccessService.getLastDataObject(memoryObj);
List<ThreadInformationData> data = (List<ThreadInformationData>) dataAccessService.getDataObjectsFromToDate(template, from, to); Date leftDate = new Date(oldFromDate.getTime() - 1); List<ThreadInformationData> rightData = (List<ThreadInformationData>) dataAccessService.getDataObjectsFromToDate(template, rightDate, to); List<ThreadInformationData> leftData = (List<ThreadInformationData>) dataAccessService.getDataObjectsFromToDate(template, from, leftDate); List<ThreadInformationData> timerData = (List<ThreadInformationData>) dataAccessService.getDataObjectsFromToDate(template, rightDate, to); List<ThreadInformationData> timerData = (List<ThreadInformationData>) dataAccessService.getDataObjectsFromToDate(template, from, leftDate);
addSection(parent, toolkit, SECTION_MEMORY); SystemInformationData systemData = (SystemInformationData) dataAccessService.getLastDataObject(systemObj); if (systemData != null) {