Search in sources :

Example 1 with GlusterTaskParameters

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

the class GlusterTasksListReturn method getTask.

@SuppressWarnings("unchecked")
private GlusterAsyncTask getTask(String taskId, Map<String, Object> map) {
    GlusterAsyncTask task = new GlusterAsyncTask();
    task.setTaskId(Guid.createGuidFromString(taskId));
    task.setStatus(GlusterAsyncTaskStatus.from((String) map.get(STATUS)).getJobExecutionStatus());
    task.setType(GlusterTaskType.fromValue((String) map.get(TASK_TYPE)));
    if (GlusterTaskType.UNKNOWN != task.getType()) {
        task.setMessage(getMessage((Map<String, Object>) map.get(DATA)));
        task.setTaskParameters(new GlusterTaskParameters());
        task.getTaskParameters().setVolumeName((String) map.get(VOLUME_NAME));
        task.getTaskParameters().setBricks(getBrickNames(map.get(BRICK_NAMES)));
    }
    return task;
}
Also used : GlusterTaskParameters(org.ovirt.engine.core.common.asynctasks.gluster.GlusterTaskParameters) GlusterAsyncTask(org.ovirt.engine.core.common.asynctasks.gluster.GlusterAsyncTask) Map(java.util.Map)

Example 2 with GlusterTaskParameters

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

the class GetGlusterVolumeRemoveBricksStatusQueryTest method getAsyncTask.

private GlusterAsyncTask getAsyncTask() {
    GlusterAsyncTask asyncTask = new GlusterAsyncTask();
    asyncTask.setStepId(STEP_ID);
    asyncTask.setType(GlusterTaskType.REBALANCE);
    asyncTask.setStatus(JobExecutionStatus.FINISHED);
    asyncTask.setMessage("test_msg");
    asyncTask.setTaskId(Guid.newGuid());
    GlusterTaskParameters params = new GlusterTaskParameters();
    params.setVolumeName("volume1");
    asyncTask.setTaskParameters(params);
    return asyncTask;
}
Also used : GlusterTaskParameters(org.ovirt.engine.core.common.asynctasks.gluster.GlusterTaskParameters) GlusterAsyncTask(org.ovirt.engine.core.common.asynctasks.gluster.GlusterAsyncTask)

Example 3 with GlusterTaskParameters

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

the class GlusterTasksSyncJobTest method createTask.

private GlusterAsyncTask createTask(Guid guid, JobExecutionStatus status) {
    GlusterAsyncTask task = new GlusterAsyncTask();
    task.setTaskId(guid);
    task.setTaskParameters(new GlusterTaskParameters());
    task.getTaskParameters().setVolumeName("VOL");
    task.setMessage("message");
    task.setStatus(status);
    task.setType(GlusterTaskType.REBALANCE);
    return task;
}
Also used : GlusterTaskParameters(org.ovirt.engine.core.common.asynctasks.gluster.GlusterTaskParameters) GlusterAsyncTask(org.ovirt.engine.core.common.asynctasks.gluster.GlusterAsyncTask)

Example 4 with GlusterTaskParameters

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

the class GlusterTaskUtils method getMessageMap.

public Map<String, String> getMessageMap(Cluster cluster, GlusterAsyncTask task) {
    Map<String, String> values = new HashMap<>();
    values.put(GlusterConstants.CLUSTER, cluster.getName());
    GlusterTaskParameters params = task.getTaskParameters();
    values.put(GlusterConstants.VOLUME, params != null ? params.getVolumeName() : "");
    String jobStatus = getJobStatusInfo(task);
    values.put(GlusterConstants.JOB_STATUS, jobStatus);
    values.put(GlusterConstants.JOB_INFO, task.getMessage());
    return values;
}
Also used : GlusterTaskParameters(org.ovirt.engine.core.common.asynctasks.gluster.GlusterTaskParameters) HashMap(java.util.HashMap)

Example 5 with GlusterTaskParameters

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

the class GlusterAsyncTaskStatusQueryBase method updateLatestStatus.

private void updateLatestStatus(GlusterVolumeTaskStatusEntity status) {
    GlusterAsyncTask asyncTask = volume.getAsyncTask();
    if (asyncTask != null && asyncTask.getTaskId() != null) {
        GlusterTaskParameters taskParameters = new GlusterTaskParameters();
        taskParameters.setVolumeName(volume.getName());
        asyncTask.setTaskParameters(taskParameters);
        List<Step> stepsList = stepDao.getStepsByExternalId(asyncTask.getTaskId());
        // if step has already ended, do not update status.
        if (stepsList != null && !stepsList.isEmpty() && stepsList.get(0).getEndTime() != null) {
            asyncTask.setStatus(status.getStatusSummary().getStatus());
            asyncTask.setMessage(glusterTaskUtils.getSummaryMessage(status.getStatusSummary()));
            glusterTaskUtils.updateSteps(clusterDao.get(clusterId), asyncTask, stepsList);
            // release the volume lock if the task is completed
            if (glusterTaskUtils.hasTaskCompleted(asyncTask)) {
                glusterTaskUtils.releaseLock(volume.getId());
            }
        }
    }
}
Also used : GlusterTaskParameters(org.ovirt.engine.core.common.asynctasks.gluster.GlusterTaskParameters) GlusterAsyncTask(org.ovirt.engine.core.common.asynctasks.gluster.GlusterAsyncTask) Step(org.ovirt.engine.core.common.job.Step)

Aggregations

GlusterTaskParameters (org.ovirt.engine.core.common.asynctasks.gluster.GlusterTaskParameters)5 GlusterAsyncTask (org.ovirt.engine.core.common.asynctasks.gluster.GlusterAsyncTask)4 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Step (org.ovirt.engine.core.common.job.Step)1