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 @@ -44,7 +44,6 @@
import jakarta.annotation.Nonnull;
import jakarta.annotation.Nullable;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.InetSocketAddress;
Expand Down Expand Up @@ -90,7 +89,6 @@
import org.apache.hadoop.security.token.SecretManager;
import org.apache.ratis.thirdparty.com.google.protobuf.ByteString;
import org.apache.ratis.util.SizeInBytes;
import org.apache.ratis.util.function.CheckedSupplier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -821,25 +819,6 @@ public static String threadNamePrefix(@Nullable Object id) {
: "";
}

/**
* Execute some code and ensure thread name is not changed
* (workaround for HADOOP-18433).
*/
public static <T, E extends IOException> T preserveThreadName(
CheckedSupplier<T, E> supplier) throws E {
final Thread thread = Thread.currentThread();
final String threadName = thread.getName();

try {
return supplier.get();
} finally {
if (!Objects.equals(threadName, thread.getName())) {
LOG.info("Restoring thread name: {}", threadName);
thread.setName(threadName);
}
}
}

/**
* Transform a protobuf UUID to Java UUID.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import static org.apache.hadoop.hdds.HddsConfigKeys.HDDS_DATANODE_HANDLER_COUNT_KEY;
import static org.apache.hadoop.hdds.HddsConfigKeys.HDDS_DATANODE_READ_THREADPOOL_DEFAULT;
import static org.apache.hadoop.hdds.HddsConfigKeys.HDDS_DATANODE_READ_THREADPOOL_KEY;
import static org.apache.hadoop.hdds.HddsUtils.preserveThreadName;
import static org.apache.hadoop.hdds.protocol.DatanodeDetails.Port.Name.CLIENT_RPC;

import com.google.protobuf.BlockingService;
Expand Down Expand Up @@ -114,8 +113,8 @@ private RPC.Server getRpcServer(OzoneConfiguration configuration,
.ReconfigureProtocolService.newReflectiveBlockingService(
reconfigureServerProtocol);

return preserveThreadName(() -> startRpcServer(configuration, rpcAddress,
ReconfigureProtocolDatanodePB.class, reconfigureService, handlerCount, readThreads));
return startRpcServer(configuration, rpcAddress,
ReconfigureProtocolDatanodePB.class, reconfigureService, handlerCount, readThreads);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

package org.apache.hadoop.hdds.scm.server;

import static org.apache.hadoop.hdds.HddsUtils.preserveThreadName;
import static org.apache.hadoop.hdds.scm.ScmConfigKeys.OZONE_SCM_EVENT_REPORT_EXEC_WAIT_THRESHOLD_DEFAULT;
import static org.apache.hadoop.hdds.scm.ScmConfigKeys.OZONE_SCM_EVENT_REPORT_QUEUE_WAIT_THRESHOLD_DEFAULT;
import static org.apache.hadoop.hdds.scm.ScmUtils.checkIfCertSignRequestAllowed;
Expand Down Expand Up @@ -1093,7 +1092,7 @@ public static RPC.Server startRpcServer(
int readThreads)
throws IOException {

RPC.Server rpcServer = preserveThreadName(() -> new RPC.Builder(conf)
RPC.Server rpcServer = new RPC.Builder(conf)
.setProtocol(protocol)
.setInstance(instance)
.setBindAddress(addr.getHostString())
Expand All @@ -1102,7 +1101,7 @@ public static RPC.Server startRpcServer(
.setNumReaders(readThreads)
.setVerbose(false)
.setSecretManager(null)
.build());
.build();

HddsServerUtil.addPBProtocol(conf, protocol, instance, rpcServer);
return rpcServer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import static org.apache.hadoop.hdds.HddsConfigKeys.HDDS_BLOCK_TOKEN_ENABLED;
import static org.apache.hadoop.hdds.HddsConfigKeys.HDDS_BLOCK_TOKEN_ENABLED_DEFAULT;
import static org.apache.hadoop.hdds.HddsUtils.getScmAddressForClients;
import static org.apache.hadoop.hdds.HddsUtils.preserveThreadName;
import static org.apache.hadoop.hdds.server.ServerUtils.updateRPCListenAddress;
import static org.apache.hadoop.hdds.utils.HAUtils.getScmInfo;
import static org.apache.hadoop.hdds.utils.HddsServerUtil.getRemoteUser;
Expand Down Expand Up @@ -1312,7 +1311,7 @@ private RPC.Server startRpcServer(OzoneConfiguration conf,
final int readThreads = conf.getInt(OZONE_OM_READ_THREADPOOL_KEY,
OZONE_OM_READ_THREADPOOL_DEFAULT);

RPC.Server rpcServer = preserveThreadName(() -> new RPC.Builder(conf)
RPC.Server rpcServer = new RPC.Builder(conf)
.setProtocol(OzoneManagerProtocolPB.class)
.setInstance(clientProtocolService)
.setBindAddress(addr.getHostString())
Expand All @@ -1321,7 +1320,7 @@ private RPC.Server startRpcServer(OzoneConfiguration conf,
.setNumReaders(readThreads)
.setVerbose(false)
.setSecretManager(delegationTokenMgr)
.build());
.build();

HddsServerUtil.addPBProtocol(conf, OMInterServiceProtocolPB.class,
interOMProtocolService, rpcServer);
Expand Down