Skip to content

Commit 6bc78d3

Browse files
committed
HBASE-22844 Fixed Checkstyle violations in client snapshot exceptions
Signed-off-by: stack <stack@apache.org>
1 parent 9d178cf commit 6bc78d3

10 files changed

+163
-116
lines changed

hbase-client/src/main/java/org/apache/hadoop/hbase/snapshot/ClientSnapshotDescriptionUtils.java

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,31 +16,34 @@
1616
* See the License for the specific language governing permissions and
1717
* limitations under the License.
1818
*/
19-
2019
package org.apache.hadoop.hbase.snapshot;
2120

2221
import org.apache.hadoop.hbase.TableName;
22+
import org.apache.hadoop.hbase.util.Bytes;
2323
import org.apache.yetus.audience.InterfaceAudience;
24+
2425
import org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos;
25-
import org.apache.hadoop.hbase.util.Bytes;
2626

2727
/**
2828
* Class to help with dealing with a snapshot description on the client side.
2929
* There is a corresponding class on the server side.
3030
*/
3131
@InterfaceAudience.Private
32-
public class ClientSnapshotDescriptionUtils {
32+
public final class ClientSnapshotDescriptionUtils {
33+
private ClientSnapshotDescriptionUtils() {
34+
}
35+
3336
/**
3437
* Check to make sure that the description of the snapshot requested is valid
3538
* @param snapshot description of the snapshot
3639
* @throws IllegalArgumentException if the name of the snapshot or the name of the table to
37-
* snapshot are not valid names.
40+
* snapshot are not valid names
3841
*/
3942
public static void assertSnapshotRequestIsValid(SnapshotProtos.SnapshotDescription snapshot)
4043
throws IllegalArgumentException {
4144
// make sure the snapshot name is valid
4245
TableName.isLegalTableQualifierName(Bytes.toBytes(snapshot.getName()), true);
43-
if(snapshot.hasTable()) {
46+
if (snapshot.hasTable()) {
4447
// make sure the table name is valid, this will implicitly check validity
4548
TableName tableName = TableName.valueOf(snapshot.getTable());
4649

@@ -51,24 +54,28 @@ public static void assertSnapshotRequestIsValid(SnapshotProtos.SnapshotDescripti
5154
}
5255

5356
/**
54-
* Returns a single line (no \n) representation of snapshot metadata. Use this instead of
55-
* {@link org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription#toString()}. We don't replace SnapshotDescrpition's toString
56-
* because it is auto-generated by protoc.
57-
* @param ssd
58-
* @return Single line string with a summary of the snapshot parameters
57+
* Returns a single line (no \n) representation of snapshot metadata. Use this instead of
58+
* {@link org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription#toString()}.
59+
* We don't replace
60+
* {@link org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription}'s
61+
* {@code toString}, because it is auto-generated by protoc.
62+
*
63+
* @param snapshot description of the snapshot
64+
* @return single line string with a summary of the snapshot parameters
5965
*/
60-
public static String toString(SnapshotProtos.SnapshotDescription ssd) {
61-
if (ssd == null) {
66+
public static String toString(SnapshotProtos.SnapshotDescription snapshot) {
67+
if (snapshot == null) {
6268
return null;
6369
}
70+
6471
return new StringBuilder("{ ss=")
65-
.append(ssd.getName())
72+
.append(snapshot.getName())
6673
.append(" table=")
67-
.append(ssd.hasTable() ? TableName.valueOf(ssd.getTable()) : "")
74+
.append(snapshot.hasTable() ? TableName.valueOf(snapshot.getTable()) : "")
6875
.append(" type=")
69-
.append(ssd.getType())
76+
.append(snapshot.getType())
7077
.append(" ttl=")
71-
.append(ssd.getTtl())
78+
.append(snapshot.getTtl())
7279
.append(" }")
7380
.toString();
7481
}

hbase-client/src/main/java/org/apache/hadoop/hbase/snapshot/CorruptedSnapshotException.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,35 +17,38 @@
1717
*/
1818
package org.apache.hadoop.hbase.snapshot;
1919

20-
import org.apache.yetus.audience.InterfaceAudience;
2120
import org.apache.hadoop.hbase.client.SnapshotDescription;
22-
21+
import org.apache.yetus.audience.InterfaceAudience;
2322

2423
/**
25-
* Exception thrown when the found snapshot info from the filesystem is not valid
24+
* Exception thrown when the found snapshot info from the filesystem is not valid.
2625
*/
2726
@SuppressWarnings("serial")
2827
@InterfaceAudience.Public
2928
public class CorruptedSnapshotException extends HBaseSnapshotException {
30-
3129
/**
30+
* Snapshot was corrupt for some reason.
31+
*
3232
* @param message message describing the exception
33-
* @param e cause
33+
* @param e the actual cause of the exception
3434
*/
3535
public CorruptedSnapshotException(String message, Exception e) {
3636
super(message, e);
3737
}
3838

3939
/**
40-
* Snapshot was corrupt for some reason
40+
* Snapshot was corrupt for some reason.
41+
*
4142
* @param message full description of the failure
42-
* @param snapshot snapshot that was expected
43+
* @param snapshotDescription snapshot that was expected
4344
*/
44-
public CorruptedSnapshotException(String message, SnapshotDescription snapshot) {
45-
super(message, snapshot);
45+
public CorruptedSnapshotException(String message, SnapshotDescription snapshotDescription) {
46+
super(message, snapshotDescription);
4647
}
4748

4849
/**
50+
* Snapshot was corrupt for some reason.
51+
*
4952
* @param message message describing the exception
5053
*/
5154
public CorruptedSnapshotException(String message) {

hbase-client/src/main/java/org/apache/hadoop/hbase/snapshot/ExportSnapshotException.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,16 @@
2525
@InterfaceAudience.Public
2626
@SuppressWarnings("serial")
2727
public class ExportSnapshotException extends HBaseSnapshotException {
28-
2928
/**
30-
* @param msg message describing the exception
29+
* @param message message describing the exception
3130
*/
32-
public ExportSnapshotException(String msg) {
33-
super(msg);
31+
public ExportSnapshotException(String message) {
32+
super(message);
3433
}
3534

3635
/**
3736
* @param message message describing the exception
38-
* @param e cause
37+
* @param e the actual cause of the exception
3938
*/
4039
public ExportSnapshotException(String message, Exception e) {
4140
super(message, e);

hbase-client/src/main/java/org/apache/hadoop/hbase/snapshot/HBaseSnapshotException.java

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,57 +18,64 @@
1818
package org.apache.hadoop.hbase.snapshot;
1919

2020
import org.apache.hadoop.hbase.DoNotRetryIOException;
21-
import org.apache.yetus.audience.InterfaceAudience;
2221
import org.apache.hadoop.hbase.client.SnapshotDescription;
22+
import org.apache.yetus.audience.InterfaceAudience;
2323

2424
/**
25-
* General exception base class for when a snapshot fails
25+
* General exception base class for when a snapshot fails.
2626
*/
2727
@SuppressWarnings("serial")
2828
@InterfaceAudience.Public
2929
public class HBaseSnapshotException extends DoNotRetryIOException {
30-
3130
private SnapshotDescription description;
3231

3332
/**
34-
* Some exception happened for a snapshot and don't even know the snapshot that it was about
35-
* @param msg Full description of the failure
33+
* Some exception happened for a snapshot and don't even know the snapshot that it was about.
34+
*
35+
* @param message the full description of the failure
3636
*/
37-
public HBaseSnapshotException(String msg) {
38-
super(msg);
37+
public HBaseSnapshotException(String message) {
38+
super(message);
3939
}
4040

4141
/**
42-
* Exception for the given snapshot that has no previous root cause
43-
* @param msg reason why the snapshot failed
44-
* @param desc description of the snapshot that is being failed
42+
* Exception for the given snapshot that has no previous root cause.
43+
*
44+
* @param message the reason why the snapshot failed
45+
* @param snapshotDescription the description of the snapshot that is failing
4546
*/
46-
public HBaseSnapshotException(String msg, SnapshotDescription desc) {
47-
super(msg);
48-
this.description = desc;
47+
public HBaseSnapshotException(String message, SnapshotDescription snapshotDescription) {
48+
super(message);
49+
this.description = snapshotDescription;
4950
}
5051

5152
/**
52-
* Exception for the given snapshot due to another exception
53-
* @param msg reason why the snapshot failed
54-
* @param cause root cause of the failure
55-
* @param desc description of the snapshot that is being failed
53+
* Exception for the given snapshot due to another exception.
54+
*
55+
* @param message the reason why the snapshot failed
56+
* @param cause the root cause of the failure
57+
* @param snapshotDescription the description of the snapshot that is being failed
5658
*/
57-
public HBaseSnapshotException(String msg, Throwable cause, SnapshotDescription desc) {
58-
super(msg, cause);
59-
this.description = desc;
59+
public HBaseSnapshotException(String message, Throwable cause,
60+
SnapshotDescription snapshotDescription) {
61+
super(message, cause);
62+
this.description = snapshotDescription;
6063
}
6164

6265
/**
6366
* Exception when the description of the snapshot cannot be determined, due to some root other
64-
* root cause
67+
* root cause.
68+
*
6569
* @param message description of what caused the failure
66-
* @param e root cause
70+
* @param cause the root cause
6771
*/
68-
public HBaseSnapshotException(String message, Throwable e) {
69-
super(message, e);
72+
public HBaseSnapshotException(String message, Throwable cause) {
73+
super(message, cause);
7074
}
7175

76+
/**
77+
* @return the description of the snapshot that is being failed
78+
*/
7279
public SnapshotDescription getSnapshotDescription() {
7380
return this.description;
7481
}

hbase-client/src/main/java/org/apache/hadoop/hbase/snapshot/RestoreSnapshotException.java

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,31 +15,47 @@
1515
* See the License for the specific language governing permissions and
1616
* limitations under the License.
1717
*/
18-
1918
package org.apache.hadoop.hbase.snapshot;
2019

21-
import org.apache.yetus.audience.InterfaceAudience;
2220
import org.apache.hadoop.hbase.client.SnapshotDescription;
21+
import org.apache.yetus.audience.InterfaceAudience;
2322

2423
/**
2524
* Thrown when a snapshot could not be restored due to a server-side error when restoring it.
2625
*/
2726
@SuppressWarnings("serial")
2827
@InterfaceAudience.Public
2928
public class RestoreSnapshotException extends HBaseSnapshotException {
30-
public RestoreSnapshotException(String msg, SnapshotDescription desc) {
31-
super(msg, desc);
29+
/**
30+
* @param message reason why restoring the snapshot fails
31+
* @param snapshotDescription description of the snapshot attempted
32+
*/
33+
public RestoreSnapshotException(String message, SnapshotDescription snapshotDescription) {
34+
super(message, snapshotDescription);
3235
}
3336

34-
public RestoreSnapshotException(String msg, Throwable cause, SnapshotDescription desc) {
35-
super(msg, cause, desc);
37+
/**
38+
* @param message reason why restoring the snapshot fails
39+
* @param cause the root cause of the failure
40+
* @param snapshotDescription description of the snapshot attempted
41+
*/
42+
public RestoreSnapshotException(String message, Throwable cause,
43+
SnapshotDescription snapshotDescription) {
44+
super(message, cause, snapshotDescription);
3645
}
3746

38-
public RestoreSnapshotException(String msg) {
39-
super(msg);
47+
/**
48+
* @param message reason why restoring the snapshot fails
49+
*/
50+
public RestoreSnapshotException(String message) {
51+
super(message);
4052
}
4153

42-
public RestoreSnapshotException(String message, Throwable e) {
43-
super(message, e);
54+
/**
55+
* @param message reason why restoring the snapshot fails
56+
* @param cause the root cause of the failure
57+
*/
58+
public RestoreSnapshotException(String message, Throwable cause) {
59+
super(message, cause);
4460
}
4561
}

hbase-client/src/main/java/org/apache/hadoop/hbase/snapshot/SnapshotCreationException.java

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
*/
1818
package org.apache.hadoop.hbase.snapshot;
1919

20-
import org.apache.yetus.audience.InterfaceAudience;
2120
import org.apache.hadoop.hbase.client.SnapshotDescription;
21+
import org.apache.yetus.audience.InterfaceAudience;
2222

2323
/**
2424
* Thrown when a snapshot could not be created due to a server-side error when
@@ -27,31 +27,34 @@
2727
@SuppressWarnings("serial")
2828
@InterfaceAudience.Public
2929
public class SnapshotCreationException extends HBaseSnapshotException {
30-
3130
/**
3231
* Used internally by the RPC engine to pass the exception back to the client.
33-
* @param msg error message to pass back
32+
*
33+
* @param message error message to pass back
3434
*/
35-
public SnapshotCreationException(String msg) {
36-
super(msg);
35+
public SnapshotCreationException(String message) {
36+
super(message);
3737
}
3838

3939
/**
40-
* Failure to create the specified snapshot
41-
* @param msg reason why the snapshot couldn't be completed
42-
* @param desc description of the snapshot attempted
40+
* Failure to create the specified snapshot.
41+
*
42+
* @param message reason why the snapshot couldn't be completed
43+
* @param snapshotDescription description of the snapshot attempted
4344
*/
44-
public SnapshotCreationException(String msg, SnapshotDescription desc) {
45-
super(msg, desc);
45+
public SnapshotCreationException(String message, SnapshotDescription snapshotDescription) {
46+
super(message, snapshotDescription);
4647
}
4748

4849
/**
49-
* Failure to create the specified snapshot due to an external cause
50-
* @param msg reason why the snapshot couldn't be completed
51-
* @param cause root cause of the failure
52-
* @param desc description of the snapshot attempted
50+
* Failure to create the specified snapshot due to an external cause.
51+
*
52+
* @param message reason why the snapshot couldn't be completed
53+
* @param cause the root cause of the failure
54+
* @param snapshotDescription description of the snapshot attempted
5355
*/
54-
public SnapshotCreationException(String msg, Throwable cause, SnapshotDescription desc) {
55-
super(msg, cause, desc);
56+
public SnapshotCreationException(String message, Throwable cause,
57+
SnapshotDescription snapshotDescription) {
58+
super(message, cause, snapshotDescription);
5659
}
5760
}

hbase-client/src/main/java/org/apache/hadoop/hbase/snapshot/SnapshotDoesNotExistException.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,27 @@
1717
*/
1818
package org.apache.hadoop.hbase.snapshot;
1919

20-
import org.apache.yetus.audience.InterfaceAudience;
2120
import org.apache.hadoop.hbase.client.SnapshotDescription;
22-
21+
import org.apache.yetus.audience.InterfaceAudience;
2322

2423
/**
25-
* Thrown when the server is looking for a snapshot but can't find the snapshot on the filesystem
24+
* Thrown when the server is looking for a snapshot, but can't find the snapshot on the filesystem.
2625
*/
2726
@SuppressWarnings("serial")
2827
@InterfaceAudience.Public
2928
public class SnapshotDoesNotExistException extends HBaseSnapshotException {
3029
/**
31-
* @param msg full description of the failure
30+
* @param message the full description of the failure
3231
*/
33-
public SnapshotDoesNotExistException(String msg) {
34-
super(msg);
32+
public SnapshotDoesNotExistException(String message) {
33+
super(message);
3534
}
3635

3736
/**
38-
* @param desc expected snapshot to find
37+
* @param snapshotDescription expected snapshot to find
3938
*/
40-
public SnapshotDoesNotExistException(SnapshotDescription desc) {
41-
super("Snapshot '" + desc.getName() +"' doesn't exist on the filesystem", desc);
39+
public SnapshotDoesNotExistException(SnapshotDescription snapshotDescription) {
40+
super("Snapshot '" + snapshotDescription.getName() + "' doesn't exist on the filesystem",
41+
snapshotDescription);
4242
}
4343
}

0 commit comments

Comments
 (0)