Search in sources :

Example 36 with GlusterBrickEntity

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);
}
Also used : GlusterTaskType(org.ovirt.engine.core.common.asynctasks.gluster.GlusterTaskType) GlusterVolumeTaskStatusEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeTaskStatusEntity) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) HashMap(java.util.HashMap) GlusterVolumeReplaceBrickActionParameters(org.ovirt.engine.core.common.action.gluster.GlusterVolumeReplaceBrickActionParameters) GlusterVolumeType(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeType) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) SearchableListModel(org.ovirt.engine.ui.uicommonweb.models.SearchableListModel) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) ArrayList(java.util.ArrayList) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) ActionType(org.ovirt.engine.core.common.action.ActionType) Frontend(org.ovirt.engine.ui.frontend.Frontend) GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) GetConfigurationValueParameters(org.ovirt.engine.core.common.queries.GetConfigurationValueParameters) Mempool(org.ovirt.engine.core.common.businessentities.gluster.Mempool) Map(java.util.Map) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) GlusterVolumeRemoveBricksParameters(org.ovirt.engine.core.common.action.gluster.GlusterVolumeRemoveBricksParameters) VolumeListModel(org.ovirt.engine.ui.uicommonweb.models.volumes.VolumeListModel) EventArgs(org.ovirt.engine.ui.uicompat.EventArgs) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) GlusterClientInfo(org.ovirt.engine.core.common.businessentities.gluster.GlusterClientInfo) JobExecutionStatus(org.ovirt.engine.core.common.job.JobExecutionStatus) GlusterVolumeBricksActionParameters(org.ovirt.engine.core.common.action.gluster.GlusterVolumeBricksActionParameters) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) Iterator(java.util.Iterator) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) ConfigValues(org.ovirt.engine.core.common.config.ConfigValues) GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) GlusterVolumeAdvancedDetails(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeAdvancedDetails) List(java.util.List) VDSStatus(org.ovirt.engine.core.common.businessentities.VDSStatus) BrickDetails(org.ovirt.engine.core.common.businessentities.gluster.BrickDetails) GlusterAsyncTask(org.ovirt.engine.core.common.asynctasks.gluster.GlusterAsyncTask) GlusterVolumeResetBrickActionParameters(org.ovirt.engine.core.common.action.gluster.GlusterVolumeResetBrickActionParameters) VDS(org.ovirt.engine.core.common.businessentities.VDS) GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) ArrayList(java.util.ArrayList) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) GlusterVolumeTaskStatusEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeTaskStatusEntity)

Example 37 with GlusterBrickEntity

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;
}
Also used : GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) HashMap(java.util.HashMap)

Example 38 with GlusterBrickEntity

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");
}
Also used : GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) BrickCapacityCell(org.ovirt.engine.ui.webadmin.widget.table.column.BrickCapacityCell) AbstractTextColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn) BrickStatusColumn(org.ovirt.engine.ui.webadmin.widget.table.column.BrickStatusColumn) BrickHealInfoColumn(org.ovirt.engine.ui.webadmin.widget.table.column.BrickHealInfoColumn) BrickProperties(org.ovirt.engine.core.common.businessentities.gluster.BrickProperties)

Example 39 with GlusterBrickEntity

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");
}
Also used : GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) AbstractTextColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn) BrickStatusColumn(org.ovirt.engine.ui.webadmin.widget.table.column.BrickStatusColumn) BrickHealInfoColumn(org.ovirt.engine.ui.webadmin.widget.table.column.BrickHealInfoColumn)

Example 40 with GlusterBrickEntity

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));
}
Also used : GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) ImageResource(com.google.gwt.resources.client.ImageResource) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml)

Aggregations

GlusterBrickEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity)132 ArrayList (java.util.ArrayList)63 GlusterVolumeEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity)43 Test (org.junit.Test)28 Guid (org.ovirt.engine.core.compat.Guid)19 GlusterAsyncTask (org.ovirt.engine.core.common.asynctasks.gluster.GlusterAsyncTask)14 ConfirmationModel (org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)13 VDS (org.ovirt.engine.core.common.businessentities.VDS)11 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)11 List (java.util.List)10 HashMap (java.util.HashMap)9 Map (java.util.Map)9 ValidationResult (org.ovirt.engine.core.bll.ValidationResult)9 BrickProperties (org.ovirt.engine.core.common.businessentities.gluster.BrickProperties)9 GlusterVolumeRemoveBricksParameters (org.ovirt.engine.core.common.action.gluster.GlusterVolumeRemoveBricksParameters)7 BrickDetails (org.ovirt.engine.core.common.businessentities.gluster.BrickDetails)7 GlusterVolumeAdvancedDetails (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeAdvancedDetails)7 GlusterVolumeType (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeType)7 EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)7 Iterator (java.util.Iterator)5