use of org.ovirt.engine.core.common.asynctasks.gluster.GlusterAsyncTask in project ovirt-engine by oVirt.
the class GlusterAsyncCommandBase method endStepJob.
protected void endStepJob(JobExecutionStatus status, Map<String, String> stepMessageMap, boolean exitStatus) {
GlusterAsyncTask asyncTask = getGlusterVolume().getAsyncTask();
// Gluster Task will be associated with only one step ( REBALANCING_VOLUME or REMOVING_BRICK)
Step step = stepDao.getStepsByExternalId(asyncTask.getTaskId()).get(0);
step.setStatus(status);
step.setEndTime(new Date());
step.setDescription(ExecutionMessageDirector.resolveStepMessage(getStepType(), stepMessageMap));
jobRepository.updateStep(step);
ExecutionContext finalContext = executionHandler.createFinalizingContext(step.getId());
executionHandler.endTaskStepAndJob(finalContext, exitStatus);
}
use of org.ovirt.engine.core.common.asynctasks.gluster.GlusterAsyncTask 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;
}
use of org.ovirt.engine.core.common.asynctasks.gluster.GlusterAsyncTask in project ovirt-engine by oVirt.
the class VolumeBrickListModel method stopRemoveBricks.
private void stopRemoveBricks() {
if (getConfirmWindow() != null) {
return;
}
ConfirmationModel model = new ConfirmationModel();
setConfirmWindow(model);
model.setTitle(ConstantsManager.getInstance().getConstants().stopRemoveBricksTitle());
model.setMessage(ConstantsManager.getInstance().getConstants().stopRemoveBricksMessage());
model.setHelpTag(HelpTag.volume_remove_bricks_stop);
// $NON-NLS-1$
model.setHashName("volume_remove_bricks_stop");
GlusterVolumeEntity volumeEntity = getVolumeEntity();
GlusterAsyncTask volumeTask = volumeEntity.getAsyncTask();
ArrayList<String> list = new ArrayList<>();
for (GlusterBrickEntity brick : volumeEntity.getBricks()) {
if (brick.getAsyncTask() != null && volumeTask != null && brick.getAsyncTask().getTaskId() != null && brick.getAsyncTask().getTaskId().equals(volumeTask.getTaskId()) && volumeTask.getStatus() == JobExecutionStatus.STARTED) {
list.add(brick.getQualifiedName());
}
}
model.setItems(list);
// $NON-NLS-1$
UICommand okCommand = UICommand.createDefaultOkUiCommand("OnStopRemoveBricks", this);
model.getCommands().add(okCommand);
// $NON-NLS-1$
UICommand cancelCommand = new UICommand("CancelConfirmation", this);
cancelCommand.setTitle(ConstantsManager.getInstance().getConstants().close());
cancelCommand.setIsCancel(true);
model.getCommands().add(cancelCommand);
}
use of org.ovirt.engine.core.common.asynctasks.gluster.GlusterAsyncTask in project ovirt-engine by oVirt.
the class VolumeBrickListModel method updateActionAvailability.
private void updateActionAvailability() {
GlusterVolumeEntity volumeEntity = getEntity();
boolean allowRemove = true;
boolean allowReplace = true;
boolean allowAdvanced = true;
boolean allowAdd = true;
boolean allowReset = true;
if (volumeEntity == null || volumeEntity.getVolumeType().isDispersedType() || !volumeEntity.getVolumeType().isSupported()) {
allowRemove = false;
allowAdd = false;
}
if (volumeEntity == null || getSelectedItems() == null || getSelectedItems().size() == 0) {
allowRemove = false;
allowReplace = false;
allowAdvanced = false;
allowReset = false;
} else {
if (getSelectedItems().size() == 1) {
allowAdvanced = volumeEntity.isOnline() && getSelectedItems().get(0).isOnline();
} else {
allowReplace = false;
allowAdvanced = false;
allowReset = false;
}
GlusterAsyncTask volumeTask = volumeEntity.getAsyncTask();
if (volumeTask != null && (volumeTask.getStatus() == JobExecutionStatus.STARTED || volumeTask.getType() == GlusterTaskType.REMOVE_BRICK && volumeTask.getStatus() == JobExecutionStatus.FINISHED)) {
allowRemove = false;
allowReplace = false;
allowReset = false;
} else if (volumeEntity.getVolumeType() == GlusterVolumeType.STRIPE || getSelectedItems().size() == volumeEntity.getBricks().size()) {
allowRemove = false;
} else if (volumeEntity.getVolumeType() == GlusterVolumeType.REPLICATE && (volumeEntity.getBricks().size() == VolumeListModel.REPLICATE_COUNT_DEFAULT || getSelectedItems().size() > 1)) {
allowRemove = false;
}
}
getRemoveBricksCommand().setIsExecutionAllowed(allowRemove);
getReplaceBrickCommand().setIsExecutionAllowed(allowReplace);
getBrickAdvancedDetailsCommand().setIsExecutionAllowed(allowAdvanced);
getAddBricksCommand().setIsExecutionAllowed(allowAdd);
getResetBrickCommand().setIsExecutionAllowed(allowReset);
}
use of org.ovirt.engine.core.common.asynctasks.gluster.GlusterAsyncTask in project ovirt-engine by oVirt.
the class VolumeBrickListModel method commitRemoveBricks.
private void commitRemoveBricks() {
if (getConfirmWindow() != null) {
return;
}
ConfirmationModel model = new ConfirmationModel();
setConfirmWindow(model);
model.setTitle(ConstantsManager.getInstance().getConstants().commitRemoveBricksTitle());
model.setMessage(ConstantsManager.getInstance().getConstants().commitRemoveBricksMessage());
model.setHelpTag(HelpTag.volume_remove_bricks_commit);
// $NON-NLS-1$
model.setHashName("volume_remove_bricks_commit");
GlusterVolumeEntity volumeEntity = getVolumeEntity();
GlusterAsyncTask volumeTask = volumeEntity.getAsyncTask();
ArrayList<String> list = new ArrayList<>();
for (GlusterBrickEntity brick : volumeEntity.getBricks()) {
if (brick.getAsyncTask() != null && volumeTask != null && brick.getAsyncTask().getTaskId() != null && brick.getAsyncTask().getTaskId().equals(volumeTask.getTaskId()) && volumeTask.getStatus() == JobExecutionStatus.FINISHED) {
list.add(brick.getQualifiedName());
}
}
model.setItems(list);
// $NON-NLS-1$
UICommand okCommand = UICommand.createDefaultOkUiCommand("OnCommitRemoveBricks", this);
model.getCommands().add(okCommand);
// $NON-NLS-1$
UICommand cancelCommand = UICommand.createCancelUiCommand("CancelConfirmation", this);
model.getCommands().add(cancelCommand);
}
Aggregations