0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 package test.org.apache.spark;
0019
0020 import java.util.Map;
0021
0022 import org.apache.spark.TaskContext;
0023 import org.apache.spark.resource.ResourceInformation;
0024 import org.apache.spark.util.TaskCompletionListener;
0025 import org.apache.spark.util.TaskFailureListener;
0026
0027
0028
0029
0030 public class JavaTaskContextCompileCheck {
0031
0032 public static void test() {
0033 TaskContext tc = TaskContext.get();
0034
0035 tc.isCompleted();
0036 tc.isInterrupted();
0037
0038 tc.addTaskCompletionListener(new JavaTaskCompletionListenerImpl());
0039 tc.addTaskFailureListener(new JavaTaskFailureListenerImpl());
0040
0041 tc.attemptNumber();
0042 tc.partitionId();
0043 tc.stageId();
0044 tc.stageAttemptNumber();
0045 tc.taskAttemptId();
0046
0047 tc.resources();
0048 Map<String, ResourceInformation> resources = tc.resourcesJMap();
0049 tc.taskMetrics();
0050 tc.taskMemoryManager();
0051 tc.getLocalProperties();
0052 }
0053
0054
0055
0056
0057
0058 static class JavaTaskCompletionListenerImpl implements TaskCompletionListener {
0059 @Override
0060 public void onTaskCompletion(TaskContext context) {
0061 context.isCompleted();
0062 context.isInterrupted();
0063 context.stageId();
0064 context.stageAttemptNumber();
0065 context.partitionId();
0066 context.addTaskCompletionListener(this);
0067 }
0068 }
0069
0070
0071
0072
0073
0074 static class JavaTaskFailureListenerImpl implements TaskFailureListener {
0075 @Override
0076 public void onTaskFailure(TaskContext context, Throwable error) {
0077 }
0078 }
0079
0080 }