Commit bc57e15e by Sarath Subramanian

ATLAS-2549: Regression with respect to Partition keys

parent 8ef6a436
...@@ -152,50 +152,44 @@ public class AtlasTypeDefStoreInitializer implements ActiveStateChangeHandler { ...@@ -152,50 +152,44 @@ public class AtlasTypeDefStoreInitializer implements ActiveStateChangeHandler {
File[] typeDefFiles = typesDir.exists() ? typesDir.listFiles() : null; File[] typeDefFiles = typesDir.exists() ? typesDir.listFiles() : null;
if (typeDefFiles == null || typeDefFiles.length == 0) { if (typeDefFiles == null || typeDefFiles.length == 0) {
LOG.info("Types directory {} does not exist or not readable or has no typedef files", typesDirName); LOG.info("Types directory {} does not exist or not readable or has no typedef files", typesDirName );
} else { } else {
// sort the files by filename // sort the files by filename
Arrays.sort(typeDefFiles); Arrays.sort(typeDefFiles);
for (File typeDefFile : typeDefFiles) {
try {
readTypesFromFile(typeDefFile);
} catch (Throwable t) {
LOG.error("error while registering types in file {}", typeDefFile.getAbsolutePath(), t);
}
}
}
LOG.info("<== AtlasTypeDefStoreInitializer({})", typesDir); for (File typeDefFile : typeDefFiles) {
} if (typeDefFile.isFile()) {
try {
String jsonStr = new String(Files.readAllBytes(typeDefFile.toPath()), StandardCharsets.UTF_8);
AtlasTypesDef typesDef = AtlasType.fromJson(jsonStr, AtlasTypesDef.class);
public void readTypesFromFile(File typeDefFile) { if (typesDef == null || typesDef.isEmpty()) {
if (!typeDefFile.isFile()) { LOG.info("No type in file {}", typeDefFile.getAbsolutePath());
return;
}
try { continue;
String jsonStr = new String(Files.readAllBytes(typeDefFile.toPath()), StandardCharsets.UTF_8); }
AtlasTypesDef typesDef = AtlasType.fromJson(jsonStr, AtlasTypesDef.class);
if (typesDef == null || typesDef.isEmpty()) { AtlasTypesDef typesToCreate = getTypesToCreate(typesDef, atlasTypeRegistry);
LOG.info("No type in file {}", typeDefFile.getAbsolutePath()); AtlasTypesDef typesToUpdate = getTypesToUpdate(typesDef, atlasTypeRegistry, true);
return;
}
AtlasTypesDef typesToCreate = getTypesToCreate(typesDef, atlasTypeRegistry); if (!typesToCreate.isEmpty() || !typesToUpdate.isEmpty()) {
AtlasTypesDef typesToUpdate = getTypesToUpdate(typesDef, atlasTypeRegistry, true); atlasTypeDefStore.createUpdateTypesDef(typesToCreate, typesToUpdate);
if (!typesToCreate.isEmpty() || !typesToUpdate.isEmpty()) { LOG.info("Created/Updated types defined in file {}", typeDefFile.getAbsolutePath());
atlasTypeDefStore.createUpdateTypesDef(typesToCreate, typesToUpdate); } else {
LOG.info("No new type in file {}", typeDefFile.getAbsolutePath());
}
LOG.info("Created/Updated types defined in file {}", typeDefFile.getAbsolutePath()); } catch (Throwable t) {
} else { LOG.error("error while registering types in file {}", typeDefFile.getAbsolutePath(), t);
LOG.info("No new type in file {}", typeDefFile.getAbsolutePath()); }
}
} }
} catch (Throwable t) { applyTypePatches(typesDir.getPath());
LOG.error("error while registering types in file {}", typeDefFile.getAbsolutePath(), t);
} }
LOG.info("<== AtlasTypeDefStoreInitializer({})", typesDir);
} }
public static AtlasTypesDef getTypesToCreate(AtlasTypesDef typesDef, AtlasTypeRegistry typeRegistry) { public static AtlasTypesDef getTypesToCreate(AtlasTypesDef typesDef, AtlasTypeRegistry typeRegistry) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment