Search in sources :

Example 6 with GlusterAsyncTask

use of org.ovirt.engine.core.common.asynctasks.gluster.GlusterAsyncTask in project ovirt-engine by oVirt.

the class GlusterBrickValidator method canStopOrCommitRemoveBrick.

public ValidationResult canStopOrCommitRemoveBrick(GlusterVolumeEntity volumeEntity, List<GlusterBrickEntity> paramBricks) {
    GlusterAsyncTask asyncTask = volumeEntity.getAsyncTask();
    if (asyncTask == null || asyncTask.getType() != GlusterTaskType.REMOVE_BRICK) {
        return new ValidationResult(EngineMessage.ACTION_TYPE_FAILED_GLUSTER_VOLUME_INVALID_TASK_TYPE);
    }
    if (paramBricks.isEmpty()) {
        return new ValidationResult(EngineMessage.ACTION_TYPE_FAILED_BRICKS_REQUIRED);
    }
    List<GlusterBrickEntity> bricksForTask = getGlusterBrickDao().getGlusterVolumeBricksByTaskId(asyncTask.getTaskId());
    if (paramBricks.size() != bricksForTask.size() || !areBricksInTheList(volumeEntity, paramBricks, bricksForTask)) {
        return new ValidationResult(EngineMessage.ACTION_TYPE_FAILED_GLUSTER_VOLUME_REMOVE_BRICKS_PARAMS_INVALID, String.format("$validBricks [%s]", getValidBrickNames(bricksForTask)));
    }
    return ValidationResult.VALID;
}
Also used : GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) GlusterAsyncTask(org.ovirt.engine.core.common.asynctasks.gluster.GlusterAsyncTask) ValidationResult(org.ovirt.engine.core.bll.ValidationResult)

Example 7 with GlusterAsyncTask

use of org.ovirt.engine.core.common.asynctasks.gluster.GlusterAsyncTask in project ovirt-engine by oVirt.

the class GlusterTasksSyncJob method updateGlusterAsyncTasks.

@OnTimerMethodAnnotation("gluster_async_task_poll_event")
public void updateGlusterAsyncTasks() {
    log.debug("Refreshing gluster tasks list");
    List<Cluster> clusters = clusterDao.getAll();
    Map<Guid, Set<Guid>> tasksFromClustersMap = new HashMap<>();
    for (Cluster cluster : clusters) {
        if (!cluster.supportsGlusterService()) {
            continue;
        }
        try {
            Map<Guid, GlusterAsyncTask> runningTasks = provider.getTaskListForCluster(cluster.getId());
            if (runningTasks != null) {
                updateTasksInCluster(cluster, runningTasks);
                tasksFromClustersMap.put(cluster.getId(), runningTasks.keySet());
            }
        } catch (EngineException e) {
            log.error("Error updating tasks from CLI", e);
        }
    }
    cleanUpOrphanTasks(tasksFromClustersMap);
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) GlusterAsyncTask(org.ovirt.engine.core.common.asynctasks.gluster.GlusterAsyncTask) EngineException(org.ovirt.engine.core.common.errors.EngineException) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) Guid(org.ovirt.engine.core.compat.Guid) OnTimerMethodAnnotation(org.ovirt.engine.core.utils.timer.OnTimerMethodAnnotation)

Example 8 with GlusterAsyncTask

use of org.ovirt.engine.core.common.asynctasks.gluster.GlusterAsyncTask in project ovirt-engine by oVirt.

the class GlusterTasksSyncJob method updateTasksInCluster.

private void updateTasksInCluster(final Cluster cluster, final Map<Guid, GlusterAsyncTask> runningTasks) {
    for (Entry<Guid, GlusterAsyncTask> entry : runningTasks.entrySet()) {
        Guid taskId = entry.getKey();
        final GlusterAsyncTask task = entry.getValue();
        List<Step> steps = stepDao.getStepsByExternalId(taskId);
        if (steps.isEmpty()) {
            createJobForTaskFromCLI(cluster, task);
        }
        glusterTaskUtils.updateSteps(cluster, task, steps);
    }
}
Also used : GlusterAsyncTask(org.ovirt.engine.core.common.asynctasks.gluster.GlusterAsyncTask) Guid(org.ovirt.engine.core.compat.Guid) Step(org.ovirt.engine.core.common.job.Step)

Example 9 with GlusterAsyncTask

use of org.ovirt.engine.core.common.asynctasks.gluster.GlusterAsyncTask in project ovirt-engine by oVirt.

the class GlusterTasksService method getTaskListForCluster.

public Map<Guid, GlusterAsyncTask> getTaskListForCluster(Guid id) {
    VDS upServer = glusterUtil.getRandomUpServer(id);
    if (upServer == null) {
        log.info("No up server in cluster");
        return null;
    }
    VDSReturnValue returnValue = runVdsCommand(VDSCommandType.GlusterTasksList, new VdsIdVDSCommandParametersBase(upServer.getId()));
    if (returnValue.getSucceeded()) {
        List<GlusterAsyncTask> tasks = (List<GlusterAsyncTask>) returnValue.getReturnValue();
        Map<Guid, GlusterAsyncTask> tasksMap = new HashMap<>();
        for (GlusterAsyncTask task : tasks) {
            tasksMap.put(task.getTaskId(), task);
        }
        return tasksMap;
    } else {
        log.error("Error: {}", returnValue.getVdsError());
        throw new EngineException(EngineError.GlusterVolumeStatusAllFailedException, returnValue.getVdsError().getMessage());
    }
}
Also used : VdsIdVDSCommandParametersBase(org.ovirt.engine.core.common.vdscommands.VdsIdVDSCommandParametersBase) VDS(org.ovirt.engine.core.common.businessentities.VDS) HashMap(java.util.HashMap) GlusterAsyncTask(org.ovirt.engine.core.common.asynctasks.gluster.GlusterAsyncTask) EngineException(org.ovirt.engine.core.common.errors.EngineException) List(java.util.List) Guid(org.ovirt.engine.core.compat.Guid) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Example 10 with GlusterAsyncTask

use of org.ovirt.engine.core.common.asynctasks.gluster.GlusterAsyncTask in project ovirt-engine by oVirt.

the class StartRebalanceGlusterVolumeCommand method executeCommand.

@Override
protected void executeCommand() {
    startSubStep();
    VDSReturnValue taskReturn = runVdsCommand(VDSCommandType.StartRebalanceGlusterVolume, new GlusterVolumeRebalanceVDSParameters(upServer.getId(), getGlusterVolumeName(), getParameters().isFixLayoutOnly(), getParameters().isForceAction()));
    setSucceeded(taskReturn.getSucceeded());
    if (!getSucceeded()) {
        handleVdsError(AuditLogType.GLUSTER_VOLUME_REBALANCE_START_FAILED, taskReturn.getVdsError().getMessage());
        return;
    }
    GlusterAsyncTask glusterTask = (GlusterAsyncTask) taskReturn.getReturnValue();
    handleTaskReturn(glusterTask);
    updateVolumeWithTaskID(glusterTask);
    getReturnValue().setActionReturnValue(glusterTask);
}
Also used : GlusterAsyncTask(org.ovirt.engine.core.common.asynctasks.gluster.GlusterAsyncTask) GlusterVolumeRebalanceVDSParameters(org.ovirt.engine.core.common.vdscommands.gluster.GlusterVolumeRebalanceVDSParameters) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Aggregations

GlusterAsyncTask (org.ovirt.engine.core.common.asynctasks.gluster.GlusterAsyncTask)30 GlusterBrickEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity)11 GlusterVolumeEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity)10 ArrayList (java.util.ArrayList)7 Test (org.junit.Test)5 GlusterTaskParameters (org.ovirt.engine.core.common.asynctasks.gluster.GlusterTaskParameters)4 Step (org.ovirt.engine.core.common.job.Step)4 VDSReturnValue (org.ovirt.engine.core.common.vdscommands.VDSReturnValue)4 Guid (org.ovirt.engine.core.compat.Guid)4 EngineException (org.ovirt.engine.core.common.errors.EngineException)3 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)3 ConfirmationModel (org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)3 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 List (java.util.List)2 JobExecutionStatus (org.ovirt.engine.core.common.job.JobExecutionStatus)2 GlusterVolumeRemoveBricksVDSParameters (org.ovirt.engine.core.common.vdscommands.gluster.GlusterVolumeRemoveBricksVDSParameters)2 Collection (java.util.Collection)1 Date (java.util.Date)1 Map (java.util.Map)1