diff --git a/hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/OzoneConfigKeys.java b/hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/OzoneConfigKeys.java
index f8b2973cf62..879e8c2bdd9 100644
--- a/hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/OzoneConfigKeys.java
+++ b/hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/OzoneConfigKeys.java
@@ -125,9 +125,6 @@ public final class OzoneConfigKeys {
* */
public static final String OZONE_ADMINISTRATORS_WILDCARD = "*";
- public static final String OZONE_CLIENT_PROTOCOL =
- "ozone.client.protocol";
-
public static final String OZONE_CLIENT_STREAM_BUFFER_FLUSH_SIZE =
"ozone.client.stream.buffer.flush.size";
diff --git a/hadoop-hdds/common/src/main/resources/ozone-default.xml b/hadoop-hdds/common/src/main/resources/ozone-default.xml
index f7334b166b8..9987415a1c5 100644
--- a/hadoop-hdds/common/src/main/resources/ozone-default.xml
+++ b/hadoop-hdds/common/src/main/resources/ozone-default.xml
@@ -461,19 +461,6 @@
there is no wait.
-
- ozone.client.protocol
- org.apache.hadoop.ozone.client.rpc.RpcClient
- OZONE, CLIENT, MANAGEMENT
- Protocol class to be used by the client to connect to ozone
- cluster.
- The build-in implementation includes:
- org.apache.hadoop.ozone.client.rpc.RpcClient for RPC
- org.apache.hadoop.ozone.client.rest.RestClient for REST
- The default is the RpClient. Please do not change this unless you have a
- very good understanding of what you are doing.
-
- ozone.client.socket.timeout5000ms
@@ -1261,7 +1248,7 @@
hdds.datanode.plugins
- org.apache.hadoop.ozone.web.OzoneHddsDatanodeService
+
Comma-separated list of HDDS datanode plug-ins to be activated when
HDDS service starts as part of datanode.
diff --git a/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/OzoneBucket.java b/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/OzoneBucket.java
index fbb50e212e3..4fd723148ea 100644
--- a/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/OzoneBucket.java
+++ b/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/OzoneBucket.java
@@ -18,6 +18,7 @@
package org.apache.hadoop.ozone.client;
+import com.fasterxml.jackson.annotation.JsonIgnore;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;
import org.apache.hadoop.conf.Configuration;
@@ -211,6 +212,7 @@ public class OzoneBucket extends WithMetadata {
*
* @return acls
*/
+ @JsonIgnore
public List getAcls() throws IOException {
return proxy.getAcl(ozoneObj);
}
diff --git a/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/OzoneClientException.java b/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/OzoneClientException.java
index de3116a6aa8..2e9080a66f8 100644
--- a/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/OzoneClientException.java
+++ b/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/OzoneClientException.java
@@ -17,38 +17,27 @@
*/
package org.apache.hadoop.ozone.client;
-import org.apache.hadoop.ozone.client.rest.OzoneException;
-
/**
* This exception is thrown by the Ozone Clients.
*/
-public class OzoneClientException extends OzoneException {
- /**
- * Constructor that allows the shortMessage.
- *
- * @param shortMessage Short Message
- */
- public OzoneClientException(String shortMessage) {
- super(0, shortMessage, shortMessage);
+public class OzoneClientException extends Exception {
+ public OzoneClientException() {
}
- /**
- * Constructor that allows a shortMessage and an exception.
- *
- * @param shortMessage short message
- * @param ex exception
- */
- public OzoneClientException(String shortMessage, Exception ex) {
- super(0, shortMessage, shortMessage, ex);
+ public OzoneClientException(String s) {
+ super(s);
}
- /**
- * Constructor that allows the shortMessage and a longer message.
- *
- * @param shortMessage Short Message
- * @param message long error message
- */
- public OzoneClientException(String shortMessage, String message) {
- super(0, shortMessage, message);
+ public OzoneClientException(String s, Throwable throwable) {
+ super(s, throwable);
+ }
+
+ public OzoneClientException(Throwable throwable) {
+ super(throwable);
+ }
+
+ public OzoneClientException(String s, Throwable throwable, boolean b,
+ boolean b1) {
+ super(s, throwable, b, b1);
}
}
diff --git a/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/OzoneClientFactory.java b/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/OzoneClientFactory.java
index de0d166abda..713a6b2df3f 100644
--- a/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/OzoneClientFactory.java
+++ b/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/OzoneClientFactory.java
@@ -18,37 +18,22 @@
package org.apache.hadoop.ozone.client;
-import com.google.common.base.Preconditions;
+import java.io.IOException;
+import java.lang.reflect.Proxy;
+
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hdds.conf.OzoneConfiguration;
import org.apache.hadoop.ozone.OmUtils;
import org.apache.hadoop.ozone.client.protocol.ClientProtocol;
-import org.apache.hadoop.ozone.client.rest.RestClient;
import org.apache.hadoop.ozone.client.rpc.RpcClient;
+import com.google.common.base.Preconditions;
+import static org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_ADDRESS_KEY;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.IOException;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Proxy;
-
-import static org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_CLIENT_PROTOCOL;
-import static org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_ADDRESS_KEY;
-import static org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_HTTP_ADDRESS_KEY;
-
/**
- * Factory class to create different types of OzoneClients.
- * Based on ozone.client.protocol, it decides which
- * protocol to use for the communication.
- * Default value is
- * org.apache.hadoop.ozone.client.rpc.RpcClient.
- * OzoneClientFactory constructs a proxy using
- * {@link OzoneClientInvocationHandler}
- * and creates OzoneClient instance with it.
- * {@link OzoneClientInvocationHandler} dispatches the call to
- * underlying {@link ClientProtocol} implementation.
+ * Factory class to create OzoneClients.
*/
public final class OzoneClientFactory {
@@ -87,9 +72,7 @@ public final class OzoneClientFactory {
public static OzoneClient getClient(Configuration config)
throws IOException {
Preconditions.checkNotNull(config);
- Class extends ClientProtocol> clazz = (Class extends ClientProtocol>)
- config.getClass(OZONE_CLIENT_PROTOCOL, RpcClient.class);
- return getClient(getClientProtocol(clazz, config), config);
+ return getClient(getClientProtocol(config), config);
}
/**
@@ -166,85 +149,7 @@ public final class OzoneClientFactory {
public static OzoneClient getRpcClient(Configuration config)
throws IOException {
Preconditions.checkNotNull(config);
- return getClient(getClientProtocol(RpcClient.class, config),
- config);
- }
-
- /**
- * Returns an OzoneClient which will use REST protocol.
- *
- * @param omHost
- * hostname of OzoneManager to connect.
- *
- * @return OzoneClient
- *
- * @throws IOException
- */
- public static OzoneClient getRestClient(String omHost)
- throws IOException {
- Configuration config = new OzoneConfiguration();
- int port = OmUtils.getOmRestPort(config);
- return getRestClient(omHost, port, config);
- }
-
- /**
- * Returns an OzoneClient which will use REST protocol.
- *
- * @param omHost
- * hostname of OzoneManager to connect.
- *
- * @param omHttpPort
- * HTTP port of OzoneManager.
- *
- * @return OzoneClient
- *
- * @throws IOException
- */
- public static OzoneClient getRestClient(String omHost, Integer omHttpPort)
- throws IOException {
- return getRestClient(omHost, omHttpPort, new OzoneConfiguration());
- }
-
- /**
- * Returns an OzoneClient which will use REST protocol.
- *
- * @param omHost
- * hostname of OzoneManager to connect.
- *
- * @param omHttpPort
- * HTTP port of OzoneManager.
- *
- * @param config
- * Configuration to be used for OzoneClient creation
- *
- * @return OzoneClient
- *
- * @throws IOException
- */
- public static OzoneClient getRestClient(String omHost, Integer omHttpPort,
- Configuration config)
- throws IOException {
- Preconditions.checkNotNull(omHost);
- Preconditions.checkNotNull(omHttpPort);
- Preconditions.checkNotNull(config);
- config.set(OZONE_OM_HTTP_ADDRESS_KEY, omHost + ":" + omHttpPort);
- return getRestClient(config);
- }
-
- /**
- * Returns an OzoneClient which will use REST protocol.
- *
- * @param config
- * Configuration to be used for OzoneClient creation
- *
- * @return OzoneClient
- *
- * @throws IOException
- */
- public static OzoneClient getRestClient(Configuration config)
- throws IOException {
- Preconditions.checkNotNull(config);
- return getClient(getClientProtocol(RestClient.class, config),
+ return getClient(getClientProtocol(config),
config);
}
@@ -270,8 +175,6 @@ public final class OzoneClientFactory {
/**
* Returns an instance of Protocol class.
*
- * @param protocolClass
- * Class object of the ClientProtocol.
*
* @param config
* Configuration used to initialize ClientProtocol.
@@ -280,23 +183,15 @@ public final class OzoneClientFactory {
*
* @throws IOException
*/
- private static ClientProtocol getClientProtocol(
- Class extends ClientProtocol> protocolClass, Configuration config)
+ private static ClientProtocol getClientProtocol(Configuration config)
throws IOException {
try {
- LOG.debug("Using {} as client protocol.",
- protocolClass.getCanonicalName());
- Constructor extends ClientProtocol> ctor =
- protocolClass.getConstructor(Configuration.class);
- return ctor.newInstance(config);
+ return new RpcClient(config);
} catch (Exception e) {
- final String message = "Couldn't create protocol " + protocolClass;
+ final String message = "Couldn't create RpcClient protocol";
LOG.error(message + " exception: ", e);
if (e.getCause() instanceof IOException) {
throw (IOException) e.getCause();
- } else if (e instanceof InvocationTargetException) {
- throw new IOException(message,
- ((InvocationTargetException) e).getTargetException());
} else {
throw new IOException(message, e);
}
diff --git a/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/OzoneClientUtils.java b/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/OzoneClientUtils.java
index 3da45cfc902..8531bfbe71e 100644
--- a/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/OzoneClientUtils.java
+++ b/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/OzoneClientUtils.java
@@ -17,106 +17,15 @@
*/
package org.apache.hadoop.ozone.client;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
import java.util.concurrent.TimeUnit;
-import org.apache.hadoop.hdds.client.OzoneQuota;
-import org.apache.hadoop.hdds.scm.client.HddsClientUtils;
import org.apache.hadoop.io.retry.RetryPolicies;
import org.apache.hadoop.io.retry.RetryPolicy;
-import org.apache.hadoop.ozone.OzoneConsts;
-import org.apache.hadoop.ozone.client.rest.response.BucketInfo;
-import org.apache.hadoop.ozone.client.rest.response.KeyInfo;
-import org.apache.hadoop.ozone.client.rest.response.KeyInfoDetails;
-import org.apache.hadoop.ozone.client.rest.response.KeyLocation;
-import org.apache.hadoop.ozone.client.rest.response.VolumeInfo;
-import org.apache.hadoop.ozone.client.rest.response.VolumeOwner;
/** A utility class for OzoneClient. */
public final class OzoneClientUtils {
private OzoneClientUtils() {}
- /**
- * Returns a BucketInfo object constructed using fields of the input
- * OzoneBucket object.
- *
- * @param bucket OzoneBucket instance from which BucketInfo object needs to
- * be created.
- * @return BucketInfo instance
- */
- public static BucketInfo asBucketInfo(OzoneBucket bucket) throws IOException {
- BucketInfo bucketInfo =
- new BucketInfo(bucket.getVolumeName(), bucket.getName());
- bucketInfo
- .setCreatedOn(HddsClientUtils.formatDateTime(bucket.getCreationTime()));
- bucketInfo.setStorageType(bucket.getStorageType());
- bucketInfo.setVersioning(
- OzoneConsts.Versioning.getVersioning(bucket.getVersioning()));
- bucketInfo.setEncryptionKeyName(
- bucket.getEncryptionKeyName()==null? "N/A" :
- bucket.getEncryptionKeyName());
- return bucketInfo;
- }
-
- /**
- * Returns a VolumeInfo object constructed using fields of the input
- * OzoneVolume object.
- *
- * @param volume OzoneVolume instance from which VolumeInfo object needs to
- * be created.
- * @return VolumeInfo instance
- */
- public static VolumeInfo asVolumeInfo(OzoneVolume volume) {
- VolumeInfo volumeInfo = new VolumeInfo(volume.getName(),
- HddsClientUtils.formatDateTime(volume.getCreationTime()),
- volume.getOwner());
- volumeInfo.setQuota(OzoneQuota.getOzoneQuota(volume.getQuota()));
- volumeInfo.setOwner(new VolumeOwner(volume.getOwner()));
- return volumeInfo;
- }
-
- /**
- * Returns a KeyInfo object constructed using fields of the input
- * OzoneKey object.
- *
- * @param key OzoneKey instance from which KeyInfo object needs to
- * be created.
- * @return KeyInfo instance
- */
- public static KeyInfo asKeyInfo(OzoneKey key) {
- KeyInfo keyInfo = new KeyInfo();
- keyInfo.setKeyName(key.getName());
- keyInfo.setCreatedOn(HddsClientUtils.formatDateTime(key.getCreationTime()));
- keyInfo.setModifiedOn(
- HddsClientUtils.formatDateTime(key.getModificationTime()));
- keyInfo.setSize(key.getDataSize());
- return keyInfo;
- }
-
- /**
- * Returns a KeyInfoDetails object constructed using fields of the input
- * OzoneKeyDetails object.
- *
- * @param key OzoneKeyDetails instance from which KeyInfo object needs to
- * be created.
- * @return KeyInfoDetails instance
- */
- public static KeyInfoDetails asKeyInfoDetails(OzoneKeyDetails key) {
- KeyInfoDetails keyInfo = new KeyInfoDetails();
- keyInfo.setKeyName(key.getName());
- keyInfo.setCreatedOn(HddsClientUtils.formatDateTime(key.getCreationTime()));
- keyInfo.setModifiedOn(
- HddsClientUtils.formatDateTime(key.getModificationTime()));
- keyInfo.setSize(key.getDataSize());
- List keyLocations = new ArrayList<>();
- key.getOzoneKeyLocations().forEach((a) -> keyLocations.add(new KeyLocation(
- a.getContainerID(), a.getLocalID(), a.getLength(), a.getOffset())));
- keyInfo.setKeyLocation(keyLocations);
- keyInfo.setFileEncryptionInfo(key.getFileEncryptionInfo());
- return keyInfo;
- }
public static RetryPolicy createRetryPolicy(int maxRetryCount,
long retryInterval) {
diff --git a/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/rest/DefaultRestServerSelector.java b/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/rest/DefaultRestServerSelector.java
deleted file mode 100644
index abdc2fbe19a..00000000000
--- a/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/rest/DefaultRestServerSelector.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.hadoop.ozone.client.rest;
-
-import org.apache.hadoop.ozone.om.helpers.ServiceInfo;
-
-import java.util.List;
-import java.util.Random;
-
-/**
- * Default selector randomly picks one of the REST Server from the list.
- */
-public class DefaultRestServerSelector implements RestServerSelector {
-
- @Override
- public ServiceInfo getRestServer(List restServices) {
- return restServices.get(
- new Random().nextInt(restServices.size()));
- }
-}
diff --git a/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/rest/OzoneExceptionMapper.java b/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/rest/OzoneExceptionMapper.java
deleted file mode 100644
index 6c479f7721a..00000000000
--- a/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/rest/OzoneExceptionMapper.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.hadoop.ozone.client.rest;
-
-
-import javax.ws.rs.core.Response;
-import javax.ws.rs.ext.ExceptionMapper;
-
-import org.slf4j.MDC;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Class the represents various errors returned by the
- * Object Layer.
- */
-public class OzoneExceptionMapper implements ExceptionMapper {
- private static final Logger LOG =
- LoggerFactory.getLogger(OzoneExceptionMapper.class);
-
- @Override
- public Response toResponse(OzoneException exception) {
- LOG.debug("Returning exception. ex: {}", exception.toJsonString());
- MDC.clear();
- return Response.status((int)exception.getHttpCode())
- .entity(exception.toJsonString()).build();
- }
-
-}
diff --git a/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/rest/RestClient.java b/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/rest/RestClient.java
deleted file mode 100644
index e01c2c3eec5..00000000000
--- a/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/rest/RestClient.java
+++ /dev/null
@@ -1,1130 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.hadoop.ozone.client.rest;
-
-import com.fasterxml.jackson.core.type.TypeReference;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.google.common.base.Preconditions;
-import com.google.common.base.Strings;
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.crypto.key.KeyProvider;
-import org.apache.hadoop.hdds.protocol.StorageType;
-import org.apache.hadoop.hdds.protocol.proto.HddsProtos;
-import org.apache.hadoop.hdds.scm.client.HddsClientUtils;
-import org.apache.hadoop.io.Text;
-import org.apache.hadoop.net.NetUtils;
-import org.apache.hadoop.ozone.OzoneAcl;
-import org.apache.hadoop.ozone.OzoneConfigKeys;
-import org.apache.hadoop.ozone.OzoneConsts;
-import org.apache.hadoop.ozone.client.*;
-import org.apache.hadoop.hdds.client.OzoneQuota;
-import org.apache.hadoop.hdds.client.ReplicationFactor;
-import org.apache.hadoop.hdds.client.ReplicationType;
-import org.apache.hadoop.ozone.client.VolumeArgs;
-import org.apache.hadoop.ozone.client.io.OzoneInputStream;
-import org.apache.hadoop.ozone.client.io.OzoneOutputStream;
-import org.apache.hadoop.ozone.client.protocol.ClientProtocol;
-import org.apache.hadoop.ozone.client.rest.headers.Header;
-import org.apache.hadoop.ozone.client.rest.response.BucketInfo;
-import org.apache.hadoop.ozone.client.rest.response.KeyInfoDetails;
-import org.apache.hadoop.ozone.client.rest.response.VolumeInfo;
-import org.apache.hadoop.ozone.client.rpc.OzoneKMSUtil;
-import org.apache.hadoop.ozone.om.OMConfigKeys;
-import org.apache.hadoop.ozone.om.ha.OMFailoverProxyProvider;
-import org.apache.hadoop.ozone.om.helpers.OmMultipartInfo;
-import org.apache.hadoop.ozone.om.helpers.OmMultipartUploadCompleteInfo;
-import org.apache.hadoop.ozone.om.helpers.S3SecretValue;
-import org.apache.hadoop.ozone.om.helpers.ServiceInfo;
-import org.apache.hadoop.ozone.om.helpers.OzoneFileStatus;
-import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.ServicePort;
-import org.apache.hadoop.ozone.security.OzoneTokenIdentifier;
-import org.apache.hadoop.ozone.security.acl.OzoneObj;
-import org.apache.hadoop.ozone.web.response.ListBuckets;
-import org.apache.hadoop.ozone.web.response.ListKeys;
-import org.apache.hadoop.ozone.web.response.ListVolumes;
-import org.apache.hadoop.security.UserGroupInformation;
-import org.apache.hadoop.security.token.Token;
-import org.apache.hadoop.util.Time;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpHeaders;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.config.RequestConfig;
-import org.apache.http.client.methods.HttpDelete;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.client.methods.HttpPut;
-import org.apache.http.client.methods.HttpUriRequest;
-import org.apache.http.client.utils.URIBuilder;
-import org.apache.http.entity.InputStreamEntity;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClients;
-import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
-import org.apache.http.util.EntityUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.PipedInputStream;
-import java.io.PipedOutputStream;
-import java.net.InetSocketAddress;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.text.ParseException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.FutureTask;
-import java.util.concurrent.TimeUnit;
-import java.util.stream.Collectors;
-
-import static java.net.HttpURLConnection.HTTP_CREATED;
-import static java.net.HttpURLConnection.HTTP_OK;
-import static org.apache.hadoop.ozone.OzoneConsts.OZONE_OM_SERVICE_LIST_HTTP_ENDPOINT;
-
-/**
- * Ozone Client REST protocol implementation. It uses REST protocol to
- * connect to Ozone Handler that executes client calls.
- */
-public class RestClient implements ClientProtocol {
-
- private static final String PATH_SEPARATOR = "/";
- private static final Logger LOG = LoggerFactory.getLogger(RestClient.class);
-
- private final Configuration conf;
- private final URI ozoneRestUri;
- private final CloseableHttpClient httpClient;
- private final UserGroupInformation ugi;
- // private final OzoneAcl.OzoneACLRights userRights;
-
- /**
- * Creates RestClient instance with the given configuration.
- * @param conf Configuration
- * @throws IOException
- */
- public RestClient(Configuration conf)
- throws IOException {
- try {
- Preconditions.checkNotNull(conf);
- this.conf = conf;
- this.ugi = UserGroupInformation.getCurrentUser();
- long socketTimeout = conf.getTimeDuration(
- OzoneConfigKeys.OZONE_CLIENT_SOCKET_TIMEOUT,
- OzoneConfigKeys.OZONE_CLIENT_SOCKET_TIMEOUT_DEFAULT,
- TimeUnit.MILLISECONDS);
- long connectionTimeout = conf.getTimeDuration(
- OzoneConfigKeys.OZONE_CLIENT_CONNECTION_TIMEOUT,
- OzoneConfigKeys.OZONE_CLIENT_CONNECTION_TIMEOUT_DEFAULT,
- TimeUnit.MILLISECONDS);
- int maxConnection = conf.getInt(
- OzoneConfigKeys.OZONE_REST_CLIENT_HTTP_CONNECTION_MAX,
- OzoneConfigKeys.OZONE_REST_CLIENT_HTTP_CONNECTION_DEFAULT);
-
- int maxConnectionPerRoute = conf.getInt(
- OzoneConfigKeys.OZONE_REST_CLIENT_HTTP_CONNECTION_PER_ROUTE_MAX,
- OzoneConfigKeys
- .OZONE_REST_CLIENT_HTTP_CONNECTION_PER_ROUTE_MAX_DEFAULT
- );
-
- /*
- To make RestClient Thread safe, creating the HttpClient with
- ThreadSafeClientConnManager.
- */
- PoolingHttpClientConnectionManager connManager =
- new PoolingHttpClientConnectionManager();
- connManager.setMaxTotal(maxConnection);
- connManager.setDefaultMaxPerRoute(maxConnectionPerRoute);
-
- this.httpClient = HttpClients.custom()
- .setConnectionManager(connManager)
- .setDefaultRequestConfig(
- RequestConfig.custom()
- .setSocketTimeout(Math.toIntExact(socketTimeout))
- .setConnectTimeout(Math.toIntExact(connectionTimeout))
- .build())
- .build();
-
-// this.userRights = conf.getEnum(OMConfigKeys.OZONE_OM_USER_RIGHTS,
-// OMConfigKeys.OZONE_OM_USER_RIGHTS_DEFAULT);
-
- // TODO: Add new configuration parameter to configure RestServerSelector.
- RestServerSelector defaultSelector = new DefaultRestServerSelector();
- InetSocketAddress restServer = getOzoneRestServerAddress(defaultSelector);
- URIBuilder uriBuilder = new URIBuilder()
- .setScheme("http")
- .setHost(restServer.getHostName())
- .setPort(restServer.getPort());
- this.ozoneRestUri = uriBuilder.build();
-
- } catch (URISyntaxException e) {
- throw new IOException(e);
- }
- }
-
- private InetSocketAddress getOzoneRestServerAddress(
- RestServerSelector selector) throws IOException {
- String httpAddress = conf.get(OMConfigKeys.OZONE_OM_HTTP_ADDRESS_KEY);
-
- if (httpAddress == null) {
- throw new IllegalArgumentException(
- OMConfigKeys.OZONE_OM_HTTP_ADDRESS_KEY + " must be defined. See" +
- " https://wiki.apache.org/hadoop/Ozone#Configuration for" +
- " details on configuring Ozone.");
- }
-
- HttpGet httpGet = new HttpGet("http://" + httpAddress +
- OZONE_OM_SERVICE_LIST_HTTP_ENDPOINT);
- HttpEntity entity = executeHttpRequest(httpGet);
- try {
- String serviceListJson = EntityUtils.toString(entity);
-
- ObjectMapper objectMapper = new ObjectMapper();
- TypeReference> serviceInfoReference =
- new TypeReference>() {
- };
- List services = objectMapper.readValue(
- serviceListJson, serviceInfoReference);
-
- List dataNodeInfos = services.stream().filter(
- a -> a.getNodeType().equals(HddsProtos.NodeType.DATANODE))
- .collect(Collectors.toList());
-
- ServiceInfo restServer = selector.getRestServer(dataNodeInfos);
-
- return NetUtils.createSocketAddr(
- NetUtils.normalizeHostName(restServer.getHostname()) + ":"
- + restServer.getPort(ServicePort.Type.HTTP));
- } finally {
- EntityUtils.consume(entity);
- }
- }
-
- @Override
- public void createVolume(String volumeName) throws IOException {
- createVolume(volumeName, VolumeArgs.newBuilder().build());
- }
-
- @Override
- public void createVolume(String volumeName, VolumeArgs volArgs)
- throws IOException {
- try {
- HddsClientUtils.verifyResourceName(volumeName);
- Preconditions.checkNotNull(volArgs);
- URIBuilder builder = new URIBuilder(ozoneRestUri);
- String owner = volArgs.getOwner() == null ?
- ugi.getUserName() : volArgs.getOwner();
- //TODO: support for ACLs has to be done in OzoneHandler (rest server)
- /**
- List listOfAcls = new ArrayList<>();
- //User ACL
- listOfAcls.add(new OzoneAcl(OzoneAcl.OzoneACLType.USER,
- owner, userRights));
- //ACLs from VolumeArgs
- if(volArgs.getAcls() != null) {
- listOfAcls.addAll(volArgs.getAcls());
- }
- */
- builder.setPath(PATH_SEPARATOR + volumeName);
-
- String quota = volArgs.getQuota();
- if(quota != null) {
- builder.setParameter(Header.OZONE_QUOTA_QUERY_TAG, quota);
- }
-
- HttpPost httpPost = new HttpPost(builder.build());
- addOzoneHeaders(httpPost);
- //use admin from VolumeArgs, if it's present
- if(volArgs.getAdmin() != null) {
- httpPost.removeHeaders(HttpHeaders.AUTHORIZATION);
- httpPost.addHeader(HttpHeaders.AUTHORIZATION,
- Header.OZONE_SIMPLE_AUTHENTICATION_SCHEME + " " +
- volArgs.getAdmin());
- }
- httpPost.addHeader(Header.OZONE_USER, owner);
- LOG.info("Creating Volume: {}, with {} as owner and quota set to {}.",
- volumeName, owner, quota == null ? "default" : quota);
- EntityUtils.consume(executeHttpRequest(httpPost));
- } catch (URISyntaxException e) {
- throw new IOException(e);
- }
- }
-
-
- @Override
- public void setVolumeOwner(String volumeName, String owner)
- throws IOException {
- try {
- HddsClientUtils.verifyResourceName(volumeName);
- Preconditions.checkNotNull(owner);
- URIBuilder builder = new URIBuilder(ozoneRestUri);
- builder.setPath(PATH_SEPARATOR + volumeName);
- HttpPut httpPut = new HttpPut(builder.build());
- addOzoneHeaders(httpPut);
- httpPut.addHeader(Header.OZONE_USER, owner);
- EntityUtils.consume(executeHttpRequest(httpPut));
- } catch (URISyntaxException e) {
- throw new IOException(e);
- }
- }
-
- @Override
- public void setVolumeQuota(String volumeName, OzoneQuota quota)
- throws IOException {
- try {
- HddsClientUtils.verifyResourceName(volumeName);
- Preconditions.checkNotNull(quota);
- String quotaString = quota.toString();
- URIBuilder builder = new URIBuilder(ozoneRestUri);
- builder.setPath(PATH_SEPARATOR + volumeName);
- builder.setParameter(Header.OZONE_QUOTA_QUERY_TAG, quotaString);
- HttpPut httpPut = new HttpPut(builder.build());
- addOzoneHeaders(httpPut);
- EntityUtils.consume(executeHttpRequest(httpPut));
- } catch (URISyntaxException e) {
- throw new IOException(e);
- }
- }
-
- @Override
- public OzoneVolume getVolumeDetails(String volumeName)
- throws IOException {
- try {
- HddsClientUtils.verifyResourceName(volumeName);
- URIBuilder builder = new URIBuilder(ozoneRestUri);
- builder.setPath(PATH_SEPARATOR + volumeName);
- builder.setParameter(Header.OZONE_INFO_QUERY_TAG,
- Header.OZONE_INFO_QUERY_VOLUME);
- HttpGet httpGet = new HttpGet(builder.build());
- addOzoneHeaders(httpGet);
- HttpEntity response = executeHttpRequest(httpGet);
- VolumeInfo volInfo =
- VolumeInfo.parse(EntityUtils.toString(response));
- //TODO: OzoneHandler in datanode has to be modified to send ACLs
- OzoneVolume volume = new OzoneVolume(conf,
- this,
- volInfo.getVolumeName(),
- volInfo.getCreatedBy(),
- volInfo.getOwner().getName(),
- volInfo.getQuota().sizeInBytes(),
- HddsClientUtils.formatDateTime(volInfo.getCreatedOn()),
- null);
- EntityUtils.consume(response);
- return volume;
- } catch (URISyntaxException | ParseException e) {
- throw new IOException(e);
- }
- }
-
- @Override
- public boolean checkVolumeAccess(String volumeName, OzoneAcl acl)
- throws IOException {
- throw new UnsupportedOperationException("Not yet implemented.");
- }
-
- @Override
- public void deleteVolume(String volumeName) throws IOException {
- try {
- HddsClientUtils.verifyResourceName(volumeName);
- URIBuilder builder = new URIBuilder(ozoneRestUri);
- builder.setPath(PATH_SEPARATOR + volumeName);
- HttpDelete httpDelete = new HttpDelete(builder.build());
- addOzoneHeaders(httpDelete);
- EntityUtils.consume(executeHttpRequest(httpDelete));
- } catch (URISyntaxException e) {
- throw new IOException(e);
- }
- }
-
- @Override
- public List listVolumes(String volumePrefix, String prevKey,
- int maxListResult)
- throws IOException {
- return listVolumes(null, volumePrefix, prevKey, maxListResult);
- }
-
- @Override
- public List listVolumes(String user, String volumePrefix,
- String prevKey, int maxListResult)
- throws IOException {
- try {
- URIBuilder builder = new URIBuilder(ozoneRestUri);
- builder.setPath(PATH_SEPARATOR);
- builder.addParameter(Header.OZONE_INFO_QUERY_TAG,
- Header.OZONE_LIST_QUERY_SERVICE);
- builder.addParameter(Header.OZONE_LIST_QUERY_MAXKEYS,
- String.valueOf(maxListResult));
- addQueryParamter(Header.OZONE_LIST_QUERY_PREFIX, volumePrefix, builder);
- addQueryParamter(Header.OZONE_LIST_QUERY_PREVKEY, prevKey, builder);
- HttpGet httpGet = new HttpGet(builder.build());
- if (!Strings.isNullOrEmpty(user)) {
- httpGet.addHeader(Header.OZONE_USER, user);
- }
- addOzoneHeaders(httpGet);
- HttpEntity response = executeHttpRequest(httpGet);
- ListVolumes volumeList =
- ListVolumes.parse(EntityUtils.toString(response));
- EntityUtils.consume(response);
- return volumeList.getVolumes().stream().map(volInfo -> {
- long creationTime = 0;
- try {
- creationTime = HddsClientUtils.formatDateTime(volInfo.getCreatedOn());
- } catch (ParseException e) {
- LOG.warn("Parse exception in getting creation time for volume", e);
- }
- return new OzoneVolume(conf, this, volInfo.getVolumeName(),
- volInfo.getCreatedBy(), volInfo.getOwner().getName(),
- volInfo.getQuota().sizeInBytes(), creationTime, null);
- }).collect(Collectors.toList());
- } catch (URISyntaxException e) {
- throw new IOException(e);
- }
- }
-
- @Override
- public void createBucket(String volumeName, String bucketName)
- throws IOException {
- createBucket(volumeName, bucketName, BucketArgs.newBuilder().build());
- }
-
- @Override
- public void createBucket(
- String volumeName, String bucketName, BucketArgs bucketArgs)
- throws IOException {
- try {
- HddsClientUtils.verifyResourceName(volumeName, bucketName);
- Preconditions.checkNotNull(bucketArgs);
- URIBuilder builder = new URIBuilder(ozoneRestUri);
- OzoneConsts.Versioning versioning = OzoneConsts.Versioning.DISABLED;
- if(bucketArgs.getVersioning() != null &&
- bucketArgs.getVersioning()) {
- versioning = OzoneConsts.Versioning.ENABLED;
- }
- StorageType storageType = bucketArgs.getStorageType() == null ?
- StorageType.DEFAULT : bucketArgs.getStorageType();
-
- builder.setPath(PATH_SEPARATOR + volumeName +
- PATH_SEPARATOR + bucketName);
- HttpPost httpPost = new HttpPost(builder.build());
- addOzoneHeaders(httpPost);
-
- //ACLs from BucketArgs
- if(bucketArgs.getAcls() != null) {
- for (OzoneAcl acl : bucketArgs.getAcls()) {
- httpPost.addHeader(
- Header.OZONE_ACLS, Header.OZONE_ACL_ADD + " " + acl.toString());
- }
- }
- httpPost.addHeader(Header.OZONE_STORAGE_TYPE, storageType.toString());
- httpPost.addHeader(Header.OZONE_BUCKET_VERSIONING,
- versioning.toString());
- LOG.info("Creating Bucket: {}/{}, with Versioning {} and Storage Type" +
- " set to {}", volumeName, bucketName, versioning,
- storageType);
-
- EntityUtils.consume(executeHttpRequest(httpPost));
- } catch (URISyntaxException e) {
- throw new IOException(e);
- }
- }
-
- @Override
- public void setBucketVersioning(
- String volumeName, String bucketName, Boolean versioning)
- throws IOException {
- try {
- HddsClientUtils.verifyResourceName(volumeName, bucketName);
- Preconditions.checkNotNull(versioning);
- URIBuilder builder = new URIBuilder(ozoneRestUri);
-
- builder.setPath(PATH_SEPARATOR + volumeName +
- PATH_SEPARATOR + bucketName);
- HttpPut httpPut = new HttpPut(builder.build());
- addOzoneHeaders(httpPut);
-
- httpPut.addHeader(Header.OZONE_BUCKET_VERSIONING,
- getBucketVersioning(versioning).toString());
- EntityUtils.consume(executeHttpRequest(httpPut));
- } catch (URISyntaxException e) {
- throw new IOException(e);
- }
- }
-
- @Override
- public void setBucketStorageType(
- String volumeName, String bucketName, StorageType storageType)
- throws IOException {
- try {
- HddsClientUtils.verifyResourceName(volumeName, bucketName);
- Preconditions.checkNotNull(storageType);
- URIBuilder builder = new URIBuilder(ozoneRestUri);
-
- builder.setPath(PATH_SEPARATOR + volumeName +
- PATH_SEPARATOR + bucketName);
- HttpPut httpPut = new HttpPut(builder.build());
- addOzoneHeaders(httpPut);
-
- httpPut.addHeader(Header.OZONE_STORAGE_TYPE, storageType.toString());
- EntityUtils.consume(executeHttpRequest(httpPut));
- } catch (URISyntaxException e) {
- throw new IOException(e);
- }
- }
-
- @Override
- public void deleteBucket(String volumeName, String bucketName)
- throws IOException {
- try {
- HddsClientUtils.verifyResourceName(volumeName, bucketName);
- URIBuilder builder = new URIBuilder(ozoneRestUri);
- builder.setPath(PATH_SEPARATOR + volumeName +
- PATH_SEPARATOR + bucketName);
- HttpDelete httpDelete = new HttpDelete(builder.build());
- addOzoneHeaders(httpDelete);
- EntityUtils.consume(executeHttpRequest(httpDelete));
- } catch (URISyntaxException e) {
- throw new IOException(e);
- }
- }
-
- @Override
- public void checkBucketAccess(String volumeName, String bucketName)
- throws IOException {
- throw new UnsupportedOperationException("Not yet implemented.");
- }
-
- @Override
- public OzoneBucket getBucketDetails(String volumeName, String bucketName)
- throws IOException {
- try {
- HddsClientUtils.verifyResourceName(volumeName, bucketName);
- URIBuilder builder = new URIBuilder(ozoneRestUri);
- builder.setPath(PATH_SEPARATOR + volumeName +
- PATH_SEPARATOR + bucketName);
- builder.setParameter(Header.OZONE_INFO_QUERY_TAG,
- Header.OZONE_INFO_QUERY_BUCKET);
- HttpGet httpGet = new HttpGet(builder.build());
- addOzoneHeaders(httpGet);
- HttpEntity response = executeHttpRequest(httpGet);
- BucketInfo bucketInfo =
- BucketInfo.parse(EntityUtils.toString(response));
- OzoneBucket bucket = new OzoneBucket(conf,
- this,
- bucketInfo.getVolumeName(),
- bucketInfo.getBucketName(),
- bucketInfo.getStorageType(),
- getBucketVersioningFlag(bucketInfo.getVersioning()),
- HddsClientUtils.formatDateTime(bucketInfo.getCreatedOn()),
- new HashMap<>());
- EntityUtils.consume(response);
- return bucket;
- } catch (URISyntaxException | ParseException e) {
- throw new IOException(e);
- }
- }
-
- @Override
- public List listBuckets(String volumeName, String bucketPrefix,
- String prevBucket, int maxListResult)
- throws IOException {
- try {
- HddsClientUtils.verifyResourceName(volumeName);
- URIBuilder builder = new URIBuilder(ozoneRestUri);
- builder.setPath(PATH_SEPARATOR + volumeName);
- builder.addParameter(Header.OZONE_INFO_QUERY_TAG,
- Header.OZONE_INFO_QUERY_BUCKET);
- builder.addParameter(Header.OZONE_LIST_QUERY_MAXKEYS,
- String.valueOf(maxListResult));
- addQueryParamter(Header.OZONE_LIST_QUERY_PREFIX, bucketPrefix, builder);
- addQueryParamter(Header.OZONE_LIST_QUERY_PREVKEY, prevBucket, builder);
- HttpGet httpGet = new HttpGet(builder.build());
- addOzoneHeaders(httpGet);
- HttpEntity response = executeHttpRequest(httpGet);
- ListBuckets bucketList =
- ListBuckets.parse(EntityUtils.toString(response));
- EntityUtils.consume(response);
- return bucketList.getBuckets().stream().map(bucketInfo -> {
- long creationTime = 0;
- try {
- creationTime =
- HddsClientUtils.formatDateTime(bucketInfo.getCreatedOn());
- } catch (ParseException e) {
- LOG.warn("Parse exception in getting creation time for volume", e);
- }
- return new OzoneBucket(conf, this, volumeName,
- bucketInfo.getBucketName(), bucketInfo.getStorageType(),
- getBucketVersioningFlag(bucketInfo.getVersioning()), creationTime,
- new HashMap<>(), bucketInfo.getEncryptionKeyName());
- }).collect(Collectors.toList());
- } catch (URISyntaxException e) {
- throw new IOException(e);
- }
- }
-
- /**
- * Writes a key in an existing bucket.
- *
- * @param volumeName Name of the Volume
- * @param bucketName Name of the Bucket
- * @param keyName Name of the Key
- * @param size Size of the data
- * @param type
- * @param factor @return {@link OzoneOutputStream}
- */
- @Override
- public OzoneOutputStream createKey(
- String volumeName, String bucketName, String keyName, long size,
- ReplicationType type, ReplicationFactor factor,
- Map metadata)
- throws IOException {
- // TODO: Once ReplicationType and ReplicationFactor are supported in
- // OzoneHandler (in Datanode), set them in header.
- try {
- HddsClientUtils.verifyResourceName(volumeName, bucketName);
- HddsClientUtils.checkNotNull(keyName, type, factor);
- URIBuilder builder = new URIBuilder(ozoneRestUri);
- builder.setPath(PATH_SEPARATOR + volumeName +
- PATH_SEPARATOR + bucketName +
- PATH_SEPARATOR + keyName);
- HttpPut putRequest = new HttpPut(builder.build());
- addOzoneHeaders(putRequest);
- PipedInputStream in = new PipedInputStream();
- OutputStream out = new PipedOutputStream(in);
- putRequest.setEntity(new InputStreamEntity(in, size));
- FutureTask futureTask =
- new FutureTask<>(() -> executeHttpRequest(putRequest));
- new Thread(futureTask).start();
- OzoneOutputStream outputStream = new OzoneOutputStream(
- new OutputStream() {
- @Override
- public void write(int b) throws IOException {
- out.write(b);
- }
-
- @Override
- public void close() throws IOException {
- try {
- out.close();
- EntityUtils.consume(futureTask.get());
- } catch (ExecutionException | InterruptedException e) {
- throw new IOException(e);
- }
- }
- });
-
- return outputStream;
- } catch (URISyntaxException e) {
- throw new IOException(e);
- }
- }
-
- /**
- * Get a valid Delegation Token. Not supported for RestClient.
- *
- * @param renewer the designated renewer for the token
- * @return Token
- * @throws IOException
- */
- @Override
- public Token getDelegationToken(Text renewer)
- throws IOException {
- throw new IOException("Method not supported");
- }
-
- /**
- * Renew an existing delegation token. Not supported for RestClient.
- *
- * @param token delegation token obtained earlier
- * @return the new expiration time
- * @throws IOException
- */
- @Override
- public long renewDelegationToken(Token token)
- throws IOException {
- throw new IOException("Method not supported");
- }
-
- /**
- * Cancel an existing delegation token. Not supported for RestClient.
- *
- * @param token delegation token
- * @throws IOException
- */
- @Override
- public void cancelDelegationToken(Token token)
- throws IOException {
- throw new IOException("Method not supported");
- }
-
- @Override
- public S3SecretValue getS3Secret(String kerberosID) throws IOException {
- throw new UnsupportedOperationException("Ozone REST protocol does not " +
- "support this operation.");
- }
-
- @Override
- public OMFailoverProxyProvider getOMProxyProvider() {
- return null;
- }
-
- @Override
- public KeyProvider getKeyProvider() throws IOException {
- // TODO: fix me to support kms instances for difference OMs
- return OzoneKMSUtil.getKeyProvider(conf, getKeyProviderUri());
- }
-
- @Override
- public URI getKeyProviderUri() throws IOException {
- return OzoneKMSUtil.getKeyProviderUri(ugi, null, null, conf);
- }
-
- @Override
- public OzoneInputStream getKey(
- String volumeName, String bucketName, String keyName)
- throws IOException {
- try {
- HddsClientUtils.verifyResourceName(volumeName, bucketName);
- Preconditions.checkNotNull(keyName);
- URIBuilder builder = new URIBuilder(ozoneRestUri);
- builder.setPath(PATH_SEPARATOR + volumeName +
- PATH_SEPARATOR + bucketName +
- PATH_SEPARATOR + keyName);
- HttpGet getRequest = new HttpGet(builder.build());
- addOzoneHeaders(getRequest);
- HttpEntity entity = executeHttpRequest(getRequest);
- PipedInputStream in = new PipedInputStream();
- OutputStream out = new PipedOutputStream(in);
- FutureTask futureTask =
- new FutureTask<>(() -> {
- entity.writeTo(out);
- out.close();
- return null;
- });
- new Thread(futureTask).start();
- OzoneInputStream inputStream = new OzoneInputStream(
- new InputStream() {
-
- @Override
- public int read() throws IOException {
- return in.read();
- }
-
- @Override
- public void close() throws IOException {
- in.close();
- EntityUtils.consume(entity);
- }
- });
-
- return inputStream;
- } catch (URISyntaxException e) {
- throw new IOException(e);
- }
- }
-
- @Override
- public void deleteKey(String volumeName, String bucketName, String keyName)
- throws IOException {
- try {
- HddsClientUtils.verifyResourceName(volumeName, bucketName);
- Preconditions.checkNotNull(keyName);
- URIBuilder builder = new URIBuilder(ozoneRestUri);
- builder.setPath(PATH_SEPARATOR + volumeName +
- PATH_SEPARATOR + bucketName + PATH_SEPARATOR + keyName);
- HttpDelete httpDelete = new HttpDelete(builder.build());
- addOzoneHeaders(httpDelete);
- EntityUtils.consume(executeHttpRequest(httpDelete));
- } catch (URISyntaxException e) {
- throw new IOException(e);
- }
- }
-
- @Override
- public void renameKey(String volumeName, String bucketName,
- String fromKeyName, String toKeyName) throws IOException {
- try {
- HddsClientUtils.verifyResourceName(volumeName, bucketName);
- HddsClientUtils.checkNotNull(fromKeyName, toKeyName);
- URIBuilder builder = new URIBuilder(ozoneRestUri);
- builder.setPath(PATH_SEPARATOR + volumeName + PATH_SEPARATOR + bucketName
- + PATH_SEPARATOR + fromKeyName);
- builder.addParameter(Header.OZONE_RENAME_TO_KEY_PARAM_NAME, toKeyName);
- HttpPost httpPost = new HttpPost(builder.build());
- addOzoneHeaders(httpPost);
- EntityUtils.consume(executeHttpRequest(httpPost));
- } catch (URISyntaxException e) {
- throw new IOException(e);
- }
- }
-
- @Override
- public List listKeys(String volumeName, String bucketName,
- String keyPrefix, String prevKey,
- int maxListResult)
- throws IOException {
- try {
- HddsClientUtils.verifyResourceName(volumeName);
- URIBuilder builder = new URIBuilder(ozoneRestUri);
- builder
- .setPath(PATH_SEPARATOR + volumeName + PATH_SEPARATOR + bucketName);
- builder.addParameter(Header.OZONE_INFO_QUERY_TAG,
- Header.OZONE_INFO_QUERY_KEY);
- builder.addParameter(Header.OZONE_LIST_QUERY_MAXKEYS,
- String.valueOf(maxListResult));
- addQueryParamter(Header.OZONE_LIST_QUERY_PREFIX, keyPrefix, builder);
- addQueryParamter(Header.OZONE_LIST_QUERY_PREVKEY, prevKey, builder);
- HttpGet httpGet = new HttpGet(builder.build());
- addOzoneHeaders(httpGet);
- HttpEntity response = executeHttpRequest(httpGet);
- ListKeys keyList = ListKeys.parse(EntityUtils.toString(response));
- EntityUtils.consume(response);
- return keyList.getKeyList().stream().map(keyInfo -> {
- long creationTime = 0, modificationTime = 0;
- try {
- creationTime = HddsClientUtils.formatDateTime(keyInfo.getCreatedOn());
- modificationTime =
- HddsClientUtils.formatDateTime(keyInfo.getModifiedOn());
- } catch (ParseException e) {
- LOG.warn("Parse exception in getting creation time for volume", e);
- }
- return new OzoneKey(volumeName, bucketName, keyInfo.getKeyName(),
- keyInfo.getSize(), creationTime, modificationTime,
- ReplicationType.valueOf(keyInfo.getType().toString()));
- }).collect(Collectors.toList());
- } catch (URISyntaxException e) {
- throw new IOException(e);
- }
- }
-
- @Override
- public OzoneKeyDetails getKeyDetails(
- String volumeName, String bucketName, String keyName)
- throws IOException {
- try {
- HddsClientUtils.verifyResourceName(volumeName, bucketName);
- Preconditions.checkNotNull(keyName);
- URIBuilder builder = new URIBuilder(ozoneRestUri);
- builder.setPath(PATH_SEPARATOR + volumeName +
- PATH_SEPARATOR + bucketName + PATH_SEPARATOR + keyName);
- builder.setParameter(Header.OZONE_INFO_QUERY_TAG,
- Header.OZONE_INFO_QUERY_KEY_DETAIL);
- HttpGet httpGet = new HttpGet(builder.build());
- addOzoneHeaders(httpGet);
- HttpEntity response = executeHttpRequest(httpGet);
- KeyInfoDetails keyInfo =
- KeyInfoDetails.parse(EntityUtils.toString(response));
-
- List ozoneKeyLocations = new ArrayList<>();
- keyInfo.getKeyLocations().forEach((a) -> ozoneKeyLocations.add(
- new OzoneKeyLocation(a.getContainerID(), a.getLocalID(),
- a.getLength(), a.getOffset())));
- OzoneKeyDetails key = new OzoneKeyDetails(volumeName,
- bucketName,
- keyInfo.getKeyName(),
- keyInfo.getSize(),
- HddsClientUtils.formatDateTime(keyInfo.getCreatedOn()),
- HddsClientUtils.formatDateTime(keyInfo.getModifiedOn()),
- ozoneKeyLocations, ReplicationType.valueOf(
- keyInfo.getType().toString()),
- new HashMap<>(), keyInfo.getFileEncryptionInfo());
- EntityUtils.consume(response);
- return key;
- } catch (URISyntaxException | ParseException e) {
- throw new IOException(e);
- }
- }
-
- @Override
- public void createS3Bucket(String userName, String s3BucketName)
- throws IOException {
- throw new UnsupportedOperationException("Ozone REST protocol does not " +
- "support this operation.");
- }
-
- @Override
- public void deleteS3Bucket(String s3BucketName)
- throws IOException {
- throw new UnsupportedOperationException("Ozone REST protocol does not " +
- "support this operation.");
- }
-
- @Override
- public String getOzoneBucketMapping(String s3BucketName) throws IOException {
- throw new UnsupportedOperationException("Ozone REST protocol does not " +
- "support this operation.");
- }
-
- @Override
- public String getOzoneVolumeName(String s3BucketName) throws IOException {
- throw new UnsupportedOperationException("Ozone REST protocol does not " +
- "support this operation.");
- }
-
- @Override
- public String getOzoneBucketName(String s3BucketName) throws IOException {
- throw new UnsupportedOperationException("Ozone REST protocol does not " +
- "support this operation.");
- }
-
- @Override
- public List listS3Buckets(String userName, String bucketPrefix,
- String prevBucket, int maxListResult)
- throws IOException {
- throw new UnsupportedOperationException("Ozone REST protocol does not " +
- "support this operation.");
- }
-
- /**
- * Adds Ozone headers to http request.
- *
- * @param httpRequest Http Request
- */
- private void addOzoneHeaders(HttpUriRequest httpRequest) {
- httpRequest.addHeader(HttpHeaders.AUTHORIZATION,
- Header.OZONE_SIMPLE_AUTHENTICATION_SCHEME + " " +
- ugi.getUserName());
- httpRequest.addHeader(HttpHeaders.DATE,
- HddsClientUtils.formatDateTime(Time.monotonicNow()));
- httpRequest.addHeader(Header.OZONE_VERSION_HEADER,
- Header.OZONE_V1_VERSION_HEADER);
- }
-
- /**
- * Sends the http request to server and returns the response HttpEntity.
- * It's responsibility of the caller to consume and close response HttpEntity
- * by calling {@code EntityUtils.consume}
- *
- * @param httpUriRequest http request
- * @throws IOException
- */
- private HttpEntity executeHttpRequest(HttpUriRequest httpUriRequest)
- throws IOException {
- HttpResponse response = httpClient.execute(httpUriRequest);
- int errorCode = response.getStatusLine().getStatusCode();
- HttpEntity entity = response.getEntity();
- if ((errorCode == HTTP_OK) || (errorCode == HTTP_CREATED)) {
- return entity;
- }
- if (entity != null) {
- throw new IOException(
- OzoneException.parse(EntityUtils.toString(entity)));
- } else {
- throw new IOException("Unexpected null in http payload," +
- " while processing request");
- }
- }
-
- /**
- * Converts OzoneConts.Versioning to boolean.
- *
- * @param version
- * @return corresponding boolean value
- */
- private Boolean getBucketVersioningFlag(
- OzoneConsts.Versioning version) {
- if(version != null) {
- switch(version) {
- case ENABLED:
- return true;
- case NOT_DEFINED:
- case DISABLED:
- default:
- return false;
- }
- }
- return false;
- }
-
- /**
- * Converts Bucket versioning flag into OzoneConts.Versioning.
- *
- * @param flag versioning flag
- * @return corresponding OzoneConts.Versionin
- */
- private OzoneConsts.Versioning getBucketVersioning(Boolean flag) {
- if(flag != null) {
- if(flag) {
- return OzoneConsts.Versioning.ENABLED;
- } else {
- return OzoneConsts.Versioning.DISABLED;
- }
- }
- return OzoneConsts.Versioning.NOT_DEFINED;
- }
-
- @Override
- public void close() throws IOException {
- httpClient.close();
- }
-
- private void addQueryParamter(String param, String value,
- URIBuilder builder) {
- if (!Strings.isNullOrEmpty(value)) {
- builder.addParameter(param, value);
- }
- }
-
- @Override
- public OmMultipartInfo initiateMultipartUpload(String volumeName,
- String bucketName,
- String keyName,
- ReplicationType type,
- ReplicationFactor factor)
- throws IOException {
- throw new UnsupportedOperationException("Ozone REST protocol does not " +
- "support this operation.");
- }
-
- @Override
- public OzoneOutputStream createMultipartKey(String volumeName,
- String bucketName,
- String keyName,
- long size,
- int partNumber,
- String uploadID)
- throws IOException {
- throw new UnsupportedOperationException("Ozone REST protocol does not " +
- "support this operation.");
- }
-
- @Override
- public OmMultipartUploadCompleteInfo completeMultipartUpload(
- String volumeName, String bucketName, String keyName, String uploadID,
- Map partsMap) throws IOException {
- throw new UnsupportedOperationException("Ozone REST protocol does not " +
- "support this operation.");
- }
-
- @Override
- public void abortMultipartUpload(String volumeName,
- String bucketName, String keyName, String uploadID) throws IOException {
- throw new UnsupportedOperationException("Ozone REST protocol does not " +
- "support this operation.");
- }
-
- @Override
- public OzoneMultipartUploadPartListParts listParts(String volumeName,
- String bucketName, String keyName, String uploadID, int partNumberMarker,
- int maxParts) throws IOException {
- throw new UnsupportedOperationException("Ozone REST protocol does not " +
- "support this operation.");
- }
-
- /**
- * Get CanonicalServiceName for ozone delegation token.
- * @return Canonical Service Name of ozone delegation token.
- */
- public String getCanonicalServiceName(){
- throw new UnsupportedOperationException("Ozone REST protocol does not " +
- "support this operation.");
- }
-
- @Override
- public OzoneFileStatus getOzoneFileStatus(String volumeName,
- String bucketName, String keyName) throws IOException {
- throw new UnsupportedOperationException("Ozone REST protocol does not " +
- "support this operation.");
- }
-
- @Override
- public void createDirectory(String volumeName, String bucketName,
- String keyName) {
- throw new UnsupportedOperationException(
- "Ozone REST protocol does not " + "support this operation.");
- }
-
- @Override
- public OzoneInputStream readFile(String volumeName, String bucketName,
- String keyName) {
- throw new UnsupportedOperationException(
- "Ozone REST protocol does not " + "support this operation.");
- }
-
- @Override
- public OzoneOutputStream createFile(String volumeName, String bucketName,
- String keyName, long size, ReplicationType type, ReplicationFactor factor,
- boolean overWrite, boolean recursive) {
- throw new UnsupportedOperationException(
- "Ozone REST protocol does not " + "support this operation.");
- }
-
- @Override
- public List listStatus(String volumeName, String bucketName,
- String keyName, boolean recursive, String startKey, long numEntries)
- throws IOException {
- throw new UnsupportedOperationException(
- "Ozone REST protocol does not " + "support this operation.");
- }
-
- /**
- * Add acl for Ozone object. Return true if acl is added successfully else
- * false.
- *
- * @param obj Ozone object for which acl should be added.
- * @param acl ozone acl top be added.
- * @throws IOException if there is error.
- */
- @Override
- public boolean addAcl(OzoneObj obj, OzoneAcl acl) throws IOException {
- throw new UnsupportedOperationException("Ozone REST protocol does not" +
- " support this operation.");
- }
-
- /**
- * Remove acl for Ozone object. Return true if acl is removed successfully
- * else false.
- *
- * @param obj Ozone object.
- * @param acl Ozone acl to be removed.
- * @throws IOException if there is error.
- */
- @Override
- public boolean removeAcl(OzoneObj obj, OzoneAcl acl) throws IOException {
- throw new UnsupportedOperationException("Ozone REST protocol does not" +
- " support this operation.");
- }
-
- /**
- * Acls to be set for given Ozone object. This operations reset ACL for given
- * object to list of ACLs provided in argument.
- *
- * @param obj Ozone object.
- * @param acls List of acls.
- * @throws IOException if there is error.
- */
- @Override
- public boolean setAcl(OzoneObj obj, List acls) throws IOException {
- throw new UnsupportedOperationException("Ozone REST protocol does not" +
- " support this operation.");
- }
-
- /**
- * Returns list of ACLs for given Ozone object.
- *
- * @param obj Ozone object.
- * @throws IOException if there is error.
- */
- @Override
- public List getAcl(OzoneObj obj) throws IOException {
- throw new UnsupportedOperationException("Ozone REST protocol does not" +
- " support this operation.");
- }
-}
diff --git a/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/rest/RestServerSelector.java b/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/rest/RestServerSelector.java
deleted file mode 100644
index fbd6eb8ea9a..00000000000
--- a/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/rest/RestServerSelector.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.hadoop.ozone.client.rest;
-
-import org.apache.hadoop.ozone.om.helpers.ServiceInfo;
-
-import java.util.List;
-
-/**
- * The implementor of this interface should select the REST server which will
- * be used by the client to connect to Ozone Cluster, given list of
- * REST Servers/DataNodes (DataNodes are the ones which hosts REST Service).
- */
-public interface RestServerSelector {
-
- /**
- * Returns the REST Service which will be used by the client for connection.
- *
- * @param restServices list of available REST servers
- * @return ServiceInfo
- */
- ServiceInfo getRestServer(List restServices);
-
-}
diff --git a/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/rest/exceptions/package-info.java b/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/rest/exceptions/package-info.java
deleted file mode 100644
index 233e7882e2d..00000000000
--- a/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/rest/exceptions/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.hadoop.ozone.client.rest.exceptions;
-
-/**
- * This package contains ozone rest client libraries.
- */
diff --git a/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/rest/headers/package-info.java b/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/rest/headers/package-info.java
deleted file mode 100644
index 340709f492d..00000000000
--- a/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/rest/headers/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-@InterfaceAudience.Private
-package org.apache.hadoop.ozone.client.rest.headers;
-
-import org.apache.hadoop.classification.InterfaceAudience;
diff --git a/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/rest/package-info.java b/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/rest/package-info.java
deleted file mode 100644
index ebcc104811f..00000000000
--- a/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/rest/package-info.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.hadoop.ozone.client.rest;
-
-/**
- * This package contains Ozone rest client library classes.
- */
diff --git a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/client/rest/OzoneException.java b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/client/rest/OzoneException.java
deleted file mode 100644
index 953e3991f7b..00000000000
--- a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/client/rest/OzoneException.java
+++ /dev/null
@@ -1,267 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.hadoop.ozone.client.rest;
-
-
-import java.io.IOException;
-
-import org.apache.hadoop.classification.InterfaceAudience;
-
-import com.fasterxml.jackson.annotation.JsonAutoDetect;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.ObjectReader;
-
-/**
- * Class the represents various errors returned by the
- * Ozone Layer.
- */
-@InterfaceAudience.Private
-public class OzoneException extends Exception {
-
- private static final ObjectReader READER =
- new ObjectMapper().readerFor(OzoneException.class);
- private static final ObjectMapper MAPPER;
-
- static {
- MAPPER = new ObjectMapper();
- MAPPER.setVisibility(
- MAPPER.getSerializationConfig().getDefaultVisibilityChecker()
- .withCreatorVisibility(JsonAutoDetect.Visibility.NONE)
- .withFieldVisibility(JsonAutoDetect.Visibility.NONE)
- .withGetterVisibility(JsonAutoDetect.Visibility.NONE)
- .withIsGetterVisibility(JsonAutoDetect.Visibility.NONE)
- .withSetterVisibility(JsonAutoDetect.Visibility.NONE));
- }
-
- @JsonProperty("httpCode")
- private long httpCode;
- @JsonProperty("shortMessage")
- private String shortMessage;
- @JsonProperty("resource")
- private String resource;
- @JsonProperty("message")
- private String message;
- @JsonProperty("requestID")
- private String requestId;
- @JsonProperty("hostName")
- private String hostID;
-
- /**
- * Constructs a new exception with {@code null} as its detail message. The
- * cause is not initialized, and may subsequently be initialized by a call
- * to {@link #initCause}.
- *
- * This constructor is needed by Json Serializer.
- */
- public OzoneException() {
- }
-
-
- /**
- * Constructor that allows a shortMessage and exception.
- *
- * @param httpCode Error Code
- * @param shortMessage Short Message
- * @param ex Exception
- */
- public OzoneException(long httpCode, String shortMessage, Exception ex) {
- super(ex);
- this.message = ex.getMessage();
- this.shortMessage = shortMessage;
- this.httpCode = httpCode;
- }
-
-
- /**
- * Constructor that allows a shortMessage.
- *
- * @param httpCode Error Code
- * @param shortMessage Short Message
- */
- public OzoneException(long httpCode, String shortMessage) {
- this.shortMessage = shortMessage;
- this.httpCode = httpCode;
- }
-
- /**
- * Constructor that allows a shortMessage and long message.
- *
- * @param httpCode Error Code
- * @param shortMessage Short Message
- * @param message long error message
- */
- public OzoneException(long httpCode, String shortMessage, String message) {
- this.shortMessage = shortMessage;
- this.message = message;
- this.httpCode = httpCode;
- }
-
- /**
- * Constructor that allows a shortMessage, a long message and an exception.
- *
- * @param httpCode Error code
- * @param shortMessage Short message
- * @param message Long error message
- * @param ex Exception
- */
- public OzoneException(long httpCode, String shortMessage,
- String message, Exception ex) {
- super(ex);
- this.shortMessage = shortMessage;
- this.message = message;
- this.httpCode = httpCode;
- }
-
- /**
- * Returns the Resource that was involved in the stackTraceString.
- *
- * @return String
- */
- public String getResource() {
- return resource;
- }
-
- /**
- * Sets Resource.
- *
- * @param resourceName - Name of the Resource
- */
- public void setResource(String resourceName) {
- this.resource = resourceName;
- }
-
- /**
- * Gets a detailed message for the error.
- *
- * @return String
- */
- public String getMessage() {
- return message;
- }
-
- /**
- * Sets the error message.
- *
- * @param longMessage - Long message
- */
- public void setMessage(String longMessage) {
- this.message = longMessage;
- }
-
- /**
- * Returns request Id.
- *
- * @return String
- */
- public String getRequestId() {
- return requestId;
- }
-
- /**
- * Sets request ID.
- *
- * @param ozoneRequestId Request ID generated by the Server
- */
- public void setRequestId(String ozoneRequestId) {
- this.requestId = ozoneRequestId;
- }
-
- /**
- * Returns short error string.
- *
- * @return String
- */
- public String getShortMessage() {
- return shortMessage;
- }
-
- /**
- * Sets short error string.
- *
- * @param shortError Short Error Code
- */
- public void setShortMessage(String shortError) {
- this.shortMessage = shortError;
- }
-
- /**
- * Returns hostID.
- *
- * @return String
- */
- public String getHostID() {
- return hostID;
- }
-
- /**
- * Sets host ID.
- *
- * @param hostName host Name
- */
- public void setHostID(String hostName) {
- this.hostID = hostName;
- }
-
- /**
- * Returns http error code.
- *
- * @return long
- */
- public long getHttpCode() {
- return httpCode;
- }
-
- /**
- * Sets http status.
- *
- * @param httpStatus http error code.
- */
- public void setHttpCode(long httpStatus) {
- this.httpCode = httpStatus;
- }
-
- /**
- * Returns a Json String.
- *
- * @return JSON representation of the Error
- */
- public String toJsonString() {
- try {
- return MAPPER.writeValueAsString(this);
- } catch (IOException ex) {
- // TODO : Log this error on server side.
- }
- // TODO : Replace this with a JSON Object -- That represents this error.
- return "500 Internal Server Error";
- }
-
- /**
- * Parses an Exception record.
- *
- * @param jsonString - Exception in Json format.
- *
- * @return OzoneException Object
- *
- * @throws IOException
- */
- public static OzoneException parse(String jsonString) throws IOException {
- return READER.readValue(jsonString);
- }
-}
diff --git a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/client/rest/headers/Header.java b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/client/rest/headers/Header.java
deleted file mode 100644
index 3e404937061..00000000000
--- a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/client/rest/headers/Header.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.hadoop.ozone.client.rest.headers;
-
-import org.apache.hadoop.classification.InterfaceAudience;
-
-/**
- * OZONE specific HTTP headers.
- */
-@InterfaceAudience.Private
-public final class Header {
- public static final String OZONE_QUOTA_BYTES = "BYTES";
- public static final String OZONE_QUOTA_MB = "MB";
- public static final String OZONE_QUOTA_GB = "GB";
- public static final String OZONE_QUOTA_TB = "TB";
- public static final String OZONE_QUOTA_REMOVE = "remove";
- public static final String OZONE_QUOTA_UNDEFINED = "undefined";
- public static final String OZONE_EMPTY_STRING="";
- public static final String OZONE_DEFAULT_LIST_SIZE = "1000";
-
- public static final String OZONE_USER = "x-ozone-user";
- public static final String OZONE_SIMPLE_AUTHENTICATION_SCHEME = "OZONE";
- public static final String OZONE_VERSION_HEADER = "x-ozone-version";
- public static final String OZONE_V1_VERSION_HEADER ="v1";
-
- public static final String OZONE_LIST_QUERY_SERVICE = "service";
-
- public static final String OZONE_INFO_QUERY_VOLUME = "volume";
- public static final String OZONE_INFO_QUERY_BUCKET = "bucket";
- public static final String OZONE_INFO_QUERY_KEY = "key";
- public static final String OZONE_INFO_QUERY_KEY_DETAIL = "key-detail";
-
- public static final String OZONE_REQUEST_ID = "x-ozone-request-id";
- public static final String OZONE_SERVER_NAME = "x-ozone-server-name";
-
- public static final String OZONE_STORAGE_TYPE = "x-ozone-storage-type";
-
- public static final String OZONE_BUCKET_VERSIONING =
- "x-ozone-bucket-versioning";
-
- public static final String OZONE_ACLS = "x-ozone-acls";
- public static final String OZONE_ACL_ADD = "ADD";
- public static final String OZONE_ACL_REMOVE = "REMOVE";
-
- public static final String OZONE_INFO_QUERY_TAG ="info";
- public static final String OZONE_QUOTA_QUERY_TAG ="quota";
- public static final String CONTENT_MD5 = "Content-MD5";
- public static final String OZONE_LIST_QUERY_PREFIX="prefix";
- public static final String OZONE_LIST_QUERY_MAXKEYS="max-keys";
- public static final String OZONE_LIST_QUERY_PREVKEY="prev-key";
- public static final String OZONE_LIST_QUERY_ROOTSCAN="root-scan";
-
- public static final String OZONE_RENAME_TO_KEY_PARAM_NAME = "toKey";
-
- private Header() {
- // Never constructed.
- }
-}
diff --git a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/client/rest/headers/package-info.java b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/client/rest/headers/package-info.java
deleted file mode 100644
index 76bc206e53d..00000000000
--- a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/client/rest/headers/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.hadoop.ozone.client.rest.headers;
-
-/**
- * Ozone HTTP Header utility.
- */
\ No newline at end of file
diff --git a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/client/rest/package-info.java b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/client/rest/package-info.java
deleted file mode 100644
index fc86dbb0576..00000000000
--- a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/client/rest/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.hadoop.ozone.client.rest;
-
-/**
- * Ozone REST interface.
- */
\ No newline at end of file
diff --git a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/client/rest/response/BucketInfo.java b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/client/rest/response/BucketInfo.java
deleted file mode 100644
index 61d051de98b..00000000000
--- a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/client/rest/response/BucketInfo.java
+++ /dev/null
@@ -1,248 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.hadoop.ozone.client.rest.response;
-
-import java.io.IOException;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.apache.hadoop.hdds.protocol.StorageType;
-import org.apache.hadoop.ozone.OzoneAcl;
-import org.apache.hadoop.ozone.OzoneConsts;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.ObjectReader;
-import com.google.common.base.Preconditions;
-
-/**
- * BucketInfo class is used used for parsing json response
- * when BucketInfo Call is made.
- */
-public class BucketInfo implements Comparable {
-
- private static final ObjectReader READER =
- new ObjectMapper().readerFor(BucketInfo.class);
-
- private String volumeName;
- private String bucketName;
- private String createdOn;
- private List acls;
- private OzoneConsts.Versioning versioning;
- private StorageType storageType;
- private String bekName;
-
- /**
- * Constructor for BucketInfo.
- *
- * @param volumeName
- * @param bucketName
- */
- public BucketInfo(String volumeName, String bucketName) {
- this.volumeName = volumeName;
- this.bucketName = bucketName;
- }
-
-
- /**
- * Default constructor for BucketInfo.
- */
- public BucketInfo() {
- acls = new LinkedList<>();
- }
-
- /**
- * Parse a JSON string into BucketInfo Object.
- *
- * @param jsonString Json String
- * @return BucketInfo
- * @throws IOException
- */
- public static BucketInfo parse(String jsonString) throws IOException {
- return READER.readValue(jsonString);
- }
-
- /**
- * Returns a List of ACLs set on the Bucket.
- *
- * @return List of Acl
- */
- public List getAcls() {
- return acls;
- }
-
- /**
- * Sets ACls.
- *
- * @param acls Acl list
- */
- public void setAcls(List acls) {
- this.acls = acls;
- }
-
- /**
- * Returns Storage Type info.
- *
- * @return Storage Type of the bucket
- */
- public StorageType getStorageType() {
- return storageType;
- }
-
- /**
- * Sets the Storage Type.
- *
- * @param storageType Storage Type
- */
- public void setStorageType(StorageType storageType) {
- this.storageType = storageType;
- }
-
- /**
- * Returns versioning.
- *
- * @return versioning Enum
- */
- public OzoneConsts.Versioning getVersioning() {
- return versioning;
- }
-
- /**
- * Sets Versioning.
- *
- * @param versioning
- */
- public void setVersioning(OzoneConsts.Versioning versioning) {
- this.versioning = versioning;
- }
-
-
- /**
- * Gets bucket Name.
- *
- * @return String
- */
- public String getBucketName() {
- return bucketName;
- }
-
- /**
- * Sets bucket Name.
- *
- * @param bucketName Name of the bucket
- */
- public void setBucketName(String bucketName) {
- this.bucketName = bucketName;
- }
-
- /**
- * Sets creation time of the bucket.
- *
- * @param creationTime Date String
- */
- public void setCreatedOn(String creationTime) {
- this.createdOn = creationTime;
- }
-
- /**
- * Returns creation time.
- *
- * @return creation time of bucket.
- */
- public String getCreatedOn() {
- return createdOn;
- }
-
- /**
- * Returns Volume Name.
- *
- * @return String volume name
- */
- public String getVolumeName() {
- return volumeName;
- }
-
- /**
- * Sets the Volume Name of bucket.
- *
- * @param volumeName volumeName
- */
- public void setVolumeName(String volumeName) {
- this.volumeName = volumeName;
- }
-
- /**
- * Return bucket encryption key name.
- * @return bucket encryption key name
- */
- public String getEncryptionKeyName() {
- return bekName;
- }
-
- /**
- * Sets the bucket encryption key name.
- * @param name bucket encryption key name
- */
- public void setEncryptionKeyName(String name) {
- this.bekName = name;
- }
-
- /**
- * Compares this object with the specified object for order. Returns a
- * negative integer, zero, or a positive integer as this object is less
- * than, equal to, or greater than the specified object.
- *
- * Please note : BucketInfo compare functions are used only within the
- * context of a volume, hence volume name is purposefully ignored in
- * compareTo, equal and hashcode functions of this class.
- */
- @Override
- public int compareTo(BucketInfo o) {
- Preconditions.checkState(o.getVolumeName().equals(this.getVolumeName()));
- return this.bucketName.compareTo(o.getBucketName());
- }
-
- /**
- * Checks if two bucketInfo's are equal.
- * @param o Object BucketInfo
- * @return True or False
- */
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (!(o instanceof BucketInfo)) {
- return false;
- }
-
- BucketInfo that = (BucketInfo) o;
- Preconditions.checkState(that.getVolumeName().equals(this.getVolumeName()));
- return bucketName.equals(that.bucketName);
-
- }
-
- /**
- * Hash Code for this object.
- * @return int
- */
- @Override
- public int hashCode() {
- return bucketName.hashCode();
- }
-
-}
diff --git a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/client/rest/response/KeyInfo.java b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/client/rest/response/KeyInfo.java
deleted file mode 100644
index 299826fa941..00000000000
--- a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/client/rest/response/KeyInfo.java
+++ /dev/null
@@ -1,236 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.hadoop.ozone.client.rest.response;
-
-import java.io.IOException;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.ObjectReader;
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
-import org.apache.hadoop.hdds.client.ReplicationType;
-
-/**
- * KeyInfo class is used used for parsing json response
- * when KeyInfo Call is made.
- */
-public class KeyInfo implements Comparable {
-
- private static final ObjectReader READER =
- new ObjectMapper().readerFor(KeyInfo.class);
-
- private long version;
- private String md5hash;
- private String createdOn;
- private String modifiedOn;
- private long size;
- private String keyName;
- private ReplicationType type;
-
- /**
- * Return replication type of the key.
- *
- * @return replication type
- */
- public ReplicationType getType() {
- return type;
- }
-
- /**
- * Set replication type of the key.
- *
- * @param replicationType
- */
- public void setType(ReplicationType replicationType) {
- this.type = replicationType;
- }
-
- /**
- * When this key was created.
- *
- * @return Date String
- */
- public String getCreatedOn() {
- return createdOn;
- }
-
- /**
- * When this key was modified.
- *
- * @return Date String
- */
- public String getModifiedOn() {
- return modifiedOn;
- }
-
- /**
- * When this key was created.
- *
- * @param createdOn Date String
- */
- public void setCreatedOn(String createdOn) {
- this.createdOn = createdOn;
- }
-
- /**
- * When this key was modified.
- *
- * @param modifiedOn Date String
- */
- public void setModifiedOn(String modifiedOn) {
- this.modifiedOn = modifiedOn;
- }
-
- /**
- * Gets the Key name of this object.
- *
- * @return String
- */
- public String getKeyName() {
- return keyName;
- }
-
- /**
- * Sets the Key name of this object.
- *
- * @param keyName String
- */
- public void setKeyName(String keyName) {
- this.keyName = keyName;
- }
-
- /**
- * Returns the MD5 Hash for the data of this key.
- *
- * @return String MD5
- */
- public String getMd5hash() {
- return md5hash;
- }
-
- /**
- * Sets the MD5 value of this key.
- *
- * @param md5hash Md5 of this file
- */
- public void setMd5hash(String md5hash) {
- this.md5hash = md5hash;
- }
-
- /**
- * Number of bytes stored in the data part of this key.
- *
- * @return long size of the data file
- */
- public long getSize() {
- return size;
- }
-
- /**
- * Sets the size of the data part of this key.
- *
- * @param size Size in long
- */
- public void setSize(long size) {
- this.size = size;
- }
-
- /**
- * Version of this key.
- *
- * @return returns the version of this key.
- */
- public long getVersion() {
- return version;
- }
-
- /**
- * Sets the version of this key.
- *
- * @param version - Version String
- */
- public void setVersion(long version) {
- this.version = version;
- }
-
- /**
- * Compares this object with the specified object for order. Returns a
- * negative integer, zero, or a positive integer as this object is less
- * than, equal to, or greater than the specified object.
- *
- * @param o the object to be compared.
- * @return a negative integer, zero, or a positive integer as this object
- * is less than, equal to, or greater than the specified object.
- * @throws NullPointerException if the specified object is null
- * @throws ClassCastException if the specified object's type prevents it
- * from being compared to this object.
- */
- @Override
- public int compareTo(KeyInfo o) {
- if (this.keyName.compareTo(o.getKeyName()) != 0) {
- return this.keyName.compareTo(o.getKeyName());
- }
-
- if (this.getVersion() == o.getVersion()) {
- return 0;
- }
- if (this.getVersion() < o.getVersion()) {
- return -1;
- }
- return 1;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
-
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
-
- KeyInfo keyInfo = (KeyInfo) o;
-
- return new EqualsBuilder()
- .append(version, keyInfo.version)
- .append(keyName, keyInfo.keyName)
- .isEquals();
- }
-
- @Override
- public int hashCode() {
- return new HashCodeBuilder(17, 37)
- .append(version)
- .append(keyName)
- .toHashCode();
- }
-
- /**
- * Parse a string to return KeyInfo Object.
- *
- * @param jsonString Json String
- * @return keyInfo
- * @throws IOException
- */
- public static KeyInfo parse(String jsonString) throws IOException {
- return READER.readValue(jsonString);
- }
-
-}
\ No newline at end of file
diff --git a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/client/rest/response/KeyInfoDetails.java b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/client/rest/response/KeyInfoDetails.java
deleted file mode 100644
index b1532397162..00000000000
--- a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/client/rest/response/KeyInfoDetails.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.hadoop.ozone.client.rest.response;
-
-import java.io.IOException;
-import java.util.List;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.ObjectReader;
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
-import org.apache.hadoop.fs.FileEncryptionInfo;
-
-/**
- * KeyInfoDetails class is used for parsing json response
- * when KeyInfoDetails Call is made.
- */
-public class KeyInfoDetails extends KeyInfo {
-
- private static final ObjectReader READER =
- new ObjectMapper().readerFor(KeyInfoDetails.class);
-
- /**
- * a list of Map which maps localID to ContainerID
- * to specify replica locations.
- */
- private List keyLocations;
-
- private FileEncryptionInfo feInfo;
-
- /**
- * Constructor needed for json serialization.
- */
- public KeyInfoDetails() {
- }
-
- /**
- * Set details of key location.
- *
- * @param locations - details of key location
- */
- public void setKeyLocation(List locations) {
- this.keyLocations = locations;
- }
-
- /**
- * Returns details of key location.
- *
- * @return volumeName
- */
- public List getKeyLocations() {
- return keyLocations;
- }
-
- public void setFileEncryptionInfo(FileEncryptionInfo info) {
- this.feInfo = info;
- }
-
- public FileEncryptionInfo getFileEncryptionInfo() {
- return feInfo;
- }
-
- /**
- * Parse a string to return KeyInfoDetails Object.
- *
- * @param jsonString Json String
- * @return KeyInfoDetails
- * @throws IOException
- */
- public static KeyInfoDetails parse(String jsonString) throws IOException {
- return READER.readValue(jsonString);
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
-
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
-
- KeyInfoDetails that = (KeyInfoDetails) o;
-
- return new EqualsBuilder()
- .append(getVersion(), that.getVersion())
- .append(getKeyName(), that.getKeyName())
- .append(keyLocations, that.keyLocations)
- .isEquals();
- }
-
- @Override
- public int hashCode() {
- return new HashCodeBuilder(21, 33)
- .append(getVersion())
- .append(getKeyName())
- .append(keyLocations)
- .toHashCode();
- }
-}
-
diff --git a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/client/rest/response/KeyLocation.java b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/client/rest/response/KeyLocation.java
deleted file mode 100644
index e5f46980ab1..00000000000
--- a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/client/rest/response/KeyLocation.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.hadoop.ozone.client.rest.response;
-
-/**
- * KeyLocation class is used used for parsing json response
- * when KeyInfoDetails Call is made.
- */
-public class KeyLocation {
- /**
- * Which container this key stored.
- */
- private long containerID;
- /**
- * Which block this key stored inside a container.
- */
- private long localID;
- /**
- * Data length of this key replica.
- */
- private long length;
- /**
- * Offset of this key.
- */
- private long offset;
-
- /**
- * Empty constructor for Json serialization.
- */
- public KeyLocation() {
-
- }
-
- /**
- * Constructs KeyLocation.
- */
- public KeyLocation(long containerID, long localID,
- long length, long offset) {
- this.containerID = containerID;
- this.localID = localID;
- this.length = length;
- this.offset = offset;
- }
-
- /**
- * Returns the containerID of this Key.
- */
- public long getContainerID() {
- return containerID;
- }
-
- /**
- * Returns the localID of this Key.
- */
- public long getLocalID() {
- return localID;
- }
-
- /**
- * Returns the length of this Key.
- */
- public long getLength() {
- return length;
- }
-
- /**
- * Returns the offset of this Key.
- */
- public long getOffset() {
- return offset;
- }
-
-}
diff --git a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/client/rest/response/VolumeInfo.java b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/client/rest/response/VolumeInfo.java
deleted file mode 100644
index f98b56a6d32..00000000000
--- a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/client/rest/response/VolumeInfo.java
+++ /dev/null
@@ -1,215 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.hadoop.ozone.client.rest.response;
-
-import java.io.IOException;
-
-import org.apache.hadoop.classification.InterfaceAudience;
-import org.apache.hadoop.hdds.client.OzoneQuota;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.ObjectReader;
-
-/**
- * VolumeInfo Class is used for parsing json response
- * when VolumeInfo Call is made.
- */
-@InterfaceAudience.Private
-public class VolumeInfo implements Comparable {
-
-
- private static final ObjectReader READER =
- new ObjectMapper().readerFor(VolumeInfo.class);
-
- private VolumeOwner owner;
- private OzoneQuota quota;
- private String volumeName;
- private String createdOn;
- private String createdBy;
-
-
- /**
- * Constructor for VolumeInfo.
- *
- * @param volumeName - Name of the Volume
- * @param createdOn _ Date String
- * @param createdBy - Person who created it
- */
- public VolumeInfo(String volumeName, String createdOn,
- String createdBy) {
- this.volumeName = volumeName;
- this.createdOn = createdOn;
- this.createdBy = createdBy;
- }
-
- /**
- * Constructor for VolumeInfo.
- */
- public VolumeInfo() {
- }
-
- /**
- * gets the volume name.
- *
- * @return Volume Name
- */
- public String getVolumeName() {
- return volumeName;
- }
-
- /**
- * Sets the volume name.
- *
- * @param volumeName Volume Name
- */
- public void setVolumeName(String volumeName) {
- this.volumeName = volumeName;
- }
-
-
- /**
- * Returns the name of the person who created this volume.
- *
- * @return Name of Admin who created this
- */
- public String getCreatedBy() {
- return createdBy;
- }
-
- /**
- * Sets the user name of the person who created this volume.
- *
- * @param createdBy UserName
- */
- public void setCreatedBy(String createdBy) {
- this.createdBy = createdBy;
- }
-
- /**
- * Gets the date on which this volume was created.
- *
- * @return Date String
- */
- public String getCreatedOn() {
- return createdOn;
- }
-
- /**
- * Sets the date string.
- *
- * @param createdOn Date String
- */
- public void setCreatedOn(String createdOn) {
- this.createdOn = createdOn;
- }
-
- /**
- * Returns the owner info.
- *
- * @return OwnerInfo
- */
- public VolumeOwner getOwner() {
- return owner;
- }
-
- /**
- * Sets the owner.
- *
- * @param owner OwnerInfo
- */
- public void setOwner(VolumeOwner owner) {
- this.owner = owner;
- }
-
- /**
- * Returns the quota information on a volume.
- *
- * @return Quota
- */
- public OzoneQuota getQuota() {
- return quota;
- }
-
- /**
- * Sets the quota info.
- *
- * @param quota Quota Info
- */
- public void setQuota(OzoneQuota quota) {
- this.quota = quota;
- }
-
- /**
- * Comparable Interface.
- * @param o VolumeInfo Object.
- * @return Result of comparison
- */
- @Override
- public int compareTo(VolumeInfo o) {
- return this.volumeName.compareTo(o.getVolumeName());
- }
-
- /**
- * Returns VolumeInfo class from json string.
- *
- * @param data Json String
- *
- * @return VolumeInfo
- *
- * @throws IOException
- */
- public static VolumeInfo parse(String data) throws IOException {
- return READER.readValue(data);
- }
-
- /**
- * Indicates whether some other object is "equal to" this one.
- *
- * @param obj the reference object with which to compare.
- *
- * @return {@code true} if this object is the same as the obj
- * argument; {@code false} otherwise.
- */
- @Override
- public boolean equals(Object obj) {
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- VolumeInfo otherInfo = (VolumeInfo) obj;
- return otherInfo.getVolumeName().equals(this.getVolumeName());
- }
-
- /**
- * Returns a hash code value for the object. This method is
- * supported for the benefit of hash tables such as those provided by
- * HashMap.
- * @return a hash code value for this object.
- *
- * @see Object#equals(Object)
- * @see System#identityHashCode
- */
- @Override
- public int hashCode() {
- return getVolumeName().hashCode();
- }
-
-}
diff --git a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/client/rest/response/VolumeOwner.java b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/client/rest/response/VolumeOwner.java
deleted file mode 100644
index d4dbad4cbf6..00000000000
--- a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/client/rest/response/VolumeOwner.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.hadoop.ozone.client.rest.response;
-
-import org.apache.hadoop.classification.InterfaceAudience;
-
-import com.fasterxml.jackson.annotation.JsonInclude;
-
-/**
- * Volume Owner represents the owner of a volume.
- *
- * This is a class instead of a string since we might need to extend this class
- * to support other forms of authentication.
- */
-@InterfaceAudience.Private
-public class VolumeOwner {
- @JsonInclude(JsonInclude.Include.NON_NULL)
- private String name;
-
- /**
- * Constructor for VolumeOwner.
- *
- * @param name name of the User
- */
- public VolumeOwner(String name) {
- this.name = name;
- }
-
- /**
- * Constructs Volume Owner.
- */
- public VolumeOwner() {
- name = null;
- }
-
- /**
- * Returns the user name.
- *
- * @return Name
- */
- public String getName() {
- return name;
- }
-
-}
diff --git a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/client/rest/response/package-info.java b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/client/rest/response/package-info.java
deleted file mode 100644
index 432b029b6fb..00000000000
--- a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/client/rest/response/package-info.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.hadoop.ozone.client.rest.response;
-
-/**
- * This package contains class for ozone rest client library.
- */
\ No newline at end of file
diff --git a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/ServiceInfo.java b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/ServiceInfo.java
index fb496441aeb..dce4f8e20d2 100644
--- a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/ServiceInfo.java
+++ b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/ServiceInfo.java
@@ -24,13 +24,11 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectReader;
import com.fasterxml.jackson.databind.ObjectWriter;
import com.google.common.base.Preconditions;
-import org.apache.hadoop.ozone.client.rest.response.BucketInfo;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos
.ServicePort;
import org.apache.hadoop.hdds.protocol.proto.HddsProtos.NodeType;
-import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -165,27 +163,6 @@ public final class ServiceInfo {
serviceInfo.getServicePortsList());
}
- /**
- * Returns a JSON string of this object.
- *
- * @return String - json string
- * @throws IOException
- */
- public String toJsonString() throws IOException {
- return WRITER.writeValueAsString(this);
- }
-
- /**
- * Parse a JSON string into ServiceInfo Object.
- *
- * @param jsonString Json String
- * @return BucketInfo
- * @throws IOException
- */
- public static BucketInfo parse(String jsonString) throws IOException {
- return READER.readValue(jsonString);
- }
-
/**
* Creates a new builder to build {@link ServiceInfo}.
* @return {@link ServiceInfo.Builder}
diff --git a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/web/handlers/BucketArgs.java b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/web/handlers/BucketArgs.java
deleted file mode 100644
index 63860dad80f..00000000000
--- a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/web/handlers/BucketArgs.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.hadoop.ozone.web.handlers;
-
-import org.apache.hadoop.hdds.protocol.StorageType;
-import org.apache.hadoop.ozone.OzoneConsts;
-
-/**
- * BucketArgs packages all bucket related arguments to
- * file system calls.
- */
-public class BucketArgs extends VolumeArgs {
- private final String bucketName;
- private OzoneConsts.Versioning versioning;
- private StorageType storageType;
-
- /**
- * Constructor for BucketArgs.
- *
- * @param volumeName - volumeName
- * @param bucketName - bucket Name
- * @param userArgs - userArgs
- */
- public BucketArgs(String volumeName, String bucketName, UserArgs userArgs) {
- super(volumeName, userArgs);
- this.bucketName = bucketName;
- this.versioning = OzoneConsts.Versioning.NOT_DEFINED;
- this.storageType = null;
- }
-
-
- /**
- * Constructor for BucketArgs.
- *
- * @param bucketName - bucket Name
- * @param volumeArgs - volume Args
- */
- public BucketArgs(String bucketName, VolumeArgs volumeArgs) {
- super(volumeArgs);
- this.bucketName = bucketName;
- this.versioning = OzoneConsts.Versioning.NOT_DEFINED;
- this.storageType = null;
- }
-
- /**
- * Constructor for BucketArgs.
- *
- * @param args - Bucket Args
- */
- public BucketArgs(BucketArgs args) {
- this(args.getBucketName(), args);
- }
-
- /**
- * Returns the Bucket Name.
- *
- * @return Bucket Name
- */
- public String getBucketName() {
- return bucketName;
- }
-
- /**
- * Returns Versioning Info.
- *
- * @return versioning
- */
- public OzoneConsts.Versioning getVersioning() {
- return versioning;
- }
-
-
- /**
- * SetVersioning Info.
- *
- * @param versioning - Enum value
- */
- public void setVersioning(OzoneConsts.Versioning versioning) {
- this.versioning = versioning;
- }
-
- /**
- * returns the current Storage Class.
- *
- * @return Storage Class
- */
- public StorageType getStorageType() {
- return storageType;
- }
-
- /**
- * Sets the Storage Class.
- *
- * @param storageType Set Storage Class
- */
- public void setStorageType(StorageType storageType) {
- this.storageType = storageType;
- }
-
- /**
- * returns - Volume/bucketName.
- *
- * @return String
- */
- @Override
- public String getResourceName() {
- return getVolumeName() + "/" + getBucketName();
- }
-
- /**
- * Returns User/Volume name which is the parent of this
- * bucket.
- *
- * @return String
- */
- public String getParentName() {
- return getUserName() + "/" + getVolumeName();
- }
-}
diff --git a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/web/handlers/KeyArgs.java b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/web/handlers/KeyArgs.java
deleted file mode 100644
index 48a4cb45136..00000000000
--- a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/web/handlers/KeyArgs.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.hadoop.ozone.web.handlers;
-
-/**
- * Class that packages all key Arguments.
- */
-public class KeyArgs extends BucketArgs {
- private String key;
- private String hash;
- private long size;
-
- /**
- * Constructor for Key Args.
- *
- * @param volumeName - Volume Name
- * @param bucketName - Bucket Name
- * @param objectName - Key
- */
- public KeyArgs(String volumeName, String bucketName,
- String objectName, UserArgs args) {
- super(volumeName, bucketName, args);
- this.key = objectName;
- }
-
- /**
- * Constructor for Key Args.
- *
- * @param objectName - Key
- * @param args - Bucket Args
- */
- public KeyArgs(String objectName, BucketArgs args) {
- super(args);
- this.key = objectName;
- }
-
- /**
- * Get Key Name.
- *
- * @return String
- */
- public String getKeyName() {
- return this.key;
- }
-
- /**
- * Computed File hash.
- *
- * @return String
- */
- public String getHash() {
- return hash;
- }
-
- /**
- * Sets the hash String.
- *
- * @param hash String
- */
- public void setHash(String hash) {
- this.hash = hash;
- }
-
- /**
- * Returns the file size.
- *
- * @return long - file size
- */
- public long getSize() {
- return size;
- }
-
- /**
- * Set Size.
- *
- * @param size Size of the file
- */
- public void setSize(long size) {
- this.size = size;
- }
-
- /**
- * Returns the name of the resource.
- *
- * @return String
- */
- @Override
- public String getResourceName() {
- return super.getResourceName() + "/" + getKeyName();
- }
-
- /**
- * Parent name of this resource.
- *
- * @return String.
- */
- @Override
- public String getParentName() {
- return super.getResourceName();
- }
-}
diff --git a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/web/handlers/ListArgs.java b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/web/handlers/ListArgs.java
deleted file mode 100644
index 49ca4a4f7e3..00000000000
--- a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/web/handlers/ListArgs.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.hadoop.ozone.web.handlers;
-
-/**
- * Supports listing keys with pagination.
- */
-public class ListArgs {
- private String prevKey;
- private String prefix;
- private int maxKeys;
- private boolean rootScan;
- private T args;
-
- /**
- * Constructor for ListArgs.
- *
- * @param args - BucketArgs
- * @param prefix Prefix to start Query from
- * @param maxKeys Max result set
- * @param prevKey - Page token
- */
- public ListArgs(T args, String prefix, int maxKeys,
- String prevKey) {
- setArgs(args);
- setPrefix(prefix);
- setMaxKeys(maxKeys);
- setPrevKey(prevKey);
- }
-
- /**
- * Copy Constructor for ListArgs.
- *
- * @param args - List Args
- */
- public ListArgs(T args, ListArgs listArgs) {
- this(args, listArgs.getPrefix(), listArgs.getMaxKeys(),
- listArgs.getPrevKey());
- }
-
- /**
- * Returns page token.
- *
- * @return String
- */
- public String getPrevKey() {
- return prevKey;
- }
-
- /**
- * Sets page token.
- *
- * @param prevKey - Page token
- */
- public void setPrevKey(String prevKey) {
- this.prevKey = prevKey;
- }
-
- /**
- * Gets max keys.
- *
- * @return int
- */
- public int getMaxKeys() {
- return maxKeys;
- }
-
- /**
- * Sets max keys.
- *
- * @param maxKeys - Maximum keys to return
- */
- public void setMaxKeys(int maxKeys) {
- this.maxKeys = maxKeys;
- }
-
- /**
- * Gets prefix.
- *
- * @return String
- */
- public String getPrefix() {
- return prefix;
- }
-
- /**
- * Sets prefix.
- *
- * @param prefix - The prefix that we are looking for
- */
- public void setPrefix(String prefix) {
- this.prefix = prefix;
- }
-
- /**
- * Gets args.
- * @return T
- */
- public T getArgs() {
- return args;
- }
-
- /**
- * Sets args.
- * @param args T
- */
- public void setArgs(T args) {
- this.args = args;
- }
-
- /**
- * Checks if we are doing a rootScan.
- * @return - RootScan.
- */
- public boolean isRootScan() {
- return rootScan;
- }
-
- /**
- * Sets the RootScan property.
- * @param rootScan - Boolean.
- */
- public void setRootScan(boolean rootScan) {
- this.rootScan = rootScan;
- }
-
-}
\ No newline at end of file
diff --git a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/web/handlers/UserArgs.java b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/web/handlers/UserArgs.java
deleted file mode 100644
index 8a75928a1c6..00000000000
--- a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/web/handlers/UserArgs.java
+++ /dev/null
@@ -1,172 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.hadoop.ozone.web.handlers;
-
-import org.apache.hadoop.classification.InterfaceAudience;
-
-import javax.ws.rs.core.HttpHeaders;
-import javax.ws.rs.core.Request;
-import javax.ws.rs.core.UriInfo;
-import java.util.Arrays;
-
-/**
- * UserArgs is used to package caller info
- * and pass it down to file system.
- */
-@InterfaceAudience.Private
-public class UserArgs {
- private String userName;
- private final String requestID;
- private final String hostName;
- private final UriInfo uri;
- private final Request request;
- private final HttpHeaders headers;
- private String[] groups;
-
-
- /**
- * Constructs user args.
- *
- * @param userName - User name
- * @param requestID - Request ID
- * @param hostName - Host Name
- * @param req - Request
- * @param info - Uri Info
- * @param httpHeaders - http headers
- */
- public UserArgs(String userName, String requestID, String hostName,
- Request req, UriInfo info, HttpHeaders httpHeaders) {
- this.hostName = hostName;
- this.userName = userName;
- this.requestID = requestID;
- this.uri = info;
- this.request = req;
- this.headers = httpHeaders;
- }
-
- /**
- * Constructs user args when we don't know the user name yet.
- *
- * @param requestID _ Request ID
- * @param hostName - Host Name
- * @param req - Request
- * @param info - UriInfo
- * @param httpHeaders - http headers
- */
- public UserArgs(String requestID, String hostName, Request req, UriInfo info,
- HttpHeaders httpHeaders) {
- this.hostName = hostName;
- this.requestID = requestID;
- this.uri = info;
- this.request = req;
- this.headers = httpHeaders;
- }
-
- /**
- * Returns hostname.
- *
- * @return String
- */
- public String getHostName() {
- return hostName;
- }
-
- /**
- * Returns RequestID.
- *
- * @return Long
- */
- public String getRequestID() {
- return requestID;
- }
-
- /**
- * Returns User Name.
- *
- * @return String
- */
- public String getUserName() {
- return userName;
- }
-
- /**
- * Sets the user name.
- *
- * @param userName Name of the user
- */
- public void setUserName(String userName) {
- this.userName = userName;
- }
-
- /**
- * Returns list of groups.
- *
- * @return String[]
- */
- public String[] getGroups() {
- return groups != null ?
- Arrays.copyOf(groups, groups.length) : null;
- }
-
- /**
- * Sets the group list.
- *
- * @param groups list of groups
- */
- public void setGroups(String[] groups) {
- if (groups != null) {
- this.groups = Arrays.copyOf(groups, groups.length);
- }
- }
-
- /**
- * Returns the resource Name.
- *
- * @return String Resource.
- */
- public String getResourceName() {
- return getUserName();
- }
-
- /**
- * Returns Http Headers for this call.
- *
- * @return httpHeaders
- */
- public HttpHeaders getHeaders() {
- return headers;
- }
-
- /**
- * Returns Request Object.
- *
- * @return Request
- */
- public Request getRequest() {
- return request;
- }
-
- /**
- * Returns UriInfo.
- *
- * @return UriInfo
- */
- public UriInfo getUri() {
- return uri;
- }
-}
diff --git a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/web/handlers/VolumeArgs.java b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/web/handlers/VolumeArgs.java
deleted file mode 100644
index 6bafac1c917..00000000000
--- a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/web/handlers/VolumeArgs.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.hadoop.ozone.web.handlers;
-
-import org.apache.hadoop.classification.InterfaceAudience;
-import org.apache.hadoop.ozone.web.request.OzoneQuota;
-
-import javax.ws.rs.core.HttpHeaders;
-import javax.ws.rs.core.Request;
-import javax.ws.rs.core.UriInfo;
-
-/**
- * VolumeArgs is used to package all volume
- * related arguments in the call to underlying
- * file system.
- */
-@InterfaceAudience.Private
-public class VolumeArgs extends UserArgs {
- private String adminName;
- private final String volumeName;
- private OzoneQuota quota;
-
- /**
- * Returns Quota Information.
- *
- * @return Quota
- */
- public OzoneQuota getQuota() {
- return quota;
- }
-
- /**
- * Returns volume name.
- *
- * @return String
- */
- public String getVolumeName() {
- return volumeName;
- }
-
- /**
- * Constructs volume Args.
- *
- * @param userName - User name
- * @param volumeName - volume Name
- * @param requestID _ Request ID
- * @param hostName - Host Name
- * @param request - Http Request
- * @param info - URI info
- * @param headers - http headers
- * @param groups - list of groups allowed to access the volume
- */
- @SuppressWarnings("parameternumber")
- public VolumeArgs(String userName, String volumeName, String requestID,
- String hostName, Request request, UriInfo info,
- HttpHeaders headers, String[] groups) {
- super(userName, requestID, hostName, request, info, headers);
- super.setGroups(groups);
- this.volumeName = volumeName;
- }
-
- /**
- * Constructs volume Args.
- *
- * @param volumeName - volume Name
- * @param userArgs - userArgs
- */
- public VolumeArgs(String volumeName, UserArgs userArgs) {
- this(userArgs.getUserName(), volumeName, userArgs.getRequestID(),
- userArgs.getHostName(), userArgs.getRequest(), userArgs.getUri(),
- userArgs.getHeaders(), userArgs.getGroups());
- }
-
- /**
- * Creates VolumeArgs from another VolumeArgs.
- */
- public VolumeArgs(VolumeArgs volArgs) {
- this(volArgs.getVolumeName(), volArgs);
- }
-
- /**
- * Sets Quota information.
- *
- * @param quota - Quota Sting
- * @throws IllegalArgumentException
- */
- public void setQuota(String quota) throws IllegalArgumentException {
- this.quota = OzoneQuota.parseQuota(quota);
- }
-
- /**
- * Sets quota information.
- *
- * @param quota - OzoneQuota
- */
- public void setQuota(OzoneQuota quota) {
- this.quota = quota;
- }
-
- /**
- * Gets admin Name.
- *
- * @return - Admin Name
- */
- public String getAdminName() {
- return adminName;
- }
-
- /**
- * Sets Admin Name.
- *
- * @param adminName - Admin Name
- */
- public void setAdminName(String adminName) {
- this.adminName = adminName;
- }
-
- /**
- * Returns UserName/VolumeName.
- *
- * @return String
- */
- @Override
- public String getResourceName() {
- return super.getResourceName() + "/" + getVolumeName();
- }
-}
diff --git a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/web/handlers/package-info.java b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/web/handlers/package-info.java
deleted file mode 100644
index a66a773c389..00000000000
--- a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/web/handlers/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.hadoop.ozone.web.handlers;
-
-/**
- * REST handler value classes.
- */
\ No newline at end of file
diff --git a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/web/request/OzoneQuota.java b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/web/request/OzoneQuota.java
deleted file mode 100644
index 9619ebdb7cd..00000000000
--- a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/web/request/OzoneQuota.java
+++ /dev/null
@@ -1,214 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.hadoop.ozone.web.request;
-
-import org.apache.hadoop.classification.InterfaceAudience;
-import org.apache.hadoop.ozone.OzoneConsts;
-import org.apache.hadoop.ozone.client.rest.headers.Header;
-import com.fasterxml.jackson.annotation.JsonIgnore;
-
-/**
- * represents an OzoneQuota Object that can be applied to
- * a storage volume.
- */
-@InterfaceAudience.Private
-public class OzoneQuota {
-
- private Units unit;
- private int size;
-
- /** Quota Units.*/
- public enum Units {UNDEFINED, BYTES, MB, GB, TB}
-
- /**
- * Returns size.
- *
- * @return int
- */
- public int getSize() {
- return size;
- }
-
- /**
- * Returns Units.
- *
- * @return Unit in MB, GB or TB
- */
- public Units getUnit() {
- return unit;
- }
-
- /**
- * Constructs a default Quota object.
- */
- public OzoneQuota() {
- this.size = 0;
- this.unit = Units.UNDEFINED;
- }
-
- /**
- * Constructor for Ozone Quota.
- *
- * @param size - Integer Size
- * @param unit MB, GB or TB
- */
- public OzoneQuota(int size, Units unit) {
- this.size = size;
- this.unit = unit;
- }
-
- /**
- * Formats a quota as a string.
- *
- * @param quota the quota to format
- * @return string representation of quota
- */
- public static String formatQuota(OzoneQuota quota) {
- return String.valueOf(quota.size) + quota.unit;
- }
-
- /**
- * Parses a user provided string and returns the
- * Quota Object.
- *
- * @param quotaString Quota String
- *
- * @return OzoneQuota object
- *
- * @throws IllegalArgumentException
- */
- public static OzoneQuota parseQuota(String quotaString)
- throws IllegalArgumentException {
-
- if ((quotaString == null) || (quotaString.isEmpty())) {
- throw new IllegalArgumentException(
- "Quota string cannot be null or empty.");
- }
-
- if (isRemove(quotaString)) {
- throw new IllegalArgumentException("Remove is invalid in this context.");
- }
-
- String uppercase = quotaString.toUpperCase().replaceAll("\\s+", "");
- String size = "";
- int nSize;
- Units currUnit = Units.MB;
- Boolean found = false;
- if (uppercase.endsWith(Header.OZONE_QUOTA_MB)) {
- size = uppercase
- .substring(0, uppercase.length() - Header.OZONE_QUOTA_MB.length());
- currUnit = Units.MB;
- found = true;
- }
-
- if (uppercase.endsWith(Header.OZONE_QUOTA_GB)) {
- size = uppercase
- .substring(0, uppercase.length() - Header.OZONE_QUOTA_GB.length());
- currUnit = Units.GB;
- found = true;
- }
-
- if (uppercase.endsWith(Header.OZONE_QUOTA_TB)) {
- size = uppercase
- .substring(0, uppercase.length() - Header.OZONE_QUOTA_TB.length());
- currUnit = Units.TB;
- found = true;
- }
-
- if (uppercase.endsWith(Header.OZONE_QUOTA_BYTES)) {
- size = uppercase
- .substring(0, uppercase.length() - Header.OZONE_QUOTA_BYTES.length());
- currUnit = Units.BYTES;
- found = true;
- }
-
- if (!found) {
- throw new IllegalArgumentException(
- "Quota unit not recognized. Supported values are BYTES, MB, GB and " +
- "TB.");
- }
-
- nSize = Integer.parseInt(size);
- if (nSize < 0) {
- throw new IllegalArgumentException("Quota cannot be negative.");
- }
-
- return new OzoneQuota(nSize, currUnit);
- }
-
-
- /**
- * Checks if Quota String is just as remove operation.
- *
- * @param quotaString User provided quota String
- *
- * @return True if it is Remove, false otherwise
- */
- public static boolean isRemove(String quotaString) {
-
- return (quotaString != null) &&
- (quotaString.compareToIgnoreCase(Header.OZONE_QUOTA_REMOVE) == 0);
- }
-
- /**
- * Returns size in Bytes or -1 if there is no Quota.
- */
- @JsonIgnore
- public long sizeInBytes() {
- switch (this.unit) {
- case BYTES:
- return this.getSize();
- case MB:
- return this.getSize() * OzoneConsts.MB;
- case GB:
- return this.getSize() * OzoneConsts.GB;
- case TB:
- return this.getSize() * OzoneConsts.TB;
- case UNDEFINED:
- default:
- return -1;
- }
- }
-
- /**
- * Returns OzoneQuota corresponding to size in bytes.
- *
- * @param sizeInBytes size in bytes to be converted
- *
- * @return OzoneQuota object
- */
- public static OzoneQuota getOzoneQuota(long sizeInBytes) {
- long size;
- Units unit;
- if (sizeInBytes % OzoneConsts.TB == 0) {
- size = sizeInBytes / OzoneConsts.TB;
- unit = Units.TB;
- } else if (sizeInBytes % OzoneConsts.GB == 0) {
- size = sizeInBytes / OzoneConsts.GB;
- unit = Units.GB;
- } else if (sizeInBytes % OzoneConsts.MB == 0) {
- size = sizeInBytes / OzoneConsts.MB;
- unit = Units.MB;
- } else {
- size = sizeInBytes;
- unit = Units.BYTES;
- }
- return new OzoneQuota((int)size, unit);
- }
-}
diff --git a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/web/request/package-info.java b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/web/request/package-info.java
deleted file mode 100644
index 4fbc18ff6e4..00000000000
--- a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/web/request/package-info.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * Netty-based HTTP server implementation for Ozone.
- */
-package org.apache.hadoop.ozone.web.request;
\ No newline at end of file
diff --git a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/web/response/BucketInfo.java b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/web/response/BucketInfo.java
deleted file mode 100644
index b431f19c19a..00000000000
--- a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/web/response/BucketInfo.java
+++ /dev/null
@@ -1,335 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.hadoop.ozone.web.response;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.hadoop.hdds.protocol.StorageType;
-import org.apache.hadoop.ozone.OzoneConsts;
-import org.apache.hadoop.ozone.OzoneAcl;
-import org.apache.hadoop.ozone.web.utils.JsonUtils;
-
-import com.fasterxml.jackson.annotation.JsonAutoDetect;
-import com.fasterxml.jackson.annotation.JsonFilter;
-import com.fasterxml.jackson.annotation.PropertyAccessor;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.ObjectReader;
-import com.fasterxml.jackson.databind.ObjectWriter;
-import com.fasterxml.jackson.databind.ser.FilterProvider;
-import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter;
-import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider;
-import com.google.common.base.Preconditions;
-
-/**
- * BucketInfo class, this is used as response class to send
- * Json info about a bucket back to a client.
- */
-public class BucketInfo implements Comparable {
- static final String BUCKET_INFO = "BUCKET_INFO_FILTER";
- private static final ObjectReader READER =
- new ObjectMapper().readerFor(BucketInfo.class);
- private static final ObjectWriter WRITER;
-
- static {
- ObjectMapper mapper = new ObjectMapper();
- String[] ignorableFieldNames = {"bytesUsed", "keyCount"};
-
- FilterProvider filters = new SimpleFilterProvider().addFilter(BUCKET_INFO,
- SimpleBeanPropertyFilter.serializeAllExcept(ignorableFieldNames));
- mapper.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY);
- mapper.addMixIn(Object.class, MixIn.class);
-
- mapper.setFilterProvider(filters);
- WRITER = mapper.writerWithDefaultPrettyPrinter();
- }
-
- private String volumeName;
- private String bucketName;
- private String createdOn;
- private List acls;
- private OzoneConsts.Versioning versioning;
- private StorageType storageType;
- private long bytesUsed;
- private long keyCount;
- private String encryptionKeyName;
-
- /**
- * Constructor for BucketInfo.
- *
- * @param volumeName
- * @param bucketName
- */
- public BucketInfo(String volumeName, String bucketName) {
- this.volumeName = volumeName;
- this.bucketName = bucketName;
- }
-
-
- /**
- * Default constructor for BucketInfo.
- */
- public BucketInfo() {
- acls = new ArrayList<>();
- }
-
- /**
- * Parse a JSON string into BucketInfo Object.
- *
- * @param jsonString - Json String
- *
- * @return - BucketInfo
- *
- * @throws IOException
- */
- public static BucketInfo parse(String jsonString) throws IOException {
- return READER.readValue(jsonString);
- }
-
- /**
- * Returns a List of ACL on the Bucket.
- *
- * @return List of Acls
- */
- public List getAcls() {
- return acls;
- }
-
- /**
- * Sets ACls.
- *
- * @param acls - Acls list
- */
- public void setAcls(List acls) {
- this.acls = acls;
- }
-
- /**
- * Returns Storage Type info.
- *
- * @return Storage Type of the bucket
- */
- public StorageType getStorageType() {
- return storageType;
- }
-
- /**
- * Sets the Storage Type.
- *
- * @param storageType - Storage Type
- */
- public void setStorageType(StorageType storageType) {
- this.storageType = storageType;
- }
-
- /**
- * Returns versioning.
- *
- * @return versioning Enum
- */
- public OzoneConsts.Versioning getVersioning() {
- return versioning;
- }
-
- /**
- * Sets Versioning.
- *
- * @param versioning
- */
- public void setVersioning(OzoneConsts.Versioning versioning) {
- this.versioning = versioning;
- }
-
-
- /**
- * Gets bucket Name.
- *
- * @return String
- */
- public String getBucketName() {
- return bucketName;
- }
-
- /**
- * Sets bucket Name.
- *
- * @param bucketName - Name of the bucket
- */
- public void setBucketName(String bucketName) {
- this.bucketName = bucketName;
- }
-
- /**
- * Sets creation time of the bucket.
- *
- * @param creationTime - Date String
- */
- public void setCreatedOn(String creationTime) {
- this.createdOn = creationTime;
- }
-
- /**
- * Returns creation time.
- *
- * @return creation time of bucket.
- */
- public String getCreatedOn() {
- return createdOn;
- }
-
-
- public void setEncryptionKeyName(String encryptionKeyName) {
- this.encryptionKeyName = encryptionKeyName;
- }
-
- public String getEncryptionKeyName() {
- return encryptionKeyName;
- }
-
- /**
- * Returns a JSON string of this object.
- * After stripping out bytesUsed and keyCount
- *
- * @return String
- */
- public String toJsonString() throws IOException {
- return WRITER.writeValueAsString(this);
- }
-
- /**
- * Returns the Object as a Json String.
- *
- * The reason why both toJSONString exists and toDBString exists
- * is because toJSONString supports an external facing contract with
- * REST clients. However server internally would want to add more
- * fields to this class. The distinction helps in serializing all
- * fields vs. only fields that are part of REST protocol.
- */
- public String toDBString() throws IOException {
- return JsonUtils.toJsonString(this);
- }
-
- /**
- * Returns Volume Name.
- *
- * @return String volume name
- */
- public String getVolumeName() {
- return volumeName;
- }
-
- /**
- * Sets the Volume Name of the bucket.
- *
- * @param volumeName - volumeName
- */
- public void setVolumeName(String volumeName) {
- this.volumeName = volumeName;
- }
-
- /**
- * Compares this object with the specified object for order. Returns a
- * negative integer, zero, or a positive integer as this object is less
- * than, equal to, or greater than the specified object.
- *
- * Please note : BucketInfo compare functions are used only within the
- * context of a volume, hence volume name is purposefully ignored in
- * compareTo, equal and hashcode functions of this class.
- */
- @Override
- public int compareTo(BucketInfo o) {
- Preconditions.checkState(o.getVolumeName().equals(this.getVolumeName()));
- return this.bucketName.compareTo(o.getBucketName());
- }
-
- /**
- * Checks if two bucketInfo's are equal.
- * @param o Object BucketInfo
- * @return True or False
- */
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (!(o instanceof BucketInfo)) {
- return false;
- }
-
- BucketInfo that = (BucketInfo) o;
- Preconditions.checkState(that.getVolumeName().equals(this.getVolumeName()));
- return bucketName.equals(that.bucketName);
-
- }
-
- /**
- * Hash Code for this object.
- * @return int
- */
- @Override
- public int hashCode() {
- return bucketName.hashCode();
- }
-
- /**
- * Get the number of bytes used by this bucket.
- *
- * @return long
- */
- public long getBytesUsed() {
- return bytesUsed;
- }
-
- /**
- * Set bytes Used.
- *
- * @param bytesUsed - bytesUsed
- */
- public void setBytesUsed(long bytesUsed) {
- this.bytesUsed = bytesUsed;
- }
-
- /**
- * Get Key Count inside this bucket.
- *
- * @return - KeyCount
- */
- public long getKeyCount() {
- return keyCount;
- }
-
- /**
- * Set Key Count inside this bucket.
- *
- * @param keyCount - Sets the Key Count
- */
- public void setKeyCount(long keyCount) {
- this.keyCount = keyCount;
- }
-
- /**
- * This class allows us to create custom filters
- * for the Json serialization.
- */
- @JsonFilter(BUCKET_INFO)
- static class MixIn {
-
- }
-
-}
diff --git a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/web/response/KeyInfo.java b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/web/response/KeyInfo.java
deleted file mode 100644
index f4801945e40..00000000000
--- a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/web/response/KeyInfo.java
+++ /dev/null
@@ -1,311 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.hadoop.ozone.web.response;
-
-import java.io.IOException;
-
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
-import org.apache.hadoop.hdds.client.ReplicationType;
-import org.apache.hadoop.ozone.web.utils.JsonUtils;
-
-import com.fasterxml.jackson.annotation.JsonAutoDetect;
-import com.fasterxml.jackson.annotation.JsonFilter;
-import com.fasterxml.jackson.annotation.PropertyAccessor;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.ObjectReader;
-import com.fasterxml.jackson.databind.ObjectWriter;
-import com.fasterxml.jackson.databind.ser.FilterProvider;
-import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter;
-import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider;
-
-/**
- * Represents an Ozone key Object.
- */
-public class KeyInfo implements Comparable {
- static final String OBJECT_INFO = "OBJECT_INFO_FILTER";
-
- private static final ObjectReader READER =
- new ObjectMapper().readerFor(KeyInfo.class);
- private static final ObjectWriter WRITER;
-
- static {
- ObjectMapper mapper = new ObjectMapper();
- String[] ignorableFieldNames = {"dataFileName"};
-
- FilterProvider filters = new SimpleFilterProvider()
- .addFilter(OBJECT_INFO, SimpleBeanPropertyFilter
- .serializeAllExcept(ignorableFieldNames));
- mapper.setVisibility(PropertyAccessor.FIELD,
- JsonAutoDetect.Visibility.ANY);
- mapper.addMixIn(Object.class, MixIn.class);
-
- mapper.setFilterProvider(filters);
- WRITER = mapper.writerWithDefaultPrettyPrinter();
- }
-
- /**
- * This class allows us to create custom filters
- * for the Json serialization.
- */
- @JsonFilter(OBJECT_INFO)
- class MixIn {
-
- }
- private long version;
- private String md5hash;
- private String createdOn;
- private String modifiedOn;
- private long size;
- private String keyName;
-
- private String dataFileName;
-
- private ReplicationType type;
-
- /**
- * Return replication type of the key.
- *
- * @return replication type
- */
- public ReplicationType getType() {
- return type;
- }
-
- /**
- * Set replication type of the key.
- *
- * @param replicationType
- */
- public void setType(ReplicationType replicationType) {
- this.type = replicationType;
- }
-
- /**
- * When this key was created.
- *
- * @return Date String
- */
- public String getCreatedOn() {
- return createdOn;
- }
-
- /**
- * When this key was modified.
- *
- * @return Date String
- */
- public String getModifiedOn() {
- return modifiedOn;
- }
-
- /**
- * When this key was created.
- *
- * @param createdOn - Date String
- */
- public void setCreatedOn(String createdOn) {
- this.createdOn = createdOn;
- }
-
- /**
- * When this key was modified.
- *
- * @param modifiedOn - Date String
- */
- public void setModifiedOn(String modifiedOn) {
- this.modifiedOn = modifiedOn;
- }
-
- /**
- * Full path to where the actual data for this key is stored.
- *
- * @return String
- */
- public String getDataFileName() {
- return dataFileName;
- }
-
- /**
- * Sets up where the file path is stored.
- *
- * @param dataFileName - Data File Name
- */
- public void setDataFileName(String dataFileName) {
- this.dataFileName = dataFileName;
- }
-
- /**
- * Gets the Keyname of this object.
- *
- * @return String
- */
- public String getKeyName() {
- return keyName;
- }
-
- /**
- * Sets the Key name of this object.
- *
- * @param keyName - String
- */
- public void setKeyName(String keyName) {
- this.keyName = keyName;
- }
-
- /**
- * Returns the MD5 Hash for the data of this key.
- *
- * @return String MD5
- */
- public String getMd5hash() {
- return md5hash;
- }
-
- /**
- * Sets the MD5 of this file.
- *
- * @param md5hash - Md5 of this file
- */
- public void setMd5hash(String md5hash) {
- this.md5hash = md5hash;
- }
-
- /**
- * Number of bytes stored in the data part of this key.
- *
- * @return long size of the data file
- */
- public long getSize() {
- return size;
- }
-
- /**
- * Sets the size of the Data part of this key.
- *
- * @param size - Size in long
- */
- public void setSize(long size) {
- this.size = size;
- }
-
- /**
- * Version of this key.
- *
- * @return - returns the version of this key.
- */
- public long getVersion() {
- return version;
- }
-
- /**
- * Sets the version of this key.
- *
- * @param version - Version String
- */
- public void setVersion(long version) {
- this.version = version;
- }
-
- /**
- * Compares this object with the specified object for order. Returns a
- * negative integer, zero, or a positive integer as this object is less
- * than, equal to, or greater than the specified object.
- *
- * @param o the object to be compared.
- *
- * @return a negative integer, zero, or a positive integer as this object
- * is less than, equal to, or greater than the specified object.
- *
- * @throws NullPointerException if the specified object is null
- * @throws ClassCastException if the specified object's type prevents it
- * from being compared to this object.
- */
- @Override
- public int compareTo(KeyInfo o) {
- if (this.keyName.compareTo(o.getKeyName()) != 0) {
- return this.keyName.compareTo(o.getKeyName());
- }
-
- if (this.getVersion() == o.getVersion()) {
- return 0;
- }
- if (this.getVersion() < o.getVersion()) {
- return -1;
- }
- return 1;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
-
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
-
- KeyInfo keyInfo = (KeyInfo) o;
-
- return new EqualsBuilder()
- .append(version, keyInfo.version)
- .append(keyName, keyInfo.keyName)
- .isEquals();
- }
-
- @Override
- public int hashCode() {
- return new HashCodeBuilder(17, 37)
- .append(version)
- .append(keyName)
- .toHashCode();
- }
-
- /**
-
- * Parse a string to retuen BucketInfo Object.
- *
- * @param jsonString - Json String
- *
- * @return - BucketInfo
- *
- * @throws IOException
- */
- public static KeyInfo parse(String jsonString) throws IOException {
- return READER.readValue(jsonString);
- }
-
-
- /**
- * Returns a JSON string of this object.
- * After stripping out bytesUsed and keyCount
- *
- * @return String
- */
- public String toJsonString() throws IOException {
- return WRITER.writeValueAsString(this);
- }
-
- /**
- * Returns the Object as a Json String.
- */
- public String toDBString() throws IOException {
- return JsonUtils.toJsonString(this);
- }
-}
diff --git a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/web/response/KeyInfoDetails.java b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/web/response/KeyInfoDetails.java
deleted file mode 100644
index 7f2ba098d79..00000000000
--- a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/web/response/KeyInfoDetails.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.hadoop.ozone.web.response;
-
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
-
-import java.util.List;
-
-/**
- * Represents an Ozone key Object with detail information of location.
- */
-public class KeyInfoDetails extends KeyInfo {
- /**
- * a list of Map which maps localID to ContainerID
- * to specify replica locations.
- */
- private List keyLocations;
-
- /**
- * Set details of key location.
- *
- * @param keyLocations - details of key location
- */
- public void setKeyLocations(List keyLocations) {
- this.keyLocations = keyLocations;
- }
-
- /**
- * Returns details of key location.
- *
- * @return volumeName
- */
- public List getKeyLocations() {
- return keyLocations;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
-
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
-
- KeyInfoDetails that = (KeyInfoDetails) o;
-
- return new EqualsBuilder()
- .append(getVersion(), that.getVersion())
- .append(getKeyName(), that.getKeyName())
- .append(keyLocations, that.getKeyLocations())
- .isEquals();
- }
-
- @Override
- public int hashCode() {
- return new HashCodeBuilder(17, 37)
- .append(getVersion())
- .append(getKeyName())
- .append(keyLocations)
- .toHashCode();
- }
-}
diff --git a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/web/response/KeyLocation.java b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/web/response/KeyLocation.java
deleted file mode 100644
index d03eff74753..00000000000
--- a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/web/response/KeyLocation.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.hadoop.ozone.web.response;
-
-/**
- * KeyLocation class is used used for parsing json response
- * when KeyInfoDetails Call is made.
- */
-public class KeyLocation {
- /**
- * Which container this key stored.
- */
- private final long containerID;
- /**
- * Which block this key stored inside a container.
- */
- private final long localID;
- /**
- * Data length of this key replica.
- */
- private final long length;
- /**
- * Offset of this key.
- */
- private final long offset;
-
- /**
- * Constructs KeyLocation.
- */
- public KeyLocation(long containerID, long localID,
- long length, long offset) {
- this.containerID = containerID;
- this.localID = localID;
- this.length = length;
- this.offset = offset;
- }
-
- /**
- * Returns the containerID of this Key.
- */
- public long getContainerID() {
- return containerID;
- }
-
- /**
- * Returns the localID of this Key.
- */
- public long getLocalID() {
- return localID;
- }
-
- /**
- * Returns the length of this Key.
- */
- public long getLength() {
- return length;
- }
-
- /**
- * Returns the offset of this Key.
- */
- public long getOffset() {
- return offset;
- }
-
-}
diff --git a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/web/response/ListBuckets.java b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/web/response/ListBuckets.java
deleted file mode 100644
index bc4e65be0df..00000000000
--- a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/web/response/ListBuckets.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.hadoop.ozone.web.response;
-
-
-import java.io.IOException;
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.apache.hadoop.ozone.web.utils.JsonUtils;
-
-import com.fasterxml.jackson.annotation.JsonAutoDetect;
-import com.fasterxml.jackson.annotation.JsonFilter;
-import com.fasterxml.jackson.annotation.PropertyAccessor;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.ObjectReader;
-import com.fasterxml.jackson.databind.ObjectWriter;
-import com.fasterxml.jackson.databind.ser.FilterProvider;
-import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter;
-import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider;
-
-/**
- * List Bucket is the response for the ListBucket Query.
- */
-public class ListBuckets {
- static final String BUCKET_LIST = "BUCKET_LIST_FILTER";
- private static final ObjectReader READER =
- new ObjectMapper().readerFor(ListBuckets.class);
- private static final ObjectWriter WRITER;
-
- static {
- ObjectMapper mapper = new ObjectMapper();
- String[] ignorableFieldNames = {"dataFileName"};
-
- FilterProvider filters = new SimpleFilterProvider()
- .addFilter(BUCKET_LIST, SimpleBeanPropertyFilter
- .serializeAllExcept(ignorableFieldNames));
- mapper.setVisibility(PropertyAccessor.FIELD,
- JsonAutoDetect.Visibility.ANY);
- mapper.addMixIn(Object.class, MixIn.class);
-
- mapper.setFilterProvider(filters);
- WRITER = mapper.writerWithDefaultPrettyPrinter();
- }
-
- private List buckets;
-
- /**
- * Constructor for ListBuckets.
- * @param buckets - List of buckets owned by this user
- */
- public ListBuckets(List buckets) {
- this.buckets = buckets;
-
- }
-
- /**
- * Constructor for ListBuckets.
- */
- public ListBuckets() {
- this.buckets = new LinkedList();
- }
-
- /**
- * Parses a String to return ListBuckets object.
- *
- * @param data - Json String
- *
- * @return - ListBuckets
- *
- * @throws IOException
- */
- public static ListBuckets parse(String data) throws IOException {
- return READER.readValue(data);
- }
-
- /**
- * Returns a list of Buckets.
- *
- * @return Bucket list
- */
- public List getBuckets() {
- return buckets;
- }
-
- /**
- * Sets the list of buckets owned by this user.
- *
- * @param buckets - List of Buckets
- */
- public void setBuckets(List buckets) {
- this.buckets = buckets;
- }
-
-
- /**
- * Returns a JSON string of this object.
- * After stripping out bytesUsed and keyCount
- *
- * @return String
- */
- public String toJsonString() throws IOException {
- return WRITER.writeValueAsString(this);
- }
-
- /**
- * Returns the Object as a Json String.
- */
- public String toDBString() throws IOException {
- return JsonUtils.toJsonString(this);
- }
-
- /**
- * Sorts the buckets based on bucketName.
- * This is useful when we return the list of buckets
- */
- public void sort() {
- Collections.sort(buckets);
- }
-
- /**
- * Add a new bucket to the list of buckets.
- * @param bucketInfo - bucket Info
- */
- public void addBucket(BucketInfo bucketInfo){
- this.buckets.add(bucketInfo);
- }
-
- /**
- * This class allows us to create custom filters
- * for the Json serialization.
- */
- @JsonFilter(BUCKET_LIST)
- class MixIn {
-
- }
-
-}
diff --git a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/web/response/ListKeys.java b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/web/response/ListKeys.java
deleted file mode 100644
index 9dc77d2c234..00000000000
--- a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/web/response/ListKeys.java
+++ /dev/null
@@ -1,209 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.hadoop.ozone.web.response;
-
-import java.io.IOException;
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.apache.hadoop.ozone.web.handlers.BucketArgs;
-import org.apache.hadoop.ozone.web.handlers.ListArgs;
-import org.apache.hadoop.ozone.web.utils.JsonUtils;
-
-import com.fasterxml.jackson.annotation.JsonAutoDetect;
-import com.fasterxml.jackson.annotation.JsonFilter;
-import com.fasterxml.jackson.annotation.PropertyAccessor;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.ObjectReader;
-import com.fasterxml.jackson.databind.ObjectWriter;
-import com.fasterxml.jackson.databind.ser.FilterProvider;
-import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter;
-import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider;
-import com.google.common.base.Preconditions;
-
-/**
- * This class the represents the list of keys (Objects) in a bucket.
- */
-public class ListKeys {
- static final String OBJECT_LIST = "OBJECT_LIST_FILTER";
-
- private static final ObjectReader READER =
- new ObjectMapper().readerFor(ListKeys.class);
- private static final ObjectWriter WRITER;
-
- static {
- ObjectMapper mapper = new ObjectMapper();
- String[] ignorableFieldNames = {"dataFileName"};
-
- FilterProvider filters = new SimpleFilterProvider()
- .addFilter(OBJECT_LIST, SimpleBeanPropertyFilter
- .serializeAllExcept(ignorableFieldNames));
- mapper.setVisibility(PropertyAccessor.FIELD,
- JsonAutoDetect.Visibility.ANY);
- mapper.addMixIn(Object.class, MixIn.class);
-
- mapper.setFilterProvider(filters);
- WRITER = mapper.writerWithDefaultPrettyPrinter();
- }
-
- private String name;
- private String prefix;
- private long maxKeys;
- private boolean truncated;
- private List keyList;
-
- /**
- * Default constructor needed for json serialization.
- */
- public ListKeys() {
- this.keyList = new LinkedList<>();
- }
-
- /**
- * Constructor for ListKeys.
- *
- * @param args ListArgs
- * @param truncated is truncated
- */
- public ListKeys(ListArgs args, boolean truncated) {
- Preconditions.checkState(args.getArgs() instanceof BucketArgs);
- this.name = ((BucketArgs) args.getArgs()).getBucketName();
- this.prefix = args.getPrefix();
- this.maxKeys = args.getMaxKeys();
- this.truncated = truncated;
- }
-
- /**
- * Converts a Json string to POJO.
- * @param jsonString - json string.
- * @return ListObject
- * @throws IOException - Json conversion error.
- */
- public static ListKeys parse(String jsonString) throws IOException {
- return READER.readValue(jsonString);
- }
-
- /**
- * Returns a list of Objects.
- *
- * @return List of KeyInfo Objects.
- */
- public List getKeyList() {
- return keyList;
- }
-
- /**
- * Sets the list of Objects.
- *
- * @param objectList - List of Keys
- */
- public void setKeyList(List objectList) {
- this.keyList = objectList;
- }
-
- /**
- * Gets the Max Key Count.
- *
- * @return long
- */
- public long getMaxKeys() {
- return maxKeys;
- }
-
- /**
- * Gets bucket Name.
- *
- * @return String
- */
- public String getName() {
- return name;
- }
-
- /**
- * Gets Prefix.
- *
- * @return String
- */
- public String getPrefix() {
- return prefix;
- }
-
- /**
- * Gets truncated Status.
- *
- * @return Boolean
- */
- public boolean isTruncated() {
- return truncated;
- }
-
- /**
- * Sets the value of truncated.
- *
- * @param value - Boolean
- */
- public void setTruncated(boolean value) {
- this.truncated = value;
- }
-
- /**
- * Returns a JSON string of this object. After stripping out bytesUsed and
- * keyCount.
- *
- * @return String
- * @throws IOException - On json Errors.
- */
- public String toJsonString() throws IOException {
- return WRITER.writeValueAsString(this);
- }
-
- /**
- * Returns the Object as a Json String.
- *
- * @return String
- * @throws IOException - on json errors.
- */
- public String toDBString() throws IOException {
- return JsonUtils.toJsonString(this);
- }
-
- /**
- * Sorts the keys based on name and version. This is useful when we return the
- * list of keys.
- */
- public void sort() {
- Collections.sort(keyList);
- }
-
- /**
- * Add a new key to the list of keys.
- * @param keyInfo - key Info
- */
- public void addKey(KeyInfo keyInfo){
- this.keyList.add(keyInfo);
- }
-
- /**
- * This class allows us to create custom filters for the Json serialization.
- */
- @JsonFilter(OBJECT_LIST)
- class MixIn {
-
- }
-}
diff --git a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/web/response/ListVolumes.java b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/web/response/ListVolumes.java
deleted file mode 100644
index b918349d493..00000000000
--- a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/web/response/ListVolumes.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.hadoop.ozone.web.response;
-
-import java.io.IOException;
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.apache.hadoop.classification.InterfaceAudience;
-import org.apache.hadoop.ozone.web.utils.JsonUtils;
-
-import com.fasterxml.jackson.annotation.JsonAutoDetect;
-import com.fasterxml.jackson.annotation.JsonFilter;
-import com.fasterxml.jackson.annotation.PropertyAccessor;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.ObjectReader;
-import com.fasterxml.jackson.databind.ObjectWriter;
-import com.fasterxml.jackson.databind.ser.FilterProvider;
-import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter;
-import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider;
-
-/**
- * List Volume Class is the class that is returned in JSON format to
- * users when they call ListVolumes.
- */
-@InterfaceAudience.Private
-public class ListVolumes {
- private List volumes;
-
- static final String VOLUME_LIST = "VOLUME_LIST_FILTER";
- private static final ObjectReader READER =
- new ObjectMapper().readerFor(ListVolumes.class);
- private static final ObjectWriter WRITER;
-
- static {
- ObjectMapper mapper = new ObjectMapper();
- String[] ignorableFieldNames = {"bytesUsed", "bucketCount"};
-
- FilterProvider filters = new SimpleFilterProvider()
- .addFilter(VOLUME_LIST, SimpleBeanPropertyFilter
- .serializeAllExcept(ignorableFieldNames));
- mapper.setVisibility(PropertyAccessor.FIELD,
- JsonAutoDetect.Visibility.ANY);
- mapper.addMixIn(Object.class, MixIn.class);
-
- mapper.setFilterProvider(filters);
- WRITER = mapper.writerWithDefaultPrettyPrinter();
- }
-
- /**
- * Used for json filtering.
- */
- @JsonFilter(VOLUME_LIST)
- class MixIn {
- }
-
- /**
- * Constructs ListVolume objects.
- */
- public ListVolumes() {
- this.volumes = new LinkedList();
- }
-
- /**
- * Gets the list of volumes.
- *
- * @return List of VolumeInfo Objects
- */
- public List getVolumes() {
- return volumes;
- }
-
-
- /**
- * Sets volume info.
- *
- * @param volumes - List of Volumes
- */
- public void setVolumes(List volumes) {
- this.volumes = volumes;
- }
-
- /**
- * Returns a JSON string of this object.
- * After stripping out bytesUsed and bucketCount
- *
- * @return String
- */
- public String toJsonString() throws IOException {
- return WRITER.writeValueAsString(this);
- }
-
- /**
- * When we serialize a volumeInfo to our database
- * we will use all fields. However the toJsonString
- * will strip out bytesUsed and bucketCount from the
- * volume Info
- *
- * @return Json String
- *
- * @throws IOException
- */
- public String toDBString() throws IOException {
- return JsonUtils.toJsonString(this);
- }
-
- /**
- * Parses a String to return ListVolumes object.
- *
- * @param data - Json String
- *
- * @return - ListVolumes
- *
- * @throws IOException
- */
- public static ListVolumes parse(String data) throws IOException {
- return READER.readValue(data);
- }
-
- /**
- * Adds a new volume info to the List.
- *
- * @param info - VolumeInfo
- */
- public void addVolume(VolumeInfo info) {
- this.volumes.add(info);
- }
-
- /**
- * Sorts the volume names based on volume name.
- * This is useful when we return the list of volume names
- */
- public void sort() {
- Collections.sort(volumes);
- }
-}
diff --git a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/web/response/VolumeInfo.java b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/web/response/VolumeInfo.java
deleted file mode 100644
index 112b27e5415..00000000000
--- a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/web/response/VolumeInfo.java
+++ /dev/null
@@ -1,308 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.hadoop.ozone.web.response;
-
-
-import java.io.IOException;
-
-import org.apache.hadoop.classification.InterfaceAudience;
-import org.apache.hadoop.ozone.web.request.OzoneQuota;
-import org.apache.hadoop.ozone.web.utils.JsonUtils;
-
-import com.fasterxml.jackson.annotation.JsonAutoDetect;
-import com.fasterxml.jackson.annotation.JsonFilter;
-import com.fasterxml.jackson.annotation.PropertyAccessor;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.ObjectReader;
-import com.fasterxml.jackson.databind.ObjectWriter;
-import com.fasterxml.jackson.databind.ser.FilterProvider;
-import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter;
-import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider;
-
-/**
- * VolumeInfo Class is the Java class that represents
- * Json when VolumeInfo Call is made.
- */
-@InterfaceAudience.Private
-public class VolumeInfo implements Comparable {
-
- static final String VOLUME_INFO = "VOLUME_INFO_FILTER";
- private static final ObjectReader READER =
- new ObjectMapper().readerFor(VolumeInfo.class);
- private static final ObjectWriter WRITER;
-
- static {
- ObjectMapper mapper = new ObjectMapper();
- String[] ignorableFieldNames = {"bytesUsed", "bucketCount"};
-
- FilterProvider filters = new SimpleFilterProvider()
- .addFilter(VOLUME_INFO, SimpleBeanPropertyFilter
- .serializeAllExcept(ignorableFieldNames));
- mapper.setVisibility(PropertyAccessor.FIELD,
- JsonAutoDetect.Visibility.ANY);
- mapper.addMixIn(Object.class, MixIn.class);
-
- mapper.setFilterProvider(filters);
- WRITER = mapper.writerWithDefaultPrettyPrinter();
- }
-
- /**
- * Custom Json Filter Class.
- */
- @JsonFilter(VOLUME_INFO)
- class MixIn {
- }
- private VolumeOwner owner;
- private OzoneQuota quota;
- private String volumeName;
- private String createdOn;
- private String createdBy;
-
- private long bytesUsed;
- private long bucketCount;
-
-
- /**
- * Constructor for VolumeInfo.
- *
- * @param volumeName - Name of the Volume
- * @param createdOn _ Date String
- * @param createdBy - Person who created it
- */
- public VolumeInfo(String volumeName, String createdOn, String createdBy) {
- this.createdOn = createdOn;
- this.volumeName = volumeName;
- this.createdBy = createdBy;
- }
-
- /**
- * Constructor for VolumeInfo.
- */
- public VolumeInfo() {
- }
-
- /**
- * Returns the name of the person who created this volume.
- *
- * @return Name of Admin who created this
- */
- public String getCreatedBy() {
- return createdBy;
- }
-
- /**
- * Sets the user name of the person who created this volume.
- *
- * @param createdBy - UserName
- */
- public void setCreatedBy(String createdBy) {
- this.createdBy = createdBy;
- }
-
- /**
- * Gets the date on which this volume was created.
- *
- * @return - Date String
- */
- public String getCreatedOn() {
- return createdOn;
- }
-
- /**
- * Sets the date string.
- *
- * @param createdOn - Date String
- */
- public void setCreatedOn(String createdOn) {
- this.createdOn = createdOn;
- }
-
- /**
- * Returns the owner info.
- *
- * @return - OwnerInfo
- */
- public VolumeOwner getOwner() {
- return owner;
- }
-
- /**
- * Sets the owner.
- *
- * @param owner - OwnerInfo
- */
- public void setOwner(VolumeOwner owner) {
- this.owner = owner;
- }
-
- /**
- * Returns the quota information on a volume.
- *
- * @return Quota
- */
- public OzoneQuota getQuota() {
- return quota;
- }
-
- /**
- * Sets the quota info.
- *
- * @param quota - Quota Info
- */
- public void setQuota(OzoneQuota quota) {
- this.quota = quota;
- }
-
- /**
- * gets the volume name.
- *
- * @return - Volume Name
- */
- public String getVolumeName() {
- return volumeName;
- }
-
- /**
- * Sets the volume name.
- *
- * @param volumeName - Volume Name
- */
- public void setVolumeName(String volumeName) {
- this.volumeName = volumeName;
- }
-
- /**
- * Returns a JSON string of this object.
- * After stripping out bytesUsed and bucketCount
- *
- * @return String - json string
- * @throws IOException
- */
- public String toJsonString() throws IOException {
- return WRITER.writeValueAsString(this);
- }
-
- /**
- * When we serialize a volumeInfo to our database
- * we will use all fields. However the toJsonString
- * will strip out bytesUsed and bucketCount from the
- * volume Info
- *
- * @return Json String
- *
- * @throws IOException
- */
- public String toDBString() throws IOException {
- return JsonUtils.toJsonString(this);
- }
-
-
- /**
- * Comparable Interface.
- * @param o VolumeInfo Object.
- * @return Result of comparison
- */
- @Override
- public int compareTo(VolumeInfo o) {
- return this.volumeName.compareTo(o.getVolumeName());
- }
-
- /**
- * Gets the number of bytesUsed by this volume.
- *
- * @return long - Bytes used
- */
- public long getBytesUsed() {
- return bytesUsed;
- }
-
- /**
- * Sets number of bytesUsed by this volume.
- *
- * @param bytesUsed - Number of bytesUsed
- */
- public void setBytesUsed(long bytesUsed) {
- this.bytesUsed = bytesUsed;
- }
-
- /**
- * Returns VolumeInfo class from json string.
- *
- * @param data - Json String
- *
- * @return VolumeInfo
- *
- * @throws IOException
- */
- public static VolumeInfo parse(String data) throws IOException {
- return READER.readValue(data);
- }
-
- /**
- * Indicates whether some other object is "equal to" this one.
- *
- * @param obj the reference object with which to compare.
- *
- * @return {@code true} if this object is the same as the obj
- * argument; {@code false} otherwise.
- */
- @Override
- public boolean equals(Object obj) {
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- VolumeInfo otherInfo = (VolumeInfo) obj;
- return otherInfo.getVolumeName().equals(this.getVolumeName());
- }
-
- /**
- * Returns a hash code value for the object. This method is
- * supported for the benefit of hash tables such as those provided by
- * HashMap.
- * @return a hash code value for this object.
- *
- * @see Object#equals(Object)
- * @see System#identityHashCode
- */
- @Override
- public int hashCode() {
- return getVolumeName().hashCode();
- }
-
- /**
- * Total number of buckets under this volume.
- *
- * @return - bucketCount
- */
- public long getBucketCount() {
- return bucketCount;
- }
-
- /**
- * Sets the buckets count.
- *
- * @param bucketCount - Bucket Count
- */
- public void setBucketCount(long bucketCount) {
- this.bucketCount = bucketCount;
- }
-}
diff --git a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/web/response/VolumeOwner.java b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/web/response/VolumeOwner.java
deleted file mode 100644
index afb0460538c..00000000000
--- a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/web/response/VolumeOwner.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.hadoop.ozone.web.response;
-
-import com.fasterxml.jackson.annotation.JsonInclude;
-import org.apache.hadoop.classification.InterfaceAudience;
-
-/**
- * Volume Owner represents the owner of a volume.
- *
- * This is a class instead of a string since we might need to extend this class
- * to support other forms of authentication.
- */
-@InterfaceAudience.Private
-public class VolumeOwner {
- @JsonInclude(JsonInclude.Include.NON_NULL)
- private String name;
-
- /**
- * Constructor for VolumeOwner.
- *
- * @param name - name of the User
- */
- public VolumeOwner(String name) {
- this.name = name;
- }
-
- /**
- * Constructs Volume Owner.
- */
- public VolumeOwner() {
- name = null;
- }
-
- /**
- * Returns the user name.
- *
- * @return Name
- */
- public String getName() {
- return name;
- }
-
-}
diff --git a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/web/response/package-info.java b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/web/response/package-info.java
deleted file mode 100644
index 3bf66c861be..00000000000
--- a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/web/response/package-info.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * Netty-based HTTP server implementation for Ozone.
- */
-package org.apache.hadoop.ozone.web.response;
\ No newline at end of file
diff --git a/hadoop-ozone/common/src/test/java/org/apache/hadoop/ozone/web/TestBucketInfo.java b/hadoop-ozone/common/src/test/java/org/apache/hadoop/ozone/web/TestBucketInfo.java
deleted file mode 100644
index e364e7db81a..00000000000
--- a/hadoop-ozone/common/src/test/java/org/apache/hadoop/ozone/web/TestBucketInfo.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.hadoop.ozone.web;
-
-import org.apache.hadoop.hdds.protocol.StorageType;
-import org.apache.hadoop.ozone.OzoneAcl;
-import org.apache.hadoop.ozone.OzoneConsts;
-import org.apache.hadoop.ozone.web.response.BucketInfo;
-import org.junit.Test;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-/**
- * Test Ozone Bucket Info operation.
- */
-public class TestBucketInfo {
- @Test
- public void testBucketInfoJson() throws IOException {
- BucketInfo bucketInfo = new BucketInfo("volumeName", "bucketName");
- String bucketInfoString = bucketInfo.toJsonString();
- BucketInfo newBucketInfo = BucketInfo.parse(bucketInfoString);
- assertEquals(bucketInfo, newBucketInfo);
- }
-
- @Test
- public void testBucketInfoDBString() throws IOException {
- BucketInfo bucketInfo = new BucketInfo("volumeName", "bucketName");
- String bucketInfoString = bucketInfo.toDBString();
- BucketInfo newBucketInfo = BucketInfo.parse(bucketInfoString);
- assertEquals(bucketInfo, newBucketInfo);
- }
-
- @Test
- public void testBucketInfoAddAcls() throws IOException {
- BucketInfo bucketInfo = new BucketInfo("volumeName", "bucketName");
- String bucketInfoString = bucketInfo.toDBString();
- BucketInfo newBucketInfo = BucketInfo.parse(bucketInfoString);
- assertEquals(bucketInfo, newBucketInfo);
- List aclList = new ArrayList<>();
-
- aclList.add(OzoneAcl.parseAcl("user:bilbo:r"));
- aclList.add(OzoneAcl.parseAcl("user:samwise:rw"));
- newBucketInfo.setAcls(aclList);
-
- assertNotNull(newBucketInfo.getAcls());
- assertEquals(2, newBucketInfo.getAcls().size());
- }
-
- @Test
- public void testBucketInfoVersionAndType() throws IOException {
- BucketInfo bucketInfo = new BucketInfo("volumeName", "bucketName");
- bucketInfo.setVersioning(OzoneConsts.Versioning.ENABLED);
- bucketInfo.setStorageType(StorageType.DISK);
-
- String bucketInfoString = bucketInfo.toDBString();
-
- BucketInfo newBucketInfo = BucketInfo.parse(bucketInfoString);
- assertEquals(bucketInfo, newBucketInfo);
- }
-
-}
diff --git a/hadoop-ozone/common/src/test/java/org/apache/hadoop/ozone/web/TestQuota.java b/hadoop-ozone/common/src/test/java/org/apache/hadoop/ozone/web/TestQuota.java
deleted file mode 100644
index ba4a5acf0c6..00000000000
--- a/hadoop-ozone/common/src/test/java/org/apache/hadoop/ozone/web/TestQuota.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership. The ASF
- * licenses this file to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *