Skip to content

Commit

Permalink
HDDS-64. OzoneClientException should extend IOException. (apache#7403)
Browse files Browse the repository at this point in the history
  • Loading branch information
nandakumar131 authored Nov 12, 2024
1 parent 27fcd0c commit 47c2409
Show file tree
Hide file tree
Showing 31 changed files with 47 additions and 77 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@
*/
package org.apache.hadoop.ozone.client;

import java.io.IOException;

/**
* This exception is thrown by the Ozone Clients.
*/
public class OzoneClientException extends Exception {
public class OzoneClientException extends IOException {
public OzoneClientException() {
}

Expand All @@ -36,8 +38,4 @@ public OzoneClientException(Throwable throwable) {
super(throwable);
}

public OzoneClientException(String s, Throwable throwable, boolean b,
boolean b1) {
super(s, throwable, b, b1);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public void testDeleteVolume()

@Test
public void testCreateVolumeWithMetadata()
throws IOException, OzoneClientException {
throws IOException {
String volumeName = UUID.randomUUID().toString();
VolumeArgs volumeArgs = VolumeArgs.newBuilder()
.addMetadata("key1", "val1")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ Test Timeout 5 minutes
*** Test Cases ***

Check om admin command
${result} = Execute and checkrc ozone admin om roles -id=omServiceIdDefault 0
${result} = Execute and ignore error ozone admin om roles -id=omServiceIdDefault
Should Contain ${result} This command works only on OzoneManager HA cluster.
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@
import org.apache.hadoop.ozone.client.ObjectStore;
import org.apache.hadoop.ozone.client.OzoneBucket;
import org.apache.hadoop.ozone.client.OzoneClient;
import org.apache.hadoop.ozone.client.OzoneClientException;
import org.apache.hadoop.ozone.client.OzoneClientFactory;
import org.apache.hadoop.ozone.client.OzoneKey;
import org.apache.hadoop.ozone.client.OzoneKeyDetails;
Expand Down Expand Up @@ -624,7 +623,7 @@ public void testDeleteVolume()

@Test
public void testCreateVolumeWithMetadata()
throws IOException, OzoneClientException {
throws IOException {
String volumeName = UUID.randomUUID().toString();
VolumeArgs volumeArgs = VolumeArgs.newBuilder()
.addMetadata("key1", "val1")
Expand All @@ -639,7 +638,7 @@ public void testCreateVolumeWithMetadata()

@Test
public void testCreateBucketWithMetadata()
throws IOException, OzoneClientException {
throws IOException {
String volumeName = UUID.randomUUID().toString();
String bucketName = UUID.randomUUID().toString();
store.createVolume(volumeName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.apache.hadoop.hdds.cli.HddsVersionProvider;
import org.apache.hadoop.hdds.protocol.proto.HddsProtos;
import org.apache.hadoop.hdds.server.JsonUtils;
import org.apache.hadoop.ozone.client.OzoneClientException;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRoleInfo;
import org.apache.hadoop.ozone.om.protocol.OzoneManagerProtocol;
import org.apache.hadoop.ozone.om.helpers.ServiceInfo;
Expand Down Expand Up @@ -94,8 +93,6 @@ public Void call() throws Exception {
} else {
printOmServerRoles(ozoneManagerClient.getServiceList());
}
} catch (OzoneClientException ex) {
System.out.printf("Error: %s", ex.getMessage());
} finally {
if (ozoneManagerClient != null) {
ozoneManagerClient.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

import org.apache.commons.lang3.StringUtils;
import org.apache.hadoop.hdds.cli.HddsVersionProvider;
import org.apache.hadoop.ozone.client.OzoneClientException;
import org.apache.hadoop.ozone.om.protocol.OzoneManagerProtocol;
import picocli.CommandLine;

Expand Down Expand Up @@ -86,9 +85,6 @@ public Void call() throws Exception {
System.err.println("Operation completed with errors. "
+ "Check OM log for details");
}

} catch (OzoneClientException ex) {
System.err.printf("Error: %s", ex.getMessage());
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
import org.apache.hadoop.hdds.server.JsonUtils;
import org.apache.hadoop.ozone.OzoneConsts;
import org.apache.hadoop.ozone.client.OzoneClient;
import org.apache.hadoop.ozone.client.OzoneClientException;
import org.apache.hadoop.ozone.container.common.impl.ContainerLayoutVersion;
import org.apache.hadoop.ozone.om.helpers.OmKeyArgs;
import org.apache.hadoop.ozone.om.helpers.OmKeyInfo;
Expand Down Expand Up @@ -74,7 +73,7 @@ private String getChunkLocationPath(String containerLocation) {

@Override
protected void execute(OzoneClient client, OzoneAddress address)
throws IOException, OzoneClientException {
throws IOException {
try (ContainerOperationClient containerOperationClient = new ContainerOperationClient(parent.getOzoneConf());
XceiverClientManager xceiverClientManager = containerOperationClient.getXceiverClientManager()) {
OzoneManagerProtocol ozoneManagerClient = client.getObjectStore().getClientProxy().getOzoneManagerClient();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

import org.apache.hadoop.hdds.cli.SubcommandWithParent;
import org.apache.hadoop.ozone.client.OzoneClient;
import org.apache.hadoop.ozone.client.OzoneClientException;
import org.apache.hadoop.ozone.shell.Handler;
import org.apache.hadoop.ozone.shell.OzoneAddress;
import org.kohsuke.MetaInfServices;
Expand Down Expand Up @@ -63,7 +62,7 @@ public Class<?> getParentType() {

@Override
protected void execute(OzoneClient client, OzoneAddress address)
throws IOException, OzoneClientException {
throws IOException {
String message = client.getObjectStore()
.printCompactionLogDag(fileNamePrefix, graphType);
System.out.println(message);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import org.apache.hadoop.hdds.server.JsonUtils;
import org.apache.hadoop.hdds.utils.IOUtils;
import org.apache.hadoop.ozone.client.OzoneClient;
import org.apache.hadoop.ozone.client.OzoneClientException;
import org.apache.hadoop.ozone.client.OzoneKeyDetails;
import org.apache.hadoop.ozone.client.io.OzoneInputStream;
import org.apache.hadoop.ozone.client.protocol.ClientProtocol;
Expand Down Expand Up @@ -90,7 +89,7 @@ public Class<?> getParentType() {

@Override
protected void execute(OzoneClient client, OzoneAddress address)
throws IOException, OzoneClientException {
throws IOException {

address.ensureKeyAddress();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ protected OzoneAddress getAddress() throws OzoneClientException {
}

protected abstract void execute(OzoneClient client, OzoneAddress address)
throws IOException, OzoneClientException;
throws IOException;

/**
* Checks whether the current command should be executed or not.
Expand Down Expand Up @@ -102,7 +102,7 @@ public Void call() throws Exception {
}

protected OzoneClient createClient(OzoneAddress address)
throws IOException, OzoneClientException {
throws IOException {
return address.createClient(conf);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ protected OzoneClient createRpcClientFromServiceId(
}

public OzoneClient createClient(MutableConfigurationSource conf)
throws IOException, OzoneClientException {
throws IOException {
OzoneClient client;
String scheme = ozoneURI.getScheme();
if (ozoneURI.getScheme() == null || scheme.isEmpty()) {
Expand Down Expand Up @@ -185,13 +185,12 @@ public OzoneClient createClient(MutableConfigurationSource conf)
* @param omServiceID
* @return OzoneClient
* @throws IOException
* @throws OzoneClientException
*/
public OzoneClient createClientForS3Commands(
OzoneConfiguration conf,
String omServiceID
)
throws IOException, OzoneClientException {
throws IOException {
Collection<String> serviceIds = conf.
getTrimmedStringCollection(OZONE_OM_SERVICE_IDS_KEY);
if (omServiceID != null) {
Expand Down Expand Up @@ -227,8 +226,7 @@ public OzoneClient createClientForS3Commands(
* @param uri - UriString
* @return URI
*/
protected URI parseURI(String uri)
throws OzoneClientException {
protected URI parseURI(String uri) throws OzoneClientException {
if ((uri == null) || uri.isEmpty()) {
throw new OzoneClientException(
"Ozone URI is needed to execute this command.");
Expand Down Expand Up @@ -422,7 +420,7 @@ public void ensureVolumeAddress() throws OzoneClientException {
}
}

public void ensureRootAddress() throws OzoneClientException {
public void ensureRootAddress() throws OzoneClientException {
if (keyName.length() != 0 || bucketName.length() != 0
|| volumeName.length() != 0) {
throw new OzoneClientException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import org.apache.hadoop.ozone.client.OzoneBucket;
import org.apache.hadoop.ozone.client.OzoneClient;
import org.apache.hadoop.ozone.client.OzoneClientException;
import org.apache.hadoop.ozone.shell.OzoneAddress;
import picocli.CommandLine;

Expand Down Expand Up @@ -70,7 +69,7 @@ public class SetEncryptionKey extends BucketHandler {

@Override
protected void execute(OzoneClient client, OzoneAddress address)
throws IOException, OzoneClientException {
throws IOException {

String volumeName = address.getVolumeName();
String bucketName = address.getBucketName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import org.apache.hadoop.ozone.OzoneIllegalArgumentException;
import org.apache.hadoop.ozone.client.OzoneBucket;
import org.apache.hadoop.ozone.client.OzoneClient;
import org.apache.hadoop.ozone.client.OzoneClientException;
import org.apache.hadoop.ozone.shell.OzoneAddress;
import org.apache.hadoop.ozone.shell.ShellReplicationOptions;
import picocli.CommandLine;
Expand All @@ -40,7 +39,7 @@ public class SetReplicationConfigHandler extends BucketHandler {

@Override
protected void execute(OzoneClient client, OzoneAddress address)
throws IOException, OzoneClientException {
throws IOException {
ReplicationConfig replicationConfig = replication.fromParams(getConf())
.orElseThrow(() -> new OzoneIllegalArgumentException(
"Replication type and config must be specified."));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import org.apache.hadoop.ozone.client.OzoneBucket;
import org.apache.hadoop.ozone.client.OzoneClient;
import org.apache.hadoop.ozone.client.OzoneClientException;
import org.apache.hadoop.ozone.shell.OzoneAddress;

import picocli.CommandLine.Command;
Expand All @@ -40,7 +39,7 @@ public class UpdateBucketHandler extends BucketHandler {

@Override
protected void execute(OzoneClient client, OzoneAddress address)
throws IOException, OzoneClientException {
throws IOException {

String volumeName = address.getVolumeName();
String bucketName = address.getBucketName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import org.apache.hadoop.io.IOUtils;
import org.apache.hadoop.ozone.client.OzoneBucket;
import org.apache.hadoop.ozone.client.OzoneClient;
import org.apache.hadoop.ozone.client.OzoneClientException;
import org.apache.hadoop.ozone.client.OzoneVolume;
import org.apache.hadoop.ozone.shell.OzoneAddress;
import picocli.CommandLine.Command;
Expand All @@ -38,7 +37,7 @@ public class CatKeyHandler extends KeyHandler {

@Override
protected void execute(OzoneClient client, OzoneAddress address)
throws IOException, OzoneClientException {
throws IOException {

String volumeName = address.getVolumeName();
String bucketName = address.getBucketName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.apache.hadoop.hdds.scm.OzoneClientConfig;
import org.apache.hadoop.ozone.client.OzoneBucket;
import org.apache.hadoop.ozone.client.OzoneClient;
import org.apache.hadoop.ozone.client.OzoneClientException;
import org.apache.hadoop.ozone.client.OzoneKeyDetails;
import org.apache.hadoop.ozone.client.OzoneVolume;
import org.apache.hadoop.ozone.client.protocol.ClientProtocol;
Expand All @@ -49,7 +48,7 @@ public class ChecksumKeyHandler extends KeyHandler {

@Override
protected void execute(OzoneClient client, OzoneAddress address)
throws IOException, OzoneClientException {
throws IOException {

ChecksumInfo checksumInfo = new ChecksumInfo(address, client, mode);
printObjectAsJson(checksumInfo);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import org.apache.hadoop.ozone.OzoneConsts;
import org.apache.hadoop.ozone.client.OzoneBucket;
import org.apache.hadoop.ozone.client.OzoneClient;
import org.apache.hadoop.ozone.client.OzoneClientException;
import org.apache.hadoop.ozone.client.OzoneKeyDetails;
import org.apache.hadoop.ozone.client.OzoneVolume;
import org.apache.hadoop.ozone.shell.OzoneAddress;
Expand Down Expand Up @@ -64,7 +63,7 @@ public class CopyKeyHandler extends BucketHandler {

@Override
protected void execute(OzoneClient client, OzoneAddress address)
throws IOException, OzoneClientException {
throws IOException {

String volumeName = address.getVolumeName();
String bucketName = address.getBucketName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.apache.hadoop.ozone.OmUtils;
import org.apache.hadoop.ozone.client.OzoneBucket;
import org.apache.hadoop.ozone.client.OzoneClient;
import org.apache.hadoop.ozone.client.OzoneClientException;
import org.apache.hadoop.ozone.client.OzoneKeyDetails;
import org.apache.hadoop.ozone.client.OzoneVolume;
import org.apache.hadoop.ozone.om.exceptions.OMException;
Expand Down Expand Up @@ -55,7 +54,7 @@ public class DeleteKeyHandler extends KeyHandler {

@Override
protected void execute(OzoneClient client, OzoneAddress address)
throws IOException, OzoneClientException {
throws IOException {

String volumeName = address.getVolumeName();
String bucketName = address.getBucketName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public class GetKeyHandler extends KeyHandler {

@Override
protected void execute(OzoneClient client, OzoneAddress address)
throws IOException, OzoneClientException {
throws IOException {

String volumeName = address.getVolumeName();
String bucketName = address.getBucketName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import com.google.common.base.Strings;
import org.apache.hadoop.ozone.client.OzoneBucket;
import org.apache.hadoop.ozone.client.OzoneClient;
import org.apache.hadoop.ozone.client.OzoneClientException;
import org.apache.hadoop.ozone.client.OzoneKey;
import org.apache.hadoop.ozone.client.OzoneVolume;
import org.apache.hadoop.ozone.shell.ListOptions;
Expand All @@ -47,7 +46,7 @@ public class ListKeyHandler extends VolumeBucketHandler {

@Override
protected void execute(OzoneClient client, OzoneAddress address)
throws IOException, OzoneClientException {
throws IOException {

if (!Strings.isNullOrEmpty(address.getBucketName())) {
listKeysInsideBucket(client, address);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import org.apache.hadoop.ozone.OzoneConsts;
import org.apache.hadoop.ozone.client.OzoneBucket;
import org.apache.hadoop.ozone.client.OzoneClient;
import org.apache.hadoop.ozone.client.OzoneClientException;
import org.apache.hadoop.ozone.client.OzoneVolume;
import org.apache.hadoop.ozone.client.io.OzoneDataStreamOutput;
import org.apache.hadoop.ozone.client.io.OzoneOutputStream;
Expand Down Expand Up @@ -75,7 +74,7 @@ public class PutKeyHandler extends KeyHandler {

@Override
protected void execute(OzoneClient client, OzoneAddress address)
throws IOException, OzoneClientException {
throws IOException {

String volumeName = address.getVolumeName();
String bucketName = address.getBucketName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import org.apache.hadoop.ozone.client.OzoneBucket;
import org.apache.hadoop.ozone.client.OzoneClient;
import org.apache.hadoop.ozone.client.OzoneClientException;
import org.apache.hadoop.ozone.client.OzoneVolume;
import org.apache.hadoop.ozone.shell.OzoneAddress;
import org.apache.hadoop.ozone.shell.bucket.BucketHandler;
Expand All @@ -46,7 +45,7 @@ public class RenameKeyHandler extends BucketHandler {

@Override
protected void execute(OzoneClient client, OzoneAddress address)
throws IOException, OzoneClientException {
throws IOException {

String volumeName = address.getVolumeName();
String bucketName = address.getBucketName();
Expand Down
Loading

0 comments on commit 47c2409

Please sign in to comment.