@@ -340,7 +340,6 @@ public boolean loadEnvironmentVars() {
340340 public List <String > listAvailableDatabases (Environment environment ) {
341341 List <String > dbs = new ArrayList <>();
342342 Connection conn = null ;
343- HmsMirrorConfig config = executeSessionService .getSession ().getConfig ();
344343 try {
345344 conn = connectionPoolService .getHS2EnvironmentConnection (environment );
346345 if (conn != null ) {
@@ -414,8 +413,8 @@ public boolean buildDBStatements(DBMirror dbMirror) {
414413 boolean skipManagedLocation = Boolean .FALSE ;
415414 boolean forceLocations = Boolean .FALSE ;
416415
417- Map <String , String > dbDefLeft = dbMirror .getProperty (Environment .LEFT );
418- Map <String , String > dbDefRight = dbMirror .getProperty (Environment .RIGHT );
416+ Map <String , String > dbPropsLeft = dbMirror .getProperty (Environment .LEFT );
417+ Map <String , String > dbPropsRight = dbMirror .getProperty (Environment .RIGHT );
419418
420419 switch (config .getDataStrategy ()) {
421420 case DUMP :
@@ -438,9 +437,9 @@ public boolean buildDBStatements(DBMirror dbMirror) {
438437 config .getClusters ().put (Environment .RIGHT , cluster );
439438 }
440439 // Build the Right Def as a Clone of the Left to Seed it.
441- if (isNull (dbDefRight )) {
442- dbDefRight = new TreeMap <String , String >();
443- dbMirror .setProperty (Environment .RIGHT , dbDefRight );
440+ if (isNull (dbPropsRight )) {
441+ dbPropsRight = new TreeMap <String , String >();
442+ dbMirror .setProperty (Environment .RIGHT , dbPropsRight );
444443 }
445444
446445 break ;
@@ -452,11 +451,11 @@ public boolean buildDBStatements(DBMirror dbMirror) {
452451 buildRight = Boolean .FALSE ;
453452 }
454453 // Build the Right Def as a Clone of the Left to Seed it.
455- if (isNull (dbDefRight )) {
454+ if (isNull (dbPropsRight )) {
456455 // No Right DB Definition. So we're going to create it.
457456 createRight = Boolean .TRUE ;
458- dbDefRight = new TreeMap <String , String >();
459- dbMirror .setProperty (Environment .RIGHT , dbDefRight );
457+ dbPropsRight = new TreeMap <String , String >();
458+ dbMirror .setProperty (Environment .RIGHT , dbPropsRight );
460459 }
461460 // Force Locations to ensure DB and new tables are created in the right locations.
462461 forceLocations = Boolean .TRUE ;
@@ -471,13 +470,13 @@ public boolean buildDBStatements(DBMirror dbMirror) {
471470 buildLeft = Boolean .FALSE ;
472471 buildRight = Boolean .TRUE ;
473472 // Build the Right Def as a Clone of the Left to Seed it.
474- if (isNull (dbDefRight )) {
473+ if (isNull (dbPropsRight )) {
475474 // No Right DB Definition. So we're going to create it.
476475 createRight = Boolean .TRUE ;
477476// dbDefRight = new TreeMap<String, String>(dbDefLeft);
478- dbDefRight = new TreeMap <String , String >();
479- dbDefRight .put (DB_NAME , HmsMirrorConfigUtil .getResolvedDB (dbMirror .getName (), config ));
480- dbMirror .setProperty (Environment .RIGHT , dbDefRight );
477+ dbPropsRight = new TreeMap <String , String >();
478+ dbPropsRight .put (DB_NAME , HmsMirrorConfigUtil .getResolvedDB (dbMirror .getName (), config ));
479+ dbMirror .setProperty (Environment .RIGHT , dbPropsRight );
481480 }
482481 // Force Locations to ensure DB and new tables are created in the right locations.
483482 if (config .getTransfer ().getStorageMigration ().getTranslationType () == TranslationTypeEnum .ALIGNED ) {
@@ -592,7 +591,7 @@ public boolean buildDBStatements(DBMirror dbMirror) {
592591 "So we're not going to set it and let it default to the ENV warehouse location: {}." , targetLocation , envWarehouse .getExternalDirectory ());
593592 // The new target location is the same as the ENV warehouse location. So we're not
594593 // going to set it and let it default to the ENV warehouse location.
595- dbDefRight .put (DB_LOCATION , targetNamespace + targetLocation );
594+ dbPropsRight .put (DB_LOCATION , targetNamespace + targetLocation );
596595 dbMirror .addIssue (Environment .RIGHT , "The database location is the same as the ENV warehouse location. The database location will NOT be set and will depend on the ENV warehouse location." );
597596 targetLocation = null ;
598597 }
@@ -651,7 +650,7 @@ public boolean buildDBStatements(DBMirror dbMirror) {
651650 log .debug ("The new target managed location: {} is the same as the ENV warehouse managed location. " +
652651 "So we're not going to set it and let it default to the ENV warehouse managed location: {}." ,
653652 targetManagedLocation , envWarehouse .getManagedDirectory ());
654- dbDefRight .put (DB_MANAGED_LOCATION , targetNamespace + targetManagedLocation );
653+ dbPropsRight .put (DB_MANAGED_LOCATION , targetNamespace + targetManagedLocation );
655654 dbMirror .addIssue (Environment .RIGHT , "The database 'Managed' location is the same as the ENV warehouse Managed location. The database location will NOT be set and will depend on the ENV warehouse location." );
656655 targetManagedLocation = null ;
657656 }
@@ -675,7 +674,7 @@ public boolean buildDBStatements(DBMirror dbMirror) {
675674 }
676675
677676 // Upsert Source DB Parameters to Target DB Parameters.
678- DatabaseUtils .upsertParameters (dbDefLeft , dbDefRight , skipList );
677+ DatabaseUtils .upsertParameters (dbPropsLeft , dbPropsRight , skipList );
679678
680679 // Deal with ReadOnly.
681680 if (config .isReadOnly ()) {
@@ -749,16 +748,16 @@ public boolean buildDBStatements(DBMirror dbMirror) {
749748 String createDb = MessageFormat .format (CREATE_DB , targetDatabase );
750749 StringBuilder sb = new StringBuilder ();
751750 sb .append (createDb ).append ("\n " );
752- if (dbDefLeft .get (COMMENT ) != null && !dbDefLeft .get (COMMENT ).trim ().isEmpty ()) {
753- sb .append (COMMENT ).append (" \" " ).append (dbDefLeft .get (COMMENT )).append ("\" \n " );
751+ if (dbPropsLeft .get (COMMENT ) != null && !dbPropsLeft .get (COMMENT ).trim ().isEmpty ()) {
752+ sb .append (COMMENT ).append (" \" " ).append (dbPropsLeft .get (COMMENT )).append ("\" \n " );
754753 }
755754 if (nonNull (originalLocation )) {
756755 sb .append (DB_LOCATION ).append (" \" " ).append (originalLocation ).append ("\" \n " );
757- dbDefLeft .put (DB_LOCATION , originalLocation );
756+ dbPropsLeft .put (DB_LOCATION , originalLocation );
758757 }
759758 if (nonNull (originalManagedLocation )) {
760759 sb .append (DB_MANAGED_LOCATION ).append (" \" " ).append (originalManagedLocation ).append ("\" \n " );
761- dbDefLeft .put (DB_MANAGED_LOCATION , originalManagedLocation );
760+ dbPropsLeft .put (DB_MANAGED_LOCATION , originalManagedLocation );
762761 }
763762 dbMirror .getSql (Environment .LEFT ).add (new Pair (CREATE_DB_DESC , sb .toString ()));
764763
@@ -784,21 +783,21 @@ public boolean buildDBStatements(DBMirror dbMirror) {
784783 if (!isBlank (targetLocation )) {
785784 String alterDbLoc = MessageFormat .format (ALTER_DB_LOCATION , targetDatabase , targetLocation );
786785 dbMirror .getSql (Environment .LEFT ).add (new Pair (ALTER_DB_LOCATION_DESC , alterDbLoc ));
787- dbDefRight .put (DB_LOCATION , targetLocation );
786+ dbPropsRight .put (DB_LOCATION , targetLocation );
788787 }
789788 }
790789 if (!config .getCluster (Environment .LEFT ).isHdpHive3 ()) {
791790 if (!isBlank (targetManagedLocation )) {
792791 String alterDbMngdLoc = MessageFormat .format (ALTER_DB_MNGD_LOCATION , targetDatabase , targetManagedLocation );
793792 dbMirror .getSql (Environment .LEFT ).add (new Pair (ALTER_DB_MNGD_LOCATION_DESC , alterDbMngdLoc ));
794- dbDefRight .put (DB_MANAGED_LOCATION , targetManagedLocation );
793+ dbPropsRight .put (DB_MANAGED_LOCATION , targetManagedLocation );
795794 }
796795 } else {
797796 if (!isBlank (targetManagedLocation )) {
798797 String alterDbMngdLoc = MessageFormat .format (ALTER_DB_LOCATION , targetDatabase , targetManagedLocation );
799798 dbMirror .getSql (Environment .LEFT ).add (new Pair (ALTER_DB_LOCATION_DESC , alterDbMngdLoc ));
800799 dbMirror .addIssue (Environment .LEFT , HDPHIVE3_DB_LOCATION .getDesc ());
801- dbDefRight .put (DB_LOCATION , targetManagedLocation );
800+ dbPropsRight .put (DB_LOCATION , targetManagedLocation );
802801 }
803802 }
804803
@@ -835,36 +834,36 @@ public boolean buildDBStatements(DBMirror dbMirror) {
835834 String createDbL = MessageFormat .format (CREATE_DB , targetDatabase );
836835 StringBuilder sbL = new StringBuilder ();
837836 sbL .append (createDbL ).append ("\n " );
838- if (dbDefLeft .get (COMMENT ) != null && !dbDefLeft .get (COMMENT ).trim ().isEmpty ()) {
839- sbL .append (COMMENT ).append (" \" " ).append (dbDefLeft .get (COMMENT )).append ("\" \n " );
837+ if (dbPropsLeft .get (COMMENT ) != null && !dbPropsLeft .get (COMMENT ).trim ().isEmpty ()) {
838+ sbL .append (COMMENT ).append (" \" " ).append (dbPropsLeft .get (COMMENT )).append ("\" \n " );
840839 }
841840 dbMirror .getSql (Environment .RIGHT ).add (new Pair (CREATE_DB_DESC , sbL .toString ()));
842841 log .trace ("RIGHT DB Create SQL: {}" , sbL );
843842 }
844843
845844 if (nonNull (targetLocation ) && !config .getCluster (Environment .RIGHT ).isHdpHive3 ()) {
846- String origRightLocation = dbDefRight .get (DB_LOCATION );
845+ String origRightLocation = dbPropsRight .get (DB_LOCATION );
847846 // If the original location is null or doesn't equal the target location, set it.
848847 if (isNull (origRightLocation ) || !origRightLocation .equals (targetLocation )) {
849848 String alterDbLoc = MessageFormat .format (ALTER_DB_LOCATION , targetDatabase , targetLocation );
850849 dbMirror .getSql (Environment .RIGHT ).add (new Pair (ALTER_DB_LOCATION_DESC , alterDbLoc ));
851- dbDefRight .put (DB_LOCATION , targetLocation );
850+ dbPropsRight .put (DB_LOCATION , targetLocation );
852851 log .trace ("RIGHT DB Location SQL: {}" , alterDbLoc );
853852 }
854853 }
855854 if (nonNull (targetManagedLocation )) {
856- String origRightManagedLocation = config .getCluster (Environment .RIGHT ).isHdpHive3 () ? dbDefRight .get (DB_LOCATION ) : dbDefRight .get (DB_MANAGED_LOCATION );
855+ String origRightManagedLocation = config .getCluster (Environment .RIGHT ).isHdpHive3 () ? dbPropsRight .get (DB_LOCATION ) : dbPropsRight .get (DB_MANAGED_LOCATION );
857856 if (isNull (origRightManagedLocation ) || !origRightManagedLocation .equals (targetManagedLocation )) {
858857 if (!config .getCluster (Environment .RIGHT ).isHdpHive3 ()) {
859858 String alterDbMngdLoc = MessageFormat .format (ALTER_DB_MNGD_LOCATION , targetDatabase , targetManagedLocation );
860859 dbMirror .getSql (Environment .RIGHT ).add (new Pair (ALTER_DB_MNGD_LOCATION_DESC , alterDbMngdLoc ));
861- dbDefRight .put (DB_MANAGED_LOCATION , targetManagedLocation );
860+ dbPropsRight .put (DB_MANAGED_LOCATION , targetManagedLocation );
862861 log .trace ("RIGHT DB Managed Location SQL: {}" , alterDbMngdLoc );
863862 } else {
864863 String alterDbMngdLoc = MessageFormat .format (ALTER_DB_LOCATION , targetDatabase , targetManagedLocation );
865864 dbMirror .getSql (Environment .RIGHT ).add (new Pair (ALTER_DB_LOCATION_DESC , alterDbMngdLoc ));
866865 dbMirror .addIssue (Environment .RIGHT , HDPHIVE3_DB_LOCATION .getDesc ());
867- dbDefRight .put (DB_LOCATION , targetManagedLocation );
866+ dbPropsRight .put (DB_LOCATION , targetManagedLocation );
868867 log .trace ("RIGHT DB Managed Location SQL: {}" , alterDbMngdLoc );
869868 }
870869 }
@@ -873,7 +872,7 @@ public boolean buildDBStatements(DBMirror dbMirror) {
873872 // Build the DBPROPERITES
874873 // Check if the user has specified any DB Properties to skip.
875874 Set <String > lclSkipList = new HashSet <>(skipList );
876- Map <String , String > dbProperties = DatabaseUtils .getParameters (dbDefRight , lclSkipList , config .getFilter ().getDbPropertySkipListPattern ());
875+ Map <String , String > dbProperties = DatabaseUtils .getParameters (dbPropsRight , lclSkipList , config .getFilter ().getDbPropertySkipListPattern ());
877876 if (!dbProperties .isEmpty ()) {
878877 for (Map .Entry <String , String > entry : dbProperties .entrySet ()) {
879878 String alterDbProps = MessageFormat .format (ALTER_DB_PROPERTIES , targetDatabase , entry .getKey (), entry .getValue ());
@@ -883,8 +882,8 @@ public boolean buildDBStatements(DBMirror dbMirror) {
883882 }
884883
885884 if (config .getOwnershipTransfer ().isDatabase ()) {
886- String ownerFromLeft = dbDefLeft .get (OWNER_NAME );
887- String ownerTypeFromLeft = dbDefLeft .get (OWNER_TYPE );
885+ String ownerFromLeft = dbPropsLeft .get (OWNER_NAME );
886+ String ownerTypeFromLeft = dbPropsLeft .get (OWNER_TYPE );
888887 if (nonNull (ownerFromLeft ) && nonNull (ownerTypeFromLeft )) {
889888 log .info ("Setting Owner: {} of type: {} on Database: {}" , ownerFromLeft , ownerTypeFromLeft , targetDatabase );
890889 if (ownerTypeFromLeft .equals ("USER" )) {
0 commit comments