HDFS-12031. Ozone: Rename OzoneClient to OzoneRestClient. Contributed by Nandakumar.
This commit is contained in:
parent
7e834c839d
commit
8ef1163eca
|
@ -150,11 +150,11 @@ public class OzoneBucket {
|
||||||
*/
|
*/
|
||||||
public void putKey(String keyName, String data) throws OzoneException {
|
public void putKey(String keyName, String data) throws OzoneException {
|
||||||
if ((keyName == null) || keyName.isEmpty()) {
|
if ((keyName == null) || keyName.isEmpty()) {
|
||||||
throw new OzoneClientException("Invalid key Name.");
|
throw new OzoneRestClientException("Invalid key Name.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data == null) {
|
if (data == null) {
|
||||||
throw new OzoneClientException("Invalid data.");
|
throw new OzoneRestClientException("Invalid data.");
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpPut putRequest = null;
|
HttpPut putRequest = null;
|
||||||
|
@ -176,7 +176,7 @@ public class OzoneBucket {
|
||||||
}
|
}
|
||||||
executePutKey(putRequest, httpClient);
|
executePutKey(putRequest, httpClient);
|
||||||
} catch (IOException | URISyntaxException ex) {
|
} catch (IOException | URISyntaxException ex) {
|
||||||
throw new OzoneClientException(ex.getMessage());
|
throw new OzoneRestClientException(ex.getMessage());
|
||||||
} finally {
|
} finally {
|
||||||
IOUtils.closeStream(is);
|
IOUtils.closeStream(is);
|
||||||
OzoneClientUtils.releaseConnection(putRequest);
|
OzoneClientUtils.releaseConnection(putRequest);
|
||||||
|
@ -192,7 +192,7 @@ public class OzoneBucket {
|
||||||
*/
|
*/
|
||||||
public void putKey(File dataFile) throws OzoneException {
|
public void putKey(File dataFile) throws OzoneException {
|
||||||
if (dataFile == null) {
|
if (dataFile == null) {
|
||||||
throw new OzoneClientException("Invalid file object.");
|
throw new OzoneRestClientException("Invalid file object.");
|
||||||
}
|
}
|
||||||
String keyName = dataFile.getName();
|
String keyName = dataFile.getName();
|
||||||
putKey(keyName, dataFile);
|
putKey(keyName, dataFile);
|
||||||
|
@ -209,11 +209,11 @@ public class OzoneBucket {
|
||||||
throws OzoneException {
|
throws OzoneException {
|
||||||
|
|
||||||
if ((keyName == null) || keyName.isEmpty()) {
|
if ((keyName == null) || keyName.isEmpty()) {
|
||||||
throw new OzoneClientException("Invalid key Name");
|
throw new OzoneRestClientException("Invalid key Name");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file == null) {
|
if (file == null) {
|
||||||
throw new OzoneClientException("Invalid data stream");
|
throw new OzoneRestClientException("Invalid data stream");
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpPut putRequest = null;
|
HttpPut putRequest = null;
|
||||||
|
@ -234,7 +234,7 @@ public class OzoneBucket {
|
||||||
executePutKey(putRequest, httpClient);
|
executePutKey(putRequest, httpClient);
|
||||||
|
|
||||||
} catch (IOException | URISyntaxException ex) {
|
} catch (IOException | URISyntaxException ex) {
|
||||||
throw new OzoneClientException(ex.getMessage());
|
throw new OzoneRestClientException(ex.getMessage());
|
||||||
} finally {
|
} finally {
|
||||||
IOUtils.closeStream(fis);
|
IOUtils.closeStream(fis);
|
||||||
OzoneClientUtils.releaseConnection(putRequest);
|
OzoneClientUtils.releaseConnection(putRequest);
|
||||||
|
@ -262,7 +262,7 @@ public class OzoneBucket {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entity == null) {
|
if (entity == null) {
|
||||||
throw new OzoneClientException("Unexpected null in http payload");
|
throw new OzoneRestClientException("Unexpected null in http payload");
|
||||||
}
|
}
|
||||||
|
|
||||||
throw OzoneException.parse(EntityUtils.toString(entity));
|
throw OzoneException.parse(EntityUtils.toString(entity));
|
||||||
|
@ -283,11 +283,11 @@ public class OzoneBucket {
|
||||||
public void getKey(String keyName, Path downloadTo) throws OzoneException {
|
public void getKey(String keyName, Path downloadTo) throws OzoneException {
|
||||||
|
|
||||||
if ((keyName == null) || keyName.isEmpty()) {
|
if ((keyName == null) || keyName.isEmpty()) {
|
||||||
throw new OzoneClientException("Invalid key Name");
|
throw new OzoneRestClientException("Invalid key Name");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (downloadTo == null) {
|
if (downloadTo == null) {
|
||||||
throw new OzoneClientException("Invalid download path");
|
throw new OzoneRestClientException("Invalid download path");
|
||||||
}
|
}
|
||||||
|
|
||||||
FileOutputStream outPutFile = null;
|
FileOutputStream outPutFile = null;
|
||||||
|
@ -303,7 +303,7 @@ public class OzoneBucket {
|
||||||
executeGetKey(getRequest, httpClient, outPutFile);
|
executeGetKey(getRequest, httpClient, outPutFile);
|
||||||
outPutFile.flush();
|
outPutFile.flush();
|
||||||
} catch (IOException | URISyntaxException ex) {
|
} catch (IOException | URISyntaxException ex) {
|
||||||
throw new OzoneClientException(ex.getMessage());
|
throw new OzoneRestClientException(ex.getMessage());
|
||||||
} finally {
|
} finally {
|
||||||
IOUtils.closeStream(outPutFile);
|
IOUtils.closeStream(outPutFile);
|
||||||
OzoneClientUtils.releaseConnection(getRequest);
|
OzoneClientUtils.releaseConnection(getRequest);
|
||||||
|
@ -320,7 +320,7 @@ public class OzoneBucket {
|
||||||
public String getKey(String keyName) throws OzoneException {
|
public String getKey(String keyName) throws OzoneException {
|
||||||
|
|
||||||
if ((keyName == null) || keyName.isEmpty()) {
|
if ((keyName == null) || keyName.isEmpty()) {
|
||||||
throw new OzoneClientException("Invalid key Name");
|
throw new OzoneRestClientException("Invalid key Name");
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpGet getRequest = null;
|
HttpGet getRequest = null;
|
||||||
|
@ -337,7 +337,7 @@ public class OzoneBucket {
|
||||||
executeGetKey(getRequest, httpClient, outPutStream);
|
executeGetKey(getRequest, httpClient, outPutStream);
|
||||||
return outPutStream.toString(ENCODING_NAME);
|
return outPutStream.toString(ENCODING_NAME);
|
||||||
} catch (IOException | URISyntaxException ex) {
|
} catch (IOException | URISyntaxException ex) {
|
||||||
throw new OzoneClientException(ex.getMessage());
|
throw new OzoneRestClientException(ex.getMessage());
|
||||||
} finally {
|
} finally {
|
||||||
IOUtils.closeStream(outPutStream);
|
IOUtils.closeStream(outPutStream);
|
||||||
OzoneClientUtils.releaseConnection(getRequest);
|
OzoneClientUtils.releaseConnection(getRequest);
|
||||||
|
@ -371,7 +371,7 @@ public class OzoneBucket {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entity == null) {
|
if (entity == null) {
|
||||||
throw new OzoneClientException("Unexpected null in http payload");
|
throw new OzoneRestClientException("Unexpected null in http payload");
|
||||||
}
|
}
|
||||||
|
|
||||||
throw OzoneException.parse(EntityUtils.toString(entity));
|
throw OzoneException.parse(EntityUtils.toString(entity));
|
||||||
|
@ -391,7 +391,7 @@ public class OzoneBucket {
|
||||||
public void deleteKey(String keyName) throws OzoneException {
|
public void deleteKey(String keyName) throws OzoneException {
|
||||||
|
|
||||||
if ((keyName == null) || keyName.isEmpty()) {
|
if ((keyName == null) || keyName.isEmpty()) {
|
||||||
throw new OzoneClientException("Invalid key Name");
|
throw new OzoneRestClientException("Invalid key Name");
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpDelete deleteRequest = null;
|
HttpDelete deleteRequest = null;
|
||||||
|
@ -404,7 +404,7 @@ public class OzoneBucket {
|
||||||
.getClient().getHttpDelete(builder.toString());
|
.getClient().getHttpDelete(builder.toString());
|
||||||
executeDeleteKey(deleteRequest, httpClient);
|
executeDeleteKey(deleteRequest, httpClient);
|
||||||
} catch (IOException | URISyntaxException ex) {
|
} catch (IOException | URISyntaxException ex) {
|
||||||
throw new OzoneClientException(ex.getMessage());
|
throw new OzoneRestClientException(ex.getMessage());
|
||||||
} finally {
|
} finally {
|
||||||
OzoneClientUtils.releaseConnection(deleteRequest);
|
OzoneClientUtils.releaseConnection(deleteRequest);
|
||||||
}
|
}
|
||||||
|
@ -434,7 +434,7 @@ public class OzoneBucket {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entity == null) {
|
if (entity == null) {
|
||||||
throw new OzoneClientException("Unexpected null in http payload");
|
throw new OzoneRestClientException("Unexpected null in http payload");
|
||||||
}
|
}
|
||||||
|
|
||||||
throw OzoneException.parse(EntityUtils.toString(entity));
|
throw OzoneException.parse(EntityUtils.toString(entity));
|
||||||
|
@ -453,7 +453,7 @@ public class OzoneBucket {
|
||||||
public List<OzoneKey> listKeys() throws OzoneException {
|
public List<OzoneKey> listKeys() throws OzoneException {
|
||||||
HttpGet getRequest = null;
|
HttpGet getRequest = null;
|
||||||
try (CloseableHttpClient httpClient = OzoneClientUtils.newHttpClient()) {
|
try (CloseableHttpClient httpClient = OzoneClientUtils.newHttpClient()) {
|
||||||
OzoneClient client = getVolume().getClient();
|
OzoneRestClient client = getVolume().getClient();
|
||||||
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();
|
||||||
|
@ -462,7 +462,7 @@ public class OzoneBucket {
|
||||||
return executeListKeys(getRequest, httpClient);
|
return executeListKeys(getRequest, httpClient);
|
||||||
|
|
||||||
} catch (IOException | URISyntaxException e) {
|
} catch (IOException | URISyntaxException e) {
|
||||||
throw new OzoneClientException(e.getMessage());
|
throw new OzoneRestClientException(e.getMessage());
|
||||||
} finally {
|
} finally {
|
||||||
OzoneClientUtils.releaseConnection(getRequest);
|
OzoneClientUtils.releaseConnection(getRequest);
|
||||||
}
|
}
|
||||||
|
@ -489,7 +489,7 @@ public class OzoneBucket {
|
||||||
entity = response.getEntity();
|
entity = response.getEntity();
|
||||||
|
|
||||||
if (entity == null) {
|
if (entity == null) {
|
||||||
throw new OzoneClientException("Unexpected null in http payload");
|
throw new OzoneRestClientException("Unexpected null in http payload");
|
||||||
}
|
}
|
||||||
if (errorCode == HTTP_OK) {
|
if (errorCode == HTTP_OK) {
|
||||||
String temp = EntityUtils.toString(entity);
|
String temp = EntityUtils.toString(entity);
|
||||||
|
|
|
@ -54,28 +54,28 @@ import static java.net.HttpURLConnection.HTTP_OK;
|
||||||
* Ozone client that connects to an Ozone server. Please note that this class is
|
* Ozone client that connects to an Ozone server. Please note that this class is
|
||||||
* not thread safe.
|
* not thread safe.
|
||||||
*/
|
*/
|
||||||
public class OzoneClient implements Closeable {
|
public class OzoneRestClient implements Closeable {
|
||||||
private URI endPointURI;
|
private URI endPointURI;
|
||||||
private String userAuth;
|
private String userAuth;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for OzoneClient.
|
* Constructor for OzoneRestClient.
|
||||||
*/
|
*/
|
||||||
public OzoneClient() {
|
public OzoneRestClient() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for OzoneClient.
|
* Constructor for OzoneRestClient.
|
||||||
*/
|
*/
|
||||||
public OzoneClient(String ozoneURI)
|
public OzoneRestClient(String ozoneURI)
|
||||||
throws OzoneException, URISyntaxException {
|
throws OzoneException, URISyntaxException {
|
||||||
setEndPoint(ozoneURI);
|
setEndPoint(ozoneURI);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for OzoneClient.
|
* Constructor for OzoneRestClient.
|
||||||
*/
|
*/
|
||||||
public OzoneClient(String ozoneURI, String userAuth)
|
public OzoneRestClient(String ozoneURI, String userAuth)
|
||||||
throws OzoneException, URISyntaxException {
|
throws OzoneException, URISyntaxException {
|
||||||
setEndPoint(ozoneURI);
|
setEndPoint(ozoneURI);
|
||||||
setUserAuth(userAuth);
|
setUserAuth(userAuth);
|
||||||
|
@ -98,7 +98,7 @@ public class OzoneClient implements Closeable {
|
||||||
*/
|
*/
|
||||||
public void setEndPointURI(URI endPointURI) throws OzoneException {
|
public void setEndPointURI(URI endPointURI) throws OzoneException {
|
||||||
if ((endPointURI == null) || (endPointURI.toString().isEmpty())) {
|
if ((endPointURI == null) || (endPointURI.toString().isEmpty())) {
|
||||||
throw new OzoneClientException("Invalid ozone URI");
|
throw new OzoneRestClientException("Invalid ozone URI");
|
||||||
}
|
}
|
||||||
this.endPointURI = endPointURI;
|
this.endPointURI = endPointURI;
|
||||||
}
|
}
|
||||||
|
@ -138,7 +138,7 @@ public class OzoneClient implements Closeable {
|
||||||
* @param onBehalfOf - The user on behalf we are making the call for
|
* @param onBehalfOf - The user on behalf we are making the call for
|
||||||
* @param quota - Quota's are specified in a specific format. it is
|
* @param quota - Quota's are specified in a specific format. it is
|
||||||
* integer(MB|GB|TB), for example 100TB.
|
* integer(MB|GB|TB), for example 100TB.
|
||||||
* @throws OzoneClientException
|
* @throws OzoneRestClientException
|
||||||
*/
|
*/
|
||||||
public OzoneVolume createVolume(String volumeName, String onBehalfOf,
|
public OzoneVolume createVolume(String volumeName, String onBehalfOf,
|
||||||
String quota) throws OzoneException {
|
String quota) throws OzoneException {
|
||||||
|
@ -156,7 +156,7 @@ public class OzoneClient implements Closeable {
|
||||||
executeCreateVolume(httpPost, httpClient);
|
executeCreateVolume(httpPost, httpClient);
|
||||||
return getVolume(volumeName);
|
return getVolume(volumeName);
|
||||||
} catch (IOException | URISyntaxException | IllegalArgumentException ex) {
|
} catch (IOException | URISyntaxException | IllegalArgumentException ex) {
|
||||||
throw new OzoneClientException(ex.getMessage());
|
throw new OzoneRestClientException(ex.getMessage());
|
||||||
} finally {
|
} finally {
|
||||||
OzoneClientUtils.releaseConnection(httpPost);
|
OzoneClientUtils.releaseConnection(httpPost);
|
||||||
}
|
}
|
||||||
|
@ -183,7 +183,7 @@ public class OzoneClient implements Closeable {
|
||||||
httpGet = getHttpGet(builder.toString());
|
httpGet = getHttpGet(builder.toString());
|
||||||
return executeInfoVolume(httpGet, httpClient);
|
return executeInfoVolume(httpGet, httpClient);
|
||||||
} catch (IOException | URISyntaxException | IllegalArgumentException ex) {
|
} catch (IOException | URISyntaxException | IllegalArgumentException ex) {
|
||||||
throw new OzoneClientException(ex.getMessage());
|
throw new OzoneRestClientException(ex.getMessage());
|
||||||
} finally {
|
} finally {
|
||||||
OzoneClientUtils.releaseConnection(httpGet);
|
OzoneClientUtils.releaseConnection(httpGet);
|
||||||
}
|
}
|
||||||
|
@ -232,7 +232,7 @@ public class OzoneClient implements Closeable {
|
||||||
}
|
}
|
||||||
return executeListVolume(httpGet, httpClient);
|
return executeListVolume(httpGet, httpClient);
|
||||||
} catch (IOException | URISyntaxException ex) {
|
} catch (IOException | URISyntaxException ex) {
|
||||||
throw new OzoneClientException(ex.getMessage());
|
throw new OzoneRestClientException(ex.getMessage());
|
||||||
} finally {
|
} finally {
|
||||||
OzoneClientUtils.releaseConnection(httpGet);
|
OzoneClientUtils.releaseConnection(httpGet);
|
||||||
}
|
}
|
||||||
|
@ -286,7 +286,7 @@ public class OzoneClient implements Closeable {
|
||||||
return executeListVolume(httpGet, httpClient);
|
return executeListVolume(httpGet, httpClient);
|
||||||
|
|
||||||
} catch (IOException | URISyntaxException ex) {
|
} catch (IOException | URISyntaxException ex) {
|
||||||
throw new OzoneClientException(ex.getMessage());
|
throw new OzoneRestClientException(ex.getMessage());
|
||||||
} finally {
|
} finally {
|
||||||
OzoneClientUtils.releaseConnection(httpGet);
|
OzoneClientUtils.releaseConnection(httpGet);
|
||||||
}
|
}
|
||||||
|
@ -308,7 +308,7 @@ public class OzoneClient implements Closeable {
|
||||||
httpDelete = getHttpDelete(builder.toString());
|
httpDelete = getHttpDelete(builder.toString());
|
||||||
executeDeleteVolume(httpDelete, httpClient);
|
executeDeleteVolume(httpDelete, httpClient);
|
||||||
} catch (IOException | URISyntaxException | IllegalArgumentException ex) {
|
} catch (IOException | URISyntaxException | IllegalArgumentException ex) {
|
||||||
throw new OzoneClientException(ex.getMessage());
|
throw new OzoneRestClientException(ex.getMessage());
|
||||||
} finally {
|
} finally {
|
||||||
OzoneClientUtils.releaseConnection(httpDelete);
|
OzoneClientUtils.releaseConnection(httpDelete);
|
||||||
}
|
}
|
||||||
|
@ -325,7 +325,7 @@ public class OzoneClient implements Closeable {
|
||||||
throws OzoneException {
|
throws OzoneException {
|
||||||
HttpPut putRequest = null;
|
HttpPut putRequest = null;
|
||||||
if (newOwner == null || newOwner.isEmpty()) {
|
if (newOwner == null || newOwner.isEmpty()) {
|
||||||
throw new OzoneClientException("Invalid new owner name");
|
throw new OzoneRestClientException("Invalid new owner name");
|
||||||
}
|
}
|
||||||
try (CloseableHttpClient httpClient = newHttpClient()) {
|
try (CloseableHttpClient httpClient = newHttpClient()) {
|
||||||
OzoneUtils.verifyBucketName(volumeName);
|
OzoneUtils.verifyBucketName(volumeName);
|
||||||
|
@ -337,7 +337,7 @@ public class OzoneClient implements Closeable {
|
||||||
executePutVolume(putRequest, httpClient);
|
executePutVolume(putRequest, httpClient);
|
||||||
|
|
||||||
} catch (URISyntaxException | IllegalArgumentException | IOException ex) {
|
} catch (URISyntaxException | IllegalArgumentException | IOException ex) {
|
||||||
throw new OzoneClientException(ex.getMessage());
|
throw new OzoneRestClientException(ex.getMessage());
|
||||||
} finally {
|
} finally {
|
||||||
OzoneClientUtils.releaseConnection(putRequest);
|
OzoneClientUtils.releaseConnection(putRequest);
|
||||||
}
|
}
|
||||||
|
@ -356,7 +356,7 @@ public class OzoneClient implements Closeable {
|
||||||
public void setVolumeQuota(String volumeName, String quota)
|
public void setVolumeQuota(String volumeName, String quota)
|
||||||
throws OzoneException {
|
throws OzoneException {
|
||||||
if (quota == null || quota.isEmpty()) {
|
if (quota == null || quota.isEmpty()) {
|
||||||
throw new OzoneClientException("Invalid quota");
|
throw new OzoneRestClientException("Invalid quota");
|
||||||
}
|
}
|
||||||
HttpPut putRequest = null;
|
HttpPut putRequest = null;
|
||||||
try (CloseableHttpClient httpClient = newHttpClient()) {
|
try (CloseableHttpClient httpClient = newHttpClient()) {
|
||||||
|
@ -370,7 +370,7 @@ public class OzoneClient implements Closeable {
|
||||||
executePutVolume(putRequest, httpClient);
|
executePutVolume(putRequest, httpClient);
|
||||||
|
|
||||||
} catch (URISyntaxException | IllegalArgumentException | IOException ex) {
|
} catch (URISyntaxException | IllegalArgumentException | IOException ex) {
|
||||||
throw new OzoneClientException(ex.getMessage());
|
throw new OzoneRestClientException(ex.getMessage());
|
||||||
} finally {
|
} finally {
|
||||||
OzoneClientUtils.releaseConnection(putRequest);
|
OzoneClientUtils.releaseConnection(putRequest);
|
||||||
}
|
}
|
||||||
|
@ -400,7 +400,7 @@ public class OzoneClient implements Closeable {
|
||||||
if (entity != null) {
|
if (entity != null) {
|
||||||
throw OzoneException.parse(EntityUtils.toString(entity));
|
throw OzoneException.parse(EntityUtils.toString(entity));
|
||||||
} else {
|
} else {
|
||||||
throw new OzoneClientException("Unexpected null in http payload");
|
throw new OzoneRestClientException("Unexpected null in http payload");
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
if (entity != null) {
|
if (entity != null) {
|
||||||
|
@ -427,7 +427,7 @@ public class OzoneClient implements Closeable {
|
||||||
|
|
||||||
entity = response.getEntity();
|
entity = response.getEntity();
|
||||||
if (entity == null) {
|
if (entity == null) {
|
||||||
throw new OzoneClientException("Unexpected null in http payload");
|
throw new OzoneRestClientException("Unexpected null in http payload");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (errorCode == HTTP_OK) {
|
if (errorCode == HTTP_OK) {
|
||||||
|
@ -488,7 +488,7 @@ public class OzoneClient implements Closeable {
|
||||||
entity = response.getEntity();
|
entity = response.getEntity();
|
||||||
|
|
||||||
if (entity == null) {
|
if (entity == null) {
|
||||||
throw new OzoneClientException("Unexpected null in http payload");
|
throw new OzoneRestClientException("Unexpected null in http payload");
|
||||||
}
|
}
|
||||||
|
|
||||||
String temp = EntityUtils.toString(entity);
|
String temp = EntityUtils.toString(entity);
|
|
@ -22,13 +22,13 @@ import org.apache.hadoop.ozone.web.exceptions.OzoneException;
|
||||||
/**
|
/**
|
||||||
* This exception is thrown by the Ozone Clients.
|
* This exception is thrown by the Ozone Clients.
|
||||||
*/
|
*/
|
||||||
public class OzoneClientException extends OzoneException {
|
public class OzoneRestClientException extends OzoneException {
|
||||||
/**
|
/**
|
||||||
* Constructor that allows the shortMessage.
|
* Constructor that allows the shortMessage.
|
||||||
*
|
*
|
||||||
* @param shortMessage Short Message
|
* @param shortMessage Short Message
|
||||||
*/
|
*/
|
||||||
public OzoneClientException(String shortMessage) {
|
public OzoneRestClientException(String shortMessage) {
|
||||||
super(0, shortMessage, shortMessage);
|
super(0, shortMessage, shortMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ public class OzoneClientException extends OzoneException {
|
||||||
* @param shortMessage Short Message
|
* @param shortMessage Short Message
|
||||||
* @param message long error message
|
* @param message long error message
|
||||||
*/
|
*/
|
||||||
public OzoneClientException(String shortMessage, String message) {
|
public OzoneRestClientException(String shortMessage, String message) {
|
||||||
super(0, shortMessage, message);
|
super(0, shortMessage, message);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -55,12 +55,12 @@ import static java.net.HttpURLConnection.HTTP_OK;
|
||||||
public class OzoneVolume {
|
public class OzoneVolume {
|
||||||
private VolumeInfo volumeInfo;
|
private VolumeInfo volumeInfo;
|
||||||
private Map<String, String> headerMap;
|
private Map<String, String> headerMap;
|
||||||
private final OzoneClient client;
|
private final OzoneRestClient client;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for OzoneVolume.
|
* Constructor for OzoneVolume.
|
||||||
*/
|
*/
|
||||||
public OzoneVolume(OzoneClient client) {
|
public OzoneVolume(OzoneRestClient client) {
|
||||||
this.client = client;
|
this.client = client;
|
||||||
this.headerMap = new HashMap<>();
|
this.headerMap = new HashMap<>();
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,7 @@ public class OzoneVolume {
|
||||||
* @param volInfo - volume Info.
|
* @param volInfo - volume Info.
|
||||||
* @param client Client
|
* @param client Client
|
||||||
*/
|
*/
|
||||||
public OzoneVolume(VolumeInfo volInfo, OzoneClient client) {
|
public OzoneVolume(VolumeInfo volInfo, OzoneRestClient client) {
|
||||||
this.volumeInfo = volInfo;
|
this.volumeInfo = volInfo;
|
||||||
this.client = client;
|
this.client = client;
|
||||||
}
|
}
|
||||||
|
@ -145,7 +145,7 @@ public class OzoneVolume {
|
||||||
*
|
*
|
||||||
* @return - Ozone Client
|
* @return - Ozone Client
|
||||||
*/
|
*/
|
||||||
OzoneClient getClient() {
|
OzoneRestClient getClient() {
|
||||||
return client;
|
return client;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,7 +184,7 @@ public class OzoneVolume {
|
||||||
executeCreateBucket(httpPost, httpClient);
|
executeCreateBucket(httpPost, httpClient);
|
||||||
return getBucket(bucketName);
|
return getBucket(bucketName);
|
||||||
} catch (IOException | URISyntaxException | IllegalArgumentException ex) {
|
} catch (IOException | URISyntaxException | IllegalArgumentException ex) {
|
||||||
throw new OzoneClientException(ex.getMessage());
|
throw new OzoneRestClientException(ex.getMessage());
|
||||||
} finally {
|
} finally {
|
||||||
OzoneClientUtils.releaseConnection(httpPost);
|
OzoneClientUtils.releaseConnection(httpPost);
|
||||||
}
|
}
|
||||||
|
@ -257,7 +257,7 @@ public class OzoneVolume {
|
||||||
if (entity != null) {
|
if (entity != null) {
|
||||||
throw OzoneException.parse(EntityUtils.toString(entity));
|
throw OzoneException.parse(EntityUtils.toString(entity));
|
||||||
} else {
|
} else {
|
||||||
throw new OzoneClientException("Unexpected null in http payload");
|
throw new OzoneRestClientException("Unexpected null in http payload");
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
if (entity != null) {
|
if (entity != null) {
|
||||||
|
@ -288,7 +288,7 @@ public class OzoneVolume {
|
||||||
}
|
}
|
||||||
executePutBucket(putRequest, httpClient);
|
executePutBucket(putRequest, httpClient);
|
||||||
} catch (URISyntaxException | IOException ex) {
|
} catch (URISyntaxException | IOException ex) {
|
||||||
throw new OzoneClientException(ex.getMessage());
|
throw new OzoneRestClientException(ex.getMessage());
|
||||||
} finally {
|
} finally {
|
||||||
OzoneClientUtils.releaseConnection(putRequest);
|
OzoneClientUtils.releaseConnection(putRequest);
|
||||||
}
|
}
|
||||||
|
@ -317,7 +317,7 @@ public class OzoneVolume {
|
||||||
}
|
}
|
||||||
executePutBucket(putRequest, httpClient);
|
executePutBucket(putRequest, httpClient);
|
||||||
} catch (URISyntaxException | IOException ex) {
|
} catch (URISyntaxException | IOException ex) {
|
||||||
throw new OzoneClientException(ex.getMessage());
|
throw new OzoneRestClientException(ex.getMessage());
|
||||||
} finally {
|
} finally {
|
||||||
OzoneClientUtils.releaseConnection(putRequest);
|
OzoneClientUtils.releaseConnection(putRequest);
|
||||||
}
|
}
|
||||||
|
@ -342,7 +342,7 @@ public class OzoneVolume {
|
||||||
return executeInfoBucket(getRequest, httpClient);
|
return executeInfoBucket(getRequest, httpClient);
|
||||||
|
|
||||||
} catch (IOException | URISyntaxException | IllegalArgumentException ex) {
|
} catch (IOException | URISyntaxException | IllegalArgumentException ex) {
|
||||||
throw new OzoneClientException(ex.getMessage());
|
throw new OzoneRestClientException(ex.getMessage());
|
||||||
} finally {
|
} finally {
|
||||||
OzoneClientUtils.releaseConnection(getRequest);
|
OzoneClientUtils.releaseConnection(getRequest);
|
||||||
}
|
}
|
||||||
|
@ -369,7 +369,7 @@ public class OzoneVolume {
|
||||||
int errorCode = response.getStatusLine().getStatusCode();
|
int errorCode = response.getStatusLine().getStatusCode();
|
||||||
entity = response.getEntity();
|
entity = response.getEntity();
|
||||||
if (entity == null) {
|
if (entity == null) {
|
||||||
throw new OzoneClientException("Unexpected null in http payload");
|
throw new OzoneRestClientException("Unexpected null in http payload");
|
||||||
}
|
}
|
||||||
if ((errorCode == HTTP_OK) || (errorCode == HTTP_CREATED)) {
|
if ((errorCode == HTTP_OK) || (errorCode == HTTP_CREATED)) {
|
||||||
OzoneBucket bucket =
|
OzoneBucket bucket =
|
||||||
|
@ -413,7 +413,7 @@ public class OzoneVolume {
|
||||||
throw OzoneException.parse(EntityUtils.toString(entity));
|
throw OzoneException.parse(EntityUtils.toString(entity));
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new OzoneClientException("Unexpected null in http result");
|
throw new OzoneRestClientException("Unexpected null in http result");
|
||||||
} finally {
|
} finally {
|
||||||
if (entity != null) {
|
if (entity != null) {
|
||||||
EntityUtils.consumeQuietly(entity);
|
EntityUtils.consumeQuietly(entity);
|
||||||
|
@ -438,7 +438,7 @@ public class OzoneVolume {
|
||||||
return executeListBuckets(getRequest, httpClient);
|
return executeListBuckets(getRequest, httpClient);
|
||||||
|
|
||||||
} catch (IOException | URISyntaxException e) {
|
} catch (IOException | URISyntaxException e) {
|
||||||
throw new OzoneClientException(e.getMessage());
|
throw new OzoneRestClientException(e.getMessage());
|
||||||
} finally {
|
} finally {
|
||||||
OzoneClientUtils.releaseConnection(getRequest);
|
OzoneClientUtils.releaseConnection(getRequest);
|
||||||
}
|
}
|
||||||
|
@ -467,7 +467,7 @@ public class OzoneVolume {
|
||||||
entity = response.getEntity();
|
entity = response.getEntity();
|
||||||
|
|
||||||
if (entity == null) {
|
if (entity == null) {
|
||||||
throw new OzoneClientException("Unexpected null in http payload");
|
throw new OzoneRestClientException("Unexpected null in http payload");
|
||||||
}
|
}
|
||||||
if (errorCode == HTTP_OK) {
|
if (errorCode == HTTP_OK) {
|
||||||
ListBuckets bucketList =
|
ListBuckets bucketList =
|
||||||
|
@ -506,7 +506,7 @@ public class OzoneVolume {
|
||||||
executeDeleteBucket(delRequest, httpClient);
|
executeDeleteBucket(delRequest, httpClient);
|
||||||
|
|
||||||
} catch (IOException | URISyntaxException | IllegalArgumentException ex) {
|
} catch (IOException | URISyntaxException | IllegalArgumentException ex) {
|
||||||
throw new OzoneClientException(ex.getMessage());
|
throw new OzoneRestClientException(ex.getMessage());
|
||||||
} finally {
|
} finally {
|
||||||
OzoneClientUtils.releaseConnection(delRequest);
|
OzoneClientUtils.releaseConnection(delRequest);
|
||||||
}
|
}
|
||||||
|
@ -535,7 +535,7 @@ public class OzoneVolume {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entity == null) {
|
if (entity == null) {
|
||||||
throw new OzoneClientException("Unexpected null in http payload.");
|
throw new OzoneRestClientException("Unexpected null in http payload.");
|
||||||
}
|
}
|
||||||
|
|
||||||
throw OzoneException.parse(EntityUtils.toString(entity));
|
throw OzoneException.parse(EntityUtils.toString(entity));
|
||||||
|
|
|
@ -19,8 +19,8 @@
|
||||||
package org.apache.hadoop.ozone.web.ozShell;
|
package org.apache.hadoop.ozone.web.ozShell;
|
||||||
|
|
||||||
import org.apache.commons.cli.CommandLine;
|
import org.apache.commons.cli.CommandLine;
|
||||||
import org.apache.hadoop.ozone.web.client.OzoneClient;
|
import org.apache.hadoop.ozone.web.client.OzoneRestClient;
|
||||||
import org.apache.hadoop.ozone.web.client.OzoneClientException;
|
import org.apache.hadoop.ozone.web.client.OzoneRestClientException;
|
||||||
import org.apache.hadoop.ozone.web.exceptions.OzoneException;
|
import org.apache.hadoop.ozone.web.exceptions.OzoneException;
|
||||||
import org.apache.http.client.utils.URIBuilder;
|
import org.apache.http.client.utils.URIBuilder;
|
||||||
|
|
||||||
|
@ -32,13 +32,13 @@ import java.net.URISyntaxException;
|
||||||
* Common interface for command handling.
|
* Common interface for command handling.
|
||||||
*/
|
*/
|
||||||
public abstract class Handler {
|
public abstract class Handler {
|
||||||
protected OzoneClient client;
|
protected OzoneRestClient client;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a client object.
|
* Constructs a client object.
|
||||||
*/
|
*/
|
||||||
public Handler() {
|
public Handler() {
|
||||||
client = new OzoneClient();
|
client = new OzoneRestClient();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -63,7 +63,7 @@ public abstract class Handler {
|
||||||
protected URI verifyURI(String uri) throws URISyntaxException,
|
protected URI verifyURI(String uri) throws URISyntaxException,
|
||||||
OzoneException {
|
OzoneException {
|
||||||
if ((uri == null) || uri.isEmpty()) {
|
if ((uri == null) || uri.isEmpty()) {
|
||||||
throw new OzoneClientException(
|
throw new OzoneRestClientException(
|
||||||
"Ozone URI is needed to execute this command.");
|
"Ozone URI is needed to execute this command.");
|
||||||
}
|
}
|
||||||
URIBuilder ozoneURI = new URIBuilder(uri);
|
URIBuilder ozoneURI = new URIBuilder(uri);
|
||||||
|
|
|
@ -19,7 +19,7 @@ package org.apache.hadoop.ozone.web.ozShell.bucket;
|
||||||
|
|
||||||
import org.apache.commons.cli.CommandLine;
|
import org.apache.commons.cli.CommandLine;
|
||||||
import org.apache.hadoop.ozone.web.client.OzoneBucket;
|
import org.apache.hadoop.ozone.web.client.OzoneBucket;
|
||||||
import org.apache.hadoop.ozone.web.client.OzoneClientException;
|
import org.apache.hadoop.ozone.web.client.OzoneRestClientException;
|
||||||
import org.apache.hadoop.ozone.web.client.OzoneVolume;
|
import org.apache.hadoop.ozone.web.client.OzoneVolume;
|
||||||
import org.apache.hadoop.ozone.web.exceptions.OzoneException;
|
import org.apache.hadoop.ozone.web.exceptions.OzoneException;
|
||||||
import org.apache.hadoop.ozone.web.ozShell.Handler;
|
import org.apache.hadoop.ozone.web.ozShell.Handler;
|
||||||
|
@ -54,7 +54,7 @@ public class CreateBucketHandler extends Handler {
|
||||||
protected void execute(CommandLine cmd)
|
protected void execute(CommandLine cmd)
|
||||||
throws IOException, OzoneException, URISyntaxException {
|
throws IOException, OzoneException, URISyntaxException {
|
||||||
if (!cmd.hasOption(Shell.CREATE_BUCKET)) {
|
if (!cmd.hasOption(Shell.CREATE_BUCKET)) {
|
||||||
throw new OzoneClientException(
|
throw new OzoneRestClientException(
|
||||||
"Incorrect call : createBucket is missing");
|
"Incorrect call : createBucket is missing");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ public class CreateBucketHandler extends Handler {
|
||||||
URI ozoneURI = verifyURI(ozoneURIString);
|
URI ozoneURI = verifyURI(ozoneURIString);
|
||||||
Path path = Paths.get(ozoneURI.getPath());
|
Path path = Paths.get(ozoneURI.getPath());
|
||||||
if (path.getNameCount() < 2) {
|
if (path.getNameCount() < 2) {
|
||||||
throw new OzoneClientException(
|
throw new OzoneRestClientException(
|
||||||
"volume and bucket name required in createBucket");
|
"volume and bucket name required in createBucket");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
package org.apache.hadoop.ozone.web.ozShell.bucket;
|
package org.apache.hadoop.ozone.web.ozShell.bucket;
|
||||||
|
|
||||||
import org.apache.commons.cli.CommandLine;
|
import org.apache.commons.cli.CommandLine;
|
||||||
import org.apache.hadoop.ozone.web.client.OzoneClientException;
|
import org.apache.hadoop.ozone.web.client.OzoneRestClientException;
|
||||||
import org.apache.hadoop.ozone.web.client.OzoneVolume;
|
import org.apache.hadoop.ozone.web.client.OzoneVolume;
|
||||||
import org.apache.hadoop.ozone.web.exceptions.OzoneException;
|
import org.apache.hadoop.ozone.web.exceptions.OzoneException;
|
||||||
import org.apache.hadoop.ozone.web.ozShell.Handler;
|
import org.apache.hadoop.ozone.web.ozShell.Handler;
|
||||||
|
@ -52,7 +52,7 @@ public class DeleteBucketHandler extends Handler {
|
||||||
protected void execute(CommandLine cmd)
|
protected void execute(CommandLine cmd)
|
||||||
throws IOException, OzoneException, URISyntaxException {
|
throws IOException, OzoneException, URISyntaxException {
|
||||||
if (!cmd.hasOption(Shell.DELETE_BUCKET)) {
|
if (!cmd.hasOption(Shell.DELETE_BUCKET)) {
|
||||||
throw new OzoneClientException(
|
throw new OzoneRestClientException(
|
||||||
"Incorrect call : deleteBucket is missing");
|
"Incorrect call : deleteBucket is missing");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ public class DeleteBucketHandler extends Handler {
|
||||||
URI ozoneURI = verifyURI(ozoneURIString);
|
URI ozoneURI = verifyURI(ozoneURIString);
|
||||||
Path path = Paths.get(ozoneURI.getPath());
|
Path path = Paths.get(ozoneURI.getPath());
|
||||||
if (path.getNameCount() < 2) {
|
if (path.getNameCount() < 2) {
|
||||||
throw new OzoneClientException(
|
throw new OzoneRestClientException(
|
||||||
"volume and bucket name required in delete Bucket");
|
"volume and bucket name required in delete Bucket");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ package org.apache.hadoop.ozone.web.ozShell.bucket;
|
||||||
|
|
||||||
import org.apache.commons.cli.CommandLine;
|
import org.apache.commons.cli.CommandLine;
|
||||||
import org.apache.hadoop.ozone.web.client.OzoneBucket;
|
import org.apache.hadoop.ozone.web.client.OzoneBucket;
|
||||||
import org.apache.hadoop.ozone.web.client.OzoneClientException;
|
import org.apache.hadoop.ozone.web.client.OzoneRestClientException;
|
||||||
import org.apache.hadoop.ozone.web.client.OzoneVolume;
|
import org.apache.hadoop.ozone.web.client.OzoneVolume;
|
||||||
import org.apache.hadoop.ozone.web.exceptions.OzoneException;
|
import org.apache.hadoop.ozone.web.exceptions.OzoneException;
|
||||||
import org.apache.hadoop.ozone.web.ozShell.Handler;
|
import org.apache.hadoop.ozone.web.ozShell.Handler;
|
||||||
|
@ -54,7 +54,7 @@ public class InfoBucketHandler extends Handler {
|
||||||
protected void execute(CommandLine cmd)
|
protected void execute(CommandLine cmd)
|
||||||
throws IOException, OzoneException, URISyntaxException {
|
throws IOException, OzoneException, URISyntaxException {
|
||||||
if (!cmd.hasOption(Shell.INFO_BUCKET)) {
|
if (!cmd.hasOption(Shell.INFO_BUCKET)) {
|
||||||
throw new OzoneClientException(
|
throw new OzoneRestClientException(
|
||||||
"Incorrect call : infoBucket is missing");
|
"Incorrect call : infoBucket is missing");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ public class InfoBucketHandler extends Handler {
|
||||||
Path path = Paths.get(ozoneURI.getPath());
|
Path path = Paths.get(ozoneURI.getPath());
|
||||||
|
|
||||||
if (path.getNameCount() < 2) {
|
if (path.getNameCount() < 2) {
|
||||||
throw new OzoneClientException(
|
throw new OzoneRestClientException(
|
||||||
"volume and bucket name required in info Bucket");
|
"volume and bucket name required in info Bucket");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ package org.apache.hadoop.ozone.web.ozShell.bucket;
|
||||||
|
|
||||||
import org.apache.commons.cli.CommandLine;
|
import org.apache.commons.cli.CommandLine;
|
||||||
import org.apache.hadoop.ozone.web.client.OzoneBucket;
|
import org.apache.hadoop.ozone.web.client.OzoneBucket;
|
||||||
import org.apache.hadoop.ozone.web.client.OzoneClientException;
|
import org.apache.hadoop.ozone.web.client.OzoneRestClientException;
|
||||||
import org.apache.hadoop.ozone.web.client.OzoneVolume;
|
import org.apache.hadoop.ozone.web.client.OzoneVolume;
|
||||||
import org.apache.hadoop.ozone.web.exceptions.OzoneException;
|
import org.apache.hadoop.ozone.web.exceptions.OzoneException;
|
||||||
import org.apache.hadoop.ozone.web.ozShell.Handler;
|
import org.apache.hadoop.ozone.web.ozShell.Handler;
|
||||||
|
@ -54,14 +54,15 @@ public class ListBucketHandler extends Handler {
|
||||||
protected void execute(CommandLine cmd)
|
protected void execute(CommandLine cmd)
|
||||||
throws IOException, OzoneException, URISyntaxException {
|
throws IOException, OzoneException, URISyntaxException {
|
||||||
if (!cmd.hasOption(Shell.LIST_BUCKET)) {
|
if (!cmd.hasOption(Shell.LIST_BUCKET)) {
|
||||||
throw new OzoneClientException("Incorrect call : listBucket is missing");
|
throw new OzoneRestClientException(
|
||||||
|
"Incorrect call : listBucket is missing");
|
||||||
}
|
}
|
||||||
|
|
||||||
String ozoneURIString = cmd.getOptionValue(Shell.LIST_BUCKET);
|
String ozoneURIString = cmd.getOptionValue(Shell.LIST_BUCKET);
|
||||||
URI ozoneURI = verifyURI(ozoneURIString);
|
URI ozoneURI = verifyURI(ozoneURIString);
|
||||||
Path path = Paths.get(ozoneURI.getPath());
|
Path path = Paths.get(ozoneURI.getPath());
|
||||||
if (path.getNameCount() < 1) {
|
if (path.getNameCount() < 1) {
|
||||||
throw new OzoneClientException("volume is required in listBucket");
|
throw new OzoneRestClientException("volume is required in listBucket");
|
||||||
}
|
}
|
||||||
|
|
||||||
volumeName = path.getName(0).toString();
|
volumeName = path.getName(0).toString();
|
||||||
|
|
|
@ -19,7 +19,7 @@ package org.apache.hadoop.ozone.web.ozShell.bucket;
|
||||||
|
|
||||||
import org.apache.commons.cli.CommandLine;
|
import org.apache.commons.cli.CommandLine;
|
||||||
import org.apache.hadoop.ozone.web.client.OzoneBucket;
|
import org.apache.hadoop.ozone.web.client.OzoneBucket;
|
||||||
import org.apache.hadoop.ozone.web.client.OzoneClientException;
|
import org.apache.hadoop.ozone.web.client.OzoneRestClientException;
|
||||||
import org.apache.hadoop.ozone.web.client.OzoneVolume;
|
import org.apache.hadoop.ozone.web.client.OzoneVolume;
|
||||||
import org.apache.hadoop.ozone.web.exceptions.OzoneException;
|
import org.apache.hadoop.ozone.web.exceptions.OzoneException;
|
||||||
import org.apache.hadoop.ozone.web.ozShell.Handler;
|
import org.apache.hadoop.ozone.web.ozShell.Handler;
|
||||||
|
@ -44,7 +44,7 @@ public class UpdateBucketHandler extends Handler {
|
||||||
protected void execute(CommandLine cmd)
|
protected void execute(CommandLine cmd)
|
||||||
throws IOException, OzoneException, URISyntaxException {
|
throws IOException, OzoneException, URISyntaxException {
|
||||||
if (!cmd.hasOption(Shell.UPDATE_BUCKET)) {
|
if (!cmd.hasOption(Shell.UPDATE_BUCKET)) {
|
||||||
throw new OzoneClientException(
|
throw new OzoneRestClientException(
|
||||||
"Incorrect call : updateBucket is missing");
|
"Incorrect call : updateBucket is missing");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ public class UpdateBucketHandler extends Handler {
|
||||||
Path path = Paths.get(ozoneURI.getPath());
|
Path path = Paths.get(ozoneURI.getPath());
|
||||||
|
|
||||||
if (path.getNameCount() < 2) {
|
if (path.getNameCount() < 2) {
|
||||||
throw new OzoneClientException(
|
throw new OzoneRestClientException(
|
||||||
"volume and bucket name required in update bucket");
|
"volume and bucket name required in update bucket");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ package org.apache.hadoop.ozone.web.ozShell.keys;
|
||||||
|
|
||||||
import org.apache.commons.cli.CommandLine;
|
import org.apache.commons.cli.CommandLine;
|
||||||
import org.apache.hadoop.ozone.web.client.OzoneBucket;
|
import org.apache.hadoop.ozone.web.client.OzoneBucket;
|
||||||
import org.apache.hadoop.ozone.web.client.OzoneClientException;
|
import org.apache.hadoop.ozone.web.client.OzoneRestClientException;
|
||||||
import org.apache.hadoop.ozone.web.client.OzoneVolume;
|
import org.apache.hadoop.ozone.web.client.OzoneVolume;
|
||||||
import org.apache.hadoop.ozone.web.exceptions.OzoneException;
|
import org.apache.hadoop.ozone.web.exceptions.OzoneException;
|
||||||
import org.apache.hadoop.ozone.web.ozShell.Handler;
|
import org.apache.hadoop.ozone.web.ozShell.Handler;
|
||||||
|
@ -53,7 +53,8 @@ public class DeleteKeyHandler extends Handler {
|
||||||
protected void execute(CommandLine cmd)
|
protected void execute(CommandLine cmd)
|
||||||
throws IOException, OzoneException, URISyntaxException {
|
throws IOException, OzoneException, URISyntaxException {
|
||||||
if (!cmd.hasOption(Shell.DELETE_KEY)) {
|
if (!cmd.hasOption(Shell.DELETE_KEY)) {
|
||||||
throw new OzoneClientException("Incorrect call : deleteKey is missing");
|
throw new OzoneRestClientException(
|
||||||
|
"Incorrect call : deleteKey is missing");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -68,7 +69,7 @@ public class DeleteKeyHandler extends Handler {
|
||||||
URI ozoneURI = verifyURI(ozoneURIString);
|
URI ozoneURI = verifyURI(ozoneURIString);
|
||||||
Path path = Paths.get(ozoneURI.getPath());
|
Path path = Paths.get(ozoneURI.getPath());
|
||||||
if (path.getNameCount() < 3) {
|
if (path.getNameCount() < 3) {
|
||||||
throw new OzoneClientException(
|
throw new OzoneRestClientException(
|
||||||
"volume/bucket/key name required in deleteKey");
|
"volume/bucket/key name required in deleteKey");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ package org.apache.hadoop.ozone.web.ozShell.keys;
|
||||||
import org.apache.commons.cli.CommandLine;
|
import org.apache.commons.cli.CommandLine;
|
||||||
import org.apache.commons.codec.digest.DigestUtils;
|
import org.apache.commons.codec.digest.DigestUtils;
|
||||||
import org.apache.hadoop.ozone.web.client.OzoneBucket;
|
import org.apache.hadoop.ozone.web.client.OzoneBucket;
|
||||||
import org.apache.hadoop.ozone.web.client.OzoneClientException;
|
import org.apache.hadoop.ozone.web.client.OzoneRestClientException;
|
||||||
import org.apache.hadoop.ozone.web.client.OzoneVolume;
|
import org.apache.hadoop.ozone.web.client.OzoneVolume;
|
||||||
import org.apache.hadoop.ozone.web.exceptions.OzoneException;
|
import org.apache.hadoop.ozone.web.exceptions.OzoneException;
|
||||||
import org.apache.hadoop.ozone.web.ozShell.Handler;
|
import org.apache.hadoop.ozone.web.ozShell.Handler;
|
||||||
|
@ -58,11 +58,11 @@ public class GetKeyHandler extends Handler {
|
||||||
protected void execute(CommandLine cmd)
|
protected void execute(CommandLine cmd)
|
||||||
throws IOException, OzoneException, URISyntaxException {
|
throws IOException, OzoneException, URISyntaxException {
|
||||||
if (!cmd.hasOption(Shell.GET_KEY)) {
|
if (!cmd.hasOption(Shell.GET_KEY)) {
|
||||||
throw new OzoneClientException("Incorrect call : getKey is missing");
|
throw new OzoneRestClientException("Incorrect call : getKey is missing");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!cmd.hasOption(Shell.FILE)) {
|
if (!cmd.hasOption(Shell.FILE)) {
|
||||||
throw new OzoneClientException(
|
throw new OzoneRestClientException(
|
||||||
"get key needs a file path to download to");
|
"get key needs a file path to download to");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ public class GetKeyHandler extends Handler {
|
||||||
URI ozoneURI = verifyURI(ozoneURIString);
|
URI ozoneURI = verifyURI(ozoneURIString);
|
||||||
Path path = Paths.get(ozoneURI.getPath());
|
Path path = Paths.get(ozoneURI.getPath());
|
||||||
if (path.getNameCount() < 3) {
|
if (path.getNameCount() < 3) {
|
||||||
throw new OzoneClientException(
|
throw new OzoneRestClientException(
|
||||||
"volume/bucket/key name required in putKey");
|
"volume/bucket/key name required in putKey");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@ public class GetKeyHandler extends Handler {
|
||||||
|
|
||||||
|
|
||||||
if (dataFile.exists()) {
|
if (dataFile.exists()) {
|
||||||
throw new OzoneClientException(fileName +
|
throw new OzoneRestClientException(fileName +
|
||||||
"exists. Download will overwrite an " +
|
"exists. Download will overwrite an " +
|
||||||
"existing file. Aborting.");
|
"existing file. Aborting.");
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
package org.apache.hadoop.ozone.web.ozShell.keys;
|
package org.apache.hadoop.ozone.web.ozShell.keys;
|
||||||
|
|
||||||
import org.apache.commons.cli.CommandLine;
|
import org.apache.commons.cli.CommandLine;
|
||||||
import org.apache.hadoop.ozone.web.client.OzoneClientException;
|
import org.apache.hadoop.ozone.web.client.OzoneRestClientException;
|
||||||
import org.apache.hadoop.ozone.web.exceptions.OzoneException;
|
import org.apache.hadoop.ozone.web.exceptions.OzoneException;
|
||||||
import org.apache.hadoop.ozone.web.ozShell.Handler;
|
import org.apache.hadoop.ozone.web.ozShell.Handler;
|
||||||
import org.apache.hadoop.ozone.web.ozShell.Shell;
|
import org.apache.hadoop.ozone.web.ozShell.Shell;
|
||||||
|
@ -51,7 +51,7 @@ public class InfoKeyHandler extends Handler {
|
||||||
protected void execute(CommandLine cmd)
|
protected void execute(CommandLine cmd)
|
||||||
throws IOException, OzoneException, URISyntaxException {
|
throws IOException, OzoneException, URISyntaxException {
|
||||||
if (!cmd.hasOption(Shell.INFO_KEY)) {
|
if (!cmd.hasOption(Shell.INFO_KEY)) {
|
||||||
throw new OzoneClientException("Incorrect call : infoKey is missing");
|
throw new OzoneRestClientException("Incorrect call : infoKey is missing");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ public class InfoKeyHandler extends Handler {
|
||||||
URI ozoneURI = verifyURI(ozoneURIString);
|
URI ozoneURI = verifyURI(ozoneURIString);
|
||||||
Path path = Paths.get(ozoneURI.getPath());
|
Path path = Paths.get(ozoneURI.getPath());
|
||||||
if (path.getNameCount() < 3) {
|
if (path.getNameCount() < 3) {
|
||||||
throw new OzoneClientException(
|
throw new OzoneRestClientException(
|
||||||
"volume/bucket/key name required in infoKey");
|
"volume/bucket/key name required in infoKey");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,6 +88,6 @@ public class InfoKeyHandler extends Handler {
|
||||||
// OzoneVolume vol = client.getVolume(volumeName);
|
// OzoneVolume vol = client.getVolume(volumeName);
|
||||||
// OzoneBucket bucket = vol.createBucket(bucketName);
|
// OzoneBucket bucket = vol.createBucket(bucketName);
|
||||||
|
|
||||||
throw new OzoneClientException("Not supported yet");
|
throw new OzoneRestClientException("Not supported yet");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ package org.apache.hadoop.ozone.web.ozShell.keys;
|
||||||
|
|
||||||
import org.apache.commons.cli.CommandLine;
|
import org.apache.commons.cli.CommandLine;
|
||||||
import org.apache.hadoop.ozone.web.client.OzoneBucket;
|
import org.apache.hadoop.ozone.web.client.OzoneBucket;
|
||||||
import org.apache.hadoop.ozone.web.client.OzoneClientException;
|
import org.apache.hadoop.ozone.web.client.OzoneRestClientException;
|
||||||
import org.apache.hadoop.ozone.web.client.OzoneKey;
|
import org.apache.hadoop.ozone.web.client.OzoneKey;
|
||||||
import org.apache.hadoop.ozone.web.client.OzoneVolume;
|
import org.apache.hadoop.ozone.web.client.OzoneVolume;
|
||||||
import org.apache.hadoop.ozone.web.exceptions.OzoneException;
|
import org.apache.hadoop.ozone.web.exceptions.OzoneException;
|
||||||
|
@ -56,14 +56,16 @@ public class ListKeyHandler extends Handler {
|
||||||
throws IOException, OzoneException, URISyntaxException {
|
throws IOException, OzoneException, URISyntaxException {
|
||||||
|
|
||||||
if (!cmd.hasOption(Shell.LIST_KEY)) {
|
if (!cmd.hasOption(Shell.LIST_KEY)) {
|
||||||
throw new OzoneClientException("Incorrect call : listKey is missing");
|
throw new OzoneRestClientException(
|
||||||
|
"Incorrect call : listKey is missing");
|
||||||
}
|
}
|
||||||
|
|
||||||
String ozoneURIString = cmd.getOptionValue(Shell.LIST_KEY);
|
String ozoneURIString = cmd.getOptionValue(Shell.LIST_KEY);
|
||||||
URI ozoneURI = verifyURI(ozoneURIString);
|
URI ozoneURI = verifyURI(ozoneURIString);
|
||||||
Path path = Paths.get(ozoneURI.getPath());
|
Path path = Paths.get(ozoneURI.getPath());
|
||||||
if (path.getNameCount() < 2) {
|
if (path.getNameCount() < 2) {
|
||||||
throw new OzoneClientException("volume/bucket is required in listKey");
|
throw new OzoneRestClientException(
|
||||||
|
"volume/bucket is required in listKey");
|
||||||
}
|
}
|
||||||
|
|
||||||
volumeName = path.getName(0).toString();
|
volumeName = path.getName(0).toString();
|
||||||
|
|
|
@ -21,7 +21,7 @@ package org.apache.hadoop.ozone.web.ozShell.keys;
|
||||||
import org.apache.commons.cli.CommandLine;
|
import org.apache.commons.cli.CommandLine;
|
||||||
import org.apache.commons.codec.digest.DigestUtils;
|
import org.apache.commons.codec.digest.DigestUtils;
|
||||||
import org.apache.hadoop.ozone.web.client.OzoneBucket;
|
import org.apache.hadoop.ozone.web.client.OzoneBucket;
|
||||||
import org.apache.hadoop.ozone.web.client.OzoneClientException;
|
import org.apache.hadoop.ozone.web.client.OzoneRestClientException;
|
||||||
import org.apache.hadoop.ozone.web.client.OzoneVolume;
|
import org.apache.hadoop.ozone.web.client.OzoneVolume;
|
||||||
import org.apache.hadoop.ozone.web.exceptions.OzoneException;
|
import org.apache.hadoop.ozone.web.exceptions.OzoneException;
|
||||||
import org.apache.hadoop.ozone.web.ozShell.Handler;
|
import org.apache.hadoop.ozone.web.ozShell.Handler;
|
||||||
|
@ -56,11 +56,11 @@ public class PutKeyHandler extends Handler {
|
||||||
protected void execute(CommandLine cmd)
|
protected void execute(CommandLine cmd)
|
||||||
throws IOException, OzoneException, URISyntaxException {
|
throws IOException, OzoneException, URISyntaxException {
|
||||||
if (!cmd.hasOption(Shell.PUT_KEY)) {
|
if (!cmd.hasOption(Shell.PUT_KEY)) {
|
||||||
throw new OzoneClientException("Incorrect call : putKey is missing");
|
throw new OzoneRestClientException("Incorrect call : putKey is missing");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!cmd.hasOption(Shell.FILE)) {
|
if (!cmd.hasOption(Shell.FILE)) {
|
||||||
throw new OzoneClientException("put key needs a file to put");
|
throw new OzoneRestClientException("put key needs a file to put");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cmd.hasOption(Shell.USER)) {
|
if (cmd.hasOption(Shell.USER)) {
|
||||||
|
@ -73,7 +73,7 @@ public class PutKeyHandler extends Handler {
|
||||||
URI ozoneURI = verifyURI(ozoneURIString);
|
URI ozoneURI = verifyURI(ozoneURIString);
|
||||||
Path path = Paths.get(ozoneURI.getPath());
|
Path path = Paths.get(ozoneURI.getPath());
|
||||||
if (path.getNameCount() < 3) {
|
if (path.getNameCount() < 3) {
|
||||||
throw new OzoneClientException(
|
throw new OzoneRestClientException(
|
||||||
"volume/bucket/key name required in putKey");
|
"volume/bucket/key name required in putKey");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
package org.apache.hadoop.ozone.web.ozShell.volume;
|
package org.apache.hadoop.ozone.web.ozShell.volume;
|
||||||
|
|
||||||
import org.apache.commons.cli.CommandLine;
|
import org.apache.commons.cli.CommandLine;
|
||||||
import org.apache.hadoop.ozone.web.client.OzoneClientException;
|
import org.apache.hadoop.ozone.web.client.OzoneRestClientException;
|
||||||
import org.apache.hadoop.ozone.web.client.OzoneVolume;
|
import org.apache.hadoop.ozone.web.client.OzoneVolume;
|
||||||
import org.apache.hadoop.ozone.web.exceptions.OzoneException;
|
import org.apache.hadoop.ozone.web.exceptions.OzoneException;
|
||||||
import org.apache.hadoop.ozone.web.ozShell.Handler;
|
import org.apache.hadoop.ozone.web.ozShell.Handler;
|
||||||
|
@ -52,14 +52,14 @@ public class CreateVolumeHandler extends Handler {
|
||||||
protected void execute(CommandLine cmd)
|
protected void execute(CommandLine cmd)
|
||||||
throws IOException, OzoneException, URISyntaxException {
|
throws IOException, OzoneException, URISyntaxException {
|
||||||
if (!cmd.hasOption(Shell.CREATE_VOLUME)) {
|
if (!cmd.hasOption(Shell.CREATE_VOLUME)) {
|
||||||
throw new OzoneClientException(
|
throw new OzoneRestClientException(
|
||||||
"Incorrect call : createVolume is missing");
|
"Incorrect call : createVolume is missing");
|
||||||
}
|
}
|
||||||
|
|
||||||
String ozoneURIString = cmd.getOptionValue(Shell.CREATE_VOLUME);
|
String ozoneURIString = cmd.getOptionValue(Shell.CREATE_VOLUME);
|
||||||
URI ozoneURI = verifyURI(ozoneURIString);
|
URI ozoneURI = verifyURI(ozoneURIString);
|
||||||
if (ozoneURI.getPath().isEmpty()) {
|
if (ozoneURI.getPath().isEmpty()) {
|
||||||
throw new OzoneClientException(
|
throw new OzoneRestClientException(
|
||||||
"Volume name is required to create a volume");
|
"Volume name is required to create a volume");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ public class CreateVolumeHandler extends Handler {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!cmd.hasOption(Shell.USER)) {
|
if (!cmd.hasOption(Shell.USER)) {
|
||||||
throw new OzoneClientException(
|
throw new OzoneRestClientException(
|
||||||
"User name is needed in createVolume call.");
|
"User name is needed in createVolume call.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
package org.apache.hadoop.ozone.web.ozShell.volume;
|
package org.apache.hadoop.ozone.web.ozShell.volume;
|
||||||
|
|
||||||
import org.apache.commons.cli.CommandLine;
|
import org.apache.commons.cli.CommandLine;
|
||||||
import org.apache.hadoop.ozone.web.client.OzoneClientException;
|
import org.apache.hadoop.ozone.web.client.OzoneRestClientException;
|
||||||
import org.apache.hadoop.ozone.web.exceptions.OzoneException;
|
import org.apache.hadoop.ozone.web.exceptions.OzoneException;
|
||||||
import org.apache.hadoop.ozone.web.ozShell.Handler;
|
import org.apache.hadoop.ozone.web.ozShell.Handler;
|
||||||
import org.apache.hadoop.ozone.web.ozShell.Shell;
|
import org.apache.hadoop.ozone.web.ozShell.Shell;
|
||||||
|
@ -49,14 +49,14 @@ public class DeleteVolumeHandler extends Handler {
|
||||||
throws IOException, OzoneException, URISyntaxException {
|
throws IOException, OzoneException, URISyntaxException {
|
||||||
|
|
||||||
if (!cmd.hasOption(Shell.DELETE_VOLUME)) {
|
if (!cmd.hasOption(Shell.DELETE_VOLUME)) {
|
||||||
throw new OzoneClientException(
|
throw new OzoneRestClientException(
|
||||||
"Incorrect call : deleteVolume call is missing");
|
"Incorrect call : deleteVolume call is missing");
|
||||||
}
|
}
|
||||||
|
|
||||||
String ozoneURIString = cmd.getOptionValue(Shell.DELETE_VOLUME);
|
String ozoneURIString = cmd.getOptionValue(Shell.DELETE_VOLUME);
|
||||||
URI ozoneURI = verifyURI(ozoneURIString);
|
URI ozoneURI = verifyURI(ozoneURIString);
|
||||||
if (ozoneURI.getPath().isEmpty()) {
|
if (ozoneURI.getPath().isEmpty()) {
|
||||||
throw new OzoneClientException(
|
throw new OzoneRestClientException(
|
||||||
"Volume name is required to delete a volume");
|
"Volume name is required to delete a volume");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
package org.apache.hadoop.ozone.web.ozShell.volume;
|
package org.apache.hadoop.ozone.web.ozShell.volume;
|
||||||
|
|
||||||
import org.apache.commons.cli.CommandLine;
|
import org.apache.commons.cli.CommandLine;
|
||||||
import org.apache.hadoop.ozone.web.client.OzoneClientException;
|
import org.apache.hadoop.ozone.web.client.OzoneRestClientException;
|
||||||
import org.apache.hadoop.ozone.web.client.OzoneVolume;
|
import org.apache.hadoop.ozone.web.client.OzoneVolume;
|
||||||
import org.apache.hadoop.ozone.web.exceptions.OzoneException;
|
import org.apache.hadoop.ozone.web.exceptions.OzoneException;
|
||||||
import org.apache.hadoop.ozone.web.ozShell.Handler;
|
import org.apache.hadoop.ozone.web.ozShell.Handler;
|
||||||
|
@ -53,14 +53,14 @@ public class InfoVolumeHandler extends Handler{
|
||||||
throws IOException, OzoneException, URISyntaxException {
|
throws IOException, OzoneException, URISyntaxException {
|
||||||
|
|
||||||
if (!cmd.hasOption(Shell.INFO_VOLUME)) {
|
if (!cmd.hasOption(Shell.INFO_VOLUME)) {
|
||||||
throw new OzoneClientException(
|
throw new OzoneRestClientException(
|
||||||
"Incorrect call : infoVolume is missing");
|
"Incorrect call : infoVolume is missing");
|
||||||
}
|
}
|
||||||
|
|
||||||
String ozoneURIString = cmd.getOptionValue(Shell.INFO_VOLUME);
|
String ozoneURIString = cmd.getOptionValue(Shell.INFO_VOLUME);
|
||||||
URI ozoneURI = verifyURI(ozoneURIString);
|
URI ozoneURI = verifyURI(ozoneURIString);
|
||||||
if (ozoneURI.getPath().isEmpty()) {
|
if (ozoneURI.getPath().isEmpty()) {
|
||||||
throw new OzoneClientException(
|
throw new OzoneRestClientException(
|
||||||
"Volume name is required to get info of a volume");
|
"Volume name is required to get info of a volume");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
package org.apache.hadoop.ozone.web.ozShell.volume;
|
package org.apache.hadoop.ozone.web.ozShell.volume;
|
||||||
|
|
||||||
import org.apache.commons.cli.CommandLine;
|
import org.apache.commons.cli.CommandLine;
|
||||||
import org.apache.hadoop.ozone.web.client.OzoneClientException;
|
import org.apache.hadoop.ozone.web.client.OzoneRestClientException;
|
||||||
import org.apache.hadoop.ozone.web.client.OzoneVolume;
|
import org.apache.hadoop.ozone.web.client.OzoneVolume;
|
||||||
import org.apache.hadoop.ozone.web.exceptions.OzoneException;
|
import org.apache.hadoop.ozone.web.exceptions.OzoneException;
|
||||||
import org.apache.hadoop.ozone.web.ozShell.Handler;
|
import org.apache.hadoop.ozone.web.ozShell.Handler;
|
||||||
|
@ -51,7 +51,7 @@ public class ListVolumeHandler extends Handler {
|
||||||
throws IOException, OzoneException, URISyntaxException {
|
throws IOException, OzoneException, URISyntaxException {
|
||||||
|
|
||||||
if (!cmd.hasOption(Shell.LIST_VOLUME)) {
|
if (!cmd.hasOption(Shell.LIST_VOLUME)) {
|
||||||
throw new OzoneClientException(
|
throw new OzoneRestClientException(
|
||||||
"Incorrect call : listVolume is missing");
|
"Incorrect call : listVolume is missing");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ public class ListVolumeHandler extends Handler {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!cmd.hasOption(Shell.USER)) {
|
if (!cmd.hasOption(Shell.USER)) {
|
||||||
throw new OzoneClientException(
|
throw new OzoneRestClientException(
|
||||||
"User name is needed in listVolume call.");
|
"User name is needed in listVolume call.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
package org.apache.hadoop.ozone.web.ozShell.volume;
|
package org.apache.hadoop.ozone.web.ozShell.volume;
|
||||||
|
|
||||||
import org.apache.commons.cli.CommandLine;
|
import org.apache.commons.cli.CommandLine;
|
||||||
import org.apache.hadoop.ozone.web.client.OzoneClientException;
|
import org.apache.hadoop.ozone.web.client.OzoneRestClientException;
|
||||||
import org.apache.hadoop.ozone.web.exceptions.OzoneException;
|
import org.apache.hadoop.ozone.web.exceptions.OzoneException;
|
||||||
import org.apache.hadoop.ozone.web.ozShell.Handler;
|
import org.apache.hadoop.ozone.web.ozShell.Handler;
|
||||||
import org.apache.hadoop.ozone.web.ozShell.Shell;
|
import org.apache.hadoop.ozone.web.ozShell.Shell;
|
||||||
|
@ -49,14 +49,14 @@ public class UpdateVolumeHandler extends Handler {
|
||||||
protected void execute(CommandLine cmd)
|
protected void execute(CommandLine cmd)
|
||||||
throws IOException, OzoneException, URISyntaxException {
|
throws IOException, OzoneException, URISyntaxException {
|
||||||
if (!cmd.hasOption(Shell.UPDATE_VOLUME)) {
|
if (!cmd.hasOption(Shell.UPDATE_VOLUME)) {
|
||||||
throw new OzoneClientException(
|
throw new OzoneRestClientException(
|
||||||
"Incorrect call : updateVolume is missing");
|
"Incorrect call : updateVolume is missing");
|
||||||
}
|
}
|
||||||
|
|
||||||
String ozoneURIString = cmd.getOptionValue(Shell.UPDATE_VOLUME);
|
String ozoneURIString = cmd.getOptionValue(Shell.UPDATE_VOLUME);
|
||||||
URI ozoneURI = verifyURI(ozoneURIString);
|
URI ozoneURI = verifyURI(ozoneURIString);
|
||||||
if (ozoneURI.getPath().isEmpty()) {
|
if (ozoneURI.getPath().isEmpty()) {
|
||||||
throw new OzoneClientException(
|
throw new OzoneRestClientException(
|
||||||
"Volume name is required to update a volume");
|
"Volume name is required to update a volume");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,13 +30,13 @@ import org.apache.hadoop.net.NetUtils;
|
||||||
import org.apache.hadoop.ozone.container.ContainerTestHelper;
|
import org.apache.hadoop.ozone.container.ContainerTestHelper;
|
||||||
import org.apache.hadoop.ozone.ksm.KSMConfigKeys;
|
import org.apache.hadoop.ozone.ksm.KSMConfigKeys;
|
||||||
import org.apache.hadoop.ozone.ksm.KeySpaceManager;
|
import org.apache.hadoop.ozone.ksm.KeySpaceManager;
|
||||||
|
import org.apache.hadoop.ozone.web.client.OzoneRestClient;
|
||||||
import org.apache.hadoop.scm.ScmConfigKeys;
|
import org.apache.hadoop.scm.ScmConfigKeys;
|
||||||
import org.apache.hadoop.scm.protocolPB
|
import org.apache.hadoop.scm.protocolPB
|
||||||
.StorageContainerLocationProtocolClientSideTranslatorPB;
|
.StorageContainerLocationProtocolClientSideTranslatorPB;
|
||||||
import org.apache.hadoop.scm.protocolPB.StorageContainerLocationProtocolPB;
|
import org.apache.hadoop.scm.protocolPB.StorageContainerLocationProtocolPB;
|
||||||
import org.apache.hadoop.ozone.scm.StorageContainerManager;
|
import org.apache.hadoop.ozone.scm.StorageContainerManager;
|
||||||
import org.apache.hadoop.ozone.scm.node.SCMNodeManager;
|
import org.apache.hadoop.ozone.scm.node.SCMNodeManager;
|
||||||
import org.apache.hadoop.ozone.web.client.OzoneClient;
|
|
||||||
import org.apache.hadoop.ozone.web.exceptions.OzoneException;
|
import org.apache.hadoop.ozone.web.exceptions.OzoneException;
|
||||||
import org.apache.hadoop.security.UserGroupInformation;
|
import org.apache.hadoop.security.UserGroupInformation;
|
||||||
import org.apache.hadoop.test.GenericTestUtils;
|
import org.apache.hadoop.test.GenericTestUtils;
|
||||||
|
@ -170,15 +170,15 @@ public final class MiniOzoneCluster extends MiniDFSCluster
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an {@link OzoneClient} connected to this cluster's REST service.
|
* Creates an {@link OzoneRestClient} connected to this cluster's REST
|
||||||
* Callers take ownership of the client and must close it when done.
|
* service. Callers take ownership of the client and must close it when done.
|
||||||
*
|
*
|
||||||
* @return OzoneClient connected to this cluster's REST service
|
* @return OzoneRestClient connected to this cluster's REST service
|
||||||
* @throws OzoneException if Ozone encounters an error creating the client
|
* @throws OzoneException if Ozone encounters an error creating the client
|
||||||
*/
|
*/
|
||||||
public OzoneClient createOzoneClient() throws OzoneException {
|
public OzoneRestClient createOzoneRestClient() throws OzoneException {
|
||||||
Preconditions.checkState(!getDataNodes().isEmpty(),
|
Preconditions.checkState(!getDataNodes().isEmpty(),
|
||||||
"Cannot create OzoneClient if the cluster has no DataNodes.");
|
"Cannot create OzoneRestClient if the cluster has no DataNodes.");
|
||||||
// An Ozone request may originate at any DataNode, so pick one at random.
|
// An Ozone request may originate at any DataNode, so pick one at random.
|
||||||
int dnIndex = new Random().nextInt(getDataNodes().size());
|
int dnIndex = new Random().nextInt(getDataNodes().size());
|
||||||
String uri = String.format("http://127.0.0.1:%d",
|
String uri = String.format("http://127.0.0.1:%d",
|
||||||
|
@ -186,7 +186,7 @@ public final class MiniOzoneCluster extends MiniDFSCluster
|
||||||
LOG.info("Creating Ozone client to DataNode {} with URI {} and user {}",
|
LOG.info("Creating Ozone client to DataNode {} with URI {} and user {}",
|
||||||
dnIndex, uri, USER_AUTH);
|
dnIndex, uri, USER_AUTH);
|
||||||
try {
|
try {
|
||||||
return new OzoneClient(uri, USER_AUTH);
|
return new OzoneRestClient(uri, USER_AUTH);
|
||||||
} catch (URISyntaxException e) {
|
} catch (URISyntaxException e) {
|
||||||
// We control the REST service URI, so it should never be invalid.
|
// We control the REST service URI, so it should never be invalid.
|
||||||
throw new IllegalStateException("Unexpected URISyntaxException", e);
|
throw new IllegalStateException("Unexpected URISyntaxException", e);
|
||||||
|
|
|
@ -25,6 +25,7 @@ import static org.junit.Assert.*;
|
||||||
|
|
||||||
import org.apache.commons.lang.RandomStringUtils;
|
import org.apache.commons.lang.RandomStringUtils;
|
||||||
import org.apache.hadoop.ozone.OzoneConsts;
|
import org.apache.hadoop.ozone.OzoneConsts;
|
||||||
|
import org.apache.hadoop.ozone.web.client.OzoneRestClient;
|
||||||
import org.junit.AfterClass;
|
import org.junit.AfterClass;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
|
@ -35,7 +36,6 @@ import org.apache.hadoop.io.IOUtils;
|
||||||
import org.apache.hadoop.ozone.MiniOzoneCluster;
|
import org.apache.hadoop.ozone.MiniOzoneCluster;
|
||||||
import org.apache.hadoop.ozone.OzoneConfiguration;
|
import org.apache.hadoop.ozone.OzoneConfiguration;
|
||||||
import org.apache.hadoop.ozone.web.client.OzoneBucket;
|
import org.apache.hadoop.ozone.web.client.OzoneBucket;
|
||||||
import org.apache.hadoop.ozone.web.client.OzoneClient;
|
|
||||||
import org.apache.hadoop.ozone.web.client.OzoneVolume;
|
import org.apache.hadoop.ozone.web.client.OzoneVolume;
|
||||||
import org.apache.hadoop.ozone.web.request.OzoneQuota;
|
import org.apache.hadoop.ozone.web.request.OzoneQuota;
|
||||||
import org.junit.rules.Timeout;
|
import org.junit.rules.Timeout;
|
||||||
|
@ -52,7 +52,7 @@ public class TestOzoneRestWithMiniCluster {
|
||||||
|
|
||||||
private static MiniOzoneCluster cluster;
|
private static MiniOzoneCluster cluster;
|
||||||
private static OzoneConfiguration conf;
|
private static OzoneConfiguration conf;
|
||||||
private static OzoneClient ozoneClient;
|
private static OzoneRestClient ozoneClient;
|
||||||
|
|
||||||
@Rule
|
@Rule
|
||||||
public ExpectedException exception = ExpectedException.none();
|
public ExpectedException exception = ExpectedException.none();
|
||||||
|
@ -63,7 +63,7 @@ public class TestOzoneRestWithMiniCluster {
|
||||||
cluster = new MiniOzoneCluster.Builder(conf).numDataNodes(1)
|
cluster = new MiniOzoneCluster.Builder(conf).numDataNodes(1)
|
||||||
.setHandlerType(OzoneConsts.OZONE_HANDLER_DISTRIBUTED).build();
|
.setHandlerType(OzoneConsts.OZONE_HANDLER_DISTRIBUTED).build();
|
||||||
cluster.waitOzoneReady();
|
cluster.waitOzoneReady();
|
||||||
ozoneClient = cluster.createOzoneClient();
|
ozoneClient = cluster.createOzoneRestClient();
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass
|
@AfterClass
|
||||||
|
|
|
@ -49,7 +49,7 @@ public class TestBuckets {
|
||||||
public Timeout testTimeout = new Timeout(300000);
|
public Timeout testTimeout = new Timeout(300000);
|
||||||
|
|
||||||
private static MiniOzoneCluster cluster = null;
|
private static MiniOzoneCluster cluster = null;
|
||||||
private static OzoneClient client = null;
|
private static OzoneRestClient client = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a MiniDFSCluster for testing.
|
* Create a MiniDFSCluster for testing.
|
||||||
|
@ -75,7 +75,7 @@ public class TestBuckets {
|
||||||
.setHandlerType(OzoneConsts.OZONE_HANDLER_LOCAL).build();
|
.setHandlerType(OzoneConsts.OZONE_HANDLER_LOCAL).build();
|
||||||
DataNode dataNode = cluster.getDataNodes().get(0);
|
DataNode dataNode = cluster.getDataNodes().get(0);
|
||||||
final int port = dataNode.getInfoPort();
|
final int port = dataNode.getInfoPort();
|
||||||
client = new OzoneClient(String.format("http://localhost:%d", port));
|
client = new OzoneRestClient(String.format("http://localhost:%d", port));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -60,7 +60,7 @@ public class TestKeys {
|
||||||
|
|
||||||
private static MiniOzoneCluster cluster = null;
|
private static MiniOzoneCluster cluster = null;
|
||||||
static private String path;
|
static private String path;
|
||||||
private static OzoneClient client = null;
|
private static OzoneRestClient client = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a MiniDFSCluster for testing.
|
* Create a MiniDFSCluster for testing.
|
||||||
|
@ -85,7 +85,7 @@ public class TestKeys {
|
||||||
.setHandlerType(OzoneConsts.OZONE_HANDLER_LOCAL).build();
|
.setHandlerType(OzoneConsts.OZONE_HANDLER_LOCAL).build();
|
||||||
DataNode dataNode = cluster.getDataNodes().get(0);
|
DataNode dataNode = cluster.getDataNodes().get(0);
|
||||||
final int port = dataNode.getInfoPort();
|
final int port = dataNode.getInfoPort();
|
||||||
client = new OzoneClient(String.format("http://localhost:%d", port));
|
client = new OzoneRestClient(String.format("http://localhost:%d", port));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -55,7 +55,7 @@ import static org.mockito.Mockito.verify;
|
||||||
|
|
||||||
public class TestVolume {
|
public class TestVolume {
|
||||||
private static MiniOzoneCluster cluster = null;
|
private static MiniOzoneCluster cluster = null;
|
||||||
private static OzoneClient client = null;
|
private static OzoneRestClient client = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a MiniDFSCluster for testing.
|
* Create a MiniDFSCluster for testing.
|
||||||
|
@ -84,7 +84,7 @@ public class TestVolume {
|
||||||
DataNode dataNode = cluster.getDataNodes().get(0);
|
DataNode dataNode = cluster.getDataNodes().get(0);
|
||||||
final int port = dataNode.getInfoPort();
|
final int port = dataNode.getInfoPort();
|
||||||
|
|
||||||
client = new OzoneClient(String.format("http://localhost:%d", port));
|
client = new OzoneRestClient(String.format("http://localhost:%d", port));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -102,7 +102,7 @@ public class TestVolume {
|
||||||
String volumeName = OzoneUtils.getRequestID().toLowerCase();
|
String volumeName = OzoneUtils.getRequestID().toLowerCase();
|
||||||
client.setUserAuth(OzoneConsts.OZONE_SIMPLE_HDFS_USER);
|
client.setUserAuth(OzoneConsts.OZONE_SIMPLE_HDFS_USER);
|
||||||
|
|
||||||
OzoneClient mockClient = Mockito.spy(client);
|
OzoneRestClient mockClient = Mockito.spy(client);
|
||||||
List<CloseableHttpClient> mockedClients = mockHttpClients(mockClient);
|
List<CloseableHttpClient> mockedClients = mockHttpClients(mockClient);
|
||||||
OzoneVolume vol = mockClient.createVolume(volumeName, "bilbo", "100TB");
|
OzoneVolume vol = mockClient.createVolume(volumeName, "bilbo", "100TB");
|
||||||
// Verify http clients are properly closed.
|
// Verify http clients are properly closed.
|
||||||
|
@ -227,16 +227,17 @@ public class TestVolume {
|
||||||
/**
|
/**
|
||||||
* Returns a list of mocked {@link CloseableHttpClient} used for testing.
|
* Returns a list of mocked {@link CloseableHttpClient} used for testing.
|
||||||
* The mocked client replaces the actual calls in
|
* The mocked client replaces the actual calls in
|
||||||
* {@link OzoneClient#newHttpClient()}, it is used to verify
|
* {@link OzoneRestClient#newHttpClient()}, it is used to verify
|
||||||
* if the invocation of this client is expected. <b>Note</b>, the output
|
* if the invocation of this client is expected. <b>Note</b>, the output
|
||||||
* of this method is always used as the input of
|
* of this method is always used as the input of
|
||||||
* {@link TestVolume#verifyHttpConnectionClosed(List)}.
|
* {@link TestVolume#verifyHttpConnectionClosed(List)}.
|
||||||
*
|
*
|
||||||
* @param ozoneClient mocked ozone client.
|
* @param ozoneRestClient mocked ozone client.
|
||||||
* @return a list of mocked {@link CloseableHttpClient}.
|
* @return a list of mocked {@link CloseableHttpClient}.
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
private List<CloseableHttpClient> mockHttpClients(OzoneClient ozoneClient)
|
private List<CloseableHttpClient> mockHttpClients(
|
||||||
|
OzoneRestClient ozoneRestClient)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
List<CloseableHttpClient> spyHttpClients = new ArrayList<>();
|
List<CloseableHttpClient> spyHttpClients = new ArrayList<>();
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
|
@ -247,7 +248,7 @@ public class TestVolume {
|
||||||
|
|
||||||
List<CloseableHttpClient> nextReturns =
|
List<CloseableHttpClient> nextReturns =
|
||||||
new ArrayList<>(spyHttpClients.subList(1, spyHttpClients.size()));
|
new ArrayList<>(spyHttpClients.subList(1, spyHttpClients.size()));
|
||||||
Mockito.when(ozoneClient.newHttpClient()).thenReturn(
|
Mockito.when(ozoneRestClient.newHttpClient()).thenReturn(
|
||||||
spyHttpClients.get(0),
|
spyHttpClients.get(0),
|
||||||
nextReturns.toArray(new CloseableHttpClient[nextReturns.size()]));
|
nextReturns.toArray(new CloseableHttpClient[nextReturns.size()]));
|
||||||
return spyHttpClients;
|
return spyHttpClients;
|
||||||
|
@ -255,7 +256,7 @@ public class TestVolume {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is used together with
|
* This method is used together with
|
||||||
* {@link TestVolume#mockHttpClients(OzoneClient)} to verify
|
* {@link TestVolume#mockHttpClients(OzoneRestClient)} to verify
|
||||||
* if the http client is properly closed. It verifies that as long as
|
* if the http client is properly closed. It verifies that as long as
|
||||||
* a client calls {@link CloseableHttpClient#execute(HttpUriRequest)} to
|
* a client calls {@link CloseableHttpClient#execute(HttpUriRequest)} to
|
||||||
* send request, then it must calls {@link CloseableHttpClient#close()}
|
* send request, then it must calls {@link CloseableHttpClient#close()}
|
||||||
|
|
Loading…
Reference in New Issue