use of org.apache.ignite.mxbean.SnapshotMXBean in project ignite by apache.
the class IgniteSnapshotMXBeanTest method testCancelSnapshot.
/**
* @throws Exception If fails.
*/
@Test
public void testCancelSnapshot() throws Exception {
IgniteEx srv = startGridsWithCache(1, dfltCacheCfg, CACHE_KEYS_RANGE);
IgniteEx startCli = startClientGrid(1);
IgniteEx killCli = startClientGrid(2);
SnapshotMXBean mxBean = getMxBean(killCli.name(), METRIC_GROUP, SnapshotMXBeanImpl.class, SnapshotMXBean.class);
doSnapshotCancellationTest(startCli, Collections.singletonList(srv), srv.cache(dfltCacheCfg.getName()), mxBean::cancelSnapshot);
}
use of org.apache.ignite.mxbean.SnapshotMXBean 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);
}
use of org.apache.ignite.mxbean.SnapshotMXBean in project ignite by apache.
the class IgniteSnapshotMXBeanTest method testCreateSnapshot.
/**
* @throws Exception If fails.
*/
@Test
public void testCreateSnapshot() throws Exception {
IgniteEx ignite = startGridsWithCache(2, dfltCacheCfg, CACHE_KEYS_RANGE);
DynamicMBean snpMBean = metricRegistry(ignite.name(), null, SNAPSHOT_METRICS);
assertEquals("Snapshot end time must be undefined on first snapshot operation starts.", 0, (long) getMetric("LastSnapshotEndTime", snpMBean));
SnapshotMXBean mxBean = getMxBean(ignite.name(), METRIC_GROUP, SnapshotMXBeanImpl.class, SnapshotMXBean.class);
mxBean.createSnapshot(SNAPSHOT_NAME);
assertTrue("Waiting for snapshot operation failed.", GridTestUtils.waitForCondition(() -> (long) getMetric("LastSnapshotEndTime", snpMBean) > 0, TIMEOUT));
stopAllGrids();
IgniteEx snp = startGridsFromSnapshot(2, SNAPSHOT_NAME);
assertSnapshotCacheKeys(snp.cache(dfltCacheCfg.getName()));
}
use of org.apache.ignite.mxbean.SnapshotMXBean in project ignite by apache.
the class IgniteSnapshotMXBeanTest method testCancelRestoreSnapshot.
/**
* @throws Exception If fails.
*/
@Test
public void testCancelRestoreSnapshot() throws Exception {
// TODO IGNITE-14999 Support dynamic restoration of encrypted snapshots.
if (encryption)
return;
IgniteEx ignite = startGridsWithSnapshot(2, CACHE_KEYS_RANGE, false);
SnapshotMXBean mxBean = getMxBean(ignite.name(), METRIC_GROUP, SnapshotMXBeanImpl.class, SnapshotMXBean.class);
DynamicMBean mReg0 = metricRegistry(grid(0).name(), null, SNAPSHOT_RESTORE_METRICS);
DynamicMBean mReg1 = metricRegistry(grid(1).name(), null, SNAPSHOT_RESTORE_METRICS);
assertEquals("", getMetric("error", mReg0));
assertEquals("", getMetric("error", mReg1));
assertEquals(0, (long) getMetric("endTime", mReg0));
assertEquals(0, (long) getMetric("endTime", mReg1));
TestRecordingCommunicationSpi spi = TestRecordingCommunicationSpi.spi(grid(1));
spi.blockMessages((node, msg) -> msg instanceof SingleNodeMessage && ((SingleNodeMessage<?>) msg).type() == RESTORE_CACHE_GROUP_SNAPSHOT_PREPARE.ordinal());
IgniteFuture<Void> fut = ignite.snapshot().restoreSnapshot(SNAPSHOT_NAME, null);
spi.waitForBlocked();
IgniteInternalFuture<Boolean> interruptFut = GridTestUtils.runAsync(() -> {
try {
return GridTestUtils.waitForCondition(() -> !"".equals(getMetric("error", mReg0)) && !"".equals(getMetric("error", mReg1)), TIMEOUT);
} finally {
spi.stopBlock();
}
});
mxBean.cancelSnapshotRestore(SNAPSHOT_NAME);
assertTrue(interruptFut.get());
String expErrMsg = "Operation has been canceled by the user.";
assertThrowsAnyCause(log, () -> fut.get(TIMEOUT), IgniteCheckedException.class, expErrMsg);
assertTrue((long) getMetric("endTime", mReg0) > 0);
assertTrue((long) getMetric("endTime", mReg1) > 0);
assertTrue(((String) getMetric("error", mReg0)).contains(expErrMsg));
assertTrue(((String) getMetric("error", mReg1)).contains(expErrMsg));
assertNull(ignite.cache(DEFAULT_CACHE_NAME));
}
Aggregations