HADOOP-13387 users always get told off for using S3 —even when not using it. Contributed by stevel.

This commit is contained in:
Steve Loughran 2016-07-20 14:01:17 +01:00
parent 5490ed5f87
commit d3df810dce
1 changed files with 7 additions and 7 deletions

View File

@ -26,6 +26,7 @@
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.hadoop.classification.InterfaceAudience; import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.classification.InterfaceStability; import org.apache.hadoop.classification.InterfaceStability;
@ -58,7 +59,8 @@
@Deprecated @Deprecated
public class S3FileSystem extends FileSystem { public class S3FileSystem extends FileSystem {
private static boolean hasWarnedDeprecation = false; private static final AtomicBoolean hasWarnedDeprecation
= new AtomicBoolean(false);
private URI uri; private URI uri;
@ -67,23 +69,20 @@ public class S3FileSystem extends FileSystem {
private Path workingDir; private Path workingDir;
public S3FileSystem() { public S3FileSystem() {
warnDeprecation();
// set store in initialize() // set store in initialize()
} }
public S3FileSystem(FileSystemStore store) { public S3FileSystem(FileSystemStore store) {
warnDeprecation();
this.store = store; this.store = store;
} }
/** /**
* This is to warn the first time in a JVM that an S3FileSystem is created. * This is to warn the first time in a JVM that an S3FileSystem is created.
*/ */
private static synchronized void warnDeprecation() { private static void warnDeprecation() {
if (!hasWarnedDeprecation) { if (!hasWarnedDeprecation.getAndSet(true)) {
System.err.println("S3FileSystem is deprecated and will be removed in " + LOG.warn("S3FileSystem is deprecated and will be removed in " +
"future releases. Use NativeS3FileSystem or S3AFileSystem instead."); "future releases. Use NativeS3FileSystem or S3AFileSystem instead.");
hasWarnedDeprecation = true;
} }
} }
@ -105,6 +104,7 @@ public URI getUri() {
@Override @Override
public void initialize(URI uri, Configuration conf) throws IOException { public void initialize(URI uri, Configuration conf) throws IOException {
super.initialize(uri, conf); super.initialize(uri, conf);
warnDeprecation();
if (store == null) { if (store == null) {
store = createDefaultStore(conf); store = createDefaultStore(conf);
} }