@@ -88,9 +88,9 @@ public void testDataNodeMetrics() throws Exception {
88
88
MiniDFSCluster cluster = new MiniDFSCluster .Builder (conf ).build ();
89
89
try {
90
90
FileSystem fs = cluster .getFileSystem ();
91
- final long LONG_FILE_LEN = Integer .MAX_VALUE + 1L ;
91
+ final long LONG_FILE_LEN = Integer .MAX_VALUE + 1L ;
92
92
DFSTestUtil .createFile (fs , new Path ("/tmp.txt" ),
93
- LONG_FILE_LEN , (short ) 1 , 1L );
93
+ LONG_FILE_LEN , (short )1 , 1L );
94
94
List <DataNode > datanodes = cluster .getDataNodes ();
95
95
assertEquals (datanodes .size (), 1 );
96
96
DataNode datanode = datanodes .get (0 );
@@ -99,9 +99,7 @@ public void testDataNodeMetrics() throws Exception {
99
99
assertTrue ("Expected non-zero number of incremental block reports" ,
100
100
getLongCounter ("IncrementalBlockReportsNumOps" , rb ) > 0 );
101
101
} finally {
102
- if (cluster != null ) {
103
- cluster .shutdown ();
104
- }
102
+ if (cluster != null ) {cluster .shutdown ();}
105
103
}
106
104
}
107
105
@@ -116,26 +114,24 @@ public void testSendDataPacketMetrics() throws Exception {
116
114
// Create and read a 1 byte file
117
115
Path tmpfile = new Path ("/tmp.txt" );
118
116
DFSTestUtil .createFile (fs , tmpfile ,
119
- (long ) 1 , (short ) 1 , 1L );
117
+ (long )1 , (short )1 , 1L );
120
118
DFSTestUtil .readFile (fs , tmpfile );
121
119
List <DataNode > datanodes = cluster .getDataNodes ();
122
120
assertEquals (datanodes .size (), 1 );
123
121
DataNode datanode = datanodes .get (0 );
124
122
MetricsRecordBuilder rb = getMetrics (datanode .getMetrics ().name ());
125
123
// Expect 2 packets, 1 for the 1 byte read, 1 for the empty packet
126
124
// signaling the end of the block
127
- assertCounter ("SendDataPacketTransferNanosNumOps" , (long ) 2 , rb );
128
- assertCounter ("SendDataPacketBlockedOnNetworkNanosNumOps" , (long ) 2 , rb );
125
+ assertCounter ("SendDataPacketTransferNanosNumOps" , (long )2 , rb );
126
+ assertCounter ("SendDataPacketBlockedOnNetworkNanosNumOps" , (long )2 , rb );
129
127
// Wait for at least 1 rollover
130
128
Thread .sleep ((interval + 1 ) * 1000 );
131
129
// Check that the sendPacket percentiles rolled to non-zero values
132
130
String sec = interval + "s" ;
133
131
assertQuantileGauges ("SendDataPacketBlockedOnNetworkNanos" + sec , rb );
134
132
assertQuantileGauges ("SendDataPacketTransferNanos" + sec , rb );
135
133
} finally {
136
- if (cluster != null ) {
137
- cluster .shutdown ();
138
- }
134
+ if (cluster != null ) {cluster .shutdown ();}
139
135
}
140
136
}
141
137
@@ -169,9 +165,7 @@ public void testReceivePacketMetrics() throws Exception {
169
165
assertQuantileGauges ("FlushNanos" + sec , dnMetrics );
170
166
assertQuantileGauges ("FsyncNanos" + sec , dnMetrics );
171
167
} finally {
172
- if (cluster != null ) {
173
- cluster .shutdown ();
174
- }
168
+ if (cluster != null ) {cluster .shutdown ();}
175
169
}
176
170
}
177
171
@@ -276,8 +270,8 @@ public void testFsDatasetMetrics() throws Exception {
276
270
}
277
271
278
272
/**
279
- * Tests that round-trip acks in a datanode write pipeline are correctly
280
- * measured.
273
+ * Tests that round-trip acks in a datanode write pipeline are correctly
274
+ * measured.
281
275
*/
282
276
@ Test
283
277
public void testRoundTripAckMetric () throws Exception {
@@ -315,14 +309,14 @@ public void testRoundTripAckMetric() throws Exception {
315
309
break ;
316
310
}
317
311
}
318
- assertNotNull ("Could not find the head of the datanode write pipeline" ,
312
+ assertNotNull ("Could not find the head of the datanode write pipeline" ,
319
313
headNode );
320
314
// Close the file and wait for the metrics to rollover
321
315
Thread .sleep ((interval + 1 ) * 1000 );
322
316
// Check the ack was received
323
317
MetricsRecordBuilder dnMetrics = getMetrics (headNode .getMetrics ()
324
318
.name ());
325
- assertTrue ("Expected non-zero number of acks" ,
319
+ assertTrue ("Expected non-zero number of acks" ,
326
320
getLongCounter ("PacketAckRoundTripTimeNanosNumOps" , dnMetrics ) > 0 );
327
321
assertQuantileGauges ("PacketAckRoundTripTimeNanos" + interval
328
322
+ "s" , dnMetrics );
@@ -333,7 +327,7 @@ public void testRoundTripAckMetric() throws Exception {
333
327
}
334
328
}
335
329
336
- @ Test (timeout = 60000 )
330
+ @ Test (timeout = 60000 )
337
331
public void testTimeoutMetric () throws Exception {
338
332
final Configuration conf = new HdfsConfiguration ();
339
333
final Path path = new Path ("/test" );
@@ -387,7 +381,7 @@ public void testTimeoutMetric() throws Exception {
387
381
*
388
382
* @throws Exception
389
383
*/
390
- @ Test (timeout = 120000 )
384
+ @ Test (timeout = 120000 )
391
385
public void testDataNodeTimeSpend () throws Exception {
392
386
Configuration conf = new HdfsConfiguration ();
393
387
conf .set (DFSConfigKeys .DFS_METRICS_PERCENTILES_INTERVALS_KEY , "" + 60 );
@@ -477,16 +471,16 @@ public void testDatanodeActiveXceiversCount() throws Exception {
477
471
478
472
MetricsRecordBuilder rb = getMetrics (datanode .getMetrics ().name ());
479
473
long dataNodeActiveXceiversCount = MetricsAsserts .getIntGauge (
480
- "DataNodeActiveXceiversCount" , rb );
474
+ "DataNodeActiveXceiversCount" , rb );
481
475
assertEquals (dataNodeActiveXceiversCount , 0 );
482
476
483
477
Path path = new Path ("/counter.txt" );
484
478
DFSTestUtil .createFile (fs , path , 204800000 , (short ) 3 , Time
485
- .monotonicNow ());
479
+ .monotonicNow ());
486
480
487
481
MetricsRecordBuilder rbNew = getMetrics (datanode .getMetrics ().name ());
488
482
dataNodeActiveXceiversCount = MetricsAsserts .getIntGauge (
489
- "DataNodeActiveXceiversCount" , rbNew );
483
+ "DataNodeActiveXceiversCount" , rbNew );
490
484
assertTrue (dataNodeActiveXceiversCount >= 0 );
491
485
} finally {
492
486
if (cluster != null ) {
@@ -573,12 +567,12 @@ public void testDNShouldNotDeleteBlockONTooManyOpenFiles()
573
567
fs .getClient ().getLocatedBlocks (p .toString (), 0 ).get (0 ).getBlock ();
574
568
try {
575
569
new BlockSender (b , 0 , -1 , false , true , true ,
576
- cluster .getDataNodes ().get (0 ), null ,
577
- CachingStrategy .newDefaultStrategy ());
570
+ cluster .getDataNodes ().get (0 ), null ,
571
+ CachingStrategy .newDefaultStrategy ());
578
572
fail ("Must throw FileNotFoundException" );
579
573
} catch (FileNotFoundException fe ) {
580
574
assertTrue ("Should throw too many open files" ,
581
- fe .getMessage ().contains ("Too many open files" ));
575
+ fe .getMessage ().contains ("Too many open files" ));
582
576
}
583
577
cluster .triggerHeartbeats (); // IBR delete ack
584
578
//After DN throws too many open files
@@ -593,7 +587,7 @@ public void testDNShouldNotDeleteBlockONTooManyOpenFiles()
593
587
}
594
588
595
589
private void verifyBlockLocations (DistributedFileSystem fs , Path p ,
596
- int expected ) throws IOException , TimeoutException , InterruptedException {
590
+ int expected ) throws IOException , TimeoutException , InterruptedException {
597
591
final LocatedBlock lb =
598
592
fs .getClient ().getLocatedBlocks (p .toString (), 0 ).get (0 );
599
593
GenericTestUtils .waitFor (new Supplier <Boolean >() {
@@ -621,8 +615,7 @@ public void testNNRpcMetricsWithNonHA() throws IOException {
621
615
@ Test (timeout = 60000 )
622
616
public void testSlowMetrics () throws Exception {
623
617
DataNodeFaultInjector dnFaultInjector = new DataNodeFaultInjector () {
624
- @ Override
625
- public void delay () {
618
+ @ Override public void delay () {
626
619
try {
627
620
Thread .sleep (310 );
628
621
} catch (InterruptedException e ) {
@@ -649,8 +642,7 @@ public void delay() {
649
642
final AtomicInteger x = new AtomicInteger (0 );
650
643
651
644
GenericTestUtils .waitFor (new Supplier <Boolean >() {
652
- @ Override
653
- public Boolean get () {
645
+ @ Override public Boolean get () {
654
646
x .getAndIncrement ();
655
647
try {
656
648
DFSTestUtil
@@ -745,7 +737,7 @@ public void testNodeLocalMetrics() throws Exception {
745
737
cluster .waitActive ();
746
738
FileSystem fs = cluster .getFileSystem ();
747
739
Path testFile = new Path ("/testNodeLocalMetrics.txt" );
748
- DFSTestUtil .createFile (fs , testFile , 10L , (short ) 1 , 1L );
740
+ DFSTestUtil .createFile (fs , testFile , 10L , (short )1 , 1L );
749
741
DFSTestUtil .readFile (fs , testFile );
750
742
List <DataNode > datanodes = cluster .getDataNodes ();
751
743
assertEquals (1 , datanodes .size ());
@@ -827,4 +819,3 @@ public Boolean get() {
827
819
}
828
820
}
829
821
}
830
-
0 commit comments