Skip to content

Commit c888527

Browse files
committed
HADOOP-18028. High performance S3A input stream
Initial merge tuning * rename test classes, have AbstractHadoopTestBase as the base * package info files for new packages * import ordering * move to intercept() for assertions; ExceptionAsserts is invoking it and can be removed in future. Tests still fail; will document in JIRA Change-Id: Ib80edd72c30af8dc996acb62aa0e31bf61eebc7a
1 parent f442641 commit c888527

25 files changed

+114
-126
lines changed

hadoop-tools/hadoop-aws/pom.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -350,10 +350,6 @@
350350
<groupId>org.apache.maven.plugins</groupId>
351351
<artifactId>maven-surefire-plugin</artifactId>
352352
<configuration>
353-
<includes>
354-
<include>**/*Test.java</include>
355-
<include>**/Test*.java</include>
356-
</includes>
357353
<forkedProcessTimeoutInSeconds>3600</forkedProcessTimeoutInSeconds>
358354
<systemPropertyVariables>
359355
<test.default.timeout>${test.integration.timeout}</test.default.timeout>

hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/common/BlockOperations.java

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

2020
package org.apache.hadoop.fs.common;
2121

22-
import org.slf4j.Logger;
23-
import org.slf4j.LoggerFactory;
24-
2522
import java.util.ArrayList;
2623
import java.util.Arrays;
2724
import java.util.DoubleSummaryStatistics;
@@ -31,6 +28,9 @@
3128
import java.util.regex.Matcher;
3229
import java.util.regex.Pattern;
3330

31+
import org.slf4j.Logger;
32+
import org.slf4j.LoggerFactory;
33+
3434
/**
3535
* Block level operations performed on a file.
3636
* This class is meant to be used by {@code BlockManager}.

hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/common/BoundedResourcePool.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424
import java.util.Set;
2525
import java.util.concurrent.ArrayBlockingQueue;
2626

27-
import static org.apache.hadoop.util.Preconditions.checkNotNull;
28-
2927
/**
3028
* Manages a fixed pool of resources.
3129
*
@@ -81,7 +79,7 @@ public T tryAcquire() {
8179
*/
8280
@Override
8381
public void release(T item) {
84-
checkNotNull(item, "item");
82+
Validate.checkNotNull(item, "item");
8583

8684
synchronized (this.createdItems) {
8785
if (!this.createdItems.contains(item)) {

hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/common/BufferData.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,16 @@
1919

2020
package org.apache.hadoop.fs.common;
2121

22-
import com.twitter.util.Future;
23-
import com.twitter.util.Awaitable.CanAwait;
24-
import org.slf4j.Logger;
25-
import org.slf4j.LoggerFactory;
26-
2722
import java.nio.ByteBuffer;
2823
import java.util.ArrayList;
2924
import java.util.List;
3025
import java.util.zip.CRC32;
3126

27+
import com.twitter.util.Awaitable.CanAwait;
28+
import com.twitter.util.Future;
29+
import org.slf4j.Logger;
30+
import org.slf4j.LoggerFactory;
31+
3232
/**
3333
* Holds the state of a ByteBuffer that is in use by {@code CachingBlockManager}.
3434
*

hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/common/BufferPool.java

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

2020
package org.apache.hadoop.fs.common;
2121

22-
import com.twitter.util.Future;
23-
import org.slf4j.Logger;
24-
import org.slf4j.LoggerFactory;
25-
2622
import java.io.Closeable;
2723
import java.nio.ByteBuffer;
2824
import java.util.ArrayList;
@@ -32,9 +28,9 @@
3228
import java.util.Map;
3329
import java.util.concurrent.CancellationException;
3430

35-
import static org.apache.hadoop.util.Preconditions.checkArgument;
36-
import static org.apache.hadoop.util.Preconditions.checkNotNull;
37-
import static org.apache.hadoop.util.Preconditions.checkState;
31+
import com.twitter.util.Future;
32+
import org.slf4j.Logger;
33+
import org.slf4j.LoggerFactory;
3834

3935
/**
4036
* Manages a fixed pool of {@code ByteBuffer} instances.
@@ -155,7 +151,7 @@ private synchronized BufferData acquireHelper(int blockNumber, boolean canBlock)
155151
data = new BufferData(blockNumber, buffer.duplicate());
156152

157153
synchronized (this.allocated) {
158-
checkState(this.find(blockNumber) == null, "buffer data already exists");
154+
Validate.checkState(this.find(blockNumber) == null, "buffer data already exists");
159155

160156
this.allocated.put(data, buffer);
161157
}
@@ -212,10 +208,10 @@ private int distance(BufferData data, int blockNumber) {
212208
* @throws IllegalArgumentException if data cannot be released due to its state.
213209
*/
214210
public synchronized void release(BufferData data) {
215-
checkNotNull(data, "data");
211+
Validate.checkNotNull(data, "data");
216212

217213
synchronized (data) {
218-
checkArgument(
214+
Validate.checkArgument(
219215
this.canRelease(data),
220216
String.format("Unable to release buffer: %s", data));
221217

hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/common/CachingBlockManager.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,18 @@
1919

2020
package org.apache.hadoop.fs.common;
2121

22+
import java.io.IOException;
23+
import java.nio.ByteBuffer;
24+
import java.util.concurrent.atomic.AtomicBoolean;
25+
import java.util.concurrent.atomic.AtomicInteger;
26+
2227
import com.twitter.util.Await;
2328
import com.twitter.util.ExceptionalFunction0;
2429
import com.twitter.util.Future;
2530
import com.twitter.util.FuturePool;
2631
import org.slf4j.Logger;
2732
import org.slf4j.LoggerFactory;
2833

29-
import java.io.IOException;
30-
import java.nio.ByteBuffer;
31-
import java.util.concurrent.atomic.AtomicBoolean;
32-
import java.util.concurrent.atomic.AtomicInteger;
33-
3434
/**
3535
* Provides read access to the underlying file one block at a time.
3636
* Improve read performance by prefetching and locall caching blocks.

hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/common/FilePosition.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121

2222
import java.nio.ByteBuffer;
2323

24-
import static org.apache.hadoop.util.Preconditions.checkState;
25-
2624
/**
2725
* Provides functionality related to tracking the position within a file.
2826
*
@@ -278,7 +276,7 @@ public String toString() {
278276

279277
private void throwIfInvalidBuffer() {
280278
if (!this.isValid()) {
281-
checkState(buffer != null, "'buffer' must not be null");
279+
Validate.checkState(buffer != null, "'buffer' must not be null");
282280
}
283281
}
284282
}

hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/common/SingleFilePerBlockCache.java

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

2020
package org.apache.hadoop.fs.common;
2121

22-
import org.slf4j.Logger;
23-
import org.slf4j.LoggerFactory;
24-
2522
import java.io.File;
2623
import java.io.IOException;
2724
import java.nio.ByteBuffer;
@@ -42,6 +39,9 @@
4239
import java.util.Set;
4340
import java.util.concurrent.ConcurrentHashMap;
4441

42+
import org.slf4j.Logger;
43+
import org.slf4j.LoggerFactory;
44+
4545
/**
4646
* Provides functionality necessary for caching blocks of data read from FileSystem.
4747
* Each cache block is stored on the local disk as a separate file.

hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/common/Validate.java

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323
import java.nio.file.Path;
2424
import java.util.Collection;
2525

26-
import org.apache.hadoop.util.Preconditions;
27-
2826
/**
2927
* A superset of Validate class in Apache commons lang3.
3028
*
@@ -42,7 +40,7 @@ private Validate() {}
4240
* @param argName the name of the argument being validated.
4341
*/
4442
public static void checkNotNull(Object obj, String argName) {
45-
Preconditions.checkNotNull(obj != null, "'%s' must not be null.", argName);
43+
checkArgument(obj != null, "'%s' must not be null.", argName);
4644
}
4745

4846
/**
@@ -52,7 +50,7 @@ public static void checkNotNull(Object obj, String argName) {
5250
* @param argName the name of the argument being validated.
5351
*/
5452
public static void checkPositiveInteger(long value, String argName) {
55-
Preconditions.checkArgument(value > 0, "'%s' must be a positive integer.", argName);
53+
checkArgument(value > 0, "'%s' must be a positive integer.", argName);
5654
}
5755

5856
/**
@@ -62,7 +60,7 @@ public static void checkPositiveInteger(long value, String argName) {
6260
* @param argName the name of the argument being validated.
6361
*/
6462
public static void checkNotNegative(long value, String argName) {
65-
Preconditions.checkArgument(value >= 0, "'%s' must not be negative.", argName);
63+
checkArgument(value >= 0, "'%s' must not be negative.", argName);
6664
}
6765

6866
/*
@@ -72,7 +70,7 @@ public static void checkNotNegative(long value, String argName) {
7270
* @param argName the name of the argument being validated.
7371
*/
7472
public static void checkRequired(boolean isPresent, String argName) {
75-
Preconditions.checkArgument(isPresent, "'%s' is required.", argName);
73+
checkArgument(isPresent, "'%s' is required.", argName);
7674
}
7775

7876
/**
@@ -82,7 +80,7 @@ public static void checkRequired(boolean isPresent, String argName) {
8280
* @param argName the name of the argument being validated.
8381
*/
8482
public static void checkValid(boolean isValid, String argName) {
85-
Preconditions.checkArgument(isValid, "'%s' is invalid.", argName);
83+
checkArgument(isValid, "'%s' is invalid.", argName);
8684
}
8785

8886
/**
@@ -387,16 +385,19 @@ public static void checkPathExistsAsDir(Path path, String argName) {
387385
*/
388386
public static void checkPathExistsAsFile(Path path, String argName) {
389387
checkPathExists(path, argName);
390-
Preconditions.checkArgument(Files.isRegularFile(path),
391-
"Path %s (%s) must point to a file.", argName, path);
388+
checkArgument(Files.isRegularFile(path), "Path %s (%s) must point to a file.", argName, path);
392389
}
393390

394391
public static void checkArgument(boolean expression, String format, Object... args) {
395-
Preconditions.checkArgument(expression, format, args);
392+
org.apache.commons.lang3.Validate.isTrue(expression, format, args);
393+
}
394+
395+
public static void checkState(boolean expression, String format, Object... args) {
396+
org.apache.commons.lang3.Validate.validState(expression, format, args);
396397
}
397398

398399
private static void checkNotEmpty(int arraySize, String argName) {
399-
Preconditions.checkArgument(
400+
Validate.checkArgument(
400401
arraySize > 0,
401402
"'%s' must have at least one element.",
402403
argName);

hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/read/S3BlockManager.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@
2424

2525
import org.apache.hadoop.fs.common.BlockData;
2626
import org.apache.hadoop.fs.common.BlockManager;
27-
28-
import static org.apache.hadoop.util.Preconditions.checkNotNull;
27+
import org.apache.hadoop.fs.common.Validate;
2928

3029
/**
3130
* Provides read access to S3 file one block at a time.
@@ -52,7 +51,9 @@ public class S3BlockManager extends BlockManager {
5251
public S3BlockManager(S3Reader reader, BlockData blockData) {
5352
super(blockData);
5453

55-
this.reader = checkNotNull(reader, "reader");
54+
Validate.checkNotNull(reader, "reader");
55+
56+
this.reader = reader;
5657
}
5758

5859
/**

0 commit comments

Comments
 (0)