use of org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity in project ovirt-engine by oVirt.
the class VolumeBrickListModel method showRemoveBricksStatus.
private void showRemoveBricksStatus() {
final GlusterVolumeEntity volumeEntity = getVolumeEntity();
final ArrayList<GlusterBrickEntity> bricks = new ArrayList<>();
for (GlusterBrickEntity brick : volumeEntity.getBricks()) {
if (brick.getAsyncTask() != null && brick.getAsyncTask().getTaskId() != null) {
bricks.add(brick);
}
}
final ConfirmationModel cModel = new ConfirmationModel();
cModel.setHelpTag(HelpTag.volume_remove_bricks_status);
// //$NON-NLS-1$
cModel.setHashName("volume_remove_bricks_status");
// $NON-NLS-1$
UICommand removeBrickStatusOk = new UICommand("CancelConfirmation", VolumeBrickListModel.this);
removeBrickStatusOk.setTitle(ConstantsManager.getInstance().getConstants().ok());
removeBrickStatusOk.setIsCancel(true);
cModel.startProgress(ConstantsManager.getInstance().getConstants().fetchingDataMessage());
cModel.getCommands().add(removeBrickStatusOk);
cModel.setTitle(ConstantsManager.getInstance().getConstants().removeBricksStatusTitle());
setConfirmWindow(cModel);
// $NON-NLS-1$
final UICommand stopRemoveBrickFromStatus = new UICommand("StopRemoveBricksOnStatus", this);
stopRemoveBrickFromStatus.setTitle(ConstantsManager.getInstance().getConstants().stopRemoveBricksButton());
stopRemoveBrickFromStatus.setIsExecutionAllowed(false);
// $NON-NLS-1$
final UICommand commitRemoveBrickFromStatus = new UICommand("CommitRemoveBricksOnStatus", this);
commitRemoveBrickFromStatus.setTitle(ConstantsManager.getInstance().getConstants().commitRemoveBricksButton());
commitRemoveBrickFromStatus.setIsExecutionAllowed(false);
// $NON-NLS-1$
final UICommand retainBricksFromStatus = new UICommand("RetainBricksOnStatus", this);
retainBricksFromStatus.setTitle(ConstantsManager.getInstance().getConstants().retainBricksButton());
retainBricksFromStatus.setIsExecutionAllowed(false);
// $NON-NLS-1$
final UICommand cancelCommand = new UICommand("CancelRemoveBricksStatus", this);
cancelCommand.setTitle(ConstantsManager.getInstance().getConstants().close());
cancelCommand.setIsCancel(true);
AsyncDataProvider.getInstance().getGlusterRemoveBricksStatus(new AsyncQuery<>(returnValue -> {
cModel.stopProgress();
if (returnValue.getSucceeded() && returnValue.getReturnValue() != null) {
cancelConfirmation();
RemoveBrickStatusModel removeBrickStatusModel;
GlusterVolumeTaskStatusEntity removeBrickStatusEntity = returnValue.getReturnValue();
if (getWindow() == null) {
removeBrickStatusModel = new RemoveBrickStatusModel(volumeEntity, bricks);
removeBrickStatusModel.setTitle(ConstantsManager.getInstance().getConstants().removeBricksStatusTitle());
removeBrickStatusModel.setHelpTag(HelpTag.volume_remove_bricks_status);
// //$NON-NLS-1$
removeBrickStatusModel.setHashName("volume_remove_bricks_status");
setWindow(removeBrickStatusModel);
removeBrickStatusModel.getVolume().setEntity(volumeEntity.getName());
removeBrickStatusModel.getCluster().setEntity(volumeEntity.getClusterName());
removeBrickStatusModel.addStopRemoveBricksCommand(stopRemoveBrickFromStatus);
removeBrickStatusModel.addCommitRemoveBricksCommand(commitRemoveBrickFromStatus);
removeBrickStatusModel.addRetainBricksCommand(retainBricksFromStatus);
removeBrickStatusModel.getCommands().add(cancelCommand);
} else {
removeBrickStatusModel = (RemoveBrickStatusModel) getWindow();
}
removeBrickStatusModel.showStatus(removeBrickStatusEntity);
} else {
cModel.setMessage(ConstantsManager.getInstance().getMessages().removeBrickStatusFailed(volumeEntity.getName()));
}
}), volumeEntity.getClusterId(), volumeEntity.getId(), bricks);
}
use of org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity in project ovirt-engine by oVirt.
the class VolumeBrickListModel method validateDistriputedReplicateRemove.
public boolean validateDistriputedReplicateRemove(GlusterVolumeType volumeType, List<GlusterBrickEntity> selectedBricks, List<GlusterBrickEntity> brickList, RemoveBrickModel removeBrickModel) {
int replicaCount = removeBrickModel.getReplicaCount();
int distributions = brickList.size() / replicaCount;
// Key - No.of.bricks selected in sub-volume
// Value - No.of sub-volumes which has 'Key' no.of bricks selected
Map<Integer, Integer> selectedBricksToSubVolumesMap = new HashMap<>();
for (int distIndex = 0; distIndex < distributions; distIndex++) {
List<GlusterBrickEntity> bricksInSubVolumeList = brickList.subList(distIndex * replicaCount, (distIndex * replicaCount) + replicaCount);
int selectedBricksInSubVolume = 0;
for (GlusterBrickEntity brick : bricksInSubVolumeList) {
if (selectedBricks.contains(brick)) {
selectedBricksInSubVolume++;
}
}
if (selectedBricksInSubVolume > 0) {
if (!selectedBricksToSubVolumesMap.containsKey(selectedBricksInSubVolume)) {
selectedBricksToSubVolumesMap.put(selectedBricksInSubVolume, 0);
}
selectedBricksToSubVolumesMap.put(selectedBricksInSubVolume, selectedBricksToSubVolumesMap.get(selectedBricksInSubVolume) + 1);
}
}
// sub-volumes, hence not valid for removal.
if (selectedBricksToSubVolumesMap.size() == 1) {
// If the user has selected once brick from each sub-volume, then replica count needs to be reduced
if (selectedBricksToSubVolumesMap.containsKey(1) && selectedBricksToSubVolumesMap.get(1) == distributions) {
removeBrickModel.setReplicaCount(removeBrickModel.getReplicaCount() - 1);
removeBrickModel.setReduceReplica(true);
return true;
} else if (selectedBricksToSubVolumesMap.containsKey(replicaCount)) {
return true;
}
return false;
}
return false;
}
use of org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity in project ovirt-engine by oVirt.
the class SubTabVolumeBrickView method initTable.
void initTable() {
getTable().enableColumnResizing();
BrickStatusColumn brickStatusColumn = new BrickStatusColumn();
brickStatusColumn.setContextMenuTitle(constants.statusVolumeBrick());
brickStatusColumn.makeSortable();
// $NON-NLS-1$
getTable().addColumn(brickStatusColumn, constants.empty(), "30px");
AbstractTextColumn<GlusterBrickEntity> serverColumn = new AbstractTextColumn<GlusterBrickEntity>() {
@Override
public String getValue(GlusterBrickEntity brick) {
return brick.getServerName();
}
};
serverColumn.makeSortable();
// $NON-NLS-1$
getTable().addColumn(serverColumn, constants.serverVolumeBrick(), "300px");
AbstractTextColumn<GlusterBrickEntity> directoryColumn = new AbstractTextColumn<GlusterBrickEntity>() {
@Override
public String getValue(GlusterBrickEntity brick) {
String qualifiedName = brick.getQualifiedName();
if (brick.getIsArbiter()) {
// $NON-NLS-1$ //$NON-NLS-2$
qualifiedName += " (" + constants.arbiter() + ")";
}
return qualifiedName;
}
};
directoryColumn.makeSortable();
// $NON-NLS-1$
getTable().addColumn(directoryColumn, constants.brickDirectoryVolumeBrick(), "400px");
getTable().addColumn(new Column<GlusterBrickEntity, BrickProperties>(new BrickCapacityCell()) {
@Override
public BrickProperties getValue(GlusterBrickEntity object) {
return object.getBrickProperties();
}
}, constants.volumeCapacity(), // $NON-NLS-1$
"100px");
BrickHealInfoColumn healInfoColumn = new BrickHealInfoColumn();
// $NON-NLS-1$
getTable().addColumn(healInfoColumn, constants.healInfo(), "110px");
getTable().addColumn(new VolumeActivityColumn<GlusterBrickEntity>(getActivityCell()), constants.activitiesOnVolume(), // $NON-NLS-1$
"100px");
}
use of org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity in project ovirt-engine by oVirt.
the class SubTabHostBrickView method initTable.
void initTable() {
getTable().enableColumnResizing();
BrickStatusColumn brickStatusColumn = new BrickStatusColumn();
brickStatusColumn.makeSortable();
// $NON-NLS-1$
getTable().addColumn(brickStatusColumn, constants.empty(), "30px");
AbstractTextColumn<GlusterBrickEntity> volNameColumn = new AbstractTextColumn<GlusterBrickEntity>() {
@Override
public String getValue(GlusterBrickEntity object) {
return object.getVolumeName();
}
};
volNameColumn.makeSortable();
getTable().addColumn(volNameColumn, constants.volumeName());
AbstractTextColumn<GlusterBrickEntity> brickDirColumn = new AbstractTextColumn<GlusterBrickEntity>() {
@Override
public String getValue(GlusterBrickEntity object) {
return object.getBrickDirectory();
}
};
brickDirColumn.makeSortable();
// $NON-NLS-1$
getTable().addColumn(brickDirColumn, constants.brickDirectoryBricks(), "220px");
BrickHealInfoColumn healInfoColumn = new BrickHealInfoColumn();
// $NON-NLS-1$
getTable().addColumn(healInfoColumn, constants.healInfo(), "110px");
}
use of org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity in project ovirt-engine by oVirt.
the class VolumeBrickStatusCell method render.
@Override
public void render(Context context, GlusterVolumeEntity volume, SafeHtmlBuilder sb, String id) {
// Nothing to render if no volume is provided:
if (volume == null) {
return;
}
int upBricks = 0;
int downBricks = 0;
for (GlusterBrickEntity brick : volume.getBricks()) {
if (brick.isOnline()) {
upBricks++;
} else {
downBricks++;
}
}
ImageResource upImage = resources.upImage();
ImageResource downImage = resources.downImage();
// Generate the HTML for the images
SafeHtml upImageHtml = SafeHtmlUtils.fromTrustedString(AbstractImagePrototype.create(upImage).getHTML());
SafeHtml downImageHtml = SafeHtmlUtils.fromTrustedString(AbstractImagePrototype.create(downImage).getHTML());
sb.append(templates.volumeBrickStatusTemplate(upImageHtml, upBricks, downImageHtml, downBricks, id));
}
Aggregations