You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@uniffle.apache.org by "lifeSo (via GitHub)" <gi...@apache.org> on 2023/06/13 06:42:22 UTC
[GitHub] [incubator-uniffle] lifeSo opened a new pull request, #947: [#854][FOLLOWUP] feat(tez): Add RssShuffleManager to run and manager shuffle work
lifeSo opened a new pull request, #947:
URL: https://github.com/apache/incubator-uniffle/pull/947
### What changes were proposed in this pull request?
Add RssShuffleManager to run and manager shuffle work
### Why are the changes needed?
Fix: https://github.com/apache/incubator-uniffle/issues/854
### Does this PR introduce _any_ user-facing change?
No.
### How was this patch tested?
unit test
--
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@uniffle.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org
For additional commands, e-mail: issues-help@uniffle.apache.org
[GitHub] [incubator-uniffle] jerqi commented on pull request #947: [#854][FOLLOWUP] feat(tez): Add RssShuffleManager to run and manager shuffle work
Posted by "jerqi (via GitHub)" <gi...@apache.org>.
jerqi commented on PR #947:
URL: https://github.com/apache/incubator-uniffle/pull/947#issuecomment-1588759406
Could you checkstyle,spotbugs and run ut locally first.
--
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@uniffle.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org
For additional commands, e-mail: issues-help@uniffle.apache.org
[GitHub] [incubator-uniffle] jerqi commented on a diff in pull request #947: [#854][FOLLOWUP] feat(tez): Add RssShuffleManager to run and manager shuffle work
Posted by "jerqi (via GitHub)" <gi...@apache.org>.
jerqi commented on code in PR #947:
URL: https://github.com/apache/incubator-uniffle/pull/947#discussion_r1236258105
##########
client-tez/src/main/java/org/apache/tez/runtime/library/common/shuffle/impl/RssShuffleManager.java:
##########
@@ -0,0 +1,1236 @@
+/**
+ * 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.tez.runtime.library.common.shuffle.impl;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.nio.ByteBuffer;
+import java.text.DecimalFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.BitSet;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.LinkedBlockingDeque;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.locks.Condition;
+import java.util.concurrent.locks.ReentrantLock;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Objects;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
+import com.google.common.util.concurrent.FutureCallback;
+import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.ListeningExecutorService;
+import com.google.common.util.concurrent.MoreExecutors;
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.LocalDirAllocator;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.fs.RawLocalFileSystem;
+import org.apache.hadoop.io.compress.CompressionCodec;
+import org.apache.hadoop.util.Time;
+import org.apache.tez.common.CallableWithNdc;
+import org.apache.tez.common.InputContextUtils;
+import org.apache.tez.common.TezRuntimeFrameworkConfigs;
+import org.apache.tez.common.TezUtilsInternal;
+import org.apache.tez.common.UmbilicalUtils;
+import org.apache.tez.common.counters.TaskCounter;
+import org.apache.tez.common.counters.TezCounter;
+import org.apache.tez.dag.api.TezConfiguration;
+import org.apache.tez.dag.api.TezUncheckedException;
+import org.apache.tez.dag.records.TezTaskAttemptID;
+import org.apache.tez.http.HttpConnectionParams;
+import org.apache.tez.runtime.api.Event;
+import org.apache.tez.runtime.api.InputContext;
+import org.apache.tez.runtime.api.TaskFailureType;
+import org.apache.tez.runtime.api.events.InputReadErrorEvent;
+import org.apache.tez.runtime.library.api.TezRuntimeConfiguration;
+import org.apache.tez.runtime.library.common.CompositeInputAttemptIdentifier;
+import org.apache.tez.runtime.library.common.InputAttemptIdentifier;
+import org.apache.tez.runtime.library.common.TezRuntimeUtils;
+import org.apache.tez.runtime.library.common.shuffle.FetchResult;
+import org.apache.tez.runtime.library.common.shuffle.FetchedInput;
+import org.apache.tez.runtime.library.common.shuffle.FetchedInputAllocator;
+import org.apache.tez.runtime.library.common.shuffle.Fetcher;
+import org.apache.tez.runtime.library.common.shuffle.Fetcher.FetcherBuilder;
+import org.apache.tez.runtime.library.common.shuffle.HostPort;
+import org.apache.tez.runtime.library.common.shuffle.InputHost;
+import org.apache.tez.runtime.library.common.shuffle.InputHost.PartitionToInputs;
+import org.apache.tez.runtime.library.common.shuffle.ShuffleUtils;
+import org.apache.tez.runtime.library.common.shuffle.ShuffleUtils.FetchStatsLogger;
+import org.roaringbitmap.longlong.Roaring64NavigableMap;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.uniffle.common.ShuffleServerInfo;
+
+// This only knows how to deal with a single srcIndex for a given targetIndex.
+// In case the src task generates multiple outputs for the same target Index
+// (multiple src-indices), modifications will be required.
+public class RssShuffleManager extends ShuffleManager {
+
+ private static final Logger LOG = LoggerFactory.getLogger(RssShuffleManager.class);
+ private static final Logger LOG_FETCH = LoggerFactory.getLogger(LOG.getName() + ".fetch");
+ private static final FetchStatsLogger fetchStatsLogger = new FetchStatsLogger(LOG_FETCH, LOG);
+
+ private final InputContext inputContext;
+ private final int numInputs;
+
+ private final DecimalFormat mbpsFormat = new DecimalFormat("0.00");
+
+ private final FetchedInputAllocator inputManager;
+
+ @VisibleForTesting
+ final ListeningExecutorService fetcherExecutor;
+
+ /**
+ * Executor for ReportCallable.
+ */
+ private ExecutorService reporterExecutor;
+
+ /**
+ * Lock to sync failedEvents.
+ */
+ private final ReentrantLock reportLock = new ReentrantLock();
+
+ /**
+ * Condition to wake up the thread notifying when events fail.
+ */
+ private final Condition reportCondition = reportLock.newCondition();
+
+ /**
+ * Events reporting fetcher failed.
+ */
+ private final HashMap<InputReadErrorEvent, Integer> failedEvents = new HashMap<>();
+
+ private final ListeningExecutorService schedulerExecutor;
+ private final RssRunShuffleCallable rssSchedulerCallable;
+
+ private final BlockingQueue<FetchedInput> completedInputs;
+ private final AtomicBoolean inputReadyNotificationSent = new AtomicBoolean(false);
+ @VisibleForTesting
+ final BitSet completedInputSet;
+ private final ConcurrentMap<HostPort, InputHost> knownSrcHosts;
+ private final BlockingQueue<InputHost> pendingHosts;
+ private final Set<InputAttemptIdentifier> obsoletedInputs;
+ private Set<RssTezFetcherTask> rssRunningFetchers;
+
+ private final AtomicInteger numCompletedInputs = new AtomicInteger(0);
+ private final AtomicInteger numFetchedSpills = new AtomicInteger(0);
+
+ private final long startTime;
+ private long lastProgressTime;
+ private long totalBytesShuffledTillNow;
+
+ // Required to be held when manipulating pendingHosts
+ private final ReentrantLock lock = new ReentrantLock();
+ private final Condition wakeLoop = lock.newCondition();
+
+ private final int numFetchers;
+ private final boolean asyncHttp;
+
+ // Parameters required by Fetchers
+ private final CompressionCodec codec;
+ private final Configuration conf;
+ private final boolean localDiskFetchEnabled;
+ private final boolean sharedFetchEnabled;
+ private final boolean verifyDiskChecksum;
+ private final boolean compositeFetch;
+
+ private final int ifileBufferSize;
+ private final boolean ifileReadAhead;
+ private final int ifileReadAheadLength;
+
+ /**
+ * Holds the time to wait for failures to batch them and send less events.
+ */
+ private final int maxTimeToWaitForReportMillis;
+
+ private final String srcNameTrimmed;
+
+ private final int maxTaskOutputAtOnce;
+
+ private final AtomicBoolean isShutdown = new AtomicBoolean(false);
+
+ private final TezCounter shuffledInputsCounter;
+ private final TezCounter failedShufflesCounter;
+ private final TezCounter bytesShuffledCounter;
+ private final TezCounter decompressedDataSizeCounter;
+ private final TezCounter bytesShuffledToDiskCounter;
+ private final TezCounter bytesShuffledToMemCounter;
+ private final TezCounter bytesShuffledDirectDiskCounter;
+
+ private volatile Throwable shuffleError;
+ private final HttpConnectionParams httpConnectionParams;
+
+ private final LocalDirAllocator localDirAllocator;
+ private final RawLocalFileSystem localFs;
+ private final Path[] localDisks;
+ private final String localhostName;
+ private final int shufflePort;
+
+ private final TezCounter shufflePhaseTime;
+ private final TezCounter firstEventReceived;
+ private final TezCounter lastEventReceived;
+
+ //To track shuffleInfo events when finalMerge is disabled OR pipelined shuffle is enabled in source.
+ @VisibleForTesting
+ final Map<Integer, ShuffleEventInfo> shuffleInfoEventsMap;
+
+ private Map<Integer, List<ShuffleServerInfo>> partitionToServers;
+ private final Set<Integer> successRssPartitionSet = new HashSet<>();
+ private final Set<Integer> runningRssPartitionMap = new HashSet<>();
+ private final Set<Integer> allRssPartition = Sets.newConcurrentHashSet();
+ private final BlockingQueue<Integer> pendingPartition = new LinkedBlockingQueue<>();
+ Map<Integer, List<InputAttemptIdentifier>> partitionToInput = new HashMap<>();
+ private final Map<Integer, Roaring64NavigableMap> rssAllBlockIdBitmapMap = new ConcurrentHashMap<>();
+ private final Map<Integer, Roaring64NavigableMap> rssSuccessBlockIdBitmapMap = new ConcurrentHashMap<>();
+ private final AtomicInteger numNoDataInput = new AtomicInteger(0);
+ private final AtomicInteger numWithDataInput = new AtomicInteger(0);
+
+ @SuppressFBWarnings("NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE")
Review Comment:
Could we remove this annotattion?
--
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@uniffle.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org
For additional commands, e-mail: issues-help@uniffle.apache.org
[GitHub] [incubator-uniffle] lifeSo commented on pull request #947: [#854][FOLLOWUP] feat(tez): Add RssShuffleManager to run and manager shuffle work
Posted by "lifeSo (via GitHub)" <gi...@apache.org>.
lifeSo commented on PR #947:
URL: https://github.com/apache/incubator-uniffle/pull/947#issuecomment-1590395943
> What‘s the difference between #947 and #948?
#947 RssShuffleManager is for unordered input, #948 RssShuffleScheduler is for ordered input
--
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@uniffle.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org
For additional commands, e-mail: issues-help@uniffle.apache.org
[GitHub] [incubator-uniffle] jerqi merged pull request #947: [#854][FOLLOWUP] feat(tez): Add RssShuffleManager to run and manager shuffle work
Posted by "jerqi (via GitHub)" <gi...@apache.org>.
jerqi merged PR #947:
URL: https://github.com/apache/incubator-uniffle/pull/947
--
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@uniffle.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org
For additional commands, e-mail: issues-help@uniffle.apache.org
[GitHub] [incubator-uniffle] jerqi commented on a diff in pull request #947: [#854][FOLLOWUP] feat(tez): Add RssShuffleManager to run and manager shuffle work
Posted by "jerqi (via GitHub)" <gi...@apache.org>.
jerqi commented on code in PR #947:
URL: https://github.com/apache/incubator-uniffle/pull/947#discussion_r1236190686
##########
client-tez/src/main/java/org/apache/tez/runtime/library/common/shuffle/impl/RssShuffleManager.java:
##########
@@ -0,0 +1,1236 @@
+/**
+ * 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.tez.runtime.library.common.shuffle.impl;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.nio.ByteBuffer;
+import java.text.DecimalFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.BitSet;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.LinkedBlockingDeque;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.locks.Condition;
+import java.util.concurrent.locks.ReentrantLock;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Objects;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
+import com.google.common.util.concurrent.FutureCallback;
+import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.ListeningExecutorService;
+import com.google.common.util.concurrent.MoreExecutors;
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.LocalDirAllocator;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.fs.RawLocalFileSystem;
+import org.apache.hadoop.io.compress.CompressionCodec;
+import org.apache.hadoop.util.Time;
+import org.apache.tez.common.CallableWithNdc;
+import org.apache.tez.common.InputContextUtils;
+import org.apache.tez.common.TezRuntimeFrameworkConfigs;
+import org.apache.tez.common.TezUtilsInternal;
+import org.apache.tez.common.UmbilicalUtils;
+import org.apache.tez.common.counters.TaskCounter;
+import org.apache.tez.common.counters.TezCounter;
+import org.apache.tez.dag.api.TezConfiguration;
+import org.apache.tez.dag.api.TezUncheckedException;
+import org.apache.tez.dag.records.TezTaskAttemptID;
+import org.apache.tez.http.HttpConnectionParams;
+import org.apache.tez.runtime.api.Event;
+import org.apache.tez.runtime.api.InputContext;
+import org.apache.tez.runtime.api.TaskFailureType;
+import org.apache.tez.runtime.api.events.InputReadErrorEvent;
+import org.apache.tez.runtime.library.api.TezRuntimeConfiguration;
+import org.apache.tez.runtime.library.common.CompositeInputAttemptIdentifier;
+import org.apache.tez.runtime.library.common.InputAttemptIdentifier;
+import org.apache.tez.runtime.library.common.TezRuntimeUtils;
+import org.apache.tez.runtime.library.common.shuffle.FetchResult;
+import org.apache.tez.runtime.library.common.shuffle.FetchedInput;
+import org.apache.tez.runtime.library.common.shuffle.FetchedInputAllocator;
+import org.apache.tez.runtime.library.common.shuffle.Fetcher;
+import org.apache.tez.runtime.library.common.shuffle.Fetcher.FetcherBuilder;
+import org.apache.tez.runtime.library.common.shuffle.HostPort;
+import org.apache.tez.runtime.library.common.shuffle.InputHost;
+import org.apache.tez.runtime.library.common.shuffle.InputHost.PartitionToInputs;
+import org.apache.tez.runtime.library.common.shuffle.ShuffleUtils;
+import org.apache.tez.runtime.library.common.shuffle.ShuffleUtils.FetchStatsLogger;
+import org.roaringbitmap.longlong.Roaring64NavigableMap;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.uniffle.common.ShuffleServerInfo;
+
+// This only knows how to deal with a single srcIndex for a given targetIndex.
+// In case the src task generates multiple outputs for the same target Index
+// (multiple src-indices), modifications will be required.
+public class RssShuffleManager extends ShuffleManager {
+
+ private static final Logger LOG = LoggerFactory.getLogger(RssShuffleManager.class);
+ private static final Logger LOG_FETCH = LoggerFactory.getLogger(LOG.getName() + ".fetch");
+ private static final FetchStatsLogger fetchStatsLogger = new FetchStatsLogger(LOG_FETCH, LOG);
+
+ private final InputContext inputContext;
+ private final int numInputs;
+
+ private final DecimalFormat mbpsFormat = new DecimalFormat("0.00");
+
+ private final FetchedInputAllocator inputManager;
+
+ @VisibleForTesting
+ final ListeningExecutorService fetcherExecutor;
+
+ /**
+ * Executor for ReportCallable.
+ */
+ private ExecutorService reporterExecutor;
+
+ /**
+ * Lock to sync failedEvents.
+ */
+ private final ReentrantLock reportLock = new ReentrantLock();
+
+ /**
+ * Condition to wake up the thread notifying when events fail.
+ */
+ private final Condition reportCondition = reportLock.newCondition();
+
+ /**
+ * Events reporting fetcher failed.
+ */
+ private final HashMap<InputReadErrorEvent, Integer> failedEvents = new HashMap<>();
+
+ private final ListeningExecutorService schedulerExecutor;
+ private final RssRunShuffleCallable rssSchedulerCallable;
+
+ private final BlockingQueue<FetchedInput> completedInputs;
+ private final AtomicBoolean inputReadyNotificationSent = new AtomicBoolean(false);
+ @VisibleForTesting
+ final BitSet completedInputSet;
+ private final ConcurrentMap<HostPort, InputHost> knownSrcHosts;
+ private final BlockingQueue<InputHost> pendingHosts;
+ private final Set<InputAttemptIdentifier> obsoletedInputs;
+ private Set<RssTezFetcherTask> rssRunningFetchers;
+
+ private final AtomicInteger numCompletedInputs = new AtomicInteger(0);
+ private final AtomicInteger numFetchedSpills = new AtomicInteger(0);
+
+ private final long startTime;
+ private long lastProgressTime;
+ private long totalBytesShuffledTillNow;
+
+ // Required to be held when manipulating pendingHosts
+ private final ReentrantLock lock = new ReentrantLock();
+ private final Condition wakeLoop = lock.newCondition();
+
+ private final int numFetchers;
+ private final boolean asyncHttp;
+
+ // Parameters required by Fetchers
+ private final CompressionCodec codec;
+ private final Configuration conf;
+ private final boolean localDiskFetchEnabled;
+ private final boolean sharedFetchEnabled;
+ private final boolean verifyDiskChecksum;
+ private final boolean compositeFetch;
+
+ private final int ifileBufferSize;
+ private final boolean ifileReadAhead;
+ private final int ifileReadAheadLength;
+
+ /**
+ * Holds the time to wait for failures to batch them and send less events.
+ */
+ private final int maxTimeToWaitForReportMillis;
+
+ private final String srcNameTrimmed;
+
+ private final int maxTaskOutputAtOnce;
+
+ private final AtomicBoolean isShutdown = new AtomicBoolean(false);
+
+ private final TezCounter shuffledInputsCounter;
+ private final TezCounter failedShufflesCounter;
+ private final TezCounter bytesShuffledCounter;
+ private final TezCounter decompressedDataSizeCounter;
+ private final TezCounter bytesShuffledToDiskCounter;
+ private final TezCounter bytesShuffledToMemCounter;
+ private final TezCounter bytesShuffledDirectDiskCounter;
+
+ private volatile Throwable shuffleError;
+ private final HttpConnectionParams httpConnectionParams;
+
+ private final LocalDirAllocator localDirAllocator;
+ private final RawLocalFileSystem localFs;
+ private final Path[] localDisks;
+ private final String localhostName;
+ private final int shufflePort;
+
+ private final TezCounter shufflePhaseTime;
+ private final TezCounter firstEventReceived;
+ private final TezCounter lastEventReceived;
+
+ //To track shuffleInfo events when finalMerge is disabled OR pipelined shuffle is enabled in source.
+ @VisibleForTesting
+ final Map<Integer, ShuffleEventInfo> shuffleInfoEventsMap;
+
+ private Map<Integer, List<ShuffleServerInfo>> partitionToServers;
+ private final Set<Integer> successRssPartitionSet = new HashSet<>();
+ private final Set<Integer> runningRssPartitionMap = new HashSet<>();
+ private final Set<Integer> allRssPartition = Sets.newConcurrentHashSet();
+ private final BlockingQueue<Integer> pendingPartition = new LinkedBlockingQueue<>();
+ Map<Integer, List<InputAttemptIdentifier>> partitionToInput = new HashMap<>();
+ private final Map<Integer, Roaring64NavigableMap> rssAllBlockIdBitmapMap = new ConcurrentHashMap<>();
+ private final Map<Integer, Roaring64NavigableMap> rssSuccessBlockIdBitmapMap = new ConcurrentHashMap<>();
+ private final AtomicInteger numNoDataInput = new AtomicInteger(0);
+ private final AtomicInteger numWithDataInput = new AtomicInteger(0);
+
+ @SuppressFBWarnings("NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE")
Review Comment:
Could we solve this issue instead of ignoring 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@uniffle.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org
For additional commands, e-mail: issues-help@uniffle.apache.org
[GitHub] [incubator-uniffle] jerqi commented on pull request #947: [#854][FOLLOWUP] feat(tez): Add RssShuffleManager to run and manager shuffle work
Posted by "jerqi (via GitHub)" <gi...@apache.org>.
jerqi commented on PR #947:
URL: https://github.com/apache/incubator-uniffle/pull/947#issuecomment-1590314592
What‘s the difference between #947 and #948?
--
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@uniffle.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org
For additional commands, e-mail: issues-help@uniffle.apache.org
[GitHub] [incubator-uniffle] lifeSo commented on pull request #947: [#854][FOLLOWUP] feat(tez): Add RssShuffleManager to run and manager shuffle work
Posted by "lifeSo (via GitHub)" <gi...@apache.org>.
lifeSo commented on PR #947:
URL: https://github.com/apache/incubator-uniffle/pull/947#issuecomment-1594184805
Could i rewrite test case like below (add a isTest field) ?
the mock is not easy.

--
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@uniffle.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org
For additional commands, e-mail: issues-help@uniffle.apache.org
[GitHub] [incubator-uniffle] codecov-commenter commented on pull request #947: [#854][FOLLOWUP] feat(tez): Add RssShuffleManager to run and manager shuffle work
Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #947:
URL: https://github.com/apache/incubator-uniffle/pull/947#issuecomment-1588722035
## [Codecov](https://app.codecov.io/gh/apache/incubator-uniffle/pull/947?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
> Merging [#947](https://app.codecov.io/gh/apache/incubator-uniffle/pull/947?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) (e6d0aae) into [master](https://app.codecov.io/gh/apache/incubator-uniffle/commit/fb394e5ee8b40c8ee176eaf8fc2e000e072a247f?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) (fb394e5) will **increase** coverage by `1.70%`.
> The diff coverage is `n/a`.
> :exclamation: Current head e6d0aae differs from pull request most recent head 768a838. Consider uploading reports for the commit 768a838 to get more accurate results
```diff
@@ Coverage Diff @@
## master #947 +/- ##
============================================
+ Coverage 55.80% 57.50% +1.70%
+ Complexity 2364 2181 -183
============================================
Files 354 310 -44
Lines 18071 13897 -4174
Branches 1414 1280 -134
============================================
- Hits 10085 7992 -2093
+ Misses 7400 5473 -1927
+ Partials 586 432 -154
```
[see 46 files with indirect coverage changes](https://app.codecov.io/gh/apache/incubator-uniffle/pull/947/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@uniffle.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org
For additional commands, e-mail: issues-help@uniffle.apache.org
[GitHub] [incubator-uniffle] jerqi commented on a diff in pull request #947: [#854][FOLLOWUP] feat(tez): Add RssShuffleManager to run and manager shuffle work
Posted by "jerqi (via GitHub)" <gi...@apache.org>.
jerqi commented on code in PR #947:
URL: https://github.com/apache/incubator-uniffle/pull/947#discussion_r1236187318
##########
client-tez/src/main/java/org/apache/tez/runtime/library/common/shuffle/impl/RssShuffleManager.java:
##########
@@ -0,0 +1,1236 @@
+/**
+ * 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.tez.runtime.library.common.shuffle.impl;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.nio.ByteBuffer;
+import java.text.DecimalFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.BitSet;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.LinkedBlockingDeque;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.locks.Condition;
+import java.util.concurrent.locks.ReentrantLock;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Objects;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
+import com.google.common.util.concurrent.FutureCallback;
+import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.ListeningExecutorService;
+import com.google.common.util.concurrent.MoreExecutors;
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.LocalDirAllocator;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.fs.RawLocalFileSystem;
+import org.apache.hadoop.io.compress.CompressionCodec;
+import org.apache.hadoop.util.Time;
+import org.apache.tez.common.CallableWithNdc;
+import org.apache.tez.common.InputContextUtils;
+import org.apache.tez.common.TezRuntimeFrameworkConfigs;
+import org.apache.tez.common.TezUtilsInternal;
+import org.apache.tez.common.UmbilicalUtils;
+import org.apache.tez.common.counters.TaskCounter;
+import org.apache.tez.common.counters.TezCounter;
+import org.apache.tez.dag.api.TezConfiguration;
+import org.apache.tez.dag.api.TezUncheckedException;
+import org.apache.tez.dag.records.TezTaskAttemptID;
+import org.apache.tez.http.HttpConnectionParams;
+import org.apache.tez.runtime.api.Event;
+import org.apache.tez.runtime.api.InputContext;
+import org.apache.tez.runtime.api.TaskFailureType;
+import org.apache.tez.runtime.api.events.InputReadErrorEvent;
+import org.apache.tez.runtime.library.api.TezRuntimeConfiguration;
+import org.apache.tez.runtime.library.common.CompositeInputAttemptIdentifier;
+import org.apache.tez.runtime.library.common.InputAttemptIdentifier;
+import org.apache.tez.runtime.library.common.TezRuntimeUtils;
+import org.apache.tez.runtime.library.common.shuffle.FetchResult;
+import org.apache.tez.runtime.library.common.shuffle.FetchedInput;
+import org.apache.tez.runtime.library.common.shuffle.FetchedInputAllocator;
+import org.apache.tez.runtime.library.common.shuffle.Fetcher;
+import org.apache.tez.runtime.library.common.shuffle.Fetcher.FetcherBuilder;
+import org.apache.tez.runtime.library.common.shuffle.HostPort;
+import org.apache.tez.runtime.library.common.shuffle.InputHost;
+import org.apache.tez.runtime.library.common.shuffle.InputHost.PartitionToInputs;
+import org.apache.tez.runtime.library.common.shuffle.ShuffleUtils;
+import org.apache.tez.runtime.library.common.shuffle.ShuffleUtils.FetchStatsLogger;
+import org.roaringbitmap.longlong.Roaring64NavigableMap;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.uniffle.common.ShuffleServerInfo;
+
+// This only knows how to deal with a single srcIndex for a given targetIndex.
+// In case the src task generates multiple outputs for the same target Index
+// (multiple src-indices), modifications will be required.
+public class RssShuffleManager extends ShuffleManager {
+
+ private static final Logger LOG = LoggerFactory.getLogger(RssShuffleManager.class);
+ private static final Logger LOG_FETCH = LoggerFactory.getLogger(LOG.getName() + ".fetch");
+ private static final FetchStatsLogger fetchStatsLogger = new FetchStatsLogger(LOG_FETCH, LOG);
+
+ private final InputContext inputContext;
+ private final int numInputs;
+
+ private final DecimalFormat mbpsFormat = new DecimalFormat("0.00");
+
+ private final FetchedInputAllocator inputManager;
+
+ @VisibleForTesting
+ final ListeningExecutorService fetcherExecutor;
+
+ /**
+ * Executor for ReportCallable.
+ */
+ private ExecutorService reporterExecutor;
+
+ /**
+ * Lock to sync failedEvents.
+ */
+ private final ReentrantLock reportLock = new ReentrantLock();
+
+ /**
+ * Condition to wake up the thread notifying when events fail.
+ */
+ private final Condition reportCondition = reportLock.newCondition();
+
+ /**
+ * Events reporting fetcher failed.
+ */
+ private final HashMap<InputReadErrorEvent, Integer> failedEvents = new HashMap<>();
+
+ private final ListeningExecutorService schedulerExecutor;
+ private final RssRunShuffleCallable rssSchedulerCallable;
+
+ private final BlockingQueue<FetchedInput> completedInputs;
+ private final AtomicBoolean inputReadyNotificationSent = new AtomicBoolean(false);
+ @VisibleForTesting
+ final BitSet completedInputSet;
+ private final ConcurrentMap<HostPort, InputHost> knownSrcHosts;
+ private final BlockingQueue<InputHost> pendingHosts;
+ private final Set<InputAttemptIdentifier> obsoletedInputs;
+ private Set<RssTezFetcherTask> rssRunningFetchers;
+
+ private final AtomicInteger numCompletedInputs = new AtomicInteger(0);
+ private final AtomicInteger numFetchedSpills = new AtomicInteger(0);
+
+ private final long startTime;
+ private long lastProgressTime;
+ private long totalBytesShuffledTillNow;
+
+ // Required to be held when manipulating pendingHosts
+ private final ReentrantLock lock = new ReentrantLock();
+ private final Condition wakeLoop = lock.newCondition();
+
+ private final int numFetchers;
+ private final boolean asyncHttp;
+
+ // Parameters required by Fetchers
+ private final CompressionCodec codec;
+ private final Configuration conf;
+ private final boolean localDiskFetchEnabled;
+ private final boolean sharedFetchEnabled;
+ private final boolean verifyDiskChecksum;
+ private final boolean compositeFetch;
+
+ private final int ifileBufferSize;
+ private final boolean ifileReadAhead;
+ private final int ifileReadAheadLength;
+
+ /**
+ * Holds the time to wait for failures to batch them and send less events.
+ */
+ private final int maxTimeToWaitForReportMillis;
+
+ private final String srcNameTrimmed;
+
+ private final int maxTaskOutputAtOnce;
+
+ private final AtomicBoolean isShutdown = new AtomicBoolean(false);
+
+ private final TezCounter shuffledInputsCounter;
+ private final TezCounter failedShufflesCounter;
+ private final TezCounter bytesShuffledCounter;
+ private final TezCounter decompressedDataSizeCounter;
+ private final TezCounter bytesShuffledToDiskCounter;
+ private final TezCounter bytesShuffledToMemCounter;
+ private final TezCounter bytesShuffledDirectDiskCounter;
+
+ private volatile Throwable shuffleError;
+ private final HttpConnectionParams httpConnectionParams;
+
+ private final LocalDirAllocator localDirAllocator;
+ private final RawLocalFileSystem localFs;
+ private final Path[] localDisks;
+ private final String localhostName;
+ private final int shufflePort;
+
+ private final TezCounter shufflePhaseTime;
+ private final TezCounter firstEventReceived;
+ private final TezCounter lastEventReceived;
+
+ //To track shuffleInfo events when finalMerge is disabled OR pipelined shuffle is enabled in source.
+ @VisibleForTesting
+ final Map<Integer, ShuffleEventInfo> shuffleInfoEventsMap;
+
+ private Map<Integer, List<ShuffleServerInfo>> partitionToServers;
+ private final Set<Integer> successRssPartitionSet = new HashSet<>();
+ private final Set<Integer> runningRssPartitionMap = new HashSet<>();
+ private final Set<Integer> allRssPartition = Sets.newConcurrentHashSet();
+ private final BlockingQueue<Integer> pendingPartition = new LinkedBlockingQueue<>();
+ Map<Integer, List<InputAttemptIdentifier>> partitionToInput = new HashMap<>();
+ private final Map<Integer, Roaring64NavigableMap> rssAllBlockIdBitmapMap = new ConcurrentHashMap<>();
+ private final Map<Integer, Roaring64NavigableMap> rssSuccessBlockIdBitmapMap = new ConcurrentHashMap<>();
+ private final AtomicInteger numNoDataInput = new AtomicInteger(0);
+ private final AtomicInteger numWithDataInput = new AtomicInteger(0);
+
+ @SuppressFBWarnings("NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE")
+ public RssShuffleManager(InputContext inputContext, Configuration conf, int numInputs,
+ int bufferSize, boolean ifileReadAheadEnabled, int ifileReadAheadLength,
+ CompressionCodec codec, FetchedInputAllocator inputAllocator) throws IOException {
+ super(inputContext, conf, numInputs, bufferSize, ifileReadAheadEnabled, ifileReadAheadLength, codec,
+ inputAllocator);
+ this.inputContext = inputContext;
+ this.conf = conf;
+ this.numInputs = numInputs;
+
+ this.shuffledInputsCounter = inputContext.getCounters().findCounter(TaskCounter.NUM_SHUFFLED_INPUTS);
+ this.failedShufflesCounter = inputContext.getCounters().findCounter(TaskCounter.NUM_FAILED_SHUFFLE_INPUTS);
+ this.bytesShuffledCounter = inputContext.getCounters().findCounter(TaskCounter.SHUFFLE_BYTES);
+ this.decompressedDataSizeCounter = inputContext.getCounters().findCounter(TaskCounter.SHUFFLE_BYTES_DECOMPRESSED);
+ this.bytesShuffledToDiskCounter = inputContext.getCounters().findCounter(TaskCounter.SHUFFLE_BYTES_TO_DISK);
+ this.bytesShuffledToMemCounter = inputContext.getCounters().findCounter(TaskCounter.SHUFFLE_BYTES_TO_MEM);
+ this.bytesShuffledDirectDiskCounter = inputContext.getCounters().findCounter(TaskCounter.SHUFFLE_BYTES_DISK_DIRECT);
+
+ this.ifileBufferSize = bufferSize;
+ this.ifileReadAhead = ifileReadAheadEnabled;
+ this.ifileReadAheadLength = ifileReadAheadLength;
+ this.codec = codec;
+ this.inputManager = inputAllocator;
+ this.localDiskFetchEnabled = conf.getBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_OPTIMIZE_LOCAL_FETCH,
+ TezRuntimeConfiguration.TEZ_RUNTIME_OPTIMIZE_LOCAL_FETCH_DEFAULT);
+ this.sharedFetchEnabled = conf.getBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_OPTIMIZE_SHARED_FETCH,
+ TezRuntimeConfiguration.TEZ_RUNTIME_OPTIMIZE_SHARED_FETCH_DEFAULT);
+ this.verifyDiskChecksum = conf.getBoolean(
+ TezRuntimeConfiguration.TEZ_RUNTIME_SHUFFLE_FETCH_VERIFY_DISK_CHECKSUM,
+ TezRuntimeConfiguration.TEZ_RUNTIME_SHUFFLE_FETCH_VERIFY_DISK_CHECKSUM_DEFAULT);
+ this.maxTimeToWaitForReportMillis = 1;
+
+ this.shufflePhaseTime = inputContext.getCounters().findCounter(TaskCounter.SHUFFLE_PHASE_TIME);
+ this.firstEventReceived = inputContext.getCounters().findCounter(TaskCounter.FIRST_EVENT_RECEIVED);
+ this.lastEventReceived = inputContext.getCounters().findCounter(TaskCounter.LAST_EVENT_RECEIVED);
+ this.compositeFetch = ShuffleUtils.isTezShuffleHandler(conf);
+
+ this.srcNameTrimmed = TezUtilsInternal.cleanVertexName(inputContext.getSourceVertexName());
+
+ completedInputSet = new BitSet(numInputs);
+ /**
+ * In case of pipelined shuffle, it is possible to get multiple FetchedInput per attempt.
+ * We do not know upfront the number of spills from source.
+ */
+ completedInputs = new LinkedBlockingDeque<>();
+ knownSrcHosts = new ConcurrentHashMap<>();
+ pendingHosts = new LinkedBlockingQueue<>();
+ obsoletedInputs = Collections.newSetFromMap(new ConcurrentHashMap<>());
+ rssRunningFetchers = Collections.newSetFromMap(new ConcurrentHashMap<>());
+
+ int maxConfiguredFetchers =
+ conf.getInt(
+ TezRuntimeConfiguration.TEZ_RUNTIME_SHUFFLE_PARALLEL_COPIES,
+ TezRuntimeConfiguration.TEZ_RUNTIME_SHUFFLE_PARALLEL_COPIES_DEFAULT);
+
+ this.numFetchers = Math.min(maxConfiguredFetchers, numInputs);
+
+ final ExecutorService fetcherRawExecutor;
+ if (conf.getBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_SHUFFLE_FETCHER_USE_SHARED_POOL,
+ TezRuntimeConfiguration.TEZ_RUNTIME_SHUFFLE_FETCHER_USE_SHARED_POOL_DEFAULT)) {
+ fetcherRawExecutor = inputContext.createTezFrameworkExecutorService(numFetchers,
+ "Fetcher_B {" + srcNameTrimmed + "} #%d");
+ } else {
+ fetcherRawExecutor = Executors.newFixedThreadPool(numFetchers, new ThreadFactoryBuilder()
+ .setDaemon(true).setNameFormat("Fetcher_B {" + srcNameTrimmed + "} #%d").build());
+ }
+ this.fetcherExecutor = MoreExecutors.listeningDecorator(fetcherRawExecutor);
+
+ ExecutorService schedulerRawExecutor = Executors.newFixedThreadPool(1, new ThreadFactoryBuilder()
+ .setDaemon(true).setNameFormat("ShuffleRunner {" + srcNameTrimmed + "}").build());
+ this.schedulerExecutor = MoreExecutors.listeningDecorator(schedulerRawExecutor);
+ this.rssSchedulerCallable = new RssRunShuffleCallable(conf);
+
+ this.startTime = System.currentTimeMillis();
+ this.lastProgressTime = startTime;
+
+ this.asyncHttp = conf.getBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_SHUFFLE_USE_ASYNC_HTTP, false);
+ httpConnectionParams = ShuffleUtils.getHttpConnectionParams(conf);
+
+ this.localFs = (RawLocalFileSystem) FileSystem.getLocal(conf).getRaw();
+
+ this.localDirAllocator = new LocalDirAllocator(
+ TezRuntimeFrameworkConfigs.LOCAL_DIRS);
+
+ this.localDisks = Iterables.toArray(
+ localDirAllocator.getAllLocalPathsToRead(".", conf), Path.class);
+ this.localhostName = inputContext.getExecutionContext().getHostName();
+
+ String auxiliaryService = conf.get(TezConfiguration.TEZ_AM_SHUFFLE_AUXILIARY_SERVICE_ID,
+ TezConfiguration.TEZ_AM_SHUFFLE_AUXILIARY_SERVICE_ID_DEFAULT);
+ final ByteBuffer shuffleMetaData =
+ inputContext.getServiceProviderMetaData(auxiliaryService);
+ this.shufflePort = ShuffleUtils.deserializeShuffleProviderMetaData(shuffleMetaData);
+
+ /**
+ * Setting to very high val can lead to Http 400 error. Cap it to 75; every attempt id would
+ * be approximately 48 bytes; 48 * 75 = 3600 which should give some room for other info in URL.
+ */
+ this.maxTaskOutputAtOnce = Math.max(1, Math.min(75, conf.getInt(
+ TezRuntimeConfiguration.TEZ_RUNTIME_SHUFFLE_FETCH_MAX_TASK_OUTPUT_AT_ONCE,
+ TezRuntimeConfiguration.TEZ_RUNTIME_SHUFFLE_FETCH_MAX_TASK_OUTPUT_AT_ONCE_DEFAULT)));
+
+ Arrays.sort(this.localDisks);
+
+ shuffleInfoEventsMap = new ConcurrentHashMap<>();
+
+ LOG.info(srcNameTrimmed + ": numInputs=" + numInputs + ", compressionCodec="
+ + (codec == null ? "NoCompressionCodec" : codec.getClass().getName()) + ", numFetchers="
+ + numFetchers + ", ifileBufferSize=" + ifileBufferSize + ", ifileReadAheadEnabled="
+ + ifileReadAhead + ", ifileReadAheadLength=" + ifileReadAheadLength + ", "
+ + "localDiskFetchEnabled=" + localDiskFetchEnabled + ", "
+ + "sharedFetchEnabled=" + sharedFetchEnabled + ", "
+ + httpConnectionParams.toString() + ", maxTaskOutputAtOnce=" + maxTaskOutputAtOnce);
+ }
+
+ @Override
+ public void run() throws IOException {
+ int shuffleId = InputContextUtils.computeShuffleId(this.inputContext);
+ TezTaskAttemptID tezTaskAttemptId = InputContextUtils.getTezTaskAttemptID(this.inputContext);
+ this.partitionToServers = UmbilicalUtils.requestShuffleServer(
+ this.inputContext.getApplicationId(), this.conf, tezTaskAttemptId, shuffleId);
+
+
+ Preconditions.checkState(inputManager != null, "InputManager must be configured");
+ if (maxTimeToWaitForReportMillis > 0) {
+ reporterExecutor = Executors.newSingleThreadExecutor(
+ new ThreadFactoryBuilder().setDaemon(true)
+ .setNameFormat("ShuffleRunner {" + srcNameTrimmed + "}")
+ .build());
+ Future reporterFuture = reporterExecutor.submit(new ReporterCallable());
+ }
+
+ ListenableFuture<Void> runShuffleFuture = schedulerExecutor.submit(rssSchedulerCallable);
+ Futures.addCallback(runShuffleFuture, new SchedulerFutureCallback(), MoreExecutors.directExecutor());
+ // Shutdown this executor once this task, and the callback complete.
+ schedulerExecutor.shutdown();
+ }
+
+ private class ReporterCallable extends CallableWithNdc<Void> {
+ /**
+ * Measures if the batching interval has ended.
+ */
+
+ ReporterCallable() {
+ }
+
+ @Override
+ protected Void callInternal() throws Exception {
+ long nextReport = 0;
+ while (!isShutdown.get()) {
+ try {
+ reportLock.lock();
+ while (failedEvents.isEmpty()) {
+ boolean signaled = reportCondition.await(maxTimeToWaitForReportMillis,
+ TimeUnit.MILLISECONDS);
+ }
+
+ long currentTime = Time.monotonicNow();;
+ if (currentTime > nextReport) {
+ if (failedEvents.size() > 0) {
+ List<Event> failedEventsToSend = Lists.newArrayListWithCapacity(
+ failedEvents.size());
+ for (InputReadErrorEvent key : failedEvents.keySet()) {
+ failedEventsToSend.add(InputReadErrorEvent
+ .create(key.getDiagnostics(), key.getIndex(),
+ key.getVersion()));
+ }
+ inputContext.sendEvents(failedEventsToSend);
+ failedEvents.clear();
+ nextReport = currentTime + maxTimeToWaitForReportMillis;
+ }
+ }
+ } finally {
+ reportLock.unlock();
+ }
+ }
+ return null;
+ }
+ }
+
+
+ private boolean isAllInputFetched() {
+ LOG.info("Check isAllInputFetched, numNoDataInput:{}, numWithDataInput:{},numInputs:{}, "
+ + "successRssPartitionSet:{}, allRssPartition:{}.",
+ numNoDataInput, numWithDataInput, numInputs, successRssPartitionSet, allRssPartition);
+ return (numNoDataInput.get() + numWithDataInput.get() >= numInputs)
+ && (successRssPartitionSet.size() >= allRssPartition.size());
+ }
+
+ private boolean isAllInputAdded() {
+ LOG.info("Check isAllInputAdded, numNoDataInput:{}, numWithDataInput:{},numInputs:{}, "
+ + "successRssPartitionSet:{}, allRssPartition:{}.",
+ numNoDataInput, numWithDataInput, numInputs, successRssPartitionSet, allRssPartition);
+ return numNoDataInput.get() + numWithDataInput.get() >= numInputs;
+ }
+
+ private class RssRunShuffleCallable extends CallableWithNdc<Void> {
+
+ private final Configuration conf;
+
+ RssRunShuffleCallable(Configuration conf) {
+ this.conf = conf;
+ }
+
+ @SuppressWarnings("RV_RETURN_VALUE_IGNORED_BAD_PRACTICE")
Review Comment:
Could we solve this issue instead of ignoring 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@uniffle.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org
For additional commands, e-mail: issues-help@uniffle.apache.org
[GitHub] [incubator-uniffle] lifeSo commented on a diff in pull request #947: [#854][FOLLOWUP] feat(tez): Add RssShuffleManager to run and manager shuffle work
Posted by "lifeSo (via GitHub)" <gi...@apache.org>.
lifeSo commented on code in PR #947:
URL: https://github.com/apache/incubator-uniffle/pull/947#discussion_r1236504611
##########
client-tez/src/main/java/org/apache/tez/runtime/library/common/shuffle/impl/RssShuffleManager.java:
##########
@@ -0,0 +1,1236 @@
+/**
+ * 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.tez.runtime.library.common.shuffle.impl;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.nio.ByteBuffer;
+import java.text.DecimalFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.BitSet;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.LinkedBlockingDeque;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.locks.Condition;
+import java.util.concurrent.locks.ReentrantLock;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Objects;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
+import com.google.common.util.concurrent.FutureCallback;
+import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.ListeningExecutorService;
+import com.google.common.util.concurrent.MoreExecutors;
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.LocalDirAllocator;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.fs.RawLocalFileSystem;
+import org.apache.hadoop.io.compress.CompressionCodec;
+import org.apache.hadoop.util.Time;
+import org.apache.tez.common.CallableWithNdc;
+import org.apache.tez.common.InputContextUtils;
+import org.apache.tez.common.TezRuntimeFrameworkConfigs;
+import org.apache.tez.common.TezUtilsInternal;
+import org.apache.tez.common.UmbilicalUtils;
+import org.apache.tez.common.counters.TaskCounter;
+import org.apache.tez.common.counters.TezCounter;
+import org.apache.tez.dag.api.TezConfiguration;
+import org.apache.tez.dag.api.TezUncheckedException;
+import org.apache.tez.dag.records.TezTaskAttemptID;
+import org.apache.tez.http.HttpConnectionParams;
+import org.apache.tez.runtime.api.Event;
+import org.apache.tez.runtime.api.InputContext;
+import org.apache.tez.runtime.api.TaskFailureType;
+import org.apache.tez.runtime.api.events.InputReadErrorEvent;
+import org.apache.tez.runtime.library.api.TezRuntimeConfiguration;
+import org.apache.tez.runtime.library.common.CompositeInputAttemptIdentifier;
+import org.apache.tez.runtime.library.common.InputAttemptIdentifier;
+import org.apache.tez.runtime.library.common.TezRuntimeUtils;
+import org.apache.tez.runtime.library.common.shuffle.FetchResult;
+import org.apache.tez.runtime.library.common.shuffle.FetchedInput;
+import org.apache.tez.runtime.library.common.shuffle.FetchedInputAllocator;
+import org.apache.tez.runtime.library.common.shuffle.Fetcher;
+import org.apache.tez.runtime.library.common.shuffle.Fetcher.FetcherBuilder;
+import org.apache.tez.runtime.library.common.shuffle.HostPort;
+import org.apache.tez.runtime.library.common.shuffle.InputHost;
+import org.apache.tez.runtime.library.common.shuffle.InputHost.PartitionToInputs;
+import org.apache.tez.runtime.library.common.shuffle.ShuffleUtils;
+import org.apache.tez.runtime.library.common.shuffle.ShuffleUtils.FetchStatsLogger;
+import org.roaringbitmap.longlong.Roaring64NavigableMap;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.uniffle.common.ShuffleServerInfo;
+
+// This only knows how to deal with a single srcIndex for a given targetIndex.
+// In case the src task generates multiple outputs for the same target Index
+// (multiple src-indices), modifications will be required.
+public class RssShuffleManager extends ShuffleManager {
+
+ private static final Logger LOG = LoggerFactory.getLogger(RssShuffleManager.class);
+ private static final Logger LOG_FETCH = LoggerFactory.getLogger(LOG.getName() + ".fetch");
+ private static final FetchStatsLogger fetchStatsLogger = new FetchStatsLogger(LOG_FETCH, LOG);
+
+ private final InputContext inputContext;
+ private final int numInputs;
+
+ private final DecimalFormat mbpsFormat = new DecimalFormat("0.00");
+
+ private final FetchedInputAllocator inputManager;
+
+ @VisibleForTesting
+ final ListeningExecutorService fetcherExecutor;
+
+ /**
+ * Executor for ReportCallable.
+ */
+ private ExecutorService reporterExecutor;
+
+ /**
+ * Lock to sync failedEvents.
+ */
+ private final ReentrantLock reportLock = new ReentrantLock();
+
+ /**
+ * Condition to wake up the thread notifying when events fail.
+ */
+ private final Condition reportCondition = reportLock.newCondition();
+
+ /**
+ * Events reporting fetcher failed.
+ */
+ private final HashMap<InputReadErrorEvent, Integer> failedEvents = new HashMap<>();
+
+ private final ListeningExecutorService schedulerExecutor;
+ private final RssRunShuffleCallable rssSchedulerCallable;
+
+ private final BlockingQueue<FetchedInput> completedInputs;
+ private final AtomicBoolean inputReadyNotificationSent = new AtomicBoolean(false);
+ @VisibleForTesting
+ final BitSet completedInputSet;
+ private final ConcurrentMap<HostPort, InputHost> knownSrcHosts;
+ private final BlockingQueue<InputHost> pendingHosts;
+ private final Set<InputAttemptIdentifier> obsoletedInputs;
+ private Set<RssTezFetcherTask> rssRunningFetchers;
+
+ private final AtomicInteger numCompletedInputs = new AtomicInteger(0);
+ private final AtomicInteger numFetchedSpills = new AtomicInteger(0);
+
+ private final long startTime;
+ private long lastProgressTime;
+ private long totalBytesShuffledTillNow;
+
+ // Required to be held when manipulating pendingHosts
+ private final ReentrantLock lock = new ReentrantLock();
+ private final Condition wakeLoop = lock.newCondition();
+
+ private final int numFetchers;
+ private final boolean asyncHttp;
+
+ // Parameters required by Fetchers
+ private final CompressionCodec codec;
+ private final Configuration conf;
+ private final boolean localDiskFetchEnabled;
+ private final boolean sharedFetchEnabled;
+ private final boolean verifyDiskChecksum;
+ private final boolean compositeFetch;
+
+ private final int ifileBufferSize;
+ private final boolean ifileReadAhead;
+ private final int ifileReadAheadLength;
+
+ /**
+ * Holds the time to wait for failures to batch them and send less events.
+ */
+ private final int maxTimeToWaitForReportMillis;
+
+ private final String srcNameTrimmed;
+
+ private final int maxTaskOutputAtOnce;
+
+ private final AtomicBoolean isShutdown = new AtomicBoolean(false);
+
+ private final TezCounter shuffledInputsCounter;
+ private final TezCounter failedShufflesCounter;
+ private final TezCounter bytesShuffledCounter;
+ private final TezCounter decompressedDataSizeCounter;
+ private final TezCounter bytesShuffledToDiskCounter;
+ private final TezCounter bytesShuffledToMemCounter;
+ private final TezCounter bytesShuffledDirectDiskCounter;
+
+ private volatile Throwable shuffleError;
+ private final HttpConnectionParams httpConnectionParams;
+
+ private final LocalDirAllocator localDirAllocator;
+ private final RawLocalFileSystem localFs;
+ private final Path[] localDisks;
+ private final String localhostName;
+ private final int shufflePort;
+
+ private final TezCounter shufflePhaseTime;
+ private final TezCounter firstEventReceived;
+ private final TezCounter lastEventReceived;
+
+ //To track shuffleInfo events when finalMerge is disabled OR pipelined shuffle is enabled in source.
+ @VisibleForTesting
+ final Map<Integer, ShuffleEventInfo> shuffleInfoEventsMap;
+
+ private Map<Integer, List<ShuffleServerInfo>> partitionToServers;
+ private final Set<Integer> successRssPartitionSet = new HashSet<>();
+ private final Set<Integer> runningRssPartitionMap = new HashSet<>();
+ private final Set<Integer> allRssPartition = Sets.newConcurrentHashSet();
+ private final BlockingQueue<Integer> pendingPartition = new LinkedBlockingQueue<>();
+ Map<Integer, List<InputAttemptIdentifier>> partitionToInput = new HashMap<>();
+ private final Map<Integer, Roaring64NavigableMap> rssAllBlockIdBitmapMap = new ConcurrentHashMap<>();
+ private final Map<Integer, Roaring64NavigableMap> rssSuccessBlockIdBitmapMap = new ConcurrentHashMap<>();
+ private final AtomicInteger numNoDataInput = new AtomicInteger(0);
+ private final AtomicInteger numWithDataInput = new AtomicInteger(0);
+
+ @SuppressFBWarnings("NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE")
Review Comment:
> Could we solve this issue instead of ignoring it?
May I say could not ? 😭
--
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@uniffle.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org
For additional commands, e-mail: issues-help@uniffle.apache.org
[GitHub] [incubator-uniffle] lifeSo commented on pull request #947: [#854][FOLLOWUP] feat(tez): Add RssShuffleManager to run and manager shuffle work
Posted by "lifeSo (via GitHub)" <gi...@apache.org>.
lifeSo commented on PR #947:
URL: https://github.com/apache/incubator-uniffle/pull/947#issuecomment-1590398375
> What‘s the difference between #947 and #948?
the logic and implements are little different:
https://github.com/apache/tez/blob/master/tez-runtime-library/src/main/java/org/apache/tez/runtime/library/common/shuffle/impl/ShuffleManager.java
https://github.com/apache/tez/blob/master/tez-runtime-library/src/main/java/org/apache/tez/runtime/library/common/shuffle/orderedgrouped/ShuffleScheduler.java
--
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@uniffle.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org
For additional commands, e-mail: issues-help@uniffle.apache.org
[GitHub] [incubator-uniffle] jerqi commented on pull request #947: [#854][FOLLOWUP] feat(tez): Add RssShuffleManager to run and manager shuffle work
Posted by "jerqi (via GitHub)" <gi...@apache.org>.
jerqi commented on PR #947:
URL: https://github.com/apache/incubator-uniffle/pull/947#issuecomment-1590428775
> > What‘s the difference between #947 and #948?
>
> the logic and implements are little different:
>
> https://github.com/apache/tez/blob/master/tez-runtime-library/src/main/java/org/apache/tez/runtime/library/common/shuffle/impl/ShuffleManager.java
>
> https://github.com/apache/tez/blob/master/tez-runtime-library/src/main/java/org/apache/tez/runtime/library/common/shuffle/orderedgrouped/ShuffleScheduler.java
Could we modify the title? I can't get the difference from title. Could they reuse some common modules?
--
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@uniffle.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org
For additional commands, e-mail: issues-help@uniffle.apache.org
[GitHub] [incubator-uniffle] lifeSo commented on a diff in pull request #947: [#854][FOLLOWUP] feat(tez): Add RssShuffleManager to run and manager shuffle work
Posted by "lifeSo (via GitHub)" <gi...@apache.org>.
lifeSo commented on code in PR #947:
URL: https://github.com/apache/incubator-uniffle/pull/947#discussion_r1236255062
##########
client-tez/src/main/java/org/apache/tez/runtime/library/common/shuffle/impl/RssShuffleManager.java:
##########
@@ -0,0 +1,1236 @@
+/**
+ * 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.tez.runtime.library.common.shuffle.impl;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.nio.ByteBuffer;
+import java.text.DecimalFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.BitSet;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.LinkedBlockingDeque;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.locks.Condition;
+import java.util.concurrent.locks.ReentrantLock;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Objects;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
+import com.google.common.util.concurrent.FutureCallback;
+import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.ListeningExecutorService;
+import com.google.common.util.concurrent.MoreExecutors;
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.LocalDirAllocator;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.fs.RawLocalFileSystem;
+import org.apache.hadoop.io.compress.CompressionCodec;
+import org.apache.hadoop.util.Time;
+import org.apache.tez.common.CallableWithNdc;
+import org.apache.tez.common.InputContextUtils;
+import org.apache.tez.common.TezRuntimeFrameworkConfigs;
+import org.apache.tez.common.TezUtilsInternal;
+import org.apache.tez.common.UmbilicalUtils;
+import org.apache.tez.common.counters.TaskCounter;
+import org.apache.tez.common.counters.TezCounter;
+import org.apache.tez.dag.api.TezConfiguration;
+import org.apache.tez.dag.api.TezUncheckedException;
+import org.apache.tez.dag.records.TezTaskAttemptID;
+import org.apache.tez.http.HttpConnectionParams;
+import org.apache.tez.runtime.api.Event;
+import org.apache.tez.runtime.api.InputContext;
+import org.apache.tez.runtime.api.TaskFailureType;
+import org.apache.tez.runtime.api.events.InputReadErrorEvent;
+import org.apache.tez.runtime.library.api.TezRuntimeConfiguration;
+import org.apache.tez.runtime.library.common.CompositeInputAttemptIdentifier;
+import org.apache.tez.runtime.library.common.InputAttemptIdentifier;
+import org.apache.tez.runtime.library.common.TezRuntimeUtils;
+import org.apache.tez.runtime.library.common.shuffle.FetchResult;
+import org.apache.tez.runtime.library.common.shuffle.FetchedInput;
+import org.apache.tez.runtime.library.common.shuffle.FetchedInputAllocator;
+import org.apache.tez.runtime.library.common.shuffle.Fetcher;
+import org.apache.tez.runtime.library.common.shuffle.Fetcher.FetcherBuilder;
+import org.apache.tez.runtime.library.common.shuffle.HostPort;
+import org.apache.tez.runtime.library.common.shuffle.InputHost;
+import org.apache.tez.runtime.library.common.shuffle.InputHost.PartitionToInputs;
+import org.apache.tez.runtime.library.common.shuffle.ShuffleUtils;
+import org.apache.tez.runtime.library.common.shuffle.ShuffleUtils.FetchStatsLogger;
+import org.roaringbitmap.longlong.Roaring64NavigableMap;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.uniffle.common.ShuffleServerInfo;
+
+// This only knows how to deal with a single srcIndex for a given targetIndex.
+// In case the src task generates multiple outputs for the same target Index
+// (multiple src-indices), modifications will be required.
+public class RssShuffleManager extends ShuffleManager {
+
+ private static final Logger LOG = LoggerFactory.getLogger(RssShuffleManager.class);
+ private static final Logger LOG_FETCH = LoggerFactory.getLogger(LOG.getName() + ".fetch");
+ private static final FetchStatsLogger fetchStatsLogger = new FetchStatsLogger(LOG_FETCH, LOG);
+
+ private final InputContext inputContext;
+ private final int numInputs;
+
+ private final DecimalFormat mbpsFormat = new DecimalFormat("0.00");
+
+ private final FetchedInputAllocator inputManager;
+
+ @VisibleForTesting
+ final ListeningExecutorService fetcherExecutor;
+
+ /**
+ * Executor for ReportCallable.
+ */
+ private ExecutorService reporterExecutor;
+
+ /**
+ * Lock to sync failedEvents.
+ */
+ private final ReentrantLock reportLock = new ReentrantLock();
+
+ /**
+ * Condition to wake up the thread notifying when events fail.
+ */
+ private final Condition reportCondition = reportLock.newCondition();
+
+ /**
+ * Events reporting fetcher failed.
+ */
+ private final HashMap<InputReadErrorEvent, Integer> failedEvents = new HashMap<>();
+
+ private final ListeningExecutorService schedulerExecutor;
+ private final RssRunShuffleCallable rssSchedulerCallable;
+
+ private final BlockingQueue<FetchedInput> completedInputs;
+ private final AtomicBoolean inputReadyNotificationSent = new AtomicBoolean(false);
+ @VisibleForTesting
+ final BitSet completedInputSet;
+ private final ConcurrentMap<HostPort, InputHost> knownSrcHosts;
+ private final BlockingQueue<InputHost> pendingHosts;
+ private final Set<InputAttemptIdentifier> obsoletedInputs;
+ private Set<RssTezFetcherTask> rssRunningFetchers;
+
+ private final AtomicInteger numCompletedInputs = new AtomicInteger(0);
+ private final AtomicInteger numFetchedSpills = new AtomicInteger(0);
+
+ private final long startTime;
+ private long lastProgressTime;
+ private long totalBytesShuffledTillNow;
+
+ // Required to be held when manipulating pendingHosts
+ private final ReentrantLock lock = new ReentrantLock();
+ private final Condition wakeLoop = lock.newCondition();
+
+ private final int numFetchers;
+ private final boolean asyncHttp;
+
+ // Parameters required by Fetchers
+ private final CompressionCodec codec;
+ private final Configuration conf;
+ private final boolean localDiskFetchEnabled;
+ private final boolean sharedFetchEnabled;
+ private final boolean verifyDiskChecksum;
+ private final boolean compositeFetch;
+
+ private final int ifileBufferSize;
+ private final boolean ifileReadAhead;
+ private final int ifileReadAheadLength;
+
+ /**
+ * Holds the time to wait for failures to batch them and send less events.
+ */
+ private final int maxTimeToWaitForReportMillis;
+
+ private final String srcNameTrimmed;
+
+ private final int maxTaskOutputAtOnce;
+
+ private final AtomicBoolean isShutdown = new AtomicBoolean(false);
+
+ private final TezCounter shuffledInputsCounter;
+ private final TezCounter failedShufflesCounter;
+ private final TezCounter bytesShuffledCounter;
+ private final TezCounter decompressedDataSizeCounter;
+ private final TezCounter bytesShuffledToDiskCounter;
+ private final TezCounter bytesShuffledToMemCounter;
+ private final TezCounter bytesShuffledDirectDiskCounter;
+
+ private volatile Throwable shuffleError;
+ private final HttpConnectionParams httpConnectionParams;
+
+ private final LocalDirAllocator localDirAllocator;
+ private final RawLocalFileSystem localFs;
+ private final Path[] localDisks;
+ private final String localhostName;
+ private final int shufflePort;
+
+ private final TezCounter shufflePhaseTime;
+ private final TezCounter firstEventReceived;
+ private final TezCounter lastEventReceived;
+
+ //To track shuffleInfo events when finalMerge is disabled OR pipelined shuffle is enabled in source.
+ @VisibleForTesting
+ final Map<Integer, ShuffleEventInfo> shuffleInfoEventsMap;
+
+ private Map<Integer, List<ShuffleServerInfo>> partitionToServers;
+ private final Set<Integer> successRssPartitionSet = new HashSet<>();
+ private final Set<Integer> runningRssPartitionMap = new HashSet<>();
+ private final Set<Integer> allRssPartition = Sets.newConcurrentHashSet();
+ private final BlockingQueue<Integer> pendingPartition = new LinkedBlockingQueue<>();
+ Map<Integer, List<InputAttemptIdentifier>> partitionToInput = new HashMap<>();
+ private final Map<Integer, Roaring64NavigableMap> rssAllBlockIdBitmapMap = new ConcurrentHashMap<>();
+ private final Map<Integer, Roaring64NavigableMap> rssSuccessBlockIdBitmapMap = new ConcurrentHashMap<>();
+ private final AtomicInteger numNoDataInput = new AtomicInteger(0);
+ private final AtomicInteger numWithDataInput = new AtomicInteger(0);
+
+ @SuppressFBWarnings("NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE")
+ public RssShuffleManager(InputContext inputContext, Configuration conf, int numInputs,
+ int bufferSize, boolean ifileReadAheadEnabled, int ifileReadAheadLength,
+ CompressionCodec codec, FetchedInputAllocator inputAllocator) throws IOException {
+ super(inputContext, conf, numInputs, bufferSize, ifileReadAheadEnabled, ifileReadAheadLength, codec,
+ inputAllocator);
+ this.inputContext = inputContext;
+ this.conf = conf;
+ this.numInputs = numInputs;
+
+ this.shuffledInputsCounter = inputContext.getCounters().findCounter(TaskCounter.NUM_SHUFFLED_INPUTS);
+ this.failedShufflesCounter = inputContext.getCounters().findCounter(TaskCounter.NUM_FAILED_SHUFFLE_INPUTS);
+ this.bytesShuffledCounter = inputContext.getCounters().findCounter(TaskCounter.SHUFFLE_BYTES);
+ this.decompressedDataSizeCounter = inputContext.getCounters().findCounter(TaskCounter.SHUFFLE_BYTES_DECOMPRESSED);
+ this.bytesShuffledToDiskCounter = inputContext.getCounters().findCounter(TaskCounter.SHUFFLE_BYTES_TO_DISK);
+ this.bytesShuffledToMemCounter = inputContext.getCounters().findCounter(TaskCounter.SHUFFLE_BYTES_TO_MEM);
+ this.bytesShuffledDirectDiskCounter = inputContext.getCounters().findCounter(TaskCounter.SHUFFLE_BYTES_DISK_DIRECT);
+
+ this.ifileBufferSize = bufferSize;
+ this.ifileReadAhead = ifileReadAheadEnabled;
+ this.ifileReadAheadLength = ifileReadAheadLength;
+ this.codec = codec;
+ this.inputManager = inputAllocator;
+ this.localDiskFetchEnabled = conf.getBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_OPTIMIZE_LOCAL_FETCH,
+ TezRuntimeConfiguration.TEZ_RUNTIME_OPTIMIZE_LOCAL_FETCH_DEFAULT);
+ this.sharedFetchEnabled = conf.getBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_OPTIMIZE_SHARED_FETCH,
+ TezRuntimeConfiguration.TEZ_RUNTIME_OPTIMIZE_SHARED_FETCH_DEFAULT);
+ this.verifyDiskChecksum = conf.getBoolean(
+ TezRuntimeConfiguration.TEZ_RUNTIME_SHUFFLE_FETCH_VERIFY_DISK_CHECKSUM,
+ TezRuntimeConfiguration.TEZ_RUNTIME_SHUFFLE_FETCH_VERIFY_DISK_CHECKSUM_DEFAULT);
+ this.maxTimeToWaitForReportMillis = 1;
+
+ this.shufflePhaseTime = inputContext.getCounters().findCounter(TaskCounter.SHUFFLE_PHASE_TIME);
+ this.firstEventReceived = inputContext.getCounters().findCounter(TaskCounter.FIRST_EVENT_RECEIVED);
+ this.lastEventReceived = inputContext.getCounters().findCounter(TaskCounter.LAST_EVENT_RECEIVED);
+ this.compositeFetch = ShuffleUtils.isTezShuffleHandler(conf);
+
+ this.srcNameTrimmed = TezUtilsInternal.cleanVertexName(inputContext.getSourceVertexName());
+
+ completedInputSet = new BitSet(numInputs);
+ /**
+ * In case of pipelined shuffle, it is possible to get multiple FetchedInput per attempt.
+ * We do not know upfront the number of spills from source.
+ */
+ completedInputs = new LinkedBlockingDeque<>();
+ knownSrcHosts = new ConcurrentHashMap<>();
+ pendingHosts = new LinkedBlockingQueue<>();
+ obsoletedInputs = Collections.newSetFromMap(new ConcurrentHashMap<>());
+ rssRunningFetchers = Collections.newSetFromMap(new ConcurrentHashMap<>());
+
+ int maxConfiguredFetchers =
+ conf.getInt(
+ TezRuntimeConfiguration.TEZ_RUNTIME_SHUFFLE_PARALLEL_COPIES,
+ TezRuntimeConfiguration.TEZ_RUNTIME_SHUFFLE_PARALLEL_COPIES_DEFAULT);
+
+ this.numFetchers = Math.min(maxConfiguredFetchers, numInputs);
+
+ final ExecutorService fetcherRawExecutor;
+ if (conf.getBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_SHUFFLE_FETCHER_USE_SHARED_POOL,
+ TezRuntimeConfiguration.TEZ_RUNTIME_SHUFFLE_FETCHER_USE_SHARED_POOL_DEFAULT)) {
+ fetcherRawExecutor = inputContext.createTezFrameworkExecutorService(numFetchers,
+ "Fetcher_B {" + srcNameTrimmed + "} #%d");
+ } else {
+ fetcherRawExecutor = Executors.newFixedThreadPool(numFetchers, new ThreadFactoryBuilder()
+ .setDaemon(true).setNameFormat("Fetcher_B {" + srcNameTrimmed + "} #%d").build());
+ }
+ this.fetcherExecutor = MoreExecutors.listeningDecorator(fetcherRawExecutor);
+
+ ExecutorService schedulerRawExecutor = Executors.newFixedThreadPool(1, new ThreadFactoryBuilder()
+ .setDaemon(true).setNameFormat("ShuffleRunner {" + srcNameTrimmed + "}").build());
+ this.schedulerExecutor = MoreExecutors.listeningDecorator(schedulerRawExecutor);
+ this.rssSchedulerCallable = new RssRunShuffleCallable(conf);
+
+ this.startTime = System.currentTimeMillis();
+ this.lastProgressTime = startTime;
+
+ this.asyncHttp = conf.getBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_SHUFFLE_USE_ASYNC_HTTP, false);
+ httpConnectionParams = ShuffleUtils.getHttpConnectionParams(conf);
+
+ this.localFs = (RawLocalFileSystem) FileSystem.getLocal(conf).getRaw();
+
+ this.localDirAllocator = new LocalDirAllocator(
+ TezRuntimeFrameworkConfigs.LOCAL_DIRS);
+
+ this.localDisks = Iterables.toArray(
+ localDirAllocator.getAllLocalPathsToRead(".", conf), Path.class);
+ this.localhostName = inputContext.getExecutionContext().getHostName();
+
+ String auxiliaryService = conf.get(TezConfiguration.TEZ_AM_SHUFFLE_AUXILIARY_SERVICE_ID,
+ TezConfiguration.TEZ_AM_SHUFFLE_AUXILIARY_SERVICE_ID_DEFAULT);
+ final ByteBuffer shuffleMetaData =
+ inputContext.getServiceProviderMetaData(auxiliaryService);
+ this.shufflePort = ShuffleUtils.deserializeShuffleProviderMetaData(shuffleMetaData);
+
+ /**
+ * Setting to very high val can lead to Http 400 error. Cap it to 75; every attempt id would
+ * be approximately 48 bytes; 48 * 75 = 3600 which should give some room for other info in URL.
+ */
+ this.maxTaskOutputAtOnce = Math.max(1, Math.min(75, conf.getInt(
+ TezRuntimeConfiguration.TEZ_RUNTIME_SHUFFLE_FETCH_MAX_TASK_OUTPUT_AT_ONCE,
+ TezRuntimeConfiguration.TEZ_RUNTIME_SHUFFLE_FETCH_MAX_TASK_OUTPUT_AT_ONCE_DEFAULT)));
+
+ Arrays.sort(this.localDisks);
+
+ shuffleInfoEventsMap = new ConcurrentHashMap<>();
+
+ LOG.info(srcNameTrimmed + ": numInputs=" + numInputs + ", compressionCodec="
+ + (codec == null ? "NoCompressionCodec" : codec.getClass().getName()) + ", numFetchers="
+ + numFetchers + ", ifileBufferSize=" + ifileBufferSize + ", ifileReadAheadEnabled="
+ + ifileReadAhead + ", ifileReadAheadLength=" + ifileReadAheadLength + ", "
+ + "localDiskFetchEnabled=" + localDiskFetchEnabled + ", "
+ + "sharedFetchEnabled=" + sharedFetchEnabled + ", "
+ + httpConnectionParams.toString() + ", maxTaskOutputAtOnce=" + maxTaskOutputAtOnce);
+ }
+
+ @Override
+ public void run() throws IOException {
+ int shuffleId = InputContextUtils.computeShuffleId(this.inputContext);
+ TezTaskAttemptID tezTaskAttemptId = InputContextUtils.getTezTaskAttemptID(this.inputContext);
+ this.partitionToServers = UmbilicalUtils.requestShuffleServer(
+ this.inputContext.getApplicationId(), this.conf, tezTaskAttemptId, shuffleId);
+
+
+ Preconditions.checkState(inputManager != null, "InputManager must be configured");
+ if (maxTimeToWaitForReportMillis > 0) {
+ reporterExecutor = Executors.newSingleThreadExecutor(
+ new ThreadFactoryBuilder().setDaemon(true)
+ .setNameFormat("ShuffleRunner {" + srcNameTrimmed + "}")
+ .build());
+ Future reporterFuture = reporterExecutor.submit(new ReporterCallable());
+ }
+
+ ListenableFuture<Void> runShuffleFuture = schedulerExecutor.submit(rssSchedulerCallable);
+ Futures.addCallback(runShuffleFuture, new SchedulerFutureCallback(), MoreExecutors.directExecutor());
+ // Shutdown this executor once this task, and the callback complete.
+ schedulerExecutor.shutdown();
+ }
+
+ private class ReporterCallable extends CallableWithNdc<Void> {
+ /**
+ * Measures if the batching interval has ended.
+ */
+
+ ReporterCallable() {
+ }
+
+ @Override
+ protected Void callInternal() throws Exception {
+ long nextReport = 0;
+ while (!isShutdown.get()) {
+ try {
+ reportLock.lock();
+ while (failedEvents.isEmpty()) {
+ boolean signaled = reportCondition.await(maxTimeToWaitForReportMillis,
+ TimeUnit.MILLISECONDS);
+ }
+
+ long currentTime = Time.monotonicNow();;
+ if (currentTime > nextReport) {
+ if (failedEvents.size() > 0) {
+ List<Event> failedEventsToSend = Lists.newArrayListWithCapacity(
+ failedEvents.size());
+ for (InputReadErrorEvent key : failedEvents.keySet()) {
+ failedEventsToSend.add(InputReadErrorEvent
+ .create(key.getDiagnostics(), key.getIndex(),
+ key.getVersion()));
+ }
+ inputContext.sendEvents(failedEventsToSend);
+ failedEvents.clear();
+ nextReport = currentTime + maxTimeToWaitForReportMillis;
+ }
+ }
+ } finally {
+ reportLock.unlock();
+ }
+ }
+ return null;
+ }
+ }
+
+
+ private boolean isAllInputFetched() {
+ LOG.info("Check isAllInputFetched, numNoDataInput:{}, numWithDataInput:{},numInputs:{}, "
+ + "successRssPartitionSet:{}, allRssPartition:{}.",
+ numNoDataInput, numWithDataInput, numInputs, successRssPartitionSet, allRssPartition);
+ return (numNoDataInput.get() + numWithDataInput.get() >= numInputs)
+ && (successRssPartitionSet.size() >= allRssPartition.size());
+ }
+
+ private boolean isAllInputAdded() {
+ LOG.info("Check isAllInputAdded, numNoDataInput:{}, numWithDataInput:{},numInputs:{}, "
+ + "successRssPartitionSet:{}, allRssPartition:{}.",
+ numNoDataInput, numWithDataInput, numInputs, successRssPartitionSet, allRssPartition);
+ return numNoDataInput.get() + numWithDataInput.get() >= numInputs;
+ }
+
+ private class RssRunShuffleCallable extends CallableWithNdc<Void> {
+
+ private final Configuration conf;
+
+ RssRunShuffleCallable(Configuration conf) {
+ this.conf = conf;
+ }
+
+ @SuppressWarnings("RV_RETURN_VALUE_IGNORED_BAD_PRACTICE")
Review Comment:
ok, I solved it and is now all compiled ok.
##########
client-tez/src/main/java/org/apache/tez/runtime/library/common/shuffle/impl/RssShuffleManager.java:
##########
@@ -0,0 +1,1236 @@
+/**
+ * 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.tez.runtime.library.common.shuffle.impl;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.nio.ByteBuffer;
+import java.text.DecimalFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.BitSet;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.LinkedBlockingDeque;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.locks.Condition;
+import java.util.concurrent.locks.ReentrantLock;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Objects;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
+import com.google.common.util.concurrent.FutureCallback;
+import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.ListeningExecutorService;
+import com.google.common.util.concurrent.MoreExecutors;
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.LocalDirAllocator;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.fs.RawLocalFileSystem;
+import org.apache.hadoop.io.compress.CompressionCodec;
+import org.apache.hadoop.util.Time;
+import org.apache.tez.common.CallableWithNdc;
+import org.apache.tez.common.InputContextUtils;
+import org.apache.tez.common.TezRuntimeFrameworkConfigs;
+import org.apache.tez.common.TezUtilsInternal;
+import org.apache.tez.common.UmbilicalUtils;
+import org.apache.tez.common.counters.TaskCounter;
+import org.apache.tez.common.counters.TezCounter;
+import org.apache.tez.dag.api.TezConfiguration;
+import org.apache.tez.dag.api.TezUncheckedException;
+import org.apache.tez.dag.records.TezTaskAttemptID;
+import org.apache.tez.http.HttpConnectionParams;
+import org.apache.tez.runtime.api.Event;
+import org.apache.tez.runtime.api.InputContext;
+import org.apache.tez.runtime.api.TaskFailureType;
+import org.apache.tez.runtime.api.events.InputReadErrorEvent;
+import org.apache.tez.runtime.library.api.TezRuntimeConfiguration;
+import org.apache.tez.runtime.library.common.CompositeInputAttemptIdentifier;
+import org.apache.tez.runtime.library.common.InputAttemptIdentifier;
+import org.apache.tez.runtime.library.common.TezRuntimeUtils;
+import org.apache.tez.runtime.library.common.shuffle.FetchResult;
+import org.apache.tez.runtime.library.common.shuffle.FetchedInput;
+import org.apache.tez.runtime.library.common.shuffle.FetchedInputAllocator;
+import org.apache.tez.runtime.library.common.shuffle.Fetcher;
+import org.apache.tez.runtime.library.common.shuffle.Fetcher.FetcherBuilder;
+import org.apache.tez.runtime.library.common.shuffle.HostPort;
+import org.apache.tez.runtime.library.common.shuffle.InputHost;
+import org.apache.tez.runtime.library.common.shuffle.InputHost.PartitionToInputs;
+import org.apache.tez.runtime.library.common.shuffle.ShuffleUtils;
+import org.apache.tez.runtime.library.common.shuffle.ShuffleUtils.FetchStatsLogger;
+import org.roaringbitmap.longlong.Roaring64NavigableMap;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.uniffle.common.ShuffleServerInfo;
+
+// This only knows how to deal with a single srcIndex for a given targetIndex.
+// In case the src task generates multiple outputs for the same target Index
+// (multiple src-indices), modifications will be required.
+public class RssShuffleManager extends ShuffleManager {
+
+ private static final Logger LOG = LoggerFactory.getLogger(RssShuffleManager.class);
+ private static final Logger LOG_FETCH = LoggerFactory.getLogger(LOG.getName() + ".fetch");
+ private static final FetchStatsLogger fetchStatsLogger = new FetchStatsLogger(LOG_FETCH, LOG);
+
+ private final InputContext inputContext;
+ private final int numInputs;
+
+ private final DecimalFormat mbpsFormat = new DecimalFormat("0.00");
+
+ private final FetchedInputAllocator inputManager;
+
+ @VisibleForTesting
+ final ListeningExecutorService fetcherExecutor;
+
+ /**
+ * Executor for ReportCallable.
+ */
+ private ExecutorService reporterExecutor;
+
+ /**
+ * Lock to sync failedEvents.
+ */
+ private final ReentrantLock reportLock = new ReentrantLock();
+
+ /**
+ * Condition to wake up the thread notifying when events fail.
+ */
+ private final Condition reportCondition = reportLock.newCondition();
+
+ /**
+ * Events reporting fetcher failed.
+ */
+ private final HashMap<InputReadErrorEvent, Integer> failedEvents = new HashMap<>();
+
+ private final ListeningExecutorService schedulerExecutor;
+ private final RssRunShuffleCallable rssSchedulerCallable;
+
+ private final BlockingQueue<FetchedInput> completedInputs;
+ private final AtomicBoolean inputReadyNotificationSent = new AtomicBoolean(false);
+ @VisibleForTesting
+ final BitSet completedInputSet;
+ private final ConcurrentMap<HostPort, InputHost> knownSrcHosts;
+ private final BlockingQueue<InputHost> pendingHosts;
+ private final Set<InputAttemptIdentifier> obsoletedInputs;
+ private Set<RssTezFetcherTask> rssRunningFetchers;
+
+ private final AtomicInteger numCompletedInputs = new AtomicInteger(0);
+ private final AtomicInteger numFetchedSpills = new AtomicInteger(0);
+
+ private final long startTime;
+ private long lastProgressTime;
+ private long totalBytesShuffledTillNow;
+
+ // Required to be held when manipulating pendingHosts
+ private final ReentrantLock lock = new ReentrantLock();
+ private final Condition wakeLoop = lock.newCondition();
+
+ private final int numFetchers;
+ private final boolean asyncHttp;
+
+ // Parameters required by Fetchers
+ private final CompressionCodec codec;
+ private final Configuration conf;
+ private final boolean localDiskFetchEnabled;
+ private final boolean sharedFetchEnabled;
+ private final boolean verifyDiskChecksum;
+ private final boolean compositeFetch;
+
+ private final int ifileBufferSize;
+ private final boolean ifileReadAhead;
+ private final int ifileReadAheadLength;
+
+ /**
+ * Holds the time to wait for failures to batch them and send less events.
+ */
+ private final int maxTimeToWaitForReportMillis;
+
+ private final String srcNameTrimmed;
+
+ private final int maxTaskOutputAtOnce;
+
+ private final AtomicBoolean isShutdown = new AtomicBoolean(false);
+
+ private final TezCounter shuffledInputsCounter;
+ private final TezCounter failedShufflesCounter;
+ private final TezCounter bytesShuffledCounter;
+ private final TezCounter decompressedDataSizeCounter;
+ private final TezCounter bytesShuffledToDiskCounter;
+ private final TezCounter bytesShuffledToMemCounter;
+ private final TezCounter bytesShuffledDirectDiskCounter;
+
+ private volatile Throwable shuffleError;
+ private final HttpConnectionParams httpConnectionParams;
+
+ private final LocalDirAllocator localDirAllocator;
+ private final RawLocalFileSystem localFs;
+ private final Path[] localDisks;
+ private final String localhostName;
+ private final int shufflePort;
+
+ private final TezCounter shufflePhaseTime;
+ private final TezCounter firstEventReceived;
+ private final TezCounter lastEventReceived;
+
+ //To track shuffleInfo events when finalMerge is disabled OR pipelined shuffle is enabled in source.
+ @VisibleForTesting
+ final Map<Integer, ShuffleEventInfo> shuffleInfoEventsMap;
+
+ private Map<Integer, List<ShuffleServerInfo>> partitionToServers;
+ private final Set<Integer> successRssPartitionSet = new HashSet<>();
+ private final Set<Integer> runningRssPartitionMap = new HashSet<>();
+ private final Set<Integer> allRssPartition = Sets.newConcurrentHashSet();
+ private final BlockingQueue<Integer> pendingPartition = new LinkedBlockingQueue<>();
+ Map<Integer, List<InputAttemptIdentifier>> partitionToInput = new HashMap<>();
+ private final Map<Integer, Roaring64NavigableMap> rssAllBlockIdBitmapMap = new ConcurrentHashMap<>();
+ private final Map<Integer, Roaring64NavigableMap> rssSuccessBlockIdBitmapMap = new ConcurrentHashMap<>();
+ private final AtomicInteger numNoDataInput = new AtomicInteger(0);
+ private final AtomicInteger numWithDataInput = new AtomicInteger(0);
+
+ @SuppressFBWarnings("NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE")
Review Comment:
ok, I solved it and is now all compiled 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@uniffle.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org
For additional commands, e-mail: issues-help@uniffle.apache.org
[GitHub] [incubator-uniffle] jerqi commented on a diff in pull request #947: [#854][FOLLOWUP] feat(tez): Add RssShuffleManager to run and manager shuffle work
Posted by "jerqi (via GitHub)" <gi...@apache.org>.
jerqi commented on code in PR #947:
URL: https://github.com/apache/incubator-uniffle/pull/947#discussion_r1236258105
##########
client-tez/src/main/java/org/apache/tez/runtime/library/common/shuffle/impl/RssShuffleManager.java:
##########
@@ -0,0 +1,1236 @@
+/**
+ * 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.tez.runtime.library.common.shuffle.impl;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.nio.ByteBuffer;
+import java.text.DecimalFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.BitSet;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.LinkedBlockingDeque;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.locks.Condition;
+import java.util.concurrent.locks.ReentrantLock;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Objects;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
+import com.google.common.util.concurrent.FutureCallback;
+import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.ListeningExecutorService;
+import com.google.common.util.concurrent.MoreExecutors;
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.LocalDirAllocator;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.fs.RawLocalFileSystem;
+import org.apache.hadoop.io.compress.CompressionCodec;
+import org.apache.hadoop.util.Time;
+import org.apache.tez.common.CallableWithNdc;
+import org.apache.tez.common.InputContextUtils;
+import org.apache.tez.common.TezRuntimeFrameworkConfigs;
+import org.apache.tez.common.TezUtilsInternal;
+import org.apache.tez.common.UmbilicalUtils;
+import org.apache.tez.common.counters.TaskCounter;
+import org.apache.tez.common.counters.TezCounter;
+import org.apache.tez.dag.api.TezConfiguration;
+import org.apache.tez.dag.api.TezUncheckedException;
+import org.apache.tez.dag.records.TezTaskAttemptID;
+import org.apache.tez.http.HttpConnectionParams;
+import org.apache.tez.runtime.api.Event;
+import org.apache.tez.runtime.api.InputContext;
+import org.apache.tez.runtime.api.TaskFailureType;
+import org.apache.tez.runtime.api.events.InputReadErrorEvent;
+import org.apache.tez.runtime.library.api.TezRuntimeConfiguration;
+import org.apache.tez.runtime.library.common.CompositeInputAttemptIdentifier;
+import org.apache.tez.runtime.library.common.InputAttemptIdentifier;
+import org.apache.tez.runtime.library.common.TezRuntimeUtils;
+import org.apache.tez.runtime.library.common.shuffle.FetchResult;
+import org.apache.tez.runtime.library.common.shuffle.FetchedInput;
+import org.apache.tez.runtime.library.common.shuffle.FetchedInputAllocator;
+import org.apache.tez.runtime.library.common.shuffle.Fetcher;
+import org.apache.tez.runtime.library.common.shuffle.Fetcher.FetcherBuilder;
+import org.apache.tez.runtime.library.common.shuffle.HostPort;
+import org.apache.tez.runtime.library.common.shuffle.InputHost;
+import org.apache.tez.runtime.library.common.shuffle.InputHost.PartitionToInputs;
+import org.apache.tez.runtime.library.common.shuffle.ShuffleUtils;
+import org.apache.tez.runtime.library.common.shuffle.ShuffleUtils.FetchStatsLogger;
+import org.roaringbitmap.longlong.Roaring64NavigableMap;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.uniffle.common.ShuffleServerInfo;
+
+// This only knows how to deal with a single srcIndex for a given targetIndex.
+// In case the src task generates multiple outputs for the same target Index
+// (multiple src-indices), modifications will be required.
+public class RssShuffleManager extends ShuffleManager {
+
+ private static final Logger LOG = LoggerFactory.getLogger(RssShuffleManager.class);
+ private static final Logger LOG_FETCH = LoggerFactory.getLogger(LOG.getName() + ".fetch");
+ private static final FetchStatsLogger fetchStatsLogger = new FetchStatsLogger(LOG_FETCH, LOG);
+
+ private final InputContext inputContext;
+ private final int numInputs;
+
+ private final DecimalFormat mbpsFormat = new DecimalFormat("0.00");
+
+ private final FetchedInputAllocator inputManager;
+
+ @VisibleForTesting
+ final ListeningExecutorService fetcherExecutor;
+
+ /**
+ * Executor for ReportCallable.
+ */
+ private ExecutorService reporterExecutor;
+
+ /**
+ * Lock to sync failedEvents.
+ */
+ private final ReentrantLock reportLock = new ReentrantLock();
+
+ /**
+ * Condition to wake up the thread notifying when events fail.
+ */
+ private final Condition reportCondition = reportLock.newCondition();
+
+ /**
+ * Events reporting fetcher failed.
+ */
+ private final HashMap<InputReadErrorEvent, Integer> failedEvents = new HashMap<>();
+
+ private final ListeningExecutorService schedulerExecutor;
+ private final RssRunShuffleCallable rssSchedulerCallable;
+
+ private final BlockingQueue<FetchedInput> completedInputs;
+ private final AtomicBoolean inputReadyNotificationSent = new AtomicBoolean(false);
+ @VisibleForTesting
+ final BitSet completedInputSet;
+ private final ConcurrentMap<HostPort, InputHost> knownSrcHosts;
+ private final BlockingQueue<InputHost> pendingHosts;
+ private final Set<InputAttemptIdentifier> obsoletedInputs;
+ private Set<RssTezFetcherTask> rssRunningFetchers;
+
+ private final AtomicInteger numCompletedInputs = new AtomicInteger(0);
+ private final AtomicInteger numFetchedSpills = new AtomicInteger(0);
+
+ private final long startTime;
+ private long lastProgressTime;
+ private long totalBytesShuffledTillNow;
+
+ // Required to be held when manipulating pendingHosts
+ private final ReentrantLock lock = new ReentrantLock();
+ private final Condition wakeLoop = lock.newCondition();
+
+ private final int numFetchers;
+ private final boolean asyncHttp;
+
+ // Parameters required by Fetchers
+ private final CompressionCodec codec;
+ private final Configuration conf;
+ private final boolean localDiskFetchEnabled;
+ private final boolean sharedFetchEnabled;
+ private final boolean verifyDiskChecksum;
+ private final boolean compositeFetch;
+
+ private final int ifileBufferSize;
+ private final boolean ifileReadAhead;
+ private final int ifileReadAheadLength;
+
+ /**
+ * Holds the time to wait for failures to batch them and send less events.
+ */
+ private final int maxTimeToWaitForReportMillis;
+
+ private final String srcNameTrimmed;
+
+ private final int maxTaskOutputAtOnce;
+
+ private final AtomicBoolean isShutdown = new AtomicBoolean(false);
+
+ private final TezCounter shuffledInputsCounter;
+ private final TezCounter failedShufflesCounter;
+ private final TezCounter bytesShuffledCounter;
+ private final TezCounter decompressedDataSizeCounter;
+ private final TezCounter bytesShuffledToDiskCounter;
+ private final TezCounter bytesShuffledToMemCounter;
+ private final TezCounter bytesShuffledDirectDiskCounter;
+
+ private volatile Throwable shuffleError;
+ private final HttpConnectionParams httpConnectionParams;
+
+ private final LocalDirAllocator localDirAllocator;
+ private final RawLocalFileSystem localFs;
+ private final Path[] localDisks;
+ private final String localhostName;
+ private final int shufflePort;
+
+ private final TezCounter shufflePhaseTime;
+ private final TezCounter firstEventReceived;
+ private final TezCounter lastEventReceived;
+
+ //To track shuffleInfo events when finalMerge is disabled OR pipelined shuffle is enabled in source.
+ @VisibleForTesting
+ final Map<Integer, ShuffleEventInfo> shuffleInfoEventsMap;
+
+ private Map<Integer, List<ShuffleServerInfo>> partitionToServers;
+ private final Set<Integer> successRssPartitionSet = new HashSet<>();
+ private final Set<Integer> runningRssPartitionMap = new HashSet<>();
+ private final Set<Integer> allRssPartition = Sets.newConcurrentHashSet();
+ private final BlockingQueue<Integer> pendingPartition = new LinkedBlockingQueue<>();
+ Map<Integer, List<InputAttemptIdentifier>> partitionToInput = new HashMap<>();
+ private final Map<Integer, Roaring64NavigableMap> rssAllBlockIdBitmapMap = new ConcurrentHashMap<>();
+ private final Map<Integer, Roaring64NavigableMap> rssSuccessBlockIdBitmapMap = new ConcurrentHashMap<>();
+ private final AtomicInteger numNoDataInput = new AtomicInteger(0);
+ private final AtomicInteger numWithDataInput = new AtomicInteger(0);
+
+ @SuppressFBWarnings("NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE")
Review Comment:
Could we remove this annotation if we have solved this issue?
--
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@uniffle.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org
For additional commands, e-mail: issues-help@uniffle.apache.org