http://git-wip-us.apache.org/repos/asf/hadoop/blob/2c392da8/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/web/response/KeyInfo.java ---------------------------------------------------------------------- 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 ba47bee..0000000 --- a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/web/response/KeyInfo.java +++ /dev/null @@ -1,290 +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.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<KeyInfo> { - 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; - - /** - * 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); - } -}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/2c392da8/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/web/response/KeyInfoDetails.java ---------------------------------------------------------------------- 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 7f2ba09..0000000 --- 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<KeyLocation> keyLocations; - - /** - * Set details of key location. - * - * @param keyLocations - details of key location - */ - public void setKeyLocations(List<KeyLocation> keyLocations) { - this.keyLocations = keyLocations; - } - - /** - * Returns details of key location. - * - * @return volumeName - */ - public List<KeyLocation> 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(); - } -} http://git-wip-us.apache.org/repos/asf/hadoop/blob/2c392da8/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/web/response/KeyLocation.java ---------------------------------------------------------------------- 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 d03eff7..0000000 --- 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; - } - -} http://git-wip-us.apache.org/repos/asf/hadoop/blob/2c392da8/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/web/response/ListBuckets.java ---------------------------------------------------------------------- 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 bc4e65b..0000000 --- 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<BucketInfo> buckets; - - /** - * Constructor for ListBuckets. - * @param buckets - List of buckets owned by this user - */ - public ListBuckets(List<BucketInfo> buckets) { - this.buckets = buckets; - - } - - /** - * Constructor for ListBuckets. - */ - public ListBuckets() { - this.buckets = new LinkedList<BucketInfo>(); - } - - /** - * 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<BucketInfo> getBuckets() { - return buckets; - } - - /** - * Sets the list of buckets owned by this user. - * - * @param buckets - List of Buckets - */ - public void setBuckets(List<BucketInfo> 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 { - - } - -} http://git-wip-us.apache.org/repos/asf/hadoop/blob/2c392da8/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/web/response/ListKeys.java ---------------------------------------------------------------------- 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 9dc77d2..0000000 --- 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<KeyInfo> 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<KeyInfo> getKeyList() { - return keyList; - } - - /** - * Sets the list of Objects. - * - * @param objectList - List of Keys - */ - public void setKeyList(List<KeyInfo> 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 { - - } -} http://git-wip-us.apache.org/repos/asf/hadoop/blob/2c392da8/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/web/response/ListVolumes.java ---------------------------------------------------------------------- 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 b918349..0000000 --- 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. - */ [email protected] -public class ListVolumes { - private List<VolumeInfo> 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<VolumeInfo>(); - } - - /** - * Gets the list of volumes. - * - * @return List of VolumeInfo Objects - */ - public List<VolumeInfo> getVolumes() { - return volumes; - } - - - /** - * Sets volume info. - * - * @param volumes - List of Volumes - */ - public void setVolumes(List<VolumeInfo> 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); - } -} http://git-wip-us.apache.org/repos/asf/hadoop/blob/2c392da8/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/web/response/VolumeInfo.java ---------------------------------------------------------------------- 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 112b27e..0000000 --- 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. - */ [email protected] -public class VolumeInfo implements Comparable<VolumeInfo> { - - 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; - } -} http://git-wip-us.apache.org/repos/asf/hadoop/blob/2c392da8/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/web/response/VolumeOwner.java ---------------------------------------------------------------------- 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 afb0460..0000000 --- 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. - */ [email protected] -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; - } - -} http://git-wip-us.apache.org/repos/asf/hadoop/blob/2c392da8/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/web/response/package-info.java ---------------------------------------------------------------------- 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 3bf66c8..0000000 --- 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 http://git-wip-us.apache.org/repos/asf/hadoop/blob/2c392da8/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/web/utils/OzoneUtils.java ---------------------------------------------------------------------- diff --git a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/web/utils/OzoneUtils.java b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/web/utils/OzoneUtils.java deleted file mode 100644 index 22fff56..0000000 --- a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/web/utils/OzoneUtils.java +++ /dev/null @@ -1,227 +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.utils; - -import java.net.InetAddress; -import java.net.UnknownHostException; -import java.nio.charset.Charset; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Locale; -import java.util.TimeZone; -import java.util.UUID; - -import org.apache.hadoop.classification.InterfaceAudience; -import org.apache.hadoop.conf.Configuration; -import org.apache.hadoop.hdds.HddsUtils; -import org.apache.hadoop.ozone.OzoneConsts; - -import com.google.common.base.Preconditions; - -/** - * Set of Utility functions used in ozone. - */ [email protected] -public final class OzoneUtils { - - public static final String ENCODING_NAME = "UTF-8"; - public static final Charset ENCODING = Charset.forName(ENCODING_NAME); - - private OzoneUtils() { - // Never constructed - } - - /** - * Date format that used in ozone. Here the format is thread safe to use. - */ - private static final ThreadLocal<SimpleDateFormat> DATE_FORMAT = - new ThreadLocal<SimpleDateFormat>() { - @Override - protected SimpleDateFormat initialValue() { - SimpleDateFormat format = new SimpleDateFormat( - OzoneConsts.OZONE_DATE_FORMAT, Locale.US); - format.setTimeZone(TimeZone.getTimeZone(OzoneConsts.OZONE_TIME_ZONE)); - - return format; - } - }; - - /** - * Verifies that max key length is a valid value. - * - * @param length - * The max key length to be validated - * - * @throws IllegalArgumentException - */ - public static void verifyMaxKeyLength(String length) - throws IllegalArgumentException { - int maxKey = 0; - try { - maxKey = Integer.parseInt(length); - } catch (NumberFormatException nfe) { - throw new IllegalArgumentException( - "Invalid max key length, the vaule should be digital."); - } - - if (maxKey <= 0) { - throw new IllegalArgumentException( - "Invalid max key length, the vaule should be a positive number."); - } - } - - /** - * Returns a random Request ID. - * - * Request ID is returned to the client as well as flows through the system - * facilitating debugging on why a certain request failed. - * - * @return String random request ID - */ - public static String getRequestID() { - return UUID.randomUUID().toString(); - } - - /** - * Return host name if possible. - * - * @return Host Name or localhost - */ - public static String getHostName() { - String host = "localhost"; - try { - host = InetAddress.getLocalHost().getHostName(); - } catch (UnknownHostException e) { - // Ignore the error - } - return host; - } - - /** - * Get the path for datanode id file. - * - * @param conf - Configuration - * @return the path of datanode id as string - */ - public static String getDatanodeIdFilePath(Configuration conf) { - return HddsUtils.getDatanodeIdFilePath(conf); - } - - /** - * Convert time in millisecond to a human readable format required in ozone. - * @return a human readable string for the input time - */ - public static String formatTime(long millis) { - return DATE_FORMAT.get().format(millis); - } - - /** - * Convert time in ozone date format to millisecond. - * @return time in milliseconds - */ - public static long formatDate(String date) throws ParseException { - Preconditions.checkNotNull(date, "Date string should not be null."); - return DATE_FORMAT.get().parse(date).getTime(); - } - - public static boolean isOzoneEnabled(Configuration conf) { - return HddsUtils.isHddsEnabled(conf); - } - - - /** - * verifies that bucket name / volume name is a valid DNS name. - * - * @param resName Bucket or volume Name to be validated - * - * @throws IllegalArgumentException - */ - public static void verifyResourceName(String resName) - throws IllegalArgumentException { - - if (resName == null) { - throw new IllegalArgumentException("Bucket or Volume name is null"); - } - - if ((resName.length() < OzoneConsts.OZONE_MIN_BUCKET_NAME_LENGTH) || - (resName.length() > OzoneConsts.OZONE_MAX_BUCKET_NAME_LENGTH)) { - throw new IllegalArgumentException( - "Bucket or Volume length is illegal, " + - "valid length is 3-63 characters"); - } - - if ((resName.charAt(0) == '.') || (resName.charAt(0) == '-')) { - throw new IllegalArgumentException( - "Bucket or Volume name cannot start with a period or dash"); - } - - if ((resName.charAt(resName.length() - 1) == '.') || - (resName.charAt(resName.length() - 1) == '-')) { - throw new IllegalArgumentException( - "Bucket or Volume name cannot end with a period or dash"); - } - - boolean isIPv4 = true; - char prev = (char) 0; - - for (int index = 0; index < resName.length(); index++) { - char currChar = resName.charAt(index); - - if (currChar != '.') { - isIPv4 = ((currChar >= '0') && (currChar <= '9')) && isIPv4; - } - - if (currChar > 'A' && currChar < 'Z') { - throw new IllegalArgumentException( - "Bucket or Volume name does not support uppercase characters"); - } - - if ((currChar != '.') && (currChar != '-')) { - if ((currChar < '0') || (currChar > '9' && currChar < 'a') || - (currChar > 'z')) { - throw new IllegalArgumentException("Bucket or Volume name has an " + - "unsupported character : " + - currChar); - } - } - - if ((prev == '.') && (currChar == '.')) { - throw new IllegalArgumentException("Bucket or Volume name should not " + - "have two contiguous periods"); - } - - if ((prev == '-') && (currChar == '.')) { - throw new IllegalArgumentException( - "Bucket or Volume name should not have period after dash"); - } - - if ((prev == '.') && (currChar == '-')) { - throw new IllegalArgumentException( - "Bucket or Volume name should not have dash after period"); - } - prev = currChar; - } - - if (isIPv4) { - throw new IllegalArgumentException( - "Bucket or Volume name cannot be an IPv4 address or all numeric"); - } - } - -} http://git-wip-us.apache.org/repos/asf/hadoop/blob/2c392da8/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/web/utils/package-info.java ---------------------------------------------------------------------- diff --git a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/web/utils/package-info.java b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/web/utils/package-info.java deleted file mode 100644 index 178157f..0000000 --- a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/web/utils/package-info.java +++ /dev/null @@ -1,18 +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.utils; http://git-wip-us.apache.org/repos/asf/hadoop/blob/2c392da8/hadoop-ozone/common/src/main/proto/OzoneManagerProtocol.proto ---------------------------------------------------------------------- diff --git a/hadoop-ozone/common/src/main/proto/OzoneManagerProtocol.proto b/hadoop-ozone/common/src/main/proto/OzoneManagerProtocol.proto deleted file mode 100644 index 975c790..0000000 --- a/hadoop-ozone/common/src/main/proto/OzoneManagerProtocol.proto +++ /dev/null @@ -1,481 +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. - */ - -/** - * These .proto interfaces are private and unstable. - * Please see http://wiki.apache.org/hadoop/Compatibility - * for what changes are allowed for a *unstable* .proto interface. - */ - -option java_package = "org.apache.hadoop.ozone.protocol.proto"; -option java_outer_classname = "OzoneManagerProtocolProtos"; -option java_generic_services = true; -option java_generate_equals_and_hash = true; -package hadoop.ozone; - -/** -This is file contains the protocol to communicate with -Ozone Manager. Ozone Manager manages the namespace for ozone. -This is similar to Namenode for Ozone. -*/ - -import "hdfs.proto"; -import "hdds.proto"; - -enum Status { - OK = 1; - VOLUME_NOT_UNIQUE = 2; - VOLUME_NOT_FOUND = 3; - VOLUME_NOT_EMPTY = 4; - VOLUME_ALREADY_EXISTS = 5; - USER_NOT_FOUND = 6; - USER_TOO_MANY_VOLUMES = 7; - BUCKET_NOT_FOUND = 8; - BUCKET_NOT_EMPTY = 9; - BUCKET_ALREADY_EXISTS = 10; - KEY_ALREADY_EXISTS = 11; - KEY_NOT_FOUND = 12; - INVALID_KEY_NAME = 13; - ACCESS_DENIED = 14; - INTERNAL_ERROR = 15; - KEY_ALLOCATION_ERROR = 16; - KEY_DELETION_ERROR = 17; - KEY_RENAME_ERROR = 18; - METADATA_ERROR = 19; - OM_NOT_INITIALIZED = 20; - SCM_VERSION_MISMATCH_ERROR = 21; -} - - -message VolumeInfo { - required string adminName = 1; - required string ownerName = 2; - required string volume = 3; - optional uint64 quotaInBytes = 4; - repeated hadoop.hdds.KeyValue metadata = 5; - repeated OzoneAclInfo volumeAcls = 6; - required uint64 creationTime = 7; -} - -/** - Creates a volume -*/ -message CreateVolumeRequest { - required VolumeInfo volumeInfo = 1; -} - -message CreateVolumeResponse { - - required Status status = 1; -} - -message VolumeList { - repeated string volumeNames = 1; -} - -/** - Changes the Volume Properties -- like ownership and quota for a volume. -*/ -message SetVolumePropertyRequest { - required string volumeName = 1; - optional string ownerName = 2; - optional uint64 quotaInBytes = 3; -} - -message SetVolumePropertyResponse { - required Status status = 1; -} - -/** - * Checks if the user has specified permissions for the volume - */ -message CheckVolumeAccessRequest { - required string volumeName = 1; - required OzoneAclInfo userAcl = 2; -} - -message CheckVolumeAccessResponse { - - required Status status = 1; -} - - -/** - Returns information about a volume. -*/ - -message InfoVolumeRequest { - required string volumeName = 1; -} - -message InfoVolumeResponse { - required Status status = 1; - optional VolumeInfo volumeInfo = 2; - -} - -/** - Deletes an existing volume. -*/ -message DeleteVolumeRequest { - required string volumeName = 1; -} - -message DeleteVolumeResponse { - required Status status = 1; -} - - -/** - List Volumes -- List all volumes in the cluster or by user. -*/ - -message ListVolumeRequest { - enum Scope { - USER_VOLUMES = 1; // User volumes -- called by user - VOLUMES_BY_USER = 2; // User volumes - called by Admin - VOLUMES_BY_CLUSTER = 3; // All volumes in the cluster - } - required Scope scope = 1; - optional string userName = 2; - optional string prefix = 3; - optional string prevKey = 4; - optional uint32 maxKeys = 5; -} - -message ListVolumeResponse { - required Status status = 1; - repeated VolumeInfo volumeInfo = 2; -} - -message BucketInfo { - required string volumeName = 1; - required string bucketName = 2; - repeated OzoneAclInfo acls = 3; - required bool isVersionEnabled = 4 [default = false]; - required hadoop.hdfs.StorageTypeProto storageType = 5 [default = DISK]; - required uint64 creationTime = 6; -} - -message BucketArgs { - required string volumeName = 1; - required string bucketName = 2; - repeated OzoneAclInfo addAcls = 3; - repeated OzoneAclInfo removeAcls = 4; - optional bool isVersionEnabled = 5; - optional hadoop.hdfs.StorageTypeProto storageType = 6; -} - -message OzoneAclInfo { - enum OzoneAclType { - USER = 1; - GROUP = 2; - WORLD = 3; - } - enum OzoneAclRights { - READ = 1; - WRITE = 2; - READ_WRITE = 3; - } - required OzoneAclType type = 1; - required string name = 2; - required OzoneAclRights rights = 3; -} - -message CreateBucketRequest { - required BucketInfo bucketInfo = 1; -} - -message CreateBucketResponse { - required Status status = 1; -} - -message InfoBucketRequest { - required string volumeName = 1; - required string bucketName = 2; -} - -message InfoBucketResponse { - required Status status = 1; - optional BucketInfo bucketInfo = 2; -} - -message ListBucketsRequest { - required string volumeName = 1; - optional string startKey = 2; - optional string prefix = 3; - optional int32 count = 4; -} - -message ListBucketsResponse { - required Status status = 1; - repeated BucketInfo bucketInfo = 2; -} - -message KeyArgs { - required string volumeName = 1; - required string bucketName = 2; - required string keyName = 3; - optional uint64 dataSize = 4; - optional hadoop.hdds.ReplicationType type = 5; - optional hadoop.hdds.ReplicationFactor factor = 6; - repeated KeyLocation keyLocations = 7; -} - -message KeyLocation { - required hadoop.hdds.BlockID blockID = 1; - required bool shouldCreateContainer = 2; - required uint64 offset = 3; - required uint64 length = 4; - // indicated at which version this block gets created. - optional uint64 createVersion = 5; -} - -message KeyLocationList { - optional uint64 version = 1; - repeated KeyLocation keyLocations = 2; -} - -message KeyInfo { - required string volumeName = 1; - required string bucketName = 2; - required string keyName = 3; - required uint64 dataSize = 4; - required hadoop.hdds.ReplicationType type = 5; - required hadoop.hdds.ReplicationFactor factor = 6; - repeated KeyLocationList keyLocationList = 7; - required uint64 creationTime = 8; - required uint64 modificationTime = 9; - optional uint64 latestVersion = 10; -} - -message LocateKeyRequest { - required KeyArgs keyArgs = 1; -} - -message LocateKeyResponse { - required Status status = 1; - optional KeyInfo keyInfo = 2; - // clients' followup request may carry this ID for stateful operations (similar - // to a cookie). - optional uint64 ID = 3; - // TODO : allow specifiying a particular version to read. - optional uint64 openVersion = 4; -} - -message SetBucketPropertyRequest { - required BucketArgs bucketArgs = 1; -} - -message SetBucketPropertyResponse { - required Status status = 1; -} - -message RenameKeyRequest{ - required KeyArgs keyArgs = 1; - required string toKeyName = 2; -} - -message RenameKeyResponse{ - required Status status = 1; -} - -message DeleteBucketRequest { - required string volumeName = 1; - required string bucketName = 2; -} - -message DeleteBucketResponse { - required Status status = 1; -} - -message ListKeysRequest { - required string volumeName = 1; - required string bucketName = 2; - optional string startKey = 3; - optional string prefix = 4; - optional int32 count = 5; -} - -message ListKeysResponse { - required Status status = 1; - repeated KeyInfo keyInfo = 2; -} - -message AllocateBlockRequest { - required KeyArgs keyArgs = 1; - required uint64 clientID = 2; -} - -message AllocateBlockResponse { - required Status status = 1; - optional KeyLocation keyLocation = 2; -} - -message CommitKeyRequest { - required KeyArgs keyArgs = 1; - required uint64 clientID = 2; -} - -message CommitKeyResponse { - required Status status = 1; -} - -message ServiceListRequest { -} - -message ServiceListResponse { - required Status status = 1; - repeated ServiceInfo serviceInfo = 2; -} - -message ServicePort { - enum Type { - RPC = 1; - HTTP = 2; - HTTPS = 3; - RATIS = 4; - }; - required Type type = 1; - required uint32 value = 2; -} - -message ServiceInfo { - required hadoop.hdds.NodeType nodeType = 1; - required string hostname = 2; - repeated ServicePort servicePorts = 3; -} - -/** - The OM service that takes care of Ozone namespace. -*/ -service OzoneManagerService { - - /** - Creates a Volume. - */ - rpc createVolume(CreateVolumeRequest) - returns(CreateVolumeResponse); - - /** - Allows modificiation of volume properties. - */ - rpc setVolumeProperty(SetVolumePropertyRequest) - returns (SetVolumePropertyResponse); - - /** - Checks if the specified volume is accesible by the specified user. - */ - rpc checkVolumeAccess(CheckVolumeAccessRequest) - returns (CheckVolumeAccessResponse); - - /** - Gets Volume information. - */ - rpc infoVolume(InfoVolumeRequest) - returns(InfoVolumeResponse); - /** - Deletes a volume if it is empty. - */ - rpc deleteVolume(DeleteVolumeRequest) - returns (DeleteVolumeResponse); - - /** - Lists Volumes - */ - rpc listVolumes(ListVolumeRequest) - returns (ListVolumeResponse); - - /** - Creates a Bucket. - */ - rpc createBucket(CreateBucketRequest) - returns(CreateBucketResponse); - - /** - Get Bucket information. - */ - rpc infoBucket(InfoBucketRequest) - returns(InfoBucketResponse); - - /** - Sets bucket properties. - */ - rpc setBucketProperty(SetBucketPropertyRequest) - returns(SetBucketPropertyResponse); - - /** - Get key. - */ - rpc createKey(LocateKeyRequest) - returns(LocateKeyResponse); - - /** - Look up for an existing key. - */ - rpc lookupKey(LocateKeyRequest) - returns(LocateKeyResponse); - - /** - Rename an existing key within a bucket. - */ - rpc renameKey(RenameKeyRequest) - returns(RenameKeyResponse); - - /** - Delete an existing key. - */ - rpc deleteKey(LocateKeyRequest) - returns(LocateKeyResponse); - - /** - Deletes a bucket from volume if it is empty. - */ - rpc deleteBucket(DeleteBucketRequest) - returns (DeleteBucketResponse); - - /** - List Buckets. - */ - rpc listBuckets(ListBucketsRequest) - returns(ListBucketsResponse); - - /** - List Keys. - */ - rpc listKeys(ListKeysRequest) - returns(ListKeysResponse); - - /** - Commit a key. - */ - rpc commitKey(CommitKeyRequest) - returns(CommitKeyResponse); - - /** - Allocate a new block for a key. - */ - rpc allocateBlock(AllocateBlockRequest) - returns(AllocateBlockResponse); - - /** - Returns list of Ozone services with its configuration details. - */ - rpc getServiceList(ServiceListRequest) - returns(ServiceListResponse); -} http://git-wip-us.apache.org/repos/asf/hadoop/blob/2c392da8/hadoop-ozone/common/src/main/resources/ozone-version-info.properties ---------------------------------------------------------------------- diff --git a/hadoop-ozone/common/src/main/resources/ozone-version-info.properties b/hadoop-ozone/common/src/main/resources/ozone-version-info.properties deleted file mode 100644 index 599f14d..0000000 --- a/hadoop-ozone/common/src/main/resources/ozone-version-info.properties +++ /dev/null @@ -1,27 +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. -# - -version=${declared.ozone.version} -release=${ozone.release} -revision=${version-info.scm.commit} -branch=${version-info.scm.branch} -user=${user.name} -date=${version-info.build.time} -url=${version-info.scm.uri} -srcChecksum=${version-info.source.md5} -protocVersion=${protobuf.version} http://git-wip-us.apache.org/repos/asf/hadoop/blob/2c392da8/hadoop-ozone/common/src/main/shellprofile.d/hadoop-ozone.sh ---------------------------------------------------------------------- diff --git a/hadoop-ozone/common/src/main/shellprofile.d/hadoop-ozone.sh b/hadoop-ozone/common/src/main/shellprofile.d/hadoop-ozone.sh deleted file mode 100644 index 3fff7f5..0000000 --- a/hadoop-ozone/common/src/main/shellprofile.d/hadoop-ozone.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env bash -# 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. - -if [[ "${HADOOP_SHELL_EXECNAME}" = ozone ]]; then - hadoop_add_profile ozone -fi - - http://git-wip-us.apache.org/repos/asf/hadoop/blob/2c392da8/hadoop-ozone/common/src/test/java/org/apache/hadoop/ozone/web/TestBucketInfo.java ---------------------------------------------------------------------- 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 2e69922..0000000 --- a/hadoop-ozone/common/src/test/java/org/apache/hadoop/ozone/web/TestBucketInfo.java +++ /dev/null @@ -1,81 +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.fs.StorageType; -import org.apache.hadoop.ozone.OzoneAcl; -import org.apache.hadoop.ozone.web.response.BucketInfo; -import org.apache.hadoop.ozone.OzoneConsts; -import org.junit.Test; - -import java.io.IOException; -import java.util.LinkedList; -import java.util.List; - -/** - * 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); - assert(bucketInfo.equals(newBucketInfo)); - } - - @Test - public void testBucketInfoDBString() throws IOException { - BucketInfo bucketInfo = new BucketInfo("volumeName", "bucketName"); - String bucketInfoString = bucketInfo.toDBString(); - BucketInfo newBucketInfo = BucketInfo.parse(bucketInfoString); - assert(bucketInfo.equals(newBucketInfo)); - } - - @Test - public void testBucketInfoAddAcls() throws IOException { - BucketInfo bucketInfo = new BucketInfo("volumeName", "bucketName"); - String bucketInfoString = bucketInfo.toDBString(); - BucketInfo newBucketInfo = BucketInfo.parse(bucketInfoString); - assert(bucketInfo.equals(newBucketInfo)); - List<OzoneAcl> aclList = new LinkedList<>(); - - aclList.add(OzoneAcl.parseAcl("user:bilbo:r")); - aclList.add(OzoneAcl.parseAcl("user:samwise:rw")); - newBucketInfo.setAcls(aclList); - - assert(newBucketInfo.getAcls() != null); - assert(newBucketInfo.getAcls().size() == 2); - } - - - @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); - assert(bucketInfo.equals(newBucketInfo)); - } - -} http://git-wip-us.apache.org/repos/asf/hadoop/blob/2c392da8/hadoop-ozone/common/src/test/java/org/apache/hadoop/ozone/web/TestQuota.java ---------------------------------------------------------------------- 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 d777d0c..0000000 --- a/hadoop-ozone/common/src/test/java/org/apache/hadoop/ozone/web/TestQuota.java +++ /dev/null @@ -1,116 +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.ozone.web.request.OzoneQuota; -import org.junit.Test; - -import java.util.HashMap; -import java.util.Set; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -/** - * Test Ozone Volume Quota. - */ -public class TestQuota { - @Test - public void testParseQuota() { - HashMap<String, Boolean> testMatrix; - testMatrix = new HashMap<String, Boolean>(); - - testMatrix.put("10TB", Boolean.TRUE); - testMatrix.put("1 TB", Boolean.TRUE); - testMatrix.put("0MB", Boolean.TRUE); - testMatrix.put("0 TB", Boolean.TRUE); - testMatrix.put(" 1000MB ", Boolean.TRUE); - - testMatrix.put(" 1000MBMB ", Boolean.FALSE); - testMatrix.put(" 1000MB00 ", Boolean.FALSE); - testMatrix.put("1000ZMB", Boolean.FALSE); - testMatrix.put("MB1000", Boolean.FALSE); - testMatrix.put("9999", Boolean.FALSE); - testMatrix.put("1", Boolean.FALSE); - testMatrix.put("remove", Boolean.FALSE); - testMatrix.put("1UNDEFINED", Boolean.FALSE); - testMatrix.put(null, Boolean.FALSE); - testMatrix.put("", Boolean.FALSE); - testMatrix.put("-1000MB", Boolean.FALSE); - testMatrix.put("1024 bytes", Boolean.TRUE); - testMatrix.put("1bytes", Boolean.TRUE); - testMatrix.put("0bytes", Boolean.TRUE); - testMatrix.put("10000 BYTES", Boolean.TRUE); - testMatrix.put("BYTESbytes", Boolean.FALSE); - testMatrix.put("bytes", Boolean.FALSE); - - Set<String> keys = testMatrix.keySet(); - for (String key : keys) { - if (testMatrix.get(key)) { - OzoneQuota.parseQuota(key); - } else { - try { - OzoneQuota.parseQuota(key); - // should never get here since the isValid call will throw - fail(key); - fail("An exception was expected but did not happen."); - } catch (IllegalArgumentException e) { - - } - } - } - } - - @Test - public void testVerifyQuota() { - OzoneQuota qt = OzoneQuota.parseQuota("10TB"); - assertEquals(qt.getSize(), 10); - assertEquals(qt.getUnit(), OzoneQuota.Units.TB); - assertEquals(qt.sizeInBytes(), 10L * (1024L * 1024L * 1024L * 1024L)); - - qt = OzoneQuota.parseQuota("10MB"); - assertEquals(qt.getSize(), 10); - assertEquals(qt.getUnit(), OzoneQuota.Units.MB); - assertEquals(qt.sizeInBytes(), 10L * (1024L * 1024L)); - - qt = OzoneQuota.parseQuota("10GB"); - assertEquals(qt.getSize(), 10); - assertEquals(qt.getUnit(), OzoneQuota.Units.GB); - assertEquals(qt.sizeInBytes(), 10L * (1024L * 1024L * 1024L)); - - qt = OzoneQuota.parseQuota("10BYTES"); - assertEquals(qt.getSize(), 10); - assertEquals(qt.getUnit(), OzoneQuota.Units.BYTES); - assertEquals(qt.sizeInBytes(), 10L); - - OzoneQuota emptyQuota = new OzoneQuota(); - assertEquals(emptyQuota.sizeInBytes(), -1L); - assertEquals(emptyQuota.getSize(), 0); - assertEquals(emptyQuota.getUnit(), OzoneQuota.Units.UNDEFINED); - } - - @Test - public void testVerifyRemove() { - assertTrue(OzoneQuota.isRemove("remove")); - assertFalse(OzoneQuota.isRemove("not remove")); - assertFalse(OzoneQuota.isRemove(null)); - } -} http://git-wip-us.apache.org/repos/asf/hadoop/blob/2c392da8/hadoop-ozone/common/src/test/java/org/apache/hadoop/ozone/web/TestUtils.java ---------------------------------------------------------------------- diff --git a/hadoop-ozone/common/src/test/java/org/apache/hadoop/ozone/web/TestUtils.java b/hadoop-ozone/common/src/test/java/org/apache/hadoop/ozone/web/TestUtils.java deleted file mode 100644 index d3f8f5e..0000000 --- a/hadoop-ozone/common/src/test/java/org/apache/hadoop/ozone/web/TestUtils.java +++ /dev/null @@ -1,101 +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.junit.Test; - -import java.util.HashMap; -import java.util.HashSet; -import java.util.Set; - -import static org.apache.hadoop.ozone.web.utils.OzoneUtils.getRequestID; -import static org.apache.hadoop.ozone.web.utils.OzoneUtils.verifyResourceName; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -/** - * Test Ozone Utility operations like verifying resource name. - */ -public class TestUtils { - - /** - * Tests if the bucket name handling is correct. - */ - @Test - public void testValidBucketNames() { - HashMap<String, Boolean> testMatrix; - // Init the Table with Strings and Expected Return values - testMatrix = new HashMap<String, Boolean>(); - - testMatrix.put("bucket-.ozone.self", Boolean.FALSE); - testMatrix.put("bucket.-ozone.self", Boolean.FALSE); - testMatrix.put(".bucket.ozone.self", Boolean.FALSE); - testMatrix.put("bucket.ozone.self.", Boolean.FALSE); - testMatrix.put("bucket..ozone.self", Boolean.FALSE); - testMatrix.put("192.1.1.1", Boolean.FALSE); - testMatrix.put("ab", Boolean.FALSE); - testMatrix.put("bucket.ozone.self.this.is.a.really.long.name.that." - + "is.more.than.sixty.three.characters.long.for.sure", Boolean.FALSE); - testMatrix.put(null, Boolean.FALSE); - testMatrix.put("bucket@$", Boolean.FALSE); - testMatrix.put("BUCKET", Boolean.FALSE); - testMatrix.put("bucket .ozone.self", Boolean.FALSE); - testMatrix.put(" bucket.ozone.self", Boolean.FALSE); - testMatrix.put("bucket.ozone.self-", Boolean.FALSE); - testMatrix.put("-bucket.ozone.self", Boolean.FALSE); - - testMatrix.put("bucket", Boolean.TRUE); - testMatrix.put("bucket.ozone.self", Boolean.TRUE); - testMatrix.put("bucket.ozone.self", Boolean.TRUE); - testMatrix.put("bucket-name.ozone.self", Boolean.TRUE); - testMatrix.put("bucket.1.ozone.self", Boolean.TRUE); - - Set<String> keys = testMatrix.keySet(); - for (String key : keys) { - if (testMatrix.get(key)) { - - // For valid names there should be no exceptions at all - verifyResourceName(key); - } else { - try { - verifyResourceName(key); - // should never get here since the isValid call will throw - fail("An exception was expected but did not happen."); - } catch (IllegalArgumentException e) { - - } - } - } - } - - /** - * Just calls Request ID many times and assert we - * got different values, ideally this should be - * run under parallel threads. Since the function under - * test has no external dependencies it is assumed - * that this test is good enough. - */ - @Test - public void testRequestIDisRandom() { - HashSet<String> set = new HashSet<>(); - for (int i = 0; i < 1000; i++) { - assertTrue(set.add(getRequestID())); - } - } -} http://git-wip-us.apache.org/repos/asf/hadoop/blob/2c392da8/hadoop-ozone/common/src/test/java/org/apache/hadoop/ozone/web/TestVolumeStructs.java ---------------------------------------------------------------------- diff --git a/hadoop-ozone/common/src/test/java/org/apache/hadoop/ozone/web/TestVolumeStructs.java b/hadoop-ozone/common/src/test/java/org/apache/hadoop/ozone/web/TestVolumeStructs.java deleted file mode 100644 index b433be6..0000000 --- a/hadoop-ozone/common/src/test/java/org/apache/hadoop/ozone/web/TestVolumeStructs.java +++ /dev/null @@ -1,73 +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.ozone.web.response.ListVolumes; -import org.apache.hadoop.ozone.web.response.VolumeInfo; -import org.apache.hadoop.ozone.web.response.VolumeOwner; -import org.junit.Test; - -import java.io.IOException; - -import static org.junit.Assert.assertEquals; - -/** - * Test Ozone Volume info structure. - */ -public class TestVolumeStructs { - - @Test - public void testVolumeInfoParse() throws IOException { - VolumeInfo volInfo = - new VolumeInfo("testvol", "Thu, Apr 9, 2015 10:23:45 GMT", "gandalf"); - VolumeOwner owner = new VolumeOwner("bilbo"); - volInfo.setOwner(owner); - String jString = volInfo.toJsonString(); - VolumeInfo newVollInfo = VolumeInfo.parse(jString); - String one = volInfo.toJsonString(); - String two = newVollInfo.toJsonString(); - - assertEquals(volInfo.toJsonString(), newVollInfo.toJsonString()); - } - - @Test - public void testVolumeInfoValue() throws IOException { - String createdOn = "Thu, Apr 9, 2015 10:23:45 GMT"; - String createdBy = "gandalf"; - VolumeInfo volInfo = new VolumeInfo("testvol", createdOn, createdBy); - assertEquals(volInfo.getCreatedBy(), createdBy); - assertEquals(volInfo.getCreatedOn(), createdOn); - } - - - @Test - public void testVolumeListParse() throws IOException { - ListVolumes list = new ListVolumes(); - for (int x = 0; x < 100; x++) { - VolumeInfo volInfo = new VolumeInfo("testvol" + Integer.toString(x), - "Thu, Apr 9, 2015 10:23:45 GMT", "gandalf"); - list.addVolume(volInfo); - } - list.sort(); - String listString = list.toJsonString(); - ListVolumes newList = ListVolumes.parse(listString); - assertEquals(list.toJsonString(), newList.toJsonString()); - } -} http://git-wip-us.apache.org/repos/asf/hadoop/blob/2c392da8/hadoop-ozone/common/src/test/java/org/apache/hadoop/ozone/web/package-info.java ---------------------------------------------------------------------- diff --git a/hadoop-ozone/common/src/test/java/org/apache/hadoop/ozone/web/package-info.java b/hadoop-ozone/common/src/test/java/org/apache/hadoop/ozone/web/package-info.java deleted file mode 100644 index ddbc30e..0000000 --- a/hadoop-ozone/common/src/test/java/org/apache/hadoop/ozone/web/package-info.java +++ /dev/null @@ -1,21 +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; -/** - * Unit tests of generic ozone web app and rest utils. - */ http://git-wip-us.apache.org/repos/asf/hadoop/blob/2c392da8/hadoop-ozone/datanode/pom.xml ---------------------------------------------------------------------- diff --git a/hadoop-ozone/datanode/pom.xml b/hadoop-ozone/datanode/pom.xml deleted file mode 100644 index 02995f5..0000000 --- a/hadoop-ozone/datanode/pom.xml +++ /dev/null @@ -1,49 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - Licensed 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. See accompanying LICENSE file. ---> -<project xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.apache.hadoop</groupId> - <artifactId>hadoop-ozone</artifactId> - <version>0.3.0-SNAPSHOT</version> - </parent> - <artifactId>hadoop-ozone-datanode</artifactId> - <name>Apache Hadoop Ozone Datanode</name> - <packaging>jar</packaging> - <version>0.3.0-SNAPSHOT</version> - - <dependencies> - <dependency> - <groupId>org.apache.hadoop</groupId> - <artifactId>hadoop-common</artifactId> - <scope>compile</scope> - </dependency> - <dependency> - <groupId>org.apache.hadoop</groupId> - <artifactId>hadoop-hdfs</artifactId> - <scope>compile</scope> - </dependency> - <dependency> - <groupId>org.apache.hadoop</groupId> - <artifactId>hadoop-hdds-container-service</artifactId> - </dependency> - <dependency> - <groupId>org.apache.hadoop</groupId> - <artifactId>hadoop-ozone-objectstore-service</artifactId> - </dependency> - </dependencies> -</project> http://git-wip-us.apache.org/repos/asf/hadoop/blob/2c392da8/hadoop-ozone/dist/dev-support/bin/dist-layout-stitching ---------------------------------------------------------------------- diff --git a/hadoop-ozone/dist/dev-support/bin/dist-layout-stitching b/hadoop-ozone/dist/dev-support/bin/dist-layout-stitching deleted file mode 100755 index 3f102fa..0000000 --- a/hadoop-ozone/dist/dev-support/bin/dist-layout-stitching +++ /dev/null @@ -1,113 +0,0 @@ -#!/usr/bin/env bash -# 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. - -# project.build.directory -BASEDIR=$1 - -#hdds.version -HDDS_VERSION=$2 - -## @audience private -## @stability evolving -function run() -{ - declare res - - echo "\$ ${*}" - "${@}" - res=$? - if [[ ${res} != 0 ]]; then - echo - echo "Failed!" - echo - exit "${res}" - fi -} - -## @audience private -## @stability evolving -function findfileindir() -{ - declare file="$1" - declare dir="${2:-./share}" - declare count - - count=$(find "${dir}" -iname "${file}" | wc -l) - - #shellcheck disable=SC2086 - echo ${count} -} - - -# shellcheck disable=SC2164 -ROOT=$(cd "${BASEDIR}"/../../..;pwd) -echo -echo "Current directory $(pwd)" -echo - -run rm -rf "ozone-${HDDS_VERSION}" -run mkdir "ozone-${HDDS_VERSION}" -run cd "ozone-${HDDS_VERSION}" -run cp -p "${ROOT}/LICENSE.txt" . -run cp -p "${ROOT}/NOTICE.txt" . -run cp -p "${ROOT}/README.txt" . - -run mkdir -p ./share/hadoop/mapreduce -run mkdir -p ./share/hadoop/ozone -run mkdir -p ./share/hadoop/hdds -run mkdir -p ./share/hadoop/yarn -run mkdir -p ./share/hadoop/hdfs -run mkdir -p ./share/hadoop/common -run mkdir -p ./share/ozone/web -run mkdir -p ./bin -run mkdir -p ./sbin -run mkdir -p ./etc -run mkdir -p ./libexec - -run cp -r "${ROOT}/hadoop-common-project/hadoop-common/src/main/conf" "etc/hadoop" - -run cp "${ROOT}/hadoop-common-project/hadoop-common/src/main/bin/hadoop" "bin/" -run cp "${ROOT}/hadoop-common-project/hadoop-common/src/main/bin/hadoop.cmd" "bin/" -run cp "${ROOT}/hadoop-ozone/common/src/main/bin/ozone" "bin/" - -run cp "${ROOT}/hadoop-common-project/hadoop-common/src/main/bin/hadoop-config.sh" "libexec/" -run cp "${ROOT}/hadoop-common-project/hadoop-common/src/main/bin/hadoop-config.cmd" "libexec/" -run cp "${ROOT}/hadoop-common-project/hadoop-common/src/main/bin/hadoop-functions.sh" "libexec/" -run cp "${ROOT}/hadoop-ozone/common/src/main/bin/ozone-config.sh" "libexec/" -run cp -r "${ROOT}/hadoop-ozone/common/src/main/shellprofile.d" "libexec/" - - -run cp "${ROOT}/hadoop-common-project/hadoop-common/src/main/bin/hadoop-daemons.sh" "sbin/" -run cp "${ROOT}/hadoop-common-project/hadoop-common/src/main/bin/workers.sh" "sbin/" -run cp "${ROOT}/hadoop-ozone/common/src/main/bin/start-ozone.sh" "sbin/" -run cp "${ROOT}/hadoop-ozone/common/src/main/bin/stop-ozone.sh" "sbin/" - -#shaded ozonefs -run mkdir -p "./share/hadoop/ozonefs" -run cp "${ROOT}/hadoop-ozone/ozonefs/target/hadoop-ozone-filesystem-${HDDS_VERSION}.jar" "./share/hadoop/ozonefs/hadoop-ozone-filesystem-${HDDS_VERSION}.jar" - -#shaded datanode service -run mkdir -p "./share/hadoop/ozoneplugin" -run cp "${ROOT}/hadoop-ozone/objectstore-service/target/hadoop-ozone-objectstore-service-${HDDS_VERSION}-plugin.jar" "./share/hadoop/ozoneplugin/hadoop-ozone-datanode-plugin-${HDDS_VERSION}.jar" - - -# Optional documentation, could be missing -cp -r "${ROOT}/hadoop-ozone/docs/target/classes/webapps/docs" ./share/hadoop/ozone/webapps/ozoneManager/ -cp -r "${ROOT}/hadoop-ozone/docs/target/classes/webapps/docs" ./share/hadoop/hdds/webapps/scm/ - -#Copy docker compose files -run cp -p -r "${ROOT}/hadoop-ozone/dist/src/main/compose" . -run cp -p -r "${ROOT}/hadoop-ozone/dist/src/main/smoketest" . --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
