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);
   }
 }
  /**
   * 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);
  }