Skip to content

Commit 6c3119e

Browse files
committed
Fixed locale issue with some 'set' statements that used numeric values.
1 parent 0da4e4d commit 6c3119e

File tree

12 files changed

+137
-522
lines changed

12 files changed

+137
-522
lines changed

Writerside/topics/Hive-Conversions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Modify the `hms-mirror` configuration to include the following settings:
2727
``` yaml
2828
clusters:
2929
LEFT|RIGHT:
30-
platformType: HDP2|HDP3|CHD5|CDH6|CDP7.1|CDP7_2|...
30+
platformType: HDP2|HDP3|CHD5|CDH6|CDP7_1|CDP7_2|...
3131
```
3232
</tab>
3333
</tabs>

Writerside/topics/cli-options.md

Lines changed: 80 additions & 491 deletions
Large diffs are not rendered by default.

Writerside/writerside.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
<ihp version="2.0">
55
<topics dir="topics" web-path="topics"/>
66
<images dir="images" web-path="images"/>
7-
<instance src="hms-mirror.tree" web-path="/hms-mirror" version="v2.3.0.x"/>
7+
<instance src="hms-mirror.tree" web-path="/hms-mirror" version="v2.3.1.x"/>
88
</ihp>

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
<groupId>com.cloudera.utils.hadoop</groupId>
3030
<artifactId>hms-mirror</artifactId>
31-
<version>2.3.1.2</version>
31+
<version>2.3.1.4</version>
3232
<packaging>jar</packaging>
3333

3434
<name>hms-mirror</name>

src/main/java/com/cloudera/utils/hms/mirror/SessionVars.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ public interface SessionVars {
2121
String TEZ_EXECUTION_DESC = "SET 'tez' as the execution engine";
2222
String SET_TEZ_AS_EXECUTION_ENGINE = "SET hive.execution.engine=tez";
2323

24-
String SET_SESSION_VALUE = "SET {0}={1}";
24+
String SET_SESSION_VALUE_INT = "SET {0}={1,number,0}";
25+
String SET_SESSION_VALUE_STRING = "SET {0}={1}";
2526

2627
String SORT_DYNAMIC_PARTITION = "hive.optimize.sort.dynamic.partition";
2728
String SORT_DYNAMIC_PARTITION_THRESHOLD = "hive.optimize.sort.dynamic.partition.threshold";

src/main/java/com/cloudera/utils/hms/mirror/cli/config/CliInit.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,10 @@ public HmsMirrorConfig loadHmsMirrorConfig(@Value("${hms-mirror.config.path}") S
138138
fullConfigPath = configPath + File.separator + configFile;
139139
}
140140
HmsMirrorConfig config = domainService.deserializeConfig(fullConfigPath);
141+
if (config == null) {
142+
log.error("Couldn't locate configuration file: {}", fullConfigPath);
143+
throw new RuntimeException("Couldn't locate configuration file: " + fullConfigPath);
144+
}
141145
return config;
142146
}
143147

src/main/java/com/cloudera/utils/hms/mirror/datastrategy/DataStrategyBase.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,7 @@ protected Boolean buildMigrationSql(TableMirror tableMirror, Environment origina
597597
if (config.getOptimization().isSkip()) {
598598
if (!config.getCluster(Environment.LEFT).isLegacyHive()) {
599599
assert targetEnvTable != null;
600-
targetEnvTable.addSql("Setting " + SORT_DYNAMIC_PARTITION, MessageFormat.format(SET_SESSION_VALUE, SORT_DYNAMIC_PARTITION, "false"));
600+
targetEnvTable.addSql("Setting " + SORT_DYNAMIC_PARTITION, MessageFormat.format(SET_SESSION_VALUE_STRING, SORT_DYNAMIC_PARTITION, "false"));
601601
}
602602
String partElement = TableUtils.getPartitionElements(original);
603603
String transferSql = MessageFormat.format(MirrorConf.SQL_DATA_TRANSFER_WITH_PARTITIONS_DECLARATIVE,
@@ -607,9 +607,9 @@ protected Boolean buildMigrationSql(TableMirror tableMirror, Environment origina
607607
targetEnvTable.addSql(new Pair(transferDesc, transferSql));
608608
} else if (config.getOptimization().isSortDynamicPartitionInserts()) {
609609
if (!config.getCluster(Environment.LEFT).isLegacyHive()) {
610-
targetEnvTable.addSql("Setting " + SORT_DYNAMIC_PARTITION, MessageFormat.format(SET_SESSION_VALUE, SORT_DYNAMIC_PARTITION, "true"));
610+
targetEnvTable.addSql("Setting " + SORT_DYNAMIC_PARTITION, MessageFormat.format(SET_SESSION_VALUE_STRING, SORT_DYNAMIC_PARTITION, "true"));
611611
if (!config.getCluster(Environment.LEFT).isHdpHive3()) {
612-
targetEnvTable.addSql("Setting " + SORT_DYNAMIC_PARTITION_THRESHOLD, MessageFormat.format(SET_SESSION_VALUE, SORT_DYNAMIC_PARTITION_THRESHOLD, "0"));
612+
targetEnvTable.addSql("Setting " + SORT_DYNAMIC_PARTITION_THRESHOLD, MessageFormat.format(SET_SESSION_VALUE_INT, SORT_DYNAMIC_PARTITION_THRESHOLD, 0));
613613
}
614614
}
615615
String partElement = TableUtils.getPartitionElements(original);
@@ -619,9 +619,9 @@ protected Boolean buildMigrationSql(TableMirror tableMirror, Environment origina
619619
targetEnvTable.addSql(new Pair(transferDesc, transferSql));
620620
} else {
621621
if (!config.getCluster(Environment.LEFT).isLegacyHive()) {
622-
targetEnvTable.addSql("Setting " + SORT_DYNAMIC_PARTITION, MessageFormat.format(SET_SESSION_VALUE, SORT_DYNAMIC_PARTITION, "false"));
622+
targetEnvTable.addSql("Setting " + SORT_DYNAMIC_PARTITION, MessageFormat.format(SET_SESSION_VALUE_STRING, SORT_DYNAMIC_PARTITION, "false"));
623623
if (!config.getCluster(Environment.LEFT).isHdpHive3()) {
624-
targetEnvTable.addSql("Setting " + SORT_DYNAMIC_PARTITION_THRESHOLD, MessageFormat.format(SET_SESSION_VALUE, SORT_DYNAMIC_PARTITION_THRESHOLD, "-1"));
624+
targetEnvTable.addSql("Setting " + SORT_DYNAMIC_PARTITION_THRESHOLD, MessageFormat.format(SET_SESSION_VALUE_INT, SORT_DYNAMIC_PARTITION_THRESHOLD, -1));
625625
}
626626
}
627627
String partElement = TableUtils.getPartitionElements(original);

src/main/java/com/cloudera/utils/hms/mirror/datastrategy/SQLAcidInPlaceDataStrategy.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ public Boolean buildOutSql(TableMirror tableMirror) throws MissingDataPointExcep
166166
if (let.getPartitioned()) {
167167
if (hmsMirrorConfig.getOptimization().isSkip()) {
168168
if (!hmsMirrorConfig.getCluster(Environment.LEFT).isLegacyHive()) {
169-
let.addSql("Setting " + SORT_DYNAMIC_PARTITION, MessageFormat.format(SET_SESSION_VALUE,SORT_DYNAMIC_PARTITION,"false"));
169+
let.addSql("Setting " + SORT_DYNAMIC_PARTITION, MessageFormat.format(SET_SESSION_VALUE_STRING,SORT_DYNAMIC_PARTITION,"false"));
170170
}
171171
String partElement = TableUtils.getPartitionElements(let);
172172
String transferSql = MessageFormat.format(MirrorConf.SQL_DATA_TRANSFER_WITH_PARTITIONS_DECLARATIVE,
@@ -175,9 +175,9 @@ public Boolean buildOutSql(TableMirror tableMirror) throws MissingDataPointExcep
175175
let.addSql(new Pair(transferDesc, transferSql));
176176
} else if (hmsMirrorConfig.getOptimization().isSortDynamicPartitionInserts()) {
177177
if (!hmsMirrorConfig.getCluster(Environment.LEFT).isLegacyHive()) {
178-
let.addSql("Setting " + SORT_DYNAMIC_PARTITION, MessageFormat.format(SET_SESSION_VALUE,SORT_DYNAMIC_PARTITION ,"true"));
178+
let.addSql("Setting " + SORT_DYNAMIC_PARTITION, MessageFormat.format(SET_SESSION_VALUE_STRING,SORT_DYNAMIC_PARTITION ,"true"));
179179
if (!hmsMirrorConfig.getCluster(Environment.LEFT).isHdpHive3()) {
180-
let.addSql("Setting " + SORT_DYNAMIC_PARTITION_THRESHOLD, MessageFormat.format(SET_SESSION_VALUE,SORT_DYNAMIC_PARTITION_THRESHOLD ,"0"));
180+
let.addSql("Setting " + SORT_DYNAMIC_PARTITION_THRESHOLD, MessageFormat.format(SET_SESSION_VALUE_INT,SORT_DYNAMIC_PARTITION_THRESHOLD , 0));
181181
}
182182
}
183183
String partElement = TableUtils.getPartitionElements(let);
@@ -188,9 +188,9 @@ public Boolean buildOutSql(TableMirror tableMirror) throws MissingDataPointExcep
188188
} else {
189189
// Prescriptive Optimization.
190190
if (!hmsMirrorConfig.getCluster(Environment.LEFT).isLegacyHive()) {
191-
let.addSql("Setting " + SORT_DYNAMIC_PARTITION, MessageFormat.format(SET_SESSION_VALUE,SORT_DYNAMIC_PARTITION ,"false"));
191+
let.addSql("Setting " + SORT_DYNAMIC_PARTITION, MessageFormat.format(SET_SESSION_VALUE_STRING,SORT_DYNAMIC_PARTITION ,"false"));
192192
if (!hmsMirrorConfig.getCluster(Environment.LEFT).isHdpHive3()) {
193-
let.addSql("Setting " + SORT_DYNAMIC_PARTITION_THRESHOLD, MessageFormat.format(SET_SESSION_VALUE,SORT_DYNAMIC_PARTITION_THRESHOLD ,"-1"));
193+
let.addSql("Setting " + SORT_DYNAMIC_PARTITION_THRESHOLD, MessageFormat.format(SET_SESSION_VALUE_INT,SORT_DYNAMIC_PARTITION_THRESHOLD , -1));
194194
}
195195
}
196196

src/main/java/com/cloudera/utils/hms/mirror/datastrategy/StorageMigrationDataStrategy.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ public Boolean build(TableMirror tableMirror) {
563563
// Build Partition Elements.
564564
if (config.getOptimization().isSkip()) {
565565
if (!config.getCluster(Environment.LEFT).isLegacyHive()) {
566-
let.addSql("Setting " + SORT_DYNAMIC_PARTITION, MessageFormat.format(SET_SESSION_VALUE, SORT_DYNAMIC_PARTITION, "false"));
566+
let.addSql("Setting " + SORT_DYNAMIC_PARTITION, MessageFormat.format(SET_SESSION_VALUE_STRING, SORT_DYNAMIC_PARTITION, "false"));
567567
}
568568
String partElement = TableUtils.getPartitionElements(let);
569569
String transferSql = MessageFormat.format(MirrorConf.SQL_DATA_TRANSFER_WITH_PARTITIONS_DECLARATIVE,
@@ -573,9 +573,9 @@ public Boolean build(TableMirror tableMirror) {
573573
} else if (config.getOptimization().isSortDynamicPartitionInserts()) {
574574
// Declarative
575575
if (!config.getCluster(Environment.LEFT).isLegacyHive()) {
576-
let.addSql("Setting " + SORT_DYNAMIC_PARTITION, MessageFormat.format(SET_SESSION_VALUE, SORT_DYNAMIC_PARTITION, "true"));
576+
let.addSql("Setting " + SORT_DYNAMIC_PARTITION, MessageFormat.format(SET_SESSION_VALUE_STRING, SORT_DYNAMIC_PARTITION, "true"));
577577
if (!config.getCluster(Environment.LEFT).isHdpHive3()) {
578-
let.addSql("Setting " + SORT_DYNAMIC_PARTITION_THRESHOLD, MessageFormat.format(SET_SESSION_VALUE, SORT_DYNAMIC_PARTITION_THRESHOLD, "0"));
578+
let.addSql("Setting " + SORT_DYNAMIC_PARTITION_THRESHOLD, MessageFormat.format(SET_SESSION_VALUE_INT, SORT_DYNAMIC_PARTITION_THRESHOLD, 0));
579579
}
580580
}
581581
String partElement = TableUtils.getPartitionElements(let);
@@ -586,9 +586,9 @@ public Boolean build(TableMirror tableMirror) {
586586
} else {
587587
// Prescriptive
588588
if (!config.getCluster(Environment.LEFT).isLegacyHive()) {
589-
let.addSql("Setting " + SORT_DYNAMIC_PARTITION, MessageFormat.format(SET_SESSION_VALUE, SORT_DYNAMIC_PARTITION, "false"));
589+
let.addSql("Setting " + SORT_DYNAMIC_PARTITION, MessageFormat.format(SET_SESSION_VALUE_STRING, SORT_DYNAMIC_PARTITION, "false"));
590590
if (!config.getCluster(Environment.LEFT).isHdpHive3()) {
591-
let.addSql("Setting " + SORT_DYNAMIC_PARTITION_THRESHOLD, MessageFormat.format(SET_SESSION_VALUE, SORT_DYNAMIC_PARTITION_THRESHOLD, "-1"));
591+
let.addSql("Setting " + SORT_DYNAMIC_PARTITION_THRESHOLD, MessageFormat.format(SET_SESSION_VALUE_INT, SORT_DYNAMIC_PARTITION_THRESHOLD, -1));
592592
}
593593
}
594594
String partElement = TableUtils.getPartitionElements(let);

src/main/java/com/cloudera/utils/hms/mirror/service/DomainService.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,13 @@ protected String fileToString(String configFilename) {
128128
}
129129

130130
public HmsMirrorConfig deserializeConfig(String configFilename) {
131-
HmsMirrorConfig config;
131+
HmsMirrorConfig config = null;
132132
log.info("Initializing Config.");
133133
String yamlCfgFile = fileToString(configFilename);
134+
if (isNull(yamlCfgFile)) {
135+
log.error("Couldn't locate configuration file: " + configFilename);
136+
return null;
137+
}
134138
try {
135139
config = yamlMapper.readerFor(HmsMirrorConfig.class).readValue(yamlCfgFile);
136140
} catch (JsonProcessingException e) {

0 commit comments

Comments
 (0)