use of org.ovirt.engine.core.common.asynctasks.gluster.GlusterAsyncTask in project ovirt-engine by oVirt.
the class GlusterVolumeDaoImpl method fetchRelatedEntities.
/**
* Fetches and populates related entities like bricks, options, access protocols for the given volume
*/
private void fetchRelatedEntities(GlusterVolumeEntity volume) {
if (volume != null) {
volume.setOptions(glusterOptionDao.getOptionsOfVolume(volume.getId()));
volume.setAccessProtocols(new HashSet<>(getAccessProtocolsOfVolume(volume.getId())));
volume.setTransportTypes(new HashSet<>(getTransportTypesOfVolume(volume.getId())));
GlusterVolumeAdvancedDetails advancedDetails = fetchAdvancedDatails(volume.getId());
if (advancedDetails != null) {
volume.setAdvancedDetails(advancedDetails);
}
GlusterAsyncTask asyncTask = getAsyncTaskOfVolume(volume.getId());
if (asyncTask != null) {
volume.setAsyncTask(asyncTask);
}
List<GlusterBrickEntity> bricks = glusterBrickDao.getBricksOfVolume(volume.getId());
if (volume.getAsyncTask() != null && volume.getAsyncTask().getTaskId() != null) {
bricks.stream().filter(brick -> brick.getAsyncTask() != null && brick.getAsyncTask().getTaskId() != null && brick.getAsyncTask().getTaskId().equals(volume.getAsyncTask().getTaskId())).forEach(brick -> brick.setAsyncTask(volume.getAsyncTask()));
}
volume.setBricks(bricks);
GlusterVolumeSnapshotConfig config = glusterVolumeSnapshotConfigDao.getConfigByVolumeIdAndName(volume.getClusterId(), volume.getId(), GlusterConstants.VOLUME_SNAPSHOT_MAX_HARD_LIMIT);
if (config == null || StringUtils.isEmpty(config.getParamValue())) {
config = glusterVolumeSnapshotConfigDao.getConfigByClusterIdAndName(volume.getClusterId(), GlusterConstants.VOLUME_SNAPSHOT_MAX_HARD_LIMIT);
}
volume.setSnapMaxLimit(config != null ? Integer.parseInt(config.getParamValue()) : 0);
}
}
use of org.ovirt.engine.core.common.asynctasks.gluster.GlusterAsyncTask in project ovirt-engine by oVirt.
the class VolumeBrickListModel method retainBricks.
private void retainBricks() {
if (getConfirmWindow() != null) {
return;
}
ConfirmationModel model = new ConfirmationModel();
setConfirmWindow(model);
model.setTitle(ConstantsManager.getInstance().getConstants().retainBricksTitle());
model.setMessage(ConstantsManager.getInstance().getConstants().retainBricksMessage());
model.setHelpTag(HelpTag.volume_retain_brick);
// $NON-NLS-1$
model.setHashName("volume_retain_brick");
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("OnRetainBricks", 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 GlusterTasksSyncJob method updateVolumeBricksAndLock.
private void updateVolumeBricksAndLock(Cluster cluster, GlusterAsyncTask task, final GlusterVolumeEntity vol) {
try {
// acquire lock on volume
acquireLock(vol.getId());
// update volume with task id
volumeDao.updateVolumeTask(vol.getId(), task.getTaskId());
if (GlusterTaskType.REMOVE_BRICK == task.getType()) {
// update bricks associated with task id
String[] bricks = task.getTaskParameters().getBricks();
if (bricks != null) {
List<GlusterBrickEntity> brickEntities = new ArrayList<>();
for (String brick : bricks) {
String[] brickParts = brick.split(":", -1);
String hostnameOrIp = brickParts[0];
String brickDir = brickParts[1];
GlusterBrickEntity brickEntity = new GlusterBrickEntity();
VdsStatic server = glusterDBUtils.getServer(cluster.getId(), hostnameOrIp);
if (server == null) {
log.warn("Could not find server '{}' in cluster '{}'", hostnameOrIp, cluster.getId());
} else {
brickEntity.setServerId(server.getId());
brickEntity.setBrickDirectory(brickDir);
brickEntity.setAsyncTask(new GlusterAsyncTask());
brickEntity.getAsyncTask().setTaskId(task.getTaskId());
brickEntities.add(brickEntity);
}
}
brickDao.updateAllBrickTasksByHostIdBrickDirInBatch(brickEntities);
}
}
logTaskStartedFromCLI(cluster, task, vol);
} catch (Exception e) {
log.error("Exception", e);
// Release the lock only if there is any exception,
// otherwise the lock will be released once the task is completed
releaseLock(vol.getId());
throw new EngineException(EngineError.GeneralException, e.getMessage());
}
}
use of org.ovirt.engine.core.common.asynctasks.gluster.GlusterAsyncTask in project ovirt-engine by oVirt.
the class GlusterAsyncTaskStatusQueryBase method setStartAndStopTime.
private GlusterVolumeTaskStatusEntity setStartAndStopTime(GlusterVolumeTaskStatusEntity status) {
if (status == null) {
return null;
}
GlusterAsyncTask asyncTask = volume.getAsyncTask();
if (asyncTask != null && asyncTask.getTaskId() != null) {
List<Step> stepsList = stepDao.getStepsByExternalId(asyncTask.getTaskId());
if (stepsList != null && !stepsList.isEmpty()) {
status.setStartTime(stepsList.get(0).getStartTime());
status.setStopTime(stepsList.get(0).getEndTime());
}
}
return status;
}
use of org.ovirt.engine.core.common.asynctasks.gluster.GlusterAsyncTask 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());
}
}
}
}
Aggregations