[accumulo] branch main updated: Refactor Crypto packages (#1956)
This is an automated email from the ASF dual-hosted git repository. mmiller 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 0781550 Refactor Crypto packages (#1956) 0781550 is described below commit 0781550076f04d12716650fd64881d8b9d041afa Author: Mike Miller AuthorDate: Thu Mar 4 17:43:04 2021 -0500 Refactor Crypto packages (#1956) * Move AESCryptoService and NoCryptoService into public spi package * Move CryptoEnvironmentImpl into core.crypto package with other server crypto stuff * Make AESCryptoUtils static methods on AESCryptoService --- .../org/apache/accumulo/core/conf/Property.java| 2 +- .../CryptoEnvironmentImpl.java | 2 +- .../accumulo/core/crypto/CryptoServiceFactory.java | 2 +- .../apache/accumulo/core/crypto/CryptoUtils.java | 1 - .../accumulo/core/cryptoImpl/AESKeyUtils.java | 95 -- .../apache/accumulo/core/file/rfile/PrintInfo.java | 2 +- .../accumulo/core/file/rfile/bcfile/BCFile.java| 6 +- .../crypto}/AESCryptoService.java | 81 +++--- .../crypto}/NoCryptoService.java | 7 +- .../crypto}/NoFileDecrypter.java | 5 +- .../crypto}/NoFileEncrypter.java | 5 +- .../accumulo/core/conf/SiteConfigurationTest.java | 4 +- .../apache/accumulo/core/crypto/CryptoTest.java| 30 --- .../apache/accumulo/core/file/rfile/RFileTest.java | 2 +- core/src/test/resources/accumulo2.properties | 2 +- .../org/apache/accumulo/tserver/log/DfsLogger.java | 4 +- .../test/functional/WriteAheadLogEncryptedIT.java | 2 +- 17 files changed, 99 insertions(+), 153 deletions(-) diff --git a/core/src/main/java/org/apache/accumulo/core/conf/Property.java b/core/src/main/java/org/apache/accumulo/core/conf/Property.java index 04015e3..c757648 100644 --- a/core/src/main/java/org/apache/accumulo/core/conf/Property.java +++ b/core/src/main/java/org/apache/accumulo/core/conf/Property.java @@ -176,7 +176,7 @@ public enum Property { "Sensitive properties related to on-disk file encryption."), @Experimental INSTANCE_CRYPTO_SERVICE("instance.crypto.service", - "org.apache.accumulo.core.cryptoImpl.NoCryptoService", PropertyType.CLASSNAME, + "org.apache.accumulo.core.spi.crypto.NoCryptoService", PropertyType.CLASSNAME, "The class which executes on-disk file encryption. The default does nothing. To enable " + "encryption, replace this classname with an implementation of the" + "org.apache.accumulo.core.spi.crypto.CryptoService interface."), diff --git a/core/src/main/java/org/apache/accumulo/core/cryptoImpl/CryptoEnvironmentImpl.java b/core/src/main/java/org/apache/accumulo/core/crypto/CryptoEnvironmentImpl.java similarity index 96% rename from core/src/main/java/org/apache/accumulo/core/cryptoImpl/CryptoEnvironmentImpl.java rename to core/src/main/java/org/apache/accumulo/core/crypto/CryptoEnvironmentImpl.java index 17863be..ba2deae 100644 --- a/core/src/main/java/org/apache/accumulo/core/cryptoImpl/CryptoEnvironmentImpl.java +++ b/core/src/main/java/org/apache/accumulo/core/crypto/CryptoEnvironmentImpl.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.accumulo.core.cryptoImpl; +package org.apache.accumulo.core.crypto; import org.apache.accumulo.core.spi.crypto.CryptoEnvironment; diff --git a/core/src/main/java/org/apache/accumulo/core/crypto/CryptoServiceFactory.java b/core/src/main/java/org/apache/accumulo/core/crypto/CryptoServiceFactory.java index f3c8737..1415b0d 100644 --- a/core/src/main/java/org/apache/accumulo/core/crypto/CryptoServiceFactory.java +++ b/core/src/main/java/org/apache/accumulo/core/crypto/CryptoServiceFactory.java @@ -21,8 +21,8 @@ package org.apache.accumulo.core.crypto; import org.apache.accumulo.core.conf.AccumuloConfiguration; import org.apache.accumulo.core.conf.DefaultConfiguration; import org.apache.accumulo.core.conf.Property; -import org.apache.accumulo.core.cryptoImpl.NoCryptoService; import org.apache.accumulo.core.spi.crypto.CryptoService; +import org.apache.accumulo.core.spi.crypto.NoCryptoService; public class CryptoServiceFactory { diff --git a/core/src/main/java/org/apache/accumulo/core/crypto/CryptoUtils.java b/core/src/main/java/org/apache/accumulo/core/crypto/CryptoUtils.java index 703a0eb..53fff25 100644 --- a/core/src/main/java/org/apache/accumulo/core/crypto/CryptoUtils.java +++ b/core/src/main/java/org/apache/accumulo/core/crypto/CryptoUtils.java @@ -26,7 +26,6 @@ import java.security.NoSuchProviderException; import java.security.SecureRandom; import java.util.Objects; -import org.apache.accumulo.core.cryptoImpl.CryptoEnvironmentImpl; import org.apache.accumulo.core.spi.crypto.CryptoEnvironment;
[accumulo] branch main updated: Convert tests from MAC to ZooKeeperTestingServer (#1952)
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 58aa28e Convert tests from MAC to ZooKeeperTestingServer (#1952) 58aa28e is described below commit 58aa28ee2a7f4f35e4419a5bbae8ad01acf04a43 Author: Dom G <47725857+domgargu...@users.noreply.github.com> AuthorDate: Thu Mar 4 16:37:35 2021 -0500 Convert tests from MAC to ZooKeeperTestingServer (#1952) * Convert ZooLockITs use of MAC to ZooKeeperTestingServer * Make ZKTestingServer Auto-closeable * Move ZooKeeperTestingServer into try-with-resources block * Minor, unrelated improvements in FateMetricsIT --- .../categories/ZooKeeperTestingServerTests.java| 25 .../accumulo/test/fate/zookeeper/ZooLockIT.java| 44 -- .../zookeeper}/ZooMutatorIT.java | 38 +-- .../{FateMetricsTest.java => FateMetricsIT.java} | 12 +++--- .../test/zookeeper/ZooKeeperTestingServer.java | 3 +- 5 files changed, 75 insertions(+), 47 deletions(-) diff --git a/start/src/main/java/org/apache/accumulo/test/categories/ZooKeeperTestingServerTests.java b/start/src/main/java/org/apache/accumulo/test/categories/ZooKeeperTestingServerTests.java new file mode 100644 index 000..00c758c --- /dev/null +++ b/start/src/main/java/org/apache/accumulo/test/categories/ZooKeeperTestingServerTests.java @@ -0,0 +1,25 @@ +/* + * 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. + */ +package org.apache.accumulo.test.categories; + +/** + * Interface to be used with JUnit Category annotation to denote that the IntegrationTest requires + * the use of a ZooKeeperTestingServer. + */ +public interface ZooKeeperTestingServerTests {} diff --git a/test/src/main/java/org/apache/accumulo/test/fate/zookeeper/ZooLockIT.java b/test/src/main/java/org/apache/accumulo/test/fate/zookeeper/ZooLockIT.java index f65bff3..06dd0b0 100644 --- a/test/src/main/java/org/apache/accumulo/test/fate/zookeeper/ZooLockIT.java +++ b/test/src/main/java/org/apache/accumulo/test/fate/zookeeper/ZooLockIT.java @@ -42,7 +42,8 @@ import org.apache.accumulo.fate.zookeeper.ZooLock; import org.apache.accumulo.fate.zookeeper.ZooLock.AccumuloLockWatcher; import org.apache.accumulo.fate.zookeeper.ZooLock.LockLossReason; import org.apache.accumulo.fate.zookeeper.ZooReaderWriter; -import org.apache.accumulo.harness.SharedMiniClusterBase; +import org.apache.accumulo.test.categories.ZooKeeperTestingServerTests; +import org.apache.accumulo.test.zookeeper.ZooKeeperTestingServer; import org.apache.zookeeper.CreateMode; import org.apache.zookeeper.KeeperException; import org.apache.zookeeper.WatchedEvent; @@ -54,19 +55,24 @@ import org.apache.zookeeper.data.ACL; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; +import org.junit.experimental.categories.Category; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class ZooLockIT extends SharedMiniClusterBase { +@Category({ZooKeeperTestingServerTests.class}) +public class ZooLockIT { + + private static ZooKeeperTestingServer szk = null; @BeforeClass public static void setup() throws Exception { -SharedMiniClusterBase.startMiniCluster(); +szk = new ZooKeeperTestingServer(); +szk.initPaths("/accumulo/" + UUID.randomUUID().toString()); } @AfterClass - public static void teardown() { -SharedMiniClusterBase.stopMiniCluster(); + public static void teardown() throws Exception { +szk.close(); } static class ZooKeeperWrapper extends ZooKeeper { @@ -76,9 +82,9 @@ public class ZooLockIT extends SharedMiniClusterBase { super(connectString, sessionTimeout, watcher); } -public String createOnce(String path, byte[] data, List acl, CreateMode createMode) +public void createOnce(String path, byte[] data, List acl, CreateMode createMode) throws KeeperException, InterruptedException { - return super.create(path, data, acl, createMode); + super.create(path, data, acl, createMode); } @Override @@ -185,7 +191,7
[accumulo] branch main updated: Clean up CompactionDirectives default impl (#1950)
This is an automated email from the ASF dual-hosted git repository. mmiller 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 3bbc77d Clean up CompactionDirectives default impl (#1950) 3bbc77d is described below commit 3bbc77de13aa6cf0b849f7b28ec08cb6e6b843e9 Author: Mike Miller AuthorDate: Thu Mar 4 07:27:58 2021 -0500 Clean up CompactionDirectives default impl (#1950) * Created CompactionDirectivesBuilder class for builder logic Co-authored-by: Keith Turner --- .../core/spi/compaction/CompactionDirectives.java | 17 +++-- ...tives.java => CompactionDirectivesBuilder.java} | 38 +- ...rectives.java => CompactionDirectivesImpl.java} | 32 .../spi/compaction/CompactionsDirectiveImpl.java | 85 -- .../spi/compaction/SimpleCompactionDispatcher.java | 8 +- 5 files changed, 48 insertions(+), 132 deletions(-) diff --git a/core/src/main/java/org/apache/accumulo/core/spi/compaction/CompactionDirectives.java b/core/src/main/java/org/apache/accumulo/core/spi/compaction/CompactionDirectives.java index e3370eb..6991fc6 100644 --- a/core/src/main/java/org/apache/accumulo/core/spi/compaction/CompactionDirectives.java +++ b/core/src/main/java/org/apache/accumulo/core/spi/compaction/CompactionDirectives.java @@ -32,17 +32,24 @@ public interface CompactionDirectives { CompactionServiceId getService(); /** + * Required for CompactionDirectives + * * @since 2.1.0 */ - public static interface Builder { -Builder setService(CompactionServiceId service); + interface ServiceBuilder { +Builder toService(CompactionServiceId service); -Builder setService(String compactionServiceId); +Builder toService(String compactionServiceId); + } + /** + * @since 2.1.0 + */ + interface Builder { CompactionDirectives build(); } - public static Builder builder() { -return CompactionsDirectiveImpl.DEFAULT_BUILDER; + static ServiceBuilder builder() { +return new CompactionDirectivesBuilder(); } } diff --git a/core/src/main/java/org/apache/accumulo/core/spi/compaction/CompactionDirectives.java b/core/src/main/java/org/apache/accumulo/core/spi/compaction/CompactionDirectivesBuilder.java similarity index 55% copy from core/src/main/java/org/apache/accumulo/core/spi/compaction/CompactionDirectives.java copy to core/src/main/java/org/apache/accumulo/core/spi/compaction/CompactionDirectivesBuilder.java index e3370eb..c542699 100644 --- a/core/src/main/java/org/apache/accumulo/core/spi/compaction/CompactionDirectives.java +++ b/core/src/main/java/org/apache/accumulo/core/spi/compaction/CompactionDirectivesBuilder.java @@ -18,31 +18,31 @@ */ package org.apache.accumulo.core.spi.compaction; +import java.util.Objects; + /** - * The directions of a {@link CompactionDispatcher} - * - * @since 2.1.0 - * @see org.apache.accumulo.core.spi.compaction + * This class intentionally package private. */ -public interface CompactionDirectives { - - /** - * @return The service where a compaction should run. - */ - CompactionServiceId getService(); +class CompactionDirectivesBuilder +implements CompactionDirectives.Builder, CompactionDirectives.ServiceBuilder { - /** - * @since 2.1.0 - */ - public static interface Builder { -Builder setService(CompactionServiceId service); + private CompactionServiceId service; -Builder setService(String compactionServiceId); + @Override + public CompactionDirectives.Builder toService(CompactionServiceId service) { +this.service = Objects.requireNonNull(service, "CompactionServiceId cannot be null"); +return this; + } -CompactionDirectives build(); + @Override + public CompactionDirectives.Builder toService(String compactionServiceId) { +this.service = CompactionServiceId.of(compactionServiceId); +return this; } - public static Builder builder() { -return CompactionsDirectiveImpl.DEFAULT_BUILDER; + @Override + public CompactionDirectives build() { +return new CompactionDirectivesImpl(service); } + } diff --git a/core/src/main/java/org/apache/accumulo/core/spi/compaction/CompactionDirectives.java b/core/src/main/java/org/apache/accumulo/core/spi/compaction/CompactionDirectivesImpl.java similarity index 61% copy from core/src/main/java/org/apache/accumulo/core/spi/compaction/CompactionDirectives.java copy to core/src/main/java/org/apache/accumulo/core/spi/compaction/CompactionDirectivesImpl.java index e3370eb..fe2a833 100644 --- a/core/src/main/java/org/apache/accumulo/core/spi/compaction/CompactionDirectives.java +++ b/core/src/main/java/org/apache/accumulo/core/spi/compaction/CompactionDirectivesImpl.java @@ -19,30 +19,24 @@ package org.apache.accumulo.core.spi.compaction; /** - * The directions of a {@link CompactionDispatcher} - * - * @since 2.1.0 - * @see