You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by su...@apache.org on 2018/10/05 12:56:03 UTC
[08/51] [partial] hadoop git commit: HADOOP-15791. Remove Ozone
related sources from the 3.2 branch. Contributed by Elek, Marton.
http://git-wip-us.apache.org/repos/asf/hadoop/blob/2c392da8/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/container/InfoSubcommand.java
----------------------------------------------------------------------
diff --git a/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/container/InfoSubcommand.java b/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/container/InfoSubcommand.java
deleted file mode 100644
index 0135df3..0000000
--- a/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/container/InfoSubcommand.java
+++ /dev/null
@@ -1,94 +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
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * 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.hdds.scm.cli.container;
-
-import java.util.concurrent.Callable;
-import java.util.stream.Collectors;
-
-import org.apache.hadoop.hdds.cli.HddsVersionProvider;
-import org.apache.hadoop.hdds.protocol.DatanodeDetails;
-import org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos
- .ContainerData;
-import org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos
- .ContainerLifeCycleState;
-import org.apache.hadoop.hdds.scm.cli.SCMCLI;
-import org.apache.hadoop.hdds.scm.client.ScmClient;
-import org.apache.hadoop.hdds.scm.container.common.helpers
- .ContainerWithPipeline;
-
-import com.google.common.base.Preconditions;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import picocli.CommandLine.Command;
-import picocli.CommandLine.Parameters;
-import picocli.CommandLine.ParentCommand;
-
-/**
- * This is the handler that process container info command.
- */
-@Command(
- name = "info",
- description = "Show information about a specific container",
- mixinStandardHelpOptions = true,
- versionProvider = HddsVersionProvider.class)
-public class InfoSubcommand implements Callable<Void> {
-
- private static final Logger LOG =
- LoggerFactory.getLogger(InfoSubcommand.class);
-
- @ParentCommand
- private SCMCLI parent;
-
- @Parameters(description = "Decimal id of the container.")
- private long containerID;
-
- @Override
- public Void call() throws Exception {
- try (ScmClient scmClient = parent.createScmClient()) {
- ContainerWithPipeline container = scmClient.
- getContainerWithPipeline(containerID);
- Preconditions.checkNotNull(container, "Container cannot be null");
-
- ContainerData containerData = scmClient.readContainer(container
- .getContainerInfo().getContainerID(), container.getPipeline());
-
- // Print container report info.
- LOG.info("Container id: {}", containerID);
- String openStatus =
- containerData.getState() == ContainerLifeCycleState.OPEN ? "OPEN" :
- "CLOSED";
- LOG.info("Container State: {}", openStatus);
- LOG.info("Container Path: {}", containerData.getContainerPath());
-
- // Output meta data.
- String metadataStr = containerData.getMetadataList().stream().map(
- p -> p.getKey() + ":" + p.getValue())
- .collect(Collectors.joining(", "));
- LOG.info("Container Metadata: {}", metadataStr);
-
- // Print pipeline of an existing container.
- LOG.info("LeaderID: {}", container.getPipeline()
- .getLeader().getHostName());
- String machinesStr = container.getPipeline()
- .getMachines().stream().map(
- DatanodeDetails::getHostName).collect(Collectors.joining(","));
- LOG.info("Datanodes: [{}]", machinesStr);
- return null;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/2c392da8/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/container/ListSubcommand.java
----------------------------------------------------------------------
diff --git a/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/container/ListSubcommand.java b/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/container/ListSubcommand.java
deleted file mode 100644
index 0f520fd..0000000
--- a/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/container/ListSubcommand.java
+++ /dev/null
@@ -1,83 +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
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * 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.hdds.scm.cli.container;
-
-import java.io.IOException;
-import java.util.List;
-import java.util.concurrent.Callable;
-
-import org.apache.hadoop.hdds.cli.HddsVersionProvider;
-import org.apache.hadoop.hdds.scm.cli.SCMCLI;
-import org.apache.hadoop.hdds.scm.client.ScmClient;
-import org.apache.hadoop.hdds.scm.container.common.helpers.ContainerInfo;
-import org.apache.hadoop.ozone.web.utils.JsonUtils;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import picocli.CommandLine.Command;
-import picocli.CommandLine.Help.Visibility;
-import picocli.CommandLine.Option;
-import picocli.CommandLine.ParentCommand;
-
-/**
- * This is the handler that process container list command.
- */
-@Command(
- name = "list",
- description = "List containers",
- mixinStandardHelpOptions = true,
- versionProvider = HddsVersionProvider.class)
-public class ListSubcommand implements Callable<Void> {
-
- private static final Logger LOG =
- LoggerFactory.getLogger(ListSubcommand.class);
-
- @ParentCommand
- private SCMCLI parent;
-
- @Option(names = {"-s", "--start"},
- description = "Container id to start the iteration", required = true)
- private long startId;
-
- @Option(names = {"-c", "--count"},
- description = "Maximum number of containers to list",
- defaultValue = "20", showDefaultValue = Visibility.ALWAYS)
- private int count = 20;
-
- private void outputContainerInfo(ContainerInfo containerInfo)
- throws IOException {
- // Print container report info.
- LOG.info("{}", JsonUtils.toJsonStringWithDefaultPrettyPrinter(
- containerInfo.toJsonString()));
- }
-
- @Override
- public Void call() throws Exception {
- try (ScmClient scmClient = parent.createScmClient()) {
-
- List<ContainerInfo> containerList =
- scmClient.listContainer(startId, count);
-
- // Output data list
- for (ContainerInfo container : containerList) {
- outputContainerInfo(container);
- }
- return null;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/2c392da8/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/container/package-info.java
----------------------------------------------------------------------
diff --git a/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/container/package-info.java b/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/container/package-info.java
deleted file mode 100644
index ff8adbc..0000000
--- a/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/container/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.
- */
-
-/**
- * Contains all of the container related scm commands.
- */
-package org.apache.hadoop.hdds.scm.cli.container;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/hadoop/blob/2c392da8/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/package-info.java
----------------------------------------------------------------------
diff --git a/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/package-info.java b/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/package-info.java
deleted file mode 100644
index d358b3c..0000000
--- a/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/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
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * 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.
- * <p>
- * SCM related cli tools.
- */
-/**
- * SCM related cli tools.
- */
-package org.apache.hadoop.hdds.scm.cli;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/hadoop/blob/2c392da8/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/datanode/datanode.html
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/datanode/datanode.html b/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/datanode/datanode.html
index 0fdf552..174a9dc 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/datanode/datanode.html
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/datanode/datanode.html
@@ -98,52 +98,6 @@
{/dn.BPServiceActorInfo}
</table>
-{#ozone.enabled}
-<div class="page-header"><h1>Ozone: SCM Connections</h1></div>
-<table class="table">
- <thead>
- <tr>
- <th>SCM Address</th>
- <th>Status</th>
- <th>Version</th>
- <th>Missed count</th>
- <th>Last heartbeat</th>
- </tr>
- </thead>
- {#ozone.SCMServers}
- <tr>
- <td>{addressString}</td>
- <td>{state}</td>
- <td>{versionNumber}</td>
- <td>{missedCount}s</td>
- <td>{lastSuccessfulHeartbeat|elapsed|fmt_time}</td>
- </tr>
- {/ozone.SCMServers}
-</table>
-
-<div class="page-header"><h1>Ozone: Storage locations</h1></div>
-<table class="table">
- <thead>
- <tr>
- <th>ID</th>
- <th>Capacity</th>
- <th>Remaining</th>
- <th>SCM used</th>
- <th>failed</th>
- </tr>
- </thead>
- {#ozone.LocationReport}
- <tr>
- <td>{id}</td>
- <td>{capacity|fmt_bytes}</td>
- <td>{remaining|fmt_bytes}</td>
- <td>{scmUsed|fmt_bytes}</td>
- <td>{failed}</td>
- </tr>
- {/ozone.LocationReport}
-</table>
-{/ozone.enabled}
-
<div class="page-header"><h1>Volume Information</h1></div>
<table class="table">
<thead>
@@ -179,4 +133,4 @@
<script type="text/javascript" src="dn.js"></script>
</body>
-</html>
\ No newline at end of file
+</html>
http://git-wip-us.apache.org/repos/asf/hadoop/blob/2c392da8/hadoop-hdfs-project/hadoop-hdfs/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/resources/log4j.properties b/hadoop-hdfs-project/hadoop-hdfs/src/test/resources/log4j.properties
index 2d1c98b..bd5a4dd 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/resources/log4j.properties
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/resources/log4j.properties
@@ -48,26 +48,3 @@ log4j.appender.DNMETRICSRFA.layout.ConversionPattern=%d{ISO8601} %m%n
log4j.appender.DNMETRICSRFA.MaxBackupIndex=1
log4j.appender.DNMETRICSRFA.MaxFileSize=64MB
-#
-# Add a logger for ozone that is separate from the Datanode.
-#
-log4j.logger.org.apache.hadoop.ozone=INFO,OZONE,FILE
-
-# Do not log into datanode logs. Remove this line to have single log.
-log4j.additivity.org.apache.hadoop.ozone=false
-
-# For development purposes, log both to console and log file.
-log4j.appender.OZONE=org.apache.log4j.ConsoleAppender
-log4j.appender.OZONE.Threshold=ALL
-log4j.appender.OZONE.layout=org.apache.log4j.PatternLayout
-log4j.appender.OZONE.layout.ConversionPattern=%d{ISO8601} [%t] %-5p %c{2} (%F:%M(%L)) \
- %X{component} %X{function} %X{resource} %X{user} %X{request} - %m%n
-
-# Real ozone logger that writes to ozone.log
-log4j.appender.FILE=org.apache.log4j.DailyRollingFileAppender
-log4j.appender.FILE.File=${hadoop.log.dir}/ozone.log
-log4j.appender.FILE.Threshold=debug
-log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
-log4j.appender.FILE.layout.ConversionPattern=%d{ISO8601} [%t] %-5p \
- (%F:%L) %X{function} %X{resource} %X{user} %X{request} - \
- %m%n
http://git-wip-us.apache.org/repos/asf/hadoop/blob/2c392da8/hadoop-ozone/client/pom.xml
----------------------------------------------------------------------
diff --git a/hadoop-ozone/client/pom.xml b/hadoop-ozone/client/pom.xml
deleted file mode 100644
index e471710..0000000
--- a/hadoop-ozone/client/pom.xml
+++ /dev/null
@@ -1,37 +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-client</artifactId>
- <version>0.3.0-SNAPSHOT</version>
- <description>Apache Hadoop Ozone Client</description>
- <name>Apache Hadoop Ozone Client</name>
- <packaging>jar</packaging>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.hadoop</groupId>
- <artifactId>hadoop-ozone-common</artifactId>
- </dependency>
- </dependencies>
-</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/hadoop/blob/2c392da8/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/BucketArgs.java
----------------------------------------------------------------------
diff --git a/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/BucketArgs.java b/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/BucketArgs.java
deleted file mode 100644
index 0da52dc..0000000
--- a/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/BucketArgs.java
+++ /dev/null
@@ -1,123 +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;
-
-import org.apache.hadoop.fs.StorageType;
-import org.apache.hadoop.ozone.OzoneAcl;
-
-import java.util.List;
-
-/**
- * This class encapsulates the arguments that are
- * required for creating a bucket.
- */
-public final class BucketArgs {
-
- /**
- * ACL Information.
- */
- private List<OzoneAcl> acls;
- /**
- * Bucket Version flag.
- */
- private Boolean versioning;
- /**
- * Type of storage to be used for this bucket.
- * [RAM_DISK, SSD, DISK, ARCHIVE]
- */
- private StorageType storageType;
-
- /**
- * Private constructor, constructed via builder.
- * @param versioning Bucket version flag.
- * @param storageType Storage type to be used.
- * @param acls list of ACLs.
- */
- private BucketArgs(Boolean versioning, StorageType storageType,
- List<OzoneAcl> acls) {
- this.acls = acls;
- this.versioning = versioning;
- this.storageType = storageType;
- }
-
- /**
- * Returns true if bucket version is enabled, else false.
- * @return isVersionEnabled
- */
- public Boolean getVersioning() {
- return versioning;
- }
-
- /**
- * Returns the type of storage to be used.
- * @return StorageType
- */
- public StorageType getStorageType() {
- return storageType;
- }
-
- /**
- * Returns the ACL's associated with this bucket.
- * @return List<OzoneAcl>
- */
- public List<OzoneAcl> getAcls() {
- return acls;
- }
-
- /**
- * Returns new builder class that builds a OmBucketInfo.
- *
- * @return Builder
- */
- public static BucketArgs.Builder newBuilder() {
- return new BucketArgs.Builder();
- }
-
- /**
- * Builder for OmBucketInfo.
- */
- public static class Builder {
- private Boolean versioning;
- private StorageType storageType;
- private List<OzoneAcl> acls;
-
- public BucketArgs.Builder setVersioning(Boolean versionFlag) {
- this.versioning = versionFlag;
- return this;
- }
-
- public BucketArgs.Builder setStorageType(StorageType storage) {
- this.storageType = storage;
- return this;
- }
-
- public BucketArgs.Builder setAcls(List<OzoneAcl> listOfAcls) {
- this.acls = listOfAcls;
- return this;
- }
-
- /**
- * Constructs the BucketArgs.
- * @return instance of BucketArgs.
- */
- public BucketArgs build() {
- return new BucketArgs(versioning, storageType, acls);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/2c392da8/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/ObjectStore.java
----------------------------------------------------------------------
diff --git a/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/ObjectStore.java b/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/ObjectStore.java
deleted file mode 100644
index 17d1938..0000000
--- a/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/ObjectStore.java
+++ /dev/null
@@ -1,216 +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;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Strings;
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hdds.scm.client.HddsClientUtils;
-import org.apache.hadoop.ozone.client.protocol.ClientProtocol;
-import org.apache.hadoop.security.UserGroupInformation;
-
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.List;
-import java.util.NoSuchElementException;
-
-/**
- * ObjectStore class is responsible for the client operations that can be
- * performed on Ozone Object Store.
- */
-public class ObjectStore {
-
- /**
- * The proxy used for connecting to the cluster and perform
- * client operations.
- */
- private final ClientProtocol proxy;
-
- /**
- * Cache size to be used for listVolume calls.
- */
- private int listCacheSize;
-
- /**
- * Creates an instance of ObjectStore.
- * @param conf Configuration object.
- * @param proxy ClientProtocol proxy.
- */
- public ObjectStore(Configuration conf, ClientProtocol proxy) {
- this.proxy = proxy;
- this.listCacheSize = HddsClientUtils.getListCacheSize(conf);
- }
-
- @VisibleForTesting
- protected ObjectStore() {
- proxy = null;
- }
-
- /**
- * Creates the volume with default values.
- * @param volumeName Name of the volume to be created.
- * @throws IOException
- */
- public void createVolume(String volumeName) throws IOException {
- proxy.createVolume(volumeName);
- }
-
- /**
- * Creates the volume.
- * @param volumeName Name of the volume to be created.
- * @param volumeArgs Volume properties.
- * @throws IOException
- */
- public void createVolume(String volumeName, VolumeArgs volumeArgs)
- throws IOException {
- proxy.createVolume(volumeName, volumeArgs);
- }
-
- /**
- * Returns the volume information.
- * @param volumeName Name of the volume.
- * @return OzoneVolume
- * @throws IOException
- */
- public OzoneVolume getVolume(String volumeName) throws IOException {
- OzoneVolume volume = proxy.getVolumeDetails(volumeName);
- return volume;
- }
-
-
- /**
- * Returns Iterator to iterate over all the volumes in object store.
- * The result can be restricted using volume prefix, will return all
- * volumes if volume prefix is null.
- *
- * @param volumePrefix Volume prefix to match
- * @return {@code Iterator<OzoneVolume>}
- */
- public Iterator<? extends OzoneVolume> listVolumes(String volumePrefix)
- throws IOException {
- return listVolumes(volumePrefix, null);
- }
-
- /**
- * Returns Iterator to iterate over all the volumes after prevVolume in object
- * store. If prevVolume is null it iterates from the first volume.
- * The result can be restricted using volume prefix, will return all
- * volumes if volume prefix is null.
- *
- * @param volumePrefix Volume prefix to match
- * @param prevVolume Volumes will be listed after this volume name
- * @return {@code Iterator<OzoneVolume>}
- */
- public Iterator<? extends OzoneVolume> listVolumes(String volumePrefix,
- String prevVolume) throws IOException {
- return new VolumeIterator(null, volumePrefix, prevVolume);
- }
-
- /**
- * Returns Iterator to iterate over the list of volumes after prevVolume owned
- * by a specific user. The result can be restricted using volume prefix, will
- * return all volumes if volume prefix is null. If user is not null, returns
- * the volume of current user.
- *
- * @param user User Name
- * @param volumePrefix Volume prefix to match
- * @param prevVolume Volumes will be listed after this volume name
- * @return {@code Iterator<OzoneVolume>}
- */
- public Iterator<? extends OzoneVolume> listVolumesByUser(String user,
- String volumePrefix, String prevVolume)
- throws IOException {
- if(Strings.isNullOrEmpty(user)) {
- user = UserGroupInformation.getCurrentUser().getShortUserName();
- }
- return new VolumeIterator(user, volumePrefix, prevVolume);
- }
-
- /**
- * Deletes the volume.
- * @param volumeName Name of the volume.
- * @throws IOException
- */
- public void deleteVolume(String volumeName) throws IOException {
- proxy.deleteVolume(volumeName);
- }
-
- /**
- * An Iterator to iterate over {@link OzoneVolume} list.
- */
- private class VolumeIterator implements Iterator<OzoneVolume> {
-
- private String user = null;
- private String volPrefix = null;
-
- private Iterator<OzoneVolume> currentIterator;
- private OzoneVolume currentValue;
-
- /**
- * Creates an Iterator to iterate over all volumes after
- * prevVolume of the user. If prevVolume is null it iterates from the
- * first volume. The returned volumes match volume prefix.
- * @param user user name
- * @param volPrefix volume prefix to match
- */
- VolumeIterator(String user, String volPrefix, String prevVolume) {
- this.user = user;
- this.volPrefix = volPrefix;
- this.currentValue = null;
- this.currentIterator = getNextListOfVolumes(prevVolume).iterator();
- }
-
- @Override
- public boolean hasNext() {
- if(!currentIterator.hasNext()) {
- currentIterator = getNextListOfVolumes(
- currentValue != null ? currentValue.getName() : null)
- .iterator();
- }
- return currentIterator.hasNext();
- }
-
- @Override
- public OzoneVolume next() {
- if(hasNext()) {
- currentValue = currentIterator.next();
- return currentValue;
- }
- throw new NoSuchElementException();
- }
-
- /**
- * Returns the next set of volume list using proxy.
- * @param prevVolume previous volume, this will be excluded from the result
- * @return {@code List<OzoneVolume>}
- */
- private List<OzoneVolume> getNextListOfVolumes(String prevVolume) {
- try {
- //if user is null, we do list of all volumes.
- if(user != null) {
- return proxy.listVolumes(user, volPrefix, prevVolume, listCacheSize);
- }
- return proxy.listVolumes(volPrefix, prevVolume, listCacheSize);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/2c392da8/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/OzoneBucket.java
----------------------------------------------------------------------
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
deleted file mode 100644
index 751992e..0000000
--- a/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/OzoneBucket.java
+++ /dev/null
@@ -1,382 +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;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Preconditions;
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.fs.StorageType;
-import org.apache.hadoop.hdds.client.ReplicationFactor;
-import org.apache.hadoop.hdds.client.ReplicationType;
-import org.apache.hadoop.hdds.scm.client.HddsClientUtils;
-import org.apache.hadoop.ozone.OzoneConfigKeys;
-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.OzoneAcl;
-
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.List;
-import java.util.NoSuchElementException;
-
-/**
- * A class that encapsulates OzoneBucket.
- */
-public class OzoneBucket {
-
- /**
- * The proxy used for connecting to the cluster and perform
- * client operations.
- */
- private final ClientProtocol proxy;
- /**
- * Name of the volume in which the bucket belongs to.
- */
- private final String volumeName;
- /**
- * Name of the bucket.
- */
- private final String name;
- /**
- * Default replication factor to be used while creating keys.
- */
- private final ReplicationFactor defaultReplication;
-
- /**
- * Default replication type to be used while creating keys.
- */
- private final ReplicationType defaultReplicationType;
- /**
- * Bucket ACLs.
- */
- private List<OzoneAcl> acls;
-
- /**
- * Type of storage to be used for this bucket.
- * [RAM_DISK, SSD, DISK, ARCHIVE]
- */
- private StorageType storageType;
-
- /**
- * Bucket Version flag.
- */
- private Boolean versioning;
-
- /**
- * Cache size to be used for listKey calls.
- */
- private int listCacheSize;
-
- /**
- * Creation time of the bucket.
- */
- private long creationTime;
-
- /**
- * Constructs OzoneBucket instance.
- * @param conf Configuration object.
- * @param proxy ClientProtocol proxy.
- * @param volumeName Name of the volume the bucket belongs to.
- * @param bucketName Name of the bucket.
- * @param acls ACLs associated with the bucket.
- * @param storageType StorageType of the bucket.
- * @param versioning versioning status of the bucket.
- * @param creationTime creation time of the bucket.
- */
- public OzoneBucket(Configuration conf, ClientProtocol proxy,
- String volumeName, String bucketName,
- List<OzoneAcl> acls, StorageType storageType,
- Boolean versioning, long creationTime) {
- Preconditions.checkNotNull(proxy, "Client proxy is not set.");
- this.proxy = proxy;
- this.volumeName = volumeName;
- this.name = bucketName;
- this.acls = acls;
- this.storageType = storageType;
- this.versioning = versioning;
- this.listCacheSize = HddsClientUtils.getListCacheSize(conf);
- this.creationTime = creationTime;
- this.defaultReplication = ReplicationFactor.valueOf(conf.getInt(
- OzoneConfigKeys.OZONE_REPLICATION,
- OzoneConfigKeys.OZONE_REPLICATION_DEFAULT));
- this.defaultReplicationType = ReplicationType.valueOf(conf.get(
- OzoneConfigKeys.OZONE_REPLICATION_TYPE,
- OzoneConfigKeys.OZONE_REPLICATION_TYPE_DEFAULT));
- }
-
- @VisibleForTesting
- OzoneBucket(String volumeName, String name,
- ReplicationFactor defaultReplication,
- ReplicationType defaultReplicationType,
- List<OzoneAcl> acls, StorageType storageType, Boolean versioning,
- long creationTime) {
- this.proxy = null;
- this.volumeName = volumeName;
- this.name = name;
- this.defaultReplication = defaultReplication;
- this.defaultReplicationType = defaultReplicationType;
- this.acls = acls;
- this.storageType = storageType;
- this.versioning = versioning;
- this.creationTime = creationTime;
- }
-
- /**
- * Returns Volume Name.
- *
- * @return volumeName
- */
- public String getVolumeName() {
- return volumeName;
- }
-
- /**
- * Returns Bucket Name.
- *
- * @return bucketName
- */
- public String getName() {
- return name;
- }
-
- /**
- * Returns ACL's associated with the Bucket.
- *
- * @return acls
- */
- public List<OzoneAcl> getAcls() {
- return acls;
- }
-
- /**
- * Returns StorageType of the Bucket.
- *
- * @return storageType
- */
- public StorageType getStorageType() {
- return storageType;
- }
-
- /**
- * Returns Versioning associated with the Bucket.
- *
- * @return versioning
- */
- public Boolean getVersioning() {
- return versioning;
- }
-
- /**
- * Returns creation time of the Bucket.
- *
- * @return creation time of the bucket
- */
- public long getCreationTime() {
- return creationTime;
- }
-
- /**
- * Adds ACLs to the Bucket.
- * @param addAcls ACLs to be added
- * @throws IOException
- */
- public void addAcls(List<OzoneAcl> addAcls) throws IOException {
- proxy.addBucketAcls(volumeName, name, addAcls);
- addAcls.stream().filter(acl -> !acls.contains(acl)).forEach(
- acls::add);
- }
-
- /**
- * Removes ACLs from the bucket.
- * @param removeAcls ACLs to be removed
- * @throws IOException
- */
- public void removeAcls(List<OzoneAcl> removeAcls) throws IOException {
- proxy.removeBucketAcls(volumeName, name, removeAcls);
- acls.removeAll(removeAcls);
- }
-
- /**
- * Sets/Changes the storage type of the bucket.
- * @param newStorageType Storage type to be set
- * @throws IOException
- */
- public void setStorageType(StorageType newStorageType) throws IOException {
- proxy.setBucketStorageType(volumeName, name, newStorageType);
- storageType = newStorageType;
- }
-
- /**
- * Enable/Disable versioning of the bucket.
- * @param newVersioning
- * @throws IOException
- */
- public void setVersioning(Boolean newVersioning) throws IOException {
- proxy.setBucketVersioning(volumeName, name, newVersioning);
- versioning = newVersioning;
- }
-
- /**
- * Creates a new key in the bucket, with default replication type RATIS and
- * with replication factor THREE.
- * @param key Name of the key to be created.
- * @param size Size of the data the key will point to.
- * @return OzoneOutputStream to which the data has to be written.
- * @throws IOException
- */
- public OzoneOutputStream createKey(String key, long size)
- throws IOException {
- return createKey(key, size, defaultReplicationType, defaultReplication);
- }
-
- /**
- * Creates a new key in the bucket.
- * @param key Name of the key to be created.
- * @param size Size of the data the key will point to.
- * @param type Replication type to be used.
- * @param factor Replication factor of the key.
- * @return OzoneOutputStream to which the data has to be written.
- * @throws IOException
- */
- public OzoneOutputStream createKey(String key, long size,
- ReplicationType type,
- ReplicationFactor factor)
- throws IOException {
- return proxy.createKey(volumeName, name, key, size, type, factor);
- }
-
- /**
- * Reads an existing key from the bucket.
- * @param key Name of the key to be read.
- * @return OzoneInputStream the stream using which the data can be read.
- * @throws IOException
- */
- public OzoneInputStream readKey(String key) throws IOException {
- return proxy.getKey(volumeName, name, key);
- }
-
- /**
- * Returns information about the key.
- * @param key Name of the key.
- * @return OzoneKeyDetails Information about the key.
- * @throws IOException
- */
- public OzoneKeyDetails getKey(String key) throws IOException {
- return proxy.getKeyDetails(volumeName, name, key);
- }
-
- /**
- * Returns Iterator to iterate over all keys in the bucket.
- * The result can be restricted using key prefix, will return all
- * keys if key prefix is null.
- *
- * @param keyPrefix Bucket prefix to match
- * @return {@code Iterator<OzoneKey>}
- */
- public Iterator<? extends OzoneKey> listKeys(String keyPrefix) {
- return listKeys(keyPrefix, null);
- }
-
- /**
- * Returns Iterator to iterate over all keys after prevKey in the bucket.
- * If prevKey is null it iterates from the first key in the bucket.
- * The result can be restricted using key prefix, will return all
- * keys if key prefix is null.
- *
- * @param keyPrefix Bucket prefix to match
- * @param prevKey Keys will be listed after this key name
- * @return {@code Iterator<OzoneKey>}
- */
- public Iterator<? extends OzoneKey> listKeys(String keyPrefix,
- String prevKey) {
- return new KeyIterator(keyPrefix, prevKey);
- }
-
- /**
- * Deletes key from the bucket.
- * @param key Name of the key to be deleted.
- * @throws IOException
- */
- public void deleteKey(String key) throws IOException {
- proxy.deleteKey(volumeName, name, key);
- }
-
- public void renameKey(String fromKeyName, String toKeyName)
- throws IOException {
- proxy.renameKey(volumeName, name, fromKeyName, toKeyName);
- }
-
- /**
- * An Iterator to iterate over {@link OzoneKey} list.
- */
- private class KeyIterator implements Iterator<OzoneKey> {
-
- private String keyPrefix = null;
-
- private Iterator<OzoneKey> currentIterator;
- private OzoneKey currentValue;
-
-
- /**
- * Creates an Iterator to iterate over all keys after prevKey in the bucket.
- * If prevKey is null it iterates from the first key in the bucket.
- * The returned keys match key prefix.
- * @param keyPrefix
- */
- KeyIterator(String keyPrefix, String prevKey) {
- this.keyPrefix = keyPrefix;
- this.currentValue = null;
- this.currentIterator = getNextListOfKeys(prevKey).iterator();
- }
-
- @Override
- public boolean hasNext() {
- if(!currentIterator.hasNext()) {
- currentIterator = getNextListOfKeys(
- currentValue != null ? currentValue.getName() : null)
- .iterator();
- }
- return currentIterator.hasNext();
- }
-
- @Override
- public OzoneKey next() {
- if(hasNext()) {
- currentValue = currentIterator.next();
- return currentValue;
- }
- throw new NoSuchElementException();
- }
-
- /**
- * Gets the next set of key list using proxy.
- * @param prevKey
- * @return {@code List<OzoneVolume>}
- */
- private List<OzoneKey> getNextListOfKeys(String prevKey) {
- try {
- return proxy.listKeys(volumeName, name, keyPrefix, prevKey,
- listCacheSize);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/2c392da8/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/OzoneClient.java
----------------------------------------------------------------------
diff --git a/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/OzoneClient.java b/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/OzoneClient.java
deleted file mode 100644
index 0d65d73..0000000
--- a/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/OzoneClient.java
+++ /dev/null
@@ -1,110 +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;
-
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.ozone.client.protocol.ClientProtocol;
-
-import java.io.Closeable;
-import java.io.IOException;
-
-import com.google.common.annotations.VisibleForTesting;
-
-/**
- * OzoneClient connects to Ozone Cluster and
- * perform basic operations.
- */
-public class OzoneClient implements Closeable {
-
- /*
- * OzoneClient connects to Ozone Cluster and
- * perform basic operations.
- *
- * +-------------+ +---+ +-------------------------------------+
- * | OzoneClient | --> | C | | Object Store |
- * |_____________| | l | | +-------------------------------+ |
- * | i | | | Volume(s) | |
- * | e | | | +------------------------+ | |
- * | n | | | | Bucket(s) | | |
- * | t | | | | +------------------+ | | |
- * | | | | | | Key -> Value (s) | | | |
- * | P |-->| | | | | | | |
- * | r | | | | |__________________| | | |
- * | o | | | | | | |
- * | t | | | |________________________| | |
- * | o | | | | |
- * | c | | |_______________________________| |
- * | o | | |
- * | l | |_____________________________________|
- * |___|
- * Example:
- * ObjectStore store = client.getObjectStore();
- * store.createVolume(“volume one”, VolumeArgs);
- * volume.setQuota(“10 GB”);
- * OzoneVolume volume = store.getVolume(“volume one”);
- * volume.createBucket(“bucket one”, BucketArgs);
- * bucket.setVersioning(true);
- * OzoneOutputStream os = bucket.createKey(“key one”, 1024);
- * os.write(byte[]);
- * os.close();
- * OzoneInputStream is = bucket.readKey(“key one”);
- * is.read();
- * is.close();
- * bucket.deleteKey(“key one”);
- * volume.deleteBucket(“bucket one”);
- * store.deleteVolume(“volume one”);
- * client.close();
- */
-
- private final ClientProtocol proxy;
- private final ObjectStore objectStore;
-
- /**
- * Creates a new OzoneClient object, generally constructed
- * using {@link OzoneClientFactory}.
- * @param conf Configuration object
- * @param proxy ClientProtocol proxy instance
- */
- public OzoneClient(Configuration conf, ClientProtocol proxy) {
- this.proxy = proxy;
- this.objectStore = new ObjectStore(conf, this.proxy);
- }
-
- @VisibleForTesting
- protected OzoneClient(ObjectStore objectStore) {
- this.objectStore = objectStore;
- this.proxy = null;
- }
- /**
- * Returns the object store associated with the Ozone Cluster.
- * @return ObjectStore
- */
- public ObjectStore getObjectStore() {
- return objectStore;
- }
-
- /**
- * Closes the client and all the underlying resources.
- * @throws IOException
- */
- @Override
- public void close() throws IOException {
- proxy.close();
- }
-}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/2c392da8/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/OzoneClientException.java
----------------------------------------------------------------------
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
deleted file mode 100644
index de3116a..0000000
--- a/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/OzoneClientException.java
+++ /dev/null
@@ -1,54 +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;
-
-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);
- }
-
- /**
- * 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);
- }
-
- /**
- * 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);
- }
-}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/2c392da8/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/OzoneClientFactory.java
----------------------------------------------------------------------
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
deleted file mode 100644
index de0d166..0000000
--- a/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/OzoneClientFactory.java
+++ /dev/null
@@ -1,306 +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;
-
-import com.google.common.base.Preconditions;
-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 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 <code>ozone.client.protocol</code>, it decides which
- * protocol to use for the communication.
- * Default value is
- * <code>org.apache.hadoop.ozone.client.rpc.RpcClient</code>.<br>
- * OzoneClientFactory constructs a proxy using
- * {@link OzoneClientInvocationHandler}
- * and creates OzoneClient instance with it.
- * {@link OzoneClientInvocationHandler} dispatches the call to
- * underlying {@link ClientProtocol} implementation.
- */
-public final class OzoneClientFactory {
-
- private static final Logger LOG = LoggerFactory.getLogger(
- OzoneClientFactory.class);
-
- /**
- * Private constructor, class is not meant to be initialized.
- */
- private OzoneClientFactory(){}
-
-
- /**
- * Constructs and return an OzoneClient with default configuration.
- *
- * @return OzoneClient
- *
- * @throws IOException
- */
- public static OzoneClient getClient() throws IOException {
- LOG.info("Creating OzoneClient with default configuration.");
- return getClient(new OzoneConfiguration());
- }
-
- /**
- * Constructs and return an OzoneClient based on the configuration object.
- * Protocol type is decided by <code>ozone.client.protocol</code>.
- *
- * @param config
- * Configuration to be used for OzoneClient creation
- *
- * @return OzoneClient
- *
- * @throws IOException
- */
- 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);
- }
-
- /**
- * Returns an OzoneClient which will use RPC protocol.
- *
- * @param omHost
- * hostname of OzoneManager to connect.
- *
- * @return OzoneClient
- *
- * @throws IOException
- */
- public static OzoneClient getRpcClient(String omHost)
- throws IOException {
- Configuration config = new OzoneConfiguration();
- int port = OmUtils.getOmRpcPort(config);
- return getRpcClient(omHost, port, config);
- }
-
- /**
- * Returns an OzoneClient which will use RPC protocol.
- *
- * @param omHost
- * hostname of OzoneManager to connect.
- *
- * @param omRpcPort
- * RPC port of OzoneManager.
- *
- * @return OzoneClient
- *
- * @throws IOException
- */
- public static OzoneClient getRpcClient(String omHost, Integer omRpcPort)
- throws IOException {
- return getRpcClient(omHost, omRpcPort, new OzoneConfiguration());
- }
-
- /**
- * Returns an OzoneClient which will use RPC protocol.
- *
- * @param omHost
- * hostname of OzoneManager to connect.
- *
- * @param omRpcPort
- * RPC port of OzoneManager.
- *
- * @param config
- * Configuration to be used for OzoneClient creation
- *
- * @return OzoneClient
- *
- * @throws IOException
- */
- public static OzoneClient getRpcClient(String omHost, Integer omRpcPort,
- Configuration config)
- throws IOException {
- Preconditions.checkNotNull(omHost);
- Preconditions.checkNotNull(omRpcPort);
- Preconditions.checkNotNull(config);
- config.set(OZONE_OM_ADDRESS_KEY, omHost + ":" + omRpcPort);
- return getRpcClient(config);
- }
-
- /**
- * Returns an OzoneClient which will use RPC protocol.
- *
- * @param config
- * used for OzoneClient creation
- *
- * @return OzoneClient
- *
- * @throws IOException
- */
- 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),
- config);
- }
-
- /**
- * Creates OzoneClient with the given ClientProtocol and Configuration.
- *
- * @param clientProtocol
- * Protocol to be used by the OzoneClient
- *
- * @param config
- * Configuration to be used for OzoneClient creation
- */
- private static OzoneClient getClient(ClientProtocol clientProtocol,
- Configuration config) {
- OzoneClientInvocationHandler clientHandler =
- new OzoneClientInvocationHandler(clientProtocol);
- ClientProtocol proxy = (ClientProtocol) Proxy.newProxyInstance(
- OzoneClientInvocationHandler.class.getClassLoader(),
- new Class<?>[]{ClientProtocol.class}, clientHandler);
- return new OzoneClient(config, proxy);
- }
-
- /**
- * Returns an instance of Protocol class.
- *
- * @param protocolClass
- * Class object of the ClientProtocol.
- *
- * @param config
- * Configuration used to initialize ClientProtocol.
- *
- * @return ClientProtocol
- *
- * @throws IOException
- */
- private static ClientProtocol getClientProtocol(
- Class<? extends ClientProtocol> protocolClass, 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);
- } catch (Exception e) {
- final String message = "Couldn't create protocol " + protocolClass;
- 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);
- }
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/2c392da8/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/OzoneClientInvocationHandler.java
----------------------------------------------------------------------
diff --git a/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/OzoneClientInvocationHandler.java b/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/OzoneClientInvocationHandler.java
deleted file mode 100644
index 3051e2d..0000000
--- a/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/OzoneClientInvocationHandler.java
+++ /dev/null
@@ -1,62 +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;
-
-import org.apache.hadoop.ozone.client.protocol.ClientProtocol;
-import org.apache.hadoop.util.Time;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-
-/**
- * Invocation Handler for ozone client which dispatches the call to underlying
- * ClientProtocol implementation.
- */
-public class OzoneClientInvocationHandler implements InvocationHandler {
-
-
- private static final Logger LOG = LoggerFactory.getLogger(OzoneClient.class);
- private final ClientProtocol target;
-
- /**
- * Constructs OzoneClientInvocationHandler with the proxy.
- * @param target proxy to be used for method invocation.
- */
- public OzoneClientInvocationHandler(ClientProtocol target) {
- this.target = target;
- }
-
- @Override
- public Object invoke(Object proxy, Method method, Object[] args)
- throws Throwable {
- LOG.trace("Invoking method {} on proxy {}", method, proxy);
- try {
- long startTime = Time.monotonicNow();
- Object result = method.invoke(target, args);
- LOG.debug("Call: {} took {} ms", method,
- Time.monotonicNow() - startTime);
- return result;
- } catch(InvocationTargetException iEx) {
- throw iEx.getCause();
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/hadoop/blob/2c392da8/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/OzoneClientUtils.java
----------------------------------------------------------------------
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
deleted file mode 100644
index 40e4d83..0000000
--- a/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/OzoneClientUtils.java
+++ /dev/null
@@ -1,136 +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
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * 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;
-
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hdds.client.OzoneQuota;
-import org.apache.hadoop.hdds.scm.client.HddsClientUtils;
-import org.apache.hadoop.hdds.scm.container.common.helpers.BlockNotCommittedException;
-import org.apache.hadoop.io.retry.RetryPolicies;
-import org.apache.hadoop.io.retry.RetryPolicy;
-import org.apache.hadoop.ozone.OzoneConfigKeys;
-import org.apache.hadoop.ozone.OzoneConsts;
-import org.apache.hadoop.ozone.client.rest.response.*;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.TimeUnit;
-
-/** 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) {
- 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.setAcls(bucket.getAcls());
- 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;
- }
-
- public static RetryPolicy createRetryPolicy(Configuration conf) {
- int maxRetryCount =
- conf.getInt(OzoneConfigKeys.OZONE_CLIENT_MAX_RETRIES, OzoneConfigKeys.
- OZONE_CLIENT_MAX_RETRIES_DEFAULT);
- long retryInterval = conf.getTimeDuration(OzoneConfigKeys.
- OZONE_CLIENT_RETRY_INTERVAL, OzoneConfigKeys.
- OZONE_CLIENT_RETRY_INTERVAL_DEFAULT, TimeUnit.MILLISECONDS);
- RetryPolicy basePolicy = RetryPolicies
- .retryUpToMaximumCountWithFixedSleep(maxRetryCount, retryInterval,
- TimeUnit.MILLISECONDS);
- Map<Class<? extends Exception>, RetryPolicy> exceptionToPolicyMap =
- new HashMap<Class<? extends Exception>, RetryPolicy>();
- exceptionToPolicyMap.put(BlockNotCommittedException.class, basePolicy);
- RetryPolicy retryPolicy = RetryPolicies
- .retryByException(RetryPolicies.TRY_ONCE_THEN_FAIL,
- exceptionToPolicyMap);
- return retryPolicy;
- }
- /**
- * 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<KeyLocation> keyLocations = new ArrayList<>();
- key.getOzoneKeyLocations().forEach((a) -> keyLocations.add(new KeyLocation(
- a.getContainerID(), a.getLocalID(), a.getLength(), a.getOffset())));
- keyInfo.setKeyLocation(keyLocations);
- return keyInfo;
- }
-}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/2c392da8/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/OzoneKey.java
----------------------------------------------------------------------
diff --git a/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/OzoneKey.java b/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/OzoneKey.java
deleted file mode 100644
index 7c93146..0000000
--- a/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/OzoneKey.java
+++ /dev/null
@@ -1,119 +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;
-
-/**
- * A class that encapsulates OzoneKey.
- */
-public class OzoneKey {
-
- /**
- * Name of the Volume the Key belongs to.
- */
- private final String volumeName;
- /**
- * Name of the Bucket the Key belongs to.
- */
- private final String bucketName;
- /**
- * Name of the Key.
- */
- private final String name;
- /**
- * Size of the data.
- */
- private final long dataSize;
- /**
- * Creation time of the key.
- */
- private long creationTime;
- /**
- * Modification time of the key.
- */
- private long modificationTime;
-
- /**
- * Constructs OzoneKey from OmKeyInfo.
- *
- */
- public OzoneKey(String volumeName, String bucketName,
- String keyName, long size, long creationTime,
- long modificationTime) {
- this.volumeName = volumeName;
- this.bucketName = bucketName;
- this.name = keyName;
- this.dataSize = size;
- this.creationTime = creationTime;
- this.modificationTime = modificationTime;
- }
-
- /**
- * Returns Volume Name associated with the Key.
- *
- * @return volumeName
- */
- public String getVolumeName() {
- return volumeName;
- }
-
- /**
- * Returns Bucket Name associated with the Key.
- *
- * @return bucketName
- */
- public String getBucketName(){
- return bucketName;
- }
-
- /**
- * Returns the Key Name.
- *
- * @return keyName
- */
- public String getName() {
- return name;
- }
-
- /**
- * Returns the size of the data.
- *
- * @return dataSize
- */
- public long getDataSize() {
- return dataSize;
- }
-
- /**
- * Returns the creation time of the key.
- *
- * @return creation time
- */
- public long getCreationTime() {
- return creationTime;
- }
-
- /**
- * Returns the modification time of the key.
- *
- * @return modification time
- */
- public long getModificationTime() {
- return modificationTime;
- }
-}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/2c392da8/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/OzoneKeyDetails.java
----------------------------------------------------------------------
diff --git a/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/OzoneKeyDetails.java b/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/OzoneKeyDetails.java
deleted file mode 100644
index e7709dd..0000000
--- a/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/OzoneKeyDetails.java
+++ /dev/null
@@ -1,58 +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;
-
-import java.util.List;
-
-/**
- * A class that encapsulates OzoneKeyLocation.
- */
-public class OzoneKeyDetails extends OzoneKey {
-
- /**
- * A list of block location information to specify replica locations.
- */
- private List<OzoneKeyLocation> ozoneKeyLocations;
-
- /**
- * Constructs OzoneKeyDetails from OmKeyInfo.
- */
- public OzoneKeyDetails(String volumeName, String bucketName, String keyName,
- long size, long creationTime, long modificationTime,
- List<OzoneKeyLocation> ozoneKeyLocations) {
- super(volumeName, bucketName, keyName, size, creationTime,
- modificationTime);
- this.ozoneKeyLocations = ozoneKeyLocations;
- }
-
- /**
- * Returns the location detail information of the specific Key.
- */
- public List<OzoneKeyLocation> getOzoneKeyLocations() {
- return ozoneKeyLocations;
- }
-
- /**
- * Set details of key location.
- * @param ozoneKeyLocations - details of key location
- */
- public void setOzoneKeyLocations(List<OzoneKeyLocation> ozoneKeyLocations) {
- this.ozoneKeyLocations = ozoneKeyLocations;
- }
-}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/2c392da8/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/OzoneKeyLocation.java
----------------------------------------------------------------------
diff --git a/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/OzoneKeyLocation.java b/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/OzoneKeyLocation.java
deleted file mode 100644
index 0ff8ba7..0000000
--- a/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/OzoneKeyLocation.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.client;
-
-/**
- * One key can be stored in one or more containers as one or more blocks.
- * This class represents one such block instance.
- */
-public class OzoneKeyLocation {
- /**
- * 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 OzoneKeyLocation.
- */
- public OzoneKeyLocation(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/client/src/main/java/org/apache/hadoop/ozone/client/OzoneVolume.java
----------------------------------------------------------------------
diff --git a/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/OzoneVolume.java b/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/OzoneVolume.java
deleted file mode 100644
index e451b1a..0000000
--- a/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/OzoneVolume.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.client;
-
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.List;
-import java.util.NoSuchElementException;
-
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hdds.client.OzoneQuota;
-import org.apache.hadoop.hdds.scm.client.HddsClientUtils;
-import org.apache.hadoop.ozone.OzoneAcl;
-import org.apache.hadoop.ozone.client.protocol.ClientProtocol;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Preconditions;
-
-/**
- * A class that encapsulates OzoneVolume.
- */
-public class OzoneVolume {
-
- /**
- * The proxy used for connecting to the cluster and perform
- * client operations.
- */
- private final ClientProtocol proxy;
-
- /**
- * Name of the Volume.
- */
- private final String name;
-
- /**
- * Admin Name of the Volume.
- */
- private String admin;
- /**
- * Owner of the Volume.
- */
- private String owner;
- /**
- * Quota allocated for the Volume.
- */
- private long quotaInBytes;
- /**
- * Creation time of the volume.
- */
- private long creationTime;
- /**
- * Volume ACLs.
- */
- private List<OzoneAcl> acls;
-
- private int listCacheSize;
-
- /**
- * Constructs OzoneVolume instance.
- * @param conf Configuration object.
- * @param proxy ClientProtocol proxy.
- * @param name Name of the volume.
- * @param admin Volume admin.
- * @param owner Volume owner.
- * @param quotaInBytes Volume quota in bytes.
- * @param creationTime creation time of the volume
- * @param acls ACLs associated with the volume.
- */
- public OzoneVolume(Configuration conf, ClientProtocol proxy, String name,
- String admin, String owner, long quotaInBytes,
- long creationTime, List<OzoneAcl> acls) {
- Preconditions.checkNotNull(proxy, "Client proxy is not set.");
- this.proxy = proxy;
- this.name = name;
- this.admin = admin;
- this.owner = owner;
- this.quotaInBytes = quotaInBytes;
- this.creationTime = creationTime;
- this.acls = acls;
- this.listCacheSize = HddsClientUtils.getListCacheSize(conf);
- }
-
- @VisibleForTesting
- protected OzoneVolume(String name, String admin, String owner,
- long quotaInBytes,
- long creationTime, List<OzoneAcl> acls) {
- this.proxy = null;
- this.name = name;
- this.admin = admin;
- this.owner = owner;
- this.quotaInBytes = quotaInBytes;
- this.creationTime = creationTime;
- this.acls = acls;
- }
-
- /**
- * Returns Volume name.
- *
- * @return volumeName
- */
- public String getName() {
- return name;
- }
-
- /**
- * Returns Volume's admin name.
- *
- * @return adminName
- */
- public String getAdmin() {
- return admin;
- }
-
- /**
- * Returns Volume's owner name.
- *
- * @return ownerName
- */
- public String getOwner() {
- return owner;
- }
-
- /**
- * Returns Quota allocated for the Volume in bytes.
- *
- * @return quotaInBytes
- */
- public long getQuota() {
- return quotaInBytes;
- }
-
- /**
- * Returns creation time of the volume.
- *
- * @return creation time.
- */
- public long getCreationTime() {
- return creationTime;
- }
-
- /**
- * Returns OzoneAcl list associated with the Volume.
- *
- * @return aclMap
- */
- public List<OzoneAcl> getAcls() {
- return acls;
- }
-
- /**
- * Sets/Changes the owner of this Volume.
- * @param owner new owner
- * @throws IOException
- */
- public void setOwner(String owner) throws IOException {
- proxy.setVolumeOwner(name, owner);
- this.owner = owner;
- }
-
- /**
- * Sets/Changes the quota of this Volume.
- * @param quota new quota
- * @throws IOException
- */
- public void setQuota(OzoneQuota quota) throws IOException {
- proxy.setVolumeQuota(name, quota);
- this.quotaInBytes = quota.sizeInBytes();
- }
-
- /**
- * Creates a new Bucket in this Volume, with default values.
- * @param bucketName Name of the Bucket
- * @throws IOException
- */
- public void createBucket(String bucketName)
- throws IOException {
- proxy.createBucket(name, bucketName);
- }
-
- /**
- * Creates a new Bucket in this Volume, with properties set in bucketArgs.
- * @param bucketName Name of the Bucket
- * @param bucketArgs Properties to be set
- * @throws IOException
- */
- public void createBucket(String bucketName, BucketArgs bucketArgs)
- throws IOException {
- proxy.createBucket(name, bucketName, bucketArgs);
- }
-
- /**
- * Get the Bucket from this Volume.
- * @param bucketName Name of the Bucket
- * @return OzoneBucket
- * @throws IOException
- */
- public OzoneBucket getBucket(String bucketName) throws IOException {
- OzoneBucket bucket = proxy.getBucketDetails(name, bucketName);
- return bucket;
- }
-
- /**
- * Returns Iterator to iterate over all buckets in the volume.
- * The result can be restricted using bucket prefix, will return all
- * buckets if bucket prefix is null.
- *
- * @param bucketPrefix Bucket prefix to match
- * @return {@code Iterator<OzoneBucket>}
- */
- public Iterator<? extends OzoneBucket> listBuckets(String bucketPrefix) {
- return listBuckets(bucketPrefix, null);
- }
-
- /**
- * Returns Iterator to iterate over all buckets after prevBucket in the
- * volume.
- * If prevBucket is null it iterates from the first bucket in the volume.
- * The result can be restricted using bucket prefix, will return all
- * buckets if bucket prefix is null.
- *
- * @param bucketPrefix Bucket prefix to match
- * @param prevBucket Buckets are listed after this bucket
- * @return {@code Iterator<OzoneBucket>}
- */
- public Iterator<? extends OzoneBucket> listBuckets(String bucketPrefix,
- String prevBucket) {
- return new BucketIterator(bucketPrefix, prevBucket);
- }
-
- /**
- * Deletes the Bucket from this Volume.
- * @param bucketName Name of the Bucket
- * @throws IOException
- */
- public void deleteBucket(String bucketName) throws IOException {
- proxy.deleteBucket(name, bucketName);
- }
-
-
- /**
- * An Iterator to iterate over {@link OzoneBucket} list.
- */
- private class BucketIterator implements Iterator<OzoneBucket> {
-
- private String bucketPrefix = null;
-
- private Iterator<OzoneBucket> currentIterator;
- private OzoneBucket currentValue;
-
-
- /**
- * Creates an Iterator to iterate over all buckets after prevBucket in the volume.
- * If prevBucket is null it iterates from the first bucket in the volume.
- * The returned buckets match bucket prefix.
- * @param bucketPrefix
- */
- public BucketIterator(String bucketPrefix, String prevBucket) {
- this.bucketPrefix = bucketPrefix;
- this.currentValue = null;
- this.currentIterator = getNextListOfBuckets(prevBucket).iterator();
- }
-
- @Override
- public boolean hasNext() {
- if(!currentIterator.hasNext()) {
- currentIterator = getNextListOfBuckets(
- currentValue != null ? currentValue.getName() : null)
- .iterator();
- }
- return currentIterator.hasNext();
- }
-
- @Override
- public OzoneBucket next() {
- if(hasNext()) {
- currentValue = currentIterator.next();
- return currentValue;
- }
- throw new NoSuchElementException();
- }
-
- /**
- * Gets the next set of bucket list using proxy.
- * @param prevBucket
- * @return {@code List<OzoneVolume>}
- */
- private List<OzoneBucket> getNextListOfBuckets(String prevBucket) {
- try {
- return proxy.listBuckets(name, bucketPrefix, prevBucket, listCacheSize);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/hadoop/blob/2c392da8/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/VolumeArgs.java
----------------------------------------------------------------------
diff --git a/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/VolumeArgs.java b/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/VolumeArgs.java
deleted file mode 100644
index ae1cfcc..0000000
--- a/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/VolumeArgs.java
+++ /dev/null
@@ -1,128 +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;
-
-import org.apache.hadoop.ozone.OzoneAcl;
-
-import java.io.IOException;
-import java.util.List;
-
-/**
- * This class encapsulates the arguments that are
- * required for creating a volume.
- */
-public final class VolumeArgs {
-
- private final String admin;
- private final String owner;
- private final String quota;
- private final List<OzoneAcl> acls;
-
- /**
- * Private constructor, constructed via builder.
- * @param admin Administrator's name.
- * @param owner Volume owner's name
- * @param quota Volume Quota.
- * @param acls User to access rights map.
- */
- private VolumeArgs(String admin, String owner,
- String quota, List<OzoneAcl> acls) {
- this.admin = admin;
- this.owner = owner;
- this.quota = quota;
- this.acls = acls;
- }
-
- /**
- * Returns the Admin Name.
- * @return String.
- */
- public String getAdmin() {
- return admin;
- }
-
- /**
- * Returns the owner Name.
- * @return String
- */
- public String getOwner() {
- return owner;
- }
-
- /**
- * Returns Volume Quota.
- * @return Quota.
- */
- public String getQuota() {
- return quota;
- }
-
- public List<OzoneAcl> getAcls() {
- return acls;
- }
- /**
- * Returns new builder class that builds a OmVolumeArgs.
- *
- * @return Builder
- */
- public static VolumeArgs.Builder newBuilder() {
- return new VolumeArgs.Builder();
- }
-
- /**
- * Builder for OmVolumeArgs.
- */
- public static class Builder {
- private String adminName;
- private String ownerName;
- private String volumeQuota;
- private List<OzoneAcl> listOfAcls;
-
-
- public VolumeArgs.Builder setAdmin(String admin) {
- this.adminName = admin;
- return this;
- }
-
- public VolumeArgs.Builder setOwner(String owner) {
- this.ownerName = owner;
- return this;
- }
-
- public VolumeArgs.Builder setQuota(String quota) {
- this.volumeQuota = quota;
- return this;
- }
-
- public VolumeArgs.Builder setAcls(List<OzoneAcl> acls)
- throws IOException {
- this.listOfAcls = acls;
- return this;
- }
-
- /**
- * Constructs a CreateVolumeArgument.
- * @return CreateVolumeArgs.
- */
- public VolumeArgs build() {
- return new VolumeArgs(adminName, ownerName, volumeQuota, listOfAcls);
- }
- }
-
-}
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org