use of org.apache.ignite.mxbean.ClusterMetricsMXBean in project ignite by apache.
the class ClusterBaselineNodesMetricsSelfTest method testBaselineNodes.
/**
* @throws Exception If failed.
*/
@Test
public void testBaselineNodes() throws Exception {
// Start 2 server nodes.
IgniteEx ignite0 = startGrid(0);
ignite0.cluster().baselineAutoAdjustEnabled(false);
startGrid(1);
// Cluster metrics.
ClusterMetricsMXBean mxBeanCluster = mxBean(0, ClusterMetricsMXBeanImpl.class);
MetricRegistry mreg = ignite0.context().metric().registry(CLUSTER_METRICS);
ignite0.cluster().active(true);
// Added 2 server nodes to baseline.
resetBlt();
// Add server node outside of the baseline.
startGrid(2);
// Start client node.
startClientGrid(3);
Collection<BaselineNode> baselineNodes;
// State #0: 3 server nodes (2 total baseline nodes, 2 active baseline nodes), 1 client node
log.info(String.format(">>> State #0: topology version = %d", ignite0.cluster().topologyVersion()));
assertEquals(3, mxBeanCluster.getTotalServerNodes());
assertEquals(3, mreg.<IntMetric>findMetric(TOTAL_SERVER_NODES).value());
assertEquals(1, mxBeanCluster.getTotalClientNodes());
assertEquals(1, mreg.<IntMetric>findMetric(TOTAL_CLIENT_NODES).value());
assertEquals(2, mxBeanCluster.getTotalBaselineNodes());
assertEquals(2, mreg.<IntMetric>findMetric(TOTAL_BASELINE_NODES).value());
assertEquals(2, mxBeanCluster.getActiveBaselineNodes());
assertEquals(2, mreg.<IntMetric>findMetric(ACTIVE_BASELINE_NODES).value());
assertEquals(2, (baselineNodes = ignite0.cluster().currentBaselineTopology()) != null ? baselineNodes.size() : 0);
stopGrid(1, true);
// State #1: 2 server nodes (2 total baseline nodes, 1 active baseline node), 1 client node
log.info(String.format(">>> State #1: topology version = %d", ignite0.cluster().topologyVersion()));
assertEquals(2, mxBeanCluster.getTotalServerNodes());
assertEquals(2, mreg.<IntMetric>findMetric(TOTAL_SERVER_NODES).value());
assertEquals(1, mxBeanCluster.getTotalClientNodes());
assertEquals(1, mreg.<IntMetric>findMetric(TOTAL_CLIENT_NODES).value());
assertEquals(2, mxBeanCluster.getTotalBaselineNodes());
assertEquals(2, mreg.<IntMetric>findMetric(TOTAL_BASELINE_NODES).value());
assertEquals(1, mxBeanCluster.getActiveBaselineNodes());
assertEquals(1, mreg.<IntMetric>findMetric(ACTIVE_BASELINE_NODES).value());
assertEquals(2, (baselineNodes = ignite0.cluster().currentBaselineTopology()) != null ? baselineNodes.size() : 0);
startGrid(1);
ClusterMetricsMXBean mxBeanLocalNode1 = mxBean(1, ClusterLocalNodeMetricsMXBeanImpl.class);
// State #2: 3 server nodes (2 total baseline nodes, 2 active baseline nodes), 1 client node
log.info(String.format(">>> State #2: topology version = %d", ignite0.cluster().topologyVersion()));
assertEquals(3, mxBeanCluster.getTotalServerNodes());
assertEquals(3, mreg.<IntMetric>findMetric(TOTAL_SERVER_NODES).value());
assertEquals(1, mxBeanCluster.getTotalClientNodes());
assertEquals(1, mreg.<IntMetric>findMetric(TOTAL_CLIENT_NODES).value());
assertEquals(2, mxBeanCluster.getTotalBaselineNodes());
assertEquals(2, mreg.<IntMetric>findMetric(TOTAL_BASELINE_NODES).value());
assertEquals(2, mxBeanCluster.getActiveBaselineNodes());
assertEquals(2, mreg.<IntMetric>findMetric(ACTIVE_BASELINE_NODES).value());
assertEquals(1, mxBeanLocalNode1.getTotalBaselineNodes());
assertEquals(2, (baselineNodes = ignite0.cluster().currentBaselineTopology()) != null ? baselineNodes.size() : 0);
}
use of org.apache.ignite.mxbean.ClusterMetricsMXBean in project ignite by apache.
the class IgniteClientFailuresTest method testFailedClientLeavesTopologyAfterTimeout.
/**
* Test verifies that when client node failed but not yet cleaned up from topology
* (because {@link IgniteConfiguration#clientFailureDetectionTimeout} has not been reached yet)
* it doesn't affect new client connected from the same address.
*
* @throws Exception If failed.
*/
@Test
public void testFailedClientLeavesTopologyAfterTimeout() throws Exception {
IgniteEx srv0 = (IgniteEx) startGridsMultiThreaded(3);
IgniteEx client00 = startGrid("client00");
IgniteEx client01 = startGrid("client01");
client00.getOrCreateCache(new CacheConfiguration<>("cache0"));
client01.getOrCreateCache(new CacheConfiguration<>("cache1"));
IgniteInternalFuture f1 = GridTestUtils.runAsync(() -> breakClient(client00));
IgniteInternalFuture f2 = GridTestUtils.runAsync(() -> breakClient(client01));
f1.get();
f2.get();
final IgniteClusterEx cl = srv0.cluster();
assertEquals(5, cl.topology(cl.topologyVersion()).size());
IgniteEx client02 = startGrid("client02");
assertEquals(6, cl.topology(cl.topologyVersion()).size());
boolean waitRes = GridTestUtils.waitForCondition(() -> (cl.topology(cl.topologyVersion()).size() == 4), 20_000);
assertTrue(waitRes);
checkCacheOperations(client02.cache("cache0"));
assertEquals(4, srv0.context().discovery().allNodes().size());
// Cluster metrics.
ClusterMetricsMXBean mxBeanCluster = GridCommonAbstractTest.getMxBean(srv0.name(), "Kernal", ClusterMetricsMXBeanImpl.class.getSimpleName(), ClusterMetricsMXBean.class);
assertEquals(1, mxBeanCluster.getTotalClientNodes());
}
use of org.apache.ignite.mxbean.ClusterMetricsMXBean in project ignite by apache.
the class IgniteMBeansManager method registerMBeansAfterNodeStarted.
/**
* Registers kernal MBeans (for kernal, metrics, thread pools) after node start.
*
* @throws IgniteCheckedException if fails to register any of the MBeans.
*/
public void registerMBeansAfterNodeStarted() throws IgniteCheckedException {
if (U.IGNITE_MBEANS_DISABLED)
return;
// Kernal
IgniteMXBean kernalMXBean = new IgniteMXBeanImpl(kernal);
registerMBean("Kernal", IgniteKernal.class.getSimpleName(), kernalMXBean, IgniteMXBean.class);
// Metrics
ClusterMetricsMXBean locMetricsBean = new ClusterLocalNodeMetricsMXBeanImpl(ctx.discovery());
registerMBean("Kernal", locMetricsBean.getClass().getSimpleName(), locMetricsBean, ClusterMetricsMXBean.class);
ClusterMetricsMXBean metricsBean = new ClusterMetricsMXBeanImpl(kernal.cluster(), ctx);
registerMBean("Kernal", metricsBean.getClass().getSimpleName(), metricsBean, ClusterMetricsMXBean.class);
// Transaction metrics
TransactionMetricsMxBean txMetricsMXBean = new TransactionMetricsMxBeanImpl(ctx.cache().transactions().metrics());
registerMBean("TransactionMetrics", txMetricsMXBean.getClass().getSimpleName(), txMetricsMXBean, TransactionMetricsMxBean.class);
// Transactions
TransactionsMXBean txMXBean = new TransactionsMXBeanImpl(ctx);
registerMBean("Transactions", txMXBean.getClass().getSimpleName(), txMXBean, TransactionsMXBean.class);
// Queries management
QueryMXBean qryMXBean = new QueryMXBeanImpl(ctx);
registerMBean("Query", qryMXBean.getClass().getSimpleName(), qryMXBean, QueryMXBean.class);
// Compute task management
ComputeMXBean computeMXBean = new ComputeMXBeanImpl(ctx);
registerMBean("Compute", computeMXBean.getClass().getSimpleName(), computeMXBean, ComputeMXBean.class);
// Service management
ServiceMXBean serviceMXBean = new ServiceMXBeanImpl(ctx);
registerMBean("Service", serviceMXBean.getClass().getSimpleName(), serviceMXBean, ServiceMXBean.class);
// Data storage
DataStorageMXBean dataStorageMXBean = new DataStorageMXBeanImpl(ctx);
registerMBean("DataStorage", dataStorageMXBean.getClass().getSimpleName(), dataStorageMXBean, DataStorageMXBean.class);
// Baseline configuration
BaselineAutoAdjustMXBean baselineAutoAdjustMXBean = new BaselineAutoAdjustMXBeanImpl(ctx);
registerMBean("Baseline", baselineAutoAdjustMXBean.getClass().getSimpleName(), baselineAutoAdjustMXBean, BaselineAutoAdjustMXBean.class);
// Encryption
EncryptionMXBean encryptionMXBean = new EncryptionMXBeanImpl(ctx);
registerMBean("Encryption", encryptionMXBean.getClass().getSimpleName(), encryptionMXBean, EncryptionMXBean.class);
// Snapshot.
SnapshotMXBean snpMXBean = new SnapshotMXBeanImpl(ctx);
registerMBean("Snapshot", snpMXBean.getClass().getSimpleName(), snpMXBean, SnapshotMXBean.class);
// Defragmentation.
DefragmentationMXBean defragMXBean = new DefragmentationMXBeanImpl(ctx);
registerMBean("Defragmentation", defragMXBean.getClass().getSimpleName(), defragMXBean, DefragmentationMXBean.class);
// Metrics configuration
MetricsMxBean metricsMxBean = new MetricsMxBeanImpl(ctx.metric(), log);
registerMBean("Metrics", metricsMxBean.getClass().getSimpleName(), metricsMxBean, MetricsMxBean.class);
ctx.pools().registerMxBeans(this);
if (U.IGNITE_TEST_FEATURES_ENABLED) {
WorkersControlMXBean workerCtrlMXBean = new WorkersControlMXBeanImpl(ctx.workersRegistry());
registerMBean("Kernal", workerCtrlMXBean.getClass().getSimpleName(), workerCtrlMXBean, WorkersControlMXBean.class);
}
FailureHandlingMxBean blockOpCtrlMXBean = new FailureHandlingMxBeanImpl(ctx.workersRegistry(), ctx.cache().context().database());
registerMBean("Kernal", blockOpCtrlMXBean.getClass().getSimpleName(), blockOpCtrlMXBean, FailureHandlingMxBean.class);
if (ctx.query().moduleEnabled())
ctx.query().getIndexing().registerMxBeans(this);
PerformanceStatisticsMBeanImpl performanceStatMbean = new PerformanceStatisticsMBeanImpl(ctx);
registerMBean("PerformanceStatistics", performanceStatMbean.getClass().getSimpleName(), performanceStatMbean, PerformanceStatisticsMBean.class);
}
Aggregations