@@ -340,7 +340,6 @@ public boolean loadEnvironmentVars() {
340
340
public List <String > listAvailableDatabases (Environment environment ) {
341
341
List <String > dbs = new ArrayList <>();
342
342
Connection conn = null ;
343
- HmsMirrorConfig config = executeSessionService .getSession ().getConfig ();
344
343
try {
345
344
conn = connectionPoolService .getHS2EnvironmentConnection (environment );
346
345
if (conn != null ) {
@@ -414,8 +413,8 @@ public boolean buildDBStatements(DBMirror dbMirror) {
414
413
boolean skipManagedLocation = Boolean .FALSE ;
415
414
boolean forceLocations = Boolean .FALSE ;
416
415
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 );
419
418
420
419
switch (config .getDataStrategy ()) {
421
420
case DUMP :
@@ -438,9 +437,9 @@ public boolean buildDBStatements(DBMirror dbMirror) {
438
437
config .getClusters ().put (Environment .RIGHT , cluster );
439
438
}
440
439
// 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 );
444
443
}
445
444
446
445
break ;
@@ -452,11 +451,11 @@ public boolean buildDBStatements(DBMirror dbMirror) {
452
451
buildRight = Boolean .FALSE ;
453
452
}
454
453
// Build the Right Def as a Clone of the Left to Seed it.
455
- if (isNull (dbDefRight )) {
454
+ if (isNull (dbPropsRight )) {
456
455
// No Right DB Definition. So we're going to create it.
457
456
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 );
460
459
}
461
460
// Force Locations to ensure DB and new tables are created in the right locations.
462
461
forceLocations = Boolean .TRUE ;
@@ -471,13 +470,13 @@ public boolean buildDBStatements(DBMirror dbMirror) {
471
470
buildLeft = Boolean .FALSE ;
472
471
buildRight = Boolean .TRUE ;
473
472
// Build the Right Def as a Clone of the Left to Seed it.
474
- if (isNull (dbDefRight )) {
473
+ if (isNull (dbPropsRight )) {
475
474
// No Right DB Definition. So we're going to create it.
476
475
createRight = Boolean .TRUE ;
477
476
// 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 );
481
480
}
482
481
// Force Locations to ensure DB and new tables are created in the right locations.
483
482
if (config .getTransfer ().getStorageMigration ().getTranslationType () == TranslationTypeEnum .ALIGNED ) {
@@ -592,7 +591,7 @@ public boolean buildDBStatements(DBMirror dbMirror) {
592
591
"So we're not going to set it and let it default to the ENV warehouse location: {}." , targetLocation , envWarehouse .getExternalDirectory ());
593
592
// The new target location is the same as the ENV warehouse location. So we're not
594
593
// 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 );
596
595
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." );
597
596
targetLocation = null ;
598
597
}
@@ -651,7 +650,7 @@ public boolean buildDBStatements(DBMirror dbMirror) {
651
650
log .debug ("The new target managed location: {} is the same as the ENV warehouse managed location. " +
652
651
"So we're not going to set it and let it default to the ENV warehouse managed location: {}." ,
653
652
targetManagedLocation , envWarehouse .getManagedDirectory ());
654
- dbDefRight .put (DB_MANAGED_LOCATION , targetNamespace + targetManagedLocation );
653
+ dbPropsRight .put (DB_MANAGED_LOCATION , targetNamespace + targetManagedLocation );
655
654
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." );
656
655
targetManagedLocation = null ;
657
656
}
@@ -675,7 +674,7 @@ public boolean buildDBStatements(DBMirror dbMirror) {
675
674
}
676
675
677
676
// Upsert Source DB Parameters to Target DB Parameters.
678
- DatabaseUtils .upsertParameters (dbDefLeft , dbDefRight , skipList );
677
+ DatabaseUtils .upsertParameters (dbPropsLeft , dbPropsRight , skipList );
679
678
680
679
// Deal with ReadOnly.
681
680
if (config .isReadOnly ()) {
@@ -749,16 +748,16 @@ public boolean buildDBStatements(DBMirror dbMirror) {
749
748
String createDb = MessageFormat .format (CREATE_DB , targetDatabase );
750
749
StringBuilder sb = new StringBuilder ();
751
750
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 " );
754
753
}
755
754
if (nonNull (originalLocation )) {
756
755
sb .append (DB_LOCATION ).append (" \" " ).append (originalLocation ).append ("\" \n " );
757
- dbDefLeft .put (DB_LOCATION , originalLocation );
756
+ dbPropsLeft .put (DB_LOCATION , originalLocation );
758
757
}
759
758
if (nonNull (originalManagedLocation )) {
760
759
sb .append (DB_MANAGED_LOCATION ).append (" \" " ).append (originalManagedLocation ).append ("\" \n " );
761
- dbDefLeft .put (DB_MANAGED_LOCATION , originalManagedLocation );
760
+ dbPropsLeft .put (DB_MANAGED_LOCATION , originalManagedLocation );
762
761
}
763
762
dbMirror .getSql (Environment .LEFT ).add (new Pair (CREATE_DB_DESC , sb .toString ()));
764
763
@@ -784,21 +783,21 @@ public boolean buildDBStatements(DBMirror dbMirror) {
784
783
if (!isBlank (targetLocation )) {
785
784
String alterDbLoc = MessageFormat .format (ALTER_DB_LOCATION , targetDatabase , targetLocation );
786
785
dbMirror .getSql (Environment .LEFT ).add (new Pair (ALTER_DB_LOCATION_DESC , alterDbLoc ));
787
- dbDefRight .put (DB_LOCATION , targetLocation );
786
+ dbPropsRight .put (DB_LOCATION , targetLocation );
788
787
}
789
788
}
790
789
if (!config .getCluster (Environment .LEFT ).isHdpHive3 ()) {
791
790
if (!isBlank (targetManagedLocation )) {
792
791
String alterDbMngdLoc = MessageFormat .format (ALTER_DB_MNGD_LOCATION , targetDatabase , targetManagedLocation );
793
792
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 );
795
794
}
796
795
} else {
797
796
if (!isBlank (targetManagedLocation )) {
798
797
String alterDbMngdLoc = MessageFormat .format (ALTER_DB_LOCATION , targetDatabase , targetManagedLocation );
799
798
dbMirror .getSql (Environment .LEFT ).add (new Pair (ALTER_DB_LOCATION_DESC , alterDbMngdLoc ));
800
799
dbMirror .addIssue (Environment .LEFT , HDPHIVE3_DB_LOCATION .getDesc ());
801
- dbDefRight .put (DB_LOCATION , targetManagedLocation );
800
+ dbPropsRight .put (DB_LOCATION , targetManagedLocation );
802
801
}
803
802
}
804
803
@@ -835,36 +834,36 @@ public boolean buildDBStatements(DBMirror dbMirror) {
835
834
String createDbL = MessageFormat .format (CREATE_DB , targetDatabase );
836
835
StringBuilder sbL = new StringBuilder ();
837
836
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 " );
840
839
}
841
840
dbMirror .getSql (Environment .RIGHT ).add (new Pair (CREATE_DB_DESC , sbL .toString ()));
842
841
log .trace ("RIGHT DB Create SQL: {}" , sbL );
843
842
}
844
843
845
844
if (nonNull (targetLocation ) && !config .getCluster (Environment .RIGHT ).isHdpHive3 ()) {
846
- String origRightLocation = dbDefRight .get (DB_LOCATION );
845
+ String origRightLocation = dbPropsRight .get (DB_LOCATION );
847
846
// If the original location is null or doesn't equal the target location, set it.
848
847
if (isNull (origRightLocation ) || !origRightLocation .equals (targetLocation )) {
849
848
String alterDbLoc = MessageFormat .format (ALTER_DB_LOCATION , targetDatabase , targetLocation );
850
849
dbMirror .getSql (Environment .RIGHT ).add (new Pair (ALTER_DB_LOCATION_DESC , alterDbLoc ));
851
- dbDefRight .put (DB_LOCATION , targetLocation );
850
+ dbPropsRight .put (DB_LOCATION , targetLocation );
852
851
log .trace ("RIGHT DB Location SQL: {}" , alterDbLoc );
853
852
}
854
853
}
855
854
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 );
857
856
if (isNull (origRightManagedLocation ) || !origRightManagedLocation .equals (targetManagedLocation )) {
858
857
if (!config .getCluster (Environment .RIGHT ).isHdpHive3 ()) {
859
858
String alterDbMngdLoc = MessageFormat .format (ALTER_DB_MNGD_LOCATION , targetDatabase , targetManagedLocation );
860
859
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 );
862
861
log .trace ("RIGHT DB Managed Location SQL: {}" , alterDbMngdLoc );
863
862
} else {
864
863
String alterDbMngdLoc = MessageFormat .format (ALTER_DB_LOCATION , targetDatabase , targetManagedLocation );
865
864
dbMirror .getSql (Environment .RIGHT ).add (new Pair (ALTER_DB_LOCATION_DESC , alterDbMngdLoc ));
866
865
dbMirror .addIssue (Environment .RIGHT , HDPHIVE3_DB_LOCATION .getDesc ());
867
- dbDefRight .put (DB_LOCATION , targetManagedLocation );
866
+ dbPropsRight .put (DB_LOCATION , targetManagedLocation );
868
867
log .trace ("RIGHT DB Managed Location SQL: {}" , alterDbMngdLoc );
869
868
}
870
869
}
@@ -873,7 +872,7 @@ public boolean buildDBStatements(DBMirror dbMirror) {
873
872
// Build the DBPROPERITES
874
873
// Check if the user has specified any DB Properties to skip.
875
874
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 ());
877
876
if (!dbProperties .isEmpty ()) {
878
877
for (Map .Entry <String , String > entry : dbProperties .entrySet ()) {
879
878
String alterDbProps = MessageFormat .format (ALTER_DB_PROPERTIES , targetDatabase , entry .getKey (), entry .getValue ());
@@ -883,8 +882,8 @@ public boolean buildDBStatements(DBMirror dbMirror) {
883
882
}
884
883
885
884
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 );
888
887
if (nonNull (ownerFromLeft ) && nonNull (ownerTypeFromLeft )) {
889
888
log .info ("Setting Owner: {} of type: {} on Database: {}" , ownerFromLeft , ownerTypeFromLeft , targetDatabase );
890
889
if (ownerTypeFromLeft .equals ("USER" )) {
0 commit comments