accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mmil...@apache.org
Subject [accumulo-testing] branch master updated: Update checkstyle to use import-control for API check (#52)
Date Tue, 29 Jan 2019 19:09:24 GMT
This is an automated email from the ASF dual-hosted git repository.

mmiller pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/accumulo-testing.git


The following commit(s) were added to refs/heads/master by this push:
     new a2509be  Update checkstyle to use import-control for API check (#52)
a2509be is described below

commit a2509be5f17092384c3c7a06e62530875f978a27
Author: Mike Miller <mmiller@apache.org>
AuthorDate: Tue Jan 29 14:09:19 2019 -0500

    Update checkstyle to use import-control for API check (#52)
    
    * Update checkstyle to use import-control for checking use of accumulo API
    * Add checkstyle plugin to the build execution to always run
    * Add exceptions to API checking to hold the line until we can fix
    * Use Guava peeking iterator in place of accumulo peeking iterator
---
 contrib/checkstyle.xml                             |  8 +--
 contrib/import-control.xml                         | 67 ++++++++++++++++++++++
 pom.xml                                            | 21 +++++--
 .../randomwalk/concurrent/IsolatedScan.java        |  6 +-
 4 files changed, 91 insertions(+), 11 deletions(-)

diff --git a/contrib/checkstyle.xml b/contrib/checkstyle.xml
index 68bb068..590efce 100644
--- a/contrib/checkstyle.xml
+++ b/contrib/checkstyle.xml
@@ -17,11 +17,9 @@
 <module name="Checker">
   <property name="charset" value="UTF-8"/>
   <module name="TreeWalker">
-    <module name="RegexpSinglelineJava">
-      <!--check that only Accumulo public APIs are imported-->
-      <property name="format" value="import\s+org\.apache\.accumulo\.(.*\.(impl|thrift|crypto)\..*|(?!core|minicluster|testing).*|core\.(?!client|data|security).*)"/>
-      <property name="ignoreComments" value="true" />
-      <property name="message" value="Accumulo non-public classes imported" />
+    <!--check that only Accumulo public APIs are imported-->
+    <module name="ImportControl">
+      <property name="file" value="contrib/import-control.xml"/>
     </module>
   </module>
 </module>
diff --git a/contrib/import-control.xml b/contrib/import-control.xml
new file mode 100644
index 0000000..ff2be61
--- /dev/null
+++ b/contrib/import-control.xml
@@ -0,0 +1,67 @@
+<?xml version="1.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.
+-->
+<!DOCTYPE import-control PUBLIC
+    "-//Checkstyle//DTD ImportControl Configuration 1.4//EN"
+    "https://checkstyle.org/dtds/import_control_1_4.dtd">
+
+<!-- This checkstyle rule is configured to ensure only use of Accumulo API -->
+<import-control pkg="org.apache.accumulo.testing" strategyOnMismatch="allowed">
+    <!-- allow this package -->
+    <allow pkg="org.apache.accumulo.testing"/>
+    <!-- API packages -->
+    <allow pkg="org.apache.accumulo.core.client"/>
+    <allow pkg="org.apache.accumulo.core.data"/>
+    <allow pkg="org.apache.accumulo.core.security"/>
+    <allow pkg="org.apache.accumulo.core.iterators"/>
+    <allow pkg="org.apache.accumulo.minicluster"/>
+    <allow pkg="org.apache.accumulo.hadoop.mapreduce"/>
+
+    <!-- exceptions for testing -->
+    <allow pkg="org.apache.accumulo.core.conf"/>
+
+    <!-- TODO refactor code to remove the following exceptions -->
+    <allow class="org.apache.accumulo.core.clientImpl.thrift.TableOperationExceptionType"/>
+    <allow class="org.apache.accumulo.core.clientImpl.thrift.ThriftTableOperationException"/>
+    <allow class="org.apache.accumulo.core.metadata.MetadataTable"/>
+    <allow class="org.apache.accumulo.core.replication.ReplicationTable"/>
+    <allow class="org.apache.accumulo.core.spi.scan.HintScanPrioritizer"/>
+    <allow class="org.apache.accumulo.hadoopImpl.mapreduce.lib.MapReduceClientOnRequiredTable"/>
+    <allow class="org.apache.accumulo.core.crypto.CryptoServiceFactory"/>
+    <allow class="org.apache.accumulo.core.clientImpl.ClientContext"/>
+    <allow class="org.apache.accumulo.core.clientImpl.TabletServerBatchWriter"/>
+    <allow class="org.apache.accumulo.core.file.FileOperations"/>
+    <allow class="org.apache.accumulo.core.file.FileSKVWriter"/>
+    <allow class="org.apache.accumulo.core.file.rfile.RFile"/>
+    <allow class="org.apache.accumulo.core.util.SimpleThreadPool"/>
+    <allow class="org.apache.accumulo.core.util.FastFormat"/>
+    <allow class="org.apache.accumulo.core.cli.ClientOnRequiredTable"/>
+    <allow class="org.apache.accumulo.core.cli.BatchScannerOpts"/>
+    <allow class="org.apache.accumulo.core.cli.ClientOnDefaultTable"/>
+    <allow class="org.apache.accumulo.core.cli.ClientOpts.TimeConverter"/>
+    <allow class="org.apache.accumulo.core.cli.Help"/>
+    <allow class="org.apache.accumulo.core.cli.BatchWriterOpts"/>
+    <allow class="org.apache.accumulo.core.cli.ClientOpts"/>
+    <allow class="org.apache.accumulo.core.cli.ScannerOpts"/>
+    <allow class="org.apache.accumulo.core.util.Pair"/>
+    <allow class="org.apache.accumulo.core.trace.Trace"/>
+    <allow class="org.apache.accumulo.core.trace.TraceSamplers"/>
+    <allow class="org.apache.accumulo.core.trace.Span"/>
+    <allow class="org.apache.accumulo.core.trace.DistributedTrace"/>
+    <!-- End TODO section -->
+
+    <!-- disallow everything else coming from accumulo -->
+    <disallow pkg="org.apache.accumulo"/>
+</import-control>
diff --git a/pom.xml b/pom.xml
index deb0ed2..a1a07be 100644
--- a/pom.xml
+++ b/pom.xml
@@ -118,15 +118,28 @@
         </executions>
       </plugin>
       <plugin>
-        <!-- This was added to ensure project only uses public API. Run with the following:
-              mvn checkstyle:checkstyle
-         -->
+        <!-- This was added to ensure project only uses public API -->
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-checkstyle-plugin</artifactId>
-        <version>2.17</version>
+        <version>3.0.0</version>
         <configuration>
           <configLocation>contrib/checkstyle.xml</configLocation>
         </configuration>
+	<dependencies>
+            <dependency>
+              <groupId>com.puppycrawl.tools</groupId>
+              <artifactId>checkstyle</artifactId>
+              <version>8.17</version>
+            </dependency>
+	</dependencies>
+	<executions>
+          <execution>
+            <id>check-style</id>
+            <goals>
+              <goal>check</goal>
+            </goals>
+          </execution>
+        </executions>
       </plugin>
     </plugins>
   </build>
diff --git a/src/main/java/org/apache/accumulo/testing/randomwalk/concurrent/IsolatedScan.java
b/src/main/java/org/apache/accumulo/testing/randomwalk/concurrent/IsolatedScan.java
index 27e8d9c..14fb2ee 100644
--- a/src/main/java/org/apache/accumulo/testing/randomwalk/concurrent/IsolatedScan.java
+++ b/src/main/java/org/apache/accumulo/testing/randomwalk/concurrent/IsolatedScan.java
@@ -30,11 +30,13 @@ import org.apache.accumulo.core.client.TableOfflineException;
 import org.apache.accumulo.core.data.Key;
 import org.apache.accumulo.core.data.Value;
 import org.apache.accumulo.core.security.Authorizations;
-import org.apache.accumulo.core.util.PeekingIterator;
 import org.apache.accumulo.testing.randomwalk.RandWalkEnv;
 import org.apache.accumulo.testing.randomwalk.State;
 import org.apache.accumulo.testing.randomwalk.Test;
 
+import com.google.common.collect.Iterators;
+import com.google.common.collect.PeekingIterator;
+
 public class IsolatedScan extends Test {
 
   @Override
@@ -53,7 +55,7 @@ public class IsolatedScan extends Test {
           Authorizations.EMPTY)));
 
       while (iter.hasNext()) {
-        PeekingIterator<Entry<Key,Value>> row = new PeekingIterator<>(iter.next());
+        PeekingIterator<Entry<Key,Value>> row = Iterators.peekingIterator(iter.next());
         Entry<Key,Value> kv = null;
         if (row.hasNext())
           kv = row.peek();


Mime
View raw message