Skip to content
Open
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 @@ -52,6 +52,8 @@ public class HadoopPinotFS extends BasePinotFS {
private static final String KEYTAB = "hadoop.kerberos.keytab";
private static final String HADOOP_CONF_PATH = "hadoop.conf.path";
private static final String WRITE_CHECKSUM = "hadoop.write.checksum";
private static final String GLOBAL_HADOOP_USER = "hadoop.user.name";
private static final String ALLOW_INSECURE = "hadoop.allow.insecure";

private org.apache.hadoop.fs.FileSystem _hadoopFS = null;
private org.apache.hadoop.conf.Configuration _hadoopConf;
Expand All @@ -63,7 +65,20 @@ public HadoopPinotFS() {
public void init(PinotConfiguration config) {
try {
_hadoopConf = getConf(config.getProperty(HADOOP_CONF_PATH));
authenticate(_hadoopConf, config);
boolean allowInsecure = Boolean.parseBoolean(config.getProperty(ALLOW_INSECURE, "false"));

if (!allowInsecure) {
authenticate(_hadoopConf, config);
} else {
String globalHadoopUser = config.getProperty(GLOBAL_HADOOP_USER);
if (Strings.isNullOrEmpty(globalHadoopUser)) {
throw new RuntimeException("HADOOP_USER must be provided when ALLOW_INSECURE is true");
}

UserGroupInformation ugi = UserGroupInformation.createRemoteUser(globalHadoopUser);
UserGroupInformation.setLoginUser(ugi);
LOGGER.info("Setting HDFS login user to: {}", globalHadoopUser);
}
_hadoopFS = org.apache.hadoop.fs.FileSystem.get(_hadoopConf);
_hadoopFS.setWriteChecksum((config.getProperty(WRITE_CHECKSUM, false)));
LOGGER.info("successfully initialized HadoopPinotFS");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -452,4 +452,20 @@ public void testDeleteBatchPerformanceWithManyFiles()
hadoopFS.delete(baseURI, true);
}
}

@Test
public void testInitWithUnauthenticatedUser()
throws IOException {
String testUser = "pinot-test-user-" + System.currentTimeMillis();

PinotConfiguration config = new PinotConfiguration();
config.setProperty("hadoop.allow.insecure", "true");
config.setProperty("hadoop.user.name", testUser);

try (HadoopPinotFS hadoopFS = new HadoopPinotFS()) {
hadoopFS.init(config);
String currentUser = org.apache.hadoop.security.UserGroupInformation.getLoginUser().getUserName();
Assert.assertEquals(currentUser, testUser, "The Hadoop login user was not set correctly!");
}
}
}