Skip to content

Commit

Permalink
HBASE-22844 Fixed Checkstyle violations in client snapshot exceptions
Browse files Browse the repository at this point in the history
Signed-off-by: stack <[email protected]>
  • Loading branch information
HorizonNet committed Aug 21, 2019
1 parent bb31ffa commit 24a821c
Show file tree
Hide file tree
Showing 10 changed files with 170 additions and 108 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.hadoop.hbase.snapshot;

import org.apache.hadoop.hbase.classification.InterfaceAudience;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.classification.InterfaceAudience;
import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription;
import org.apache.hadoop.hbase.util.Bytes;

Expand All @@ -29,18 +28,21 @@
* There is a corresponding class on the server side.
*/
@InterfaceAudience.Private
public class ClientSnapshotDescriptionUtils {
public final class ClientSnapshotDescriptionUtils {
private ClientSnapshotDescriptionUtils() {
}

/**
* Check to make sure that the description of the snapshot requested is valid
* @param snapshot description of the snapshot
* @throws IllegalArgumentException if the name of the snapshot or the name of the table to
* snapshot are not valid names.
* snapshot are not valid names
*/
public static void assertSnapshotRequestIsValid(SnapshotDescription snapshot)
throws IllegalArgumentException {
// make sure the snapshot name is valid
TableName.isLegalTableQualifierName(Bytes.toBytes(snapshot.getName()), true);
if(snapshot.hasTable()) {
if (snapshot.hasTable()) {
// make sure the table name is valid, this will implicitly check validity
TableName tableName = TableName.valueOf(snapshot.getTable());

Expand All @@ -51,24 +53,28 @@ public static void assertSnapshotRequestIsValid(SnapshotDescription snapshot)
}

/**
* Returns a single line (no \n) representation of snapshot metadata. Use this instead of
* {@link SnapshotDescription#toString()}. We don't replace SnapshotDescrpition's toString
* because it is auto-generated by protoc.
* @param ssd
* @return Single line string with a summary of the snapshot parameters
* Returns a single line (no \n) representation of snapshot metadata. Use this instead of
* {@link org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription#toString()}.
* We don't replace
* {@link org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription}'s
* {@code toString}, because it is auto-generated by protoc.
*
* @param snapshot description of the snapshot
* @return single line string with a summary of the snapshot parameters
*/
public static String toString(SnapshotDescription ssd) {
if (ssd == null) {
public static String toString(SnapshotDescription snapshot) {
if (snapshot == null) {
return null;
}

return new StringBuilder("{ ss=")
.append(ssd.getName())
.append(snapshot.getName())
.append(" table=")
.append(ssd.hasTable() ? TableName.valueOf(ssd.getTable()) : "")
.append(snapshot.hasTable() ? TableName.valueOf(snapshot.getTable()) : "")
.append(" type=")
.append(ssd.getType())
.append(snapshot.getType())
.append(" ttl=")
.append(ssd.getTtl())
.append(snapshot.getTtl())
.append(" }")
.toString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,36 +19,42 @@

import org.apache.hadoop.hbase.classification.InterfaceAudience;
import org.apache.hadoop.hbase.classification.InterfaceStability;

import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription;


/**
* Exception thrown when the found snapshot info from the filesystem is not valid
* Exception thrown when the found snapshot info from the filesystem is not valid.
*/
@SuppressWarnings("serial")
@InterfaceAudience.Public
@InterfaceStability.Evolving
public class CorruptedSnapshotException extends HBaseSnapshotException {

/**
* Snapshot was corrupt for some reason.
*
* @param message message describing the exception
* @param e cause
* @param e the actual cause of the exception
*/
public CorruptedSnapshotException(String message, Exception e) {
super(message, e);
}

/**
* Snapshot was corrupt for some reason
* Snapshot was corrupt for some reason.
*
* @param message full description of the failure
* @param snapshot snapshot that was expected
* @param snapshotDescription snapshot that was expected
* @deprecated since 1.3.0, will be removed in 3.0.0
*/
@Deprecated
public CorruptedSnapshotException(String message, SnapshotDescription snapshot) {
super(message, snapshot);
public CorruptedSnapshotException(String message, SnapshotDescription snapshotDescription) {
super(message, snapshotDescription);
}

/**
* Snapshot was corrupt for some reason.
*
* @param message message describing the exception
*/
public CorruptedSnapshotException(String message) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,16 @@
@InterfaceStability.Stable
@SuppressWarnings("serial")
public class ExportSnapshotException extends HBaseSnapshotException {

/**
* @param msg message describing the exception
* @param message message describing the exception
*/
public ExportSnapshotException(String msg) {
super(msg);
public ExportSnapshotException(String message) {
super(message);
}

/**
* @param message message describing the exception
* @param e cause
* @param e the actual cause of the exception
*/
public ExportSnapshotException(String message, Exception e) {
super(message, e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,62 +17,73 @@
*/
package org.apache.hadoop.hbase.snapshot;

import org.apache.hadoop.hbase.DoNotRetryIOException;
import org.apache.hadoop.hbase.classification.InterfaceAudience;
import org.apache.hadoop.hbase.classification.InterfaceStability;
import org.apache.hadoop.hbase.DoNotRetryIOException;

import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription;

/**
* General exception base class for when a snapshot fails
* General exception base class for when a snapshot fails.
*/
@SuppressWarnings("serial")
@InterfaceAudience.Public
@InterfaceStability.Evolving
public class HBaseSnapshotException extends DoNotRetryIOException {

private SnapshotDescription description;

/**
* Some exception happened for a snapshot and don't even know the snapshot that it was about
* @param msg Full description of the failure
* Some exception happened for a snapshot and don't even know the snapshot that it was about.
*
* @param message the full description of the failure
*/
public HBaseSnapshotException(String msg) {
super(msg);
public HBaseSnapshotException(String message) {
super(message);
}

/**
* Exception for the given snapshot that has no previous root cause
* @param msg reason why the snapshot failed
* @param desc description of the snapshot that is being failed
* Exception for the given snapshot that has no previous root cause.
*
* @param message the reason why the snapshot failed
* @param snapshotDescription the description of the snapshot that is failing
* @deprecated since 1.3.0, will be removed in 3.0.0
*/
@Deprecated
public HBaseSnapshotException(String msg, SnapshotDescription desc) {
super(msg);
this.description = desc;
public HBaseSnapshotException(String message, SnapshotDescription snapshotDescription) {
super(message);
this.description = snapshotDescription;
}

/**
* Exception for the given snapshot due to another exception
* @param msg reason why the snapshot failed
* @param cause root cause of the failure
* @param desc description of the snapshot that is being failed
* Exception for the given snapshot due to another exception.
*
* @param message the reason why the snapshot failed
* @param cause the root cause of the failure
* @param snapshotDescription the description of the snapshot that is being failed
* @deprecated since 1.3.0, will be removed in 3.0.0
*/
@Deprecated
public HBaseSnapshotException(String msg, Throwable cause, SnapshotDescription desc) {
super(msg, cause);
this.description = desc;
public HBaseSnapshotException(String message, Throwable cause,
SnapshotDescription snapshotDescription) {
super(message, cause);
this.description = snapshotDescription;
}

/**
* Exception when the description of the snapshot cannot be determined, due to some root other
* root cause
* root cause.
*
* @param message description of what caused the failure
* @param e root cause
* @param e the root cause
*/
public HBaseSnapshotException(String message, Exception e) {
super(message, e);
}

/**
* @return the description of the snapshot that is being failed
* @deprecated since 1.3.0, will be removed in 3.0.0
*/
@Deprecated
public SnapshotDescription getSnapshotDescription() {
return this.description;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.hadoop.hbase.snapshot;

import org.apache.hadoop.hbase.classification.InterfaceAudience;
import org.apache.hadoop.hbase.classification.InterfaceStability;

import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription;

/**
Expand All @@ -29,20 +29,39 @@
@InterfaceAudience.Public
@InterfaceStability.Evolving
public class RestoreSnapshotException extends HBaseSnapshotException {
/**
* @param message reason why restoring the snapshot fails
* @param snapshotDescription description of the snapshot attempted
* @deprecated since 1.3.0, will be removed in 3.0.0
*/
@Deprecated
public RestoreSnapshotException(String msg, SnapshotDescription desc) {
super(msg, desc);
public RestoreSnapshotException(String message, SnapshotDescription snapshotDescription) {
super(message, snapshotDescription);
}

/**
* @param message reason why restoring the snapshot fails
* @param cause the root cause of the failure
* @param snapshotDescription description of the snapshot attempted
* @deprecated since 1.3.0, will be removed in 3.0.0
*/
@Deprecated
public RestoreSnapshotException(String msg, Throwable cause, SnapshotDescription desc) {
super(msg, cause, desc);
public RestoreSnapshotException(String message, Throwable cause,
SnapshotDescription snapshotDescription) {
super(message, cause, snapshotDescription);
}

public RestoreSnapshotException(String msg) {
super(msg);
/**
* @param message reason why restoring the snapshot fails
*/
public RestoreSnapshotException(String message) {
super(message);
}

/**
* @param message reason why restoring the snapshot fails
* @param e the root cause of the failure
*/
public RestoreSnapshotException(String message, Exception e) {
super(message, e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import org.apache.hadoop.hbase.classification.InterfaceAudience;
import org.apache.hadoop.hbase.classification.InterfaceStability;

import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription;

/**
Expand All @@ -29,32 +30,36 @@
@InterfaceAudience.Public
@InterfaceStability.Evolving
public class SnapshotCreationException extends HBaseSnapshotException {

/**
* Used internally by the RPC engine to pass the exception back to the client.
* @param msg error message to pass back
*
* @param message error message to pass back
*/
public SnapshotCreationException(String msg) {
super(msg);
public SnapshotCreationException(String message) {
super(message);
}

/**
* Failure to create the specified snapshot
* @param msg reason why the snapshot couldn't be completed
* @param desc description of the snapshot attempted
* Failure to create the specified snapshot.
*
* @param message reason why the snapshot couldn't be completed
* @param snapshotDescription description of the snapshot attempted
*/
public SnapshotCreationException(String msg, SnapshotDescription desc) {
super(msg, desc);
public SnapshotCreationException(String message, SnapshotDescription snapshotDescription) {
super(message, snapshotDescription);
}

/**
* Failure to create the specified snapshot due to an external cause
* @param msg reason why the snapshot couldn't be completed
* @param cause root cause of the failure
* @param desc description of the snapshot attempted
* Failure to create the specified snapshot due to an external cause.
*
* @param message reason why the snapshot couldn't be completed
* @param cause the root cause of the failure
* @param snapshotDescription description of the snapshot attempted
* @deprecated since 1.3.0, will be removed in 3.0.0
*/
@Deprecated
public SnapshotCreationException(String msg, Throwable cause, SnapshotDescription desc) {
super(msg, cause, desc);
public SnapshotCreationException(String message, Throwable cause,
SnapshotDescription snapshotDescription) {
super(message, cause, snapshotDescription);
}
}
Loading

0 comments on commit 24a821c

Please sign in to comment.