use of org.apache.ignite.maintenance.MaintenanceTask in project ignite by apache.
the class MaintenanceRegistrySimpleTest method testMaintenanceTasksWithoutParameters.
/**
* @throws IgniteCheckedException If initialization of Maintenance Processor failed.
*/
@Test
public void testMaintenanceTasksWithoutParameters() throws IgniteCheckedException {
MaintenanceProcessor proc = new MaintenanceProcessor(initContext(true));
String task0Name = "name0";
String task1Name = "name1";
String desc0 = "task0";
String desc1 = "task1";
String params0 = "task0_param";
// call to initialize file for maintenance tasks
proc.start();
proc.registerMaintenanceTask(new MaintenanceTask(task0Name, desc0, params0));
proc.registerMaintenanceTask(new MaintenanceTask(task1Name, desc1, null));
proc.stop(false);
// call to force Maintenance Processor to read that file and fill internal collection of maintenance tasks
proc.start();
MaintenanceTask task0 = proc.activeMaintenanceTask(task0Name);
MaintenanceTask task1 = proc.activeMaintenanceTask(task1Name);
assertNotNull(task0);
assertNotNull(task1);
assertEquals(params0, task0.parameters());
assertNull(task1.parameters());
}
use of org.apache.ignite.maintenance.MaintenanceTask in project ignite by apache.
the class MaintenanceRegistrySimpleTest method testMultipleMaintenanceTasks.
/**
* Smoke test for writing and restoring back maintenance tasks to/from file.
*
* @throws IgniteCheckedException If initialization of Maintenance Processor failed.
*/
@Test
public void testMultipleMaintenanceTasks() throws IgniteCheckedException {
MaintenanceProcessor proc = new MaintenanceProcessor(initContext(true));
String task0Name = "name0";
String task1Name = "name1";
String desc0 = "task0";
String desc1 = "task1";
String params0 = "task0_param";
String params1 = "task1_param";
proc.start();
proc.registerMaintenanceTask(new MaintenanceTask(task0Name, desc0, params0));
proc.registerMaintenanceTask(new MaintenanceTask(task1Name, desc1, params1));
proc.stop(false);
proc.start();
MaintenanceTask task0 = proc.activeMaintenanceTask(task0Name);
MaintenanceTask task1 = proc.activeMaintenanceTask(task1Name);
assertNotNull(task0);
assertNotNull(task1);
assertEquals(desc0, task0.description());
assertEquals(desc1, task1.description());
assertEquals(params0, task0.parameters());
assertEquals(params1, task1.parameters());
}
use of org.apache.ignite.maintenance.MaintenanceTask in project ignite by apache.
the class DefragmentationMXBeanTest method testDefragmentationSchedule.
/**
* Test that defragmentation won't be scheduled second time, if previously scheduled via maintenance registry.
* Description:
* 1. Start two nodes.
* 2. Register defragmentation maintenance task on the first node.
* 3. Restart node.
* 3. Scheduling of the defragmentation on the first node via JMX bean should fail.
* @throws Exception If failed.
*/
@Test
public void testDefragmentationSchedule() throws Exception {
Ignite ignite = startGrids(2);
ignite.cluster().state(ACTIVE);
DefragmentationMXBean mxBean = defragmentationMXBean(ignite.name());
assertTrue(mxBean.schedule(""));
MaintenanceTask mntcTask = DefragmentationParameters.toStore(Collections.emptyList());
assertNotNull(grid(0).context().maintenanceRegistry().registerMaintenanceTask(mntcTask));
assertNull(grid(1).context().maintenanceRegistry().registerMaintenanceTask(mntcTask));
stopGrid(0);
startGrid(0);
// node is already in defragmentation mode, hence scheduling is not possible
assertFalse(mxBean.schedule(""));
}
use of org.apache.ignite.maintenance.MaintenanceTask in project ignite by apache.
the class FilePageStoreManager method beginRecover.
/**
* {@inheritDoc}
*/
@Override
public void beginRecover() {
List<String> groupsWithWalDisabled = checkCachesWithDisabledWal();
if (!groupsWithWalDisabled.isEmpty()) {
String errorMsg = "Cache groups with potentially corrupted partition files found. " + "To cleanup them maintenance is needed, node will enter maintenance mode on next restart. " + "Cleanup cache group folders manually or trigger maintenance action to do that and restart the node. " + "Corrupted files are located in subdirectories " + groupsWithWalDisabled + " in a work dir " + storeWorkDir;
log.warning(errorMsg);
try {
cctx.kernalContext().maintenanceRegistry().registerMaintenanceTask(new MaintenanceTask(CORRUPTED_DATA_FILES_MNTC_TASK_NAME, "Corrupted cache groups found", groupsWithWalDisabled.stream().collect(Collectors.joining(File.separator))));
} catch (IgniteCheckedException e) {
log.warning("Failed to register maintenance record for corrupted partition files.", e);
}
throw new IgniteException(errorMsg);
}
for (CacheStoreHolder holder : idxCacheStores.values()) {
holder.idxStore.beginRecover();
for (PageStore partStore : holder.partStores) partStore.beginRecover();
}
}
use of org.apache.ignite.maintenance.MaintenanceTask in project ignite by apache.
the class GridCommandHandlerDefragmentationTest method testDefragmentationSchedule.
/**
* @throws Exception If failed.
*/
@Test
public void testDefragmentationSchedule() throws Exception {
Ignite ignite = startGrids(2);
ignite.cluster().state(ACTIVE);
assertEquals(EXIT_CODE_INVALID_ARGUMENTS, execute("--defragmentation", "schedule"));
String grid0ConsId = grid(0).configuration().getConsistentId().toString();
String grid1ConsId = grid(1).configuration().getConsistentId().toString();
ListeningTestLogger testLog = new ListeningTestLogger();
CommandHandler cmd = createCommandHandler(testLog);
LogListener logLsnr = LogListener.matches("Scheduling completed successfully.").build();
testLog.registerListener(logLsnr);
assertEquals(EXIT_CODE_OK, execute(cmd, "--defragmentation", "schedule", "--nodes", grid0ConsId));
assertTrue(logLsnr.check());
MaintenanceTask mntcTask = DefragmentationParameters.toStore(Collections.emptyList());
assertNotNull(grid(0).context().maintenanceRegistry().registerMaintenanceTask(mntcTask));
assertNull(grid(1).context().maintenanceRegistry().registerMaintenanceTask(mntcTask));
stopGrid(0);
startGrid(0);
logLsnr = LogListener.matches("Node is already in Maintenance Mode").build();
testLog.clearListeners();
testLog.registerListener(logLsnr);
assertEquals(EXIT_CODE_OK, execute(cmd, "--defragmentation", "schedule", "--nodes", grid0ConsId));
assertTrue(logLsnr.check());
stopGrid(0);
startGrid(0);
stopGrid(1);
startGrid(1);
stopAllGrids();
startGrids(2);
logLsnr = LogListener.matches("Scheduling completed successfully.").times(2).build();
testLog.clearListeners();
testLog.registerListener(logLsnr);
assertEquals(EXIT_CODE_OK, execute(cmd, "--defragmentation", "schedule", "--nodes", String.join(",", grid0ConsId, grid1ConsId)));
assertTrue(logLsnr.check());
}
Aggregations