ulysses-you commented on code in PR #4913:
URL: https://github.com/apache/incubator-gluten/pull/4913#discussion_r1525704092


##########
gluten-celeborn/common/src/main/java/org/apache/spark/shuffle/gluten/celeborn/CelebornShuffleManager.java:
##########
@@ -284,24 +300,57 @@ public <K, V> ShuffleWriter<K, V> getWriter(
       ShuffleHandle handle, long mapId, TaskContext context, 
ShuffleWriteMetricsReporter metrics) {
     try {
       if (handle instanceof CelebornShuffleHandle) {
+        byte[] extension;
+        try {
+          Field field = 
CelebornShuffleHandle.class.getDeclaredField("extension");

Review Comment:
   ditto



##########
gluten-celeborn/common/src/main/java/org/apache/spark/shuffle/gluten/celeborn/CelebornShuffleManager.java:
##########
@@ -284,24 +300,57 @@ public <K, V> ShuffleWriter<K, V> getWriter(
       ShuffleHandle handle, long mapId, TaskContext context, 
ShuffleWriteMetricsReporter metrics) {
     try {
       if (handle instanceof CelebornShuffleHandle) {
+        byte[] extension;
+        try {
+          Field field = 
CelebornShuffleHandle.class.getDeclaredField("extension");
+          field.setAccessible(true);
+          extension = (byte[]) field.get(handle);
+
+        } catch (NoSuchFieldException e) {
+          extension = null;
+        }
         @SuppressWarnings("unchecked")
         CelebornShuffleHandle<K, V, V> h = ((CelebornShuffleHandle<K, V, V>) 
handle);
         ShuffleClient client =
-            getShuffleClient(
+            CelebornUtils.getShuffleClient(
                 h.appUniqueId(),
                 h.lifecycleManagerHost(),
                 h.lifecycleManagerPort(),
                 celebornConf,
                 h.userIdentifier(),
-                false);
+                false,
+                extension);
+
+        int shuffleId;
+
+        // for Celeborn 0.4.0
+        try {
+          Method celebornShuffleIdMethod =
+              SparkUtils.class.getMethod(
+                  "celebornShuffleId",
+                  ShuffleClient.class,
+                  CelebornShuffleHandle.class,
+                  TaskContext.class,
+                  boolean.class);
+          shuffleId = (int) celebornShuffleIdMethod.invoke(null, 
shuffleClient, h, context, true);

Review Comment:
   ditto



##########
gluten-celeborn/common/src/main/java/org/apache/spark/shuffle/gluten/celeborn/CelebornShuffleManager.java:
##########
@@ -220,6 +222,25 @@ public <K, V, C> ShuffleHandle registerShuffle(
       int shuffleId, ShuffleDependency<K, V, C> dependency) {
     appUniqueId = SparkUtils.appUniqueId(dependency.rdd().context());
     initializeLifecycleManager();
+
+    // for Celeborn 0.4.0
+    try {
+      Method registerAppShuffleDeterminateMethod =
+          lifecycleManager
+              .getClass()
+              .getDeclaredMethod("registerAppShuffleDeterminate", 
Integer.TYPE, Boolean.TYPE);
+
+      registerAppShuffleDeterminateMethod.invoke(

Review Comment:
   ditto



##########
pom.xml:
##########
@@ -47,7 +47,7 @@
     <sparkbundle.version>3.2</sparkbundle.version>
     <spark.version>3.4.2</spark.version>
     
<sparkshim.artifactId>spark-sql-columnar-shims-spark32</sparkshim.artifactId>
-    <celeborn.version>0.3.0-incubating</celeborn.version>
+    <celeborn.version>0.3.2-incubating</celeborn.version>

Review Comment:
   shall we add profile for 0.4 ?



##########
gluten-celeborn/common/src/main/java/org/apache/spark/shuffle/gluten/celeborn/CelebornShuffleManager.java:
##########
@@ -190,27 +158,61 @@ private void initializeLifecycleManager() {
       synchronized (this) {
         if (lifecycleManager == null) {
           lifecycleManager = new LifecycleManager(appUniqueId, celebornConf);
+
+          // for Celeborn 0.4.0
+          try {
+            if (throwsFetchFailure) {
+              MapOutputTrackerMaster mapOutputTracker =
+                  (MapOutputTrackerMaster) SparkEnv.get().mapOutputTracker();
+
+              Method registerShuffleTrackerCallbackMethod =
+                  lifecycleManager
+                      .getClass()
+                      .getDeclaredMethod("registerShuffleTrackerCallback", 
Consumer.class);
+
+              Consumer<Integer> consumer =
+                  shuffleId -> {
+                    try {
+                      Method unregisterAllMapOutputMethod =
+                          SparkUtils.class.getMethod(
+                              "unregisterAllMapOutput", 
MapOutputTrackerMaster.class, int.class);
+                      unregisterAllMapOutputMethod.invoke(null, 
mapOutputTracker, shuffleId);
+                    } catch (Exception e) {
+                      throw new RuntimeException(e);
+                    }
+                  };
+
+              registerShuffleTrackerCallbackMethod.invoke(lifecycleManager, 
consumer);

Review Comment:
   ditto



##########
gluten-celeborn/common/src/main/java/org/apache/spark/shuffle/gluten/celeborn/CelebornShuffleManager.java:
##########
@@ -99,6 +107,18 @@ public CelebornShuffleManager(SparkConf conf) {
     this.conf = conf;
     this.celebornConf = SparkUtils.fromSparkConf(conf);
     this.fallbackPolicyRunner = new 
CelebornShuffleFallbackPolicyRunner(celebornConf);
+
+    this.shuffleIdTracker =
+        
CelebornUtils.createInstance(CelebornUtils.EXECUTOR_SHUFFLE_ID_TRACKER_NAME);
+    try {
+      Method clientFetchThrowsFetchFailureMethod =
+          
celebornConf.getClass().getDeclaredMethod("clientFetchThrowsFetchFailure");
+      this.throwsFetchFailure = (Boolean) 
clientFetchThrowsFetchFailureMethod.invoke(celebornConf);

Review Comment:
   I think such reflect can be moved to `CelebornUtils`



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to