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);
}
}
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);
}
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;
}
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());
}
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());
}
Aggregations