Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import com.google.common.util.concurrent.Uninterruptibles;
import org.apache.hadoop.io.RawComparator;
import org.apache.hadoop.io.serializer.Serializer;
Expand All @@ -49,6 +48,7 @@
import org.apache.uniffle.common.ShuffleServerInfo;
import org.apache.uniffle.common.exception.RssException;
import org.apache.uniffle.common.util.ChecksumUtils;
import org.apache.uniffle.common.util.ThreadUtils;

public class SortWriteBufferManager<K, V> {

Expand Down Expand Up @@ -139,10 +139,7 @@ public SortWriteBufferManager(
this.maxBufferSize = maxBufferSize;
this.sendExecutorService = Executors.newFixedThreadPool(
sendThreadNum,
new ThreadFactoryBuilder()
.setDaemon(true)
.setNameFormat("send-thread-%d")
.build());
ThreadUtils.getThreadFactory("send-thread-%d"));
}

// todo: Single Buffer should also have its size limit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import com.google.common.collect.Maps;
import com.google.common.collect.Queues;
import com.google.common.collect.Sets;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import org.apache.hadoop.conf.Configuration;
import org.apache.spark.ShuffleDependency;
import org.apache.spark.SparkConf;
Expand Down Expand Up @@ -62,6 +61,7 @@
import org.apache.uniffle.common.ShuffleBlockInfo;
import org.apache.uniffle.common.ShuffleServerInfo;
import org.apache.uniffle.common.util.RssUtils;
import org.apache.uniffle.common.util.ThreadUtils;

public class RssShuffleManager implements ShuffleManager {

Expand Down Expand Up @@ -194,11 +194,11 @@ public RssShuffleManager(SparkConf sparkConf, boolean isDriver) {
RssSparkConfig.RSS_CLIENT_SEND_THREAD_POOL_KEEPALIVE_DEFAULT_VALUE);
threadPoolExecutor = new ThreadPoolExecutor(poolSize, poolSize * 2, keepAliveTime, TimeUnit.SECONDS,
Queues.newLinkedBlockingQueue(Integer.MAX_VALUE),
new ThreadFactoryBuilder().setDaemon(true).setNameFormat("SendData").build());
ThreadUtils.getThreadFactory("SendData"));

if (isDriver) {
heartBeatScheduledExecutorService = Executors.newSingleThreadScheduledExecutor(
new ThreadFactoryBuilder().setDaemon(true).setNameFormat("rss-heartbeat-%d").build());
ThreadUtils.getThreadFactory("rss-heartbeat-%d"));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import com.google.common.collect.Maps;
import com.google.common.collect.Queues;
import com.google.common.collect.Sets;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import org.apache.hadoop.conf.Configuration;
import org.apache.spark.ShuffleDependency;
import org.apache.spark.SparkConf;
Expand Down Expand Up @@ -66,6 +65,7 @@
import org.apache.uniffle.common.ShuffleBlockInfo;
import org.apache.uniffle.common.ShuffleServerInfo;
import org.apache.uniffle.common.util.RssUtils;
import org.apache.uniffle.common.util.ThreadUtils;

public class RssShuffleManager implements ShuffleManager {

Expand Down Expand Up @@ -200,7 +200,7 @@ public RssShuffleManager(SparkConf conf, boolean isDriver) {
Queues.newLinkedBlockingQueue(Integer.MAX_VALUE));
if (isDriver) {
heartBeatScheduledExecutorService = Executors.newSingleThreadScheduledExecutor(
new ThreadFactoryBuilder().setDaemon(true).setNameFormat("rss-heartbeat-%d").build());
ThreadUtils.getThreadFactory("rss-heartbeat-%d"));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import org.roaringbitmap.longlong.Roaring64NavigableMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -72,6 +71,7 @@
import org.apache.uniffle.common.ShuffleBlockInfo;
import org.apache.uniffle.common.ShuffleServerInfo;
import org.apache.uniffle.common.exception.RssException;
import org.apache.uniffle.common.util.ThreadUtils;

public class ShuffleWriteClientImpl implements ShuffleWriteClient {

Expand All @@ -98,7 +98,7 @@ public ShuffleWriteClientImpl(String clientType, int retryMax, long retryInterva
this.retryIntervalMax = retryIntervalMax;
this.coordinatorClientFactory = new CoordinatorClientFactory(clientType);
this.heartBeatExecutorService = Executors.newFixedThreadPool(heartBeatThreadNum,
new ThreadFactoryBuilder().setDaemon(true).setNameFormat("client-heartbeat-%d").build());
ThreadUtils.getThreadFactory("client-heartbeat-%d"));
this.replica = replica;
this.replicaWrite = replicaWrite;
this.replicaRead = replicaRead;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import java.util.concurrent.TimeUnit;

import com.google.common.collect.Queues;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import io.grpc.BindableService;
import io.grpc.Server;
import io.grpc.ServerBuilder;
Expand All @@ -34,6 +33,7 @@
import org.apache.uniffle.common.config.RssBaseConf;
import org.apache.uniffle.common.metrics.GRPCMetrics;
import org.apache.uniffle.common.util.ExitUtils;
import org.apache.uniffle.common.util.ThreadUtils;

public class GrpcServer implements ServerInterface {

Expand All @@ -52,7 +52,7 @@ public GrpcServer(RssBaseConf conf, BindableService service, GRPCMetrics grpcMet
10,
TimeUnit.MINUTES,
Queues.newLinkedBlockingQueue(Integer.MAX_VALUE),
new ThreadFactoryBuilder().setDaemon(true).setNameFormat("Grpc-%d").build()
ThreadUtils.getThreadFactory("Grpc-%d")
);

boolean isMetricsEnabled = conf.getBoolean(RssBaseConf.RPC_METRICS_ENABLED);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* 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.uniffle.common.util;

import java.util.concurrent.ThreadFactory;

import com.google.common.util.concurrent.ThreadFactoryBuilder;

/**
* Provide a general method to create a thread factory to make the code more standardized
*/
public class ThreadUtils {

public static ThreadFactory getThreadFactory(String factoryName) {
return new ThreadFactoryBuilder().setDaemon(true).setNameFormat(factoryName).build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import java.util.concurrent.atomic.AtomicReference;

import com.google.common.collect.Sets;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
Expand All @@ -39,6 +38,7 @@
import org.slf4j.LoggerFactory;

import org.apache.uniffle.common.util.Constants;
import org.apache.uniffle.common.util.ThreadUtils;

/**
* AccessCandidatesChecker maintain a list of candidate access id and update it periodically,
Expand Down Expand Up @@ -75,7 +75,7 @@ public AccessCandidatesChecker(AccessManager accessManager) throws Exception {

int updateIntervalS = conf.getInteger(CoordinatorConf.COORDINATOR_ACCESS_CANDIDATES_UPDATE_INTERVAL_SEC);
updateAccessCandidatesSES = Executors.newSingleThreadScheduledExecutor(
new ThreadFactoryBuilder().setDaemon(true).setNameFormat("UpdateAccessCandidates-%d").build());
ThreadUtils.getThreadFactory("UpdateAccessCandidates-%d"));
updateAccessCandidatesSES.scheduleAtFixedRate(
this::updateAccessCandidates, 0, updateIntervalS, TimeUnit.SECONDS);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.apache.uniffle.common.RemoteStorageInfo;
import org.apache.uniffle.common.util.Constants;
import org.apache.uniffle.common.util.ThreadUtils;

public class ApplicationManager {

Expand All @@ -59,7 +59,7 @@ public ApplicationManager(CoordinatorConf conf) {
expired = conf.getLong(CoordinatorConf.COORDINATOR_APP_EXPIRED);
// the thread for checking application status
scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(
new ThreadFactoryBuilder().setDaemon(true).setNameFormat("ApplicationManager-%d").build());
ThreadUtils.getThreadFactory("ApplicationManager-%d"));
scheduledExecutorService.scheduleAtFixedRate(
() -> statusCheck(), expired / 2, expired / 2, TimeUnit.MILLISECONDS);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import java.util.concurrent.atomic.AtomicLong;

import com.google.common.collect.Maps;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
Expand All @@ -38,6 +37,8 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.apache.uniffle.common.util.ThreadUtils;

public class ClientConfManager implements Closeable {
private static final Logger LOG = LoggerFactory.getLogger(ClientConfManager.class);

Expand Down Expand Up @@ -73,7 +74,7 @@ private void init(CoordinatorConf conf, Configuration hadoopConf) throws Excepti

int updateIntervalS = conf.getInteger(CoordinatorConf.COORDINATOR_DYNAMIC_CLIENT_CONF_UPDATE_INTERVAL_SEC);
updateClientConfSES = Executors.newSingleThreadScheduledExecutor(
new ThreadFactoryBuilder().setDaemon(true).setNameFormat("ClientConfManager-%d").build());
ThreadUtils.getThreadFactory("ClientConfManager-%d"));
updateClientConfSES.scheduleAtFixedRate(
this::updateClientConf, 0, updateIntervalS, TimeUnit.SECONDS);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import org.apache.commons.lang3.StringUtils;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileStatus;
Expand All @@ -43,6 +42,8 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.apache.uniffle.common.util.ThreadUtils;

public class SimpleClusterManager implements ClusterManager {

private static final Logger LOG = LoggerFactory.getLogger(SimpleClusterManager.class);
Expand All @@ -63,7 +64,7 @@ public SimpleClusterManager(CoordinatorConf conf, Configuration hadoopConf) thro
this.heartbeatTimeout = conf.getLong(CoordinatorConf.COORDINATOR_HEARTBEAT_TIMEOUT);
// the thread for checking if shuffle server report heartbeat in time
scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(
new ThreadFactoryBuilder().setDaemon(true).setNameFormat("SimpleClusterManager-%d").build());
ThreadUtils.getThreadFactory("SimpleClusterManager-%d"));
scheduledExecutorService.scheduleAtFixedRate(
() -> nodesCheck(), heartbeatTimeout / 3,
heartbeatTimeout / 3, TimeUnit.MILLISECONDS);
Expand All @@ -73,7 +74,7 @@ public SimpleClusterManager(CoordinatorConf conf, Configuration hadoopConf) thro
this.hadoopFileSystem = CoordinatorUtils.getFileSystemForPath(new Path(excludeNodesPath), hadoopConf);
long updateNodesInterval = conf.getLong(CoordinatorConf.COORDINATOR_EXCLUDE_NODES_CHECK_INTERVAL);
checkNodesExecutorService = Executors.newSingleThreadScheduledExecutor(
new ThreadFactoryBuilder().setDaemon(true).setNameFormat("UpdateExcludeNodes-%d").build());
ThreadUtils.getThreadFactory("UpdateExcludeNodes-%d"));
checkNodesExecutorService.scheduleAtFixedRate(
() -> updateExcludeNodes(excludeNodesPath), updateNodesInterval, updateNodesInterval, TimeUnit.MILLISECONDS);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import com.google.common.collect.Maps;
import com.google.common.collect.Queues;
import com.google.common.collect.RangeMap;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import com.google.common.util.concurrent.Uninterruptibles;
import org.apache.hadoop.conf.Configuration;
import org.roaringbitmap.longlong.Roaring64NavigableMap;
Expand All @@ -37,6 +36,7 @@

import org.apache.uniffle.common.ShufflePartitionedBlock;
import org.apache.uniffle.common.config.RssBaseConf;
import org.apache.uniffle.common.util.ThreadUtils;
import org.apache.uniffle.server.buffer.ShuffleBuffer;
import org.apache.uniffle.server.storage.StorageManager;
import org.apache.uniffle.storage.common.Storage;
Expand Down Expand Up @@ -84,7 +84,7 @@ public ShuffleFlushManager(ShuffleServerConf shuffleServerConf, String shuffleSe
int poolSize = shuffleServerConf.getInteger(ShuffleServerConf.SERVER_FLUSH_THREAD_POOL_SIZE);
long keepAliveTime = shuffleServerConf.getLong(ShuffleServerConf.SERVER_FLUSH_THREAD_ALIVE);
threadPoolExecutor = new ThreadPoolExecutor(poolSize, poolSize, keepAliveTime, TimeUnit.SECONDS, waitQueue,
new ThreadFactoryBuilder().setDaemon(true).setNameFormat("FlushEventThreadPool").build());
ThreadUtils.getThreadFactory("FlushEventThreadPool"));
storageBasePaths = shuffleServerConf.getString(ShuffleServerConf.RSS_STORAGE_BASE_PATH).split(",");
pendingEventTimeoutSec = shuffleServerConf.getLong(ShuffleServerConf.PENDING_EVENT_TIMEOUT_SEC);
// the thread for flush data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import com.google.common.collect.Maps;
import com.google.common.collect.Queues;
import com.google.common.collect.Sets;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import org.roaringbitmap.longlong.LongIterator;
import org.roaringbitmap.longlong.Roaring64NavigableMap;
import org.slf4j.Logger;
Expand All @@ -48,6 +47,7 @@
import org.apache.uniffle.common.config.RssBaseConf;
import org.apache.uniffle.common.util.Constants;
import org.apache.uniffle.common.util.RssUtils;
import org.apache.uniffle.common.util.ThreadUtils;
import org.apache.uniffle.server.buffer.PreAllocatedBufferInfo;
import org.apache.uniffle.server.buffer.ShuffleBufferManager;
import org.apache.uniffle.server.storage.StorageManager;
Expand Down Expand Up @@ -100,12 +100,12 @@ public ShuffleTaskManager(
this.preAllocationExpired = conf.getLong(ShuffleServerConf.SERVER_PRE_ALLOCATION_EXPIRED);
// the thread for checking application status
this.scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(
new ThreadFactoryBuilder().setDaemon(true).setNameFormat("checkResource-%d").build());
ThreadUtils.getThreadFactory("checkResource-%d"));
scheduledExecutorService.scheduleAtFixedRate(
() -> preAllocatedBufferCheck(), preAllocationExpired / 2,
preAllocationExpired / 2, TimeUnit.MILLISECONDS);
this.expiredAppCleanupExecutorService = Executors.newSingleThreadScheduledExecutor(
new ThreadFactoryBuilder().setDaemon(true).setNameFormat("expiredAppCleaner").build());
ThreadUtils.getThreadFactory("expiredAppCleaner"));
expiredAppCleanupExecutorService.scheduleAtFixedRate(
() -> checkResourceStatus(), appExpiredWithoutHB / 2,
appExpiredWithoutHB / 2, TimeUnit.MILLISECONDS);
Expand Down