use of org.apache.ignite.internal.processors.cache.persistence.defragmentation.CachePartitionDefragmentationManager.DEFRAGMENTATION_MNTC_TASK_NAME in project ignite by apache.
the class IgniteDefragmentationImpl method cancel.
/**
* {@inheritDoc}
*/
@Override
public CancelResult cancel() throws IgniteCheckedException {
final MaintenanceRegistry maintenanceRegistry = ctx.maintenanceRegistry();
if (!maintenanceRegistry.isMaintenanceMode()) {
boolean deleted = maintenanceRegistry.unregisterMaintenanceTask(DEFRAGMENTATION_MNTC_TASK_NAME);
return deleted ? CancelResult.CANCELLED_SCHEDULED : CancelResult.SCHEDULED_NOT_FOUND;
} else {
List<MaintenanceAction<?>> actions;
try {
actions = maintenanceRegistry.actionsForMaintenanceTask(DEFRAGMENTATION_MNTC_TASK_NAME);
} catch (IgniteException e) {
return CancelResult.COMPLETED_OR_CANCELLED;
}
Optional<MaintenanceAction<?>> stopAct = actions.stream().filter(a -> "stop".equals(a.name())).findAny();
assert stopAct.isPresent();
try {
Object res = stopAct.get().execute();
assert res instanceof Boolean;
boolean cancelled = (Boolean) res;
return cancelled ? CancelResult.CANCELLED : CancelResult.COMPLETED_OR_CANCELLED;
} catch (Exception e) {
throw new IgniteCheckedException("Exception occurred: " + e.getMessage(), e);
}
}
}
Aggregations