Skip to content

Commit e283d6e

Browse files
committed
Non Configs blocking WEB UI Create: #122
SCHEMA_ONLY with ALIGNED, DISTCP and Partitions is too granular on partition distcp: #123 Expose rid in web ui: #121
1 parent 8e7c568 commit e283d6e

File tree

3 files changed

+14
-88
lines changed

3 files changed

+14
-88
lines changed

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.2.0.6</version>
31+
<version>2.2.0.7</version>
3232
<packaging>jar</packaging>
3333

3434
<name>hms-mirror</name>

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

Lines changed: 5 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -48,68 +48,8 @@ public class TranslatorService {
4848

4949
@Getter
5050
private ExecuteSessionService executeSessionService = null;
51-
// @Getter
52-
// private ConfigService configService = null;
53-
54-
// private ConfigService configService;
5551
private DatabaseService databaseService;
5652

57-
// @Autowired
58-
// public void setConfigService(ConfigService configService) {
59-
// this.configService = configService;
60-
// }
61-
62-
/**
63-
* @param consolidationLevel how far up the directory hierarchy to go to build the distcp list based on the sources
64-
* provided.
65-
* @return A map of databases. Each database will have a map that has 1 or more 'targets' and 'x' sources for each
66-
* target.
67-
*/
68-
// public synchronized Map<String, Map<String, Set<String>>> buildDistcpList(String database, Environment environment, int consolidationLevel) {
69-
// Map<String, Map<String, Set<String>>> rtn = new TreeMap<>();
70-
//
71-
// HmsMirrorConfig hmsMirrorConfig = executeSessionService.getSession().getConfig();
72-
//
73-
// // get the map for a db.
74-
// Set<String> databases = hmsMirrorConfig.getTranslator().getTranslationMap().keySet();
75-
//
76-
// // get the map.entry
77-
// Map<String, Set<String>> reverseMap = new TreeMap<>();
78-
// // Get a static view of set to avoid concurrent modification.
79-
// Set<EnvironmentMap.TranslationLevel> dbTranslationLevel =
80-
// new HashSet<>(hmsMirrorConfig.getTranslator().getTranslationMap(database, environment));
81-
//
82-
// Map<String, String> dbLocationMap = new TreeMap<>();
83-
//
84-
// for (EnvironmentMap.TranslationLevel translationLevel : dbTranslationLevel) {
85-
// if (translationLevel.getOriginal() != null &&
86-
// translationLevel.getTarget() != null) {
87-
// dbLocationMap.put(translationLevel.getAdjustedOriginal(), translationLevel.getAdjustedTarget());
88-
// }
89-
// }
90-
//
91-
// for (Map.Entry<String, String> entry : dbLocationMap.entrySet()) {
92-
// // reduce folder level by 'consolidationLevel' for key and value.
93-
// // Source
94-
// String reducedSource = UrlUtils.reduceUrlBy(entry.getKey(), consolidationLevel);
95-
// // Target
96-
// String reducedTarget = UrlUtils.reduceUrlBy(entry.getValue(), consolidationLevel);
97-
//
98-
// if (reverseMap.get(reducedTarget) != null) {
99-
// reverseMap.get(reducedTarget).add(entry.getKey());
100-
// } else {
101-
// Set<String> sourceSet = new TreeSet<String>();
102-
// sourceSet.add(entry.getKey());
103-
// reverseMap.put(reducedTarget, sourceSet);
104-
// }
105-
//
106-
// }
107-
// if (!reverseMap.isEmpty()) {
108-
// rtn.put(database, reverseMap);
109-
// }
110-
// return rtn;
111-
// }
112-
11353
public String buildPartitionAddStatement(EnvironmentTable environmentTable) {
11454
StringBuilder sbPartitionDetails = new StringBuilder();
11555
Map<String, String> partitions = new HashMap<String, String>();
@@ -187,7 +127,10 @@ public Boolean translatePartitionLocations(TableMirror tblMirror) throws Require
187127
for (Map.Entry<String, String> entry : partitionLocationMap.entrySet()) {
188128
String partitionLocation = entry.getValue();
189129
String partSpec = entry.getKey();
190-
int level = StringUtils.countMatches(partSpec, "/") + 1;
130+
// First level partitions are +2 from the DB level. So we need to add 2 to the level.
131+
// EG: The spec for a single partition will have level 1.
132+
String spec[] = partSpec.split("/");
133+
int level = spec.length + 1;
191134
// Increase level to the table, since we're not filter any tables. It's assumed that
192135
// we're pulling the whole DB.
193136
// if (!config.getFilter().isTableFiltering()) {
@@ -258,8 +201,6 @@ public String translateLocation(TableMirror tableMirror, String originalLocation
258201

259202
if (config.getDataStrategy() == DataStrategyEnum.STORAGE_MIGRATION
260203
&& origNamespace.equals(config.getTransfer().getTargetNamespace())) {
261-
// tableMirror.addIssue(Environment.LEFT, "Location Mapping can't be determined. No matching `glm` entry to make translation." +
262-
// "Original Location: " + originalLocation);
263204
tableMirror.setPhaseState(PhaseState.ERROR);
264205
throw new MissingDataPointException("Location Mapping can't be determined. No matching `glm` entry to make translation." +
265206
"Original Location: " + originalLocation);
@@ -381,8 +322,6 @@ public Map<String, Map<TableType, String>> getGlobalLocationMap() {
381322
}
382323

383324
public Map<String, Map<TableType, String>> buildGlobalLocationMapFromWarehousePlansAndSources(boolean dryrun, int consolidationLevel) throws MismatchException, SessionException {
384-
// Don't reload if running.
385-
// executeSessionService.clearActiveSession();
386325

387326
HmsMirrorConfig config = executeSessionService.getSession().getConfig();
388327

@@ -427,7 +366,6 @@ public Map<String, Map<TableType, String>> buildGlobalLocationMapFromWarehousePl
427366
*/
428367

429368
for (Map.Entry<String, Warehouse> warehouseEntry : warehousePlans.entrySet()) {
430-
// String database = warehouseEntry.getKey();
431369
String database = HmsMirrorConfigUtil.getResolvedDB(warehouseEntry.getKey(), config);
432370
Warehouse warehouse = warehouseEntry.getValue();
433371
String externalBaseLocation = warehouse.getExternalDirectory();
@@ -438,32 +376,12 @@ public Map<String, Map<TableType, String>> buildGlobalLocationMapFromWarehousePl
438376
String typeTargetLocation = null;
439377
String extTargetLocation = new String(externalBaseLocation + "/" + database + ".db");
440378
String mngdTargetLocation = new String(managedBaseLocation + "/" + database + ".db");
441-
// Set the location based on the table type.
442-
443-
// switch (sourceLocationEntry.getKey()) {
444-
// case EXTERNAL_TABLE:
445-
// typeTargetLocation = externalBaseLocation;
446-
// break;
447-
// case MANAGED_TABLE:
448-
// typeTargetLocation = managedBaseLocation;
449-
// break;
450-
// }
451-
// typeTargetLocation = typeTargetLocation + "/" + database + ".db";
379+
452380
// Locations and the tables that are in that location.
453381
for (Map.Entry<String, Set<String>> sourceLocationSet : sourceLocationEntry.getValue().entrySet()) {
454382
String sourceLocation = new String(sourceLocationSet.getKey());
455383
// Strip the namespace from the location.
456384
sourceLocation = NamespaceUtils.stripNamespace(sourceLocation); //.replace(hmsMirrorConfig.getCluster(Environment.LEFT).getHcfsNamespace(), "");
457-
// I don't think this is relevant anymore, since we switch the namespace stripping to not required the LEFT hcfsNamespace.
458-
// if (config.getTransfer().getStorageMigration().isStrict() && (!sourceLocation.startsWith("/") || (sourceLocation.length() == sourceLocationSet.getKey().length()))) {
459-
// // Issue with reducing the location.
460-
// // This happens when the table(s) location doesn't match the source namespace.
461-
// throw new MismatchException("Location doesn't start with the configured namespace. This is a problem"
462-
// + " and doesn't allow for the location to be converted to the new namespace."
463-
// + " Location: " + sourceLocationSet.getKey() + " Database: " + database + " Type: " + sourceLocationEntry.getKey()
464-
// + " containing tables: " + String.join(",", sourceLocationSet.getValue())
465-
// + " HCFS Namespace: " + config.getCluster(Environment.LEFT).getHcfsNamespace());
466-
// }
467385

468386
// NOTE: The locations were already reduced by '1' when the Sources were built.
469387
// This removed the 'table' directory from the location and allows for them to

src/main/java/com/cloudera/utils/hms/mirror/web/service/WebConfigService.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,14 @@ public boolean accept(File dir, String name) {
103103
}
104104
}
105105
}
106+
107+
// Handle the case where no valid config files are found. This will help get us past the chicken and egg scenario
108+
// with the UI/
109+
if (configList.isEmpty()) {
110+
configList.add("--non defined--");
111+
log.warn("No valid config files found in the config directory: " + cfgPath);
112+
}
113+
106114
return configList;
107115
}
108116

0 commit comments

Comments
 (0)