Skip to content

Commit 79924c5

Browse files
HIVE-28965: tez.DagUtils: Failed to add credential supplier, ClassNotFoundException: org.apache.hadoop.hive.kafka.KafkaDagCredentialSupplier (#6081)
1 parent ad55d58 commit 79924c5

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

ql/src/java/org/apache/hadoop/hive/ql/exec/tez/DagUtils.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
import java.util.Stack;
4646
import java.util.concurrent.TimeUnit;
4747
import java.util.function.Predicate;
48+
import java.util.function.Supplier;
4849
import java.util.regex.Matcher;
4950
import java.util.regex.Pattern;
5051
import java.util.zip.ZipOutputStream;
@@ -179,13 +180,13 @@ public class DagUtils {
179180
public static final String TEZ_TMP_DIR_KEY = "_hive_tez_tmp_dir";
180181
private static final Logger LOG = LoggerFactory.getLogger(DagUtils.class.getName());
181182
private static final String TEZ_DIR = "_tez_scratch_dir";
182-
private static final DagUtils instance = new DagUtils(defaultCredentialSuppliers());
183+
private static final DagUtils instance = new DagUtils(DagUtils::defaultCredentialSuppliers);
183184
// The merge file being currently processed.
184185
public static final String TEZ_MERGE_CURRENT_MERGE_FILE_PREFIX =
185186
"hive.tez.current.merge.file.prefix";
186187
// A comma separated list of work names used as prefix.
187188
public static final String TEZ_MERGE_WORK_FILE_PREFIXES = "hive.tez.merge.file.prefixes";
188-
private final List<DagCredentialSupplier> credentialSuppliers;
189+
private final Supplier<List<DagCredentialSupplier>> credentialSuppliers;
189190
/**
190191
* Notifiers to synchronize resource localization across threads. If one thread is localizing
191192
* a file, other threads can wait on the corresponding notifier object instead of just sleeping
@@ -286,7 +287,7 @@ private void getCredentialsFromSuppliers(BaseWork work, Set<TableDesc> tables, D
286287
if (!UserGroupInformation.isSecurityEnabled()){
287288
return;
288289
}
289-
for (DagCredentialSupplier supplier : credentialSuppliers) {
290+
for (DagCredentialSupplier supplier : credentialSuppliers.get()) {
290291
Text alias = supplier.getTokenAlias();
291292
Token<?> t = dag.getCredentials().getToken(alias);
292293
if (t != null) {
@@ -1697,7 +1698,7 @@ public static String getUserSpecifiedDagName(Configuration conf) {
16971698
}
16981699

16991700
@VisibleForTesting
1700-
DagUtils(List<DagCredentialSupplier> suppliers) {
1701+
DagUtils(Supplier<List<DagCredentialSupplier>> suppliers) {
17011702
this.credentialSuppliers = suppliers;
17021703
}
17031704

ql/src/test/org/apache/hadoop/hive/ql/exec/tez/TestDagUtilsSecurityEnabled.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public static void clear() {
5959
@Test
6060
public void testAddCredentialsWithCredentialSupplierNewTokenAdded() {
6161
IncrementalIntDagCredentialSupplier supplier = new IncrementalIntDagCredentialSupplier();
62-
DagUtils dagUtils = new DagUtils(Collections.singletonList(supplier));
62+
DagUtils dagUtils = new DagUtils(() -> Collections.singletonList(supplier));
6363
DAG dag = DAG.create("test_credentials_dag");
6464

6565
dagUtils.addCredentials(mock(MapWork.class), dag, null);
@@ -70,7 +70,7 @@ public void testAddCredentialsWithCredentialSupplierNewTokenAdded() {
7070
@Test
7171
public void testAddCredentialsWithCredentialSupplierTokenExistsNothingAdded() {
7272
IncrementalIntDagCredentialSupplier supplier = new IncrementalIntDagCredentialSupplier();
73-
DagUtils dagUtils = new DagUtils(Collections.singletonList(supplier));
73+
DagUtils dagUtils = new DagUtils(() -> Collections.singletonList(supplier));
7474
DAG dag = DAG.create("test_credentials_dag");
7575
Token<TokenIdentifier> oldToken = new Token<>();
7676
// Add explicitly the token in the DAG before calling addCredentials simulating the use-case where the DAG has already the token

0 commit comments

Comments
 (0)