Search in sources :

Example 1 with MaintenanceTask

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());
}
Also used : MaintenanceProcessor(org.apache.ignite.internal.maintenance.MaintenanceProcessor) MaintenanceTask(org.apache.ignite.maintenance.MaintenanceTask) Test(org.junit.Test)

Example 2 with MaintenanceTask

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());
}
Also used : MaintenanceProcessor(org.apache.ignite.internal.maintenance.MaintenanceProcessor) MaintenanceTask(org.apache.ignite.maintenance.MaintenanceTask) Test(org.junit.Test)

Example 3 with MaintenanceTask

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(""));
}
Also used : DefragmentationMXBean(org.apache.ignite.mxbean.DefragmentationMXBean) Ignite(org.apache.ignite.Ignite) MaintenanceTask(org.apache.ignite.maintenance.MaintenanceTask) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 4 with MaintenanceTask

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();
    }
}
Also used : IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteException(org.apache.ignite.IgniteException) PageStore(org.apache.ignite.internal.pagemem.store.PageStore) MaintenanceTask(org.apache.ignite.maintenance.MaintenanceTask)

Example 5 with MaintenanceTask

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());
}
Also used : LogListener(org.apache.ignite.testframework.LogListener) Ignite(org.apache.ignite.Ignite) ListeningTestLogger(org.apache.ignite.testframework.ListeningTestLogger) CommandHandler(org.apache.ignite.internal.commandline.CommandHandler) MaintenanceTask(org.apache.ignite.maintenance.MaintenanceTask) Test(org.junit.Test)

Aggregations

MaintenanceTask (org.apache.ignite.maintenance.MaintenanceTask)10 Test (org.junit.Test)6 MaintenanceProcessor (org.apache.ignite.internal.maintenance.MaintenanceProcessor)4 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)3 Ignite (org.apache.ignite.Ignite)2 MaintenanceRegistry (org.apache.ignite.maintenance.MaintenanceRegistry)2 File (java.io.File)1 IgniteException (org.apache.ignite.IgniteException)1 CommandHandler (org.apache.ignite.internal.commandline.CommandHandler)1 PageStore (org.apache.ignite.internal.pagemem.store.PageStore)1 CheckpointStatus (org.apache.ignite.internal.processors.cache.persistence.checkpoint.CheckpointStatus)1 FilePageStoreManager (org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager)1 DefragmentationMXBean (org.apache.ignite.mxbean.DefragmentationMXBean)1 ListeningTestLogger (org.apache.ignite.testframework.ListeningTestLogger)1 LogListener (org.apache.ignite.testframework.LogListener)1 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)1