HADOOP-11613. Remove commons-httpclient dependency from hadoop-azure. Contributed by Masatake Iwasaki.

This commit is contained in:
cnauroth 2016-02-22 13:39:38 -08:00
parent a63301a864
commit d4f5fc23b2
2 changed files with 15 additions and 21 deletions

View File

@ -1137,6 +1137,9 @@ Release 2.8.0 - UNRELEASED
HADOOP-12828. Print user when services are started. HADOOP-12828. Print user when services are started.
(Wei-Chiu Chuang via Yongjun Zhang) (Wei-Chiu Chuang via Yongjun Zhang)
HADOOP-11613. Remove commons-httpclient dependency from hadoop-azure.
(Masatake Iwasaki via cnauroth)
OPTIMIZATIONS OPTIMIZATIONS
HADOOP-11785. Reduce the number of listStatus operation in distcp HADOOP-11785. Reduce the number of listStatus operation in distcp

View File

@ -33,9 +33,10 @@ import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.TimeZone; import java.util.TimeZone;
import java.util.List; import java.util.List;
import org.apache.commons.httpclient.URIException; import org.apache.commons.codec.DecoderException;
import org.apache.commons.httpclient.util.URIUtil; import org.apache.commons.codec.net.URLCodec;
import org.apache.commons.lang.NotImplementedException; import org.apache.commons.lang.NotImplementedException;
import org.apache.http.client.utils.URIBuilder;
import com.microsoft.azure.storage.AccessCondition; import com.microsoft.azure.storage.AccessCondition;
import com.microsoft.azure.storage.CloudStorageAccount; import com.microsoft.azure.storage.CloudStorageAccount;
@ -68,6 +69,7 @@ public class MockStorageInterface extends StorageInterface {
private final ArrayList<PreExistingContainer> preExistingContainers = private final ArrayList<PreExistingContainer> preExistingContainers =
new ArrayList<MockStorageInterface.PreExistingContainer>(); new ArrayList<MockStorageInterface.PreExistingContainer>();
private String baseUriString; private String baseUriString;
private static final URLCodec codec = new URLCodec();
public InMemoryBlockBlobStore getBackingStore() { public InMemoryBlockBlobStore getBackingStore() {
return backingStore; return backingStore;
@ -126,22 +128,17 @@ public class MockStorageInterface extends StorageInterface {
*/ */
private static String convertUriToDecodedString(URI uri) { private static String convertUriToDecodedString(URI uri) {
try { try {
String result = URIUtil.decode(uri.toString()); return codec.decode(uri.toString());
return result; } catch (DecoderException e) {
} catch (URIException e) {
throw new AssertionError("Failed to decode URI: " + uri.toString()); throw new AssertionError("Failed to decode URI: " + uri.toString());
} }
} }
private static URI convertKeyToEncodedUri(String key) { private static URI convertKeyToEncodedUri(String key) {
try { try {
String encodedKey = URIUtil.encodePath(key); return new URIBuilder().setPath(key).build();
URI uri = new URI(encodedKey);
return uri;
} catch (URISyntaxException e) { } catch (URISyntaxException e) {
throw new AssertionError("Failed to encode key: " + key); throw new AssertionError("Failed to encode key: " + key);
} catch (URIException e) {
throw new AssertionError("Failed to encode key: " + key);
} }
} }
@ -149,11 +146,8 @@ public class MockStorageInterface extends StorageInterface {
public CloudBlobContainerWrapper getContainerReference(String name) public CloudBlobContainerWrapper getContainerReference(String name)
throws URISyntaxException, StorageException { throws URISyntaxException, StorageException {
String fullUri; String fullUri;
try { URIBuilder builder = new URIBuilder(baseUriString);
fullUri = baseUriString + "/" + URIUtil.encodePath(name); fullUri = builder.setPath(builder.getPath() + "/" + name).toString();
} catch (URIException e) {
throw new RuntimeException("problem encoding fullUri", e);
}
MockCloudBlobContainerWrapper container = new MockCloudBlobContainerWrapper( MockCloudBlobContainerWrapper container = new MockCloudBlobContainerWrapper(
fullUri, name); fullUri, name);
@ -243,8 +237,6 @@ public class MockStorageInterface extends StorageInterface {
// helper to create full URIs for directory and blob. // helper to create full URIs for directory and blob.
// use withTrailingSlash=true to get a good path for a directory. // use withTrailingSlash=true to get a good path for a directory.
private String fullUriString(String relativePath, boolean withTrailingSlash) { private String fullUriString(String relativePath, boolean withTrailingSlash) {
String fullUri;
String baseUri = this.baseUri; String baseUri = this.baseUri;
if (!baseUri.endsWith("/")) { if (!baseUri.endsWith("/")) {
baseUri += "/"; baseUri += "/";
@ -255,12 +247,11 @@ public class MockStorageInterface extends StorageInterface {
} }
try { try {
fullUri = baseUri + URIUtil.encodePath(relativePath); URIBuilder builder = new URIBuilder(baseUri);
} catch (URIException e) { return builder.setPath(builder.getPath() + relativePath).toString();
} catch (URISyntaxException e) {
throw new RuntimeException("problem encoding fullUri", e); throw new RuntimeException("problem encoding fullUri", e);
} }
return fullUri;
} }
} }