AHeise commented on a change in pull request #17958:
URL: https://github.com/apache/flink/pull/17958#discussion_r761381259
##########
File path:
flink-runtime/src/main/java/org/apache/flink/runtime/taskmanager/Task.java
##########
@@ -431,6 +433,14 @@ public Task(
// finally, create the executing thread, but do not start it
executingThread = new Thread(TASK_THREADS_GROUP, this,
taskNameWithSubtask);
+
+ //add CallerContext
+ //JID => jobID, JName => jobName, TName => TaskName, and with attempt
number end.
+ String callerContext = "Flink_Task_"+ "JID_" + jobId +
+ "_TName_" + taskInfo.getTaskName() +
+ "_" + taskInfo.getAttemptNumber();
+
HadoopUtils.setCallerContext(tmConfig.getOptional(ExecutionOptions.CALLER_CONTEXT_APP_ID)
Review comment:
Calling this method here assumes that Hadoop is on the classpath, which
is rarely the case. So your solution will work but only if there is a hadoop
and fail for all cases.
You probably want to use a service loader mechanism somehow. Maybe we should
add a new module `flink-hadoop-utils` containing such a service that is in
flink-dist/opt and that hadoop users can copy to flink-dist/lib.
##########
File path:
flink-core/src/main/java/org/apache/flink/configuration/ExecutionOptions.java
##########
@@ -105,6 +105,14 @@
+ "throughput"))
.build());
+ public static final ConfigOption<String> CALLER_CONTEXT_APP_ID =
+ ConfigOptions.key("execution.caller-context-app-id")
+ .stringType()
+ .defaultValue("")
Review comment:
This default value is never used.
##########
File path:
flink-core/src/main/java/org/apache/flink/configuration/ExecutionOptions.java
##########
@@ -105,6 +105,14 @@
+ "throughput"))
.build());
+ public static final ConfigOption<String> CALLER_CONTEXT_APP_ID =
Review comment:
👍 to make it configurable
##########
File path:
flink-runtime/src/main/java/org/apache/flink/runtime/taskmanager/Task.java
##########
@@ -431,6 +433,14 @@ public Task(
// finally, create the executing thread, but do not start it
executingThread = new Thread(TASK_THREADS_GROUP, this,
taskNameWithSubtask);
+
+ //add CallerContext
+ //JID => jobID, JName => jobName, TName => TaskName, and with attempt
number end.
Review comment:
Just spell it out instead of using uncommon abbreviations.
##########
File path:
flink-filesystems/flink-hadoop-fs/src/main/java/org/apache/flink/runtime/util/HadoopUtils.java
##########
@@ -247,4 +248,43 @@ private static boolean addHadoopConfIfFound(
}
return foundHadoopConfiguration;
}
+
+ /**
+ * Set up the caller context [[callerContext]] by invoking Hadoop
CallerContext API of
+ * [[org.apache.hadoop.ipc.CallerContext]], which was added in hadoop 2.8.
+ */
+ public static void setCallerContext(String callerContext,
+
org.apache.flink.configuration.Configuration flinkConfig) {
+ if (isMinHadoopVersion(2,8)) {
+ try {
+ callerContext = truncateCallerContext(callerContext,
flinkConfig);
+ Class callerContextClass =
Class.forName("org.apache.hadoop.ipc.CallerContext");
+ Class builder =
Class.forName("org.apache.hadoop.ipc.CallerContext$Builder");
+ Constructor builderInst =
builder.getConstructor(callerContext.getClass());
+ callerContextClass.getMethod("setCurrent", callerContextClass)
+ .invoke(null, builder.getMethod("build")
+
.invoke(builderInst.newInstance(callerContext)));
Review comment:
We could avoid reflection if we bump Hadoop min version to 2.8. But
that's probably a bigger effort that should be independent. If you want to take
that as a prerequisite, I could create a new ticket.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]