Skip to content

Commit 65b8179

Browse files
committed
HBASE-22326 Fixed Checkstyle errors in hbase-examples
1 parent 21fe1d2 commit 65b8179

File tree

13 files changed

+87
-83
lines changed

13 files changed

+87
-83
lines changed

hbase-examples/pom.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,13 @@
6969
<groupId>net.revelc.code</groupId>
7070
<artifactId>warbucks-maven-plugin</artifactId>
7171
</plugin>
72+
<plugin>
73+
<groupId>org.apache.maven.plugins</groupId>
74+
<artifactId>maven-checkstyle-plugin</artifactId>
75+
<configuration>
76+
<failOnViolation>true</failOnViolation>
77+
</configuration>
78+
</plugin>
7279
</plugins>
7380
</build>
7481
<dependencies>

hbase-examples/src/main/java/org/apache/hadoop/hbase/client/example/RefreshHFilesClient.java

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

2221
import java.io.Closeable;
@@ -51,7 +50,7 @@ public class RefreshHFilesClient extends Configured implements Tool, Closeable {
5150
/**
5251
* Constructor with Conf object
5352
*
54-
* @param cfg
53+
* @param cfg the {@link Configuration} object to use
5554
*/
5655
public RefreshHFilesClient(Configuration cfg) {
5756
try {
@@ -75,26 +74,28 @@ public void refreshHFiles(final TableName tableName) throws Throwable {
7574
}
7675

7776
public void refreshHFiles(final Table table) throws Throwable {
78-
final RefreshHFilesProtos.RefreshHFilesRequest request = RefreshHFilesProtos.RefreshHFilesRequest
79-
.getDefaultInstance();
80-
table.coprocessorService(RefreshHFilesProtos.RefreshHFilesService.class, HConstants.EMPTY_START_ROW,
81-
HConstants.EMPTY_END_ROW,
82-
new Batch.Call<RefreshHFilesProtos.RefreshHFilesService,
83-
RefreshHFilesProtos.RefreshHFilesResponse>() {
84-
@Override
85-
public RefreshHFilesProtos.RefreshHFilesResponse call(
86-
RefreshHFilesProtos.RefreshHFilesService refreshHFilesService)
87-
throws IOException {
88-
ServerRpcController controller = new ServerRpcController();
89-
BlockingRpcCallback<RefreshHFilesProtos.RefreshHFilesResponse> rpcCallback =
90-
new BlockingRpcCallback<>();
91-
refreshHFilesService.refreshHFiles(controller, request, rpcCallback);
92-
if (controller.failedOnException()) {
93-
throw controller.getFailedOn();
94-
}
95-
return rpcCallback.get();
96-
}
97-
});
77+
final RefreshHFilesProtos.RefreshHFilesRequest request =
78+
RefreshHFilesProtos.RefreshHFilesRequest.getDefaultInstance();
79+
table.coprocessorService(RefreshHFilesProtos.RefreshHFilesService.class,
80+
HConstants.EMPTY_START_ROW, HConstants.EMPTY_END_ROW,
81+
new Batch.Call<RefreshHFilesProtos.RefreshHFilesService,
82+
RefreshHFilesProtos.RefreshHFilesResponse>() {
83+
@Override
84+
public RefreshHFilesProtos.RefreshHFilesResponse call(
85+
RefreshHFilesProtos.RefreshHFilesService refreshHFilesService)
86+
throws IOException {
87+
ServerRpcController controller = new ServerRpcController();
88+
BlockingRpcCallback<RefreshHFilesProtos.RefreshHFilesResponse> rpcCallback =
89+
new BlockingRpcCallback<>();
90+
refreshHFilesService.refreshHFiles(controller, request, rpcCallback);
91+
92+
if (controller.failedOnException()) {
93+
throw controller.getFailedOn();
94+
}
95+
96+
return rpcCallback.get();
97+
}
98+
});
9899
LOG.debug("Done refreshing HFiles");
99100
}
100101

hbase-examples/src/main/java/org/apache/hadoop/hbase/coprocessor/example/BulkDeleteEndpoint.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@
8787
* return rpcCallback.get();
8888
* }
8989
* };
90-
* Map&lt;byte[], BulkDeleteResponse&gt; result = ht.coprocessorService(BulkDeleteService.class, scan
91-
* .getStartRow(), scan.getStopRow(), callable);
90+
* Map&lt;byte[], BulkDeleteResponse&gt; result = ht.coprocessorService(BulkDeleteService.class,
91+
* scan.getStartRow(), scan.getStopRow(), callable);
9292
* for (BulkDeleteResponse response : result.values()) {
9393
* noOfDeletedRows += response.getRowsDeleted();
9494
* }
@@ -225,7 +225,8 @@ private Delete createDeleteMutation(List<Cell> deleteRow, DeleteType deleteType,
225225
int noOfVersionsToDelete = 0;
226226
if (timestamp == null) {
227227
for (Cell kv : deleteRow) {
228-
delete.addColumn(CellUtil.cloneFamily(kv), CellUtil.cloneQualifier(kv), kv.getTimestamp());
228+
delete.addColumn(CellUtil.cloneFamily(kv), CellUtil.cloneQualifier(kv),
229+
kv.getTimestamp());
229230
noOfVersionsToDelete++;
230231
}
231232
} else {

hbase-examples/src/main/java/org/apache/hadoop/hbase/coprocessor/example/ExampleMasterObserverWithMetrics.java

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

2120
import java.io.IOException;
@@ -94,7 +93,8 @@ public void postCreateTable(ObserverContext<MasterCoprocessorEnvironment> ctx,
9493
}
9594

9695
@Override
97-
public void preDisableTable(ObserverContext<MasterCoprocessorEnvironment> ctx, TableName tableName) throws IOException {
96+
public void preDisableTable(ObserverContext<MasterCoprocessorEnvironment> ctx,
97+
TableName tableName) throws IOException {
9898
// Increment the Counter for disable table operations
9999
this.disableTableCounter.increment();
100100
}

hbase-examples/src/main/java/org/apache/hadoop/hbase/coprocessor/example/RefreshHFilesEndpoint.java

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

2120
import com.google.protobuf.RpcCallback;
@@ -57,8 +56,9 @@ public Iterable<Service> getServices() {
5756
}
5857

5958
@Override
60-
public void refreshHFiles(RpcController controller, RefreshHFilesProtos.RefreshHFilesRequest request,
61-
RpcCallback<RefreshHFilesProtos.RefreshHFilesResponse> done) {
59+
public void refreshHFiles(RpcController controller,
60+
RefreshHFilesProtos.RefreshHFilesRequest request,
61+
RpcCallback<RefreshHFilesProtos.RefreshHFilesResponse> done) {
6262
try {
6363
for (Store store : env.getRegion().getStores()) {
6464
LOG.debug("Refreshing HFiles for region: " + store.getRegionInfo().getRegionNameAsString() +

hbase-examples/src/main/java/org/apache/hadoop/hbase/mapreduce/IndexBuilder.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@
5252
* Modify ${HADOOP_HOME}/conf/hadoop-env.sh to include the hbase jar, the
5353
* zookeeper jar (can be found in lib/ directory under HBase root, the examples output directory,
5454
* and the hbase conf directory in HADOOP_CLASSPATH, and then run
55-
* <tt><strong>bin/hadoop org.apache.hadoop.hbase.mapreduce.IndexBuilder TABLE_NAME COLUMN_FAMILY ATTR [ATTR ...]</strong></tt>
55+
* <tt><strong>bin/hadoop org.apache.hadoop.hbase.mapreduce.IndexBuilder
56+
* TABLE_NAME COLUMN_FAMILY ATTR [ATTR ...]</strong></tt>
5657
* </p>
5758
*
5859
* <p>
@@ -117,8 +118,7 @@ protected void setup(Context context) throws IOException,
117118
/**
118119
* Job configuration.
119120
*/
120-
public static Job configureJob(Configuration conf, String [] args)
121-
throws IOException {
121+
public static Job configureJob(Configuration conf, String [] args) throws IOException {
122122
String tableName = args[0];
123123
String columnFamily = args[1];
124124
System.out.println("****" + tableName);

hbase-examples/src/main/java/org/apache/hadoop/hbase/mapreduce/SampleUploader.java

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,12 @@ public class SampleUploader extends Configured implements Tool {
6666

6767
private static final String NAME = "SampleUploader";
6868

69-
static class Uploader
70-
extends Mapper<LongWritable, Text, ImmutableBytesWritable, Put> {
71-
69+
static class Uploader extends Mapper<LongWritable, Text, ImmutableBytesWritable, Put> {
7270
private long checkpoint = 100;
7371
private long count = 0;
7472

7573
@Override
76-
public void map(LongWritable key, Text line, Context context)
77-
throws IOException {
78-
74+
public void map(LongWritable key, Text line, Context context) throws IOException {
7975
// Input is a CSV file
8076
// Each map() is a single line, where the key is the line number
8177
// Each line is comma-delimited; row,family,qualifier,value
@@ -117,8 +113,7 @@ public void map(LongWritable key, Text line, Context context)
117113
/**
118114
* Job configuration.
119115
*/
120-
public static Job configureJob(Configuration conf, String [] args)
121-
throws IOException {
116+
public static Job configureJob(Configuration conf, String [] args) throws IOException {
122117
Path inputPath = new Path(args[0]);
123118
String tableName = args[1];
124119
Job job = new Job(conf, NAME + "_" + tableName);

hbase-examples/src/main/java/org/apache/hadoop/hbase/thrift/DemoClient.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -192,11 +192,11 @@ private void run() throws Exception {
192192

193193
// Test UTF-8 handling
194194
byte[] invalid = {(byte) 'f', (byte) 'o', (byte) 'o', (byte) '-',
195-
(byte) 0xfc, (byte) 0xa1, (byte) 0xa1, (byte) 0xa1, (byte) 0xa1};
195+
(byte) 0xfc, (byte) 0xa1, (byte) 0xa1, (byte) 0xa1, (byte) 0xa1};
196196
byte[] valid = {(byte) 'f', (byte) 'o', (byte) 'o', (byte) '-',
197-
(byte) 0xE7, (byte) 0x94, (byte) 0x9F, (byte) 0xE3, (byte) 0x83,
198-
(byte) 0x93, (byte) 0xE3, (byte) 0x83, (byte) 0xBC, (byte) 0xE3,
199-
(byte) 0x83, (byte) 0xAB};
197+
(byte) 0xE7, (byte) 0x94, (byte) 0x9F, (byte) 0xE3, (byte) 0x83,
198+
(byte) 0x93, (byte) 0xE3, (byte) 0x83, (byte) 0xBC, (byte) 0xE3,
199+
(byte) 0x83, (byte) 0xAB};
200200

201201
ArrayList<Mutation> mutations;
202202
// non-utf8 is fine for data
@@ -421,9 +421,9 @@ public AppConfigurationEntry[] getAppConfigurationEntry(String name) {
421421
options.put("debug", "true");
422422

423423
return new AppConfigurationEntry[]{
424-
new AppConfigurationEntry("com.sun.security.auth.module.Krb5LoginModule",
425-
AppConfigurationEntry.LoginModuleControlFlag.REQUIRED,
426-
options)};
424+
new AppConfigurationEntry("com.sun.security.auth.module.Krb5LoginModule",
425+
AppConfigurationEntry.LoginModuleControlFlag.REQUIRED,
426+
options)};
427427
}
428428
});
429429

hbase-examples/src/main/java/org/apache/hadoop/hbase/thrift/HttpDoAsClient.java

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,7 @@ public class HttpDoAsClient {
7070
static protected String principal = null;
7171

7272
public static void main(String[] args) throws Exception {
73-
7473
if (args.length < 3 || args.length > 4) {
75-
7674
System.out.println("Invalid arguments!");
7775
System.out.println("Usage: HttpDoAsClient host port doAsUserName [security=true]");
7876
System.exit(-1);
@@ -143,8 +141,6 @@ private void run() throws Exception {
143141
}
144142
}
145143

146-
147-
148144
//
149145
// Create the demo table with two column families, entry: and unused:
150146
//
@@ -172,7 +168,7 @@ private void run() throws Exception {
172168
Map<ByteBuffer, ColumnDescriptor> columnMap = refresh(client, httpClient)
173169
.getColumnDescriptors(ByteBuffer.wrap(t));
174170
for (ColumnDescriptor col2 : columnMap.values()) {
175-
System.out.println(" column: " + utf8(col2.name.array()) + ", maxVer: " + Integer.toString(col2.maxVersions));
171+
System.out.println(" column: " + utf8(col2.name.array()) + ", maxVer: " + col2.maxVersions);
176172
}
177173

178174
transport.close();
@@ -181,7 +177,7 @@ private void run() throws Exception {
181177

182178
private Hbase.Client refresh(Hbase.Client client, THttpClient httpClient) {
183179
httpClient.setCustomHeader("doAs", doAsUser);
184-
if(secure) {
180+
if (secure) {
185181
try {
186182
httpClient.setCustomHeader("Authorization", generateTicket());
187183
} catch (GSSException e) {
@@ -232,7 +228,6 @@ private void printVersions(ByteBuffer row, List<TCell> versions) {
232228

233229
private void printRow(TRowResult rowResult) {
234230
// copy values into a TreeMap to get them in sorted order
235-
236231
TreeMap<String, TCell> sorted = new TreeMap<>();
237232
for (Map.Entry<ByteBuffer, TCell> column : rowResult.columns.entrySet()) {
238233
sorted.put(utf8(column.getKey().array()), column.getValue());
@@ -249,7 +244,10 @@ private void printRow(TRowResult rowResult) {
249244
}
250245

251246
static Subject getSubject() throws Exception {
252-
if (!secure) return new Subject();
247+
if (!secure) {
248+
return new Subject();
249+
}
250+
253251
/*
254252
* To authenticate the DemoClient, kinit should be invoked ahead.
255253
* Here we try to get the Kerberos credential from the ticket cache.
@@ -273,9 +271,9 @@ public AppConfigurationEntry[] getAppConfigurationEntry(String name) {
273271
options.put("debug", "true");
274272

275273
return new AppConfigurationEntry[]{
276-
new AppConfigurationEntry("com.sun.security.auth.module.Krb5LoginModule",
277-
AppConfigurationEntry.LoginModuleControlFlag.REQUIRED,
278-
options)};
274+
new AppConfigurationEntry("com.sun.security.auth.module.Krb5LoginModule",
275+
AppConfigurationEntry.LoginModuleControlFlag.REQUIRED,
276+
options)};
279277
}
280278
});
281279
context.login();

hbase-examples/src/main/java/org/apache/hadoop/hbase/thrift2/DemoClient.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646

4747
@InterfaceAudience.Private
4848
public class DemoClient {
49-
5049
private static String host = "localhost";
5150
private static int port = 9090;
5251
private static boolean secure = false;
@@ -55,7 +54,8 @@ public class DemoClient {
5554
public static void main(String[] args) throws Exception {
5655
System.out.println("Thrift2 Demo");
5756
System.out.println("Usage: DemoClient [host=localhost] [port=9090] [secure=false]");
58-
System.out.println("This demo assumes you have a table called \"example\" with a column family called \"family1\"");
57+
System.out.println("This demo assumes you have a table called \"example\" with a column " +
58+
"family called \"family1\"");
5959

6060
// use passed in arguments instead of defaults
6161
if (args.length >= 1) {
@@ -96,7 +96,7 @@ public void run() throws Exception {
9696
if (framed) {
9797
transport = new TFramedTransport(transport);
9898
} else if (secure) {
99-
/**
99+
/*
100100
* The Thrift server the DemoClient is trying to connect to
101101
* must have a matching principal, and support authentication.
102102
*
@@ -149,7 +149,9 @@ public void run() throws Exception {
149149
}
150150

151151
static Subject getSubject() throws Exception {
152-
if (!secure) return new Subject();
152+
if (!secure) {
153+
return new Subject();
154+
}
153155

154156
/*
155157
* To authenticate the DemoClient, kinit should be invoked ahead.
@@ -174,9 +176,9 @@ public AppConfigurationEntry[] getAppConfigurationEntry(String name) {
174176
options.put("debug", "true");
175177

176178
return new AppConfigurationEntry[]{
177-
new AppConfigurationEntry("com.sun.security.auth.module.Krb5LoginModule",
178-
AppConfigurationEntry.LoginModuleControlFlag.REQUIRED,
179-
options)};
179+
new AppConfigurationEntry("com.sun.security.auth.module.Krb5LoginModule",
180+
AppConfigurationEntry.LoginModuleControlFlag.REQUIRED,
181+
options)};
180182
}
181183
});
182184
context.login();

hbase-examples/src/test/java/org/apache/hadoop/hbase/coprocessor/example/TestRefreshHFilesBase.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ public static void setUp(String regionImpl) {
5555
CONF.set(HConstants.REGION_IMPL, regionImpl);
5656
CONF.setInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER, 2);
5757

58-
CONF.setStrings(CoprocessorHost.REGION_COPROCESSOR_CONF_KEY, RefreshHFilesEndpoint.class.getName());
58+
CONF.setStrings(CoprocessorHost.REGION_COPROCESSOR_CONF_KEY,
59+
RefreshHFilesEndpoint.class.getName());
5960
cluster = HTU.startMiniCluster(NUM_RS);
6061

6162
// Create table
@@ -80,9 +81,9 @@ protected void addHFilesToRegions() throws IOException {
8081
for (Region region : cluster.getRegions(TABLE_NAME)) {
8182
Path regionDir = new Path(tableDir, region.getRegionInfo().getEncodedName());
8283
Path familyDir = new Path(regionDir, Bytes.toString(FAMILY));
83-
HFileTestUtil
84-
.createHFile(HTU.getConfiguration(), HTU.getTestFileSystem(), new Path(familyDir, HFILE_NAME), FAMILY,
85-
QUALIFIER, Bytes.toBytes("50"), Bytes.toBytes("60"), NUM_ROWS);
84+
HFileTestUtil.createHFile(HTU.getConfiguration(), HTU.getTestFileSystem(),
85+
new Path(familyDir, HFILE_NAME), FAMILY, QUALIFIER, Bytes.toBytes("50"),
86+
Bytes.toBytes("60"), NUM_ROWS);
8687
}
8788
}
8889
}

hbase-examples/src/test/java/org/apache/hadoop/hbase/coprocessor/example/TestRefreshHFilesEndpoint.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444

4545
@Category(MediumTests.class)
4646
public class TestRefreshHFilesEndpoint extends TestRefreshHFilesBase {
47-
4847
@ClassRule
4948
public static final HBaseClassTestRule CLASS_RULE =
5049
HBaseClassTestRule.forClass(TestRefreshHFilesEndpoint.class);
@@ -69,8 +68,9 @@ private void callRefreshRegionHFilesEndPoint() throws IOException {
6968
RefreshHFilesClient refreshHFilesClient = new RefreshHFilesClient(CONF);
7069
refreshHFilesClient.refreshHFiles(TABLE_NAME);
7170
} catch (RetriesExhaustedException rex) {
72-
if (rex.getCause() instanceof IOException)
71+
if (rex.getCause() instanceof IOException) {
7372
throw new IOException();
73+
}
7474
} catch (Throwable ex) {
7575
LOG.error(ex.toString(), ex);
7676
fail("Couldn't call the RefreshRegionHFilesEndpoint");
@@ -81,15 +81,15 @@ public static class HRegionForRefreshHFilesEP extends HRegion {
8181
HStoreWithFaultyRefreshHFilesAPI store;
8282

8383
public HRegionForRefreshHFilesEP(final Path tableDir, final WAL wal, final FileSystem fs,
84-
final Configuration confParam, final RegionInfo regionInfo,
85-
final TableDescriptor htd, final RegionServerServices rsServices) {
84+
final Configuration confParam, final RegionInfo regionInfo, final TableDescriptor htd,
85+
final RegionServerServices rsServices) {
8686
super(tableDir, wal, fs, confParam, regionInfo, htd, rsServices);
8787
}
8888

8989
@Override
9090
public List<HStore> getStores() {
9191
List<HStore> list = new ArrayList<>(stores.size());
92-
/**
92+
/*
9393
* This is used to trigger the custom definition (faulty)
9494
* of refresh HFiles API.
9595
*/

0 commit comments

Comments
 (0)