Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#445] feat(lakehouse-iceberg): support load HDFS config files for Iceberg REST server #468

Merged
merged 2 commits into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ private static InMemoryCatalog loadMemoryCatalog(Map<String, String> properties)

private static HiveCatalog loadHiveCatalog(Map<String, String> properties) {
HiveCatalog hiveCatalog = new HiveCatalog();
hiveCatalog.setConf(new HdfsConfiguration());
hiveCatalog.initialize("hive", properties);
return hiveCatalog;
}
Expand All @@ -59,6 +60,7 @@ public static Catalog loadCatalogBackend(String catalogType, Map<String, String>
// TODO Organize the configuration properties and adapt them to the lower layer, and map some
// graviton configuration keys.
LOG.info("Load catalog backend of {}", catalogType);

switch (catalogType.toLowerCase(Locale.ENGLISH)) {
case "memory":
return loadMemoryCatalog(properties);
Expand Down
3 changes: 2 additions & 1 deletion conf/graviton.conf.template
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ graviton.catalog.cache.evictionIntervalMs = 3600000
# Auxiliary service names, separate by ','
graviton.auxService.names = iceberg-rest
# Iceberg REST service classpath
graviton.auxService.iceberg-rest.classpath = catalogs/lakehouse-iceberg/libs
graviton.auxService.iceberg-rest.classpath = catalogs/lakehouse-iceberg/libs, catalogs/lakehouse-iceberg/conf
# Iceberg REST service host
graviton.auxService.iceberg-rest.host = 127.0.0.1
# Iceberg REST service http port
graviton.auxService.iceberg-rest.httpPort = 9001

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import com.google.common.base.Preconditions;
import com.google.common.base.Splitter;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.common.collect.Streams;
import java.nio.file.Files;
import java.nio.file.Path;
Expand Down Expand Up @@ -86,12 +85,6 @@ public IsolatedClassLoader getIsolatedClassLoader(List<String> classPaths) {

@VisibleForTesting
static String getValidPath(String auxServiceName, String pathString) {
Preconditions.checkArgument(
StringUtils.isNoneBlank(pathString),
String.format(
"AuxService:%s, %s%s.%s is not set in configuration",
auxServiceName, GRAVITON_AUX_SERVICE_PREFIX, auxServiceName, AUX_SERVICE_CLASSPATH));

Path path = Paths.get(pathString);
if (Files.exists(path)) {
return path.toAbsolutePath().toString();
Expand All @@ -112,11 +105,24 @@ static String getValidPath(String auxServiceName, String pathString) {
}

private void registerAuxService(String auxServiceName, Map<String, String> config) {
String classPath = config.get(AUX_SERVICE_CLASSPATH);
classPath = getValidPath(auxServiceName, classPath);
LOG.info("AuxService name:{}, config:{}, classpath:{}", auxServiceName, config, classPath);
String classpath = config.get(AUX_SERVICE_CLASSPATH);
Preconditions.checkArgument(
StringUtils.isNoneBlank(classpath),
String.format(
"AuxService:%s, %s%s.%s is not set in configuration",
auxServiceName, GRAVITON_AUX_SERVICE_PREFIX, auxServiceName, AUX_SERVICE_CLASSPATH));

List<String> validPaths =
splitter
.trimResults()
.omitEmptyStrings()
.splitToStream(classpath)
.map(path -> getValidPath(auxServiceName, path))
.collect(Collectors.toList());
LOG.info(
"AuxService name:{}, config:{}, valid classpath:{}", auxServiceName, config, validPaths);

IsolatedClassLoader isolatedClassLoader = getIsolatedClassLoader(Lists.newArrayList(classPath));
IsolatedClassLoader isolatedClassLoader = getIsolatedClassLoader(validPaths);
try {
GravitonAuxiliaryService gravitonAuxiliaryService =
loadAuxService(auxServiceName, isolatedClassLoader);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,14 +169,16 @@ private void customizeConfigFile(String configTempFileName, String configFileNam
+ AuxiliaryServiceManager.AUX_SERVICE_NAMES,
IcebergRESTService.SERVICE_NAME);

String icebergClassPath =
String icebergJarPath =
Paths.get("catalogs", "catalog-lakehouse-iceberg", "build", "libs").toString();
String icebergConfigPath =
Paths.get("catalogs", "catalog-lakehouse-iceberg", "src", "main", "resources").toString();
configMap.put(
AuxiliaryServiceManager.GRAVITON_AUX_SERVICE_PREFIX
+ IcebergRESTService.SERVICE_NAME
+ "."
+ AuxiliaryServiceManager.AUX_SERVICE_CLASSPATH,
icebergClassPath);
String.join(",", icebergJarPath, icebergConfigPath));
configMap.put(
AuxiliaryServiceManager.GRAVITON_AUX_SERVICE_PREFIX
+ IcebergRESTService.SERVICE_NAME
Expand Down
Loading