HDFS-11824. Ozone: Fix javac warnings. Contributed by Yiqun Lin.
This commit is contained in:
parent
7f0be64284
commit
e9d09c209e
|
@ -281,7 +281,7 @@ public final class OzoneClientUtils {
|
||||||
if ((value == null) || value.isEmpty()) {
|
if ((value == null) || value.isEmpty()) {
|
||||||
return Optional.absent();
|
return Optional.absent();
|
||||||
}
|
}
|
||||||
return Optional.of(HostAndPort.fromString(value).getHostText());
|
return Optional.of(HostAndPort.fromString(value).getHost());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -36,10 +36,10 @@ import org.apache.http.client.utils.URIBuilder;
|
||||||
import org.apache.http.entity.ContentType;
|
import org.apache.http.entity.ContentType;
|
||||||
import org.apache.http.entity.FileEntity;
|
import org.apache.http.entity.FileEntity;
|
||||||
import org.apache.http.entity.InputStreamEntity;
|
import org.apache.http.entity.InputStreamEntity;
|
||||||
import org.apache.http.impl.client.DefaultHttpClient;
|
import org.apache.http.impl.client.CloseableHttpClient;
|
||||||
|
import org.apache.http.impl.client.HttpClients;
|
||||||
import org.apache.http.util.EntityUtils;
|
import org.apache.http.util.EntityUtils;
|
||||||
|
|
||||||
import javax.ws.rs.core.HttpHeaders;
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@ -159,7 +159,7 @@ public class OzoneBucket {
|
||||||
try {
|
try {
|
||||||
OzoneClient client = getVolume().getClient();
|
OzoneClient client = getVolume().getClient();
|
||||||
|
|
||||||
DefaultHttpClient httpClient = new DefaultHttpClient();
|
CloseableHttpClient httpClient = HttpClients.createDefault();
|
||||||
|
|
||||||
URIBuilder builder = new URIBuilder(volume.getClient().getEndPointURI());
|
URIBuilder builder = new URIBuilder(volume.getClient().getEndPointURI());
|
||||||
builder.setPath("/" + getVolume().getVolumeName() + "/" + getBucketName()
|
builder.setPath("/" + getVolume().getVolumeName() + "/" + getBucketName()
|
||||||
|
@ -219,7 +219,7 @@ public class OzoneBucket {
|
||||||
try {
|
try {
|
||||||
OzoneClient client = getVolume().getClient();
|
OzoneClient client = getVolume().getClient();
|
||||||
|
|
||||||
DefaultHttpClient httpClient = new DefaultHttpClient();
|
CloseableHttpClient httpClient = HttpClients.createDefault();
|
||||||
URIBuilder builder = new URIBuilder(volume.getClient().getEndPointURI());
|
URIBuilder builder = new URIBuilder(volume.getClient().getEndPointURI());
|
||||||
builder.setPath("/" + getVolume().getVolumeName() + "/" + getBucketName()
|
builder.setPath("/" + getVolume().getVolumeName() + "/" + getBucketName()
|
||||||
+ "/" + keyName).build();
|
+ "/" + keyName).build();
|
||||||
|
@ -234,10 +234,6 @@ public class OzoneBucket {
|
||||||
FileInputStream fis = new FileInputStream(file);
|
FileInputStream fis = new FileInputStream(file);
|
||||||
putRequest.setHeader(Header.CONTENT_MD5, DigestUtils.md5Hex(fis));
|
putRequest.setHeader(Header.CONTENT_MD5, DigestUtils.md5Hex(fis));
|
||||||
fis.close();
|
fis.close();
|
||||||
putRequest.setHeader(HttpHeaders.CONTENT_LENGTH, Long.toString(file
|
|
||||||
.length()));
|
|
||||||
httpClient.removeRequestInterceptorByClass(
|
|
||||||
org.apache.http.protocol.RequestContent.class);
|
|
||||||
executePutKey(putRequest, httpClient);
|
executePutKey(putRequest, httpClient);
|
||||||
|
|
||||||
} catch (IOException | URISyntaxException ex) {
|
} catch (IOException | URISyntaxException ex) {
|
||||||
|
@ -253,7 +249,7 @@ public class OzoneBucket {
|
||||||
* @throws OzoneException
|
* @throws OzoneException
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
private void executePutKey(HttpPut putRequest, DefaultHttpClient httpClient)
|
private void executePutKey(HttpPut putRequest, CloseableHttpClient httpClient)
|
||||||
throws OzoneException, IOException {
|
throws OzoneException, IOException {
|
||||||
HttpEntity entity = null;
|
HttpEntity entity = null;
|
||||||
try {
|
try {
|
||||||
|
@ -298,7 +294,7 @@ public class OzoneBucket {
|
||||||
try {
|
try {
|
||||||
OzoneClient client = getVolume().getClient();
|
OzoneClient client = getVolume().getClient();
|
||||||
|
|
||||||
DefaultHttpClient httpClient = new DefaultHttpClient();
|
CloseableHttpClient httpClient = HttpClients.createDefault();
|
||||||
FileOutputStream outPutFile = new FileOutputStream(downloadTo.toFile());
|
FileOutputStream outPutFile = new FileOutputStream(downloadTo.toFile());
|
||||||
|
|
||||||
URIBuilder builder = new URIBuilder(volume.getClient().getEndPointURI());
|
URIBuilder builder = new URIBuilder(volume.getClient().getEndPointURI());
|
||||||
|
@ -332,7 +328,7 @@ public class OzoneBucket {
|
||||||
OzoneClient client = getVolume().getClient();
|
OzoneClient client = getVolume().getClient();
|
||||||
ByteArrayOutputStream outPutStream = new ByteArrayOutputStream();
|
ByteArrayOutputStream outPutStream = new ByteArrayOutputStream();
|
||||||
|
|
||||||
DefaultHttpClient httpClient = new DefaultHttpClient();
|
CloseableHttpClient httpClient = HttpClients.createDefault();
|
||||||
URIBuilder builder = new URIBuilder(volume.getClient().getEndPointURI());
|
URIBuilder builder = new URIBuilder(volume.getClient().getEndPointURI());
|
||||||
|
|
||||||
builder.setPath("/" + getVolume().getVolumeName() + "/" + getBucketName()
|
builder.setPath("/" + getVolume().getVolumeName() + "/" + getBucketName()
|
||||||
|
@ -357,7 +353,7 @@ public class OzoneBucket {
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* @throws OzoneException
|
* @throws OzoneException
|
||||||
*/
|
*/
|
||||||
private void executeGetKey(HttpGet getRequest, DefaultHttpClient httpClient,
|
private void executeGetKey(HttpGet getRequest, CloseableHttpClient httpClient,
|
||||||
OutputStream stream)
|
OutputStream stream)
|
||||||
throws IOException, OzoneException {
|
throws IOException, OzoneException {
|
||||||
|
|
||||||
|
@ -399,7 +395,7 @@ public class OzoneBucket {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
OzoneClient client = getVolume().getClient();
|
OzoneClient client = getVolume().getClient();
|
||||||
DefaultHttpClient httpClient = new DefaultHttpClient();
|
CloseableHttpClient httpClient = HttpClients.createDefault();
|
||||||
|
|
||||||
URIBuilder builder = new URIBuilder(volume.getClient().getEndPointURI());
|
URIBuilder builder = new URIBuilder(volume.getClient().getEndPointURI());
|
||||||
builder.setPath("/" + getVolume().getVolumeName() + "/" + getBucketName()
|
builder.setPath("/" + getVolume().getVolumeName() + "/" + getBucketName()
|
||||||
|
@ -422,7 +418,7 @@ public class OzoneBucket {
|
||||||
* @throws OzoneException
|
* @throws OzoneException
|
||||||
*/
|
*/
|
||||||
private void executeDeleteKey(HttpDelete deleteRequest,
|
private void executeDeleteKey(HttpDelete deleteRequest,
|
||||||
DefaultHttpClient httpClient)
|
CloseableHttpClient httpClient)
|
||||||
throws IOException, OzoneException {
|
throws IOException, OzoneException {
|
||||||
|
|
||||||
HttpEntity entity = null;
|
HttpEntity entity = null;
|
||||||
|
@ -456,7 +452,7 @@ public class OzoneBucket {
|
||||||
public List<OzoneKey> listKeys() throws OzoneException {
|
public List<OzoneKey> listKeys() throws OzoneException {
|
||||||
try {
|
try {
|
||||||
OzoneClient client = getVolume().getClient();
|
OzoneClient client = getVolume().getClient();
|
||||||
DefaultHttpClient httpClient = new DefaultHttpClient();
|
CloseableHttpClient httpClient = HttpClients.createDefault();
|
||||||
URIBuilder builder = new URIBuilder(volume.getClient().getEndPointURI());
|
URIBuilder builder = new URIBuilder(volume.getClient().getEndPointURI());
|
||||||
builder.setPath("/" + getVolume().getVolumeName() + "/" + getBucketName())
|
builder.setPath("/" + getVolume().getVolumeName() + "/" + getBucketName())
|
||||||
.build();
|
.build();
|
||||||
|
@ -479,7 +475,7 @@ public class OzoneBucket {
|
||||||
* @throws OzoneException
|
* @throws OzoneException
|
||||||
*/
|
*/
|
||||||
private List<OzoneKey> executeListKeys(HttpGet getRequest,
|
private List<OzoneKey> executeListKeys(HttpGet getRequest,
|
||||||
DefaultHttpClient httpClient)
|
CloseableHttpClient httpClient)
|
||||||
throws IOException, OzoneException {
|
throws IOException, OzoneException {
|
||||||
HttpEntity entity = null;
|
HttpEntity entity = null;
|
||||||
List<OzoneKey> ozoneKeyList = new LinkedList<OzoneKey>();
|
List<OzoneKey> ozoneKeyList = new LinkedList<OzoneKey>();
|
||||||
|
|
|
@ -31,7 +31,8 @@ import org.apache.http.client.methods.HttpPost;
|
||||||
import org.apache.http.client.methods.HttpPut;
|
import org.apache.http.client.methods.HttpPut;
|
||||||
import org.apache.http.client.methods.HttpRequestBase;
|
import org.apache.http.client.methods.HttpRequestBase;
|
||||||
import org.apache.http.client.utils.URIBuilder;
|
import org.apache.http.client.utils.URIBuilder;
|
||||||
import org.apache.http.impl.client.DefaultHttpClient;
|
import org.apache.http.impl.client.CloseableHttpClient;
|
||||||
|
import org.apache.http.impl.client.HttpClients;
|
||||||
import org.apache.http.util.EntityUtils;
|
import org.apache.http.util.EntityUtils;
|
||||||
|
|
||||||
import javax.ws.rs.core.HttpHeaders;
|
import javax.ws.rs.core.HttpHeaders;
|
||||||
|
@ -142,7 +143,7 @@ public class OzoneClient implements Closeable {
|
||||||
public OzoneVolume createVolume(String volumeName, String onBehalfOf,
|
public OzoneVolume createVolume(String volumeName, String onBehalfOf,
|
||||||
String quota) throws OzoneException {
|
String quota) throws OzoneException {
|
||||||
try {
|
try {
|
||||||
DefaultHttpClient httpClient = new DefaultHttpClient();
|
CloseableHttpClient httpClient = HttpClients.createDefault();
|
||||||
OzoneUtils.verifyBucketName(volumeName);
|
OzoneUtils.verifyBucketName(volumeName);
|
||||||
|
|
||||||
URIBuilder builder = new URIBuilder(endPointURI);
|
URIBuilder builder = new URIBuilder(endPointURI);
|
||||||
|
@ -169,7 +170,7 @@ public class OzoneClient implements Closeable {
|
||||||
*/
|
*/
|
||||||
public OzoneVolume getVolume(String volumeName) throws OzoneException {
|
public OzoneVolume getVolume(String volumeName) throws OzoneException {
|
||||||
try {
|
try {
|
||||||
DefaultHttpClient httpClient = new DefaultHttpClient();
|
CloseableHttpClient httpClient = HttpClients.createDefault();
|
||||||
|
|
||||||
OzoneUtils.verifyBucketName(volumeName);
|
OzoneUtils.verifyBucketName(volumeName);
|
||||||
URIBuilder builder = new URIBuilder(endPointURI);
|
URIBuilder builder = new URIBuilder(endPointURI);
|
||||||
|
@ -205,7 +206,7 @@ public class OzoneClient implements Closeable {
|
||||||
public List<OzoneVolume> listVolumes(String onBehalfOf, String prefix, int
|
public List<OzoneVolume> listVolumes(String onBehalfOf, String prefix, int
|
||||||
maxKeys, OzoneVolume prevKey) throws OzoneException {
|
maxKeys, OzoneVolume prevKey) throws OzoneException {
|
||||||
try {
|
try {
|
||||||
DefaultHttpClient httpClient = new DefaultHttpClient();
|
CloseableHttpClient httpClient = HttpClients.createDefault();
|
||||||
|
|
||||||
URIBuilder builder = new URIBuilder(endPointURI);
|
URIBuilder builder = new URIBuilder(endPointURI);
|
||||||
if (prefix != null) {
|
if (prefix != null) {
|
||||||
|
@ -261,7 +262,7 @@ public class OzoneClient implements Closeable {
|
||||||
public List<OzoneVolume> listAllVolumes(String prefix, int maxKeys,
|
public List<OzoneVolume> listAllVolumes(String prefix, int maxKeys,
|
||||||
OzoneVolume prevKey) throws OzoneException {
|
OzoneVolume prevKey) throws OzoneException {
|
||||||
try {
|
try {
|
||||||
DefaultHttpClient httpClient = new DefaultHttpClient();
|
CloseableHttpClient httpClient = HttpClients.createDefault();
|
||||||
|
|
||||||
URIBuilder builder = new URIBuilder(endPointURI);
|
URIBuilder builder = new URIBuilder(endPointURI);
|
||||||
if (prefix != null) {
|
if (prefix != null) {
|
||||||
|
@ -296,7 +297,7 @@ public class OzoneClient implements Closeable {
|
||||||
*/
|
*/
|
||||||
public void deleteVolume(String volumeName) throws OzoneException {
|
public void deleteVolume(String volumeName) throws OzoneException {
|
||||||
try {
|
try {
|
||||||
DefaultHttpClient httpClient = new DefaultHttpClient();
|
CloseableHttpClient httpClient = HttpClients.createDefault();
|
||||||
|
|
||||||
OzoneUtils.verifyBucketName(volumeName);
|
OzoneUtils.verifyBucketName(volumeName);
|
||||||
URIBuilder builder = new URIBuilder(endPointURI);
|
URIBuilder builder = new URIBuilder(endPointURI);
|
||||||
|
@ -323,7 +324,7 @@ public class OzoneClient implements Closeable {
|
||||||
throw new OzoneClientException("Invalid new owner name");
|
throw new OzoneClientException("Invalid new owner name");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
DefaultHttpClient httpClient = new DefaultHttpClient();
|
CloseableHttpClient httpClient = HttpClients.createDefault();
|
||||||
|
|
||||||
OzoneUtils.verifyBucketName(volumeName);
|
OzoneUtils.verifyBucketName(volumeName);
|
||||||
URIBuilder builder = new URIBuilder(endPointURI);
|
URIBuilder builder = new URIBuilder(endPointURI);
|
||||||
|
@ -354,7 +355,7 @@ public class OzoneClient implements Closeable {
|
||||||
throw new OzoneClientException("Invalid quota");
|
throw new OzoneClientException("Invalid quota");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
DefaultHttpClient httpClient = new DefaultHttpClient();
|
CloseableHttpClient httpClient = HttpClients.createDefault();
|
||||||
|
|
||||||
OzoneUtils.verifyBucketName(volumeName);
|
OzoneUtils.verifyBucketName(volumeName);
|
||||||
URIBuilder builder = new URIBuilder(endPointURI);
|
URIBuilder builder = new URIBuilder(endPointURI);
|
||||||
|
@ -379,7 +380,7 @@ public class OzoneClient implements Closeable {
|
||||||
* @throws OzoneException
|
* @throws OzoneException
|
||||||
*/
|
*/
|
||||||
private void executeCreateVolume(HttpPost httppost,
|
private void executeCreateVolume(HttpPost httppost,
|
||||||
DefaultHttpClient httpClient)
|
CloseableHttpClient httpClient)
|
||||||
throws IOException, OzoneException {
|
throws IOException, OzoneException {
|
||||||
HttpEntity entity = null;
|
HttpEntity entity = null;
|
||||||
try {
|
try {
|
||||||
|
@ -412,7 +413,7 @@ public class OzoneClient implements Closeable {
|
||||||
* @throws OzoneException
|
* @throws OzoneException
|
||||||
*/
|
*/
|
||||||
private OzoneVolume executeInfoVolume(HttpGet httpGet,
|
private OzoneVolume executeInfoVolume(HttpGet httpGet,
|
||||||
DefaultHttpClient httpClient)
|
CloseableHttpClient httpClient)
|
||||||
throws IOException, OzoneException {
|
throws IOException, OzoneException {
|
||||||
HttpEntity entity = null;
|
HttpEntity entity = null;
|
||||||
try {
|
try {
|
||||||
|
@ -446,7 +447,7 @@ public class OzoneClient implements Closeable {
|
||||||
* @throws OzoneException
|
* @throws OzoneException
|
||||||
*/
|
*/
|
||||||
private void executePutVolume(HttpPut putRequest,
|
private void executePutVolume(HttpPut putRequest,
|
||||||
DefaultHttpClient httpClient)
|
CloseableHttpClient httpClient)
|
||||||
throws IOException, OzoneException {
|
throws IOException, OzoneException {
|
||||||
HttpEntity entity = null;
|
HttpEntity entity = null;
|
||||||
try {
|
try {
|
||||||
|
@ -472,7 +473,7 @@ public class OzoneClient implements Closeable {
|
||||||
* @throws OzoneException
|
* @throws OzoneException
|
||||||
*/
|
*/
|
||||||
private List<OzoneVolume> executeListVolume(HttpGet httpGet,
|
private List<OzoneVolume> executeListVolume(HttpGet httpGet,
|
||||||
DefaultHttpClient httpClient)
|
CloseableHttpClient httpClient)
|
||||||
throws IOException, OzoneException {
|
throws IOException, OzoneException {
|
||||||
HttpEntity entity = null;
|
HttpEntity entity = null;
|
||||||
List<OzoneVolume> volList = new LinkedList<>();
|
List<OzoneVolume> volList = new LinkedList<>();
|
||||||
|
@ -513,7 +514,7 @@ public class OzoneClient implements Closeable {
|
||||||
* @throws OzoneException
|
* @throws OzoneException
|
||||||
*/
|
*/
|
||||||
private void executeDeleteVolume(HttpDelete httpDelete,
|
private void executeDeleteVolume(HttpDelete httpDelete,
|
||||||
DefaultHttpClient httpClient)
|
CloseableHttpClient httpClient)
|
||||||
throws IOException, OzoneException {
|
throws IOException, OzoneException {
|
||||||
HttpEntity entity = null;
|
HttpEntity entity = null;
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -34,7 +34,8 @@ import org.apache.http.client.methods.HttpGet;
|
||||||
import org.apache.http.client.methods.HttpPost;
|
import org.apache.http.client.methods.HttpPost;
|
||||||
import org.apache.http.client.methods.HttpPut;
|
import org.apache.http.client.methods.HttpPut;
|
||||||
import org.apache.http.client.utils.URIBuilder;
|
import org.apache.http.client.utils.URIBuilder;
|
||||||
import org.apache.http.impl.client.DefaultHttpClient;
|
import org.apache.http.impl.client.CloseableHttpClient;
|
||||||
|
import org.apache.http.impl.client.HttpClients;
|
||||||
import org.apache.http.util.EntityUtils;
|
import org.apache.http.util.EntityUtils;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -165,7 +166,7 @@ public class OzoneVolume {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
OzoneUtils.verifyBucketName(bucketName);
|
OzoneUtils.verifyBucketName(bucketName);
|
||||||
DefaultHttpClient httpClient = new DefaultHttpClient();
|
CloseableHttpClient httpClient = HttpClients.createDefault();
|
||||||
URIBuilder builder = new URIBuilder(getClient().getEndPointURI());
|
URIBuilder builder = new URIBuilder(getClient().getEndPointURI());
|
||||||
builder.setPath("/" + getVolumeName() + "/" + bucketName).build();
|
builder.setPath("/" + getVolumeName() + "/" + bucketName).build();
|
||||||
|
|
||||||
|
@ -240,7 +241,7 @@ public class OzoneVolume {
|
||||||
* @throws OzoneException
|
* @throws OzoneException
|
||||||
*/
|
*/
|
||||||
private void executeCreateBucket(HttpPost httppost,
|
private void executeCreateBucket(HttpPost httppost,
|
||||||
DefaultHttpClient httpClient)
|
CloseableHttpClient httpClient)
|
||||||
throws IOException, OzoneException {
|
throws IOException, OzoneException {
|
||||||
HttpEntity entity = null;
|
HttpEntity entity = null;
|
||||||
try {
|
try {
|
||||||
|
@ -275,7 +276,7 @@ public class OzoneVolume {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
OzoneUtils.verifyBucketName(bucketName);
|
OzoneUtils.verifyBucketName(bucketName);
|
||||||
DefaultHttpClient httpClient = new DefaultHttpClient();
|
CloseableHttpClient httpClient = HttpClients.createDefault();
|
||||||
URIBuilder builder = new URIBuilder(getClient().getEndPointURI());
|
URIBuilder builder = new URIBuilder(getClient().getEndPointURI());
|
||||||
builder.setPath("/" + getVolumeName() + "/" + bucketName).build();
|
builder.setPath("/" + getVolumeName() + "/" + bucketName).build();
|
||||||
HttpPut putRequest = client.getHttpPut(builder.toString());
|
HttpPut putRequest = client.getHttpPut(builder.toString());
|
||||||
|
@ -302,7 +303,7 @@ public class OzoneVolume {
|
||||||
throws OzoneException {
|
throws OzoneException {
|
||||||
try {
|
try {
|
||||||
OzoneUtils.verifyBucketName(bucketName);
|
OzoneUtils.verifyBucketName(bucketName);
|
||||||
DefaultHttpClient httpClient = new DefaultHttpClient();
|
CloseableHttpClient httpClient = HttpClients.createDefault();
|
||||||
URIBuilder builder = new URIBuilder(getClient().getEndPointURI());
|
URIBuilder builder = new URIBuilder(getClient().getEndPointURI());
|
||||||
builder.setPath("/" + getVolumeName() + "/" + bucketName).build();
|
builder.setPath("/" + getVolumeName() + "/" + bucketName).build();
|
||||||
HttpPut putRequest = client.getHttpPut(builder.toString());
|
HttpPut putRequest = client.getHttpPut(builder.toString());
|
||||||
|
@ -327,7 +328,7 @@ public class OzoneVolume {
|
||||||
public OzoneBucket getBucket(String bucketName) throws OzoneException {
|
public OzoneBucket getBucket(String bucketName) throws OzoneException {
|
||||||
try {
|
try {
|
||||||
OzoneUtils.verifyBucketName(bucketName);
|
OzoneUtils.verifyBucketName(bucketName);
|
||||||
DefaultHttpClient httpClient = new DefaultHttpClient();
|
CloseableHttpClient httpClient = HttpClients.createDefault();
|
||||||
URIBuilder builder = new URIBuilder(getClient().getEndPointURI());
|
URIBuilder builder = new URIBuilder(getClient().getEndPointURI());
|
||||||
builder.setPath("/" + getVolumeName() + "/" + bucketName)
|
builder.setPath("/" + getVolumeName() + "/" + bucketName)
|
||||||
.setParameter(Header.OZONE_LIST_QUERY_TAG,
|
.setParameter(Header.OZONE_LIST_QUERY_TAG,
|
||||||
|
@ -353,7 +354,7 @@ public class OzoneVolume {
|
||||||
* @throws OzoneException
|
* @throws OzoneException
|
||||||
*/
|
*/
|
||||||
private OzoneBucket executeInfoBucket(HttpGet getRequest,
|
private OzoneBucket executeInfoBucket(HttpGet getRequest,
|
||||||
DefaultHttpClient httpClient)
|
CloseableHttpClient httpClient)
|
||||||
throws IOException, OzoneException {
|
throws IOException, OzoneException {
|
||||||
HttpEntity entity = null;
|
HttpEntity entity = null;
|
||||||
try {
|
try {
|
||||||
|
@ -389,7 +390,7 @@ public class OzoneVolume {
|
||||||
* @throws OzoneException
|
* @throws OzoneException
|
||||||
*/
|
*/
|
||||||
private void executePutBucket(HttpPut putRequest,
|
private void executePutBucket(HttpPut putRequest,
|
||||||
DefaultHttpClient httpClient)
|
CloseableHttpClient httpClient)
|
||||||
throws IOException, OzoneException {
|
throws IOException, OzoneException {
|
||||||
HttpEntity entity = null;
|
HttpEntity entity = null;
|
||||||
try {
|
try {
|
||||||
|
@ -422,7 +423,7 @@ public class OzoneVolume {
|
||||||
*/
|
*/
|
||||||
public List<OzoneBucket> listBuckets() throws OzoneException {
|
public List<OzoneBucket> listBuckets() throws OzoneException {
|
||||||
try {
|
try {
|
||||||
DefaultHttpClient httpClient = new DefaultHttpClient();
|
CloseableHttpClient httpClient = HttpClients.createDefault();
|
||||||
|
|
||||||
URIBuilder builder = new URIBuilder(getClient().getEndPointURI());
|
URIBuilder builder = new URIBuilder(getClient().getEndPointURI());
|
||||||
builder.setPath("/" + getVolumeName()).build();
|
builder.setPath("/" + getVolumeName()).build();
|
||||||
|
@ -447,7 +448,7 @@ public class OzoneVolume {
|
||||||
* @throws OzoneException
|
* @throws OzoneException
|
||||||
*/
|
*/
|
||||||
private List<OzoneBucket> executeListBuckets(HttpGet getRequest,
|
private List<OzoneBucket> executeListBuckets(HttpGet getRequest,
|
||||||
DefaultHttpClient httpClient)
|
CloseableHttpClient httpClient)
|
||||||
throws IOException, OzoneException {
|
throws IOException, OzoneException {
|
||||||
HttpEntity entity = null;
|
HttpEntity entity = null;
|
||||||
List<OzoneBucket> ozoneBucketList = new LinkedList<OzoneBucket>();
|
List<OzoneBucket> ozoneBucketList = new LinkedList<OzoneBucket>();
|
||||||
|
@ -489,7 +490,7 @@ public class OzoneVolume {
|
||||||
public void deleteBucket(String bucketName) throws OzoneException {
|
public void deleteBucket(String bucketName) throws OzoneException {
|
||||||
try {
|
try {
|
||||||
OzoneUtils.verifyBucketName(bucketName);
|
OzoneUtils.verifyBucketName(bucketName);
|
||||||
DefaultHttpClient httpClient = new DefaultHttpClient();
|
CloseableHttpClient httpClient = HttpClients.createDefault();
|
||||||
URIBuilder builder = new URIBuilder(getClient().getEndPointURI());
|
URIBuilder builder = new URIBuilder(getClient().getEndPointURI());
|
||||||
builder.setPath("/" + getVolumeName() + "/" + bucketName).build();
|
builder.setPath("/" + getVolumeName() + "/" + bucketName).build();
|
||||||
|
|
||||||
|
@ -511,7 +512,7 @@ public class OzoneVolume {
|
||||||
* @throws OzoneException
|
* @throws OzoneException
|
||||||
*/
|
*/
|
||||||
private void executeDeleteBucket(HttpDelete delRequest,
|
private void executeDeleteBucket(HttpDelete delRequest,
|
||||||
DefaultHttpClient httpClient)
|
CloseableHttpClient httpClient)
|
||||||
throws IOException, OzoneException {
|
throws IOException, OzoneException {
|
||||||
HttpEntity entity = null;
|
HttpEntity entity = null;
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -26,7 +26,7 @@ import org.apache.http.HttpResponse;
|
||||||
import org.apache.http.client.methods.HttpGet;
|
import org.apache.http.client.methods.HttpGet;
|
||||||
import org.apache.http.client.methods.HttpPost;
|
import org.apache.http.client.methods.HttpPost;
|
||||||
import org.apache.http.impl.client.CloseableHttpClient;
|
import org.apache.http.impl.client.CloseableHttpClient;
|
||||||
import org.apache.http.impl.client.HttpClientBuilder;
|
import org.apache.http.impl.client.HttpClients;
|
||||||
|
|
||||||
import javax.ws.rs.core.HttpHeaders;
|
import javax.ws.rs.core.HttpHeaders;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -44,7 +44,7 @@ import static org.junit.Assert.assertEquals;
|
||||||
public class TestOzoneHelper {
|
public class TestOzoneHelper {
|
||||||
|
|
||||||
public CloseableHttpClient createHttpClient() {
|
public CloseableHttpClient createHttpClient() {
|
||||||
return HttpClientBuilder.create().build();
|
return HttpClients.createDefault();
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Creates Volumes on Ozone Store.
|
* Creates Volumes on Ozone Store.
|
||||||
|
|
|
@ -27,9 +27,9 @@ import org.apache.hadoop.ozone.web.headers.Header;
|
||||||
import org.apache.hadoop.test.GenericTestUtils;
|
import org.apache.hadoop.test.GenericTestUtils;
|
||||||
import org.apache.hadoop.util.Time;
|
import org.apache.hadoop.util.Time;
|
||||||
import org.apache.http.HttpResponse;
|
import org.apache.http.HttpResponse;
|
||||||
import org.apache.http.client.HttpClient;
|
|
||||||
import org.apache.http.client.methods.HttpPost;
|
import org.apache.http.client.methods.HttpPost;
|
||||||
import org.apache.http.impl.client.DefaultHttpClient;
|
import org.apache.http.impl.client.CloseableHttpClient;
|
||||||
|
import org.apache.http.impl.client.HttpClients;
|
||||||
import org.junit.AfterClass;
|
import org.junit.AfterClass;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
|
@ -98,7 +98,7 @@ public class TestOzoneWebAccess {
|
||||||
public void testOzoneRequest() throws IOException {
|
public void testOzoneRequest() throws IOException {
|
||||||
SimpleDateFormat format =
|
SimpleDateFormat format =
|
||||||
new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss ZZZ", Locale.US);
|
new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss ZZZ", Locale.US);
|
||||||
HttpClient client = new DefaultHttpClient();
|
CloseableHttpClient client = HttpClients.createDefault();
|
||||||
String volumeName = getRequestID().toLowerCase(Locale.US);
|
String volumeName = getRequestID().toLowerCase(Locale.US);
|
||||||
try {
|
try {
|
||||||
HttpPost httppost = new HttpPost(
|
HttpPost httppost = new HttpPost(
|
||||||
|
@ -117,7 +117,7 @@ public class TestOzoneWebAccess {
|
||||||
assertEquals(response.toString(), HTTP_CREATED,
|
assertEquals(response.toString(), HTTP_CREATED,
|
||||||
response.getStatusLine().getStatusCode());
|
response.getStatusLine().getStatusCode());
|
||||||
} finally {
|
} finally {
|
||||||
client.getConnectionManager().shutdown();
|
client.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue