Source:
<code>public ValidationResult canRemoveBrick(List<GlusterBrickEntity> bricks, GlusterVolumeEntity volumeEntity, int replicaCount, boolean forceRemove) { if (bricks.isEmpty()) { return new ValidationResult(VdcBllMessages.ACTION_TYPE_FAILED_BRICKS_REQUIRED); } if (volumeEntity.getBricks().size() == 1 || volumeEntity.getBricks().size() <= bricks.size()) { return new ValidationResult(VdcBllMessages.ACTION_TYPE_FAILED_CAN_NOT_REMOVE_ALL_BRICKS_FROM_VOLUME); } if (volumeEntity.getVolumeType().isReplicatedType()) { if (replicaCount < volumeEntity.getReplicaCount() - 1) { return new ValidationResult(VdcBllMessages.ACTION_TYPE_FAILED_CAN_NOT_REDUCE_REPLICA_COUNT_MORE_THAN_ONE); } else if (replicaCount > volumeEntity.getReplicaCount()) { return new ValidationResult(VdcBllMessages.ACTION_TYPE_FAILED_CAN_NOT_INCREASE_REPLICA_COUNT); } } for (GlusterBrickEntity brick : bricks) { if (brick.getId(false) == null && brick.getQualifiedName() == null) { return new ValidationResult(VdcBllMessages.ACTION_TYPE_FAILED_BRICKS_REQUIRED); } GlusterBrickEntity brickFromVolume = volumeEntity.getBrickWithId(brick.getId()); if (brickFromVolume == null) { brickFromVolume = volumeEntity.getBrickWithQualifiedName(brick.getQualifiedName()); } if (brickFromVolume == null) { return new ValidationResult(VdcBllMessages.ACTION_TYPE_FAILED_GLUSTER_BRICK_INVALID); } else { brick.setServerName(brickFromVolume.getServerName()); brick.setBrickDirectory(brickFromVolume.getBrickDirectory()); } } if (!forceRemove) { <START> return canRebalance(volumeEntity); <END> } else { return ValidationResult.VALID; } }</code><technical_language>If removal, need consider bricks other removed online in subvolume</technical_language>

Target:
public ValidationResult canRemoveBrick(List<GlusterBrickEntity> bricks, GlusterVolumeEntity volumeEntity, int replicaCount, boolean forceRemove) { if (bricks.isEmpty()) { return new ValidationResult(VdcBllMessages.ACTION_TYPE_FAILED_BRICKS_REQUIRED); } if (volumeEntity.getBricks().size() == 1 || volumeEntity.getBricks().size() <= bricks.size()) { return new ValidationResult(VdcBllMessages.ACTION_TYPE_FAILED_CAN_NOT_REMOVE_ALL_BRICKS_FROM_VOLUME); } if (volumeEntity.getVolumeType().isReplicatedType()) { if (replicaCount < volumeEntity.getReplicaCount() - 1) { return new ValidationResult(VdcBllMessages.ACTION_TYPE_FAILED_CAN_NOT_REDUCE_REPLICA_COUNT_MORE_THAN_ONE); } else if (replicaCount > volumeEntity.getReplicaCount()) { return new ValidationResult(VdcBllMessages.ACTION_TYPE_FAILED_CAN_NOT_INCREASE_REPLICA_COUNT); } } for (GlusterBrickEntity brick : bricks) { if (brick.getId(false) == null && brick.getQualifiedName() == null) { return new ValidationResult(VdcBllMessages.ACTION_TYPE_FAILED_BRICKS_REQUIRED); } GlusterBrickEntity brickFromVolume = volumeEntity.getBrickWithId(brick.getId()); if (brickFromVolume == null) { brickFromVolume = volumeEntity.getBrickWithQualifiedName(brick.getQualifiedName()); } if (brickFromVolume == null) { return new ValidationResult(VdcBllMessages.ACTION_TYPE_FAILED_GLUSTER_BRICK_INVALID); } else { brick.setId(brickFromVolume.getId()); brick.setServerName(brickFromVolume.getServerName()); brick.setBrickDirectory(brickFromVolume.getBrickDirectory()); } } if (!forceRemove) { return canRebalance(volumeEntity); } else { return ValidationResult.VALID; } }