Skip to content

Commit 875e43e

Browse files
committed
Merge branch 'trunk' into HADOOP-17765-new
2 parents f306f88 + 5d76549 commit 875e43e

File tree

51 files changed

+1115
-365
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+1115
-365
lines changed

hadoop-build-tools/src/main/resources/checkstyle/checkstyle.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@
6969

7070
<!-- Checks for line length violations. -->
7171
<!-- See https://checkstyle.sourceforge.io/config_sizes.html#LineLength -->
72-
<module name="LineLength"/>
72+
<module name="LineLength">
73+
<property name="max" value="100"/>
74+
</module>
7375

7476
<module name="TreeWalker">
7577

hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/CommonConfigurationKeys.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,9 @@ public class CommonConfigurationKeys extends CommonConfigurationKeysPublic {
381381
public static final boolean RPC_METRICS_QUANTILE_ENABLE_DEFAULT = false;
382382
public static final String RPC_METRICS_PERCENTILES_INTERVALS_KEY =
383383
"rpc.metrics.percentiles.intervals";
384-
384+
385+
public static final String RPC_METRICS_TIME_UNIT = "rpc.metrics.timeunit";
386+
385387
/** Allowed hosts for nfs exports */
386388
public static final String NFS_EXPORTS_ALLOWED_HOSTS_SEPARATOR = ";";
387389
public static final String NFS_EXPORTS_ALLOWED_HOSTS_KEY = "nfs.exports.allowed.hosts";

hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/Client.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1051,7 +1051,10 @@ private synchronized boolean waitForWork() {
10511051
if (timeout>0) {
10521052
try {
10531053
wait(timeout);
1054-
} catch (InterruptedException e) {}
1054+
} catch (InterruptedException e) {
1055+
LOG.info("Interrupted while waiting to retrieve RPC response.", e);
1056+
Thread.currentThread().interrupt();
1057+
}
10551058
}
10561059
}
10571060

@@ -1383,6 +1386,9 @@ public void stop() {
13831386
try {
13841387
emptyCondition.wait();
13851388
} catch (InterruptedException e) {
1389+
LOG.info("Interrupted while waiting on all connections to be closed.",
1390+
e);
1391+
Thread.currentThread().interrupt();
13861392
}
13871393
}
13881394
}

hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/DecayRpcScheduler.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ public class DecayRpcScheduler implements RpcScheduler,
193193
private final String namespace;
194194
private final int topUsersCount; // e.g., report top 10 users' metrics
195195
private static final double PRECISION = 0.0001;
196+
private final TimeUnit metricsTimeUnit;
196197
private MetricsProxy metricsProxy;
197198
private final CostProvider costProvider;
198199
private final Map<String, Integer> staticPriorities = new HashMap<>();
@@ -266,6 +267,8 @@ public DecayRpcScheduler(int numLevels, String ns, Configuration conf) {
266267
DecayRpcSchedulerDetailedMetrics.create(ns);
267268
decayRpcSchedulerDetailedMetrics.init(numLevels);
268269

270+
metricsTimeUnit = RpcMetrics.getMetricsTimeUnit(conf);
271+
269272
// Setup delay timer
270273
Timer timer = new Timer(true);
271274
DecayTask task = new DecayTask(this, timer);
@@ -725,8 +728,9 @@ public void addResponseTime(String callName, Schedulable schedulable,
725728
addCost(user, processingCost);
726729

727730
int priorityLevel = schedulable.getPriorityLevel();
728-
long queueTime = details.get(Timing.QUEUE, RpcMetrics.TIMEUNIT);
729-
long processingTime = details.get(Timing.PROCESSING, RpcMetrics.TIMEUNIT);
731+
long queueTime = details.get(Timing.QUEUE, metricsTimeUnit);
732+
long processingTime = details.get(Timing.PROCESSING,
733+
metricsTimeUnit);
730734

731735
this.decayRpcSchedulerDetailedMetrics.addQueueTime(
732736
priorityLevel, queueTime);

hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/RpcScheduler.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ default void addResponseTime(String callName, Schedulable schedulable,
6262
// this interface, a default implementation is supplied which uses the old
6363
// method. All new implementations MUST override this interface and should
6464
// NOT use the other addResponseTime method.
65-
int queueTime = (int)
66-
details.get(ProcessingDetails.Timing.QUEUE, RpcMetrics.TIMEUNIT);
67-
int processingTime = (int)
68-
details.get(ProcessingDetails.Timing.PROCESSING, RpcMetrics.TIMEUNIT);
65+
int queueTime = (int) details.get(ProcessingDetails.Timing.QUEUE,
66+
RpcMetrics.DEFAULT_METRIC_TIME_UNIT);
67+
int processingTime = (int) details.get(ProcessingDetails.Timing.PROCESSING,
68+
RpcMetrics.DEFAULT_METRIC_TIME_UNIT);
6969
addResponseTime(callName, schedulable.getPriorityLevel(),
7070
queueTime, processingTime);
7171
}

hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/Server.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -544,13 +544,13 @@ void logSlowRpcCalls(String methodName, Call call,
544544
(rpcMetrics.getProcessingStdDev() * deviation);
545545

546546
long processingTime =
547-
details.get(Timing.PROCESSING, RpcMetrics.TIMEUNIT);
547+
details.get(Timing.PROCESSING, rpcMetrics.getMetricsTimeUnit());
548548
if ((rpcMetrics.getProcessingSampleCount() > minSampleSize) &&
549549
(processingTime > threeSigma)) {
550550
LOG.warn(
551551
"Slow RPC : {} took {} {} to process from client {},"
552552
+ " the processing detail is {}",
553-
methodName, processingTime, RpcMetrics.TIMEUNIT, call,
553+
methodName, processingTime, rpcMetrics.getMetricsTimeUnit(), call,
554554
details.toString());
555555
rpcMetrics.incrSlowRpc();
556556
}
@@ -570,7 +570,7 @@ void updateMetrics(Call call, long startTime, boolean connDropped) {
570570
deltaNanos -= details.get(Timing.RESPONSE);
571571
details.set(Timing.HANDLER, deltaNanos);
572572

573-
long queueTime = details.get(Timing.QUEUE, RpcMetrics.TIMEUNIT);
573+
long queueTime = details.get(Timing.QUEUE, rpcMetrics.getMetricsTimeUnit());
574574
rpcMetrics.addRpcQueueTime(queueTime);
575575

576576
if (call.isResponseDeferred() || connDropped) {
@@ -579,9 +579,9 @@ void updateMetrics(Call call, long startTime, boolean connDropped) {
579579
}
580580

581581
long processingTime =
582-
details.get(Timing.PROCESSING, RpcMetrics.TIMEUNIT);
582+
details.get(Timing.PROCESSING, rpcMetrics.getMetricsTimeUnit());
583583
long waitTime =
584-
details.get(Timing.LOCKWAIT, RpcMetrics.TIMEUNIT);
584+
details.get(Timing.LOCKWAIT, rpcMetrics.getMetricsTimeUnit());
585585
rpcMetrics.addRpcLockWaitTime(waitTime);
586586
rpcMetrics.addRpcProcessingTime(processingTime);
587587
// don't include lock wait for detailed metrics.

hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/metrics/RpcMetrics.java

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
import java.util.concurrent.TimeUnit;
2121

22+
import org.apache.commons.lang3.StringUtils;
2223
import org.apache.hadoop.thirdparty.com.google.common.annotations.VisibleForTesting;
2324
import org.apache.hadoop.fs.CommonConfigurationKeys;
2425
import org.apache.hadoop.ipc.Server;
@@ -48,9 +49,12 @@ public class RpcMetrics {
4849
final MetricsRegistry registry;
4950
final String name;
5051
final boolean rpcQuantileEnable;
52+
53+
public static final TimeUnit DEFAULT_METRIC_TIME_UNIT =
54+
TimeUnit.MILLISECONDS;
5155
/** The time unit used when storing/accessing time durations. */
52-
public final static TimeUnit TIMEUNIT = TimeUnit.MILLISECONDS;
53-
56+
private final TimeUnit metricsTimeUnit;
57+
5458
RpcMetrics(Server server, Configuration conf) {
5559
String port = String.valueOf(server.getListenerAddress().getPort());
5660
name = "RpcActivityForPort" + port;
@@ -63,6 +67,7 @@ public class RpcMetrics {
6367
rpcQuantileEnable = (intervals.length > 0) && conf.getBoolean(
6468
CommonConfigurationKeys.RPC_METRICS_QUANTILE_ENABLE,
6569
CommonConfigurationKeys.RPC_METRICS_QUANTILE_ENABLE_DEFAULT);
70+
metricsTimeUnit = getMetricsTimeUnit(conf);
6671
if (rpcQuantileEnable) {
6772
rpcQueueTimeQuantiles =
6873
new MutableQuantiles[intervals.length];
@@ -75,19 +80,19 @@ public class RpcMetrics {
7580
for (int i = 0; i < intervals.length; i++) {
7681
int interval = intervals[i];
7782
rpcQueueTimeQuantiles[i] = registry.newQuantiles("rpcQueueTime"
78-
+ interval + "s", "rpc queue time in " + TIMEUNIT, "ops",
83+
+ interval + "s", "rpc queue time in " + metricsTimeUnit, "ops",
7984
"latency", interval);
8085
rpcLockWaitTimeQuantiles[i] = registry.newQuantiles(
8186
"rpcLockWaitTime" + interval + "s",
82-
"rpc lock wait time in " + TIMEUNIT, "ops",
87+
"rpc lock wait time in " + metricsTimeUnit, "ops",
8388
"latency", interval);
8489
rpcProcessingTimeQuantiles[i] = registry.newQuantiles(
8590
"rpcProcessingTime" + interval + "s",
86-
"rpc processing time in " + TIMEUNIT, "ops",
91+
"rpc processing time in " + metricsTimeUnit, "ops",
8792
"latency", interval);
8893
deferredRpcProcessingTimeQuantiles[i] = registry.newQuantiles(
8994
"deferredRpcProcessingTime" + interval + "s",
90-
"deferred rpc processing time in " + TIMEUNIT, "ops",
95+
"deferred rpc processing time in " + metricsTimeUnit, "ops",
9196
"latency", interval);
9297
}
9398
}
@@ -141,6 +146,27 @@ public String numOpenConnectionsPerUser() {
141146
return server.getNumDroppedConnections();
142147
}
143148

149+
public TimeUnit getMetricsTimeUnit() {
150+
return metricsTimeUnit;
151+
}
152+
153+
public static TimeUnit getMetricsTimeUnit(Configuration conf) {
154+
TimeUnit metricsTimeUnit = RpcMetrics.DEFAULT_METRIC_TIME_UNIT;
155+
String timeunit = conf.get(CommonConfigurationKeys.RPC_METRICS_TIME_UNIT);
156+
if (StringUtils.isNotEmpty(timeunit)) {
157+
try {
158+
metricsTimeUnit = TimeUnit.valueOf(timeunit);
159+
} catch (IllegalArgumentException e) {
160+
LOG.info("Config key {} 's value {} does not correspond to enum values"
161+
+ " of java.util.concurrent.TimeUnit. Hence default unit"
162+
+ " {} will be used",
163+
CommonConfigurationKeys.RPC_METRICS_TIME_UNIT, timeunit,
164+
RpcMetrics.DEFAULT_METRIC_TIME_UNIT);
165+
}
166+
}
167+
return metricsTimeUnit;
168+
}
169+
144170
// Public instrumentation methods that could be extracted to an
145171
// abstract class if we decide to do custom instrumentation classes a la
146172
// JobTrackerInstrumentation. The methods with //@Override comment are

hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/SecurityUtil.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -608,11 +608,8 @@ protected static class QualifiedHostResolver implements HostResolver {
608608
private List<String> searchDomains = new ArrayList<>();
609609
{
610610
ResolverConfig resolverConfig = ResolverConfig.getCurrentConfig();
611-
Name[] names = resolverConfig.searchPath();
612-
if (names != null) {
613-
for (Name name : names) {
614-
searchDomains.add(name.toString());
615-
}
611+
for (Name name : resolverConfig.searchPath()) {
612+
searchDomains.add(name.toString());
616613
}
617614
}
618615

hadoop-common-project/hadoop-common/src/main/resources/core-default.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3345,6 +3345,21 @@
33453345
</description>
33463346
</property>
33473347

3348+
<property>
3349+
<name>rpc.metrics.timeunit</name>
3350+
<value>MILLISECONDS</value>
3351+
<description>
3352+
This property is used to configure timeunit for various RPC Metrics
3353+
e.g rpcQueueTime, rpcLockWaitTime, rpcProcessingTime,
3354+
deferredRpcProcessingTime. In the absence of this property,
3355+
default timeunit used is milliseconds.
3356+
The value of this property should match to any one value of enum:
3357+
java.util.concurrent.TimeUnit.
3358+
Some of the valid values: NANOSECONDS, MICROSECONDS, MILLISECONDS,
3359+
SECONDS etc.
3360+
</description>
3361+
</property>
3362+
33483363
<property>
33493364
<name>rpc.metrics.percentiles.intervals</name>
33503365
<value></value>

hadoop-common-project/hadoop-common/src/site/markdown/Metrics.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ rpc
6565
---
6666

6767
Each metrics record contains tags such as Hostname and port (number to which server is bound) as additional information along with metrics.
68+
`rpc.metrics.timeunit` config can be used to configure timeunit for RPC metrics.
69+
The default timeunit used for RPC metrics is milliseconds (as per the below description).
6870

6971
| Name | Description |
7072
|:---- |:---- |

0 commit comments

Comments
 (0)