You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@celeborn.apache.org by "FMX (via GitHub)" <gi...@apache.org> on 2023/08/23 11:59:46 UTC
[GitHub] [incubator-celeborn] FMX opened a new pull request, #1830: [Celeborn-839] Support mapreduce client
FMX opened a new pull request, #1830:
URL: https://github.com/apache/incubator-celeborn/pull/1830
### What changes were proposed in this pull request?
1. Map side merge and push.
2. Support hadoop2 & 3.
3. Reduce in-memory merge.
4. Integrate LifecycleManager to RmApplicationMaster.
### Why are the changes needed?
Ditto.
### Does this PR introduce _any_ user-facing change?
NO.
### How was this patch tested?
Cluster.
--
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: issues-unsubscribe@celeborn.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-celeborn] cfmcgrady commented on a diff in pull request #1830: [CELEBORN-839][MR] Support Hadoop MapReduce
Posted by "cfmcgrady (via GitHub)" <gi...@apache.org>.
cfmcgrady commented on code in PR #1830:
URL: https://github.com/apache/incubator-celeborn/pull/1830#discussion_r1309770221
##########
client-mr/mr-shaded/pom.xml:
##########
@@ -0,0 +1,149 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+~ Licensed to the Apache Software Foundation (ASF) under one or more
+~ contributor license agreements. See the NOTICE file distributed with
+~ this work for additional information regarding copyright ownership.
+~ The ASF licenses this file to You under the Apache License, Version 2.0
+~ (the "License"); you may not use this file except in compliance with
+~ the License. You may obtain a copy of the License at
+~
+~ http://www.apache.org/licenses/LICENSE-2.0
+~
+~ Unless required by applicable law or agreed to in writing, software
+~ distributed under the License is distributed on an "AS IS" BASIS,
+~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+~ See the License for the specific language governing permissions and
+~ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.celeborn</groupId>
+ <artifactId>celeborn-parent_${scala.binary.version}</artifactId>
+ <version>${project.version}</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>celeborn-client-mr-shaded-${hadoop.version}</artifactId>
+ <packaging>jar</packaging>
+ <name>Celeborn Shaded Client for MapReduce</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.celeborn</groupId>
+ <artifactId>celeborn-client-mr-${hadoop.version}</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-shade-plugin</artifactId>
+ <configuration>
+ <relocations>
+ <relocation>
+ <pattern>com.google.protobuf</pattern>
+ <shadedPattern>${shading.prefix}.com.google.protobuf</shadedPattern>
+ </relocation>
+ <relocation>
+ <pattern>com.google.common</pattern>
+ <shadedPattern>${shading.prefix}.com.google.common</shadedPattern>
+ </relocation>
+ <relocation>
+ <pattern>io.netty</pattern>
+ <shadedPattern>${shading.prefix}.io.netty</shadedPattern>
+ </relocation>
+ <relocation>
+ <pattern>org.apache.commons</pattern>
+ <shadedPattern>${shading.prefix}.org.apache.commons</shadedPattern>
+ </relocation>
+ <relocation>
+ <pattern>com.fasterxml.jackson.core</pattern>
Review Comment:
but the Celeborn client doesn't need Jackson at runtime, right?
--
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: issues-unsubscribe@celeborn.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-celeborn] FMX commented on a diff in pull request #1830: [CELEBORN-839][MR] Support Hadoop MapReduce
Posted by "FMX (via GitHub)" <gi...@apache.org>.
FMX commented on code in PR #1830:
URL: https://github.com/apache/incubator-celeborn/pull/1830#discussion_r1318000082
##########
client-mr/mr/src/main/java/org/apache/hadoop/mapreduce/task/reduce/CelebornShuffleFetcher.java:
##########
@@ -0,0 +1,224 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.mapreduce.task.reduce;
+
+import java.io.IOException;
+import java.lang.reflect.Field;
+
+import org.apache.hadoop.io.compress.CodecPool;
+import org.apache.hadoop.io.compress.Decompressor;
+import org.apache.hadoop.mapred.Counters;
+import org.apache.hadoop.mapred.Reporter;
+import org.apache.hadoop.mapred.TaskStatus;
+import org.apache.hadoop.mapreduce.TaskAttemptID;
+import org.apache.hadoop.mapreduce.TaskID;
+import org.apache.hadoop.mapreduce.TaskType;
+import org.apache.hadoop.util.Progress;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.celeborn.client.read.CelebornInputStream;
+import org.apache.celeborn.common.exception.CelebornIOException;
+import org.apache.celeborn.common.unsafe.Platform;
+
+public class CelebornShuffleFetcher<K, V> {
+ private static final Logger logger = LoggerFactory.getLogger(CelebornShuffleFetcher.class);
+ private final TaskAttemptID reduceId;
+ private final Reporter reporter;
+ private final TaskStatus status;
+ private final MergeManager<K, V> merger;
+ private final Progress progress;
+ private final ShuffleClientMetrics metrics;
+ private final CelebornInputStream celebornInputStream;
+ private volatile boolean stopped = false;
+ private int uniqueMapId = 0;
+ private final Counters.Counter ioErrs;
+ private boolean hasPendingData = false;
+ private long inputShuffleSize;
+ private byte[] shuffleData;
+
+ public CelebornShuffleFetcher(
+ TaskAttemptID reduceId,
+ TaskStatus status,
+ MergeManager<K, V> merger,
+ Progress progress,
+ Reporter reporter,
+ ShuffleClientMetrics metrics,
+ CelebornInputStream input) {
+ this.reduceId = reduceId;
+ this.reporter = reporter;
+ this.status = status;
+ this.merger = merger;
+ this.progress = progress;
+ this.metrics = metrics;
+ this.celebornInputStream = input;
+
+ ioErrs = reporter.getCounter("Shuffle Errors", "IO_ERROR");
+ }
+
+ // fetch all push data and merge
+ public void fetchAndMerge() {
+ while (!stopped) {
+ try {
+ // If merge is on, block
+ merger.waitForResource();
+ // Do shuffle
+ metrics.threadBusy();
+ // read blocks
+ fetchToLocalAndMerge();
+ } catch (Exception e) {
+ logger.error("Celeborn shuffle fetcher fetch data failed.", e);
+ } finally {
+ metrics.threadFree();
+ }
+ }
+ }
+
+ private byte[] getShuffleBlock() throws IOException {
+ // get len
+ byte[] header = new byte[4];
+ int count = celebornInputStream.read(header);
+ if (count == -1) {
+ stopped = true;
+ return null;
+ }
+ while (count != header.length) {
+ count += celebornInputStream.read(header, count, 4 - count);
+ }
+
+ // get data
+ int blockLen = Platform.getInt(header, Platform.BYTE_ARRAY_OFFSET);
+ inputShuffleSize += blockLen;
+ byte[] shuffleData = new byte[blockLen];
+ count = 0;
+ count = celebornInputStream.read(shuffleData);
+ while (count != shuffleData.length) {
+ count += celebornInputStream.read(shuffleData, count, blockLen - count);
+ if (count == -1) {
+ // read shuffle is done.
+ stopped = true;
+ throw new CelebornIOException("Read mr shuffle failed.");
+ }
+ }
+ return shuffleData;
+ }
+
+ private void fetchToLocalAndMerge() throws IOException {
+ if (!hasPendingData) {
+ shuffleData = getShuffleBlock();
+ }
+
+ if (shuffleData != null) {
+ // start to merge
+ if (wrapMapOutput(shuffleData)) {
+ hasPendingData = false;
+ } else {
+ return;
+ }
+
+ updateStatus();
+ reporter.progress();
+ } else {
+ celebornInputStream.close();
+ metrics.inputBytes(inputShuffleSize);
+ logger.info("reduce task {} read {} bytes", reduceId, inputShuffleSize);
+ stopped = true;
+ }
+ }
+
+ private boolean wrapMapOutput(byte[] shuffleData) throws IOException {
+ // treat push data as mapoutput
+ TaskAttemptID mapId =
+ new TaskAttemptID(new TaskID(reduceId.getJobID(), TaskType.MAP, uniqueMapId++), 0);
+ MapOutput<K, V> mapOutput = null;
+ try {
+ mapOutput = merger.reserve(mapId, shuffleData.length, 0);
+ } catch (IOException ioe) {
+ ioErrs.increment(1);
+ throw ioe;
+ }
+ if (mapOutput == null) {
+ logger.info(
+ "Celeborn fetcher returned status wait because reserve buffer for shuffle get null");
+ hasPendingData = true;
+ return false;
+ }
+
+ // write data to mapOutput
+ try {
+ writeShuffle(mapOutput, shuffleData);
+ // let the merger knows this block is ready for merging
+ mapOutput.commit();
+ } catch (Throwable t) {
+ ioErrs.increment(1);
+ mapOutput.abort();
+ throw new CelebornIOException(
+ "Reduce: {} "
+ + reduceId
+ + " fetch failed to {} "
+ + mapOutput.getClass().getSimpleName()
+ + " due to: {} "
+ + t.getClass().getName());
+ }
+ return true;
+ }
+
+ private Decompressor getDecompressor(InMemoryMapOutput inMemoryMapOutput)
+ throws CelebornIOException {
+ try {
+ Class clazz = Class.forName(InMemoryMapOutput.class.getName());
+ Field deCompressorField = clazz.getDeclaredField("decompressor");
+ deCompressorField.setAccessible(true);
+ return (Decompressor) deCompressorField.get(inMemoryMapOutput);
+ } catch (Exception e) {
+ throw new CelebornIOException("Get Decompressor fail " + e.getMessage());
+ }
+ }
+
+ private void writeShuffle(MapOutput mapOutput, byte[] shuffle) throws CelebornIOException {
+ if (mapOutput instanceof InMemoryMapOutput) {
+ InMemoryMapOutput inMemoryMapOutput = (InMemoryMapOutput) mapOutput;
+ CodecPool.returnDecompressor(getDecompressor(inMemoryMapOutput));
+ byte[] memory = inMemoryMapOutput.getMemory();
+ System.arraycopy(shuffle, 0, memory, 0, shuffle.length);
+ } else if (mapOutput instanceof OnDiskMapOutput) {
Review Comment:
Reduce will spill shuffle to local disks and do out-of-memory merge sort.
--
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: issues-unsubscribe@celeborn.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-celeborn] pan3793 commented on a diff in pull request #1830: [CELEBORN-839][MR] Support Hadoop MapReduce
Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on code in PR #1830:
URL: https://github.com/apache/incubator-celeborn/pull/1830#discussion_r1321742485
##########
pom.xml:
##########
@@ -383,6 +378,32 @@
<artifactId>snakeyaml</artifactId>
<version>${snakeyaml.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.hadoop</groupId>
+ <artifactId>${hadoop-client-api.artifact}</artifactId>
+ <version>${hadoop.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.hadoop</groupId>
+ <artifactId>${hadoop-client-runtime.artifact}</artifactId>
+ <version>${hadoop.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.hadoop</groupId>
+ <artifactId>hadoop-mapreduce-client-app</artifactId>
Review Comment:
BTW, is it already under MR job classpath? if then, it could be marked as provided
--
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: issues-unsubscribe@celeborn.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-celeborn] pan3793 commented on a diff in pull request #1830: [CELEBORN-839][MR] Support Hadoop MapReduce
Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on code in PR #1830:
URL: https://github.com/apache/incubator-celeborn/pull/1830#discussion_r1321728674
##########
client-mr/mr/pom.xml:
##########
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+~ Licensed to the Apache Software Foundation (ASF) under one or more
+~ contributor license agreements. See the NOTICE file distributed with
+~ this work for additional information regarding copyright ownership.
+~ The ASF licenses this file to You under the Apache License, Version 2.0
+~ (the "License"); you may not use this file except in compliance with
+~ the License. You may obtain a copy of the License at
+~
+~ http://www.apache.org/licenses/LICENSE-2.0
+~
+~ Unless required by applicable law or agreed to in writing, software
+~ distributed under the License is distributed on an "AS IS" BASIS,
+~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+~ See the License for the specific language governing permissions and
+~ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.celeborn</groupId>
+ <artifactId>celeborn-parent_${scala.binary.version}</artifactId>
+ <version>${project.version}</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>celeborn-client-mr-${hadoop.version}</artifactId>
Review Comment:
BTW, as it's a jar depends on scala, the suffix `_${scala.binary.version}` should be added
--
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: issues-unsubscribe@celeborn.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-celeborn] FMX commented on a diff in pull request #1830: [CELEBORN-839][MR] Support Hadoop MapReduce
Posted by "FMX (via GitHub)" <gi...@apache.org>.
FMX commented on code in PR #1830:
URL: https://github.com/apache/incubator-celeborn/pull/1830#discussion_r1323815191
##########
pom.xml:
##########
@@ -64,9 +64,14 @@
<maven.version>3.8.8</maven.version>
<flink.version>1.14.6</flink.version>
- <hadoop.version>3.2.4</hadoop.version>
<spark.version>3.3.2</spark.version>
+ <!-- use hadoop-3 as default -->
+ <hadoop.version>3.2.4</hadoop.version>
+ <hadoop-client-api.artifact>hadoop-client-api</hadoop-client-api.artifact>
Review Comment:
Won't do this. Running mr integration test will need to shade celeborn worker and master, this is awful.
--
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: issues-unsubscribe@celeborn.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-celeborn] FMX commented on a diff in pull request #1830: [CELEBORN-839][MR] Support Hadoop MapReduce
Posted by "FMX (via GitHub)" <gi...@apache.org>.
FMX commented on code in PR #1830:
URL: https://github.com/apache/incubator-celeborn/pull/1830#discussion_r1323857165
##########
client-mr/mr/pom.xml:
##########
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+~ Licensed to the Apache Software Foundation (ASF) under one or more
+~ contributor license agreements. See the NOTICE file distributed with
+~ this work for additional information regarding copyright ownership.
+~ The ASF licenses this file to You under the Apache License, Version 2.0
+~ (the "License"); you may not use this file except in compliance with
+~ the License. You may obtain a copy of the License at
+~
+~ http://www.apache.org/licenses/LICENSE-2.0
+~
+~ Unless required by applicable law or agreed to in writing, software
+~ distributed under the License is distributed on an "AS IS" BASIS,
+~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+~ See the License for the specific language governing permissions and
+~ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.celeborn</groupId>
+ <artifactId>celeborn-parent_${scala.binary.version}</artifactId>
+ <version>${project.version}</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>celeborn-client-mr-${hadoop.version}</artifactId>
Review Comment:
I think this is a good idea. I'll remove hadoop-2 profile.
--
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: issues-unsubscribe@celeborn.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-celeborn] FMX commented on a diff in pull request #1830: [CELEBORN-839][MR] Support Hadoop MapReduce
Posted by "FMX (via GitHub)" <gi...@apache.org>.
FMX commented on code in PR #1830:
URL: https://github.com/apache/incubator-celeborn/pull/1830#discussion_r1312461121
##########
pom.xml:
##########
@@ -64,9 +64,14 @@
<maven.version>3.8.8</maven.version>
<flink.version>1.14.6</flink.version>
- <hadoop.version>3.2.4</hadoop.version>
<spark.version>3.3.2</spark.version>
+ <!-- use hadoop-3 as default -->
+ <hadoop.version>3.2.4</hadoop.version>
Review Comment:
Hadoop client 3.3.6 can not access hadoop 2.x HDFS. So we can not use hadoop 3.3.6 now.
--
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: issues-unsubscribe@celeborn.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-celeborn] FMX commented on pull request #1830: [CELEBORN-839][MR] Support Hadoop MapReduce
Posted by "FMX (via GitHub)" <gi...@apache.org>.
FMX commented on PR #1830:
URL: https://github.com/apache/incubator-celeborn/pull/1830#issuecomment-1718483005
@pan3793 @cfmcgrady All comments are addressed, how about now?
--
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: issues-unsubscribe@celeborn.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-celeborn] SteNicholas commented on pull request #1830: [CELEBORN-839][MR] Support Hadoop MapReduce
Posted by "SteNicholas (via GitHub)" <gi...@apache.org>.
SteNicholas commented on PR #1830:
URL: https://github.com/apache/incubator-celeborn/pull/1830#issuecomment-1695152469
@waitinfuture, I will take a review today.
--
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: issues-unsubscribe@celeborn.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-celeborn] waitinfuture commented on pull request #1830: [Celeborn-839] Support Hadoop MapReduce
Posted by "waitinfuture (via GitHub)" <gi...@apache.org>.
waitinfuture commented on PR #1830:
URL: https://github.com/apache/incubator-celeborn/pull/1830#issuecomment-1694216175
cc @JQ-Cao @SteNicholas
--
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: issues-unsubscribe@celeborn.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-celeborn] FMX commented on a diff in pull request #1830: [CELEBORN-839][MR] Support Hadoop MapReduce
Posted by "FMX (via GitHub)" <gi...@apache.org>.
FMX commented on code in PR #1830:
URL: https://github.com/apache/incubator-celeborn/pull/1830#discussion_r1312479821
##########
client-mr/mr/src/main/java/org/apache/hadoop/mapreduce/task/reduce/CelebornShuffleConsumer.java:
##########
@@ -0,0 +1,173 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.mapreduce.task.reduce;
+
+import java.io.IOException;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import org.apache.hadoop.mapred.*;
+import org.apache.hadoop.mapreduce.task.reduce.Shuffle.ShuffleError;
+import org.apache.hadoop.util.Progress;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.celeborn.client.ShuffleClient;
+import org.apache.celeborn.client.read.CelebornInputStream;
+import org.apache.celeborn.common.CelebornConf;
+import org.apache.celeborn.common.identity.UserIdentifier;
+import org.apache.celeborn.util.HadoopUtils;
+
+public class CelebornShuffleConsumer<K, V>
+ implements ShuffleConsumerPlugin<K, V>, ExceptionReporter {
+ private static final Logger logger = LoggerFactory.getLogger(CelebornShuffleConsumer.class);
+ private JobConf mrJobConf;
+ private MergeManager<K, V> merger;
+ private Throwable throwable = null;
+ private Progress copyPhase;
+ private TaskStatus taskStatus;
+ private org.apache.hadoop.mapreduce.TaskAttemptID reduceId;
+ private TaskUmbilicalProtocol umbilical;
+ private Reporter reporter;
+ private ShuffleClientMetrics metrics;
+ private Task reduceTask;
+
+ private ShuffleClient shuffleClient;
+
+ @Override
+ public void init(Context<K, V> context) {
+
+ reduceId = context.getReduceId();
+ mrJobConf = context.getJobConf();
+ JobConf celebornJobConf = new JobConf(HadoopUtils.MR_CELEBORN_CONF);
+
+ umbilical = context.getUmbilical();
+ reporter = context.getReporter();
+ try {
+ this.metrics = createMetrics(reduceId, mrJobConf);
+ } catch (Exception e) {
+ logger.error("Fatal error occurred, failed to get shuffle client metrics.", e);
+ reportException(e);
+ }
+ copyPhase = context.getCopyPhase();
+ taskStatus = context.getStatus();
+ reduceTask = context.getReduceTask();
+
+ String appId = celebornJobConf.get(HadoopUtils.MR_CELEBORN_APPLICATION_ID);
+ String lcHost = celebornJobConf.get(HadoopUtils.MR_CELEBORN_LC_HOST);
+ int lcPort = Integer.parseInt(celebornJobConf.get(HadoopUtils.MR_CELEBORN_LC_PORT));
+ logger.info("Reducer initialized with celeborn {} {} {}", appId, lcHost, lcPort);
+ CelebornConf celebornConf = HadoopUtils.fromYarnConf(mrJobConf);
+ shuffleClient =
+ ShuffleClient.get(
+ appId,
+ lcHost,
+ lcPort,
+ celebornConf,
+ new UserIdentifier(
+ celebornConf.quotaUserSpecificTenant(), celebornConf.quotaUserSpecificUserName()));
+ this.merger = createMergeManager(context);
+ }
+
+ // Merge mapOutput and spill in local disks if necessary
+ protected MergeManager<K, V> createMergeManager(ShuffleConsumerPlugin.Context context) {
+ return new MergeManagerImpl<K, V>(
+ reduceId,
+ mrJobConf,
+ context.getLocalFS(),
+ context.getLocalDirAllocator(),
+ reporter,
+ context.getCodec(),
+ context.getCombinerClass(),
+ context.getCombineCollector(),
+ context.getSpilledRecordsCounter(),
+ context.getReduceCombineInputCounter(),
+ context.getMergedMapOutputsCounter(),
+ this,
+ context.getMergePhase(),
+ context.getMapOutputFile());
+ }
+
+ private ShuffleClientMetrics createMetrics(
+ org.apache.hadoop.mapreduce.TaskAttemptID taskAttemptID, JobConf jobConf)
+ throws NoSuchMethodException, InvocationTargetException, InstantiationException,
+ IllegalAccessException {
+ // for hadoop 3
Review Comment:
Sounds good to me. I'll try it.
--
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: issues-unsubscribe@celeborn.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-celeborn] pan3793 commented on a diff in pull request #1830: [CELEBORN-839][MR] Support Hadoop MapReduce
Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on code in PR #1830:
URL: https://github.com/apache/incubator-celeborn/pull/1830#discussion_r1321727744
##########
client-mr/mr/pom.xml:
##########
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+~ Licensed to the Apache Software Foundation (ASF) under one or more
+~ contributor license agreements. See the NOTICE file distributed with
+~ this work for additional information regarding copyright ownership.
+~ The ASF licenses this file to You under the Apache License, Version 2.0
+~ (the "License"); you may not use this file except in compliance with
+~ the License. You may obtain a copy of the License at
+~
+~ http://www.apache.org/licenses/LICENSE-2.0
+~
+~ Unless required by applicable law or agreed to in writing, software
+~ distributed under the License is distributed on an "AS IS" BASIS,
+~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+~ See the License for the specific language governing permissions and
+~ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.celeborn</groupId>
+ <artifactId>celeborn-parent_${scala.binary.version}</artifactId>
+ <version>${project.version}</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>celeborn-client-mr-${hadoop.version}</artifactId>
Review Comment:
I think we only need to create a jar with suffixes when version-specific APIs are involved, otherwise, prefer to produce a unified jar and handle the API changes via reflection.
--
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: issues-unsubscribe@celeborn.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-celeborn] pan3793 commented on a diff in pull request #1830: [CELEBORN-839][MR] Support Hadoop MapReduce
Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on code in PR #1830:
URL: https://github.com/apache/incubator-celeborn/pull/1830#discussion_r1321558937
##########
client-mr/mr/pom.xml:
##########
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+~ Licensed to the Apache Software Foundation (ASF) under one or more
+~ contributor license agreements. See the NOTICE file distributed with
+~ this work for additional information regarding copyright ownership.
+~ The ASF licenses this file to You under the Apache License, Version 2.0
+~ (the "License"); you may not use this file except in compliance with
+~ the License. You may obtain a copy of the License at
+~
+~ http://www.apache.org/licenses/LICENSE-2.0
+~
+~ Unless required by applicable law or agreed to in writing, software
+~ distributed under the License is distributed on an "AS IS" BASIS,
+~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+~ See the License for the specific language governing permissions and
+~ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.celeborn</groupId>
+ <artifactId>celeborn-parent_${scala.binary.version}</artifactId>
+ <version>${project.version}</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>celeborn-client-mr-${hadoop.version}</artifactId>
Review Comment:
Seems a little bit inconsistent with Spark and Flink. Do we really use version-specific APIs of Hadoop MapReduce?
--
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: issues-unsubscribe@celeborn.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-celeborn] SteNicholas commented on a diff in pull request #1830: [CELEBORN-839][MR] Support Hadoop MapReduce
Posted by "SteNicholas (via GitHub)" <gi...@apache.org>.
SteNicholas commented on code in PR #1830:
URL: https://github.com/apache/incubator-celeborn/pull/1830#discussion_r1307416346
##########
README.md:
##########
@@ -41,12 +41,12 @@ Celeborn Worker's slot count is decided by `total usable disk size / average shu
Celeborn worker's slot count decreases when a partition is allocated and increments when a partition is freed.
## Build
-1.Celeborn supports Spark 2.4/3.0/3.1/3.2/3.3/3.4 and flink 1.14/1.15/1.17.
+1.Celeborn supports Spark 2.4/3.0/3.1/3.2/3.3/3.4 and flink 1.14/1.15/1.17 and mr hadoop-2/hadoop-3.
2.Celeborn tested under Java 8 environment.
Build Celeborn
```shell
-./build/make-distribution.sh -Pspark-2.4/-Pspark-3.0/-Pspark-3.1/-Pspark-3.2/-Pspark-3.3/-Pspark-3.4/-Pflink-1.14/-Pflink-1.15/-Pflink-1.17
+./build/make-distribution.sh -Pspark-2.4/-Pspark-3.0/-Pspark-3.1/-Pspark-3.2/-Pspark-3.3/-Pspark-3.4/-Pflink-1.14/-Pflink-1.15/-Pflink-1.17/-Phadoop-2,mr/-Pmr
Review Comment:
Could this describe how to build celeborn with hadoop 3?
##########
build/make-distribution.sh:
##########
@@ -218,22 +218,43 @@ function build_flink_client {
cp "$PROJECT_DIR"/client-flink/flink-$FLINK_BINARY_VERSION-shaded/target/celeborn-client-flink-${FLINK_BINARY_VERSION}-shaded_$SCALA_VERSION-$VERSION.jar "$DIST_DIR/flink/"
}
+function build_mr_client {
+ HADOOP_VERSION=$("$MVN" help:evaluate -Dexpression=hadoop.version $@ 2>/dev/null \
+ | grep -v "INFO" \
+ | grep -v "WARNING" \
+ | tail -n 1)
+ BUILD_COMMAND=("$MVN" clean package $MVN_DIST_OPT -pl :celeborn-client-mr-shaded-${HADOOP_VERSION} -am $@)
+
+ # Actually build the jar
+ echo -e "\nBuilding with..."
+ echo -e "\$ ${BUILD_COMMAND[@]}\n"
+
+ "${BUILD_COMMAND[@]}"
+
+ ## flink spark client jars
+ mkdir -p "$DIST_DIR/mr"
+ cp "$PROJECT_DIR"/client-mr/mr-shaded/target/celeborn-client-mr-shaded-${HADOOP_VERSION}-$VERSION.jar "$DIST_DIR/mr/"
+}
+
if [ "$RELEASE" == "true" ]; then
build_service
build_spark_client -Pspark-2.4
build_spark_client -Pspark-3.4
build_flink_client -Pflink-1.14
build_flink_client -Pflink-1.15
build_flink_client -Pflink-1.17
+ build_mr_client -Phadoop-2,mr
Review Comment:
Does this need to build with default hadoop version which is hadoop 3 default?
##########
client-mr/mr/src/main/java/org/apache/hadoop/mapreduce/task/reduce/CelebornShuffleConsumer.java:
##########
@@ -0,0 +1,173 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.mapreduce.task.reduce;
+
+import java.io.IOException;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import org.apache.hadoop.mapred.*;
+import org.apache.hadoop.mapreduce.task.reduce.Shuffle.ShuffleError;
+import org.apache.hadoop.util.Progress;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.celeborn.client.ShuffleClient;
+import org.apache.celeborn.client.read.CelebornInputStream;
+import org.apache.celeborn.common.CelebornConf;
+import org.apache.celeborn.common.identity.UserIdentifier;
+import org.apache.celeborn.util.HadoopUtils;
+
+public class CelebornShuffleConsumer<K, V>
+ implements ShuffleConsumerPlugin<K, V>, ExceptionReporter {
+ private static final Logger logger = LoggerFactory.getLogger(CelebornShuffleConsumer.class);
+ private JobConf mrJobConf;
+ private MergeManager<K, V> merger;
+ private Throwable throwable = null;
+ private Progress copyPhase;
+ private TaskStatus taskStatus;
+ private org.apache.hadoop.mapreduce.TaskAttemptID reduceId;
+ private TaskUmbilicalProtocol umbilical;
+ private Reporter reporter;
+ private ShuffleClientMetrics metrics;
+ private Task reduceTask;
+
+ private ShuffleClient shuffleClient;
+
+ @Override
+ public void init(Context<K, V> context) {
+
+ reduceId = context.getReduceId();
+ mrJobConf = context.getJobConf();
+ JobConf celebornJobConf = new JobConf(HadoopUtils.MR_CELEBORN_CONF);
+
+ umbilical = context.getUmbilical();
+ reporter = context.getReporter();
+ try {
+ this.metrics = createMetrics(reduceId, mrJobConf);
+ } catch (Exception e) {
+ logger.error("Fatal error occurred, failed to get shuffle client metrics.", e);
+ reportException(e);
+ }
+ copyPhase = context.getCopyPhase();
+ taskStatus = context.getStatus();
+ reduceTask = context.getReduceTask();
+
+ String appId = celebornJobConf.get(HadoopUtils.MR_CELEBORN_APPLICATION_ID);
+ String lcHost = celebornJobConf.get(HadoopUtils.MR_CELEBORN_LC_HOST);
+ int lcPort = Integer.parseInt(celebornJobConf.get(HadoopUtils.MR_CELEBORN_LC_PORT));
+ logger.info("Reducer initialized with celeborn {} {} {}", appId, lcHost, lcPort);
+ CelebornConf celebornConf = HadoopUtils.fromYarnConf(mrJobConf);
+ shuffleClient =
+ ShuffleClient.get(
+ appId,
+ lcHost,
+ lcPort,
+ celebornConf,
+ new UserIdentifier(
+ celebornConf.quotaUserSpecificTenant(), celebornConf.quotaUserSpecificUserName()));
+ this.merger = createMergeManager(context);
+ }
+
+ // Merge mapOutput and spill in local disks if necessary
+ protected MergeManager<K, V> createMergeManager(ShuffleConsumerPlugin.Context context) {
+ return new MergeManagerImpl<K, V>(
+ reduceId,
+ mrJobConf,
+ context.getLocalFS(),
+ context.getLocalDirAllocator(),
+ reporter,
+ context.getCodec(),
+ context.getCombinerClass(),
+ context.getCombineCollector(),
+ context.getSpilledRecordsCounter(),
+ context.getReduceCombineInputCounter(),
+ context.getMergedMapOutputsCounter(),
+ this,
+ context.getMergePhase(),
+ context.getMapOutputFile());
+ }
+
+ private ShuffleClientMetrics createMetrics(
+ org.apache.hadoop.mapreduce.TaskAttemptID taskAttemptID, JobConf jobConf)
+ throws NoSuchMethodException, InvocationTargetException, InstantiationException,
+ IllegalAccessException {
+ // for hadoop 3
+ Method createMethod = null;
+ try {
+ ShuffleClientMetrics.class.getDeclaredMethod(
+ "create", org.apache.hadoop.mapreduce.TaskAttemptID.class, JobConf.class);
+ } catch (Exception e) {
+ // ignore this exception because
+ }
+ if (createMethod != null) {
+ return (ShuffleClientMetrics) createMethod.invoke(null, taskAttemptID, jobConf);
+ }
+ // for hadoop 2
+ Constructor constructor =
+ ShuffleClientMetrics.class.getDeclaredConstructor(
+ org.apache.hadoop.mapreduce.TaskAttemptID.class, JobConf.class);
+ constructor.setAccessible(true);
+ return (ShuffleClientMetrics) constructor.newInstance(taskAttemptID, jobConf);
+ }
+
+ @Override
+ public RawKeyValueIterator run() throws IOException, InterruptedException {
+ logger.info(
+ "In reduce:{}, Celeborn mr client start to read shuffle data."
+ + " Create inputstream with params: shuffleId 0 reduceId:{} attemptId:{}",
+ reduceId,
+ reduceId.getTaskID().getId(),
+ reduceId.getId());
+
+ CelebornInputStream shuffleInputStream =
+ shuffleClient.readPartition(
+ 0, reduceId.getTaskID().getId(), reduceId.getId(), 0, Integer.MAX_VALUE);
+ CelebornShuffleFetcher<K, V> shuffleReader =
+ new CelebornShuffleFetcher(
+ reduceId, taskStatus, merger, copyPhase, reporter, metrics, shuffleInputStream);
+ shuffleReader.fetchAndMerge();
+
+ copyPhase.complete();
+ taskStatus.setPhase(TaskStatus.Phase.SORT);
+ reduceTask.statusUpdate(umbilical);
+
+ // Finish the on-going merges...
+ RawKeyValueIterator kvIter = null;
+ try {
+ kvIter = merger.close();
+ } catch (Throwable e) {
+ throw new ShuffleError("Error while doing final merge ", e);
+ }
+
+ logger.info("In reduce: " + reduceId + ", Celeborn mr client read shuffle data complete");
+
+ return kvIter;
+ }
+
+ @Override
+ public void close() {}
Review Comment:
Does the `shuffleClient` need to close?
##########
tests/mr-it/src/test/java/org/apache/celeborn/tests/mr/WordCountTest.java:
##########
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.celeborn.tests.mr;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.Random;
+
+import com.google.common.collect.Lists;
+import org.apache.hadoop.fs.FSDataOutputStream;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.io.IntWritable;
+import org.apache.hadoop.io.Text;
+import org.apache.hadoop.mapred.FileInputFormat;
+import org.apache.hadoop.mapred.FileOutputFormat;
+import org.apache.hadoop.mapred.JobConf;
+import org.apache.hadoop.mapreduce.Job;
+import org.apache.hadoop.util.Tool;
+import org.junit.Ignore;
+import org.junit.Test;
+
+// This test case is ignored because of class dependencies conflicts.
+@Ignore
Review Comment:
If the test case is ignored, could this remove in this pull request?
##########
client-mr/mr/src/main/java/org/apache/hadoop/mapreduce/task/reduce/CelebornShuffleConsumer.java:
##########
@@ -0,0 +1,173 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.mapreduce.task.reduce;
+
+import java.io.IOException;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import org.apache.hadoop.mapred.*;
+import org.apache.hadoop.mapreduce.task.reduce.Shuffle.ShuffleError;
+import org.apache.hadoop.util.Progress;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.celeborn.client.ShuffleClient;
+import org.apache.celeborn.client.read.CelebornInputStream;
+import org.apache.celeborn.common.CelebornConf;
+import org.apache.celeborn.common.identity.UserIdentifier;
+import org.apache.celeborn.util.HadoopUtils;
+
+public class CelebornShuffleConsumer<K, V>
+ implements ShuffleConsumerPlugin<K, V>, ExceptionReporter {
+ private static final Logger logger = LoggerFactory.getLogger(CelebornShuffleConsumer.class);
+ private JobConf mrJobConf;
+ private MergeManager<K, V> merger;
+ private Throwable throwable = null;
+ private Progress copyPhase;
+ private TaskStatus taskStatus;
+ private org.apache.hadoop.mapreduce.TaskAttemptID reduceId;
+ private TaskUmbilicalProtocol umbilical;
+ private Reporter reporter;
+ private ShuffleClientMetrics metrics;
+ private Task reduceTask;
+
+ private ShuffleClient shuffleClient;
+
+ @Override
+ public void init(Context<K, V> context) {
+
+ reduceId = context.getReduceId();
+ mrJobConf = context.getJobConf();
+ JobConf celebornJobConf = new JobConf(HadoopUtils.MR_CELEBORN_CONF);
+
+ umbilical = context.getUmbilical();
+ reporter = context.getReporter();
+ try {
+ this.metrics = createMetrics(reduceId, mrJobConf);
+ } catch (Exception e) {
+ logger.error("Fatal error occurred, failed to get shuffle client metrics.", e);
+ reportException(e);
+ }
+ copyPhase = context.getCopyPhase();
+ taskStatus = context.getStatus();
+ reduceTask = context.getReduceTask();
+
+ String appId = celebornJobConf.get(HadoopUtils.MR_CELEBORN_APPLICATION_ID);
+ String lcHost = celebornJobConf.get(HadoopUtils.MR_CELEBORN_LC_HOST);
+ int lcPort = Integer.parseInt(celebornJobConf.get(HadoopUtils.MR_CELEBORN_LC_PORT));
+ logger.info("Reducer initialized with celeborn {} {} {}", appId, lcHost, lcPort);
+ CelebornConf celebornConf = HadoopUtils.fromYarnConf(mrJobConf);
+ shuffleClient =
+ ShuffleClient.get(
+ appId,
+ lcHost,
+ lcPort,
+ celebornConf,
+ new UserIdentifier(
+ celebornConf.quotaUserSpecificTenant(), celebornConf.quotaUserSpecificUserName()));
+ this.merger = createMergeManager(context);
+ }
+
+ // Merge mapOutput and spill in local disks if necessary
+ protected MergeManager<K, V> createMergeManager(ShuffleConsumerPlugin.Context context) {
+ return new MergeManagerImpl<K, V>(
+ reduceId,
+ mrJobConf,
+ context.getLocalFS(),
+ context.getLocalDirAllocator(),
+ reporter,
+ context.getCodec(),
+ context.getCombinerClass(),
+ context.getCombineCollector(),
+ context.getSpilledRecordsCounter(),
+ context.getReduceCombineInputCounter(),
+ context.getMergedMapOutputsCounter(),
+ this,
+ context.getMergePhase(),
+ context.getMapOutputFile());
+ }
+
+ private ShuffleClientMetrics createMetrics(
+ org.apache.hadoop.mapreduce.TaskAttemptID taskAttemptID, JobConf jobConf)
+ throws NoSuchMethodException, InvocationTargetException, InstantiationException,
+ IllegalAccessException {
+ // for hadoop 3
+ Method createMethod = null;
+ try {
+ ShuffleClientMetrics.class.getDeclaredMethod(
+ "create", org.apache.hadoop.mapreduce.TaskAttemptID.class, JobConf.class);
+ } catch (Exception e) {
+ // ignore this exception because
Review Comment:
```suggestion
// ignore this exception because the createMetrics may uses hadoop2
```
##########
client-mr/mr/src/main/java/org/apache/hadoop/mapred/CelebornMapOutputCollector.java:
##########
@@ -0,0 +1,129 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.mapred;
+
+import java.io.IOException;
+
+import org.apache.hadoop.io.serializer.SerializationFactory;
+import org.apache.hadoop.mapreduce.JobContext;
+import org.apache.hadoop.mapreduce.TaskCounter;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.celeborn.client.ShuffleClient;
+import org.apache.celeborn.common.CelebornConf;
+import org.apache.celeborn.common.identity.UserIdentifier;
+import org.apache.celeborn.util.HadoopUtils;
+
+public class CelebornMapOutputCollector<K extends Object, V extends Object>
+ implements MapOutputCollector<K, V> {
+ private static final Logger logger = LoggerFactory.getLogger(CelebornMapOutputCollector.class);
+ private Class<K> keyClass;
+ private Class<V> valClass;
+ private Task.TaskReporter reporter;
+ private CelebornSortBasedPusher<K, V> celebornSortBasedPusher;
+ private int numReducers;
+
+ @Override
+ public void init(Context context) throws IOException {
+ JobConf jobConf = context.getJobConf();
+ reporter = context.getReporter();
+ keyClass = (Class<K>) jobConf.getMapOutputKeyClass();
+ valClass = (Class<V>) jobConf.getMapOutputValueClass();
+ context.getMapTask().getTaskID().getId();
+ numReducers = jobConf.getNumReduceTasks();
+
+ int IOBufferSize = jobConf.getInt(JobContext.IO_SORT_MB, 100);
+ // Java bytebuffer cannot be larger than Integer.MAX_VALUE
+ if ((IOBufferSize & 0x7FF) != IOBufferSize) {
+ throw new IOException("Invalid \"" + JobContext.IO_SORT_MB + "\": " + IOBufferSize);
+ }
+ jobConf.getNumReduceTasks();
+
+ CelebornConf celebornConf = HadoopUtils.fromYarnConf(jobConf);
+ JobConf celebornAppendConf = new JobConf(HadoopUtils.MR_CELEBORN_CONF);
+ String lcHost = celebornAppendConf.get(HadoopUtils.MR_CELEBORN_LC_HOST);
+ int lcPort = Integer.parseInt(celebornAppendConf.get(HadoopUtils.MR_CELEBORN_LC_PORT));
+ String applicationAttemptId = celebornAppendConf.get(HadoopUtils.MR_CELEBORN_APPLICATION_ID);
+ logger.info("Mapper initialized with celeborn {} {} {}", lcHost, lcPort, applicationAttemptId);
+ UserIdentifier userIdentifier =
+ new UserIdentifier(
+ celebornConf.quotaUserSpecificTenant(), celebornConf.quotaUserSpecificUserName());
+
+ logger.info(JobContext.IO_SORT_MB + ": " + IOBufferSize);
+ final float spiller = jobConf.getFloat(JobContext.MAP_SORT_SPILL_PERCENT, (float) 0.8);
+ int pushSize = (int) ((IOBufferSize << 20) * spiller);
+
+ SerializationFactory serializationFactory = new SerializationFactory(jobConf);
+ celebornSortBasedPusher =
+ new CelebornSortBasedPusher<>(
+ jobConf.getNumMapTasks(),
+ jobConf.getNumReduceTasks(),
+ // this is map id
+ context.getMapTask().getTaskID().getTaskID().getId(),
+ // this is attempt id
+ context.getMapTask().getTaskID().getId(),
+ serializationFactory.getSerializer(keyClass),
+ serializationFactory.getSerializer(valClass),
+ IOBufferSize << 20,
+ pushSize,
+ jobConf.getOutputKeyComparator(),
+ reporter.getCounter(TaskCounter.MAP_OUTPUT_BYTES),
+ reporter.getCounter(TaskCounter.MAP_OUTPUT_RECORDS),
+ ShuffleClient.get(applicationAttemptId, lcHost, lcPort, celebornConf, userIdentifier),
+ celebornConf);
+ }
+
+ @Override
+ public void collect(K key, V value, int partition) throws IOException {
+ reporter.progress();
+ if (key.getClass() != keyClass) {
+ throw new IOException(
+ "Type mismatch in key from map: expected "
+ + keyClass.getName()
+ + ", received "
+ + key.getClass().getName());
+ }
+ if (value.getClass() != valClass) {
+ throw new IOException(
+ "Type mismatch in value from map: expected "
+ + valClass.getName()
+ + ", received "
+ + value.getClass().getName());
+ }
+ if (partition < 0 || partition >= numReducers) {
+ throw new IOException("Illegal partition for " + key + " (" + partition + ")");
+ }
+ celebornSortBasedPusher.checkException();
+ celebornSortBasedPusher.insert(key, value, partition);
+ }
+
+ @Override
+ public void close() {
+ logger.info("Mapper collector close");
+ reporter.progress();
Review Comment:
Does this need to set `reporter` and `celebornSortBasedPusher` to null?
##########
client-mr/mr/src/main/java/org/apache/celeborn/util/HadoopUtils.java:
##########
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.celeborn.util;
+
+import java.util.Map;
+
+import org.apache.hadoop.mapred.JobConf;
+
+import org.apache.celeborn.common.CelebornConf;
+
+public class HadoopUtils {
+ public static final String MR_CELEBORN_CONF = "celeborn.xml";
+ public static final String MR_CELEBORN_LC_HOST = "celeborn.lifecycleManager.host";
+ public static final String MR_CELEBORN_LC_PORT = "celeborn.lifecycleManager.port";
+ public static final String MR_CELEBORN_APPLICATION_ID = "celeborn.applicationId";
+
+ public static CelebornConf fromYarnConf(JobConf conf) {
+ CelebornConf tmpCelebornConf = new CelebornConf();
+ for (Map.Entry<String, String> property : conf) {
+ String proName = property.getKey();
Review Comment:
```suggestion
String proName = property.getKey().toLowerCase();
```
--
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: issues-unsubscribe@celeborn.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-celeborn] cfmcgrady commented on a diff in pull request #1830: [CELEBORN-839][MR] Support Hadoop MapReduce
Posted by "cfmcgrady (via GitHub)" <gi...@apache.org>.
cfmcgrady commented on code in PR #1830:
URL: https://github.com/apache/incubator-celeborn/pull/1830#discussion_r1309571233
##########
client-mr/mr/src/main/java/org/apache/hadoop/mapred/CelebornSortBasedPusher.java:
##########
@@ -0,0 +1,338 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.mapred;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.*;
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.apache.hadoop.io.RawComparator;
+import org.apache.hadoop.io.WritableUtils;
+import org.apache.hadoop.io.serializer.Serializer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.celeborn.client.ShuffleClient;
+import org.apache.celeborn.common.CelebornConf;
+import org.apache.celeborn.common.unsafe.Platform;
+import org.apache.celeborn.common.util.Utils;
+
+public class CelebornSortBasedPusher<K, V> extends OutputStream {
+ final Logger logger = LoggerFactory.getLogger(CelebornSortBasedPusher.class);
+ private final int mapId;
+ private final int attempt;
+ private final int numMappers;
+ private final int numReducers;
+ private final ShuffleClient shuffleClient;
+ private final int maxIOBufferSize;
+ private final int spillIOBufferSize;
+ private final Serializer<K> kSer;
+ private final Serializer<V> vSer;
+ private final RawComparator<K> comparator;
+ private final AtomicReference<Exception> exception = new AtomicReference<>();
+ private final Counters.Counter mapOutputByteCounter;
+ private final Counters.Counter mapOutputRecordCounter;
+ private final Map<Integer, List<SerializedKV>> currentSerializedKVs;
+ private int writePos;
+ private byte[] serializedKV;
+ private final int maxPushDataSize;
+
+ public CelebornSortBasedPusher(
+ int numMappers,
+ int numReducers,
+ int mapId,
+ int attemptId,
+ Serializer<K> kSer,
+ Serializer<V> vSer,
+ int maxIOBufferSize,
+ int spillIOBufferSize,
+ RawComparator<K> comparator,
+ Counters.Counter mapOutputByteCounter,
+ Counters.Counter mapOutputRecordCounter,
+ ShuffleClient shuffleClient,
+ CelebornConf celebornConf) {
+ this.numMappers = numMappers;
+ this.numReducers = numReducers;
+ this.mapId = mapId;
+ this.attempt = attemptId;
+ this.kSer = kSer;
+ this.vSer = vSer;
+ this.maxIOBufferSize = maxIOBufferSize;
+ this.spillIOBufferSize = spillIOBufferSize;
+ this.mapOutputByteCounter = mapOutputByteCounter;
+ this.mapOutputRecordCounter = mapOutputRecordCounter;
+ this.comparator = comparator;
+ this.shuffleClient = shuffleClient;
+ currentSerializedKVs = new HashMap<>();
+ serializedKV = new byte[maxIOBufferSize];
+ maxPushDataSize = (int) celebornConf.clientMrMaxPushData();
Review Comment:
add `checkValues` for the conf `celeborn.client.mr.pushData.max` to validate that the config value is below Int.MaxValue.
--
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: issues-unsubscribe@celeborn.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-celeborn] cfmcgrady commented on a diff in pull request #1830: [CELEBORN-839][MR] Support Hadoop MapReduce
Posted by "cfmcgrady (via GitHub)" <gi...@apache.org>.
cfmcgrady commented on code in PR #1830:
URL: https://github.com/apache/incubator-celeborn/pull/1830#discussion_r1309777724
##########
client-mr/mr-shaded/pom.xml:
##########
@@ -0,0 +1,149 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+~ Licensed to the Apache Software Foundation (ASF) under one or more
+~ contributor license agreements. See the NOTICE file distributed with
+~ this work for additional information regarding copyright ownership.
+~ The ASF licenses this file to You under the Apache License, Version 2.0
+~ (the "License"); you may not use this file except in compliance with
+~ the License. You may obtain a copy of the License at
+~
+~ http://www.apache.org/licenses/LICENSE-2.0
+~
+~ Unless required by applicable law or agreed to in writing, software
+~ distributed under the License is distributed on an "AS IS" BASIS,
+~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+~ See the License for the specific language governing permissions and
+~ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.celeborn</groupId>
+ <artifactId>celeborn-parent_${scala.binary.version}</artifactId>
+ <version>${project.version}</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>celeborn-client-mr-shaded-${hadoop.version}</artifactId>
+ <packaging>jar</packaging>
+ <name>Celeborn Shaded Client for MapReduce</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.celeborn</groupId>
+ <artifactId>celeborn-client-mr-${hadoop.version}</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-shade-plugin</artifactId>
+ <configuration>
+ <relocations>
+ <relocation>
+ <pattern>com.google.protobuf</pattern>
+ <shadedPattern>${shading.prefix}.com.google.protobuf</shadedPattern>
+ </relocation>
+ <relocation>
+ <pattern>com.google.common</pattern>
+ <shadedPattern>${shading.prefix}.com.google.common</shadedPattern>
+ </relocation>
+ <relocation>
+ <pattern>io.netty</pattern>
+ <shadedPattern>${shading.prefix}.io.netty</shadedPattern>
+ </relocation>
+ <relocation>
+ <pattern>org.apache.commons</pattern>
+ <shadedPattern>${shading.prefix}.org.apache.commons</shadedPattern>
+ </relocation>
+ <relocation>
+ <pattern>com.fasterxml.jackson.core</pattern>
Review Comment:
for spark-3.4
```
$ ./build/mvn -Pspark-3.4 dependency:tree | grep -i jackson
Using `mvn` from path: /tmp/dddd/celeborn/build/apache-maven-3.8.8/bin/mvn
[INFO] | | \- com.fasterxml.jackson.core:jackson-core:jar:2.12.7:provided
[INFO] | | \- com.fasterxml.jackson.core:jackson-annotations:jar:2.14.2:provided
[INFO] | +- org.json4s:json4s-jackson_2.12:jar:3.7.0-M11:provided
[INFO] | +- com.fasterxml.jackson.core:jackson-databind:jar:2.14.2:provided
[INFO] | +- com.fasterxml.jackson.module:jackson-module-scala_2.12:jar:2.14.2:provided
[INFO] | | | +- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.13.4:provided
[INFO] | \- org.apache.parquet:parquet-jackson:jar:1.12.3:provided
[INFO] | | \- com.fasterxml.jackson.core:jackson-core:jar:2.12.7:provided
[INFO] | | \- com.fasterxml.jackson.core:jackson-annotations:jar:2.14.2:provided
[INFO] | +- org.json4s:json4s-jackson_2.12:jar:3.7.0-M11:provided
[INFO] | +- com.fasterxml.jackson.core:jackson-databind:jar:2.14.2:provided
[INFO] | +- com.fasterxml.jackson.module:jackson-module-scala_2.12:jar:2.14.2:provided
[INFO] | | | +- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.13.4:provided
[INFO] | \- org.apache.parquet:parquet-jackson:jar:1.12.3:provided
[INFO] | | +- org.json4s:json4s-jackson_2.12:jar:3.7.0-M11:provided
[INFO] | | +- com.fasterxml.jackson.module:jackson-module-scala_2.12:jar:2.14.2:provided
[INFO] | | | +- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.13.4:provided
[INFO] | | \- org.apache.parquet:parquet-jackson:jar:1.12.3:provided
[INFO] | +- com.fasterxml.jackson.core:jackson-databind:jar:2.14.2:provided
[INFO] | | +- com.fasterxml.jackson.core:jackson-annotations:jar:2.14.2:provided
[INFO] | | \- com.fasterxml.jackson.core:jackson-core:jar:2.14.2:provided
[INFO] | | \- com.fasterxml.jackson.core:jackson-core:jar:2.12.7:test
[INFO] | | \- com.fasterxml.jackson.core:jackson-annotations:jar:2.14.2:test
[INFO] | +- org.json4s:json4s-jackson_2.12:jar:3.7.0-M11:test
[INFO] | +- com.fasterxml.jackson.core:jackson-databind:jar:2.14.2:test
[INFO] | +- com.fasterxml.jackson.module:jackson-module-scala_2.12:jar:2.14.2:test
[INFO] | | | +- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.13.4:test
[INFO] | \- org.apache.parquet:parquet-jackson:jar:1.12.3:test
```
```
$./build/sbt -Pspark-3.4 celeborn-client-spark-3/Runtime/dependencyTree | grep -i jackson
```
All of them fall within the scope of both the `test` and `provided` categories.
--
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: issues-unsubscribe@celeborn.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-celeborn] cfmcgrady commented on a diff in pull request #1830: [CELEBORN-839][MR] Support Hadoop MapReduce
Posted by "cfmcgrady (via GitHub)" <gi...@apache.org>.
cfmcgrady commented on code in PR #1830:
URL: https://github.com/apache/incubator-celeborn/pull/1830#discussion_r1312601304
##########
pom.xml:
##########
@@ -64,9 +64,14 @@
<maven.version>3.8.8</maven.version>
<flink.version>1.14.6</flink.version>
- <hadoop.version>3.2.4</hadoop.version>
<spark.version>3.3.2</spark.version>
+ <!-- use hadoop-3 as default -->
+ <hadoop.version>3.2.4</hadoop.version>
Review Comment:
thanks for the explanation.
--
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: issues-unsubscribe@celeborn.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-celeborn] FMX commented on pull request #1830: [CELEBORN-839][MR] Support Hadoop MapReduce
Posted by "FMX (via GitHub)" <gi...@apache.org>.
FMX commented on PR #1830:
URL: https://github.com/apache/incubator-celeborn/pull/1830#issuecomment-1700358735
Ping @SteNicholas @cfmcgrady @zwangsheng All comments are addressed. How about the latest change?
--
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: issues-unsubscribe@celeborn.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-celeborn] FMX commented on a diff in pull request #1830: [CELEBORN-839][MR] Support Hadoop MapReduce
Posted by "FMX (via GitHub)" <gi...@apache.org>.
FMX commented on code in PR #1830:
URL: https://github.com/apache/incubator-celeborn/pull/1830#discussion_r1311064107
##########
client-mr/mr/src/main/java/org/apache/celeborn/mapreduce/v2/app/MRAppMasterWithCeleborn.java:
##########
@@ -0,0 +1,177 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.celeborn.mapreduce.v2.app;
+
+import java.io.IOException;
+
+import org.apache.hadoop.fs.FSDataOutputStream;
+import org.apache.hadoop.fs.FileStatus;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.fs.permission.FsPermission;
+import org.apache.hadoop.ipc.CallerContext;
+import org.apache.hadoop.mapred.JobConf;
+import org.apache.hadoop.mapreduce.Cluster;
+import org.apache.hadoop.mapreduce.JobSubmissionFiles;
+import org.apache.hadoop.mapreduce.MRJobConfig;
+import org.apache.hadoop.mapreduce.v2.app.MRAppMaster;
+import org.apache.hadoop.mapreduce.v2.util.MRApps;
+import org.apache.hadoop.mapreduce.v2.util.MRWebAppUtil;
+import org.apache.hadoop.util.ExitUtil;
+import org.apache.hadoop.util.ShutdownHookManager;
+import org.apache.hadoop.yarn.YarnUncaughtExceptionHandler;
+import org.apache.hadoop.yarn.api.ApplicationConstants;
+import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
+import org.apache.hadoop.yarn.api.records.ContainerId;
+import org.apache.hadoop.yarn.conf.YarnConfiguration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.celeborn.client.LifecycleManager;
+import org.apache.celeborn.common.CelebornConf;
+import org.apache.celeborn.common.exception.CelebornIOException;
+import org.apache.celeborn.util.HadoopUtils;
+
+public class MRAppMasterWithCeleborn extends MRAppMaster {
+ private static final Logger logger = LoggerFactory.getLogger(MRAppMasterWithCeleborn.class);
+
+ public MRAppMasterWithCeleborn(
+ ApplicationAttemptId applicationAttemptId,
+ ContainerId containerId,
+ String nmHost,
+ int nmPort,
+ int nmHttpPort,
+ long appSubmitTime,
+ JobConf jobConf)
+ throws CelebornIOException {
+ super(applicationAttemptId, containerId, nmHost, nmPort, nmHttpPort, appSubmitTime);
+
+ int numReducers = jobConf.getInt(MRJobConfig.NUM_REDUCES, 0);
+ if (numReducers > 0) {
+ CelebornConf conf = HadoopUtils.fromYarnConf(jobConf);
+ LifecycleManager lifecycleManager =
+ new LifecycleManager(applicationAttemptId.toString(), conf);
+ String lcHost = lifecycleManager.getHost();
+ int lcPort = lifecycleManager.getPort();
+ logger.info("RMAppMaster initialized with {} {} {}", lcHost, lcPort, applicationAttemptId);
+ JobConf lcConf = new JobConf();
+ lcConf.clear();
+ lcConf.set(HadoopUtils.MR_CELEBORN_LC_HOST, lcHost);
+ lcConf.set(HadoopUtils.MR_CELEBORN_LC_PORT, lcPort + "");
+ lcConf.set(HadoopUtils.MR_CELEBORN_APPLICATION_ID, applicationAttemptId.toString());
+ writeLifecycleManagerConfToTask(jobConf, lcConf);
+ }
+ }
+
+ void writeLifecycleManagerConfToTask(JobConf conf, JobConf lcConf) throws CelebornIOException {
+ try {
+ FileSystem fs = new Cluster(conf).getFileSystem();
+ String jobDirStr = conf.get(MRJobConfig.MAPREDUCE_JOB_DIR);
+ Path celebornExtraConf = new Path(jobDirStr, HadoopUtils.MR_CELEBORN_CONF);
+
+ try (FSDataOutputStream out =
+ FileSystem.create(
+ fs, celebornExtraConf, new FsPermission(JobSubmissionFiles.JOB_FILE_PERMISSION))) {
+ lcConf.writeXml(out);
+ }
+ FileStatus status = fs.getFileStatus(celebornExtraConf);
+ long currentTs = status.getModificationTime();
+ String uri = fs.getUri() + Path.SEPARATOR + celebornExtraConf.toUri();
+ String files = conf.get(MRJobConfig.CACHE_FILES);
+ conf.set(MRJobConfig.CACHE_FILES, files == null ? uri : uri + "," + files);
+ String ts = conf.get(MRJobConfig.CACHE_FILE_TIMESTAMPS);
+ conf.set(
+ MRJobConfig.CACHE_FILE_TIMESTAMPS,
+ ts == null ? String.valueOf(currentTs) : currentTs + "," + ts);
+ String vis = conf.get(MRJobConfig.CACHE_FILE_VISIBILITIES);
+ conf.set(MRJobConfig.CACHE_FILE_VISIBILITIES, vis == null ? "false" : "false" + "," + vis);
+ long size = status.getLen();
+ String sizes = conf.get(MRJobConfig.CACHE_FILES_SIZES);
+ conf.set(
+ MRJobConfig.CACHE_FILES_SIZES, sizes == null ? String.valueOf(size) : size + "," + sizes);
+ } catch (InterruptedException | IOException e) {
+ logger.error("Upload extra conf exception", e);
+ throw new CelebornIOException("Upload extra conf exception ", e);
+ }
+ }
+
+ private static void validateInputParam(String value, String param) throws IOException {
+ if (value == null) {
+ String msg = param + " is null";
+ logger.error(msg);
+ throw new IOException(msg);
Review Comment:
OK
--
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: issues-unsubscribe@celeborn.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-celeborn] waitinfuture closed pull request #1830: [CELEBORN-839][MR] Support Hadoop MapReduce
Posted by "waitinfuture (via GitHub)" <gi...@apache.org>.
waitinfuture closed pull request #1830: [CELEBORN-839][MR] Support Hadoop MapReduce
URL: https://github.com/apache/incubator-celeborn/pull/1830
--
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: issues-unsubscribe@celeborn.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-celeborn] pan3793 commented on a diff in pull request #1830: [CELEBORN-839][MR] Support Hadoop MapReduce
Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on code in PR #1830:
URL: https://github.com/apache/incubator-celeborn/pull/1830#discussion_r1321731202
##########
pom.xml:
##########
@@ -383,6 +378,32 @@
<artifactId>snakeyaml</artifactId>
<version>${snakeyaml.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.hadoop</groupId>
+ <artifactId>${hadoop-client-api.artifact}</artifactId>
+ <version>${hadoop.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.hadoop</groupId>
+ <artifactId>${hadoop-client-runtime.artifact}</artifactId>
+ <version>${hadoop.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.hadoop</groupId>
+ <artifactId>hadoop-mapreduce-client-app</artifactId>
Review Comment:
this actually pulls hadoop-common deps, which is unexpected.
--
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: issues-unsubscribe@celeborn.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-celeborn] zwangsheng commented on a diff in pull request #1830: [CELEBORN-839][MR] Support Hadoop MapReduce
Posted by "zwangsheng (via GitHub)" <gi...@apache.org>.
zwangsheng commented on code in PR #1830:
URL: https://github.com/apache/incubator-celeborn/pull/1830#discussion_r1309573072
##########
build/make-distribution.sh:
##########
@@ -218,22 +218,43 @@ function build_flink_client {
cp "$PROJECT_DIR"/client-flink/flink-$FLINK_BINARY_VERSION-shaded/target/celeborn-client-flink-${FLINK_BINARY_VERSION}-shaded_$SCALA_VERSION-$VERSION.jar "$DIST_DIR/flink/"
}
+function build_mr_client {
+ HADOOP_VERSION=$("$MVN" help:evaluate -Dexpression=hadoop.version $@ 2>/dev/null \
+ | grep -v "INFO" \
+ | grep -v "WARNING" \
+ | tail -n 1)
+ BUILD_COMMAND=("$MVN" clean package $MVN_DIST_OPT -pl :celeborn-client-mr-shaded-${HADOOP_VERSION} -am $@)
+
+ # Actually build the jar
+ echo -e "\nBuilding with..."
+ echo -e "\$ ${BUILD_COMMAND[@]}\n"
+
+ "${BUILD_COMMAND[@]}"
+
+ ## flink spark client jars
+ mkdir -p "$DIST_DIR/mr"
+ cp "$PROJECT_DIR"/client-mr/mr-shaded/target/celeborn-client-mr-shaded-${HADOOP_VERSION}-$VERSION.jar "$DIST_DIR/mr/"
+}
+
if [ "$RELEASE" == "true" ]; then
build_service
build_spark_client -Pspark-2.4
build_spark_client -Pspark-3.4
build_flink_client -Pflink-1.14
build_flink_client -Pflink-1.15
build_flink_client -Pflink-1.17
+ build_mr_client mr
else
## build release package on demand
build_service $@
- if [[ $@ != *"spark"* && $@ != *"flink"* ]]; then
+ if [[ $@ != *"spark"* && $@ != *"flink"* && $@ != *"mr"* ]]; then
echo "Skip building client."
elif [[ $@ == *"spark"* && $@ != *"flink"* ]]; then
build_spark_client $@
elif [[ $@ == *"flink"* && $@ != *"spark"* ]]; then
build_flink_client $@
+ elif [[ $@ == *"mr"* ]]; then
Review Comment:
If we build with `-Pspark-3.4 -Pmr`, will only build spark client
##########
client-mr/mr/src/main/java/org/apache/celeborn/mapreduce/v2/app/MRAppMasterWithCeleborn.java:
##########
@@ -0,0 +1,177 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.celeborn.mapreduce.v2.app;
+
+import java.io.IOException;
+
+import org.apache.hadoop.fs.FSDataOutputStream;
+import org.apache.hadoop.fs.FileStatus;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.fs.permission.FsPermission;
+import org.apache.hadoop.ipc.CallerContext;
+import org.apache.hadoop.mapred.JobConf;
+import org.apache.hadoop.mapreduce.Cluster;
+import org.apache.hadoop.mapreduce.JobSubmissionFiles;
+import org.apache.hadoop.mapreduce.MRJobConfig;
+import org.apache.hadoop.mapreduce.v2.app.MRAppMaster;
+import org.apache.hadoop.mapreduce.v2.util.MRApps;
+import org.apache.hadoop.mapreduce.v2.util.MRWebAppUtil;
+import org.apache.hadoop.util.ExitUtil;
+import org.apache.hadoop.util.ShutdownHookManager;
+import org.apache.hadoop.yarn.YarnUncaughtExceptionHandler;
+import org.apache.hadoop.yarn.api.ApplicationConstants;
+import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
+import org.apache.hadoop.yarn.api.records.ContainerId;
+import org.apache.hadoop.yarn.conf.YarnConfiguration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.celeborn.client.LifecycleManager;
+import org.apache.celeborn.common.CelebornConf;
+import org.apache.celeborn.common.exception.CelebornIOException;
+import org.apache.celeborn.util.HadoopUtils;
+
+public class MRAppMasterWithCeleborn extends MRAppMaster {
+ private static final Logger logger = LoggerFactory.getLogger(MRAppMasterWithCeleborn.class);
+
+ public MRAppMasterWithCeleborn(
+ ApplicationAttemptId applicationAttemptId,
+ ContainerId containerId,
+ String nmHost,
+ int nmPort,
+ int nmHttpPort,
+ long appSubmitTime,
+ JobConf jobConf)
+ throws CelebornIOException {
+ super(applicationAttemptId, containerId, nmHost, nmPort, nmHttpPort, appSubmitTime);
+
+ int numReducers = jobConf.getInt(MRJobConfig.NUM_REDUCES, 0);
+ if (numReducers > 0) {
+ CelebornConf conf = HadoopUtils.fromYarnConf(jobConf);
+ LifecycleManager lifecycleManager =
+ new LifecycleManager(applicationAttemptId.toString(), conf);
+ String lcHost = lifecycleManager.getHost();
+ int lcPort = lifecycleManager.getPort();
+ logger.info("RMAppMaster initialized with {} {} {}", lcHost, lcPort, applicationAttemptId);
+ JobConf lcConf = new JobConf();
+ lcConf.clear();
+ lcConf.set(HadoopUtils.MR_CELEBORN_LC_HOST, lcHost);
+ lcConf.set(HadoopUtils.MR_CELEBORN_LC_PORT, lcPort + "");
+ lcConf.set(HadoopUtils.MR_CELEBORN_APPLICATION_ID, applicationAttemptId.toString());
+ writeLifecycleManagerConfToTask(jobConf, lcConf);
+ }
+ }
+
+ void writeLifecycleManagerConfToTask(JobConf conf, JobConf lcConf) throws CelebornIOException {
+ try {
+ FileSystem fs = new Cluster(conf).getFileSystem();
+ String jobDirStr = conf.get(MRJobConfig.MAPREDUCE_JOB_DIR);
+ Path celebornExtraConf = new Path(jobDirStr, HadoopUtils.MR_CELEBORN_CONF);
+
+ try (FSDataOutputStream out =
+ FileSystem.create(
+ fs, celebornExtraConf, new FsPermission(JobSubmissionFiles.JOB_FILE_PERMISSION))) {
+ lcConf.writeXml(out);
+ }
+ FileStatus status = fs.getFileStatus(celebornExtraConf);
+ long currentTs = status.getModificationTime();
+ String uri = fs.getUri() + Path.SEPARATOR + celebornExtraConf.toUri();
+ String files = conf.get(MRJobConfig.CACHE_FILES);
+ conf.set(MRJobConfig.CACHE_FILES, files == null ? uri : uri + "," + files);
+ String ts = conf.get(MRJobConfig.CACHE_FILE_TIMESTAMPS);
+ conf.set(
+ MRJobConfig.CACHE_FILE_TIMESTAMPS,
+ ts == null ? String.valueOf(currentTs) : currentTs + "," + ts);
+ String vis = conf.get(MRJobConfig.CACHE_FILE_VISIBILITIES);
+ conf.set(MRJobConfig.CACHE_FILE_VISIBILITIES, vis == null ? "false" : "false" + "," + vis);
+ long size = status.getLen();
+ String sizes = conf.get(MRJobConfig.CACHE_FILES_SIZES);
+ conf.set(
+ MRJobConfig.CACHE_FILES_SIZES, sizes == null ? String.valueOf(size) : size + "," + sizes);
+ } catch (InterruptedException | IOException e) {
+ logger.error("Upload extra conf exception", e);
+ throw new CelebornIOException("Upload extra conf exception ", e);
+ }
+ }
+
+ private static void validateInputParam(String value, String param) throws IOException {
+ if (value == null) {
+ String msg = param + " is null";
+ logger.error(msg);
+ throw new IOException(msg);
Review Comment:
Why using IOException? How about using `CelebornRuntimeException`
--
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: issues-unsubscribe@celeborn.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-celeborn] FMX commented on a diff in pull request #1830: [CELEBORN-839][MR] Support Hadoop MapReduce
Posted by "FMX (via GitHub)" <gi...@apache.org>.
FMX commented on code in PR #1830:
URL: https://github.com/apache/incubator-celeborn/pull/1830#discussion_r1309748396
##########
client-mr/mr-shaded/pom.xml:
##########
@@ -0,0 +1,149 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+~ Licensed to the Apache Software Foundation (ASF) under one or more
+~ contributor license agreements. See the NOTICE file distributed with
+~ this work for additional information regarding copyright ownership.
+~ The ASF licenses this file to You under the Apache License, Version 2.0
+~ (the "License"); you may not use this file except in compliance with
+~ the License. You may obtain a copy of the License at
+~
+~ http://www.apache.org/licenses/LICENSE-2.0
+~
+~ Unless required by applicable law or agreed to in writing, software
+~ distributed under the License is distributed on an "AS IS" BASIS,
+~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+~ See the License for the specific language governing permissions and
+~ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.celeborn</groupId>
+ <artifactId>celeborn-parent_${scala.binary.version}</artifactId>
+ <version>${project.version}</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>celeborn-client-mr-shaded-${hadoop.version}</artifactId>
+ <packaging>jar</packaging>
+ <name>Celeborn Shaded Client for MapReduce</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.celeborn</groupId>
+ <artifactId>celeborn-client-mr-${hadoop.version}</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-shade-plugin</artifactId>
+ <configuration>
+ <relocations>
+ <relocation>
+ <pattern>com.google.protobuf</pattern>
+ <shadedPattern>${shading.prefix}.com.google.protobuf</shadedPattern>
+ </relocation>
+ <relocation>
+ <pattern>com.google.common</pattern>
+ <shadedPattern>${shading.prefix}.com.google.common</shadedPattern>
+ </relocation>
+ <relocation>
+ <pattern>io.netty</pattern>
+ <shadedPattern>${shading.prefix}.io.netty</shadedPattern>
+ </relocation>
+ <relocation>
+ <pattern>org.apache.commons</pattern>
+ <shadedPattern>${shading.prefix}.org.apache.commons</shadedPattern>
+ </relocation>
+ <relocation>
+ <pattern>com.fasterxml.jackson.core</pattern>
Review Comment:
Spark3 has Jackson and Hadoop 3 has Jackson. I found that they have different versions so I just shade Jackson to avoid dependencies conflicts.
--
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: issues-unsubscribe@celeborn.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-celeborn] cfmcgrady commented on a diff in pull request #1830: [CELEBORN-839][MR] Support Hadoop MapReduce
Posted by "cfmcgrady (via GitHub)" <gi...@apache.org>.
cfmcgrady commented on code in PR #1830:
URL: https://github.com/apache/incubator-celeborn/pull/1830#discussion_r1309777724
##########
client-mr/mr-shaded/pom.xml:
##########
@@ -0,0 +1,149 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+~ Licensed to the Apache Software Foundation (ASF) under one or more
+~ contributor license agreements. See the NOTICE file distributed with
+~ this work for additional information regarding copyright ownership.
+~ The ASF licenses this file to You under the Apache License, Version 2.0
+~ (the "License"); you may not use this file except in compliance with
+~ the License. You may obtain a copy of the License at
+~
+~ http://www.apache.org/licenses/LICENSE-2.0
+~
+~ Unless required by applicable law or agreed to in writing, software
+~ distributed under the License is distributed on an "AS IS" BASIS,
+~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+~ See the License for the specific language governing permissions and
+~ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.celeborn</groupId>
+ <artifactId>celeborn-parent_${scala.binary.version}</artifactId>
+ <version>${project.version}</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>celeborn-client-mr-shaded-${hadoop.version}</artifactId>
+ <packaging>jar</packaging>
+ <name>Celeborn Shaded Client for MapReduce</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.celeborn</groupId>
+ <artifactId>celeborn-client-mr-${hadoop.version}</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-shade-plugin</artifactId>
+ <configuration>
+ <relocations>
+ <relocation>
+ <pattern>com.google.protobuf</pattern>
+ <shadedPattern>${shading.prefix}.com.google.protobuf</shadedPattern>
+ </relocation>
+ <relocation>
+ <pattern>com.google.common</pattern>
+ <shadedPattern>${shading.prefix}.com.google.common</shadedPattern>
+ </relocation>
+ <relocation>
+ <pattern>io.netty</pattern>
+ <shadedPattern>${shading.prefix}.io.netty</shadedPattern>
+ </relocation>
+ <relocation>
+ <pattern>org.apache.commons</pattern>
+ <shadedPattern>${shading.prefix}.org.apache.commons</shadedPattern>
+ </relocation>
+ <relocation>
+ <pattern>com.fasterxml.jackson.core</pattern>
Review Comment:
for spark-3.4
```
$ ./build/mvn -Pspark-3.4 dependency:tree | grep -i jackson
[INFO] | | \- com.fasterxml.jackson.core:jackson-core:jar:2.12.7:provided
[INFO] | | \- com.fasterxml.jackson.core:jackson-annotations:jar:2.14.2:provided
[INFO] | +- org.json4s:json4s-jackson_2.12:jar:3.7.0-M11:provided
[INFO] | +- com.fasterxml.jackson.core:jackson-databind:jar:2.14.2:provided
[INFO] | +- com.fasterxml.jackson.module:jackson-module-scala_2.12:jar:2.14.2:provided
[INFO] | | | +- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.13.4:provided
[INFO] | \- org.apache.parquet:parquet-jackson:jar:1.12.3:provided
[INFO] | | \- com.fasterxml.jackson.core:jackson-core:jar:2.12.7:provided
[INFO] | | \- com.fasterxml.jackson.core:jackson-annotations:jar:2.14.2:provided
[INFO] | +- org.json4s:json4s-jackson_2.12:jar:3.7.0-M11:provided
[INFO] | +- com.fasterxml.jackson.core:jackson-databind:jar:2.14.2:provided
[INFO] | +- com.fasterxml.jackson.module:jackson-module-scala_2.12:jar:2.14.2:provided
[INFO] | | | +- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.13.4:provided
[INFO] | \- org.apache.parquet:parquet-jackson:jar:1.12.3:provided
[INFO] | | +- org.json4s:json4s-jackson_2.12:jar:3.7.0-M11:provided
[INFO] | | +- com.fasterxml.jackson.module:jackson-module-scala_2.12:jar:2.14.2:provided
[INFO] | | | +- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.13.4:provided
[INFO] | | \- org.apache.parquet:parquet-jackson:jar:1.12.3:provided
[INFO] | +- com.fasterxml.jackson.core:jackson-databind:jar:2.14.2:provided
[INFO] | | +- com.fasterxml.jackson.core:jackson-annotations:jar:2.14.2:provided
[INFO] | | \- com.fasterxml.jackson.core:jackson-core:jar:2.14.2:provided
[INFO] | | \- com.fasterxml.jackson.core:jackson-core:jar:2.12.7:test
[INFO] | | \- com.fasterxml.jackson.core:jackson-annotations:jar:2.14.2:test
[INFO] | +- org.json4s:json4s-jackson_2.12:jar:3.7.0-M11:test
[INFO] | +- com.fasterxml.jackson.core:jackson-databind:jar:2.14.2:test
[INFO] | +- com.fasterxml.jackson.module:jackson-module-scala_2.12:jar:2.14.2:test
[INFO] | | | +- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.13.4:test
[INFO] | \- org.apache.parquet:parquet-jackson:jar:1.12.3:test
```
```
$./build/sbt -Pspark-3.4 celeborn-client-spark-3/Runtime/dependencyTree | grep -i jackson
$ # no output
```
All of them fall within the scope of both the `test` and `provided`.
--
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: issues-unsubscribe@celeborn.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-celeborn] cfmcgrady commented on a diff in pull request #1830: [CELEBORN-839][MR] Support Hadoop MapReduce
Posted by "cfmcgrady (via GitHub)" <gi...@apache.org>.
cfmcgrady commented on code in PR #1830:
URL: https://github.com/apache/incubator-celeborn/pull/1830#discussion_r1311836629
##########
client-mr/mr/src/main/java/org/apache/hadoop/mapred/CelebornSortBasedPusher.java:
##########
@@ -0,0 +1,338 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.mapred;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.*;
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.apache.hadoop.io.RawComparator;
+import org.apache.hadoop.io.WritableUtils;
+import org.apache.hadoop.io.serializer.Serializer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.celeborn.client.ShuffleClient;
+import org.apache.celeborn.common.CelebornConf;
+import org.apache.celeborn.common.unsafe.Platform;
+import org.apache.celeborn.common.util.Utils;
+
+public class CelebornSortBasedPusher<K, V> extends OutputStream {
+ final Logger logger = LoggerFactory.getLogger(CelebornSortBasedPusher.class);
+ private final int mapId;
+ private final int attempt;
+ private final int numMappers;
+ private final int numReducers;
+ private final ShuffleClient shuffleClient;
+ private final int maxIOBufferSize;
+ private final int spillIOBufferSize;
+ private final Serializer<K> kSer;
+ private final Serializer<V> vSer;
+ private final RawComparator<K> comparator;
+ private final AtomicReference<Exception> exception = new AtomicReference<>();
+ private final Counters.Counter mapOutputByteCounter;
+ private final Counters.Counter mapOutputRecordCounter;
+ private final Map<Integer, List<SerializedKV>> currentSerializedKVs;
+ private int writePos;
+ private byte[] serializedKV;
+ private final int maxPushDataSize;
+
+ public CelebornSortBasedPusher(
+ int numMappers,
+ int numReducers,
+ int mapId,
+ int attemptId,
+ Serializer<K> kSer,
+ Serializer<V> vSer,
+ int maxIOBufferSize,
+ int spillIOBufferSize,
+ RawComparator<K> comparator,
+ Counters.Counter mapOutputByteCounter,
+ Counters.Counter mapOutputRecordCounter,
+ ShuffleClient shuffleClient,
+ CelebornConf celebornConf) {
+ this.numMappers = numMappers;
+ this.numReducers = numReducers;
+ this.mapId = mapId;
+ this.attempt = attemptId;
+ this.kSer = kSer;
+ this.vSer = vSer;
+ this.maxIOBufferSize = maxIOBufferSize;
+ this.spillIOBufferSize = spillIOBufferSize;
+ this.mapOutputByteCounter = mapOutputByteCounter;
+ this.mapOutputRecordCounter = mapOutputRecordCounter;
+ this.comparator = comparator;
+ this.shuffleClient = shuffleClient;
+ currentSerializedKVs = new HashMap<>();
+ serializedKV = new byte[maxIOBufferSize];
+ maxPushDataSize = (int) celebornConf.clientMrMaxPushData();
+ logger.info(
+ "Sort based push initialized with"
+ + " numMappers:{} numReducers:{} mapId:{} attemptId:{}"
+ + " maxIOBufferSize:{} spillIOBufferSize:{}",
+ numMappers,
+ numReducers,
+ mapId,
+ attemptId,
+ maxIOBufferSize,
+ spillIOBufferSize);
+ try {
+ kSer.open(this);
+ vSer.open(this);
+ } catch (IOException e) {
+ exception.compareAndSet(null, e);
+ }
+ }
+
+ public void insert(K key, V value, int partition) {
+ try {
+ if (writePos >= spillIOBufferSize) {
+ // needs to sort and flush data
+ if (logger.isDebugEnabled()) {
+ logger.debug(
+ "Data is large enough {}/{}/{}, trigger sort and flush",
+ Utils.bytesToString(writePos),
+ Utils.bytesToString(spillIOBufferSize),
+ Utils.bytesToString(maxIOBufferSize));
+ }
+ synchronized (this) {
+ sortKVs();
+ sendKVAndUpdateWritePos();
+ }
+ }
+ int dataLen = insertRecordInternal(key, value, partition);
+ if (logger.isDebugEnabled()) {
+ logger.debug(
+ "Sort based pusher insert into partition:{} with {} bytes", partition, dataLen);
+ }
+ mapOutputRecordCounter.increment(1);
+ mapOutputByteCounter.increment(dataLen);
+ } catch (IOException e) {
+ exception.compareAndSet(null, e);
+ }
+ }
+
+ private void sendKVAndUpdateWritePos() throws IOException {
+ for (Map.Entry<Integer, List<SerializedKV>> partitionKVEntry :
+ currentSerializedKVs.entrySet()) {
+ List<SerializedKV> kvs = partitionKVEntry.getValue();
+ synchronized (kvs) {
+ int partition = partitionKVEntry.getKey();
+ List<SerializedKV> localKVs = new ArrayList<>();
+ int partitionKVTotalLen = 0;
+ // process buffers for specific partition
+ for (SerializedKV kv : kvs) {
+ partitionKVTotalLen += kv.kLen + kv.vLen;
+ localKVs.add(kv);
+ if (partitionKVTotalLen > maxPushDataSize) {
+ // limit max size of pushdata to avoid possible memory issue in Celeborn worker
+ // data layout
+ // pushdata header (16) + pushDataLen(4) +
+ // [keyLen(4)+valLen(4)+serializedRecord(x)][...]
+ sendSortedBuffersPartition(partition, localKVs, partitionKVTotalLen);
+ localKVs.clear();
+ partitionKVTotalLen = 0;
+ }
+ }
+ if (!localKVs.isEmpty()) {
+ sendSortedBuffersPartition(partition, localKVs, partitionKVTotalLen);
+ }
+ kvs.clear();
+ }
+ }
+ // all data sent
+ currentSerializedKVs.clear();
+ writePos = 0;
+ }
+
+ private void sendSortedBuffersPartition(
+ int partition, List<SerializedKV> localKVs, int partitionKVTotalLen) throws IOException {
+ int extraSize = 0;
+ for (SerializedKV localKV : localKVs) {
+ extraSize += WritableUtils.getVIntSize(localKV.kLen);
+ extraSize += WritableUtils.getVIntSize(localKV.vLen);
+ }
+ // copied from hadoop logic
+ extraSize += WritableUtils.getVIntSize(-1);
+ extraSize += WritableUtils.getVIntSize(-1);
+ // whole buffer's size + [(keyLen+valueLen)+(serializedKey+serializedValue)]
+ byte[] pkvs = new byte[4 + extraSize + partitionKVTotalLen];
+ int pkvsPos = 4;
+ Platform.putInt(pkvs, Platform.BYTE_ARRAY_OFFSET, partitionKVTotalLen + extraSize);
+ for (SerializedKV kv : localKVs) {
+ int recordLen = kv.kLen + kv.vLen;
+ // write key len
+ pkvsPos = writeDataInt(pkvs, pkvsPos, kv.kLen);
+ // write value len
+ pkvsPos = writeDataInt(pkvs, pkvsPos, kv.vLen);
+ // write serialized record
+ System.arraycopy(serializedKV, kv.offset, pkvs, pkvsPos, recordLen);
+ pkvsPos += recordLen;
+ }
+ // finally write -1 two times
+ pkvsPos = writeDataInt(pkvs, pkvsPos, -1);
+ writeDataInt(pkvs, pkvsPos, -1);
+ int compressedSize =
+ shuffleClient.pushData(
+ 0,
+ mapId,
+ attempt,
+ partition,
+ pkvs,
+ 0,
+ 4 + extraSize + partitionKVTotalLen,
+ numMappers,
+ numReducers);
+ if (logger.isDebugEnabled()) {
+ logger.debug(
+ "Send sorted buffer mapId:{} attemptId:{} to partition:{} uncompressed size:{} compressed size:{}",
+ mapId,
+ attempt,
+ partition,
+ Utils.bytesToString(4 + extraSize + partitionKVTotalLen),
+ Utils.bytesToString(compressedSize));
+ }
+ }
+
+ private int writeDataInt(byte[] data, int offset, long dataInt) {
+ if (dataInt >= -112L && dataInt <= 127L) {
+ data[offset] = (byte) ((int) dataInt);
+ offset++;
+ } else {
+ int len = -112;
+ if (dataInt < 0L) {
+ dataInt = ~dataInt;
+ len = -120;
+ }
+
+ for (long tmp = dataInt; tmp != 0L; --len) {
+ tmp >>= 8;
+ }
+
+ data[offset] = (byte) len;
+ offset++;
+ len = len < -120 ? -(len + 120) : -(len + 112);
+
+ for (int idx = len; idx != 0; --idx) {
+ int shiftBits = (idx - 1) * 8;
+ long mask = 255L << shiftBits;
+ data[offset] = ((byte) ((int) ((dataInt & mask) >> shiftBits)));
+ offset++;
+ }
+ }
+ return offset;
+ }
+
+ private void sortKVs() {
+ for (Map.Entry<Integer, List<SerializedKV>> partitionKVEntry :
+ currentSerializedKVs.entrySet()) {
+ partitionKVEntry
+ .getValue()
+ .sort(
+ (o1, o2) ->
+ comparator.compare(
+ serializedKV, o1.offset, o1.kLen, serializedKV, o2.offset, o2.kLen));
+ }
+ }
+
+ private int insertRecordInternal(K key, V value, int partition) throws IOException {
+ int offset = writePos;
+ int keyLen = writePos;
+ int valLen = 0;
+ kSer.serialize(key);
+ keyLen = writePos - offset;
+ vSer.serialize(value);
+ valLen = writePos - keyLen - offset;
+ List<SerializedKV> serializedKVs =
+ currentSerializedKVs.computeIfAbsent(partition, v -> new ArrayList<>());
+ synchronized (serializedKVs) {
+ serializedKVs.add(new SerializedKV(offset, keyLen, valLen));
+ }
+ if (logger.isDebugEnabled()) {
+ logger.debug(
+ "Pusher insert into buffer partition:{} offset:{} keyLen:{} valueLen:{} size:{}",
+ partition,
+ offset,
+ keyLen,
+ valLen,
+ currentSerializedKVs.size());
+ }
+ return keyLen + valLen;
+ }
+
+ public void checkException() throws IOException {
+ if (exception.get() != null) {
+ throw new IOException("Write data to celeborn failed", exception.get());
+ }
+ }
+
+ @Override
+ public void write(int b) throws IOException {
+ if (writePos < maxIOBufferSize) {
+ serializedKV[writePos] = (byte) b;
+ writePos++;
+ } else {
+ logger.warn("Sort push memory high ,write pos {} max size {}", writePos, maxIOBufferSize);
Review Comment:
```suggestion
logger.warn("Sort push memory high, write pos {} max size {}", writePos, maxIOBufferSize);
```
--
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: issues-unsubscribe@celeborn.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-celeborn] pan3793 commented on a diff in pull request #1830: [CELEBORN-839][MR] Support Hadoop MapReduce
Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on code in PR #1830:
URL: https://github.com/apache/incubator-celeborn/pull/1830#discussion_r1321548811
##########
README.md:
##########
@@ -78,6 +78,18 @@ Flink package layout:
└── flink // flink client jars
```
+MR package layout:
+```
+ ├── RELEASE
+ ├── bin
+ ├── conf
+ ├── jars // common jars for master and worker
+ ├── master-jars
+ ├── worker-jars
+ ├── sbin
+ └── mr // mr client jars
Review Comment:
I'm wondering if we can merge the layout, and simply comment the engine's client folder as optional.
--
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: issues-unsubscribe@celeborn.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-celeborn] RexXiong commented on a diff in pull request #1830: [CELEBORN-839][MR] Support Hadoop MapReduce
Posted by "RexXiong (via GitHub)" <gi...@apache.org>.
RexXiong commented on code in PR #1830:
URL: https://github.com/apache/incubator-celeborn/pull/1830#discussion_r1312476049
##########
build/make-distribution.sh:
##########
@@ -218,25 +218,54 @@ function build_flink_client {
cp "$PROJECT_DIR"/client-flink/flink-$FLINK_BINARY_VERSION-shaded/target/celeborn-client-flink-${FLINK_BINARY_VERSION}-shaded_$SCALA_VERSION-$VERSION.jar "$DIST_DIR/flink/"
}
+function build_mr_client {
+ VERSION=$("$MVN" help:evaluate -Dexpression=project.version $@ 2>/dev/null \
+ | grep -v "INFO" \
+ | grep -v "WARNING" \
+ | tail -n 1)
+ HADOOP_VERSION=$("$MVN" help:evaluate -Dexpression=hadoop.version $@ 2>/dev/null \
+ | grep -v "INFO" \
+ | grep -v "WARNING" \
+ | tail -n 1)
+ BUILD_COMMAND=("$MVN" clean package $MVN_DIST_OPT -pl :celeborn-client-mr-shaded-${HADOOP_VERSION} -am $@)
+
+ # Actually build the jar
+ echo -e "\nBuilding with..."
+ echo -e "\$ ${BUILD_COMMAND[@]}\n"
+
+ "${BUILD_COMMAND[@]}"
+
+ ## flink spark client jars
+ mkdir -p "$DIST_DIR/mr"
+ cp "$PROJECT_DIR"/client-mr/mr-shaded/target/celeborn-client-mr-shaded-${HADOOP_VERSION}-$VERSION.jar "$DIST_DIR/mr/"
+}
+
if [ "$RELEASE" == "true" ]; then
build_service
build_spark_client -Pspark-2.4
build_spark_client -Pspark-3.4
build_flink_client -Pflink-1.14
build_flink_client -Pflink-1.15
build_flink_client -Pflink-1.17
+ build_mr_client mr
else
## build release package on demand
build_service $@
- if [[ $@ != *"spark"* && $@ != *"flink"* ]]; then
+ echo "build client with $@"
+ if [[ $@ != *"spark"* && $@ != *"flink"* && $@ != *"mr"* ]]; then
Review Comment:
It seems complicated to identify which client should build. Maybe can simplify this by check no more than two kind client build at the same time
##########
client-mr/mr/src/main/java/org/apache/celeborn/mapreduce/v2/app/MRAppMasterWithCeleborn.java:
##########
@@ -0,0 +1,177 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.celeborn.mapreduce.v2.app;
+
+import java.io.IOException;
+
+import org.apache.hadoop.fs.FSDataOutputStream;
+import org.apache.hadoop.fs.FileStatus;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.fs.permission.FsPermission;
+import org.apache.hadoop.ipc.CallerContext;
+import org.apache.hadoop.mapred.JobConf;
+import org.apache.hadoop.mapreduce.Cluster;
+import org.apache.hadoop.mapreduce.JobSubmissionFiles;
+import org.apache.hadoop.mapreduce.MRJobConfig;
+import org.apache.hadoop.mapreduce.v2.app.MRAppMaster;
+import org.apache.hadoop.mapreduce.v2.util.MRApps;
+import org.apache.hadoop.mapreduce.v2.util.MRWebAppUtil;
+import org.apache.hadoop.util.ExitUtil;
+import org.apache.hadoop.util.ShutdownHookManager;
+import org.apache.hadoop.yarn.YarnUncaughtExceptionHandler;
+import org.apache.hadoop.yarn.api.ApplicationConstants;
+import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
+import org.apache.hadoop.yarn.api.records.ContainerId;
+import org.apache.hadoop.yarn.conf.YarnConfiguration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.celeborn.client.LifecycleManager;
+import org.apache.celeborn.common.CelebornConf;
+import org.apache.celeborn.common.exception.CelebornIOException;
+import org.apache.celeborn.util.HadoopUtils;
+
+public class MRAppMasterWithCeleborn extends MRAppMaster {
+ private static final Logger logger = LoggerFactory.getLogger(MRAppMasterWithCeleborn.class);
+
+ public MRAppMasterWithCeleborn(
+ ApplicationAttemptId applicationAttemptId,
+ ContainerId containerId,
+ String nmHost,
+ int nmPort,
+ int nmHttpPort,
+ long appSubmitTime,
+ JobConf jobConf)
+ throws CelebornIOException {
+ super(applicationAttemptId, containerId, nmHost, nmPort, nmHttpPort, appSubmitTime);
+
+ int numReducers = jobConf.getInt(MRJobConfig.NUM_REDUCES, 0);
+ if (numReducers > 0) {
+ CelebornConf conf = HadoopUtils.fromYarnConf(jobConf);
+ LifecycleManager lifecycleManager =
+ new LifecycleManager(applicationAttemptId.toString(), conf);
+ String lcHost = lifecycleManager.getHost();
+ int lcPort = lifecycleManager.getPort();
+ logger.info("RMAppMaster initialized with {} {} {}", lcHost, lcPort, applicationAttemptId);
+ JobConf lcConf = new JobConf();
+ lcConf.clear();
+ lcConf.set(HadoopUtils.MR_CELEBORN_LC_HOST, lcHost);
+ lcConf.set(HadoopUtils.MR_CELEBORN_LC_PORT, lcPort + "");
+ lcConf.set(HadoopUtils.MR_CELEBORN_APPLICATION_ID, applicationAttemptId.toString());
+ writeLifecycleManagerConfToTask(jobConf, lcConf);
+ }
+ }
+
+ void writeLifecycleManagerConfToTask(JobConf conf, JobConf lcConf) throws CelebornIOException {
+ try {
+ FileSystem fs = new Cluster(conf).getFileSystem();
+ String jobDirStr = conf.get(MRJobConfig.MAPREDUCE_JOB_DIR);
+ Path celebornExtraConf = new Path(jobDirStr, HadoopUtils.MR_CELEBORN_CONF);
+
+ try (FSDataOutputStream out =
+ FileSystem.create(
+ fs, celebornExtraConf, new FsPermission(JobSubmissionFiles.JOB_FILE_PERMISSION))) {
+ lcConf.writeXml(out);
+ }
+ FileStatus status = fs.getFileStatus(celebornExtraConf);
+ long currentTs = status.getModificationTime();
+ String uri = fs.getUri() + Path.SEPARATOR + celebornExtraConf.toUri();
+ String files = conf.get(MRJobConfig.CACHE_FILES);
+ conf.set(MRJobConfig.CACHE_FILES, files == null ? uri : uri + "," + files);
+ String ts = conf.get(MRJobConfig.CACHE_FILE_TIMESTAMPS);
+ conf.set(
+ MRJobConfig.CACHE_FILE_TIMESTAMPS,
+ ts == null ? String.valueOf(currentTs) : currentTs + "," + ts);
+ String vis = conf.get(MRJobConfig.CACHE_FILE_VISIBILITIES);
+ conf.set(MRJobConfig.CACHE_FILE_VISIBILITIES, vis == null ? "false" : "false" + "," + vis);
+ long size = status.getLen();
+ String sizes = conf.get(MRJobConfig.CACHE_FILES_SIZES);
+ conf.set(
+ MRJobConfig.CACHE_FILES_SIZES, sizes == null ? String.valueOf(size) : size + "," + sizes);
+ } catch (InterruptedException | IOException e) {
+ logger.error("Upload extra conf exception", e);
+ throw new CelebornIOException("Upload extra conf exception ", e);
+ }
+ }
+
+ private static void validateInputParam(String value, String param) throws IOException {
+ if (value == null) {
+ String msg = param + " is null";
+ logger.error(msg);
+ throw new CelebornIOException(msg);
+ }
+ }
+
+ public static void main(String[] args) {
+ JobConf rmAppConf = new JobConf(new YarnConfiguration());
+ rmAppConf.addResource(new Path(MRJobConfig.JOB_CONF_FILE));
+ try {
+ Thread.setDefaultUncaughtExceptionHandler(new YarnUncaughtExceptionHandler());
+ String containerIdStr = System.getenv(ApplicationConstants.Environment.CONTAINER_ID.name());
Review Comment:
Let's extract a method like getSystemEnv to merge System.getenv with validateInputParam together
--
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: issues-unsubscribe@celeborn.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-celeborn] codecov[bot] commented on pull request #1830: [Celeborn-839] Support mapreduce client
Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #1830:
URL: https://github.com/apache/incubator-celeborn/pull/1830#issuecomment-1690855015
## [Codecov](https://app.codecov.io/gh/apache/incubator-celeborn/pull/1830?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
> Merging [#1830](https://app.codecov.io/gh/apache/incubator-celeborn/pull/1830?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) (49edb39) into [main](https://app.codecov.io/gh/apache/incubator-celeborn/commit/5f0295e9f3f1f5781af124ae319e202a2594a103?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) (5f0295e) will **decrease** coverage by `0.32%`.
> Report is 50 commits behind head on main.
> The diff coverage is `85.72%`.
```diff
@@ Coverage Diff @@
## main #1830 +/- ##
==========================================
- Coverage 46.81% 46.48% -0.32%
==========================================
Files 162 163 +1
Lines 10012 10143 +131
Branches 923 934 +11
==========================================
+ Hits 4686 4714 +28
- Misses 5019 5118 +99
- Partials 307 311 +4
```
| [Files Changed](https://app.codecov.io/gh/apache/incubator-celeborn/pull/1830?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
|---|---|---|
| [...cala/org/apache/celeborn/common/CelebornConf.scala](https://app.codecov.io/gh/apache/incubator-celeborn/pull/1830?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-Y29tbW9uL3NyYy9tYWluL3NjYWxhL29yZy9hcGFjaGUvY2VsZWJvcm4vY29tbW9uL0NlbGVib3JuQ29uZi5zY2FsYQ==) | `87.48% <85.72%> (+0.25%)` | :arrow_up: |
... and [19 files with indirect coverage changes](https://app.codecov.io/gh/apache/incubator-celeborn/pull/1830/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
:mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
--
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: issues-unsubscribe@celeborn.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-celeborn] zwangsheng commented on a diff in pull request #1830: [CELEBORN-839][MR] Support Hadoop MapReduce
Posted by "zwangsheng (via GitHub)" <gi...@apache.org>.
zwangsheng commented on code in PR #1830:
URL: https://github.com/apache/incubator-celeborn/pull/1830#discussion_r1319314479
##########
client-mr/mr/src/main/java/org/apache/celeborn/mapreduce/v2/app/MRAppMasterWithCeleborn.java:
##########
@@ -0,0 +1,172 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.celeborn.mapreduce.v2.app;
+
+import java.io.IOException;
+
+import org.apache.hadoop.fs.FSDataOutputStream;
+import org.apache.hadoop.fs.FileStatus;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.fs.permission.FsPermission;
+import org.apache.hadoop.ipc.CallerContext;
+import org.apache.hadoop.mapred.JobConf;
+import org.apache.hadoop.mapreduce.JobSubmissionFiles;
+import org.apache.hadoop.mapreduce.MRJobConfig;
+import org.apache.hadoop.mapreduce.v2.app.MRAppMaster;
+import org.apache.hadoop.mapreduce.v2.util.MRApps;
+import org.apache.hadoop.mapreduce.v2.util.MRWebAppUtil;
+import org.apache.hadoop.util.ExitUtil;
+import org.apache.hadoop.util.ShutdownHookManager;
+import org.apache.hadoop.yarn.YarnUncaughtExceptionHandler;
+import org.apache.hadoop.yarn.api.ApplicationConstants;
+import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
+import org.apache.hadoop.yarn.api.records.ContainerId;
+import org.apache.hadoop.yarn.conf.YarnConfiguration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.celeborn.client.LifecycleManager;
+import org.apache.celeborn.common.CelebornConf;
+import org.apache.celeborn.common.exception.CelebornIOException;
+import org.apache.celeborn.util.HadoopUtils;
+
+public class MRAppMasterWithCeleborn extends MRAppMaster {
+ private static final Logger logger = LoggerFactory.getLogger(MRAppMasterWithCeleborn.class);
+
+ public MRAppMasterWithCeleborn(
+ ApplicationAttemptId applicationAttemptId,
+ ContainerId containerId,
+ String nmHost,
+ int nmPort,
+ int nmHttpPort,
+ long appSubmitTime,
+ JobConf jobConf)
+ throws CelebornIOException {
+ super(applicationAttemptId, containerId, nmHost, nmPort, nmHttpPort, appSubmitTime);
+
+ int numReducers = jobConf.getInt(MRJobConfig.NUM_REDUCES, 0);
+ if (numReducers > 0) {
+ CelebornConf conf = HadoopUtils.fromYarnConf(jobConf);
+ LifecycleManager lifecycleManager =
+ new LifecycleManager(applicationAttemptId.toString(), conf);
+ String lmHost = lifecycleManager.getHost();
+ int lmPort = lifecycleManager.getPort();
+ logger.info("RMAppMaster initialized with {} {} {}", lmHost, lmPort, applicationAttemptId);
+ JobConf lmConf = new JobConf();
+ lmConf.clear();
+ lmConf.set(HadoopUtils.MR_CELEBORN_LM_HOST, lmHost);
+ lmConf.set(HadoopUtils.MR_CELEBORN_LM_PORT, lmPort + "");
+ lmConf.set(HadoopUtils.MR_CELEBORN_APPLICATION_ID, applicationAttemptId.toString());
+ writeLifecycleManagerConfToTask(jobConf, lmConf);
+ }
+ }
+
+ void writeLifecycleManagerConfToTask(JobConf conf, JobConf lmConf) throws CelebornIOException {
Review Comment:
If there is no need for external exposure, you should use `private` grooming.
##########
client-mr/mr/src/main/java/org/apache/hadoop/mapred/CelebornSortBasedPusher.java:
##########
@@ -0,0 +1,336 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.mapred;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.*;
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.apache.hadoop.io.RawComparator;
+import org.apache.hadoop.io.WritableUtils;
+import org.apache.hadoop.io.serializer.Serializer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.celeborn.client.ShuffleClient;
+import org.apache.celeborn.common.CelebornConf;
+import org.apache.celeborn.common.unsafe.Platform;
+import org.apache.celeborn.common.util.Utils;
+
+public class CelebornSortBasedPusher<K, V> extends OutputStream {
+ final Logger logger = LoggerFactory.getLogger(CelebornSortBasedPusher.class);
Review Comment:
ditto
--
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: issues-unsubscribe@celeborn.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-celeborn] pan3793 commented on a diff in pull request #1830: [CELEBORN-839][MR] Support Hadoop MapReduce
Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on code in PR #1830:
URL: https://github.com/apache/incubator-celeborn/pull/1830#discussion_r1308276596
##########
pom.xml:
##########
@@ -383,6 +378,32 @@
<artifactId>snakeyaml</artifactId>
<version>${snakeyaml.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.hadoop</groupId>
+ <artifactId>${hadoop-client-api.artifact}</artifactId>
+ <version>${hadoop.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.hadoop</groupId>
+ <artifactId>${hadoop-client-runtime.artifact}</artifactId>
+ <version>${hadoop.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.hadoop</groupId>
+ <artifactId>hadoop-mapreduce-client-app</artifactId>
Review Comment:
why should we introduce this dep?
--
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: issues-unsubscribe@celeborn.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-celeborn] cfmcgrady commented on a diff in pull request #1830: [CELEBORN-839][MR] Support Hadoop MapReduce
Posted by "cfmcgrady (via GitHub)" <gi...@apache.org>.
cfmcgrady commented on code in PR #1830:
URL: https://github.com/apache/incubator-celeborn/pull/1830#discussion_r1309777724
##########
client-mr/mr-shaded/pom.xml:
##########
@@ -0,0 +1,149 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+~ Licensed to the Apache Software Foundation (ASF) under one or more
+~ contributor license agreements. See the NOTICE file distributed with
+~ this work for additional information regarding copyright ownership.
+~ The ASF licenses this file to You under the Apache License, Version 2.0
+~ (the "License"); you may not use this file except in compliance with
+~ the License. You may obtain a copy of the License at
+~
+~ http://www.apache.org/licenses/LICENSE-2.0
+~
+~ Unless required by applicable law or agreed to in writing, software
+~ distributed under the License is distributed on an "AS IS" BASIS,
+~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+~ See the License for the specific language governing permissions and
+~ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.celeborn</groupId>
+ <artifactId>celeborn-parent_${scala.binary.version}</artifactId>
+ <version>${project.version}</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>celeborn-client-mr-shaded-${hadoop.version}</artifactId>
+ <packaging>jar</packaging>
+ <name>Celeborn Shaded Client for MapReduce</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.celeborn</groupId>
+ <artifactId>celeborn-client-mr-${hadoop.version}</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-shade-plugin</artifactId>
+ <configuration>
+ <relocations>
+ <relocation>
+ <pattern>com.google.protobuf</pattern>
+ <shadedPattern>${shading.prefix}.com.google.protobuf</shadedPattern>
+ </relocation>
+ <relocation>
+ <pattern>com.google.common</pattern>
+ <shadedPattern>${shading.prefix}.com.google.common</shadedPattern>
+ </relocation>
+ <relocation>
+ <pattern>io.netty</pattern>
+ <shadedPattern>${shading.prefix}.io.netty</shadedPattern>
+ </relocation>
+ <relocation>
+ <pattern>org.apache.commons</pattern>
+ <shadedPattern>${shading.prefix}.org.apache.commons</shadedPattern>
+ </relocation>
+ <relocation>
+ <pattern>com.fasterxml.jackson.core</pattern>
Review Comment:
for spark-3.4
```
$ ./build/mvn -Pspark-3.4 dependency:tree | grep -i jackson
[INFO] | | \- com.fasterxml.jackson.core:jackson-core:jar:2.12.7:provided
[INFO] | | \- com.fasterxml.jackson.core:jackson-annotations:jar:2.14.2:provided
[INFO] | +- org.json4s:json4s-jackson_2.12:jar:3.7.0-M11:provided
[INFO] | +- com.fasterxml.jackson.core:jackson-databind:jar:2.14.2:provided
[INFO] | +- com.fasterxml.jackson.module:jackson-module-scala_2.12:jar:2.14.2:provided
[INFO] | | | +- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.13.4:provided
[INFO] | \- org.apache.parquet:parquet-jackson:jar:1.12.3:provided
[INFO] | | \- com.fasterxml.jackson.core:jackson-core:jar:2.12.7:provided
[INFO] | | \- com.fasterxml.jackson.core:jackson-annotations:jar:2.14.2:provided
[INFO] | +- org.json4s:json4s-jackson_2.12:jar:3.7.0-M11:provided
[INFO] | +- com.fasterxml.jackson.core:jackson-databind:jar:2.14.2:provided
[INFO] | +- com.fasterxml.jackson.module:jackson-module-scala_2.12:jar:2.14.2:provided
[INFO] | | | +- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.13.4:provided
[INFO] | \- org.apache.parquet:parquet-jackson:jar:1.12.3:provided
[INFO] | | +- org.json4s:json4s-jackson_2.12:jar:3.7.0-M11:provided
[INFO] | | +- com.fasterxml.jackson.module:jackson-module-scala_2.12:jar:2.14.2:provided
[INFO] | | | +- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.13.4:provided
[INFO] | | \- org.apache.parquet:parquet-jackson:jar:1.12.3:provided
[INFO] | +- com.fasterxml.jackson.core:jackson-databind:jar:2.14.2:provided
[INFO] | | +- com.fasterxml.jackson.core:jackson-annotations:jar:2.14.2:provided
[INFO] | | \- com.fasterxml.jackson.core:jackson-core:jar:2.14.2:provided
[INFO] | | \- com.fasterxml.jackson.core:jackson-core:jar:2.12.7:test
[INFO] | | \- com.fasterxml.jackson.core:jackson-annotations:jar:2.14.2:test
[INFO] | +- org.json4s:json4s-jackson_2.12:jar:3.7.0-M11:test
[INFO] | +- com.fasterxml.jackson.core:jackson-databind:jar:2.14.2:test
[INFO] | +- com.fasterxml.jackson.module:jackson-module-scala_2.12:jar:2.14.2:test
[INFO] | | | +- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.13.4:test
[INFO] | \- org.apache.parquet:parquet-jackson:jar:1.12.3:test
```
```
$./build/sbt -Pspark-3.4 celeborn-client-spark-3/Runtime/dependencyTree | grep -i jackson
```
All of them fall within the scope of both the `test` and `provided`.
--
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: issues-unsubscribe@celeborn.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-celeborn] pan3793 commented on a diff in pull request #1830: [CELEBORN-839][MR] Support Hadoop MapReduce
Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on code in PR #1830:
URL: https://github.com/apache/incubator-celeborn/pull/1830#discussion_r1321546151
##########
README.md:
##########
@@ -41,12 +41,12 @@ Celeborn Worker's slot count is decided by `total usable disk size / average shu
Celeborn worker's slot count decreases when a partition is allocated and increments when a partition is freed.
## Build
-1.Celeborn supports Spark 2.4/3.0/3.1/3.2/3.3/3.4 and flink 1.14/1.15/1.17.
+1.Celeborn supports Spark 2.4/3.0/3.1/3.2/3.3/3.4 and flink 1.14/1.15/1.17 and mr hadoop-2/hadoop-3.
Review Comment:
We should use the full name of the Apache Software when it is first present in the article.
--
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: issues-unsubscribe@celeborn.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-celeborn] cfmcgrady commented on a diff in pull request #1830: [CELEBORN-839][MR] Support Hadoop MapReduce
Posted by "cfmcgrady (via GitHub)" <gi...@apache.org>.
cfmcgrady commented on code in PR #1830:
URL: https://github.com/apache/incubator-celeborn/pull/1830#discussion_r1309777724
##########
client-mr/mr-shaded/pom.xml:
##########
@@ -0,0 +1,149 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+~ Licensed to the Apache Software Foundation (ASF) under one or more
+~ contributor license agreements. See the NOTICE file distributed with
+~ this work for additional information regarding copyright ownership.
+~ The ASF licenses this file to You under the Apache License, Version 2.0
+~ (the "License"); you may not use this file except in compliance with
+~ the License. You may obtain a copy of the License at
+~
+~ http://www.apache.org/licenses/LICENSE-2.0
+~
+~ Unless required by applicable law or agreed to in writing, software
+~ distributed under the License is distributed on an "AS IS" BASIS,
+~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+~ See the License for the specific language governing permissions and
+~ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.celeborn</groupId>
+ <artifactId>celeborn-parent_${scala.binary.version}</artifactId>
+ <version>${project.version}</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>celeborn-client-mr-shaded-${hadoop.version}</artifactId>
+ <packaging>jar</packaging>
+ <name>Celeborn Shaded Client for MapReduce</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.celeborn</groupId>
+ <artifactId>celeborn-client-mr-${hadoop.version}</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-shade-plugin</artifactId>
+ <configuration>
+ <relocations>
+ <relocation>
+ <pattern>com.google.protobuf</pattern>
+ <shadedPattern>${shading.prefix}.com.google.protobuf</shadedPattern>
+ </relocation>
+ <relocation>
+ <pattern>com.google.common</pattern>
+ <shadedPattern>${shading.prefix}.com.google.common</shadedPattern>
+ </relocation>
+ <relocation>
+ <pattern>io.netty</pattern>
+ <shadedPattern>${shading.prefix}.io.netty</shadedPattern>
+ </relocation>
+ <relocation>
+ <pattern>org.apache.commons</pattern>
+ <shadedPattern>${shading.prefix}.org.apache.commons</shadedPattern>
+ </relocation>
+ <relocation>
+ <pattern>com.fasterxml.jackson.core</pattern>
Review Comment:
for spark-3.4
```
$ ./build/mvn -Pspark-3.4 dependency:tree | grep -i jackson
[INFO] | | \- com.fasterxml.jackson.core:jackson-core:jar:2.12.7:provided
[INFO] | | \- com.fasterxml.jackson.core:jackson-annotations:jar:2.14.2:provided
[INFO] | +- org.json4s:json4s-jackson_2.12:jar:3.7.0-M11:provided
[INFO] | +- com.fasterxml.jackson.core:jackson-databind:jar:2.14.2:provided
[INFO] | +- com.fasterxml.jackson.module:jackson-module-scala_2.12:jar:2.14.2:provided
[INFO] | | | +- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.13.4:provided
[INFO] | \- org.apache.parquet:parquet-jackson:jar:1.12.3:provided
[INFO] | | \- com.fasterxml.jackson.core:jackson-core:jar:2.12.7:provided
[INFO] | | \- com.fasterxml.jackson.core:jackson-annotations:jar:2.14.2:provided
[INFO] | +- org.json4s:json4s-jackson_2.12:jar:3.7.0-M11:provided
[INFO] | +- com.fasterxml.jackson.core:jackson-databind:jar:2.14.2:provided
[INFO] | +- com.fasterxml.jackson.module:jackson-module-scala_2.12:jar:2.14.2:provided
[INFO] | | | +- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.13.4:provided
[INFO] | \- org.apache.parquet:parquet-jackson:jar:1.12.3:provided
[INFO] | | +- org.json4s:json4s-jackson_2.12:jar:3.7.0-M11:provided
[INFO] | | +- com.fasterxml.jackson.module:jackson-module-scala_2.12:jar:2.14.2:provided
[INFO] | | | +- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.13.4:provided
[INFO] | | \- org.apache.parquet:parquet-jackson:jar:1.12.3:provided
[INFO] | +- com.fasterxml.jackson.core:jackson-databind:jar:2.14.2:provided
[INFO] | | +- com.fasterxml.jackson.core:jackson-annotations:jar:2.14.2:provided
[INFO] | | \- com.fasterxml.jackson.core:jackson-core:jar:2.14.2:provided
[INFO] | | \- com.fasterxml.jackson.core:jackson-core:jar:2.12.7:test
[INFO] | | \- com.fasterxml.jackson.core:jackson-annotations:jar:2.14.2:test
[INFO] | +- org.json4s:json4s-jackson_2.12:jar:3.7.0-M11:test
[INFO] | +- com.fasterxml.jackson.core:jackson-databind:jar:2.14.2:test
[INFO] | +- com.fasterxml.jackson.module:jackson-module-scala_2.12:jar:2.14.2:test
[INFO] | | | +- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.13.4:test
[INFO] | \- org.apache.parquet:parquet-jackson:jar:1.12.3:test
```
```
$./build/sbt -Pspark-3.4 celeborn-client-spark-3/Runtime/dependencyTree | grep -i jackson
$ # no any output
```
All of them fall within the scope of both the `test` and `provided`.
--
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: issues-unsubscribe@celeborn.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-celeborn] FMX commented on a diff in pull request #1830: [CELEBORN-839][MR] Support Hadoop MapReduce
Posted by "FMX (via GitHub)" <gi...@apache.org>.
FMX commented on code in PR #1830:
URL: https://github.com/apache/incubator-celeborn/pull/1830#discussion_r1309531520
##########
client-mr/mr/src/main/java/org/apache/hadoop/mapreduce/task/reduce/CelebornShuffleConsumer.java:
##########
@@ -0,0 +1,173 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.mapreduce.task.reduce;
+
+import java.io.IOException;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import org.apache.hadoop.mapred.*;
+import org.apache.hadoop.mapreduce.task.reduce.Shuffle.ShuffleError;
+import org.apache.hadoop.util.Progress;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.celeborn.client.ShuffleClient;
+import org.apache.celeborn.client.read.CelebornInputStream;
+import org.apache.celeborn.common.CelebornConf;
+import org.apache.celeborn.common.identity.UserIdentifier;
+import org.apache.celeborn.util.HadoopUtils;
+
+public class CelebornShuffleConsumer<K, V>
+ implements ShuffleConsumerPlugin<K, V>, ExceptionReporter {
+ private static final Logger logger = LoggerFactory.getLogger(CelebornShuffleConsumer.class);
+ private JobConf mrJobConf;
+ private MergeManager<K, V> merger;
+ private Throwable throwable = null;
+ private Progress copyPhase;
+ private TaskStatus taskStatus;
+ private org.apache.hadoop.mapreduce.TaskAttemptID reduceId;
+ private TaskUmbilicalProtocol umbilical;
+ private Reporter reporter;
+ private ShuffleClientMetrics metrics;
+ private Task reduceTask;
+
+ private ShuffleClient shuffleClient;
+
+ @Override
+ public void init(Context<K, V> context) {
+
+ reduceId = context.getReduceId();
+ mrJobConf = context.getJobConf();
+ JobConf celebornJobConf = new JobConf(HadoopUtils.MR_CELEBORN_CONF);
+
+ umbilical = context.getUmbilical();
+ reporter = context.getReporter();
+ try {
+ this.metrics = createMetrics(reduceId, mrJobConf);
+ } catch (Exception e) {
+ logger.error("Fatal error occurred, failed to get shuffle client metrics.", e);
+ reportException(e);
+ }
+ copyPhase = context.getCopyPhase();
+ taskStatus = context.getStatus();
+ reduceTask = context.getReduceTask();
+
+ String appId = celebornJobConf.get(HadoopUtils.MR_CELEBORN_APPLICATION_ID);
+ String lcHost = celebornJobConf.get(HadoopUtils.MR_CELEBORN_LC_HOST);
+ int lcPort = Integer.parseInt(celebornJobConf.get(HadoopUtils.MR_CELEBORN_LC_PORT));
+ logger.info("Reducer initialized with celeborn {} {} {}", appId, lcHost, lcPort);
+ CelebornConf celebornConf = HadoopUtils.fromYarnConf(mrJobConf);
+ shuffleClient =
+ ShuffleClient.get(
+ appId,
+ lcHost,
+ lcPort,
+ celebornConf,
+ new UserIdentifier(
+ celebornConf.quotaUserSpecificTenant(), celebornConf.quotaUserSpecificUserName()));
+ this.merger = createMergeManager(context);
+ }
+
+ // Merge mapOutput and spill in local disks if necessary
+ protected MergeManager<K, V> createMergeManager(ShuffleConsumerPlugin.Context context) {
+ return new MergeManagerImpl<K, V>(
+ reduceId,
+ mrJobConf,
+ context.getLocalFS(),
+ context.getLocalDirAllocator(),
+ reporter,
+ context.getCodec(),
+ context.getCombinerClass(),
+ context.getCombineCollector(),
+ context.getSpilledRecordsCounter(),
+ context.getReduceCombineInputCounter(),
+ context.getMergedMapOutputsCounter(),
+ this,
+ context.getMergePhase(),
+ context.getMapOutputFile());
+ }
+
+ private ShuffleClientMetrics createMetrics(
+ org.apache.hadoop.mapreduce.TaskAttemptID taskAttemptID, JobConf jobConf)
+ throws NoSuchMethodException, InvocationTargetException, InstantiationException,
+ IllegalAccessException {
+ // for hadoop 3
+ Method createMethod = null;
+ try {
+ ShuffleClientMetrics.class.getDeclaredMethod(
+ "create", org.apache.hadoop.mapreduce.TaskAttemptID.class, JobConf.class);
+ } catch (Exception e) {
+ // ignore this exception because
+ }
+ if (createMethod != null) {
+ return (ShuffleClientMetrics) createMethod.invoke(null, taskAttemptID, jobConf);
+ }
+ // for hadoop 2
+ Constructor constructor =
+ ShuffleClientMetrics.class.getDeclaredConstructor(
+ org.apache.hadoop.mapreduce.TaskAttemptID.class, JobConf.class);
+ constructor.setAccessible(true);
+ return (ShuffleClientMetrics) constructor.newInstance(taskAttemptID, jobConf);
+ }
+
+ @Override
+ public RawKeyValueIterator run() throws IOException, InterruptedException {
+ logger.info(
+ "In reduce:{}, Celeborn mr client start to read shuffle data."
+ + " Create inputstream with params: shuffleId 0 reduceId:{} attemptId:{}",
+ reduceId,
+ reduceId.getTaskID().getId(),
+ reduceId.getId());
+
+ CelebornInputStream shuffleInputStream =
+ shuffleClient.readPartition(
+ 0, reduceId.getTaskID().getId(), reduceId.getId(), 0, Integer.MAX_VALUE);
+ CelebornShuffleFetcher<K, V> shuffleReader =
+ new CelebornShuffleFetcher(
+ reduceId, taskStatus, merger, copyPhase, reporter, metrics, shuffleInputStream);
+ shuffleReader.fetchAndMerge();
+
+ copyPhase.complete();
+ taskStatus.setPhase(TaskStatus.Phase.SORT);
+ reduceTask.statusUpdate(umbilical);
+
+ // Finish the on-going merges...
+ RawKeyValueIterator kvIter = null;
+ try {
+ kvIter = merger.close();
+ } catch (Throwable e) {
+ throw new ShuffleError("Error while doing final merge ", e);
+ }
+
+ logger.info("In reduce: " + reduceId + ", Celeborn mr client read shuffle data complete");
+
+ return kvIter;
+ }
+
+ @Override
+ public void close() {}
Review Comment:
`shuffleClient` is a singleton. It can not close.
--
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: issues-unsubscribe@celeborn.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-celeborn] FMX commented on a diff in pull request #1830: [CELEBORN-839][MR] Support Hadoop MapReduce
Posted by "FMX (via GitHub)" <gi...@apache.org>.
FMX commented on code in PR #1830:
URL: https://github.com/apache/incubator-celeborn/pull/1830#discussion_r1309530706
##########
pom.xml:
##########
@@ -383,6 +378,32 @@
<artifactId>snakeyaml</artifactId>
<version>${snakeyaml.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.hadoop</groupId>
+ <artifactId>${hadoop-client-api.artifact}</artifactId>
+ <version>${hadoop.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.hadoop</groupId>
+ <artifactId>${hadoop-client-runtime.artifact}</artifactId>
+ <version>${hadoop.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.hadoop</groupId>
+ <artifactId>hadoop-mapreduce-client-app</artifactId>
Review Comment:
Hadoop 3 `MRAppMaster` is in this dependency.
--
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: issues-unsubscribe@celeborn.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-celeborn] pan3793 commented on a diff in pull request #1830: [CELEBORN-839][MR] Support Hadoop MapReduce
Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on code in PR #1830:
URL: https://github.com/apache/incubator-celeborn/pull/1830#discussion_r1323898648
##########
README.md:
##########
@@ -41,41 +41,31 @@ Celeborn Worker's slot count is decided by `total usable disk size / average shu
Celeborn worker's slot count decreases when a partition is allocated and increments when a partition is freed.
## Build
-1.Celeborn supports Spark 2.4/3.0/3.1/3.2/3.3/3.4 and flink 1.14/1.15/1.17.
+1.Celeborn supports Spark 2.4/3.0/3.1/3.2/3.3/3.4 and flink 1.14/1.15/1.17 and Hadoop 2/3.
2.Celeborn tested under Java 8 environment.
Build Celeborn
```shell
-./build/make-distribution.sh -Pspark-2.4/-Pspark-3.0/-Pspark-3.1/-Pspark-3.2/-Pspark-3.3/-Pspark-3.4/-Pflink-1.14/-Pflink-1.15/-Pflink-1.17
+./build/make-distribution.sh -Pspark-2.4/-Pspark-3.0/-Pspark-3.1/-Pspark-3.2/-Pspark-3.3/-Pspark-3.4/-Pflink-1.14/-Pflink-1.15/-Pflink-1.17/-Pmr
```
package apache-celeborn-${project.version}-bin.tgz will be generated.
### Package Details
Build procedure will create a compressed package.
-Spark package layout:
+General package layout:
```
├── RELEASE
├── bin
├── conf
├── jars // common jars for master and worker
├── master-jars
├── worker-jars
- ├── sbin
- └── spark // Spark client jars
-```
-
-Flink package layout:
-```
- ├── RELEASE
- ├── bin
- ├── conf
- ├── jars // common jars for master and worker
- ├── master-jars
- ├── worker-jars
- ├── sbin
- └── flink // flink client jars
+ ├── spark // Spark client jars if spark profiles are activated
+ ├── flink // flink client jars if flink profiles are activated
+ ├── mr // mr client jars if hadoop profiles are activated
Review Comment:
```suggestion
├── spark // Spark client jars if spark profiles are activated
├── flink // Flink client jars if flink profiles are activated
├── mr // MapReduce client jars if mr profile is activated
```
##########
README.md:
##########
@@ -41,41 +41,31 @@ Celeborn Worker's slot count is decided by `total usable disk size / average shu
Celeborn worker's slot count decreases when a partition is allocated and increments when a partition is freed.
## Build
-1.Celeborn supports Spark 2.4/3.0/3.1/3.2/3.3/3.4 and flink 1.14/1.15/1.17.
+1.Celeborn supports Spark 2.4/3.0/3.1/3.2/3.3/3.4 and flink 1.14/1.15/1.17 and Hadoop 2/3.
2.Celeborn tested under Java 8 environment.
Build Celeborn
```shell
-./build/make-distribution.sh -Pspark-2.4/-Pspark-3.0/-Pspark-3.1/-Pspark-3.2/-Pspark-3.3/-Pspark-3.4/-Pflink-1.14/-Pflink-1.15/-Pflink-1.17
+./build/make-distribution.sh -Pspark-2.4/-Pspark-3.0/-Pspark-3.1/-Pspark-3.2/-Pspark-3.3/-Pspark-3.4/-Pflink-1.14/-Pflink-1.15/-Pflink-1.17/-Pmr
```
package apache-celeborn-${project.version}-bin.tgz will be generated.
### Package Details
Build procedure will create a compressed package.
-Spark package layout:
+General package layout:
```
├── RELEASE
├── bin
├── conf
├── jars // common jars for master and worker
├── master-jars
├── worker-jars
- ├── sbin
- └── spark // Spark client jars
-```
-
-Flink package layout:
-```
- ├── RELEASE
- ├── bin
- ├── conf
- ├── jars // common jars for master and worker
- ├── master-jars
- ├── worker-jars
- ├── sbin
- └── flink // flink client jars
+ ├── spark // Spark client jars if spark profiles are activated
+ ├── flink // flink client jars if flink profiles are activated
+ ├── mr // mr client jars if hadoop profiles are activated
Review Comment:
```suggestion
├── spark // Spark client jars if spark profiles are activated
├── flink // Flink client jars if flink profiles are activated
├── mr // MapReduce client jars if mr profile is activated
```
--
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: issues-unsubscribe@celeborn.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-celeborn] pan3793 commented on a diff in pull request #1830: [CELEBORN-839][MR] Support Hadoop MapReduce
Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on code in PR #1830:
URL: https://github.com/apache/incubator-celeborn/pull/1830#discussion_r1323905723
##########
client-mr/mr/pom.xml:
##########
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+~ Licensed to the Apache Software Foundation (ASF) under one or more
+~ contributor license agreements. See the NOTICE file distributed with
+~ this work for additional information regarding copyright ownership.
+~ The ASF licenses this file to You under the Apache License, Version 2.0
+~ (the "License"); you may not use this file except in compliance with
+~ the License. You may obtain a copy of the License at
+~
+~ http://www.apache.org/licenses/LICENSE-2.0
+~
+~ Unless required by applicable law or agreed to in writing, software
+~ distributed under the License is distributed on an "AS IS" BASIS,
+~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+~ See the License for the specific language governing permissions and
+~ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.celeborn</groupId>
+ <artifactId>celeborn-parent_${scala.binary.version}</artifactId>
+ <version>${project.version}</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>celeborn-client-mr-${scala.binary.version}</artifactId>
Review Comment:
```suggestion
<artifactId>celeborn-client-mr_${scala.binary.version}</artifactId>
```
--
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: issues-unsubscribe@celeborn.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-celeborn] cfmcgrady commented on a diff in pull request #1830: [CELEBORN-839][MR] Support Hadoop MapReduce
Posted by "cfmcgrady (via GitHub)" <gi...@apache.org>.
cfmcgrady commented on code in PR #1830:
URL: https://github.com/apache/incubator-celeborn/pull/1830#discussion_r1323910474
##########
client-mr/mr-shaded/pom.xml:
##########
@@ -0,0 +1,138 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+~ Licensed to the Apache Software Foundation (ASF) under one or more
+~ contributor license agreements. See the NOTICE file distributed with
+~ this work for additional information regarding copyright ownership.
+~ The ASF licenses this file to You under the Apache License, Version 2.0
+~ (the "License"); you may not use this file except in compliance with
+~ the License. You may obtain a copy of the License at
+~
+~ http://www.apache.org/licenses/LICENSE-2.0
+~
+~ Unless required by applicable law or agreed to in writing, software
+~ distributed under the License is distributed on an "AS IS" BASIS,
+~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+~ See the License for the specific language governing permissions and
+~ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.celeborn</groupId>
+ <artifactId>celeborn-parent_${scala.binary.version}</artifactId>
+ <version>${project.version}</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>celeborn-client-mr-shaded-${scala.binary.version}</artifactId>
+ <packaging>jar</packaging>
+ <name>Celeborn Shaded Client for MapReduce</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.celeborn</groupId>
+ <artifactId>celeborn-client-mr-${scala.binary.version}</artifactId>
Review Comment:
```suggestion
<artifactId>celeborn-client-mr_${scala.binary.version}</artifactId>
```
--
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: issues-unsubscribe@celeborn.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-celeborn] FMX commented on a diff in pull request #1830: [CELEBORN-839][MR] Support Hadoop MapReduce
Posted by "FMX (via GitHub)" <gi...@apache.org>.
FMX commented on code in PR #1830:
URL: https://github.com/apache/incubator-celeborn/pull/1830#discussion_r1323857789
##########
client-mr/mr/pom.xml:
##########
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+~ Licensed to the Apache Software Foundation (ASF) under one or more
+~ contributor license agreements. See the NOTICE file distributed with
+~ this work for additional information regarding copyright ownership.
+~ The ASF licenses this file to You under the Apache License, Version 2.0
+~ (the "License"); you may not use this file except in compliance with
+~ the License. You may obtain a copy of the License at
+~
+~ http://www.apache.org/licenses/LICENSE-2.0
+~
+~ Unless required by applicable law or agreed to in writing, software
+~ distributed under the License is distributed on an "AS IS" BASIS,
+~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+~ See the License for the specific language governing permissions and
+~ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.celeborn</groupId>
+ <artifactId>celeborn-parent_${scala.binary.version}</artifactId>
+ <version>${project.version}</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>celeborn-client-mr-${hadoop.version}</artifactId>
Review Comment:
After some tests, I can ensure that Celeborn builds with Hadoop 3 works fine on a Hadoop 2 cluster.
--
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: issues-unsubscribe@celeborn.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-celeborn] FMX commented on a diff in pull request #1830: [CELEBORN-839][MR] Support Hadoop MapReduce
Posted by "FMX (via GitHub)" <gi...@apache.org>.
FMX commented on code in PR #1830:
URL: https://github.com/apache/incubator-celeborn/pull/1830#discussion_r1311061896
##########
build/make-distribution.sh:
##########
@@ -218,22 +218,43 @@ function build_flink_client {
cp "$PROJECT_DIR"/client-flink/flink-$FLINK_BINARY_VERSION-shaded/target/celeborn-client-flink-${FLINK_BINARY_VERSION}-shaded_$SCALA_VERSION-$VERSION.jar "$DIST_DIR/flink/"
}
+function build_mr_client {
+ HADOOP_VERSION=$("$MVN" help:evaluate -Dexpression=hadoop.version $@ 2>/dev/null \
+ | grep -v "INFO" \
+ | grep -v "WARNING" \
+ | tail -n 1)
+ BUILD_COMMAND=("$MVN" clean package $MVN_DIST_OPT -pl :celeborn-client-mr-shaded-${HADOOP_VERSION} -am $@)
+
+ # Actually build the jar
+ echo -e "\nBuilding with..."
+ echo -e "\$ ${BUILD_COMMAND[@]}\n"
+
+ "${BUILD_COMMAND[@]}"
+
+ ## flink spark client jars
+ mkdir -p "$DIST_DIR/mr"
+ cp "$PROJECT_DIR"/client-mr/mr-shaded/target/celeborn-client-mr-shaded-${HADOOP_VERSION}-$VERSION.jar "$DIST_DIR/mr/"
+}
+
if [ "$RELEASE" == "true" ]; then
build_service
build_spark_client -Pspark-2.4
build_spark_client -Pspark-3.4
build_flink_client -Pflink-1.14
build_flink_client -Pflink-1.15
build_flink_client -Pflink-1.17
+ build_mr_client mr
else
## build release package on demand
build_service $@
- if [[ $@ != *"spark"* && $@ != *"flink"* ]]; then
+ if [[ $@ != *"spark"* && $@ != *"flink"* && $@ != *"mr"* ]]; then
echo "Skip building client."
elif [[ $@ == *"spark"* && $@ != *"flink"* ]]; then
build_spark_client $@
elif [[ $@ == *"flink"* && $@ != *"spark"* ]]; then
build_flink_client $@
+ elif [[ $@ == *"mr"* ]]; then
Review Comment:
I'll add a note about Celeborn can not compile Spark and Flink and MR clients at the same time.
--
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: issues-unsubscribe@celeborn.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-celeborn] FMX commented on a diff in pull request #1830: [CELEBORN-839][MR] Support Hadoop MapReduce
Posted by "FMX (via GitHub)" <gi...@apache.org>.
FMX commented on code in PR #1830:
URL: https://github.com/apache/incubator-celeborn/pull/1830#discussion_r1311061896
##########
build/make-distribution.sh:
##########
@@ -218,22 +218,43 @@ function build_flink_client {
cp "$PROJECT_DIR"/client-flink/flink-$FLINK_BINARY_VERSION-shaded/target/celeborn-client-flink-${FLINK_BINARY_VERSION}-shaded_$SCALA_VERSION-$VERSION.jar "$DIST_DIR/flink/"
}
+function build_mr_client {
+ HADOOP_VERSION=$("$MVN" help:evaluate -Dexpression=hadoop.version $@ 2>/dev/null \
+ | grep -v "INFO" \
+ | grep -v "WARNING" \
+ | tail -n 1)
+ BUILD_COMMAND=("$MVN" clean package $MVN_DIST_OPT -pl :celeborn-client-mr-shaded-${HADOOP_VERSION} -am $@)
+
+ # Actually build the jar
+ echo -e "\nBuilding with..."
+ echo -e "\$ ${BUILD_COMMAND[@]}\n"
+
+ "${BUILD_COMMAND[@]}"
+
+ ## flink spark client jars
+ mkdir -p "$DIST_DIR/mr"
+ cp "$PROJECT_DIR"/client-mr/mr-shaded/target/celeborn-client-mr-shaded-${HADOOP_VERSION}-$VERSION.jar "$DIST_DIR/mr/"
+}
+
if [ "$RELEASE" == "true" ]; then
build_service
build_spark_client -Pspark-2.4
build_spark_client -Pspark-3.4
build_flink_client -Pflink-1.14
build_flink_client -Pflink-1.15
build_flink_client -Pflink-1.17
+ build_mr_client mr
else
## build release package on demand
build_service $@
- if [[ $@ != *"spark"* && $@ != *"flink"* ]]; then
+ if [[ $@ != *"spark"* && $@ != *"flink"* && $@ != *"mr"* ]]; then
echo "Skip building client."
elif [[ $@ == *"spark"* && $@ != *"flink"* ]]; then
build_spark_client $@
elif [[ $@ == *"flink"* && $@ != *"spark"* ]]; then
build_flink_client $@
+ elif [[ $@ == *"mr"* ]]; then
Review Comment:
I'll add a note about Celeborn can not compile Spark or Flink or MR clients at the same time.
--
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: issues-unsubscribe@celeborn.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-celeborn] waitinfuture commented on pull request #1830: [CELEBORN-839][MR] Support Hadoop MapReduce
Posted by "waitinfuture (via GitHub)" <gi...@apache.org>.
waitinfuture commented on PR #1830:
URL: https://github.com/apache/incubator-celeborn/pull/1830#issuecomment-1717689390
Thanks, merging to main
--
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: issues-unsubscribe@celeborn.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-celeborn] pan3793 commented on a diff in pull request #1830: [CELEBORN-839][MR] Support Hadoop MapReduce
Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on code in PR #1830:
URL: https://github.com/apache/incubator-celeborn/pull/1830#discussion_r1323897405
##########
README.md:
##########
@@ -41,41 +41,31 @@ Celeborn Worker's slot count is decided by `total usable disk size / average shu
Celeborn worker's slot count decreases when a partition is allocated and increments when a partition is freed.
## Build
-1.Celeborn supports Spark 2.4/3.0/3.1/3.2/3.3/3.4 and flink 1.14/1.15/1.17.
+1.Celeborn supports Spark 2.4/3.0/3.1/3.2/3.3/3.4 and flink 1.14/1.15/1.17 and Hadoop 2/3.
Review Comment:
```suggestion
1.Celeborn supports Spark 2.4/3.0/3.1/3.2/3.3/3.4, Flink 1.14/1.15/1.17 and Hadoop MapReduce 2/3.
```
--
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: issues-unsubscribe@celeborn.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-celeborn] pan3793 commented on a diff in pull request #1830: [CELEBORN-839][MR] Support Hadoop MapReduce
Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on code in PR #1830:
URL: https://github.com/apache/incubator-celeborn/pull/1830#discussion_r1321550960
##########
README.md:
##########
@@ -293,6 +305,19 @@ taskmanager.network.memory.buffers-per-channel: 0
taskmanager.memory.task.off-heap.size: 512m
```
+### Deploy mr client
Review Comment:
mr => MapReduce
--
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: issues-unsubscribe@celeborn.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-celeborn] cfmcgrady commented on a diff in pull request #1830: [CELEBORN-839][MR] Support Hadoop MapReduce
Posted by "cfmcgrady (via GitHub)" <gi...@apache.org>.
cfmcgrady commented on code in PR #1830:
URL: https://github.com/apache/incubator-celeborn/pull/1830#discussion_r1311852084
##########
pom.xml:
##########
@@ -64,9 +64,14 @@
<maven.version>3.8.8</maven.version>
<flink.version>1.14.6</flink.version>
- <hadoop.version>3.2.4</hadoop.version>
<spark.version>3.3.2</spark.version>
+ <!-- use hadoop-3 as default -->
+ <hadoop.version>3.2.4</hadoop.version>
Review Comment:
Curious, why `3.2.4` not the last release `3.3.6`?
--
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: issues-unsubscribe@celeborn.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-celeborn] FMX commented on a diff in pull request #1830: [CELEBORN-839][MR] Support Hadoop MapReduce
Posted by "FMX (via GitHub)" <gi...@apache.org>.
FMX commented on code in PR #1830:
URL: https://github.com/apache/incubator-celeborn/pull/1830#discussion_r1309525716
##########
tests/mr-it/src/test/java/org/apache/celeborn/tests/mr/WordCountTest.java:
##########
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.celeborn.tests.mr;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.Random;
+
+import com.google.common.collect.Lists;
+import org.apache.hadoop.fs.FSDataOutputStream;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.io.IntWritable;
+import org.apache.hadoop.io.Text;
+import org.apache.hadoop.mapred.FileInputFormat;
+import org.apache.hadoop.mapred.FileOutputFormat;
+import org.apache.hadoop.mapred.JobConf;
+import org.apache.hadoop.mapreduce.Job;
+import org.apache.hadoop.util.Tool;
+import org.junit.Ignore;
+import org.junit.Test;
+
+// This test case is ignored because of class dependencies conflicts.
+@Ignore
Review Comment:
Celeborn has server dependencies conflicts. I'll remove integration test for MR.
--
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: issues-unsubscribe@celeborn.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-celeborn] FMX commented on a diff in pull request #1830: [CELEBORN-839][MR] Support Hadoop MapReduce
Posted by "FMX (via GitHub)" <gi...@apache.org>.
FMX commented on code in PR #1830:
URL: https://github.com/apache/incubator-celeborn/pull/1830#discussion_r1309538415
##########
client-mr/mr/src/main/java/org/apache/celeborn/util/HadoopUtils.java:
##########
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.celeborn.util;
+
+import java.util.Map;
+
+import org.apache.hadoop.mapred.JobConf;
+
+import org.apache.celeborn.common.CelebornConf;
+
+public class HadoopUtils {
+ public static final String MR_CELEBORN_CONF = "celeborn.xml";
+ public static final String MR_CELEBORN_LC_HOST = "celeborn.lifecycleManager.host";
+ public static final String MR_CELEBORN_LC_PORT = "celeborn.lifecycleManager.port";
+ public static final String MR_CELEBORN_APPLICATION_ID = "celeborn.applicationId";
+
+ public static CelebornConf fromYarnConf(JobConf conf) {
+ CelebornConf tmpCelebornConf = new CelebornConf();
+ for (Map.Entry<String, String> property : conf) {
+ String proName = property.getKey();
Review Comment:
Config names in MR are usually lowercase letters.
--
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: issues-unsubscribe@celeborn.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-celeborn] FMX commented on a diff in pull request #1830: [CELEBORN-839][MR] Support Hadoop MapReduce
Posted by "FMX (via GitHub)" <gi...@apache.org>.
FMX commented on code in PR #1830:
URL: https://github.com/apache/incubator-celeborn/pull/1830#discussion_r1309541093
##########
README.md:
##########
@@ -41,12 +41,12 @@ Celeborn Worker's slot count is decided by `total usable disk size / average shu
Celeborn worker's slot count decreases when a partition is allocated and increments when a partition is freed.
## Build
-1.Celeborn supports Spark 2.4/3.0/3.1/3.2/3.3/3.4 and flink 1.14/1.15/1.17.
+1.Celeborn supports Spark 2.4/3.0/3.1/3.2/3.3/3.4 and flink 1.14/1.15/1.17 and mr hadoop-2/hadoop-3.
2.Celeborn tested under Java 8 environment.
Build Celeborn
```shell
-./build/make-distribution.sh -Pspark-2.4/-Pspark-3.0/-Pspark-3.1/-Pspark-3.2/-Pspark-3.3/-Pspark-3.4/-Pflink-1.14/-Pflink-1.15/-Pflink-1.17
+./build/make-distribution.sh -Pspark-2.4/-Pspark-3.0/-Pspark-3.1/-Pspark-3.2/-Pspark-3.3/-Pspark-3.4/-Pflink-1.14/-Pflink-1.15/-Pflink-1.17/-Phadoop-2,mr/-Pmr
Review Comment:
`-Pmr` is build flag for hadoop 3. Because we use hadoop 3 as default.
--
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: issues-unsubscribe@celeborn.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-celeborn] waitinfuture commented on a diff in pull request #1830: [CELEBORN-839][MR] Support Hadoop MapReduce
Posted by "waitinfuture (via GitHub)" <gi...@apache.org>.
waitinfuture commented on code in PR #1830:
URL: https://github.com/apache/incubator-celeborn/pull/1830#discussion_r1307125426
##########
client-mr/mr/src/main/java/org/apache/celeborn/mapreduce/v2/app/MRAppMasterWithCeleborn.java:
##########
@@ -0,0 +1,177 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.celeborn.mapreduce.v2.app;
+
+import java.io.IOException;
+
+import org.apache.hadoop.fs.FSDataOutputStream;
+import org.apache.hadoop.fs.FileStatus;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.fs.permission.FsPermission;
+import org.apache.hadoop.ipc.CallerContext;
+import org.apache.hadoop.mapred.JobConf;
+import org.apache.hadoop.mapreduce.Cluster;
+import org.apache.hadoop.mapreduce.JobSubmissionFiles;
+import org.apache.hadoop.mapreduce.MRJobConfig;
+import org.apache.hadoop.mapreduce.v2.app.MRAppMaster;
+import org.apache.hadoop.mapreduce.v2.util.MRApps;
+import org.apache.hadoop.mapreduce.v2.util.MRWebAppUtil;
+import org.apache.hadoop.util.ExitUtil;
+import org.apache.hadoop.util.ShutdownHookManager;
+import org.apache.hadoop.yarn.YarnUncaughtExceptionHandler;
+import org.apache.hadoop.yarn.api.ApplicationConstants;
+import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
+import org.apache.hadoop.yarn.api.records.ContainerId;
+import org.apache.hadoop.yarn.conf.YarnConfiguration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.celeborn.client.LifecycleManager;
+import org.apache.celeborn.common.CelebornConf;
+import org.apache.celeborn.common.exception.CelebornIOException;
+import org.apache.celeborn.util.HadoopUtils;
+
+public class MRAppMasterWithCeleborn extends MRAppMaster {
+ private static final Logger logger = LoggerFactory.getLogger(MRAppMasterWithCeleborn.class);
+
+ public MRAppMasterWithCeleborn(
+ ApplicationAttemptId applicationAttemptId,
+ ContainerId containerId,
+ String nmHost,
+ int nmPort,
+ int nmHttpPort,
+ long appSubmitTime,
+ JobConf jobConf)
+ throws CelebornIOException {
+ super(applicationAttemptId, containerId, nmHost, nmPort, nmHttpPort, appSubmitTime);
+
+ int numReducers = jobConf.getInt(MRJobConfig.NUM_REDUCES, 0);
+ if (numReducers > 0) {
+ CelebornConf conf = HadoopUtils.fromYarnConf(jobConf);
+ LifecycleManager lifecycleManager =
+ new LifecycleManager(applicationAttemptId.toString(), conf);
+ String lcHost = lifecycleManager.getHost();
+ int lcPort = lifecycleManager.getPort();
+ logger.info("RMAppMaster initialized with {} {} {}", lcHost, lcPort, applicationAttemptId);
+ JobConf lcConf = new JobConf();
+ lcConf.clear();
+ lcConf.set(HadoopUtils.MR_CELEBORN_LC_HOST, lcHost);
+ lcConf.set(HadoopUtils.MR_CELEBORN_LC_PORT, lcPort + "");
+ lcConf.set(HadoopUtils.MR_CELEBORN_APPLICATION_ID, applicationAttemptId.toString());
+ writeLifecycleManagerConfToTask(jobConf, lcConf);
+ }
+ }
+
+ void writeLifecycleManagerConfToTask(JobConf conf, JobConf lcConf) throws CelebornIOException {
+ try {
+ FileSystem fs = new Cluster(conf).getFileSystem();
Review Comment:
Not sure about the cost to new a `Cluster` object, are there lighter ways to get the fs? If this is the normal way to get the fs, please correct me.
##########
client-mr/mr/src/main/java/org/apache/hadoop/mapred/CelebornSortBasedPusher.java:
##########
@@ -0,0 +1,338 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.mapred;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.*;
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.apache.hadoop.io.RawComparator;
+import org.apache.hadoop.io.WritableUtils;
+import org.apache.hadoop.io.serializer.Serializer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.celeborn.client.ShuffleClient;
+import org.apache.celeborn.common.CelebornConf;
+import org.apache.celeborn.common.unsafe.Platform;
+import org.apache.celeborn.common.util.Utils;
+
+public class CelebornSortBasedPusher<K, V> extends OutputStream {
+ final Logger logger = LoggerFactory.getLogger(CelebornSortBasedPusher.class);
+ private final int mapId;
+ private final int attempt;
+ private final int numMappers;
+ private final int numReducers;
+ private final ShuffleClient shuffleClient;
+ private final int maxIOBufferSize;
+ private final int spillIOBufferSize;
+ private final Serializer<K> kSer;
+ private final Serializer<V> vSer;
+ private final RawComparator<K> comparator;
+ private final AtomicReference<Exception> exception = new AtomicReference<>();
+ private final Counters.Counter mapOutputByteCounter;
+ private final Counters.Counter mapOutputRecordCounter;
+ private final Map<Integer, List<SerializedKV>> currentSerializedKVs;
+ private int writePos;
+ private byte[] serializedKV;
+ private final int maxPushDataSize;
+
+ public CelebornSortBasedPusher(
+ int numMappers,
+ int numReducers,
+ int mapId,
+ int attemptId,
+ Serializer<K> kSer,
+ Serializer<V> vSer,
+ int maxIOBufferSize,
+ int spillIOBufferSize,
+ RawComparator<K> comparator,
+ Counters.Counter mapOutputByteCounter,
+ Counters.Counter mapOutputRecordCounter,
+ ShuffleClient shuffleClient,
+ CelebornConf celebornConf) {
+ this.numMappers = numMappers;
+ this.numReducers = numReducers;
+ this.mapId = mapId;
+ this.attempt = attemptId;
+ this.kSer = kSer;
+ this.vSer = vSer;
+ this.maxIOBufferSize = maxIOBufferSize;
+ this.spillIOBufferSize = spillIOBufferSize;
+ this.mapOutputByteCounter = mapOutputByteCounter;
+ this.mapOutputRecordCounter = mapOutputRecordCounter;
+ this.comparator = comparator;
+ this.shuffleClient = shuffleClient;
+ currentSerializedKVs = new HashMap<>();
+ serializedKV = new byte[maxIOBufferSize];
+ maxPushDataSize = (int) celebornConf.clientMrMaxPushData();
+ logger.info(
+ "Sort based push initialized with"
+ + " numMappers:{} numReducers:{} mapId:{} attemptId:{}"
+ + " maxIOBufferSize:{} spillIOBufferSize:{}",
+ numMappers,
+ numReducers,
+ mapId,
+ attemptId,
+ maxIOBufferSize,
+ spillIOBufferSize);
+ try {
+ kSer.open(this);
+ vSer.open(this);
+ } catch (IOException e) {
+ exception.compareAndSet(null, e);
+ }
+ }
+
+ public void insert(K key, V value, int partition) {
+ try {
+ if (writePos >= spillIOBufferSize) {
+ // needs to sort and flush data
+ if (logger.isDebugEnabled()) {
+ logger.debug(
+ "Data is large enough {}/{}/{}, trigger sort and flush",
+ Utils.bytesToString(writePos),
+ Utils.bytesToString(spillIOBufferSize),
+ Utils.bytesToString(maxIOBufferSize));
+ }
+ synchronized (this) {
+ sortKVs();
+ sendKVAndUpdateWritePos();
+ }
+ }
+ int dataLen = insertRecordInternal(key, value, partition);
+ if (logger.isDebugEnabled()) {
+ logger.debug(
+ "Sort based pusher insert into partition:{} with {} bytes", partition, dataLen);
+ }
+ mapOutputRecordCounter.increment(1);
+ mapOutputByteCounter.increment(dataLen);
+ } catch (IOException e) {
+ exception.compareAndSet(null, e);
+ }
+ }
+
+ private void sendKVAndUpdateWritePos() throws IOException {
+ for (Map.Entry<Integer, List<SerializedKV>> partitionKVEntry :
+ currentSerializedKVs.entrySet()) {
+ List<SerializedKV> kvs = partitionKVEntry.getValue();
+ synchronized (kvs) {
+ int partition = partitionKVEntry.getKey();
+ List<SerializedKV> localKVs = new ArrayList<>();
+ int partitionKVTotalLen = 0;
+ // process buffers for specific partition
+ for (SerializedKV kv : kvs) {
+ partitionKVTotalLen += kv.kLen + kv.vLen;
+ localKVs.add(kv);
+ if (partitionKVTotalLen > maxPushDataSize) {
+ // limit max size of pushdata to avoid possible memory issue in Celeborn worker
+ // data layout
+ // pushdata header (16) + pushDataLen(4) +
+ // [keyLen(4)+valLen(4)+serializedRecord(x)][...]
+ sendSortedBuffersPartition(partition, localKVs, partitionKVTotalLen);
+ localKVs.clear();
+ partitionKVTotalLen = 0;
+ }
+ }
+ if (!localKVs.isEmpty()) {
+ sendSortedBuffersPartition(partition, localKVs, partitionKVTotalLen);
+ }
+ kvs.clear();
+ }
+ }
+ // all data sent
+ currentSerializedKVs.clear();
+ writePos = 0;
+ }
+
+ private void sendSortedBuffersPartition(
+ int partition, List<SerializedKV> localKVs, int partitionKVTotalLen) throws IOException {
+ int extraSize = 0;
+ for (SerializedKV localKV : localKVs) {
+ extraSize += WritableUtils.getVIntSize(localKV.kLen);
+ extraSize += WritableUtils.getVIntSize(localKV.vLen);
+ }
+ // copied from hadoop logic
+ extraSize += WritableUtils.getVIntSize(-1);
+ extraSize += WritableUtils.getVIntSize(-1);
+ // whole buffer's size + [(keyLen+valueLen)+(serializedKey+serializedValue)]
+ byte[] pkvs = new byte[4 + extraSize + partitionKVTotalLen];
+ int pkvsPos = 4;
+ Platform.putInt(pkvs, Platform.BYTE_ARRAY_OFFSET, partitionKVTotalLen + extraSize);
+ for (SerializedKV kv : localKVs) {
+ int recordLen = kv.kLen + kv.vLen;
+ // write key len
+ pkvsPos = writeDataInt(pkvs, pkvsPos, kv.kLen);
+ // write value len
+ pkvsPos = writeDataInt(pkvs, pkvsPos, kv.vLen);
+ // write serialized record
+ System.arraycopy(serializedKV, kv.offset, pkvs, pkvsPos, recordLen);
+ pkvsPos += recordLen;
+ }
+ // finally write -1 two times
+ pkvsPos = writeDataInt(pkvs, pkvsPos, -1);
+ writeDataInt(pkvs, pkvsPos, -1);
+ int compressedSize =
+ shuffleClient.pushData(
+ 0,
Review Comment:
Better to comment about why shuffleId is always set to 0
##########
client-mr/mr/src/main/java/org/apache/hadoop/mapred/CelebornSortBasedPusher.java:
##########
@@ -0,0 +1,341 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.mapred;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.*;
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.apache.hadoop.io.RawComparator;
+import org.apache.hadoop.io.WritableUtils;
+import org.apache.hadoop.io.serializer.Serializer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.celeborn.client.ShuffleClient;
+import org.apache.celeborn.common.CelebornConf;
+import org.apache.celeborn.common.unsafe.Platform;
+import org.apache.celeborn.common.util.Utils;
+
+public class CelebornSortBasedPusher<K, V> extends OutputStream {
+ final Logger logger = LoggerFactory.getLogger(CelebornSortBasedPusher.class);
+ private final int mapId;
+ private final int attempt;
+ private final int numMappers;
+ private final int numReducers;
+ private final ShuffleClient shuffleClient;
+ private final int maxIOBufferSize;
+ private final int spillIOBufferSize;
+ private final Serializer<K> kSer;
+ private final Serializer<V> vSer;
+ private final RawComparator<K> comparator;
+ private final AtomicReference<Exception> exception = new AtomicReference<>();
+ private final Counters.Counter mapOutputByteCounter;
+ private final Counters.Counter mapOutputRecordCounter;
+ private final Map<Integer, List<SerializedKV>> currentSerializedKVs;
+ private int writePos;
+ private byte[] serializedKV;
+ private final int maxPushDataSize;
+
+ public CelebornSortBasedPusher(
+ int numMappers,
+ int numReducers,
+ int mapId,
+ int attemptId,
+ Serializer<K> kSer,
+ Serializer<V> vSer,
+ int maxIOBufferSize,
+ int spillIOBufferSize,
+ RawComparator<K> comparator,
+ Counters.Counter mapOutputByteCounter,
+ Counters.Counter mapOutputRecordCounter,
+ ShuffleClient shuffleClient,
+ CelebornConf celebornConf) {
+ this.numMappers = numMappers;
+ this.numReducers = numReducers;
+ this.mapId = mapId;
+ this.attempt = attemptId;
+ this.kSer = kSer;
+ this.vSer = vSer;
+ this.maxIOBufferSize = maxIOBufferSize;
+ this.spillIOBufferSize = spillIOBufferSize;
+ this.mapOutputByteCounter = mapOutputByteCounter;
+ this.mapOutputRecordCounter = mapOutputRecordCounter;
+ this.comparator = comparator;
+ this.shuffleClient = shuffleClient;
+ currentSerializedKVs = new HashMap<>();
+ serializedKV = new byte[maxIOBufferSize];
+ maxPushDataSize = (int) celebornConf.clientMrMaxPushData();
+ logger.info(
+ "Sort based push initialized with"
+ + " numMappers:{} numReducers:{} mapId:{} attemptId:{}"
+ + " maxIOBufferSize:{} spillIOBufferSize:{}",
+ numMappers,
+ numReducers,
+ mapId,
+ attemptId,
+ maxIOBufferSize,
+ spillIOBufferSize);
+ try {
+ kSer.open(this);
+ vSer.open(this);
+ } catch (IOException e) {
+ exception.compareAndSet(null, e);
+ }
+ }
+
+ public void insert(K key, V value, int partition) {
+ try {
+ if (writePos >= spillIOBufferSize) {
+ // needs to sort and flush data
+ if (logger.isDebugEnabled()) {
+ logger.debug(
+ "Data is large enough {}/{}/{}, trigger sort and flush",
+ Utils.bytesToString(writePos),
+ Utils.bytesToString(spillIOBufferSize),
+ Utils.bytesToString(maxIOBufferSize));
+ }
+ synchronized (this) {
+ sortKVs();
+ sendKVAndUpdateWritePos();
+ }
+ }
+ int dataLen = insertRecordInternal(key, value, partition);
+ if (logger.isDebugEnabled()) {
+ logger.debug(
+ "Sort based pusher insert into partition:{} with {} bytes", partition, dataLen);
+ }
+ mapOutputRecordCounter.increment(1);
+ mapOutputByteCounter.increment(dataLen);
+ } catch (IOException e) {
+ exception.compareAndSet(null, e);
+ }
+ }
+
+ private void sendKVAndUpdateWritePos() throws IOException {
+ for (Map.Entry<Integer, List<SerializedKV>> partitionKVEntry :
+ currentSerializedKVs.entrySet()) {
+ List<SerializedKV> kvs = partitionKVEntry.getValue();
+ synchronized (kvs) {
+ int partition = partitionKVEntry.getKey();
+ List<SerializedKV> localKVs = new ArrayList<>();
+ int partitionKVTotalLen = 0;
+ // process buffers for specific partition
+ for (SerializedKV kv : kvs) {
+ partitionKVTotalLen += kv.kLen + kv.vLen;
+ localKVs.add(kv);
+ if (partitionKVTotalLen > maxPushDataSize) {
+ // limit max size of pushdata to avoid possible memory issue in Celeborn worker
+ // data layout
+ // pushdata header (16) + pushDataLen(4) +
+ // [varKeyLen+varValLen+serializedRecord(x)][...]
+ sendSortedBuffersPartition(partition, localKVs, partitionKVTotalLen);
+ localKVs.clear();
+ partitionKVTotalLen = 0;
+ }
+ }
+ if (!localKVs.isEmpty()) {
+ sendSortedBuffersPartition(partition, localKVs, partitionKVTotalLen);
+ }
+ kvs.clear();
+ }
+ }
+ // all data sent
+ currentSerializedKVs.clear();
+ writePos = 0;
+ }
+
+ private void sendSortedBuffersPartition(
+ int partition, List<SerializedKV> localKVs, int partitionKVTotalLen) throws IOException {
+ int extraSize = 0;
+ for (SerializedKV localKV : localKVs) {
+ extraSize += WritableUtils.getVIntSize(localKV.kLen);
+ extraSize += WritableUtils.getVIntSize(localKV.vLen);
+ }
+ // copied from hadoop logic
+ extraSize += WritableUtils.getVIntSize(-1);
+ extraSize += WritableUtils.getVIntSize(-1);
+ // whole buffer's size + [(keyLen+valueLen)+(serializedKey+serializedValue)]
+ byte[] pkvs = new byte[4 + extraSize + partitionKVTotalLen];
+ int pkvsPos = 4;
+ Platform.putInt(pkvs, Platform.BYTE_ARRAY_OFFSET, partitionKVTotalLen + extraSize);
+ for (SerializedKV kv : localKVs) {
+ int recordLen = kv.kLen + kv.vLen;
+ // write key len
+ pkvsPos = writeVLong(pkvs, pkvsPos, kv.kLen);
+ // write value len
+ pkvsPos = writeVLong(pkvs, pkvsPos, kv.vLen);
+ // write serialized record
+ System.arraycopy(serializedKV, kv.offset, pkvs, pkvsPos, recordLen);
+ pkvsPos += recordLen;
+ }
+ // finally write -1 two times
+ pkvsPos = writeVLong(pkvs, pkvsPos, -1);
+ writeVLong(pkvs, pkvsPos, -1);
+ int compressedSize =
+ shuffleClient.pushData(
+ 0,
+ mapId,
+ attempt,
+ partition,
+ pkvs,
+ 0,
+ 4 + extraSize + partitionKVTotalLen,
+ numMappers,
+ numReducers);
+ if (logger.isDebugEnabled()) {
+ logger.debug(
+ "Send sorted buffer mapId:{} attemptId:{} to partition:{} uncompressed size:{} compressed size:{}",
+ mapId,
+ attempt,
+ partition,
+ Utils.bytesToString(4 + extraSize + partitionKVTotalLen),
+ Utils.bytesToString(compressedSize));
+ }
+ }
+
+ /**
+ * Write variable length int to array Modified from
+ * org.apache.hadoop.io.WritableUtils#writeVLong(java.io.DataOutput, long)
+ */
+ private int writeVLong(byte[] data, int offset, long dataInt) {
+ if (dataInt >= -112L && dataInt <= 127L) {
+ data[offset++] = (byte) ((int) dataInt);
+ return offset;
+ }
+
+ int len = -112;
+ if (dataInt < 0L) {
+ dataInt ^= -1L;
+ len = -120;
+ }
+
+ long tmp = dataInt;
+ while (tmp != 0) {
+ tmp = tmp >> 8;
+ len--;
+ }
+
+ data[offset++] = (byte) len;
+
+ len = len < -120 ? -(len + 120) : -(len + 112);
+
+ for (int idx = len; idx != 0; --idx) {
+ int shiftBits = (idx - 1) * 8;
+ long mask = 0xFFL << shiftBits;
+ data[offset++] = ((byte) ((int) ((dataInt & mask) >> shiftBits)));
+ }
+ return offset;
+ }
+
+ private void sortKVs() {
+ for (Map.Entry<Integer, List<SerializedKV>> partitionKVEntry :
+ currentSerializedKVs.entrySet()) {
+ partitionKVEntry
+ .getValue()
+ .sort(
+ (o1, o2) ->
+ comparator.compare(
+ serializedKV, o1.offset, o1.kLen, serializedKV, o2.offset, o2.kLen));
+ }
+ }
+
+ private int insertRecordInternal(K key, V value, int partition) throws IOException {
Review Comment:
Should also consider giant records, maybe in later PRs
##########
client/src/main/java/org/apache/celeborn/client/read/CelebornInputStream.java:
##########
@@ -93,8 +93,22 @@ public int read(byte[] b, int off, int len) throws IOException {
@Override
public void setCallback(MetricsCallback callback) {}
+
+ @Override
+ public int totalPartitionsToRead() {
+ return 0;
+ }
+
+ @Override
+ public int readPartitions() {
+ return 0;
+ }
};
+ public abstract int totalPartitionsToRead();
Review Comment:
Better to move these methods after `logger`
##########
client-mr/mr/src/main/java/org/apache/hadoop/mapreduce/task/reduce/CelebornShuffleConsumer.java:
##########
@@ -0,0 +1,170 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.mapreduce.task.reduce;
+
+import java.io.IOException;
+
+import org.apache.hadoop.mapred.*;
+import org.apache.hadoop.mapreduce.task.reduce.Shuffle.ShuffleError;
+import org.apache.hadoop.util.Progress;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.celeborn.client.ShuffleClient;
+import org.apache.celeborn.client.read.CelebornInputStream;
+import org.apache.celeborn.common.CelebornConf;
+import org.apache.celeborn.common.identity.UserIdentifier;
+import org.apache.celeborn.reflect.DynConstructors;
+import org.apache.celeborn.reflect.DynMethods;
+import org.apache.celeborn.util.HadoopUtils;
+
+public class CelebornShuffleConsumer<K, V>
+ implements ShuffleConsumerPlugin<K, V>, ExceptionReporter {
+ private static final Logger logger = LoggerFactory.getLogger(CelebornShuffleConsumer.class);
+ private JobConf mrJobConf;
+ private MergeManager<K, V> merger;
+ private Throwable throwable = null;
+ private Progress copyPhase;
+ private TaskStatus taskStatus;
+ private org.apache.hadoop.mapreduce.TaskAttemptID reduceId;
+ private TaskUmbilicalProtocol umbilical;
+ private Reporter reporter;
+ private ShuffleClientMetrics metrics;
+ private Task reduceTask;
+ private ShuffleClient shuffleClient;
+
+ @Override
+ public void init(Context<K, V> context) {
+
+ reduceId = context.getReduceId();
+ mrJobConf = context.getJobConf();
+ JobConf celebornJobConf = new JobConf(HadoopUtils.MR_CELEBORN_CONF);
+
+ umbilical = context.getUmbilical();
+ reporter = context.getReporter();
+ try {
+ this.metrics = createMetrics(reduceId, mrJobConf);
+ } catch (Exception e) {
+ logger.error("Fatal error occurred, failed to get shuffle client metrics.", e);
+ reportException(e);
+ }
+ copyPhase = context.getCopyPhase();
+ taskStatus = context.getStatus();
+ reduceTask = context.getReduceTask();
+
+ String appId = celebornJobConf.get(HadoopUtils.MR_CELEBORN_APPLICATION_ID);
+ String lcHost = celebornJobConf.get(HadoopUtils.MR_CELEBORN_LC_HOST);
+ int lcPort = Integer.parseInt(celebornJobConf.get(HadoopUtils.MR_CELEBORN_LC_PORT));
+ logger.info("Reducer initialized with celeborn {} {} {}", appId, lcHost, lcPort);
+ CelebornConf celebornConf = HadoopUtils.fromYarnConf(mrJobConf);
+ shuffleClient =
+ ShuffleClient.get(
+ appId,
+ lcHost,
+ lcPort,
+ celebornConf,
+ new UserIdentifier(
+ celebornConf.quotaUserSpecificTenant(), celebornConf.quotaUserSpecificUserName()));
+ this.merger = createMergeManager(context);
+ }
+
+ // Merge mapOutput and spill in local disks if necessary
+ protected MergeManager<K, V> createMergeManager(ShuffleConsumerPlugin.Context context) {
+ return new MergeManagerImpl<K, V>(
+ reduceId,
+ mrJobConf,
+ context.getLocalFS(),
+ context.getLocalDirAllocator(),
+ reporter,
+ context.getCodec(),
+ context.getCombinerClass(),
+ context.getCombineCollector(),
+ context.getSpilledRecordsCounter(),
+ context.getReduceCombineInputCounter(),
+ context.getMergedMapOutputsCounter(),
+ this,
+ context.getMergePhase(),
+ context.getMapOutputFile());
+ }
+
+ private ShuffleClientMetrics createMetrics(
+ org.apache.hadoop.mapreduce.TaskAttemptID taskAttemptID, JobConf jobConf)
+ throws NoSuchMethodException {
+ // for hadoop 3
+ try {
+ return DynMethods.builder("create")
+ .impl(
+ ShuffleClientMetrics.class,
+ org.apache.hadoop.mapreduce.TaskAttemptID.class,
+ JobConf.class)
+ .buildStaticChecked()
+ .invoke(taskAttemptID, jobConf);
+ } catch (Exception e) {
+ // ignore this exception because the createMetrics might use hadoop2
+ }
+ // for hadoop 2
+ return DynConstructors.builder(ShuffleClientMetrics.class)
+ .hiddenImpl(new Class[] {org.apache.hadoop.mapreduce.TaskAttemptID.class, JobConf.class})
+ .buildChecked()
+ .invoke(null, taskAttemptID, jobConf);
+ }
+
+ @Override
+ public RawKeyValueIterator run() throws IOException, InterruptedException {
+ logger.info(
+ "In reduce:{}, Celeborn mr client start to read shuffle data."
+ + " Create inputstream with params: shuffleId 0 reduceId:{} attemptId:{}",
+ reduceId,
+ reduceId.getTaskID().getId(),
+ reduceId.getId());
+
+ CelebornInputStream shuffleInputStream =
+ shuffleClient.readPartition(
+ 0, reduceId.getTaskID().getId(), reduceId.getId(), 0, Integer.MAX_VALUE);
+ CelebornShuffleFetcher<K, V> shuffleReader =
+ new CelebornShuffleFetcher(
+ reduceId, taskStatus, merger, copyPhase, reporter, metrics, shuffleInputStream);
+ shuffleReader.fetchAndMerge();
+
+ copyPhase.complete();
+ taskStatus.setPhase(TaskStatus.Phase.SORT);
+ reduceTask.statusUpdate(umbilical);
+
+ // Finish the on-going merges...
+ RawKeyValueIterator kvIter = null;
Review Comment:
No need to initialize to null
##########
client/src/main/java/org/apache/celeborn/client/read/CelebornInputStream.java:
##########
@@ -93,8 +93,22 @@ public int read(byte[] b, int off, int len) throws IOException {
@Override
public void setCallback(MetricsCallback callback) {}
+
+ @Override
+ public int totalPartitionsToRead() {
+ return 0;
+ }
+
+ @Override
+ public int readPartitions() {
Review Comment:
partitionsRead()
##########
client-mr/mr/src/main/java/org/apache/celeborn/mapreduce/v2/app/MRAppMasterWithCeleborn.java:
##########
@@ -0,0 +1,178 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.celeborn.mapreduce.v2.app;
+
+import java.io.IOException;
+
+import org.apache.hadoop.fs.FSDataOutputStream;
+import org.apache.hadoop.fs.FileStatus;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.fs.permission.FsPermission;
+import org.apache.hadoop.ipc.CallerContext;
+import org.apache.hadoop.mapred.JobConf;
+import org.apache.hadoop.mapreduce.Cluster;
+import org.apache.hadoop.mapreduce.JobSubmissionFiles;
+import org.apache.hadoop.mapreduce.MRJobConfig;
+import org.apache.hadoop.mapreduce.v2.app.MRAppMaster;
+import org.apache.hadoop.mapreduce.v2.util.MRApps;
+import org.apache.hadoop.mapreduce.v2.util.MRWebAppUtil;
+import org.apache.hadoop.util.ExitUtil;
+import org.apache.hadoop.util.ShutdownHookManager;
+import org.apache.hadoop.yarn.YarnUncaughtExceptionHandler;
+import org.apache.hadoop.yarn.api.ApplicationConstants;
+import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
+import org.apache.hadoop.yarn.api.records.ContainerId;
+import org.apache.hadoop.yarn.conf.YarnConfiguration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.celeborn.client.LifecycleManager;
+import org.apache.celeborn.common.CelebornConf;
+import org.apache.celeborn.common.exception.CelebornIOException;
+import org.apache.celeborn.util.HadoopUtils;
+
+public class MRAppMasterWithCeleborn extends MRAppMaster {
+ private static final Logger logger = LoggerFactory.getLogger(MRAppMasterWithCeleborn.class);
+
+ public MRAppMasterWithCeleborn(
+ ApplicationAttemptId applicationAttemptId,
+ ContainerId containerId,
+ String nmHost,
+ int nmPort,
+ int nmHttpPort,
+ long appSubmitTime,
+ JobConf jobConf)
+ throws CelebornIOException {
+ super(applicationAttemptId, containerId, nmHost, nmPort, nmHttpPort, appSubmitTime);
+
+ int numReducers = jobConf.getInt(MRJobConfig.NUM_REDUCES, 0);
+ if (numReducers > 0) {
+ CelebornConf conf = HadoopUtils.fromYarnConf(jobConf);
+ LifecycleManager lifecycleManager =
+ new LifecycleManager(applicationAttemptId.toString(), conf);
+ String lcHost = lifecycleManager.getHost();
Review Comment:
lmHost, and other places
##########
client-mr/mr/src/main/java/org/apache/celeborn/mapreduce/v2/app/MRAppMasterWithCeleborn.java:
##########
@@ -0,0 +1,178 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.celeborn.mapreduce.v2.app;
+
+import java.io.IOException;
+
+import org.apache.hadoop.fs.FSDataOutputStream;
+import org.apache.hadoop.fs.FileStatus;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.fs.permission.FsPermission;
+import org.apache.hadoop.ipc.CallerContext;
+import org.apache.hadoop.mapred.JobConf;
+import org.apache.hadoop.mapreduce.Cluster;
+import org.apache.hadoop.mapreduce.JobSubmissionFiles;
+import org.apache.hadoop.mapreduce.MRJobConfig;
+import org.apache.hadoop.mapreduce.v2.app.MRAppMaster;
+import org.apache.hadoop.mapreduce.v2.util.MRApps;
+import org.apache.hadoop.mapreduce.v2.util.MRWebAppUtil;
+import org.apache.hadoop.util.ExitUtil;
+import org.apache.hadoop.util.ShutdownHookManager;
+import org.apache.hadoop.yarn.YarnUncaughtExceptionHandler;
+import org.apache.hadoop.yarn.api.ApplicationConstants;
+import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
+import org.apache.hadoop.yarn.api.records.ContainerId;
+import org.apache.hadoop.yarn.conf.YarnConfiguration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.celeborn.client.LifecycleManager;
+import org.apache.celeborn.common.CelebornConf;
+import org.apache.celeborn.common.exception.CelebornIOException;
+import org.apache.celeborn.util.HadoopUtils;
+
+public class MRAppMasterWithCeleborn extends MRAppMaster {
+ private static final Logger logger = LoggerFactory.getLogger(MRAppMasterWithCeleborn.class);
+
+ public MRAppMasterWithCeleborn(
+ ApplicationAttemptId applicationAttemptId,
+ ContainerId containerId,
+ String nmHost,
+ int nmPort,
+ int nmHttpPort,
+ long appSubmitTime,
+ JobConf jobConf)
+ throws CelebornIOException {
+ super(applicationAttemptId, containerId, nmHost, nmPort, nmHttpPort, appSubmitTime);
+
+ int numReducers = jobConf.getInt(MRJobConfig.NUM_REDUCES, 0);
+ if (numReducers > 0) {
+ CelebornConf conf = HadoopUtils.fromYarnConf(jobConf);
+ LifecycleManager lifecycleManager =
+ new LifecycleManager(applicationAttemptId.toString(), conf);
+ String lcHost = lifecycleManager.getHost();
+ int lcPort = lifecycleManager.getPort();
+ logger.info("RMAppMaster initialized with {} {} {}", lcHost, lcPort, applicationAttemptId);
+ JobConf lcConf = new JobConf();
+ lcConf.clear();
+ lcConf.set(HadoopUtils.MR_CELEBORN_LC_HOST, lcHost);
+ lcConf.set(HadoopUtils.MR_CELEBORN_LC_PORT, lcPort + "");
+ lcConf.set(HadoopUtils.MR_CELEBORN_APPLICATION_ID, applicationAttemptId.toString());
+ writeLifecycleManagerConfToTask(jobConf, lcConf);
+ }
+ }
+
+ void writeLifecycleManagerConfToTask(JobConf conf, JobConf lcConf) throws CelebornIOException {
+ try {
+ FileSystem fs = new Cluster(conf).getFileSystem();
+ String jobDirStr = conf.get(MRJobConfig.MAPREDUCE_JOB_DIR);
+ Path celebornExtraConf = new Path(jobDirStr, HadoopUtils.MR_CELEBORN_CONF);
+
+ try (FSDataOutputStream out =
+ FileSystem.create(
+ fs, celebornExtraConf, new FsPermission(JobSubmissionFiles.JOB_FILE_PERMISSION))) {
+ lcConf.writeXml(out);
+ }
+ FileStatus status = fs.getFileStatus(celebornExtraConf);
+ long currentTs = status.getModificationTime();
+ String uri = fs.getUri() + Path.SEPARATOR + celebornExtraConf.toUri();
+ String files = conf.get(MRJobConfig.CACHE_FILES);
+ conf.set(MRJobConfig.CACHE_FILES, files == null ? uri : uri + "," + files);
+ String ts = conf.get(MRJobConfig.CACHE_FILE_TIMESTAMPS);
+ conf.set(
+ MRJobConfig.CACHE_FILE_TIMESTAMPS,
+ ts == null ? String.valueOf(currentTs) : currentTs + "," + ts);
+ String vis = conf.get(MRJobConfig.CACHE_FILE_VISIBILITIES);
+ conf.set(MRJobConfig.CACHE_FILE_VISIBILITIES, vis == null ? "false" : "false" + "," + vis);
+ long size = status.getLen();
+ String sizes = conf.get(MRJobConfig.CACHE_FILES_SIZES);
+ conf.set(
+ MRJobConfig.CACHE_FILES_SIZES, sizes == null ? String.valueOf(size) : size + "," + sizes);
+ } catch (InterruptedException | IOException e) {
+ logger.error("Upload extra conf exception", e);
+ throw new CelebornIOException("Upload extra conf exception ", e);
+ }
+ }
+
+ private static String getSysEnvAndValidateInputParam(String envName) throws IOException {
Review Comment:
better to rename to `ensureGetSysEnv` or `getSysEnvOrThrow`
##########
client-mr/mr/src/main/java/org/apache/hadoop/mapred/CelebornSortBasedPusher.java:
##########
@@ -0,0 +1,338 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.mapred;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.*;
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.apache.hadoop.io.RawComparator;
+import org.apache.hadoop.io.WritableUtils;
+import org.apache.hadoop.io.serializer.Serializer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.celeborn.client.ShuffleClient;
+import org.apache.celeborn.common.CelebornConf;
+import org.apache.celeborn.common.unsafe.Platform;
+import org.apache.celeborn.common.util.Utils;
+
+public class CelebornSortBasedPusher<K, V> extends OutputStream {
+ final Logger logger = LoggerFactory.getLogger(CelebornSortBasedPusher.class);
+ private final int mapId;
+ private final int attempt;
+ private final int numMappers;
+ private final int numReducers;
+ private final ShuffleClient shuffleClient;
+ private final int maxIOBufferSize;
+ private final int spillIOBufferSize;
+ private final Serializer<K> kSer;
+ private final Serializer<V> vSer;
+ private final RawComparator<K> comparator;
+ private final AtomicReference<Exception> exception = new AtomicReference<>();
+ private final Counters.Counter mapOutputByteCounter;
+ private final Counters.Counter mapOutputRecordCounter;
+ private final Map<Integer, List<SerializedKV>> currentSerializedKVs;
+ private int writePos;
+ private byte[] serializedKV;
+ private final int maxPushDataSize;
+
+ public CelebornSortBasedPusher(
+ int numMappers,
+ int numReducers,
+ int mapId,
+ int attemptId,
+ Serializer<K> kSer,
+ Serializer<V> vSer,
+ int maxIOBufferSize,
+ int spillIOBufferSize,
+ RawComparator<K> comparator,
+ Counters.Counter mapOutputByteCounter,
+ Counters.Counter mapOutputRecordCounter,
+ ShuffleClient shuffleClient,
+ CelebornConf celebornConf) {
+ this.numMappers = numMappers;
+ this.numReducers = numReducers;
+ this.mapId = mapId;
+ this.attempt = attemptId;
+ this.kSer = kSer;
+ this.vSer = vSer;
+ this.maxIOBufferSize = maxIOBufferSize;
+ this.spillIOBufferSize = spillIOBufferSize;
+ this.mapOutputByteCounter = mapOutputByteCounter;
+ this.mapOutputRecordCounter = mapOutputRecordCounter;
+ this.comparator = comparator;
+ this.shuffleClient = shuffleClient;
+ currentSerializedKVs = new HashMap<>();
+ serializedKV = new byte[maxIOBufferSize];
+ maxPushDataSize = (int) celebornConf.clientMrMaxPushData();
+ logger.info(
+ "Sort based push initialized with"
+ + " numMappers:{} numReducers:{} mapId:{} attemptId:{}"
+ + " maxIOBufferSize:{} spillIOBufferSize:{}",
+ numMappers,
+ numReducers,
+ mapId,
+ attemptId,
+ maxIOBufferSize,
+ spillIOBufferSize);
+ try {
+ kSer.open(this);
+ vSer.open(this);
+ } catch (IOException e) {
+ exception.compareAndSet(null, e);
+ }
+ }
+
+ public void insert(K key, V value, int partition) {
+ try {
+ if (writePos >= spillIOBufferSize) {
+ // needs to sort and flush data
+ if (logger.isDebugEnabled()) {
+ logger.debug(
+ "Data is large enough {}/{}/{}, trigger sort and flush",
+ Utils.bytesToString(writePos),
+ Utils.bytesToString(spillIOBufferSize),
+ Utils.bytesToString(maxIOBufferSize));
+ }
+ synchronized (this) {
+ sortKVs();
+ sendKVAndUpdateWritePos();
+ }
+ }
+ int dataLen = insertRecordInternal(key, value, partition);
+ if (logger.isDebugEnabled()) {
+ logger.debug(
+ "Sort based pusher insert into partition:{} with {} bytes", partition, dataLen);
+ }
+ mapOutputRecordCounter.increment(1);
+ mapOutputByteCounter.increment(dataLen);
+ } catch (IOException e) {
+ exception.compareAndSet(null, e);
+ }
+ }
+
+ private void sendKVAndUpdateWritePos() throws IOException {
+ for (Map.Entry<Integer, List<SerializedKV>> partitionKVEntry :
+ currentSerializedKVs.entrySet()) {
+ List<SerializedKV> kvs = partitionKVEntry.getValue();
+ synchronized (kvs) {
Review Comment:
`sendKVAndUpdateWritePos` is called inside `synchronized(this)`, so I think it unnecessary to sync here
##########
client-mr/mr/src/main/java/org/apache/celeborn/mapreduce/v2/app/MRAppMasterWithCeleborn.java:
##########
@@ -0,0 +1,178 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.celeborn.mapreduce.v2.app;
+
+import java.io.IOException;
+
+import org.apache.hadoop.fs.FSDataOutputStream;
+import org.apache.hadoop.fs.FileStatus;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.fs.permission.FsPermission;
+import org.apache.hadoop.ipc.CallerContext;
+import org.apache.hadoop.mapred.JobConf;
+import org.apache.hadoop.mapreduce.Cluster;
+import org.apache.hadoop.mapreduce.JobSubmissionFiles;
+import org.apache.hadoop.mapreduce.MRJobConfig;
+import org.apache.hadoop.mapreduce.v2.app.MRAppMaster;
+import org.apache.hadoop.mapreduce.v2.util.MRApps;
+import org.apache.hadoop.mapreduce.v2.util.MRWebAppUtil;
+import org.apache.hadoop.util.ExitUtil;
+import org.apache.hadoop.util.ShutdownHookManager;
+import org.apache.hadoop.yarn.YarnUncaughtExceptionHandler;
+import org.apache.hadoop.yarn.api.ApplicationConstants;
+import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
+import org.apache.hadoop.yarn.api.records.ContainerId;
+import org.apache.hadoop.yarn.conf.YarnConfiguration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.celeborn.client.LifecycleManager;
+import org.apache.celeborn.common.CelebornConf;
+import org.apache.celeborn.common.exception.CelebornIOException;
+import org.apache.celeborn.util.HadoopUtils;
+
+public class MRAppMasterWithCeleborn extends MRAppMaster {
+ private static final Logger logger = LoggerFactory.getLogger(MRAppMasterWithCeleborn.class);
+
+ public MRAppMasterWithCeleborn(
+ ApplicationAttemptId applicationAttemptId,
+ ContainerId containerId,
+ String nmHost,
+ int nmPort,
+ int nmHttpPort,
+ long appSubmitTime,
+ JobConf jobConf)
+ throws CelebornIOException {
+ super(applicationAttemptId, containerId, nmHost, nmPort, nmHttpPort, appSubmitTime);
+
+ int numReducers = jobConf.getInt(MRJobConfig.NUM_REDUCES, 0);
+ if (numReducers > 0) {
+ CelebornConf conf = HadoopUtils.fromYarnConf(jobConf);
+ LifecycleManager lifecycleManager =
+ new LifecycleManager(applicationAttemptId.toString(), conf);
+ String lcHost = lifecycleManager.getHost();
+ int lcPort = lifecycleManager.getPort();
+ logger.info("RMAppMaster initialized with {} {} {}", lcHost, lcPort, applicationAttemptId);
+ JobConf lcConf = new JobConf();
Review Comment:
lmConf
##########
client-mr/mr/src/main/java/org/apache/celeborn/mapreduce/v2/app/MRAppMasterWithCeleborn.java:
##########
@@ -0,0 +1,178 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.celeborn.mapreduce.v2.app;
+
+import java.io.IOException;
+
+import org.apache.hadoop.fs.FSDataOutputStream;
+import org.apache.hadoop.fs.FileStatus;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.fs.permission.FsPermission;
+import org.apache.hadoop.ipc.CallerContext;
+import org.apache.hadoop.mapred.JobConf;
+import org.apache.hadoop.mapreduce.Cluster;
+import org.apache.hadoop.mapreduce.JobSubmissionFiles;
+import org.apache.hadoop.mapreduce.MRJobConfig;
+import org.apache.hadoop.mapreduce.v2.app.MRAppMaster;
+import org.apache.hadoop.mapreduce.v2.util.MRApps;
+import org.apache.hadoop.mapreduce.v2.util.MRWebAppUtil;
+import org.apache.hadoop.util.ExitUtil;
+import org.apache.hadoop.util.ShutdownHookManager;
+import org.apache.hadoop.yarn.YarnUncaughtExceptionHandler;
+import org.apache.hadoop.yarn.api.ApplicationConstants;
+import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
+import org.apache.hadoop.yarn.api.records.ContainerId;
+import org.apache.hadoop.yarn.conf.YarnConfiguration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.celeborn.client.LifecycleManager;
+import org.apache.celeborn.common.CelebornConf;
+import org.apache.celeborn.common.exception.CelebornIOException;
+import org.apache.celeborn.util.HadoopUtils;
+
+public class MRAppMasterWithCeleborn extends MRAppMaster {
+ private static final Logger logger = LoggerFactory.getLogger(MRAppMasterWithCeleborn.class);
+
+ public MRAppMasterWithCeleborn(
+ ApplicationAttemptId applicationAttemptId,
+ ContainerId containerId,
+ String nmHost,
+ int nmPort,
+ int nmHttpPort,
+ long appSubmitTime,
+ JobConf jobConf)
+ throws CelebornIOException {
+ super(applicationAttemptId, containerId, nmHost, nmPort, nmHttpPort, appSubmitTime);
+
+ int numReducers = jobConf.getInt(MRJobConfig.NUM_REDUCES, 0);
+ if (numReducers > 0) {
+ CelebornConf conf = HadoopUtils.fromYarnConf(jobConf);
+ LifecycleManager lifecycleManager =
+ new LifecycleManager(applicationAttemptId.toString(), conf);
+ String lcHost = lifecycleManager.getHost();
+ int lcPort = lifecycleManager.getPort();
Review Comment:
lmPort
##########
client-mr/mr/src/main/java/org/apache/hadoop/mapred/CelebornSortBasedPusher.java:
##########
@@ -0,0 +1,341 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.mapred;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.*;
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.apache.hadoop.io.RawComparator;
+import org.apache.hadoop.io.WritableUtils;
+import org.apache.hadoop.io.serializer.Serializer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.celeborn.client.ShuffleClient;
+import org.apache.celeborn.common.CelebornConf;
+import org.apache.celeborn.common.unsafe.Platform;
+import org.apache.celeborn.common.util.Utils;
+
+public class CelebornSortBasedPusher<K, V> extends OutputStream {
+ final Logger logger = LoggerFactory.getLogger(CelebornSortBasedPusher.class);
+ private final int mapId;
+ private final int attempt;
+ private final int numMappers;
+ private final int numReducers;
+ private final ShuffleClient shuffleClient;
+ private final int maxIOBufferSize;
+ private final int spillIOBufferSize;
+ private final Serializer<K> kSer;
+ private final Serializer<V> vSer;
+ private final RawComparator<K> comparator;
+ private final AtomicReference<Exception> exception = new AtomicReference<>();
+ private final Counters.Counter mapOutputByteCounter;
+ private final Counters.Counter mapOutputRecordCounter;
+ private final Map<Integer, List<SerializedKV>> currentSerializedKVs;
+ private int writePos;
+ private byte[] serializedKV;
+ private final int maxPushDataSize;
+
+ public CelebornSortBasedPusher(
+ int numMappers,
+ int numReducers,
+ int mapId,
+ int attemptId,
+ Serializer<K> kSer,
+ Serializer<V> vSer,
+ int maxIOBufferSize,
+ int spillIOBufferSize,
+ RawComparator<K> comparator,
+ Counters.Counter mapOutputByteCounter,
+ Counters.Counter mapOutputRecordCounter,
+ ShuffleClient shuffleClient,
+ CelebornConf celebornConf) {
+ this.numMappers = numMappers;
+ this.numReducers = numReducers;
+ this.mapId = mapId;
+ this.attempt = attemptId;
+ this.kSer = kSer;
+ this.vSer = vSer;
+ this.maxIOBufferSize = maxIOBufferSize;
+ this.spillIOBufferSize = spillIOBufferSize;
+ this.mapOutputByteCounter = mapOutputByteCounter;
+ this.mapOutputRecordCounter = mapOutputRecordCounter;
+ this.comparator = comparator;
+ this.shuffleClient = shuffleClient;
+ currentSerializedKVs = new HashMap<>();
+ serializedKV = new byte[maxIOBufferSize];
+ maxPushDataSize = (int) celebornConf.clientMrMaxPushData();
+ logger.info(
+ "Sort based push initialized with"
+ + " numMappers:{} numReducers:{} mapId:{} attemptId:{}"
+ + " maxIOBufferSize:{} spillIOBufferSize:{}",
+ numMappers,
+ numReducers,
+ mapId,
+ attemptId,
+ maxIOBufferSize,
+ spillIOBufferSize);
+ try {
+ kSer.open(this);
+ vSer.open(this);
+ } catch (IOException e) {
+ exception.compareAndSet(null, e);
+ }
+ }
+
+ public void insert(K key, V value, int partition) {
+ try {
+ if (writePos >= spillIOBufferSize) {
+ // needs to sort and flush data
+ if (logger.isDebugEnabled()) {
+ logger.debug(
+ "Data is large enough {}/{}/{}, trigger sort and flush",
+ Utils.bytesToString(writePos),
+ Utils.bytesToString(spillIOBufferSize),
+ Utils.bytesToString(maxIOBufferSize));
+ }
+ synchronized (this) {
+ sortKVs();
+ sendKVAndUpdateWritePos();
+ }
+ }
+ int dataLen = insertRecordInternal(key, value, partition);
+ if (logger.isDebugEnabled()) {
+ logger.debug(
+ "Sort based pusher insert into partition:{} with {} bytes", partition, dataLen);
+ }
+ mapOutputRecordCounter.increment(1);
+ mapOutputByteCounter.increment(dataLen);
+ } catch (IOException e) {
+ exception.compareAndSet(null, e);
+ }
+ }
+
+ private void sendKVAndUpdateWritePos() throws IOException {
+ for (Map.Entry<Integer, List<SerializedKV>> partitionKVEntry :
+ currentSerializedKVs.entrySet()) {
+ List<SerializedKV> kvs = partitionKVEntry.getValue();
+ synchronized (kvs) {
+ int partition = partitionKVEntry.getKey();
+ List<SerializedKV> localKVs = new ArrayList<>();
+ int partitionKVTotalLen = 0;
+ // process buffers for specific partition
+ for (SerializedKV kv : kvs) {
+ partitionKVTotalLen += kv.kLen + kv.vLen;
+ localKVs.add(kv);
+ if (partitionKVTotalLen > maxPushDataSize) {
+ // limit max size of pushdata to avoid possible memory issue in Celeborn worker
+ // data layout
+ // pushdata header (16) + pushDataLen(4) +
+ // [varKeyLen+varValLen+serializedRecord(x)][...]
+ sendSortedBuffersPartition(partition, localKVs, partitionKVTotalLen);
+ localKVs.clear();
+ partitionKVTotalLen = 0;
+ }
+ }
+ if (!localKVs.isEmpty()) {
+ sendSortedBuffersPartition(partition, localKVs, partitionKVTotalLen);
+ }
+ kvs.clear();
+ }
+ }
+ // all data sent
+ currentSerializedKVs.clear();
+ writePos = 0;
+ }
+
+ private void sendSortedBuffersPartition(
+ int partition, List<SerializedKV> localKVs, int partitionKVTotalLen) throws IOException {
+ int extraSize = 0;
+ for (SerializedKV localKV : localKVs) {
+ extraSize += WritableUtils.getVIntSize(localKV.kLen);
+ extraSize += WritableUtils.getVIntSize(localKV.vLen);
+ }
+ // copied from hadoop logic
+ extraSize += WritableUtils.getVIntSize(-1);
+ extraSize += WritableUtils.getVIntSize(-1);
+ // whole buffer's size + [(keyLen+valueLen)+(serializedKey+serializedValue)]
+ byte[] pkvs = new byte[4 + extraSize + partitionKVTotalLen];
+ int pkvsPos = 4;
+ Platform.putInt(pkvs, Platform.BYTE_ARRAY_OFFSET, partitionKVTotalLen + extraSize);
+ for (SerializedKV kv : localKVs) {
+ int recordLen = kv.kLen + kv.vLen;
+ // write key len
+ pkvsPos = writeVLong(pkvs, pkvsPos, kv.kLen);
+ // write value len
+ pkvsPos = writeVLong(pkvs, pkvsPos, kv.vLen);
+ // write serialized record
+ System.arraycopy(serializedKV, kv.offset, pkvs, pkvsPos, recordLen);
+ pkvsPos += recordLen;
+ }
+ // finally write -1 two times
+ pkvsPos = writeVLong(pkvs, pkvsPos, -1);
+ writeVLong(pkvs, pkvsPos, -1);
+ int compressedSize =
+ shuffleClient.pushData(
+ 0,
+ mapId,
+ attempt,
+ partition,
+ pkvs,
+ 0,
+ 4 + extraSize + partitionKVTotalLen,
+ numMappers,
+ numReducers);
+ if (logger.isDebugEnabled()) {
+ logger.debug(
+ "Send sorted buffer mapId:{} attemptId:{} to partition:{} uncompressed size:{} compressed size:{}",
+ mapId,
+ attempt,
+ partition,
+ Utils.bytesToString(4 + extraSize + partitionKVTotalLen),
+ Utils.bytesToString(compressedSize));
+ }
+ }
+
+ /**
+ * Write variable length int to array Modified from
+ * org.apache.hadoop.io.WritableUtils#writeVLong(java.io.DataOutput, long)
+ */
+ private int writeVLong(byte[] data, int offset, long dataInt) {
+ if (dataInt >= -112L && dataInt <= 127L) {
+ data[offset++] = (byte) ((int) dataInt);
+ return offset;
+ }
+
+ int len = -112;
+ if (dataInt < 0L) {
+ dataInt ^= -1L;
+ len = -120;
+ }
+
+ long tmp = dataInt;
+ while (tmp != 0) {
+ tmp = tmp >> 8;
+ len--;
+ }
+
+ data[offset++] = (byte) len;
+
+ len = len < -120 ? -(len + 120) : -(len + 112);
+
+ for (int idx = len; idx != 0; --idx) {
+ int shiftBits = (idx - 1) * 8;
+ long mask = 0xFFL << shiftBits;
+ data[offset++] = ((byte) ((int) ((dataInt & mask) >> shiftBits)));
+ }
+ return offset;
+ }
+
+ private void sortKVs() {
+ for (Map.Entry<Integer, List<SerializedKV>> partitionKVEntry :
+ currentSerializedKVs.entrySet()) {
+ partitionKVEntry
+ .getValue()
+ .sort(
+ (o1, o2) ->
+ comparator.compare(
+ serializedKV, o1.offset, o1.kLen, serializedKV, o2.offset, o2.kLen));
+ }
+ }
+
+ private int insertRecordInternal(K key, V value, int partition) throws IOException {
+ int offset = writePos;
+ int keyLen = writePos;
Review Comment:
L261 and L262 is unnecessary
##########
client-mr/mr/src/main/java/org/apache/celeborn/mapreduce/v2/app/MRAppMasterWithCeleborn.java:
##########
@@ -0,0 +1,178 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.celeborn.mapreduce.v2.app;
+
+import java.io.IOException;
+
+import org.apache.hadoop.fs.FSDataOutputStream;
+import org.apache.hadoop.fs.FileStatus;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.fs.permission.FsPermission;
+import org.apache.hadoop.ipc.CallerContext;
+import org.apache.hadoop.mapred.JobConf;
+import org.apache.hadoop.mapreduce.Cluster;
+import org.apache.hadoop.mapreduce.JobSubmissionFiles;
+import org.apache.hadoop.mapreduce.MRJobConfig;
+import org.apache.hadoop.mapreduce.v2.app.MRAppMaster;
+import org.apache.hadoop.mapreduce.v2.util.MRApps;
+import org.apache.hadoop.mapreduce.v2.util.MRWebAppUtil;
+import org.apache.hadoop.util.ExitUtil;
+import org.apache.hadoop.util.ShutdownHookManager;
+import org.apache.hadoop.yarn.YarnUncaughtExceptionHandler;
+import org.apache.hadoop.yarn.api.ApplicationConstants;
+import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
+import org.apache.hadoop.yarn.api.records.ContainerId;
+import org.apache.hadoop.yarn.conf.YarnConfiguration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.celeborn.client.LifecycleManager;
+import org.apache.celeborn.common.CelebornConf;
+import org.apache.celeborn.common.exception.CelebornIOException;
+import org.apache.celeborn.util.HadoopUtils;
+
+public class MRAppMasterWithCeleborn extends MRAppMaster {
+ private static final Logger logger = LoggerFactory.getLogger(MRAppMasterWithCeleborn.class);
+
+ public MRAppMasterWithCeleborn(
+ ApplicationAttemptId applicationAttemptId,
+ ContainerId containerId,
+ String nmHost,
+ int nmPort,
+ int nmHttpPort,
+ long appSubmitTime,
+ JobConf jobConf)
+ throws CelebornIOException {
+ super(applicationAttemptId, containerId, nmHost, nmPort, nmHttpPort, appSubmitTime);
+
+ int numReducers = jobConf.getInt(MRJobConfig.NUM_REDUCES, 0);
+ if (numReducers > 0) {
+ CelebornConf conf = HadoopUtils.fromYarnConf(jobConf);
+ LifecycleManager lifecycleManager =
+ new LifecycleManager(applicationAttemptId.toString(), conf);
+ String lcHost = lifecycleManager.getHost();
+ int lcPort = lifecycleManager.getPort();
+ logger.info("RMAppMaster initialized with {} {} {}", lcHost, lcPort, applicationAttemptId);
+ JobConf lcConf = new JobConf();
+ lcConf.clear();
+ lcConf.set(HadoopUtils.MR_CELEBORN_LC_HOST, lcHost);
+ lcConf.set(HadoopUtils.MR_CELEBORN_LC_PORT, lcPort + "");
+ lcConf.set(HadoopUtils.MR_CELEBORN_APPLICATION_ID, applicationAttemptId.toString());
+ writeLifecycleManagerConfToTask(jobConf, lcConf);
+ }
+ }
+
+ void writeLifecycleManagerConfToTask(JobConf conf, JobConf lcConf) throws CelebornIOException {
+ try {
+ FileSystem fs = new Cluster(conf).getFileSystem();
+ String jobDirStr = conf.get(MRJobConfig.MAPREDUCE_JOB_DIR);
+ Path celebornExtraConf = new Path(jobDirStr, HadoopUtils.MR_CELEBORN_CONF);
Review Comment:
celebornConfPath
##########
client-mr/mr/src/main/java/org/apache/celeborn/mapreduce/v2/app/MRAppMasterWithCeleborn.java:
##########
@@ -0,0 +1,178 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.celeborn.mapreduce.v2.app;
+
+import java.io.IOException;
+
+import org.apache.hadoop.fs.FSDataOutputStream;
+import org.apache.hadoop.fs.FileStatus;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.fs.permission.FsPermission;
+import org.apache.hadoop.ipc.CallerContext;
+import org.apache.hadoop.mapred.JobConf;
+import org.apache.hadoop.mapreduce.Cluster;
+import org.apache.hadoop.mapreduce.JobSubmissionFiles;
+import org.apache.hadoop.mapreduce.MRJobConfig;
+import org.apache.hadoop.mapreduce.v2.app.MRAppMaster;
+import org.apache.hadoop.mapreduce.v2.util.MRApps;
+import org.apache.hadoop.mapreduce.v2.util.MRWebAppUtil;
+import org.apache.hadoop.util.ExitUtil;
+import org.apache.hadoop.util.ShutdownHookManager;
+import org.apache.hadoop.yarn.YarnUncaughtExceptionHandler;
+import org.apache.hadoop.yarn.api.ApplicationConstants;
+import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
+import org.apache.hadoop.yarn.api.records.ContainerId;
+import org.apache.hadoop.yarn.conf.YarnConfiguration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.celeborn.client.LifecycleManager;
+import org.apache.celeborn.common.CelebornConf;
+import org.apache.celeborn.common.exception.CelebornIOException;
+import org.apache.celeborn.util.HadoopUtils;
+
+public class MRAppMasterWithCeleborn extends MRAppMaster {
+ private static final Logger logger = LoggerFactory.getLogger(MRAppMasterWithCeleborn.class);
+
+ public MRAppMasterWithCeleborn(
+ ApplicationAttemptId applicationAttemptId,
+ ContainerId containerId,
+ String nmHost,
+ int nmPort,
+ int nmHttpPort,
+ long appSubmitTime,
+ JobConf jobConf)
+ throws CelebornIOException {
+ super(applicationAttemptId, containerId, nmHost, nmPort, nmHttpPort, appSubmitTime);
+
+ int numReducers = jobConf.getInt(MRJobConfig.NUM_REDUCES, 0);
+ if (numReducers > 0) {
+ CelebornConf conf = HadoopUtils.fromYarnConf(jobConf);
+ LifecycleManager lifecycleManager =
+ new LifecycleManager(applicationAttemptId.toString(), conf);
+ String lcHost = lifecycleManager.getHost();
+ int lcPort = lifecycleManager.getPort();
+ logger.info("RMAppMaster initialized with {} {} {}", lcHost, lcPort, applicationAttemptId);
+ JobConf lcConf = new JobConf();
+ lcConf.clear();
+ lcConf.set(HadoopUtils.MR_CELEBORN_LC_HOST, lcHost);
+ lcConf.set(HadoopUtils.MR_CELEBORN_LC_PORT, lcPort + "");
+ lcConf.set(HadoopUtils.MR_CELEBORN_APPLICATION_ID, applicationAttemptId.toString());
+ writeLifecycleManagerConfToTask(jobConf, lcConf);
+ }
+ }
+
+ void writeLifecycleManagerConfToTask(JobConf conf, JobConf lcConf) throws CelebornIOException {
+ try {
+ FileSystem fs = new Cluster(conf).getFileSystem();
+ String jobDirStr = conf.get(MRJobConfig.MAPREDUCE_JOB_DIR);
+ Path celebornExtraConf = new Path(jobDirStr, HadoopUtils.MR_CELEBORN_CONF);
+
+ try (FSDataOutputStream out =
+ FileSystem.create(
+ fs, celebornExtraConf, new FsPermission(JobSubmissionFiles.JOB_FILE_PERMISSION))) {
+ lcConf.writeXml(out);
+ }
+ FileStatus status = fs.getFileStatus(celebornExtraConf);
+ long currentTs = status.getModificationTime();
+ String uri = fs.getUri() + Path.SEPARATOR + celebornExtraConf.toUri();
+ String files = conf.get(MRJobConfig.CACHE_FILES);
+ conf.set(MRJobConfig.CACHE_FILES, files == null ? uri : uri + "," + files);
+ String ts = conf.get(MRJobConfig.CACHE_FILE_TIMESTAMPS);
+ conf.set(
+ MRJobConfig.CACHE_FILE_TIMESTAMPS,
+ ts == null ? String.valueOf(currentTs) : currentTs + "," + ts);
+ String vis = conf.get(MRJobConfig.CACHE_FILE_VISIBILITIES);
+ conf.set(MRJobConfig.CACHE_FILE_VISIBILITIES, vis == null ? "false" : "false" + "," + vis);
+ long size = status.getLen();
+ String sizes = conf.get(MRJobConfig.CACHE_FILES_SIZES);
+ conf.set(
+ MRJobConfig.CACHE_FILES_SIZES, sizes == null ? String.valueOf(size) : size + "," + sizes);
+ } catch (InterruptedException | IOException e) {
+ logger.error("Upload extra conf exception", e);
+ throw new CelebornIOException("Upload extra conf exception ", e);
+ }
+ }
+
+ private static String getSysEnvAndValidateInputParam(String envName) throws IOException {
+ String value = System.getenv(envName);
+ if (value == null) {
+ String msg = envName + " is null";
+ logger.error(msg);
+ throw new CelebornIOException(msg);
+ }
+ return value;
+ }
+
+ public static void main(String[] args) {
+ JobConf rmAppConf = new JobConf(new YarnConfiguration());
+ rmAppConf.addResource(new Path(MRJobConfig.JOB_CONF_FILE));
+ try {
+ Thread.setDefaultUncaughtExceptionHandler(new YarnUncaughtExceptionHandler());
+ String containerIdStr =
+ getSysEnvAndValidateInputParam(ApplicationConstants.Environment.CONTAINER_ID.name());
+ String nodeHostString =
+ getSysEnvAndValidateInputParam(ApplicationConstants.Environment.NM_HOST.name());
+ String nodePortString =
+ getSysEnvAndValidateInputParam(ApplicationConstants.Environment.NM_PORT.name());
+ String nodeHttpPortString =
+ getSysEnvAndValidateInputParam(ApplicationConstants.Environment.NM_HTTP_PORT.name());
+ String appSubmitTimeStr = System.getenv("APP_SUBMIT_TIME_ENV");
+ getSysEnvAndValidateInputParam("APP_SUBMIT_TIME_ENV");
Review Comment:
Should be `String appSubmitTimeStr = getSysEnvAndValidateInputParam("APP_SUBMIT_TIME_ENV");` here?
##########
client-mr/mr/src/main/java/org/apache/celeborn/mapreduce/v2/app/MRAppMasterWithCeleborn.java:
##########
@@ -0,0 +1,178 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.celeborn.mapreduce.v2.app;
+
+import java.io.IOException;
+
+import org.apache.hadoop.fs.FSDataOutputStream;
+import org.apache.hadoop.fs.FileStatus;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.fs.permission.FsPermission;
+import org.apache.hadoop.ipc.CallerContext;
+import org.apache.hadoop.mapred.JobConf;
+import org.apache.hadoop.mapreduce.Cluster;
+import org.apache.hadoop.mapreduce.JobSubmissionFiles;
+import org.apache.hadoop.mapreduce.MRJobConfig;
+import org.apache.hadoop.mapreduce.v2.app.MRAppMaster;
+import org.apache.hadoop.mapreduce.v2.util.MRApps;
+import org.apache.hadoop.mapreduce.v2.util.MRWebAppUtil;
+import org.apache.hadoop.util.ExitUtil;
+import org.apache.hadoop.util.ShutdownHookManager;
+import org.apache.hadoop.yarn.YarnUncaughtExceptionHandler;
+import org.apache.hadoop.yarn.api.ApplicationConstants;
+import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
+import org.apache.hadoop.yarn.api.records.ContainerId;
+import org.apache.hadoop.yarn.conf.YarnConfiguration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.celeborn.client.LifecycleManager;
+import org.apache.celeborn.common.CelebornConf;
+import org.apache.celeborn.common.exception.CelebornIOException;
+import org.apache.celeborn.util.HadoopUtils;
+
+public class MRAppMasterWithCeleborn extends MRAppMaster {
+ private static final Logger logger = LoggerFactory.getLogger(MRAppMasterWithCeleborn.class);
+
+ public MRAppMasterWithCeleborn(
+ ApplicationAttemptId applicationAttemptId,
+ ContainerId containerId,
+ String nmHost,
+ int nmPort,
+ int nmHttpPort,
+ long appSubmitTime,
+ JobConf jobConf)
+ throws CelebornIOException {
+ super(applicationAttemptId, containerId, nmHost, nmPort, nmHttpPort, appSubmitTime);
+
+ int numReducers = jobConf.getInt(MRJobConfig.NUM_REDUCES, 0);
+ if (numReducers > 0) {
+ CelebornConf conf = HadoopUtils.fromYarnConf(jobConf);
+ LifecycleManager lifecycleManager =
+ new LifecycleManager(applicationAttemptId.toString(), conf);
+ String lcHost = lifecycleManager.getHost();
+ int lcPort = lifecycleManager.getPort();
+ logger.info("RMAppMaster initialized with {} {} {}", lcHost, lcPort, applicationAttemptId);
+ JobConf lcConf = new JobConf();
+ lcConf.clear();
+ lcConf.set(HadoopUtils.MR_CELEBORN_LC_HOST, lcHost);
+ lcConf.set(HadoopUtils.MR_CELEBORN_LC_PORT, lcPort + "");
+ lcConf.set(HadoopUtils.MR_CELEBORN_APPLICATION_ID, applicationAttemptId.toString());
+ writeLifecycleManagerConfToTask(jobConf, lcConf);
+ }
+ }
+
+ void writeLifecycleManagerConfToTask(JobConf conf, JobConf lcConf) throws CelebornIOException {
+ try {
+ FileSystem fs = new Cluster(conf).getFileSystem();
+ String jobDirStr = conf.get(MRJobConfig.MAPREDUCE_JOB_DIR);
+ Path celebornExtraConf = new Path(jobDirStr, HadoopUtils.MR_CELEBORN_CONF);
+
+ try (FSDataOutputStream out =
+ FileSystem.create(
+ fs, celebornExtraConf, new FsPermission(JobSubmissionFiles.JOB_FILE_PERMISSION))) {
+ lcConf.writeXml(out);
+ }
+ FileStatus status = fs.getFileStatus(celebornExtraConf);
+ long currentTs = status.getModificationTime();
+ String uri = fs.getUri() + Path.SEPARATOR + celebornExtraConf.toUri();
+ String files = conf.get(MRJobConfig.CACHE_FILES);
+ conf.set(MRJobConfig.CACHE_FILES, files == null ? uri : uri + "," + files);
+ String ts = conf.get(MRJobConfig.CACHE_FILE_TIMESTAMPS);
+ conf.set(
+ MRJobConfig.CACHE_FILE_TIMESTAMPS,
+ ts == null ? String.valueOf(currentTs) : currentTs + "," + ts);
+ String vis = conf.get(MRJobConfig.CACHE_FILE_VISIBILITIES);
+ conf.set(MRJobConfig.CACHE_FILE_VISIBILITIES, vis == null ? "false" : "false" + "," + vis);
+ long size = status.getLen();
+ String sizes = conf.get(MRJobConfig.CACHE_FILES_SIZES);
+ conf.set(
+ MRJobConfig.CACHE_FILES_SIZES, sizes == null ? String.valueOf(size) : size + "," + sizes);
+ } catch (InterruptedException | IOException e) {
+ logger.error("Upload extra conf exception", e);
+ throw new CelebornIOException("Upload extra conf exception ", e);
+ }
+ }
+
+ private static String getSysEnvAndValidateInputParam(String envName) throws IOException {
+ String value = System.getenv(envName);
+ if (value == null) {
+ String msg = envName + " is null";
+ logger.error(msg);
+ throw new CelebornIOException(msg);
+ }
+ return value;
+ }
+
+ public static void main(String[] args) {
+ JobConf rmAppConf = new JobConf(new YarnConfiguration());
+ rmAppConf.addResource(new Path(MRJobConfig.JOB_CONF_FILE));
+ try {
+ Thread.setDefaultUncaughtExceptionHandler(new YarnUncaughtExceptionHandler());
+ String containerIdStr =
+ getSysEnvAndValidateInputParam(ApplicationConstants.Environment.CONTAINER_ID.name());
+ String nodeHostString =
+ getSysEnvAndValidateInputParam(ApplicationConstants.Environment.NM_HOST.name());
+ String nodePortString =
+ getSysEnvAndValidateInputParam(ApplicationConstants.Environment.NM_PORT.name());
+ String nodeHttpPortString =
+ getSysEnvAndValidateInputParam(ApplicationConstants.Environment.NM_HTTP_PORT.name());
+ String appSubmitTimeStr = System.getenv("APP_SUBMIT_TIME_ENV");
+ getSysEnvAndValidateInputParam("APP_SUBMIT_TIME_ENV");
+ ContainerId containerId = ContainerId.fromString(containerIdStr);
+ ApplicationAttemptId applicationAttemptId = containerId.getApplicationAttemptId();
+ if (applicationAttemptId != null) {
+ CallerContext.setCurrent(
+ (new CallerContext.Builder(
+ "mr_app_master_with_celeborn_" + applicationAttemptId.toString()))
Review Comment:
`.toString()` is unnecessary
##########
client-mr/mr/src/main/java/org/apache/hadoop/mapred/CelebornSortBasedPusher.java:
##########
@@ -0,0 +1,341 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.mapred;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.*;
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.apache.hadoop.io.RawComparator;
+import org.apache.hadoop.io.WritableUtils;
+import org.apache.hadoop.io.serializer.Serializer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.celeborn.client.ShuffleClient;
+import org.apache.celeborn.common.CelebornConf;
+import org.apache.celeborn.common.unsafe.Platform;
+import org.apache.celeborn.common.util.Utils;
+
+public class CelebornSortBasedPusher<K, V> extends OutputStream {
+ final Logger logger = LoggerFactory.getLogger(CelebornSortBasedPusher.class);
+ private final int mapId;
+ private final int attempt;
+ private final int numMappers;
+ private final int numReducers;
+ private final ShuffleClient shuffleClient;
+ private final int maxIOBufferSize;
+ private final int spillIOBufferSize;
+ private final Serializer<K> kSer;
+ private final Serializer<V> vSer;
+ private final RawComparator<K> comparator;
+ private final AtomicReference<Exception> exception = new AtomicReference<>();
+ private final Counters.Counter mapOutputByteCounter;
+ private final Counters.Counter mapOutputRecordCounter;
+ private final Map<Integer, List<SerializedKV>> currentSerializedKVs;
Review Comment:
better to rename to `partitionedKVs`
##########
client-mr/mr/src/main/java/org/apache/hadoop/mapreduce/task/reduce/CelebornShuffleConsumer.java:
##########
@@ -0,0 +1,170 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.mapreduce.task.reduce;
+
+import java.io.IOException;
+
+import org.apache.hadoop.mapred.*;
+import org.apache.hadoop.mapreduce.task.reduce.Shuffle.ShuffleError;
+import org.apache.hadoop.util.Progress;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.celeborn.client.ShuffleClient;
+import org.apache.celeborn.client.read.CelebornInputStream;
+import org.apache.celeborn.common.CelebornConf;
+import org.apache.celeborn.common.identity.UserIdentifier;
+import org.apache.celeborn.reflect.DynConstructors;
+import org.apache.celeborn.reflect.DynMethods;
+import org.apache.celeborn.util.HadoopUtils;
+
+public class CelebornShuffleConsumer<K, V>
+ implements ShuffleConsumerPlugin<K, V>, ExceptionReporter {
+ private static final Logger logger = LoggerFactory.getLogger(CelebornShuffleConsumer.class);
+ private JobConf mrJobConf;
+ private MergeManager<K, V> merger;
+ private Throwable throwable = null;
+ private Progress copyPhase;
+ private TaskStatus taskStatus;
+ private org.apache.hadoop.mapreduce.TaskAttemptID reduceId;
+ private TaskUmbilicalProtocol umbilical;
+ private Reporter reporter;
+ private ShuffleClientMetrics metrics;
+ private Task reduceTask;
+ private ShuffleClient shuffleClient;
+
+ @Override
+ public void init(Context<K, V> context) {
+
+ reduceId = context.getReduceId();
+ mrJobConf = context.getJobConf();
+ JobConf celebornJobConf = new JobConf(HadoopUtils.MR_CELEBORN_CONF);
+
+ umbilical = context.getUmbilical();
+ reporter = context.getReporter();
+ try {
+ this.metrics = createMetrics(reduceId, mrJobConf);
+ } catch (Exception e) {
+ logger.error("Fatal error occurred, failed to get shuffle client metrics.", e);
+ reportException(e);
+ }
+ copyPhase = context.getCopyPhase();
+ taskStatus = context.getStatus();
+ reduceTask = context.getReduceTask();
+
+ String appId = celebornJobConf.get(HadoopUtils.MR_CELEBORN_APPLICATION_ID);
+ String lcHost = celebornJobConf.get(HadoopUtils.MR_CELEBORN_LC_HOST);
+ int lcPort = Integer.parseInt(celebornJobConf.get(HadoopUtils.MR_CELEBORN_LC_PORT));
+ logger.info("Reducer initialized with celeborn {} {} {}", appId, lcHost, lcPort);
+ CelebornConf celebornConf = HadoopUtils.fromYarnConf(mrJobConf);
+ shuffleClient =
+ ShuffleClient.get(
+ appId,
+ lcHost,
+ lcPort,
+ celebornConf,
+ new UserIdentifier(
+ celebornConf.quotaUserSpecificTenant(), celebornConf.quotaUserSpecificUserName()));
+ this.merger = createMergeManager(context);
+ }
+
+ // Merge mapOutput and spill in local disks if necessary
+ protected MergeManager<K, V> createMergeManager(ShuffleConsumerPlugin.Context context) {
+ return new MergeManagerImpl<K, V>(
+ reduceId,
+ mrJobConf,
+ context.getLocalFS(),
+ context.getLocalDirAllocator(),
+ reporter,
+ context.getCodec(),
+ context.getCombinerClass(),
+ context.getCombineCollector(),
+ context.getSpilledRecordsCounter(),
+ context.getReduceCombineInputCounter(),
+ context.getMergedMapOutputsCounter(),
+ this,
+ context.getMergePhase(),
+ context.getMapOutputFile());
+ }
+
+ private ShuffleClientMetrics createMetrics(
+ org.apache.hadoop.mapreduce.TaskAttemptID taskAttemptID, JobConf jobConf)
+ throws NoSuchMethodException {
+ // for hadoop 3
+ try {
+ return DynMethods.builder("create")
+ .impl(
+ ShuffleClientMetrics.class,
+ org.apache.hadoop.mapreduce.TaskAttemptID.class,
+ JobConf.class)
+ .buildStaticChecked()
+ .invoke(taskAttemptID, jobConf);
+ } catch (Exception e) {
+ // ignore this exception because the createMetrics might use hadoop2
+ }
+ // for hadoop 2
+ return DynConstructors.builder(ShuffleClientMetrics.class)
+ .hiddenImpl(new Class[] {org.apache.hadoop.mapreduce.TaskAttemptID.class, JobConf.class})
+ .buildChecked()
+ .invoke(null, taskAttemptID, jobConf);
+ }
+
+ @Override
+ public RawKeyValueIterator run() throws IOException, InterruptedException {
Review Comment:
InterruptedException is not thrown
##########
client-mr/mr/src/main/java/org/apache/celeborn/mapreduce/v2/app/MRAppMasterWithCeleborn.java:
##########
@@ -0,0 +1,178 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.celeborn.mapreduce.v2.app;
+
+import java.io.IOException;
+
+import org.apache.hadoop.fs.FSDataOutputStream;
+import org.apache.hadoop.fs.FileStatus;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.fs.permission.FsPermission;
+import org.apache.hadoop.ipc.CallerContext;
+import org.apache.hadoop.mapred.JobConf;
+import org.apache.hadoop.mapreduce.Cluster;
+import org.apache.hadoop.mapreduce.JobSubmissionFiles;
+import org.apache.hadoop.mapreduce.MRJobConfig;
+import org.apache.hadoop.mapreduce.v2.app.MRAppMaster;
+import org.apache.hadoop.mapreduce.v2.util.MRApps;
+import org.apache.hadoop.mapreduce.v2.util.MRWebAppUtil;
+import org.apache.hadoop.util.ExitUtil;
+import org.apache.hadoop.util.ShutdownHookManager;
+import org.apache.hadoop.yarn.YarnUncaughtExceptionHandler;
+import org.apache.hadoop.yarn.api.ApplicationConstants;
+import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
+import org.apache.hadoop.yarn.api.records.ContainerId;
+import org.apache.hadoop.yarn.conf.YarnConfiguration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.celeborn.client.LifecycleManager;
+import org.apache.celeborn.common.CelebornConf;
+import org.apache.celeborn.common.exception.CelebornIOException;
+import org.apache.celeborn.util.HadoopUtils;
+
+public class MRAppMasterWithCeleborn extends MRAppMaster {
+ private static final Logger logger = LoggerFactory.getLogger(MRAppMasterWithCeleborn.class);
+
+ public MRAppMasterWithCeleborn(
+ ApplicationAttemptId applicationAttemptId,
+ ContainerId containerId,
+ String nmHost,
+ int nmPort,
+ int nmHttpPort,
+ long appSubmitTime,
+ JobConf jobConf)
+ throws CelebornIOException {
+ super(applicationAttemptId, containerId, nmHost, nmPort, nmHttpPort, appSubmitTime);
+
+ int numReducers = jobConf.getInt(MRJobConfig.NUM_REDUCES, 0);
+ if (numReducers > 0) {
+ CelebornConf conf = HadoopUtils.fromYarnConf(jobConf);
+ LifecycleManager lifecycleManager =
+ new LifecycleManager(applicationAttemptId.toString(), conf);
+ String lcHost = lifecycleManager.getHost();
+ int lcPort = lifecycleManager.getPort();
+ logger.info("RMAppMaster initialized with {} {} {}", lcHost, lcPort, applicationAttemptId);
+ JobConf lcConf = new JobConf();
+ lcConf.clear();
+ lcConf.set(HadoopUtils.MR_CELEBORN_LC_HOST, lcHost);
Review Comment:
MR_CELEBORN_LM_HOST/MR_CELEBORN_LM_PORT
##########
client-mr/mr/src/main/java/org/apache/hadoop/mapred/CelebornMapOutputCollector.java:
##########
@@ -0,0 +1,133 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.mapred;
+
+import java.io.IOException;
+
+import org.apache.hadoop.io.serializer.SerializationFactory;
+import org.apache.hadoop.mapreduce.JobContext;
+import org.apache.hadoop.mapreduce.TaskCounter;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.celeborn.client.ShuffleClient;
+import org.apache.celeborn.common.CelebornConf;
+import org.apache.celeborn.common.identity.UserIdentifier;
+import org.apache.celeborn.util.HadoopUtils;
+
+public class CelebornMapOutputCollector<K extends Object, V extends Object>
+ implements MapOutputCollector<K, V> {
+ private static final Logger logger = LoggerFactory.getLogger(CelebornMapOutputCollector.class);
+ private Class<K> keyClass;
+ private Class<V> valClass;
+ private Task.TaskReporter reporter;
+ private CelebornSortBasedPusher<K, V> celebornSortBasedPusher;
+ private int numReducers;
+
+ @Override
+ public void init(Context context) throws IOException {
+ JobConf jobConf = context.getJobConf();
+ reporter = context.getReporter();
+ keyClass = (Class<K>) jobConf.getMapOutputKeyClass();
+ valClass = (Class<V>) jobConf.getMapOutputValueClass();
+ context.getMapTask().getTaskID().getId();
+ numReducers = jobConf.getNumReduceTasks();
+
+ int IOBufferSize = jobConf.getInt(JobContext.IO_SORT_MB, 100);
+ // Java bytebuffer cannot be larger than Integer.MAX_VALUE
+ if ((IOBufferSize & 0x7FF) != IOBufferSize) {
+ throw new IOException("Invalid \"" + JobContext.IO_SORT_MB + "\": " + IOBufferSize);
+ }
+ jobConf.getNumReduceTasks();
Review Comment:
This line seems unnecessary
##########
client-mr/mr/src/main/java/org/apache/hadoop/mapreduce/task/reduce/CelebornShuffleConsumer.java:
##########
@@ -0,0 +1,170 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.mapreduce.task.reduce;
+
+import java.io.IOException;
+
+import org.apache.hadoop.mapred.*;
+import org.apache.hadoop.mapreduce.task.reduce.Shuffle.ShuffleError;
+import org.apache.hadoop.util.Progress;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.celeborn.client.ShuffleClient;
+import org.apache.celeborn.client.read.CelebornInputStream;
+import org.apache.celeborn.common.CelebornConf;
+import org.apache.celeborn.common.identity.UserIdentifier;
+import org.apache.celeborn.reflect.DynConstructors;
+import org.apache.celeborn.reflect.DynMethods;
+import org.apache.celeborn.util.HadoopUtils;
+
+public class CelebornShuffleConsumer<K, V>
+ implements ShuffleConsumerPlugin<K, V>, ExceptionReporter {
+ private static final Logger logger = LoggerFactory.getLogger(CelebornShuffleConsumer.class);
+ private JobConf mrJobConf;
+ private MergeManager<K, V> merger;
+ private Throwable throwable = null;
+ private Progress copyPhase;
+ private TaskStatus taskStatus;
+ private org.apache.hadoop.mapreduce.TaskAttemptID reduceId;
+ private TaskUmbilicalProtocol umbilical;
+ private Reporter reporter;
+ private ShuffleClientMetrics metrics;
+ private Task reduceTask;
+ private ShuffleClient shuffleClient;
+
+ @Override
+ public void init(Context<K, V> context) {
+
+ reduceId = context.getReduceId();
+ mrJobConf = context.getJobConf();
+ JobConf celebornJobConf = new JobConf(HadoopUtils.MR_CELEBORN_CONF);
+
+ umbilical = context.getUmbilical();
+ reporter = context.getReporter();
+ try {
+ this.metrics = createMetrics(reduceId, mrJobConf);
+ } catch (Exception e) {
+ logger.error("Fatal error occurred, failed to get shuffle client metrics.", e);
+ reportException(e);
+ }
+ copyPhase = context.getCopyPhase();
+ taskStatus = context.getStatus();
+ reduceTask = context.getReduceTask();
+
+ String appId = celebornJobConf.get(HadoopUtils.MR_CELEBORN_APPLICATION_ID);
+ String lcHost = celebornJobConf.get(HadoopUtils.MR_CELEBORN_LC_HOST);
+ int lcPort = Integer.parseInt(celebornJobConf.get(HadoopUtils.MR_CELEBORN_LC_PORT));
+ logger.info("Reducer initialized with celeborn {} {} {}", appId, lcHost, lcPort);
+ CelebornConf celebornConf = HadoopUtils.fromYarnConf(mrJobConf);
+ shuffleClient =
+ ShuffleClient.get(
+ appId,
+ lcHost,
+ lcPort,
+ celebornConf,
+ new UserIdentifier(
+ celebornConf.quotaUserSpecificTenant(), celebornConf.quotaUserSpecificUserName()));
+ this.merger = createMergeManager(context);
+ }
+
+ // Merge mapOutput and spill in local disks if necessary
+ protected MergeManager<K, V> createMergeManager(ShuffleConsumerPlugin.Context context) {
Review Comment:
Seems this method is unnecessary since it's only used in one place
##########
client-mr/mr/src/main/java/org/apache/hadoop/mapred/CelebornSortBasedPusher.java:
##########
@@ -0,0 +1,341 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.mapred;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.*;
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.apache.hadoop.io.RawComparator;
+import org.apache.hadoop.io.WritableUtils;
+import org.apache.hadoop.io.serializer.Serializer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.celeborn.client.ShuffleClient;
+import org.apache.celeborn.common.CelebornConf;
+import org.apache.celeborn.common.unsafe.Platform;
+import org.apache.celeborn.common.util.Utils;
+
+public class CelebornSortBasedPusher<K, V> extends OutputStream {
+ final Logger logger = LoggerFactory.getLogger(CelebornSortBasedPusher.class);
+ private final int mapId;
+ private final int attempt;
+ private final int numMappers;
+ private final int numReducers;
+ private final ShuffleClient shuffleClient;
+ private final int maxIOBufferSize;
+ private final int spillIOBufferSize;
+ private final Serializer<K> kSer;
+ private final Serializer<V> vSer;
+ private final RawComparator<K> comparator;
+ private final AtomicReference<Exception> exception = new AtomicReference<>();
+ private final Counters.Counter mapOutputByteCounter;
+ private final Counters.Counter mapOutputRecordCounter;
+ private final Map<Integer, List<SerializedKV>> currentSerializedKVs;
+ private int writePos;
+ private byte[] serializedKV;
+ private final int maxPushDataSize;
+
+ public CelebornSortBasedPusher(
+ int numMappers,
+ int numReducers,
+ int mapId,
+ int attemptId,
+ Serializer<K> kSer,
+ Serializer<V> vSer,
+ int maxIOBufferSize,
+ int spillIOBufferSize,
+ RawComparator<K> comparator,
+ Counters.Counter mapOutputByteCounter,
+ Counters.Counter mapOutputRecordCounter,
+ ShuffleClient shuffleClient,
+ CelebornConf celebornConf) {
+ this.numMappers = numMappers;
+ this.numReducers = numReducers;
+ this.mapId = mapId;
+ this.attempt = attemptId;
+ this.kSer = kSer;
+ this.vSer = vSer;
+ this.maxIOBufferSize = maxIOBufferSize;
+ this.spillIOBufferSize = spillIOBufferSize;
+ this.mapOutputByteCounter = mapOutputByteCounter;
+ this.mapOutputRecordCounter = mapOutputRecordCounter;
+ this.comparator = comparator;
+ this.shuffleClient = shuffleClient;
+ currentSerializedKVs = new HashMap<>();
+ serializedKV = new byte[maxIOBufferSize];
+ maxPushDataSize = (int) celebornConf.clientMrMaxPushData();
+ logger.info(
+ "Sort based push initialized with"
+ + " numMappers:{} numReducers:{} mapId:{} attemptId:{}"
+ + " maxIOBufferSize:{} spillIOBufferSize:{}",
+ numMappers,
+ numReducers,
+ mapId,
+ attemptId,
+ maxIOBufferSize,
+ spillIOBufferSize);
+ try {
+ kSer.open(this);
+ vSer.open(this);
+ } catch (IOException e) {
+ exception.compareAndSet(null, e);
+ }
+ }
+
+ public void insert(K key, V value, int partition) {
+ try {
+ if (writePos >= spillIOBufferSize) {
+ // needs to sort and flush data
+ if (logger.isDebugEnabled()) {
+ logger.debug(
+ "Data is large enough {}/{}/{}, trigger sort and flush",
+ Utils.bytesToString(writePos),
+ Utils.bytesToString(spillIOBufferSize),
+ Utils.bytesToString(maxIOBufferSize));
+ }
+ synchronized (this) {
+ sortKVs();
+ sendKVAndUpdateWritePos();
+ }
+ }
+ int dataLen = insertRecordInternal(key, value, partition);
+ if (logger.isDebugEnabled()) {
+ logger.debug(
+ "Sort based pusher insert into partition:{} with {} bytes", partition, dataLen);
+ }
+ mapOutputRecordCounter.increment(1);
+ mapOutputByteCounter.increment(dataLen);
+ } catch (IOException e) {
+ exception.compareAndSet(null, e);
+ }
+ }
+
+ private void sendKVAndUpdateWritePos() throws IOException {
+ for (Map.Entry<Integer, List<SerializedKV>> partitionKVEntry :
+ currentSerializedKVs.entrySet()) {
+ List<SerializedKV> kvs = partitionKVEntry.getValue();
+ synchronized (kvs) {
+ int partition = partitionKVEntry.getKey();
+ List<SerializedKV> localKVs = new ArrayList<>();
+ int partitionKVTotalLen = 0;
+ // process buffers for specific partition
+ for (SerializedKV kv : kvs) {
+ partitionKVTotalLen += kv.kLen + kv.vLen;
+ localKVs.add(kv);
+ if (partitionKVTotalLen > maxPushDataSize) {
+ // limit max size of pushdata to avoid possible memory issue in Celeborn worker
+ // data layout
+ // pushdata header (16) + pushDataLen(4) +
+ // [varKeyLen+varValLen+serializedRecord(x)][...]
+ sendSortedBuffersPartition(partition, localKVs, partitionKVTotalLen);
+ localKVs.clear();
+ partitionKVTotalLen = 0;
+ }
+ }
+ if (!localKVs.isEmpty()) {
+ sendSortedBuffersPartition(partition, localKVs, partitionKVTotalLen);
+ }
+ kvs.clear();
+ }
+ }
+ // all data sent
+ currentSerializedKVs.clear();
+ writePos = 0;
+ }
+
+ private void sendSortedBuffersPartition(
+ int partition, List<SerializedKV> localKVs, int partitionKVTotalLen) throws IOException {
Review Comment:
We'd better add metrics showing `partitionKVTotalLen`. We can do this in later PRs.
##########
client-mr/mr/src/main/java/org/apache/hadoop/mapreduce/task/reduce/CelebornShuffleFetcher.java:
##########
@@ -0,0 +1,224 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.mapreduce.task.reduce;
+
+import java.io.IOException;
+import java.lang.reflect.Field;
+
+import org.apache.hadoop.io.compress.CodecPool;
+import org.apache.hadoop.io.compress.Decompressor;
+import org.apache.hadoop.mapred.Counters;
+import org.apache.hadoop.mapred.Reporter;
+import org.apache.hadoop.mapred.TaskStatus;
+import org.apache.hadoop.mapreduce.TaskAttemptID;
+import org.apache.hadoop.mapreduce.TaskID;
+import org.apache.hadoop.mapreduce.TaskType;
+import org.apache.hadoop.util.Progress;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.celeborn.client.read.CelebornInputStream;
+import org.apache.celeborn.common.exception.CelebornIOException;
+import org.apache.celeborn.common.unsafe.Platform;
+
+public class CelebornShuffleFetcher<K, V> {
+ private static final Logger logger = LoggerFactory.getLogger(CelebornShuffleFetcher.class);
+ private final TaskAttemptID reduceId;
+ private final Reporter reporter;
+ private final TaskStatus status;
+ private final MergeManager<K, V> merger;
+ private final Progress progress;
+ private final ShuffleClientMetrics metrics;
+ private final CelebornInputStream celebornInputStream;
+ private volatile boolean stopped = false;
+ private int uniqueMapId = 0;
+ private final Counters.Counter ioErrs;
+ private boolean hasPendingData = false;
+ private long inputShuffleSize;
+ private byte[] shuffleData;
+
+ public CelebornShuffleFetcher(
+ TaskAttemptID reduceId,
+ TaskStatus status,
+ MergeManager<K, V> merger,
+ Progress progress,
+ Reporter reporter,
+ ShuffleClientMetrics metrics,
+ CelebornInputStream input) {
+ this.reduceId = reduceId;
+ this.reporter = reporter;
+ this.status = status;
+ this.merger = merger;
+ this.progress = progress;
+ this.metrics = metrics;
+ this.celebornInputStream = input;
+
+ ioErrs = reporter.getCounter("Shuffle Errors", "IO_ERROR");
+ }
+
+ // fetch all push data and merge
+ public void fetchAndMerge() {
+ while (!stopped) {
+ try {
+ // If merge is on, block
+ merger.waitForResource();
+ // Do shuffle
+ metrics.threadBusy();
+ // read blocks
+ fetchToLocalAndMerge();
+ } catch (Exception e) {
+ logger.error("Celeborn shuffle fetcher fetch data failed.", e);
+ } finally {
+ metrics.threadFree();
+ }
+ }
+ }
+
+ private byte[] getShuffleBlock() throws IOException {
+ // get len
+ byte[] header = new byte[4];
+ int count = celebornInputStream.read(header);
+ if (count == -1) {
+ stopped = true;
+ return null;
+ }
+ while (count != header.length) {
+ count += celebornInputStream.read(header, count, 4 - count);
+ }
+
+ // get data
+ int blockLen = Platform.getInt(header, Platform.BYTE_ARRAY_OFFSET);
+ inputShuffleSize += blockLen;
+ byte[] shuffleData = new byte[blockLen];
+ count = 0;
Review Comment:
this line is unnecessary
##########
client-mr/mr/src/main/java/org/apache/hadoop/mapreduce/task/reduce/CelebornShuffleFetcher.java:
##########
@@ -0,0 +1,224 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.mapreduce.task.reduce;
+
+import java.io.IOException;
+import java.lang.reflect.Field;
+
+import org.apache.hadoop.io.compress.CodecPool;
+import org.apache.hadoop.io.compress.Decompressor;
+import org.apache.hadoop.mapred.Counters;
+import org.apache.hadoop.mapred.Reporter;
+import org.apache.hadoop.mapred.TaskStatus;
+import org.apache.hadoop.mapreduce.TaskAttemptID;
+import org.apache.hadoop.mapreduce.TaskID;
+import org.apache.hadoop.mapreduce.TaskType;
+import org.apache.hadoop.util.Progress;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.celeborn.client.read.CelebornInputStream;
+import org.apache.celeborn.common.exception.CelebornIOException;
+import org.apache.celeborn.common.unsafe.Platform;
+
+public class CelebornShuffleFetcher<K, V> {
+ private static final Logger logger = LoggerFactory.getLogger(CelebornShuffleFetcher.class);
+ private final TaskAttemptID reduceId;
+ private final Reporter reporter;
+ private final TaskStatus status;
+ private final MergeManager<K, V> merger;
+ private final Progress progress;
+ private final ShuffleClientMetrics metrics;
+ private final CelebornInputStream celebornInputStream;
+ private volatile boolean stopped = false;
+ private int uniqueMapId = 0;
+ private final Counters.Counter ioErrs;
+ private boolean hasPendingData = false;
+ private long inputShuffleSize;
+ private byte[] shuffleData;
+
+ public CelebornShuffleFetcher(
+ TaskAttemptID reduceId,
+ TaskStatus status,
+ MergeManager<K, V> merger,
+ Progress progress,
+ Reporter reporter,
+ ShuffleClientMetrics metrics,
+ CelebornInputStream input) {
+ this.reduceId = reduceId;
+ this.reporter = reporter;
+ this.status = status;
+ this.merger = merger;
+ this.progress = progress;
+ this.metrics = metrics;
+ this.celebornInputStream = input;
+
+ ioErrs = reporter.getCounter("Shuffle Errors", "IO_ERROR");
+ }
+
+ // fetch all push data and merge
+ public void fetchAndMerge() {
+ while (!stopped) {
+ try {
+ // If merge is on, block
+ merger.waitForResource();
+ // Do shuffle
+ metrics.threadBusy();
+ // read blocks
+ fetchToLocalAndMerge();
+ } catch (Exception e) {
+ logger.error("Celeborn shuffle fetcher fetch data failed.", e);
+ } finally {
+ metrics.threadFree();
+ }
+ }
+ }
+
+ private byte[] getShuffleBlock() throws IOException {
+ // get len
+ byte[] header = new byte[4];
+ int count = celebornInputStream.read(header);
+ if (count == -1) {
+ stopped = true;
+ return null;
+ }
+ while (count != header.length) {
+ count += celebornInputStream.read(header, count, 4 - count);
+ }
+
+ // get data
+ int blockLen = Platform.getInt(header, Platform.BYTE_ARRAY_OFFSET);
+ inputShuffleSize += blockLen;
+ byte[] shuffleData = new byte[blockLen];
+ count = 0;
+ count = celebornInputStream.read(shuffleData);
+ while (count != shuffleData.length) {
+ count += celebornInputStream.read(shuffleData, count, blockLen - count);
+ if (count == -1) {
+ // read shuffle is done.
+ stopped = true;
+ throw new CelebornIOException("Read mr shuffle failed.");
+ }
+ }
+ return shuffleData;
+ }
+
+ private void fetchToLocalAndMerge() throws IOException {
+ if (!hasPendingData) {
+ shuffleData = getShuffleBlock();
+ }
+
+ if (shuffleData != null) {
+ // start to merge
+ if (wrapMapOutput(shuffleData)) {
+ hasPendingData = false;
+ } else {
+ return;
+ }
+
+ updateStatus();
+ reporter.progress();
+ } else {
+ celebornInputStream.close();
+ metrics.inputBytes(inputShuffleSize);
+ logger.info("reduce task {} read {} bytes", reduceId, inputShuffleSize);
+ stopped = true;
+ }
+ }
+
+ private boolean wrapMapOutput(byte[] shuffleData) throws IOException {
+ // treat push data as mapoutput
+ TaskAttemptID mapId =
+ new TaskAttemptID(new TaskID(reduceId.getJobID(), TaskType.MAP, uniqueMapId++), 0);
+ MapOutput<K, V> mapOutput = null;
+ try {
+ mapOutput = merger.reserve(mapId, shuffleData.length, 0);
+ } catch (IOException ioe) {
+ ioErrs.increment(1);
+ throw ioe;
+ }
+ if (mapOutput == null) {
+ logger.info(
+ "Celeborn fetcher returned status wait because reserve buffer for shuffle get null");
+ hasPendingData = true;
+ return false;
+ }
+
+ // write data to mapOutput
+ try {
+ writeShuffle(mapOutput, shuffleData);
+ // let the merger knows this block is ready for merging
+ mapOutput.commit();
+ } catch (Throwable t) {
+ ioErrs.increment(1);
+ mapOutput.abort();
+ throw new CelebornIOException(
+ "Reduce: {} "
+ + reduceId
+ + " fetch failed to {} "
+ + mapOutput.getClass().getSimpleName()
+ + " due to: {} "
+ + t.getClass().getName());
+ }
+ return true;
+ }
+
+ private Decompressor getDecompressor(InMemoryMapOutput inMemoryMapOutput)
+ throws CelebornIOException {
+ try {
+ Class clazz = Class.forName(InMemoryMapOutput.class.getName());
+ Field deCompressorField = clazz.getDeclaredField("decompressor");
+ deCompressorField.setAccessible(true);
+ return (Decompressor) deCompressorField.get(inMemoryMapOutput);
+ } catch (Exception e) {
+ throw new CelebornIOException("Get Decompressor fail " + e.getMessage());
+ }
+ }
+
+ private void writeShuffle(MapOutput mapOutput, byte[] shuffle) throws CelebornIOException {
+ if (mapOutput instanceof InMemoryMapOutput) {
+ InMemoryMapOutput inMemoryMapOutput = (InMemoryMapOutput) mapOutput;
+ CodecPool.returnDecompressor(getDecompressor(inMemoryMapOutput));
+ byte[] memory = inMemoryMapOutput.getMemory();
+ System.arraycopy(shuffle, 0, memory, 0, shuffle.length);
+ } else if (mapOutput instanceof OnDiskMapOutput) {
Review Comment:
What will happen when memory is not enough to hold all shuffle data, will it be spilled to disk or throw Exception? I think we need to verify this.
--
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: issues-unsubscribe@celeborn.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-celeborn] waitinfuture commented on a diff in pull request #1830: [CELEBORN-839][MR] Support Hadoop MapReduce
Posted by "waitinfuture (via GitHub)" <gi...@apache.org>.
waitinfuture commented on code in PR #1830:
URL: https://github.com/apache/incubator-celeborn/pull/1830#discussion_r1316597165
##########
client-mr/mr/src/main/java/org/apache/hadoop/mapreduce/task/reduce/CelebornShuffleConsumer.java:
##########
@@ -0,0 +1,170 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.mapreduce.task.reduce;
+
+import java.io.IOException;
+
+import org.apache.hadoop.mapred.*;
+import org.apache.hadoop.mapreduce.task.reduce.Shuffle.ShuffleError;
+import org.apache.hadoop.util.Progress;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.celeborn.client.ShuffleClient;
+import org.apache.celeborn.client.read.CelebornInputStream;
+import org.apache.celeborn.common.CelebornConf;
+import org.apache.celeborn.common.identity.UserIdentifier;
+import org.apache.celeborn.reflect.DynConstructors;
+import org.apache.celeborn.reflect.DynMethods;
+import org.apache.celeborn.util.HadoopUtils;
+
+public class CelebornShuffleConsumer<K, V>
+ implements ShuffleConsumerPlugin<K, V>, ExceptionReporter {
+ private static final Logger logger = LoggerFactory.getLogger(CelebornShuffleConsumer.class);
+ private JobConf mrJobConf;
+ private MergeManager<K, V> merger;
+ private Throwable throwable = null;
+ private Progress copyPhase;
+ private TaskStatus taskStatus;
+ private org.apache.hadoop.mapreduce.TaskAttemptID reduceId;
+ private TaskUmbilicalProtocol umbilical;
+ private Reporter reporter;
+ private ShuffleClientMetrics metrics;
+ private Task reduceTask;
+ private ShuffleClient shuffleClient;
+
+ @Override
+ public void init(Context<K, V> context) {
+
+ reduceId = context.getReduceId();
+ mrJobConf = context.getJobConf();
+ JobConf celebornJobConf = new JobConf(HadoopUtils.MR_CELEBORN_CONF);
+
+ umbilical = context.getUmbilical();
+ reporter = context.getReporter();
+ try {
+ this.metrics = createMetrics(reduceId, mrJobConf);
+ } catch (Exception e) {
+ logger.error("Fatal error occurred, failed to get shuffle client metrics.", e);
+ reportException(e);
+ }
+ copyPhase = context.getCopyPhase();
+ taskStatus = context.getStatus();
+ reduceTask = context.getReduceTask();
+
+ String appId = celebornJobConf.get(HadoopUtils.MR_CELEBORN_APPLICATION_ID);
+ String lcHost = celebornJobConf.get(HadoopUtils.MR_CELEBORN_LC_HOST);
+ int lcPort = Integer.parseInt(celebornJobConf.get(HadoopUtils.MR_CELEBORN_LC_PORT));
+ logger.info("Reducer initialized with celeborn {} {} {}", appId, lcHost, lcPort);
+ CelebornConf celebornConf = HadoopUtils.fromYarnConf(mrJobConf);
+ shuffleClient =
+ ShuffleClient.get(
+ appId,
+ lcHost,
+ lcPort,
+ celebornConf,
+ new UserIdentifier(
+ celebornConf.quotaUserSpecificTenant(), celebornConf.quotaUserSpecificUserName()));
+ this.merger = createMergeManager(context);
+ }
+
+ // Merge mapOutput and spill in local disks if necessary
+ protected MergeManager<K, V> createMergeManager(ShuffleConsumerPlugin.Context context) {
Review Comment:
Seems defining this method is unnecessary since it's only used in one place
--
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: issues-unsubscribe@celeborn.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-celeborn] pan3793 commented on a diff in pull request #1830: [CELEBORN-839][MR] Support Hadoop MapReduce
Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on code in PR #1830:
URL: https://github.com/apache/incubator-celeborn/pull/1830#discussion_r1321551347
##########
README.md:
##########
@@ -293,6 +305,19 @@ taskmanager.network.memory.buffers-per-channel: 0
taskmanager.memory.task.off-heap.size: 512m
```
+### Deploy mr client
+Add $CELEBORN_HOME/mr/*.jar to to `mapreduce.application.classpath` and `yarn.application.classpath`.
+And setting the following settings in Yarn and MR config.
Review Comment:
```suggestion
And setting the following settings in YARN and MapReduce config.
```
--
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: issues-unsubscribe@celeborn.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-celeborn] pan3793 commented on a diff in pull request #1830: [CELEBORN-839][MR] Support Hadoop MapReduce
Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on code in PR #1830:
URL: https://github.com/apache/incubator-celeborn/pull/1830#discussion_r1321740779
##########
pom.xml:
##########
@@ -64,9 +64,14 @@
<maven.version>3.8.8</maven.version>
<flink.version>1.14.6</flink.version>
- <hadoop.version>3.2.4</hadoop.version>
<spark.version>3.3.2</spark.version>
+ <!-- use hadoop-3 as default -->
+ <hadoop.version>3.2.4</hadoop.version>
+ <hadoop-client-api.artifact>hadoop-client-api</hadoop-client-api.artifact>
Review Comment:
I suppose the celeborn-mr-client-shaded built a against hadoop3 is runnable on hadoop2 too, thus, can we eliminate the global change and create a dedicated module under `tests/mr-it-hadoop2`, which launches a hadoop2 cluster via hadoop minicluster and tests by submitting an MR job with celeborn-mr-client-shaded built against hadoop3.
##########
pom.xml:
##########
@@ -64,9 +64,14 @@
<maven.version>3.8.8</maven.version>
<flink.version>1.14.6</flink.version>
- <hadoop.version>3.2.4</hadoop.version>
<spark.version>3.3.2</spark.version>
+ <!-- use hadoop-3 as default -->
+ <hadoop.version>3.2.4</hadoop.version>
+ <hadoop-client-api.artifact>hadoop-client-api</hadoop-client-api.artifact>
Review Comment:
I suppose the celeborn-mr-client-shaded built against hadoop3 is runnable on hadoop2 too, thus, can we eliminate the global change and create a dedicated module under `tests/mr-it-hadoop2`, which launches a hadoop2 cluster via hadoop minicluster and tests by submitting an MR job with celeborn-mr-client-shaded built against hadoop3.
--
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: issues-unsubscribe@celeborn.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-celeborn] FMX commented on pull request #1830: [CELEBORN-839][MR] Support Hadoop MapReduce
Posted by "FMX (via GitHub)" <gi...@apache.org>.
FMX commented on PR #1830:
URL: https://github.com/apache/incubator-celeborn/pull/1830#issuecomment-1698364518
> @FMX, I left some comments for the support of MR. PTAL. cc @waitinfuture
Thanks, I'll handle these comments today.
--
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: issues-unsubscribe@celeborn.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-celeborn] FMX commented on a diff in pull request #1830: [CELEBORN-839][MR] Support Hadoop MapReduce
Posted by "FMX (via GitHub)" <gi...@apache.org>.
FMX commented on code in PR #1830:
URL: https://github.com/apache/incubator-celeborn/pull/1830#discussion_r1309532844
##########
client-mr/mr/src/main/java/org/apache/hadoop/mapred/CelebornMapOutputCollector.java:
##########
@@ -0,0 +1,129 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.mapred;
+
+import java.io.IOException;
+
+import org.apache.hadoop.io.serializer.SerializationFactory;
+import org.apache.hadoop.mapreduce.JobContext;
+import org.apache.hadoop.mapreduce.TaskCounter;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.celeborn.client.ShuffleClient;
+import org.apache.celeborn.common.CelebornConf;
+import org.apache.celeborn.common.identity.UserIdentifier;
+import org.apache.celeborn.util.HadoopUtils;
+
+public class CelebornMapOutputCollector<K extends Object, V extends Object>
+ implements MapOutputCollector<K, V> {
+ private static final Logger logger = LoggerFactory.getLogger(CelebornMapOutputCollector.class);
+ private Class<K> keyClass;
+ private Class<V> valClass;
+ private Task.TaskReporter reporter;
+ private CelebornSortBasedPusher<K, V> celebornSortBasedPusher;
+ private int numReducers;
+
+ @Override
+ public void init(Context context) throws IOException {
+ JobConf jobConf = context.getJobConf();
+ reporter = context.getReporter();
+ keyClass = (Class<K>) jobConf.getMapOutputKeyClass();
+ valClass = (Class<V>) jobConf.getMapOutputValueClass();
+ context.getMapTask().getTaskID().getId();
+ numReducers = jobConf.getNumReduceTasks();
+
+ int IOBufferSize = jobConf.getInt(JobContext.IO_SORT_MB, 100);
+ // Java bytebuffer cannot be larger than Integer.MAX_VALUE
+ if ((IOBufferSize & 0x7FF) != IOBufferSize) {
+ throw new IOException("Invalid \"" + JobContext.IO_SORT_MB + "\": " + IOBufferSize);
+ }
+ jobConf.getNumReduceTasks();
+
+ CelebornConf celebornConf = HadoopUtils.fromYarnConf(jobConf);
+ JobConf celebornAppendConf = new JobConf(HadoopUtils.MR_CELEBORN_CONF);
+ String lcHost = celebornAppendConf.get(HadoopUtils.MR_CELEBORN_LC_HOST);
+ int lcPort = Integer.parseInt(celebornAppendConf.get(HadoopUtils.MR_CELEBORN_LC_PORT));
+ String applicationAttemptId = celebornAppendConf.get(HadoopUtils.MR_CELEBORN_APPLICATION_ID);
+ logger.info("Mapper initialized with celeborn {} {} {}", lcHost, lcPort, applicationAttemptId);
+ UserIdentifier userIdentifier =
+ new UserIdentifier(
+ celebornConf.quotaUserSpecificTenant(), celebornConf.quotaUserSpecificUserName());
+
+ logger.info(JobContext.IO_SORT_MB + ": " + IOBufferSize);
+ final float spiller = jobConf.getFloat(JobContext.MAP_SORT_SPILL_PERCENT, (float) 0.8);
+ int pushSize = (int) ((IOBufferSize << 20) * spiller);
+
+ SerializationFactory serializationFactory = new SerializationFactory(jobConf);
+ celebornSortBasedPusher =
+ new CelebornSortBasedPusher<>(
+ jobConf.getNumMapTasks(),
+ jobConf.getNumReduceTasks(),
+ // this is map id
+ context.getMapTask().getTaskID().getTaskID().getId(),
+ // this is attempt id
+ context.getMapTask().getTaskID().getId(),
+ serializationFactory.getSerializer(keyClass),
+ serializationFactory.getSerializer(valClass),
+ IOBufferSize << 20,
+ pushSize,
+ jobConf.getOutputKeyComparator(),
+ reporter.getCounter(TaskCounter.MAP_OUTPUT_BYTES),
+ reporter.getCounter(TaskCounter.MAP_OUTPUT_RECORDS),
+ ShuffleClient.get(applicationAttemptId, lcHost, lcPort, celebornConf, userIdentifier),
+ celebornConf);
+ }
+
+ @Override
+ public void collect(K key, V value, int partition) throws IOException {
+ reporter.progress();
+ if (key.getClass() != keyClass) {
+ throw new IOException(
+ "Type mismatch in key from map: expected "
+ + keyClass.getName()
+ + ", received "
+ + key.getClass().getName());
+ }
+ if (value.getClass() != valClass) {
+ throw new IOException(
+ "Type mismatch in value from map: expected "
+ + valClass.getName()
+ + ", received "
+ + value.getClass().getName());
+ }
+ if (partition < 0 || partition >= numReducers) {
+ throw new IOException("Illegal partition for " + key + " (" + partition + ")");
+ }
+ celebornSortBasedPusher.checkException();
+ celebornSortBasedPusher.insert(key, value, partition);
+ }
+
+ @Override
+ public void close() {
+ logger.info("Mapper collector close");
+ reporter.progress();
Review Comment:
IMO, the collector is closed and it will be cleaned after GC, I think the reporter and celebornSortBasedPusher instance will be cleaned after GC is occurred.
--
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: issues-unsubscribe@celeborn.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-celeborn] cfmcgrady commented on a diff in pull request #1830: [CELEBORN-839][MR] Support Hadoop MapReduce
Posted by "cfmcgrady (via GitHub)" <gi...@apache.org>.
cfmcgrady commented on code in PR #1830:
URL: https://github.com/apache/incubator-celeborn/pull/1830#discussion_r1309563854
##########
client-mr/mr-shaded/pom.xml:
##########
@@ -0,0 +1,149 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+~ Licensed to the Apache Software Foundation (ASF) under one or more
+~ contributor license agreements. See the NOTICE file distributed with
+~ this work for additional information regarding copyright ownership.
+~ The ASF licenses this file to You under the Apache License, Version 2.0
+~ (the "License"); you may not use this file except in compliance with
+~ the License. You may obtain a copy of the License at
+~
+~ http://www.apache.org/licenses/LICENSE-2.0
+~
+~ Unless required by applicable law or agreed to in writing, software
+~ distributed under the License is distributed on an "AS IS" BASIS,
+~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+~ See the License for the specific language governing permissions and
+~ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.celeborn</groupId>
+ <artifactId>celeborn-parent_${scala.binary.version}</artifactId>
+ <version>${project.version}</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>celeborn-client-mr-shaded-${hadoop.version}</artifactId>
+ <packaging>jar</packaging>
+ <name>Celeborn Shaded Client for MapReduce</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.celeborn</groupId>
+ <artifactId>celeborn-client-mr-${hadoop.version}</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-shade-plugin</artifactId>
+ <configuration>
+ <relocations>
+ <relocation>
+ <pattern>com.google.protobuf</pattern>
+ <shadedPattern>${shading.prefix}.com.google.protobuf</shadedPattern>
+ </relocation>
+ <relocation>
+ <pattern>com.google.common</pattern>
+ <shadedPattern>${shading.prefix}.com.google.common</shadedPattern>
+ </relocation>
+ <relocation>
+ <pattern>io.netty</pattern>
+ <shadedPattern>${shading.prefix}.io.netty</shadedPattern>
+ </relocation>
+ <relocation>
+ <pattern>org.apache.commons</pattern>
+ <shadedPattern>${shading.prefix}.org.apache.commons</shadedPattern>
+ </relocation>
+ <relocation>
+ <pattern>com.fasterxml.jackson.core</pattern>
Review Comment:
why do we need to shade the dependency `jackson` for MapReduce client?
--
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: issues-unsubscribe@celeborn.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-celeborn] FMX commented on a diff in pull request #1830: [CELEBORN-839][MR] Support Hadoop MapReduce
Posted by "FMX (via GitHub)" <gi...@apache.org>.
FMX commented on code in PR #1830:
URL: https://github.com/apache/incubator-celeborn/pull/1830#discussion_r1309820410
##########
client-mr/mr-shaded/pom.xml:
##########
@@ -0,0 +1,149 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+~ Licensed to the Apache Software Foundation (ASF) under one or more
+~ contributor license agreements. See the NOTICE file distributed with
+~ this work for additional information regarding copyright ownership.
+~ The ASF licenses this file to You under the Apache License, Version 2.0
+~ (the "License"); you may not use this file except in compliance with
+~ the License. You may obtain a copy of the License at
+~
+~ http://www.apache.org/licenses/LICENSE-2.0
+~
+~ Unless required by applicable law or agreed to in writing, software
+~ distributed under the License is distributed on an "AS IS" BASIS,
+~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+~ See the License for the specific language governing permissions and
+~ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.celeborn</groupId>
+ <artifactId>celeborn-parent_${scala.binary.version}</artifactId>
+ <version>${project.version}</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>celeborn-client-mr-shaded-${hadoop.version}</artifactId>
+ <packaging>jar</packaging>
+ <name>Celeborn Shaded Client for MapReduce</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.celeborn</groupId>
+ <artifactId>celeborn-client-mr-${hadoop.version}</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-shade-plugin</artifactId>
+ <configuration>
+ <relocations>
+ <relocation>
+ <pattern>com.google.protobuf</pattern>
+ <shadedPattern>${shading.prefix}.com.google.protobuf</shadedPattern>
+ </relocation>
+ <relocation>
+ <pattern>com.google.common</pattern>
+ <shadedPattern>${shading.prefix}.com.google.common</shadedPattern>
+ </relocation>
+ <relocation>
+ <pattern>io.netty</pattern>
+ <shadedPattern>${shading.prefix}.io.netty</shadedPattern>
+ </relocation>
+ <relocation>
+ <pattern>org.apache.commons</pattern>
+ <shadedPattern>${shading.prefix}.org.apache.commons</shadedPattern>
+ </relocation>
+ <relocation>
+ <pattern>com.fasterxml.jackson.core</pattern>
Review Comment:
> but the Celeborn client doesn't need Jackson at runtime, right?
Yes, Celeborn client won't need Jackson at runtime.
--
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: issues-unsubscribe@celeborn.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-celeborn] cfmcgrady commented on a diff in pull request #1830: [CELEBORN-839][MR] Support Hadoop MapReduce
Posted by "cfmcgrady (via GitHub)" <gi...@apache.org>.
cfmcgrady commented on code in PR #1830:
URL: https://github.com/apache/incubator-celeborn/pull/1830#discussion_r1309777724
##########
client-mr/mr-shaded/pom.xml:
##########
@@ -0,0 +1,149 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+~ Licensed to the Apache Software Foundation (ASF) under one or more
+~ contributor license agreements. See the NOTICE file distributed with
+~ this work for additional information regarding copyright ownership.
+~ The ASF licenses this file to You under the Apache License, Version 2.0
+~ (the "License"); you may not use this file except in compliance with
+~ the License. You may obtain a copy of the License at
+~
+~ http://www.apache.org/licenses/LICENSE-2.0
+~
+~ Unless required by applicable law or agreed to in writing, software
+~ distributed under the License is distributed on an "AS IS" BASIS,
+~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+~ See the License for the specific language governing permissions and
+~ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.celeborn</groupId>
+ <artifactId>celeborn-parent_${scala.binary.version}</artifactId>
+ <version>${project.version}</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>celeborn-client-mr-shaded-${hadoop.version}</artifactId>
+ <packaging>jar</packaging>
+ <name>Celeborn Shaded Client for MapReduce</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.celeborn</groupId>
+ <artifactId>celeborn-client-mr-${hadoop.version}</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-shade-plugin</artifactId>
+ <configuration>
+ <relocations>
+ <relocation>
+ <pattern>com.google.protobuf</pattern>
+ <shadedPattern>${shading.prefix}.com.google.protobuf</shadedPattern>
+ </relocation>
+ <relocation>
+ <pattern>com.google.common</pattern>
+ <shadedPattern>${shading.prefix}.com.google.common</shadedPattern>
+ </relocation>
+ <relocation>
+ <pattern>io.netty</pattern>
+ <shadedPattern>${shading.prefix}.io.netty</shadedPattern>
+ </relocation>
+ <relocation>
+ <pattern>org.apache.commons</pattern>
+ <shadedPattern>${shading.prefix}.org.apache.commons</shadedPattern>
+ </relocation>
+ <relocation>
+ <pattern>com.fasterxml.jackson.core</pattern>
Review Comment:
for spark-3.4
```
$ ./build/mvn -Pspark-3.4 dependency:tree | grep -i jackson
Using `mvn` from path: /tmp/dddd/celeborn/build/apache-maven-3.8.8/bin/mvn
[INFO] | | \- com.fasterxml.jackson.core:jackson-core:jar:2.12.7:provided
[INFO] | | \- com.fasterxml.jackson.core:jackson-annotations:jar:2.14.2:provided
[INFO] | +- org.json4s:json4s-jackson_2.12:jar:3.7.0-M11:provided
[INFO] | +- com.fasterxml.jackson.core:jackson-databind:jar:2.14.2:provided
[INFO] | +- com.fasterxml.jackson.module:jackson-module-scala_2.12:jar:2.14.2:provided
[INFO] | | | +- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.13.4:provided
[INFO] | \- org.apache.parquet:parquet-jackson:jar:1.12.3:provided
[INFO] | | \- com.fasterxml.jackson.core:jackson-core:jar:2.12.7:provided
[INFO] | | \- com.fasterxml.jackson.core:jackson-annotations:jar:2.14.2:provided
[INFO] | +- org.json4s:json4s-jackson_2.12:jar:3.7.0-M11:provided
[INFO] | +- com.fasterxml.jackson.core:jackson-databind:jar:2.14.2:provided
[INFO] | +- com.fasterxml.jackson.module:jackson-module-scala_2.12:jar:2.14.2:provided
[INFO] | | | +- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.13.4:provided
[INFO] | \- org.apache.parquet:parquet-jackson:jar:1.12.3:provided
[INFO] | | +- org.json4s:json4s-jackson_2.12:jar:3.7.0-M11:provided
[INFO] | | +- com.fasterxml.jackson.module:jackson-module-scala_2.12:jar:2.14.2:provided
[INFO] | | | +- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.13.4:provided
[INFO] | | \- org.apache.parquet:parquet-jackson:jar:1.12.3:provided
[INFO] | +- com.fasterxml.jackson.core:jackson-databind:jar:2.14.2:provided
[INFO] | | +- com.fasterxml.jackson.core:jackson-annotations:jar:2.14.2:provided
[INFO] | | \- com.fasterxml.jackson.core:jackson-core:jar:2.14.2:provided
[INFO] | | \- com.fasterxml.jackson.core:jackson-core:jar:2.12.7:test
[INFO] | | \- com.fasterxml.jackson.core:jackson-annotations:jar:2.14.2:test
[INFO] | +- org.json4s:json4s-jackson_2.12:jar:3.7.0-M11:test
[INFO] | +- com.fasterxml.jackson.core:jackson-databind:jar:2.14.2:test
[INFO] | +- com.fasterxml.jackson.module:jackson-module-scala_2.12:jar:2.14.2:test
[INFO] | | | +- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.13.4:test
[INFO] | \- org.apache.parquet:parquet-jackson:jar:1.12.3:test
```
```
$./build/sbt -Pspark-3.4 celeborn-client-spark-3/Runtime/dependencyTree | grep -i jackson
```
All of them fall within the scope of both the `test` and `provided`.
--
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: issues-unsubscribe@celeborn.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-celeborn] cfmcgrady commented on a diff in pull request #1830: [CELEBORN-839][MR] Support Hadoop MapReduce
Posted by "cfmcgrady (via GitHub)" <gi...@apache.org>.
cfmcgrady commented on code in PR #1830:
URL: https://github.com/apache/incubator-celeborn/pull/1830#discussion_r1311845075
##########
client-mr/mr/src/main/java/org/apache/hadoop/mapreduce/task/reduce/CelebornShuffleConsumer.java:
##########
@@ -0,0 +1,173 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.mapreduce.task.reduce;
+
+import java.io.IOException;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import org.apache.hadoop.mapred.*;
+import org.apache.hadoop.mapreduce.task.reduce.Shuffle.ShuffleError;
+import org.apache.hadoop.util.Progress;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.celeborn.client.ShuffleClient;
+import org.apache.celeborn.client.read.CelebornInputStream;
+import org.apache.celeborn.common.CelebornConf;
+import org.apache.celeborn.common.identity.UserIdentifier;
+import org.apache.celeborn.util.HadoopUtils;
+
+public class CelebornShuffleConsumer<K, V>
+ implements ShuffleConsumerPlugin<K, V>, ExceptionReporter {
+ private static final Logger logger = LoggerFactory.getLogger(CelebornShuffleConsumer.class);
+ private JobConf mrJobConf;
+ private MergeManager<K, V> merger;
+ private Throwable throwable = null;
+ private Progress copyPhase;
+ private TaskStatus taskStatus;
+ private org.apache.hadoop.mapreduce.TaskAttemptID reduceId;
+ private TaskUmbilicalProtocol umbilical;
+ private Reporter reporter;
+ private ShuffleClientMetrics metrics;
+ private Task reduceTask;
+
+ private ShuffleClient shuffleClient;
+
+ @Override
+ public void init(Context<K, V> context) {
+
+ reduceId = context.getReduceId();
+ mrJobConf = context.getJobConf();
+ JobConf celebornJobConf = new JobConf(HadoopUtils.MR_CELEBORN_CONF);
+
+ umbilical = context.getUmbilical();
+ reporter = context.getReporter();
+ try {
+ this.metrics = createMetrics(reduceId, mrJobConf);
+ } catch (Exception e) {
+ logger.error("Fatal error occurred, failed to get shuffle client metrics.", e);
+ reportException(e);
+ }
+ copyPhase = context.getCopyPhase();
+ taskStatus = context.getStatus();
+ reduceTask = context.getReduceTask();
+
+ String appId = celebornJobConf.get(HadoopUtils.MR_CELEBORN_APPLICATION_ID);
+ String lcHost = celebornJobConf.get(HadoopUtils.MR_CELEBORN_LC_HOST);
+ int lcPort = Integer.parseInt(celebornJobConf.get(HadoopUtils.MR_CELEBORN_LC_PORT));
+ logger.info("Reducer initialized with celeborn {} {} {}", appId, lcHost, lcPort);
+ CelebornConf celebornConf = HadoopUtils.fromYarnConf(mrJobConf);
+ shuffleClient =
+ ShuffleClient.get(
+ appId,
+ lcHost,
+ lcPort,
+ celebornConf,
+ new UserIdentifier(
+ celebornConf.quotaUserSpecificTenant(), celebornConf.quotaUserSpecificUserName()));
+ this.merger = createMergeManager(context);
+ }
+
+ // Merge mapOutput and spill in local disks if necessary
+ protected MergeManager<K, V> createMergeManager(ShuffleConsumerPlugin.Context context) {
+ return new MergeManagerImpl<K, V>(
+ reduceId,
+ mrJobConf,
+ context.getLocalFS(),
+ context.getLocalDirAllocator(),
+ reporter,
+ context.getCodec(),
+ context.getCombinerClass(),
+ context.getCombineCollector(),
+ context.getSpilledRecordsCounter(),
+ context.getReduceCombineInputCounter(),
+ context.getMergedMapOutputsCounter(),
+ this,
+ context.getMergePhase(),
+ context.getMapOutputFile());
+ }
+
+ private ShuffleClientMetrics createMetrics(
+ org.apache.hadoop.mapreduce.TaskAttemptID taskAttemptID, JobConf jobConf)
+ throws NoSuchMethodException, InvocationTargetException, InstantiationException,
+ IllegalAccessException {
+ // for hadoop 3
Review Comment:
we can use `DynMethods` to improve code readability, like what we did in the class `MemoryManager`.
https://github.com/apache/incubator-celeborn/blob/e2c42faed9b268de38420ed94fe64a3b09a940d4/worker/src/main/java/org/apache/celeborn/service/deploy/worker/memory/MemoryManager.java#L115-L120
--
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: issues-unsubscribe@celeborn.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-celeborn] FMX commented on a diff in pull request #1830: [CELEBORN-839][MR] Support Hadoop MapReduce
Posted by "FMX (via GitHub)" <gi...@apache.org>.
FMX commented on code in PR #1830:
URL: https://github.com/apache/incubator-celeborn/pull/1830#discussion_r1311019966
##########
client-mr/mr-shaded/pom.xml:
##########
@@ -0,0 +1,149 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+~ Licensed to the Apache Software Foundation (ASF) under one or more
+~ contributor license agreements. See the NOTICE file distributed with
+~ this work for additional information regarding copyright ownership.
+~ The ASF licenses this file to You under the Apache License, Version 2.0
+~ (the "License"); you may not use this file except in compliance with
+~ the License. You may obtain a copy of the License at
+~
+~ http://www.apache.org/licenses/LICENSE-2.0
+~
+~ Unless required by applicable law or agreed to in writing, software
+~ distributed under the License is distributed on an "AS IS" BASIS,
+~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+~ See the License for the specific language governing permissions and
+~ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.celeborn</groupId>
+ <artifactId>celeborn-parent_${scala.binary.version}</artifactId>
+ <version>${project.version}</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>celeborn-client-mr-shaded-${hadoop.version}</artifactId>
+ <packaging>jar</packaging>
+ <name>Celeborn Shaded Client for MapReduce</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.celeborn</groupId>
+ <artifactId>celeborn-client-mr-${hadoop.version}</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-shade-plugin</artifactId>
+ <configuration>
+ <relocations>
+ <relocation>
+ <pattern>com.google.protobuf</pattern>
+ <shadedPattern>${shading.prefix}.com.google.protobuf</shadedPattern>
+ </relocation>
+ <relocation>
+ <pattern>com.google.common</pattern>
+ <shadedPattern>${shading.prefix}.com.google.common</shadedPattern>
+ </relocation>
+ <relocation>
+ <pattern>io.netty</pattern>
+ <shadedPattern>${shading.prefix}.io.netty</shadedPattern>
+ </relocation>
+ <relocation>
+ <pattern>org.apache.commons</pattern>
+ <shadedPattern>${shading.prefix}.org.apache.commons</shadedPattern>
+ </relocation>
+ <relocation>
+ <pattern>com.fasterxml.jackson.core</pattern>
Review Comment:
I'll try to remove Jackson dependencies.
--
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: issues-unsubscribe@celeborn.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org