Skip to content

Commit

Permalink
Move impersonation check to DefaultRubixHdfsInitializer
Browse files Browse the repository at this point in the history
  • Loading branch information
sopel39 committed Aug 6, 2020
1 parent ff9f050 commit 2a5de1c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@
import com.google.inject.Module;
import io.airlift.configuration.AbstractConfigurationAwareModule;
import io.prestosql.plugin.hive.authentication.HiveAuthenticationConfig.HdfsAuthenticationType;
import io.prestosql.plugin.hive.rubix.RubixEnabledConfig;

import java.util.function.Predicate;

import static com.google.common.base.Preconditions.checkArgument;
import static io.airlift.configuration.ConditionalModule.installModuleIf;
import static io.prestosql.plugin.hive.authentication.AuthenticationModules.kerberosHdfsAuthenticationModule;
import static io.prestosql.plugin.hive.authentication.AuthenticationModules.kerberosImpersonatingHdfsAuthenticationModule;
Expand Down Expand Up @@ -49,10 +47,6 @@ protected void setup(Binder binder)
bindAuthenticationModule(
config -> kerberosHdfsAuth(config) && config.isHdfsImpersonationEnabled(),
kerberosImpersonatingHdfsAuthenticationModule());

checkArgument(
!buildConfigObject(HiveAuthenticationConfig.class).isHdfsImpersonationEnabled() || !buildConfigObject(RubixEnabledConfig.class).isCacheEnabled(),
"Hdfs impersonation is not compatible with Hive caching");
}

private void bindAuthenticationModule(Predicate<HiveAuthenticationConfig> predicate, Module module)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.google.inject.Scopes;
import com.qubole.rubix.prestosql.CachingPrestoDistributedFileSystem;
import io.prestosql.plugin.hive.DynamicConfigurationProvider;
import io.prestosql.plugin.hive.authentication.HiveAuthenticationConfig;
import org.apache.hadoop.conf.Configuration;

import java.util.Set;
Expand All @@ -38,6 +39,7 @@ public class RubixModule
public void configure(Binder binder)
{
configBinder(binder).bindConfig(RubixConfig.class);
configBinder(binder).bindConfig(HiveAuthenticationConfig.class);
binder.bind(RubixConfigurationInitializer.class).in(Scopes.SINGLETON);
binder.bind(RubixInitializer.class).in(Scopes.SINGLETON);
// Make initialization of Rubix happen just once.
Expand Down Expand Up @@ -65,6 +67,12 @@ private RubixStarter(RubixInitializer rubixInitializer, Set<DynamicConfiguration
static class DefaultRubixHdfsInitializer
implements RubixHdfsInitializer
{
@Inject
public DefaultRubixHdfsInitializer(HiveAuthenticationConfig authenticationConfig)
{
checkArgument(!authenticationConfig.isHdfsImpersonationEnabled(), "Hdfs impersonation is not compatible with Hive caching");
}

@Override
public void initializeConfiguration(Configuration config)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import io.prestosql.plugin.hive.HdfsEnvironment.HdfsContext;
import io.prestosql.plugin.hive.HiveConfig;
import io.prestosql.plugin.hive.HiveHdfsConfiguration;
import io.prestosql.plugin.hive.authentication.HiveAuthenticationConfig;
import io.prestosql.plugin.hive.authentication.NoHdfsAuthentication;
import io.prestosql.plugin.hive.orc.OrcReaderConfig;
import io.prestosql.plugin.hive.rubix.RubixConfig.ReadMode;
Expand Down Expand Up @@ -187,7 +188,7 @@ private void initializeRubix(RubixConfig rubixConfig, List<Node> nodes)
nodeManager,
new CatalogName("catalog"),
configurationInitializer,
new DefaultRubixHdfsInitializer());
new DefaultRubixHdfsInitializer(new HiveAuthenticationConfig()));
rubixConfigInitializer = new RubixConfigurationInitializer(rubixInitializer);
rubixInitializer.initializeRubix();
retry().run("wait for rubix to startup", () -> {
Expand Down Expand Up @@ -303,7 +304,7 @@ public void testCoordinatorNotJoining()
new TestingNodeManager(ImmutableList.of(workerNode)),
new CatalogName("catalog"),
configurationInitializer,
new DefaultRubixHdfsInitializer());
new DefaultRubixHdfsInitializer(new HiveAuthenticationConfig()));
assertThatThrownBy(rubixInitializer::initializeRubix)
.hasMessage("No coordinator node available");
}
Expand Down

0 comments on commit 2a5de1c

Please sign in to comment.