[accumulo] branch main updated: Centralize ZK auth digest construction (#2424)

2022-01-20 Thread ctubbsii
This is an automated email from the ASF dual-hosted git repository.

ctubbsii pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/accumulo.git


The following commit(s) were added to refs/heads/main by this push:
 new 2b65a22  Centralize ZK auth digest construction (#2424)
2b65a22 is described below

commit 2b65a222c6b740567f62eecd20900bcd5965d6f5
Author: Christopher Tubbs 
AuthorDate: Thu Jan 20 22:36:03 2022 -0500

Centralize ZK auth digest construction (#2424)
---
 .../org/apache/accumulo/fate/zookeeper/ZooSession.java   |  2 +-
 .../java/org/apache/accumulo/fate/zookeeper/ZooUtil.java | 10 ++
 .../accumulo/miniclusterImpl/MiniAccumuloConfigImpl.java |  2 ++
 .../accumulo/server/replication/proto/Replication.java   |  1 +
 .../org/apache/accumulo/server/util/CleanZookeeper.java  |  3 ++-
 .../accumulo/test/fate/zookeeper/ServiceLockIT.java  | 16 +---
 6 files changed, 25 insertions(+), 9 deletions(-)

diff --git 
a/core/src/main/java/org/apache/accumulo/fate/zookeeper/ZooSession.java 
b/core/src/main/java/org/apache/accumulo/fate/zookeeper/ZooSession.java
index 5966f4b..f5221aa 100644
--- a/core/src/main/java/org/apache/accumulo/fate/zookeeper/ZooSession.java
+++ b/core/src/main/java/org/apache/accumulo/fate/zookeeper/ZooSession.java
@@ -129,7 +129,7 @@ public class ZooSession {
 for (int i = 0; i < connectTimeWait / TIME_BETWEEN_CONNECT_CHECKS_MS 
&& tryAgain; i++) {
   if (zooKeeper.getState().equals(States.CONNECTED)) {
 if (auth != null)
-  zooKeeper.addAuthInfo(scheme, auth);
+  ZooUtil.auth(zooKeeper, scheme, auth);
 tryAgain = false;
   } else
 UtilWaitThread.sleep(TIME_BETWEEN_CONNECT_CHECKS_MS);
diff --git a/core/src/main/java/org/apache/accumulo/fate/zookeeper/ZooUtil.java 
b/core/src/main/java/org/apache/accumulo/fate/zookeeper/ZooUtil.java
index 80c46e9..269cd63 100644
--- a/core/src/main/java/org/apache/accumulo/fate/zookeeper/ZooUtil.java
+++ b/core/src/main/java/org/apache/accumulo/fate/zookeeper/ZooUtil.java
@@ -18,6 +18,8 @@
  */
 package org.apache.accumulo.fate.zookeeper;
 
+import static java.nio.charset.StandardCharsets.UTF_8;
+
 import java.math.BigInteger;
 import java.util.ArrayList;
 import java.util.List;
@@ -121,4 +123,12 @@ public class ZooUtil {
 }
   }
 
+  public static void digestAuth(ZooKeeper zoo, String secret) {
+auth(zoo, "digest", ("accumulo:" + secret).getBytes(UTF_8));
+  }
+
+  public static void auth(ZooKeeper zoo, String scheme, byte[] auth) {
+zoo.addAuthInfo(scheme, auth);
+  }
+
 }
diff --git 
a/minicluster/src/main/java/org/apache/accumulo/miniclusterImpl/MiniAccumuloConfigImpl.java
 
b/minicluster/src/main/java/org/apache/accumulo/miniclusterImpl/MiniAccumuloConfigImpl.java
index 1885bdc..e7592a0 100644
--- 
a/minicluster/src/main/java/org/apache/accumulo/miniclusterImpl/MiniAccumuloConfigImpl.java
+++ 
b/minicluster/src/main/java/org/apache/accumulo/miniclusterImpl/MiniAccumuloConfigImpl.java
@@ -110,6 +110,8 @@ public class MiniAccumuloConfigImpl {
 
   /**
* Set directories and fully populate site config
+   *
+   * @return this
*/
   MiniAccumuloConfigImpl initialize() {
 
diff --git 
a/server/base/src/main/java/org/apache/accumulo/server/replication/proto/Replication.java
 
b/server/base/src/main/java/org/apache/accumulo/server/replication/proto/Replication.java
index 043ff72..1e67623 100644
--- 
a/server/base/src/main/java/org/apache/accumulo/server/replication/proto/Replication.java
+++ 
b/server/base/src/main/java/org/apache/accumulo/server/replication/proto/Replication.java
@@ -472,6 +472,7 @@ package org.apache.accumulo.server.replication.proto;
   return true;
 }
 
+@SuppressWarnings("unchecked")
 @java.lang.Override
 public int hashCode() {
   if (memoizedHashCode != 0) {
diff --git 
a/server/base/src/main/java/org/apache/accumulo/server/util/CleanZookeeper.java 
b/server/base/src/main/java/org/apache/accumulo/server/util/CleanZookeeper.java
index 5125113..66fe43d 100644
--- 
a/server/base/src/main/java/org/apache/accumulo/server/util/CleanZookeeper.java
+++ 
b/server/base/src/main/java/org/apache/accumulo/server/util/CleanZookeeper.java
@@ -24,6 +24,7 @@ import org.apache.accumulo.core.Constants;
 import org.apache.accumulo.core.cli.Help;
 import org.apache.accumulo.core.conf.SiteConfiguration;
 import org.apache.accumulo.fate.zookeeper.ZooReaderWriter;
+import org.apache.accumulo.fate.zookeeper.ZooUtil;
 import org.apache.accumulo.fate.zookeeper.ZooUtil.NodeMissingPolicy;
 import org.apache.accumulo.server.ServerContext;
 import org.apache.zookeeper.KeeperException;
@@ -57,7 +58,7 @@ public class CleanZookeeper {
   String root = Constants.ZROOT;
   ZooReaderWriter zk = context.getZooReaderWriter();
   if (opts.auth != null) {
-zk.getZooKeeper().addAuthInfo("digest", ("accumulo:" + 
opts.auth).getBytes(UTF_8));
+

[accumulo] branch main updated: Remove obsolete comments and add minor improvements to OfflineIterator (#2421)

2022-01-20 Thread domgarguilo
This is an automated email from the ASF dual-hosted git repository.

domgarguilo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/accumulo.git


The following commit(s) were added to refs/heads/main by this push:
 new 1f80b74  Remove obsolete comments and add minor improvements to 
OfflineIterator (#2421)
1f80b74 is described below

commit 1f80b7445d1320efaa8db1fb58c7b67d73c9fdbc
Author: Dom G 
AuthorDate: Thu Jan 20 09:30:06 2022 -0500

Remove obsolete comments and add minor improvements to OfflineIterator 
(#2421)

* Removed comments and added final to vars

Co-authored-by: Christopher Tubbs 
---
 .../accumulo/core/clientImpl/OfflineIterator.java  | 37 --
 1 file changed, 14 insertions(+), 23 deletions(-)

diff --git 
a/core/src/main/java/org/apache/accumulo/core/clientImpl/OfflineIterator.java 
b/core/src/main/java/org/apache/accumulo/core/clientImpl/OfflineIterator.java
index d2dc70a..426cc02 100644
--- 
a/core/src/main/java/org/apache/accumulo/core/clientImpl/OfflineIterator.java
+++ 
b/core/src/main/java/org/apache/accumulo/core/clientImpl/OfflineIterator.java
@@ -76,9 +76,9 @@ class OfflineIterator implements Iterator> {
   static class OfflineIteratorEnvironment implements IteratorEnvironment {
 
 private final Authorizations authorizations;
-private AccumuloConfiguration conf;
-private boolean useSample;
-private SamplerConfiguration sampleConf;
+private final AccumuloConfiguration conf;
+private final boolean useSample;
+private final SamplerConfiguration sampleConf;
 
 public OfflineIteratorEnvironment(Authorizations auths, 
AccumuloConfiguration acuTableConf,
 boolean useSample, SamplerConfiguration samplerConf) {
@@ -109,7 +109,8 @@ class OfflineIterator implements Iterator> 
{
   return false;
 }
 
-private ArrayList> topLevelIterators = 
new ArrayList<>();
+private final ArrayList> 
topLevelIterators =
+new ArrayList<>();
 
 @Deprecated(since = "2.0.0")
 @Override
@@ -151,11 +152,11 @@ class OfflineIterator implements 
Iterator> {
   private SortedKeyValueIterator iter;
   private Range range;
   private KeyExtent currentExtent;
-  private TableId tableId;
-  private Authorizations authorizations;
-  private ClientContext context;
-  private ScannerOptions options;
-  private ArrayList> readers;
+  private final TableId tableId;
+  private final Authorizations authorizations;
+  private final ClientContext context;
+  private final ScannerOptions options;
+  private final ArrayList> readers;
 
   public OfflineIterator(ScannerOptions options, ClientContext context,
   Authorizations authorizations, Text table, Range range) {
@@ -210,7 +211,7 @@ class OfflineIterator implements Iterator> 
{
 
   private void nextTablet() throws TableNotFoundException, AccumuloException, 
IOException {
 
-Range nextRange = null;
+Range nextRange;
 
 if (currentExtent == null) {
   Text startRow;
@@ -223,12 +224,8 @@ class OfflineIterator implements 
Iterator> {
   nextRange = new Range(TabletsSection.encodeRow(tableId, startRow), true, 
null, false);
 } else {
 
-  if (currentExtent.endRow() == null) {
-iter = null;
-return;
-  }
-
-  if (range.afterEndKey(new 
Key(currentExtent.endRow()).followingKey(PartialKey.ROW))) {
+  if (currentExtent.endRow() == null
+  || range.afterEndKey(new 
Key(currentExtent.endRow()).followingKey(PartialKey.ROW))) {
 iter = null;
 return;
   }
@@ -279,8 +276,6 @@ class OfflineIterator implements Iterator> 
{
   Collection absFiles)
   throws TableNotFoundException, AccumuloException, IOException {
 
-// TODO share code w/ tablet - ACCUMULO-1303
-
 // possible race condition here, if table is renamed
 String tableName = Tables.getTableName(context, tableId);
 AccumuloConfiguration acuTableConf =
@@ -300,13 +295,9 @@ class OfflineIterator implements 
Iterator> {
 SamplerConfigurationImpl samplerConfImpl =
 SamplerConfigurationImpl.newSamplerConfig(acuTableConf);
 
-if (scannerSamplerConfigImpl != null
-&& ((samplerConfImpl != null && 
!scannerSamplerConfigImpl.equals(samplerConfImpl))
-|| samplerConfImpl == null)) {
+if (scannerSamplerConfigImpl != null && 
!scannerSamplerConfigImpl.equals(samplerConfImpl)) {
   throw new SampleNotPresentException();
 }
-
-// TODO need to close files - ACCUMULO-1303
 for (TabletFile file : absFiles) {
   FileSystem fs = VolumeConfiguration.fileSystemForPath(file.getPathStr(), 
conf);
   FileSKVIterator reader = FileOperations.getInstance().newReaderBuilder()