@Override protected boolean canDoAction() { if (!super.canDoAction()) { return false; } VDSGroup cluster = getVdsGroup(); if (cluster == null) { addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_CLUSTER_IS_NOT_VALID); return false; } if (!cluster.supportsGlusterService()) { addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_CLUSTER_DOES_NOT_SUPPORT_GLUSTER); return false; } if (volumeNameExists(volume.getName())) { addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_GLUSTER_VOLUME_NAME_ALREADY_EXISTS); addCanDoActionMessage(String.format("$volumeName %1$s", volume.getName())); return false; } return validateBricks(volume); }
private void onSetParameter() { if (getEntity() == null) { return; } GlusterVolumeEntity volume = getEntity(); VolumeParameterModel model = (VolumeParameterModel) getWindow(); if (!model.validate()) { return; } GlusterVolumeOptionEntity option = new GlusterVolumeOptionEntity(); option.setVolumeId(volume.getId()); option.setKey(model.getSelectedKey().getEntity()); option.setValue(model.getValue().getEntity()); model.startProgress(); Frontend.getInstance() .runAction( VdcActionType.SetGlusterVolumeOption, new GlusterVolumeOptionParameters(option), new IFrontendActionAsyncCallback() { @Override public void executed(FrontendActionAsyncResult result) { VolumeParameterListModel localModel = (VolumeParameterListModel) result.getState(); localModel.postOnSetParameter(result.getReturnValue()); } }, this); }
private void onResetAllParameters() { ConfirmationModel model = (ConfirmationModel) getWindow(); if (model.getProgress() != null) { return; } if (getEntity() == null) { return; } GlusterVolumeEntity volume = getEntity(); ResetGlusterVolumeOptionsParameters parameters = new ResetGlusterVolumeOptionsParameters(volume.getId(), null, false); model.startProgress(); Frontend.getInstance() .runAction( VdcActionType.ResetGlusterVolumeOptions, parameters, new IFrontendActionAsyncCallback() { @Override public void executed(FrontendActionAsyncResult result) { ConfirmationModel localModel = (ConfirmationModel) result.getState(); localModel.stopProgress(); cancel(); } }, model); }
private GlusterVolumeAdvancedDetails getVolumeAdvancedDetails(GlusterVolumeEntity volume) { GlusterVolumeAdvancedDetails volDetails = new GlusterVolumeAdvancedDetails(); GlusterVolumeSizeInfo capacityInfo = new GlusterVolumeSizeInfo(); capacityInfo.setVolumeId(volume.getId()); capacityInfo.setTotalSize(600000L); capacityInfo.setFreeSize(200000L); capacityInfo.setUsedSize(400000L); volDetails.setCapacityInfo(capacityInfo); List<BrickDetails> brickDetailsList = new ArrayList<>(); for (GlusterBrickEntity brick : volume.getBricks()) { BrickDetails brickDetails = new BrickDetails(); BrickProperties properties = new BrickProperties(); properties.setBrickId(brick.getId()); brickDetails.setBrickProperties(properties); properties.setStatus(brick.getStatus()); if (volume == existingReplVol) { if (brick.getServerId().equals(SERVER_ID_1) && (brick.getBrickDirectory().equals(REPL_BRICK_R1D1) || brick.getBrickDirectory().equals(REPL_BRICK_R2D1))) { properties.setStatus(GlusterStatus.DOWN); bricksWithChangedStatus.add(brick); } } brickDetailsList.add(brickDetails); } volDetails.setBrickDetails(brickDetailsList); return volDetails; }
/** * Returns the list of volumes as if they were fetched from glusterfs. Changes from existing * volumes are:<br> * - existingDistVol not fetched (means it was removed from gluster cli, and should be removed * from db<br> * - option 'auth.allow' removed from the existingReplVol<br> * - new option 'auth.reject' added to existingReplVol<br> * - value of option 'nfs.disable' changed from 'off' ot 'on' in existingReplVol<br> * - new volume test-new-vol fetched from gluster (means it was added from gluster cli, and should * be added to db<br> */ private Map<Guid, GlusterVolumeEntity> getFetchedVolumesList() { Map<Guid, GlusterVolumeEntity> volumes = new HashMap<>(); GlusterVolumeEntity fetchedReplVol = createReplVol(); fetchedReplVol.removeOption(OPTION_AUTH_ALLOW); // option removed fetchedReplVol.setOption(OPTION_AUTH_REJECT, AUTH_REJECT_IP); // added fetchedReplVol.setOption(OPTION_NFS_DISABLE, OPTION_VALUE_ON); // changed // brick changes removedBrickIds.add( GlusterCoreUtil.findBrick(existingReplVol.getBricks(), SERVER_ID_1, REPL_BRICK_R1D1) .getId()); removedBrickIds.add( GlusterCoreUtil.findBrick(existingReplVol.getBricks(), SERVER_ID_1, REPL_BRICK_R2D1) .getId()); GlusterBrickEntity brickToReplace = GlusterCoreUtil.findBrick(fetchedReplVol.getBricks(), SERVER_ID_1, REPL_BRICK_R1D1); replaceBrick(brickToReplace, SERVER_ID_1, REPL_BRICK_R1D1_NEW); brickToReplace = GlusterCoreUtil.findBrick(fetchedReplVol.getBricks(), SERVER_ID_1, REPL_BRICK_R2D1); replaceBrick(brickToReplace, SERVER_ID_1, REPL_BRICK_R2D1_NEW); volumes.put(fetchedReplVol.getId(), fetchedReplVol); // add a new volume newVolume = getNewVolume(); volumes.put(newVolume.getId(), newVolume); return volumes; }
/** * Validates the the number of bricks against the replica count or stripe count based on volume * type * * @param volume * @return */ private boolean validateBricks(GlusterVolumeEntity volume) { List<GlusterBrickEntity> bricks = volume.getBricks(); if (bricks.isEmpty()) { addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_BRICKS_REQUIRED); return false; } int brickCount = bricks.size(); int replicaCount = volume.getReplicaCount(); int stripeCount = volume.getStripeCount(); switch (volume.getVolumeType()) { case REPLICATE: if (replicaCount < 2) { addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_REPLICA_COUNT_MIN_2); return false; } if (brickCount != replicaCount) { addCanDoActionMessage( VdcBllMessages.ACTION_TYPE_FAILED_INVALID_BRICK_COUNT_FOR_REPLICATE); return false; } break; case DISTRIBUTED_REPLICATE: if (replicaCount < 2) { addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_REPLICA_COUNT_MIN_2); return false; } if (brickCount < replicaCount || Math.IEEEremainder(brickCount, replicaCount) != 0) { addCanDoActionMessage( VdcBllMessages.ACTION_TYPE_FAILED_INVALID_BRICK_COUNT_FOR_DISTRIBUTED_REPLICATE); return false; } break; case STRIPE: if (stripeCount < 4) { addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_STRIPE_COUNT_MIN_4); return false; } if (brickCount != stripeCount) { addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_INVALID_BRICK_COUNT_FOR_STRIPE); return false; } break; case DISTRIBUTED_STRIPE: if (stripeCount < 4) { addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_STRIPE_COUNT_MIN_4); return false; } if (brickCount < stripeCount || Math.IEEEremainder(brickCount, stripeCount) != 0) { addCanDoActionMessage( VdcBllMessages.ACTION_TYPE_FAILED_INVALID_BRICK_COUNT_FOR_DISTRIBUTED_STRIPE); return false; } break; } return updateBrickServerNames(bricks, true); }
private GlusterVolumeEntity getMultiBrickVolume(Guid volumeId) { GlusterVolumeEntity volume = getGlusterVolume(volumeId); volume.setStatus(GlusterStatus.UP); volume.setBricks(getBricks(volumeId, 2)); volume.setClusterId(CLUSTER_ID); return volume; }
private void addParameter() { if (getWindow() != null) { return; } GlusterVolumeEntity volume = getEntity(); if (volume == null) { return; } VolumeParameterModel volumeParameterModel = new VolumeParameterModel(); volumeParameterModel.setTitle(ConstantsManager.getInstance().getConstants().addOptionVolume()); volumeParameterModel.setHelpTag(HelpTag.add_option); volumeParameterModel.setHashName("add_option"); // $NON-NLS-1$ setWindow(volumeParameterModel); volumeParameterModel.startProgress(); AsyncQuery _asyncQuery = new AsyncQuery(); _asyncQuery.setModel(this); _asyncQuery.setHandleFailure(true); _asyncQuery.asyncCallback = new INewAsyncCallback() { @Override public void onSuccess(Object model, Object result) { VolumeParameterListModel volumeParameterListModel = (VolumeParameterListModel) model; VolumeParameterModel innerParameterModel = (VolumeParameterModel) getWindow(); ArrayList<GlusterVolumeOptionInfo> optionInfoList = new ArrayList<GlusterVolumeOptionInfo>(); VdcQueryReturnValue returnValue = (VdcQueryReturnValue) result; if (!returnValue.getSucceeded()) { innerParameterModel.setMessage( ConstantsManager.getInstance().getConstants().errorInFetchingVolumeOptionList()); } else { optionInfoList = new ArrayList<GlusterVolumeOptionInfo>( (Set<GlusterVolumeOptionInfo>) returnValue.getReturnValue()); optionInfoList.add(getCifsVolumeOption()); } innerParameterModel.getKeyList().setItems(optionInfoList); innerParameterModel.stopProgress(); UICommand command = UICommand.createDefaultOkUiCommand( "OnSetParameter", volumeParameterListModel); // $NON-NLS-1$ innerParameterModel.getCommands().add(command); innerParameterModel .getCommands() .add( UICommand.createCancelUiCommand( "OnCancel", volumeParameterListModel)); // $NON-NLS-1$ } }; AsyncDataProvider.getInstance() .getGlusterVolumeOptionInfoList(_asyncQuery, volume.getClusterId()); }
private GlusterVolumeEntity getVolume(Guid id) { GlusterVolumeEntity volumeEntity = new GlusterVolumeEntity(); volumeEntity.setId(id); volumeEntity.setName("test-vol"); volumeEntity.addAccessProtocol(AccessProtocol.GLUSTER); volumeEntity.addTransportType(TransportType.TCP); return volumeEntity; }
private GlusterVolumeEntity getDistributedVolume(Guid volumeId) { GlusterVolumeEntity volume = getVolume(volumeId); volume.setStatus((volumeId == volumeId1) ? GlusterStatus.UP : GlusterStatus.DOWN); volume.setBricks(getBricks(volumeId, "distrib", 2)); volume.setVolumeType(GlusterVolumeType.DISTRIBUTED_REPLICATE); volume.setClusterId(clusterId); return volume; }
private GlusterVolumeEntity createVolume(String volName, Guid id) { GlusterVolumeEntity vol = new GlusterVolumeEntity(); vol.setId(id); vol.setName(volName); vol.setClusterId(CLUSTER_ID); vol.setStatus(GlusterStatus.UP); return vol; }
private GlusterVolumeEntity createDistVol(String volName, Guid volId) { GlusterVolumeEntity vol = createVolume(volName, volId); vol.getAdvancedDetails().setCapacityInfo(getCapacityInfo(volId)); vol.addBrick(createBrick(volId, existingServer1, DIST_BRICK_D1)); vol.addBrick(createBrick(volId, existingServer1, DIST_BRICK_D2)); existingVolumes.add(vol); return vol; }
private GlusterVolumeEntity createReplVol() { GlusterVolumeEntity vol = createVolume(REPL_VOL_NAME, EXISTING_VOL_REPL_ID); vol.addBrick(createBrick(EXISTING_VOL_REPL_ID, existingServer1, REPL_BRICK_R1D1)); vol.addBrick(createBrick(EXISTING_VOL_REPL_ID, existingServer2, REPL_BRICK_R1D2)); vol.addBrick(createBrick(EXISTING_VOL_REPL_ID, existingServer1, REPL_BRICK_R2D1)); vol.addBrick(createBrick(EXISTING_VOL_REPL_ID, existingServer2, REPL_BRICK_R2D2)); vol.setOption(OPTION_AUTH_ALLOW, "*"); vol.setOption(OPTION_NFS_DISABLE, OPTION_VALUE_OFF); existingVolumes.add(vol); return vol; }
@Override protected void syncSearch() { if (getEntity() == null) { return; } GlusterVolumeEntity glusterVolumeEntity = getEntity(); ArrayList<GlusterVolumeOptionEntity> list = new ArrayList<GlusterVolumeOptionEntity>(); for (GlusterVolumeOptionEntity glusterVolumeOption : glusterVolumeEntity.getOptions()) { list.add(glusterVolumeOption); } setItems(list); }
@SuppressWarnings("unchecked") private void setupMocks() throws Exception { logUtil = spy(GlusterAuditLogUtil.getInstance()); glusterManager.setLogUtil(logUtil); mockDaos(); doReturn(glusterUtil).when(glusterManager).getGlusterUtil(); doReturn(existingServer1).when(glusterUtil).getUpServer(any(Guid.class)); doReturn(existingServer1).when(glusterUtil).getRandomUpServer(any(Guid.class)); doNothing().when(logUtil).logServerMessage(any(VDS.class), any(AuditLogType.class)); doNothing() .when(logUtil) .logVolumeMessage(any(GlusterVolumeEntity.class), any(AuditLogType.class)); doNothing() .when(logUtil) .logAuditMessage( any(Guid.class), any(GlusterVolumeEntity.class), any(VDS.class), any(AuditLogType.class), any(HashMap.class)); doNothing() .when(logUtil) .logAuditMessage( any(Guid.class), any(GlusterVolumeEntity.class), any(VDS.class), any(AuditLogType.class), any(Guid.class), any(String.class)); doReturn(getFetchedServersList()).when(glusterManager).fetchServers(any(VDS.class)); doReturn(getFetchedVolumesList()).when(glusterManager).fetchVolumes(any(VDS.class)); doReturn(getVolumeAdvancedDetails(existingDistVol)) .when(glusterManager) .getVolumeAdvancedDetails(existingServer1, CLUSTER_ID, existingDistVol.getName()); doReturn(getVolumeAdvancedDetails(existingReplVol)) .when(glusterManager) .getVolumeAdvancedDetails(existingServer1, CLUSTER_ID, existingReplVol.getName()); doReturn(new VDSReturnValue()) .when(glusterManager) .runVdsCommand(eq(VDSCommandType.RemoveVds), argThat(isRemovedServer())); doReturn(mockVdcReturn()) .when(backend) .runInternalAction( any(VdcActionType.class), any(VdcActionParametersBase.class), any(CommandContext.class)); doNothing().when(glusterManager).acquireLock(CLUSTER_ID); doNothing().when(glusterManager).releaseLock(CLUSTER_ID); doReturn(glusterUtil).when(glusterManager).getGlusterUtil(); }
private void verifyMocksForHeavyWeight() { InOrder inOrder = inOrder(clusterDao, glusterUtil, volumeDao, glusterManager, brickDao); // all clusters fetched from db inOrder.verify(clusterDao, times(1)).getAll(); VerificationMode mode = times(1); // get the UP server from cluster inOrder.verify(glusterUtil, mode).getRandomUpServer(CLUSTER_ID); // get volumes of the cluster inOrder.verify(volumeDao, mode).getByClusterId(CLUSTER_ID); // acquire lock on the cluster inOrder.verify(glusterManager, mode).acquireLock(CLUSTER_ID); // get volume advance details inOrder .verify(glusterManager, mode) .getVolumeAdvancedDetails(existingServer1, CLUSTER_ID, existingDistVol.getName()); // Update capacity info inOrder .verify(volumeDao, mode) .updateVolumeCapacityInfo(getVolumeAdvancedDetails(existingDistVol).getCapacityInfo()); // release lock on the cluster inOrder.verify(glusterManager, mode).releaseLock(CLUSTER_ID); // acquire lock on the cluster for repl volume inOrder.verify(glusterManager, mode).acquireLock(CLUSTER_ID); // get volume advance details of repl volume inOrder .verify(glusterManager, mode) .getVolumeAdvancedDetails(existingServer1, CLUSTER_ID, existingReplVol.getName()); // Add Capacity Info inOrder .verify(volumeDao, mode) .addVolumeCapacityInfo(getVolumeAdvancedDetails(existingReplVol).getCapacityInfo()); // Add Capacity Info inOrder.verify(brickDao, mode).addBrickProperties(any(List.class)); // update brick status inOrder.verify(brickDao, mode).updateBrickStatuses(argThat(hasBricksWithChangedStatus())); // release lock on the cluster inOrder.verify(glusterManager, mode).releaseLock(CLUSTER_ID); }
/** * Sets all options of a volume by invoking the action {@link * VdcActionType#SetGlusterVolumeOption} in a loop. <br> * Errors if any are collected and added to "executeFailedMessages" * * @param volume */ private void setVolumeOptions(GlusterVolumeEntity volume) { List<String> errors = new ArrayList<String>(); for (GlusterVolumeOptionEntity option : volume.getOptions()) { // make sure that volume id is set option.setVolumeId(volume.getId()); VdcReturnValueBase setOptionReturnValue = runBllAction( VdcActionType.SetGlusterVolumeOption, new GlusterVolumeOptionParameters(option)); if (!getSucceeded()) { errors.addAll(setOptionReturnValue.getCanDoActionMessages()); errors.addAll(setOptionReturnValue.getExecuteFailedMessages()); } } if (!errors.isEmpty()) { handleVdsErrors(AuditLogType.GLUSTER_VOLUME_OPTION_SET_FAILED, errors); } }
/* * (non-Javadoc) * * @see org.ovirt.engine.core.bll.CommandBase#executeCommand() */ @Override protected void executeCommand() { // set the gluster volume name for audit purpose setGlusterVolumeName(volume.getName()); if (volume.getTransportTypes() == null || volume.getTransportTypes().isEmpty()) { volume.addTransportType(TransportType.TCP); } // GLUSTER access protocol is enabled by default volume.addAccessProtocol(AccessProtocol.GLUSTER); if (!volume.getAccessProtocols().contains(AccessProtocol.NFS)) { volume.disableNFS(); } VDSReturnValue returnValue = runVdsCommand( VDSCommandType.CreateGlusterVolume, new CreateGlusterVolumeVDSParameters(upServer.getId(), volume)); setSucceeded(returnValue.getSucceeded()); if (!getSucceeded()) { handleVdsError( AuditLogType.GLUSTER_VOLUME_CREATE_FAILED, returnValue.getVdsError().getMessage()); return; } // Volume created successfully. Insert it to database. GlusterVolumeEntity createdVolume = (GlusterVolumeEntity) returnValue.getReturnValue(); setVolumeType(createdVolume); setBrickOrder(createdVolume.getBricks()); addVolumeToDb(createdVolume); // set all options of the volume setVolumeOptions(createdVolume); getReturnValue().setActionReturnValue(createdVolume.getId()); }
private GlusterVolumeEntity getReplicatedVolume(Guid volumeId, int brickCount) { GlusterVolumeEntity volume = getVolume(volumeId); volume.setStatus(GlusterStatus.UP); volume.setBricks(getBricks(volumeId, "repl", brickCount)); volume.setVolumeType(GlusterVolumeType.REPLICATE); volume.setReplicaCount(brickCount); volume.setClusterId(clusterId); return volume; }
@Override protected List<Class<?>> getValidationGroups() { switch (volume.getVolumeType()) { case REPLICATE: case DISTRIBUTED_REPLICATE: addValidationGroup(CreateReplicatedVolume.class); break; case STRIPE: case DISTRIBUTED_STRIPE: addValidationGroup(CreateStripedVolume.class); break; default: addValidationGroup(CreateEntity.class); } return super.getValidationGroups(); }
@Override public void render(Context context, GlusterVolumeEntity object, SafeHtmlBuilder sb, String id) { GlusterVolumeAdvancedDetails advancedDetails = object.getAdvancedDetails(); GlusterVolumeSizeInfo sizeInfo = null; if (advancedDetails != null) { sizeInfo = advancedDetails.getCapacityInfo(); if (sizeInfo != null) { setFreeSize(sizeInfo.getFreeSize().doubleValue()); setTotalSize(sizeInfo.getTotalSize().doubleValue()); setUsedSize(sizeInfo.getUsedSize().doubleValue()); setInUnit(SizeUnit.BYTES); } } super.render( context, advancedDetails == null ? null : sizeInfo == null ? null : sizeInfo, sb, id); }
private GlusterVolumeEntity getNewVolume() { GlusterVolumeEntity volume = new GlusterVolumeEntity(); volume.setName(NEW_VOL_NAME); volume.setClusterId(CLUSTER_ID); volume.setId(NEW_VOL_ID); volume.setVolumeType(GlusterVolumeType.DISTRIBUTE); volume.addTransportType(TransportType.TCP); volume.setReplicaCount(0); volume.setStripeCount(0); volume.setStatus(GlusterStatus.UP); volume.setOption("auth.allow", "*"); volume.addAccessProtocol(AccessProtocol.GLUSTER); volume.addAccessProtocol(AccessProtocol.NFS); GlusterBrickEntity brick = new GlusterBrickEntity(); brick.setVolumeId(NEW_VOL_ID); brick.setServerId(existingServer1.getId()); brick.setServerName(existingServer1.getHostName()); brick.setBrickDirectory("/export/testvol1"); brick.setStatus(GlusterStatus.UP); brick.setBrickOrder(0); volume.addBrick(brick); return volume; }
private void addVolumeToDb(final GlusterVolumeEntity createdVolume) { // volume fetched from VDSM doesn't contain cluster id as // GlusterFS is not aware of multiple clusters createdVolume.setClusterId(getVdsGroupId()); DbFacade.getInstance().getGlusterVolumeDao().save(createdVolume); }
private void verifyMocksForLightWeight() { InOrder inOrder = inOrder( clusterDao, vdsDao, glusterUtil, glusterManager, vdsStatisticsDao, vdsDynamicDao, vdsStaticDao, volumeDao, brickDao, optionDao); // all clusters fetched from db inOrder.verify(clusterDao, times(1)).getAll(); // get servers of the cluster from db inOrder.verify(vdsDao, times(1)).getAllForCluster(CLUSTER_ID); // get the UP server from cluster inOrder.verify(glusterUtil, times(1)).getUpServer(CLUSTER_ID); // acquire lock on the cluster inOrder.verify(glusterManager, times(1)).acquireLock(CLUSTER_ID); // servers are fetched from glusterfs inOrder.verify(glusterManager, times(1)).fetchServers(existingServer1); // detached server SERVER_ID_3 is deleted from DB inOrder.verify(vdsStatisticsDao, times(1)).remove(SERVER_ID_3); inOrder.verify(vdsDynamicDao, times(1)).remove(SERVER_ID_3); inOrder.verify(vdsStaticDao, times(1)).remove(SERVER_ID_3); // detached server SERVER_ID_3 is removed from resource manager inOrder .verify(glusterManager, times(1)) .runVdsCommand(eq(VDSCommandType.RemoveVds), any(RemoveVdsVDSCommandParameters.class)); // release lock on the cluster inOrder.verify(glusterManager, times(1)).releaseLock(CLUSTER_ID); // acquire lock on the cluster for next operation (refresh volumes) inOrder.verify(glusterManager, times(1)).acquireLock(CLUSTER_ID); // volumes are fetched from glusterfs inOrder.verify(glusterManager, times(1)).fetchVolumes(any(VDS.class)); // get volumes by cluster id to identify those that need to be removed inOrder.verify(volumeDao, times(1)).getByClusterId(CLUSTER_ID); // remove deleted volumes inOrder.verify(volumeDao, times(1)).removeAll(argThat(areRemovedVolumes())); // create new volume inOrder.verify(volumeDao, times(1)).save(newVolume); // remove detached bricks inOrder.verify(brickDao, times(1)).removeAll(argThat(containsRemovedBricks())); // add new bricks inOrder.verify(brickDao, times(2)).save(argThat(isAddedBrick())); // add new options inOrder.verify(optionDao, times(1)).saveAll(argThat(areAddedOptions())); // update modified options Map<String, GlusterVolumeOptionEntity> existingOptions = new HashMap<>(); existingReplVol.getOption(OPTION_NFS_DISABLE).setValue(OPTION_VALUE_ON); existingOptions.put(OPTION_NFS_DISABLE, existingReplVol.getOption(OPTION_NFS_DISABLE)); List<GlusterVolumeOptionEntity> list = new ArrayList<>(existingOptions.values()); Collections.sort(list); inOrder.verify(optionDao, times(1)).updateAll("UpdateGlusterVolumeOption", list); // delete removed options inOrder.verify(optionDao, times(1)).removeAll(argThat(areRemovedOptions())); // release lock on the cluster inOrder.verify(glusterManager, times(1)).releaseLock(CLUSTER_ID); }
public CreateGlusterVolumeCommand(CreateGlusterVolumeParameters params) { super(params); volume = getParameters().getVolume(); setVdsGroupId(volume.getClusterId()); }
private void setVolumeType(GlusterVolumeEntity createdVolume) { if (createdVolume.getVolumeType() == GlusterVolumeType.REPLICATE && createdVolume.getBricks().size() > createdVolume.getReplicaCount()) { createdVolume.setVolumeType(GlusterVolumeType.DISTRIBUTED_REPLICATE); } else if (createdVolume.getVolumeType() == GlusterVolumeType.DISTRIBUTED_REPLICATE && createdVolume.getBricks().size() == createdVolume.getReplicaCount()) { createdVolume.setVolumeType(GlusterVolumeType.REPLICATE); } else if (createdVolume.getVolumeType() == GlusterVolumeType.STRIPE && createdVolume.getBricks().size() > createdVolume.getStripeCount()) { createdVolume.setVolumeType(GlusterVolumeType.DISTRIBUTED_STRIPE); } else if (createdVolume.getVolumeType() == GlusterVolumeType.DISTRIBUTED_STRIPE && createdVolume.getBricks().size() == createdVolume.getStripeCount()) { createdVolume.setVolumeType(GlusterVolumeType.STRIPE); } }