managed/src/main/java/com/yugabyte/yw/common/PlacementInfoUtil.java
/**
   * Verify that the planned changes for an Edit Universe operation are allowed.
   *
   * @param oldCluster    The current (soon to be old) version of a cluster.
   * @param newCluster    The intended next version of the same cluster.
   */
Verify that the planned changes for an Edit Universe operation are allowed.
@param oldCluster    The current (soon to be old) version of a cluster.
@param newCluster    The intended next version of the same cluster.
Verify that the planned changes for an Edit Universe operation are allowed . @param oldCluster The current ( soon to be old ) version of a cluster . @param newCluster The intended next version of the same cluster .
private static void verifyEditParams(Cluster oldCluster, Cluster newCluster) {
    UserIntent existingIntent = oldCluster.userIntent;
    UserIntent userIntent = newCluster.userIntent;
    LOG.info("old intent: {}", existingIntent.toString());
    LOG.info("new intent: {}", userIntent.toString());
    if (userIntent.equals(existingIntent) &&
        userIntent.instanceTags.equals(existingIntent.instanceTags) &&
        isSamePlacement(oldCluster.placementInfo, newCluster.placementInfo)) {
      LOG.error("No fields were modified for edit universe.");
      throw new IllegalArgumentException("Invalid operation: At least one field should be " +
                                         "modified for editing the universe.");
    }
    if (oldCluster.clusterType != newCluster.clusterType) {
      LOG.error("Cluster type cannot be changed from {} to {}",
                oldCluster.clusterType, newCluster.clusterType);
      throw new UnsupportedOperationException("Cluster type cannot be modified.");
    }
    if (existingIntent.replicationFactor != userIntent.replicationFactor) {
      LOG.error("Replication factor cannot be changed from {} to {}",
              existingIntent.replicationFactor, userIntent.replicationFactor);
      throw new UnsupportedOperationException("Replication factor cannot be modified.");
    }
    if (!existingIntent.universeName.equals(userIntent.universeName)) {
      LOG.error("universeName cannot be changed from {} to {}",
              existingIntent.universeName, userIntent.universeName);
      throw new UnsupportedOperationException("Universe name cannot be modified.");
    }
    if (!existingIntent.provider.equals(userIntent.provider)) {
      LOG.error("Provider cannot be changed from {} to {}",
                existingIntent.provider, userIntent.provider);
      throw new UnsupportedOperationException("Provider cannot be modified.");
    }
    if (existingIntent.providerType != userIntent.providerType) {
      LOG.error("Provider type cannot be changed from {} to {}",
                existingIntent.providerType, userIntent.providerType);
      throw new UnsupportedOperationException("providerType cannot be modified.");
    }
    verifyNodesAndRF(oldCluster.clusterType,
                     userIntent.numNodes, userIntent.replicationFactor);
  }
private static void verifyEditParams ( Cluster oldCluster , Cluster newCluster ) { UserIntent existingIntent = oldCluster . userIntent ; UserIntent userIntent = newCluster . userIntent ; LOG . info ( "old intent: {}" , existingIntent . toString ( ) ) ; LOG . info ( "new intent: {}" , userIntent . toString ( ) ) ; if ( userIntent . equals ( existingIntent ) && userIntent . instanceTags . equals ( existingIntent . instanceTags ) && isSamePlacement ( oldCluster . placementInfo , newCluster . placementInfo ) ) { LOG . error ( "No fields were modified for edit universe." ) ; throw new IllegalArgumentException ( "Invalid operation: At least one field should be " + "modified for editing the universe." ) ; } if ( oldCluster . clusterType != newCluster . clusterType ) { LOG . error ( "Cluster type cannot be changed from {} to {}" , oldCluster . clusterType , newCluster . clusterType ) ; throw new UnsupportedOperationException ( "Cluster type cannot be modified." ) ; } if ( existingIntent . replicationFactor != userIntent . replicationFactor ) { LOG . error ( "Replication factor cannot be changed from {} to {}" , existingIntent . replicationFactor , userIntent . replicationFactor ) ; throw new UnsupportedOperationException ( "Replication factor cannot be modified." ) ; } if ( ! existingIntent . universeName . equals ( userIntent . universeName ) ) { LOG . error ( "universeName cannot be changed from {} to {}" , existingIntent . universeName , userIntent . universeName ) ; throw new UnsupportedOperationException ( "Universe name cannot be modified." ) ; } if ( ! existingIntent . provider . equals ( userIntent . provider ) ) { LOG . error ( "Provider cannot be changed from {} to {}" , existingIntent . provider , userIntent . provider ) ; throw new UnsupportedOperationException ( "Provider cannot be modified." ) ; } if ( existingIntent . providerType != userIntent . providerType ) { LOG . error ( "Provider type cannot be changed from {} to {}" , existingIntent . providerType , userIntent . providerType ) ; throw new UnsupportedOperationException ( "providerType cannot be modified." ) ; } verifyNodesAndRF ( oldCluster . clusterType , userIntent . numNodes , userIntent . replicationFactor ) ; }
Verify that the planned changes for an Edit Universe operation are allowed.
Verify that the planned changes for an Edit Universe operation are allowed .
// Error out if no fields are modified. // Rule out some of the universe changes that we do not allow (they can be enabled as needed).