Search in sources :

Example 6 with MaintenanceTask

use of org.apache.ignite.maintenance.MaintenanceTask in project ignite by apache.

the class MaintenanceFileStore method readTasksFromFile.

/**
 */
private void readTasksFromFile() throws IOException {
    int len = (int) mntcTasksFileIO.size();
    if (len == 0)
        return;
    byte[] allBytes = new byte[len];
    mntcTasksFileIO.read(allBytes, 0, len);
    String[] allTasks = new String(allBytes).split(TASKS_SEPARATOR);
    for (String taskStr : allTasks) {
        String[] subStrs = taskStr.split(TASK_PARTS_SEPARATOR);
        int partsNum = subStrs.length;
        if (partsNum < MAX_MNTC_TASK_PARTS_COUNT - 1) {
            log.info("Corrupted maintenance task found and will be skipped, " + "mandatory parts are missing: " + taskStr);
            continue;
        }
        if (partsNum > MAX_MNTC_TASK_PARTS_COUNT) {
            log.info("Corrupted maintenance task found and will be skipped, " + "too many parts in task: " + taskStr);
            continue;
        }
        String name = subStrs[0];
        MaintenanceTask task = new MaintenanceTask(name, subStrs[1], partsNum == 3 ? subStrs[2] : null);
        tasksInSync.put(name, task);
    }
}
Also used : MaintenanceTask(org.apache.ignite.maintenance.MaintenanceTask)

Example 7 with MaintenanceTask

use of org.apache.ignite.maintenance.MaintenanceTask in project ignite by apache.

the class GridCacheDatabaseSharedManager method startMemoryRestore.

/**
 * {@inheritDoc}
 */
@Override
public void startMemoryRestore(GridKernalContext kctx, TimeBag startTimer) throws IgniteCheckedException {
    if (kctx.clientNode())
        return;
    MaintenanceRegistry mntcRegistry = kctx.maintenanceRegistry();
    MaintenanceTask mntcTask = mntcRegistry.activeMaintenanceTask(CORRUPTED_DATA_FILES_MNTC_TASK_NAME);
    if (mntcTask != null) {
        log.warning("Maintenance task found, stop restoring memory");
        File workDir = ((FilePageStoreManager) cctx.pageStore()).workDir();
        mntcRegistry.registerWorkflowCallback(CORRUPTED_DATA_FILES_MNTC_TASK_NAME, new CorruptedPdsMaintenanceCallback(workDir, Arrays.asList(mntcTask.parameters().split(Pattern.quote(File.separator)))));
        return;
    }
    checkpointReadLock();
    RestoreLogicalState logicalState;
    try {
        // Preform early regions startup before restoring state.
        initAndStartRegions(kctx.config().getDataStorageConfiguration());
        startTimer.finishGlobalStage("Init and start regions");
        // Restore binary memory for all not WAL disabled cache groups.
        restoreBinaryMemory(groupsWithEnabledWal(), physicalRecords());
        if (recoveryVerboseLogging && log.isInfoEnabled()) {
            log.info("Partition states information after BINARY RECOVERY phase:");
            dumpPartitionsInfo(cctx, log);
        }
        startTimer.finishGlobalStage("Restore binary memory");
        CheckpointStatus status = readCheckpointStatus();
        logicalState = applyLogicalUpdates(status, groupsWithEnabledWal(), logicalRecords(), false);
        cctx.tm().clearUncommitedStates();
        cctx.wal().startAutoReleaseSegments();
        if (recoveryVerboseLogging && log.isInfoEnabled()) {
            log.info("Partition states information after LOGICAL RECOVERY phase:");
            dumpPartitionsInfo(cctx, log);
        }
        startTimer.finishGlobalStage("Restore logical state");
    } catch (IgniteCheckedException e) {
        releaseFileLock();
        throw e;
    } finally {
        checkpointReadUnlock();
    }
    walTail = tailPointer(logicalState);
    cctx.wal().onDeActivate(kctx);
}
Also used : CheckpointStatus(org.apache.ignite.internal.processors.cache.persistence.checkpoint.CheckpointStatus) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) MaintenanceRegistry(org.apache.ignite.maintenance.MaintenanceRegistry) MaintenanceTask(org.apache.ignite.maintenance.MaintenanceTask) FilePageStoreManager(org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager) File(java.io.File)

Example 8 with MaintenanceTask

use of org.apache.ignite.maintenance.MaintenanceTask in project ignite by apache.

the class IgniteDefragmentationImpl method schedule.

/**
 * {@inheritDoc}
 */
@Override
public ScheduleResult schedule(List<String> cacheNames) throws IgniteCheckedException {
    final MaintenanceRegistry maintenanceRegistry = ctx.maintenanceRegistry();
    MaintenanceTask oldTask;
    try {
        oldTask = maintenanceRegistry.registerMaintenanceTask(toStore(cacheNames != null ? cacheNames : Collections.emptyList()));
    } catch (IgniteCheckedException e) {
        throw new IgniteCheckedException("Scheduling failed: " + e.getMessage());
    }
    return oldTask != null ? ScheduleResult.SUCCESS_SUPERSEDED_PREVIOUS : ScheduleResult.SUCCESS;
}
Also used : IgniteCheckedException(org.apache.ignite.IgniteCheckedException) MaintenanceRegistry(org.apache.ignite.maintenance.MaintenanceRegistry) MaintenanceTask(org.apache.ignite.maintenance.MaintenanceTask)

Example 9 with MaintenanceTask

use of org.apache.ignite.maintenance.MaintenanceTask in project ignite by apache.

the class MaintenanceRegistrySimpleTest method testDeleteMaintenanceTask.

/**
 * Registered {@link MaintenanceTask} can be deleted before node entered Maintenance Mode (before node restart).
 *
 * @throws IgniteCheckedException If initialization failed.
 */
@Test
public void testDeleteMaintenanceTask() throws IgniteCheckedException {
    String name = "name0";
    MaintenanceTask task = new MaintenanceTask(name, "description", null);
    MaintenanceProcessor proc = new MaintenanceProcessor(initContext(true));
    proc.start();
    proc.registerMaintenanceTask(task);
    assertFalse(proc.isMaintenanceMode());
    proc.unregisterMaintenanceTask(name);
    proc.stop(false);
    proc.start();
    assertNull(proc.activeMaintenanceTask(name));
    assertFalse(proc.isMaintenanceMode());
}
Also used : MaintenanceProcessor(org.apache.ignite.internal.maintenance.MaintenanceProcessor) MaintenanceTask(org.apache.ignite.maintenance.MaintenanceTask) Test(org.junit.Test)

Example 10 with MaintenanceTask

use of org.apache.ignite.maintenance.MaintenanceTask in project ignite by apache.

the class MaintenanceRegistrySimpleTest method testMaintenanceTaskReplacement.

/**
 * {@link MaintenanceTask} could be replaced with new parameters after registration, old task is deleted.
 *
 * @throws IgniteCheckedException If initialization failed.
 */
@Test
public void testMaintenanceTaskReplacement() throws IgniteCheckedException {
    String name0 = "taskName0";
    String descr = "description";
    String oldParams = "oldParams";
    String newParams = "newParams";
    MaintenanceProcessor proc = new MaintenanceProcessor(initContext(true));
    proc.start();
    assertFalse(proc.isMaintenanceMode());
    proc.registerMaintenanceTask(new MaintenanceTask(name0, descr, oldParams));
    proc.registerMaintenanceTask(new MaintenanceTask(name0, descr, newParams));
    proc.stop(false);
    proc.start();
    assertTrue(proc.isMaintenanceMode());
    MaintenanceTask task = proc.activeMaintenanceTask(name0);
    assertNotNull(task);
    assertEquals(newParams, task.parameters());
}
Also used : MaintenanceProcessor(org.apache.ignite.internal.maintenance.MaintenanceProcessor) 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