use of com.oracle.coherence.plugin.visualvm.tablemodel.model.ClusterData in project coherence-visualvm by oracle.
the class VisualVMModel method getData.
/**
* This is a wrapper method which will call the underlying implementation
* to get statistics. If statistics directly from the reporter are available
* then run the particular report, otherwise do a JMX query.
*
* @param requestSender the {@link RequestSender} to use to query the report
* @param clazz the implementation of {@link DataRetriever} to get data for
*
* @return the {@link List} of data obtainer by either method
*/
public List<Entry<Object, Data>> getData(RequestSender requestSender, Class clazz) {
boolean fFallBack = false;
// are collecting ProxyStats, we need to force to use JMX rather than report
if (isReporterAvailable() != null && isReporterAvailable() && !(clazz.equals(ProxyData.class) && getClusterVersionAsInt() < 122110)) {
// retrieve the report XML for this class
String sReportXML = f_mapReportXML.get(clazz);
if (sReportXML == null) {
// this means there is no report for this class
fFallBack = true;
}
if (!fFallBack) {
try {
DataRetriever retriever = getDataRetrieverInstance(clazz);
SortedMap<Object, Data> mapCollectedData = null;
if (requestSender instanceof HttpRequestSender) {
mapCollectedData = retriever.getAggregatedDataFromHttpQuerying(this, ((HttpRequestSender) requestSender));
} else {
mapCollectedData = retriever.getAggregatedDataUsingReport(this, requestSender, sReportXML);
}
if (mapCollectedData != null) {
return new ArrayList<Map.Entry<Object, Data>>(mapCollectedData.entrySet());
} else {
return null;
}
} catch (Exception e) {
// we received an error running the report, so mark as
// a fall back so it will be immediately run
LOGGER.warning(Localization.getLocalText("ERR_Failed_to_run_report", clazz.toString(), e.toString()));
e.printStackTrace();
fFallBack = true;
}
}
}
// are collecting ProxyStats, we need to force to use JMX rather than report
if (fFallBack || isReporterAvailable() == null || !isReporterAvailable() || (clazz.equals(ProxyData.class) && getClusterVersionAsInt() < 122110)) {
try {
// we may be able to use the reporter
if (clazz.equals(ClusterData.class)) {
List<Entry<Object, Data>> clusterData = getDataRetrieverInstance(clazz).getJMXData(requestSender, this);
// then do it. Also check for the version as well.
if (isReporterAvailable() == null || is1213AndAbove() == null) {
if (clusterData != null) {
for (Entry<Object, Data> entry : clusterData) {
// there will only be one cluster entry
String sCoherenceVersion = entry.getValue().getColumn(ClusterData.VERSION).toString().replaceFirst(" .*$", "").replaceFirst("[\\.-]SNAPSHOT.*$", "").replaceAll("-", ".");
m_sClusterVersion = sCoherenceVersion;
int nVersion = 0;
if (sCoherenceVersion.startsWith("3.5")) {
// manual check as version numbering changed after 35
nVersion = 353;
} else if (sCoherenceVersion.startsWith("2")) {
// check for versions such as 20.06 or 20.06.01 and convert them to an ever increasing number
// 20.06 -> 2006000
// 20.06.1 -> 2006100
// 20.06.10 -> 2006100
String sStrippedVersion = sCoherenceVersion.replaceAll("\\.", "");
nVersion = Integer.parseInt(sStrippedVersion) * (int) Math.pow(10, 7 - sStrippedVersion.length());
} else {
nVersion = Integer.parseInt(sCoherenceVersion.replaceAll("\\.", ""));
}
if (nVersion >= 121300) {
// only set if the reporter available is it is not already set as we may have
// got to this code path because is1213AndAbove() is still null
setReporterAvailable(isReporterAvailable() == null ? true : isReporterAvailable());
m_fis1213AndAbove = true;
} else {
setReporterAvailable(isReporterAvailable() == null ? false : isReporterAvailable());
m_fis1213AndAbove = false;
}
m_nClusterVersion = nVersion;
}
}
}
return clusterData;
} else {
return getDataRetrieverInstance(clazz).getJMXData(requestSender, this);
}
} catch (Exception e) {
LOGGER.log(Level.WARNING, "Unable to get data", e);
}
}
return null;
}
use of com.oracle.coherence.plugin.visualvm.tablemodel.model.ClusterData in project coherence-visualvm by oracle.
the class VisualVMView method createComponent.
// ----- helpers --------------------------------------------------------
/**
* Create the new {@link DataViewComponent} which will display all the
* Coherence related information.
*/
@Override
protected DataViewComponent createComponent() {
final VisualVMModel model = VisualVMModel.getInstance();
boolean fClusterSnapshotEnabled = com.oracle.coherence.plugin.visualvm.GlobalPreferences.sharedInstance().isClusterSnapshotEnabled();
// Data area for master view
JEditorPane generalDataArea = new JEditorPane();
generalDataArea.setEditable(false);
// do an initial refresh of the data so we can see if we need to display
// the proxy server tab
model.refreshStatistics(requestSender);
model.setIsFirstRefresh(false);
// we then construct the panels after the initial refresh so we can utilize
// any information we have gathered in the startup
final CoherenceClusterSnapshotPanel pnlClusterSnapshot = fClusterSnapshotEnabled ? new CoherenceClusterSnapshotPanel(model) : null;
final CoherenceClusterOverviewPanel pnlClusterOverview = new CoherenceClusterOverviewPanel(model);
final CoherenceMachinePanel pnlMachine = new CoherenceMachinePanel(model);
final CoherenceMemberPanel pnlMember = new CoherenceMemberPanel(model);
final CoherenceServicePanel pnlService = new CoherenceServicePanel(model);
final CoherenceCachePanel pnlCache = new CoherenceCachePanel(model);
final CoherenceTopicPanel pnlTopic = new CoherenceTopicPanel(model);
final CoherenceProxyPanel pnlProxy = new CoherenceProxyPanel(model);
final CoherenceHotCachePanel pnlHotCache = new CoherenceHotCachePanel(model);
final CoherencePersistencePanel pnlPersistence = new CoherencePersistencePanel(model);
final CoherenceHttpSessionPanel pnlHttpSession = new CoherenceHttpSessionPanel(model);
final CoherenceFederationPanel pnlFederation = new CoherenceFederationPanel(model);
final CoherenceElasticDataPanel pnlElasticData = new CoherenceElasticDataPanel(model);
final CoherenceJCachePanel pnlJCache = new CoherenceJCachePanel(model);
final CoherenceHttpProxyPanel pnlHttpProxy = new CoherenceHttpProxyPanel(model);
final CoherenceExecutorPanel pnlExecutor = new CoherenceExecutorPanel(model);
final CoherenceGrpcProxyPanel pnlGrpcProxy = new CoherenceGrpcProxyPanel(model);
String sClusterVersion = model.getClusterVersion();
String sClusterName = null;
List<Map.Entry<Object, Data>> clusterData = model.getData(VisualVMModel.DataType.CLUSTER);
for (Map.Entry<Object, Data> entry : clusterData) {
sClusterName = entry.getValue().getColumn(ClusterData.CLUSTER_NAME).toString();
break;
}
// Master view:
DataViewComponent.MasterView masterView = new DataViewComponent.MasterView(Localization.getLocalText("LBL_cluster_information", sClusterName, sClusterVersion), null, generalDataArea);
// Configuration of master view:
DataViewComponent.MasterViewConfiguration masterConfiguration = new DataViewComponent.MasterViewConfiguration(false);
// Add the master view and configuration view to the component:
m_dvc = new DataViewComponent(masterView, masterConfiguration);
m_dvc.configureDetailsArea(new DataViewComponent.DetailsAreaConfiguration(Localization.getLocalText("LBL_cluster_overview"), false), DataViewComponent.TOP_RIGHT);
// Add detail views to the components
if (pnlClusterSnapshot != null) {
m_dvc.addDetailsView(new DataViewComponent.DetailsView(Localization.getLocalText("LBL_cluster_snapshot"), null, 10, pnlClusterSnapshot, null), DataViewComponent.TOP_RIGHT);
}
DataViewComponent.DetailsView clusterOverview = new DataViewComponent.DetailsView(Localization.getLocalText("LBL_cluster_overview"), null, 10, pnlClusterOverview, null);
m_dvc.addDetailsView(clusterOverview, DataViewComponent.TOP_RIGHT);
m_dvc.addDetailsView(new DataViewComponent.DetailsView(Localization.getLocalText("LBL_machines"), null, 10, pnlMachine, null), DataViewComponent.TOP_RIGHT);
m_dvc.addDetailsView(new DataViewComponent.DetailsView(Localization.getLocalText("LBL_members"), null, 10, pnlMember, null), DataViewComponent.TOP_RIGHT);
m_dvc.addDetailsView(new DataViewComponent.DetailsView(Localization.getLocalText("LBL_services"), null, 10, pnlService, null), DataViewComponent.TOP_RIGHT);
m_dvc.addDetailsView(new DataViewComponent.DetailsView(Localization.getLocalText("LBL_caches"), null, 10, pnlCache, null), DataViewComponent.TOP_RIGHT);
// add the default panels
if (pnlClusterSnapshot != null) {
f_setPanels.add(pnlClusterSnapshot);
pnlClusterSnapshot.setRequestSender(requestSender);
}
f_setPanels.add(pnlClusterOverview);
f_setPanels.add(pnlMachine);
f_setPanels.add(pnlMember);
f_setPanels.add(pnlService);
f_setPanels.add(pnlCache);
if (model.isHotcacheConfigured()) {
m_dvc.addDetailsView(new DataViewComponent.DetailsView(Localization.getLocalText("LBL_hotcache"), null, 10, pnlHotCache, null), DataViewComponent.TOP_RIGHT);
f_setPanels.add(pnlHotCache);
}
// selectively add tabs based upon used functionality
if (model.isFederationCongfigured()) {
m_dvc.addDetailsView(new DataViewComponent.DetailsView(Localization.getLocalText("LBL_federation"), null, 10, pnlFederation, null), DataViewComponent.TOP_RIGHT);
f_setPanels.add(pnlFederation);
}
if (model.isCoherenceExtendConfigured()) {
m_dvc.addDetailsView(new DataViewComponent.DetailsView(Localization.getLocalText("LBL_proxy_servers"), null, 10, pnlProxy, null), DataViewComponent.TOP_RIGHT);
f_setPanels.add(pnlProxy);
}
if (model.isHttpProxyConfigured()) {
m_dvc.addDetailsView(new DataViewComponent.DetailsView(Localization.getLocalText("LBL_http_proxy_servers"), null, 10, pnlHttpProxy, null), DataViewComponent.TOP_RIGHT);
f_setPanels.add(pnlHttpProxy);
}
if (model.isTopicsConfigured()) {
m_dvc.addDetailsView(new DataViewComponent.DetailsView(Localization.getLocalText("LBL_topics"), null, 10, pnlTopic, null), DataViewComponent.TOP_RIGHT);
f_setPanels.add(pnlTopic);
}
if (model.isPersistenceConfigured()) {
m_dvc.addDetailsView(new DataViewComponent.DetailsView(Localization.getLocalText("LBL_persistence"), null, 10, pnlPersistence, null), DataViewComponent.TOP_RIGHT);
f_setPanels.add(pnlPersistence);
}
if (model.isCoherenceWebConfigured()) {
m_dvc.addDetailsView(new DataViewComponent.DetailsView(Localization.getLocalText("LBL_Coherence_web"), null, 10, pnlHttpSession, null), DataViewComponent.TOP_RIGHT);
f_setPanels.add(pnlHttpSession);
}
if (model.isElasticDataConfigured()) {
m_dvc.addDetailsView(new DataViewComponent.DetailsView(Localization.getLocalText("LBL_elastic_data"), null, 10, pnlElasticData, null), DataViewComponent.TOP_RIGHT);
f_setPanels.add(pnlElasticData);
}
if (model.isJCacheConfigured()) {
m_dvc.addDetailsView(new DataViewComponent.DetailsView(Localization.getLocalText("LBL_JCache"), null, 10, pnlJCache, null), DataViewComponent.TOP_RIGHT);
f_setPanels.add(pnlJCache);
}
if (model.isExecutorConfigured()) {
m_dvc.addDetailsView(new DataViewComponent.DetailsView(Localization.getLocalText("LBL_executors"), null, 10, pnlExecutor, null), DataViewComponent.TOP_RIGHT);
f_setPanels.add(pnlExecutor);
}
if (model.isGrpcProxyConfigured()) {
m_dvc.addDetailsView(new DataViewComponent.DetailsView(Localization.getLocalText("LBL_grpc"), null, 10, pnlGrpcProxy, null), DataViewComponent.TOP_RIGHT);
f_setPanels.add(pnlGrpcProxy);
}
// update the request sender
pnlClusterOverview.setRequestSender(requestSender);
pnlMachine.setRequestSender(requestSender);
pnlMember.setRequestSender(requestSender);
pnlService.setRequestSender(requestSender);
pnlCache.setRequestSender(requestSender);
pnlHotCache.setRequestSender(requestSender);
pnlFederation.setRequestSender(requestSender);
pnlProxy.setRequestSender(requestSender);
pnlTopic.setRequestSender(requestSender);
pnlPersistence.setRequestSender(requestSender);
pnlHttpSession.setRequestSender(requestSender);
pnlElasticData.setRequestSender(requestSender);
pnlJCache.setRequestSender(requestSender);
pnlExecutor.setRequestSender(requestSender);
pnlGrpcProxy.setRequestSender(requestSender);
// using JMX queries rather than the reporter.
if (model.getDomainPartitions().size() > 1) {
JOptionPane.showMessageDialog(null, Localization.getLocalText("LBL_mt_warning"));
}
m_dvc.selectDetailsView(clusterOverview);
// create a timer that will refresh the TAB's as required every 3 seconds
// the reason for 3 seconds is so that with the min cluster data refresh time of
// 5 seconds, the updates will be smoother
m_timer = new Timer(3000, new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (refreshRunning) {
return;
}
refreshRunning = true;
RequestProcessor.getDefault().post(new Runnable() {
public void run() {
try {
// application may be null inside the constructor
if (m_application == null || m_application.getState() == Application.STATE_AVAILABLE) {
// Schedule the SwingWorker to update the GUI
model.refreshStatistics(requestSender);
// refresh only the panels that were activated on startup
for (AbstractCoherencePanel panel : f_setPanels) {
panel.updateData();
panel.updateGUI();
}
}
} catch (Exception ex) {
LOGGER.warning("Error while refreshing tabs. " + ex.toString());
ex.printStackTrace();
} finally {
refreshRunning = false;
}
}
});
}
});
m_timer.setInitialDelay(800);
m_timer.start();
return m_dvc;
}
use of com.oracle.coherence.plugin.visualvm.tablemodel.model.ClusterData in project coherence-visualvm by oracle.
the class VisualVMModel method init.
// ---- helper methods --------------------------------------------------
/**
* Initialize anything for this instance of the model.
*/
private void init() {
m_nRefreshTime = getRefreshTime();
m_fLogJMXQueryTimes = isLogQueryTimes();
String sReporterDisabled = System.getProperty(PROP_REPORTER_DISABLED);
// version >= 12.1.3
if ("true".equalsIgnoreCase(sReporterDisabled)) {
setReporterAvailable(false);
}
// force update on first time
m_ldtLastUpdate = System.currentTimeMillis() - m_nRefreshTime - 1L;
// populate mapCollectedData which contains an entry for each type
m_mapCollectedData = new HashMap<DataType, List<Entry<Object, Data>>>();
for (DataType type : DataType.values()) {
m_mapCollectedData.put(type, null);
}
// intialize the data retrievers map
f_mapDataRetrievers.put(CacheData.class, new CacheData());
f_mapDataRetrievers.put(ClusterData.class, new ClusterData());
f_mapDataRetrievers.put(MemberData.class, new MemberData());
f_mapDataRetrievers.put(ServiceData.class, new ServiceData());
f_mapDataRetrievers.put(ServiceMemberData.class, new ServiceMemberData());
f_mapDataRetrievers.put(ProxyData.class, new ProxyData());
f_mapDataRetrievers.put(MachineData.class, new MachineData());
f_mapDataRetrievers.put(CacheDetailData.class, new CacheDetailData());
f_mapDataRetrievers.put(CacheFrontDetailData.class, new CacheFrontDetailData());
f_mapDataRetrievers.put(TopicData.class, new TopicData());
f_mapDataRetrievers.put(PersistenceData.class, new PersistenceData());
f_mapDataRetrievers.put(PersistenceNotificationsData.class, new PersistenceNotificationsData());
f_mapDataRetrievers.put(CacheStorageManagerData.class, new CacheStorageManagerData());
f_mapDataRetrievers.put(HttpSessionData.class, new HttpSessionData());
f_mapDataRetrievers.put(FederationDestinationData.class, new FederationDestinationData());
f_mapDataRetrievers.put(FederationDestinationDetailsData.class, new FederationDestinationDetailsData());
f_mapDataRetrievers.put(FederationOriginData.class, new FederationOriginData());
f_mapDataRetrievers.put(FederationOriginDetailsData.class, new FederationOriginDetailsData());
f_mapDataRetrievers.put(RamJournalData.class, new RamJournalData());
f_mapDataRetrievers.put(FlashJournalData.class, new FlashJournalData());
f_mapDataRetrievers.put(JCacheConfigurationData.class, new JCacheConfigurationData());
f_mapDataRetrievers.put(JCacheStatisticsData.class, new JCacheStatisticsData());
f_mapDataRetrievers.put(HttpProxyData.class, new HttpProxyData());
f_mapDataRetrievers.put(HttpProxyMemberData.class, new HttpProxyMemberData());
f_mapDataRetrievers.put(HotCacheData.class, new HotCacheData());
f_mapDataRetrievers.put(HotCachePerCacheData.class, new HotCachePerCacheData());
f_mapDataRetrievers.put(NodeStorageData.class, new NodeStorageData());
f_mapDataRetrievers.put(ExecutorData.class, new ExecutorData());
f_mapDataRetrievers.put(GrpcProxyData.class, new GrpcProxyData());
// Loop through each data retriever and initialize the map of
// report XML. Doing it this way we load it only once
Iterator<Map.Entry<Class, DataRetriever>> iter = f_mapDataRetrievers.entrySet().iterator();
while (iter.hasNext()) {
Map.Entry<Class, DataRetriever> entry = iter.next();
String sReport = entry.getValue().getReporterReport();
if (sReport != null) {
String sReportXML = getReportXML(sReport);
if (sReportXML != null) {
f_mapReportXML.put(entry.getKey(), sReportXML);
}
}
}
}
use of com.oracle.coherence.plugin.visualvm.tablemodel.model.ClusterData in project coherence-visualvm by oracle.
the class AbstractDataRetrieverTest method testClusterData.
/**
* Test the retrieval of ClusterData via the VisualVMModel.
*/
private void testClusterData() {
List<Map.Entry<Object, Data>> clusterData;
VisualVMModel model = getModel();
assertClusterReady();
waitForRefresh();
// refresh the statistics
model.refreshStatistics(getRequestSender());
clusterData = model.getData(VisualVMModel.DataType.CLUSTER);
validateData(VisualVMModel.DataType.CLUSTER, clusterData, 1);
setCurrentDataType(VisualVMModel.DataType.CLUSTER);
// ensure we have correct values
for (Map.Entry<Object, Data> entry : clusterData) {
validateColumn(ClusterData.CLUSTER_NAME, entry, CLUSTER_NAME);
validateColumn(ClusterData.CLUSTER_SIZE, entry, 2);
validateColumn(ClusterData.VERSION, entry, CacheFactory.VERSION);
validateColumn(ClusterData.DEPARTURE_COUNT, entry, 0L);
}
}
Aggregations