From commits-return-24318-archive-asf-public=cust-asf.ponee.io@accumulo.apache.org Wed Nov 4 17:20:16 2020 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mxout1-he-de.apache.org (mxout1-he-de.apache.org [95.216.194.37]) by mx-eu-01.ponee.io (Postfix) with ESMTPS id 2E88618060E for ; Wed, 4 Nov 2020 18:20:16 +0100 (CET) Received: from mail.apache.org (mailroute1-lw-us.apache.org [207.244.88.153]) by mxout1-he-de.apache.org (ASF Mail Server at mxout1-he-de.apache.org) with SMTP id 9B4E762C4A for ; Wed, 4 Nov 2020 17:20:15 +0000 (UTC) Received: (qmail 3963 invoked by uid 500); 4 Nov 2020 17:20:14 -0000 Mailing-List: contact commits-help@accumulo.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@accumulo.apache.org Delivered-To: mailing list commits@accumulo.apache.org Received: (qmail 3933 invoked by uid 99); 4 Nov 2020 17:20:14 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 04 Nov 2020 17:20:14 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id B326F820EB; Wed, 4 Nov 2020 17:20:14 +0000 (UTC) Date: Wed, 04 Nov 2020 17:20:14 +0000 To: "commits@accumulo.apache.org" Subject: [accumulo] branch main updated: Implement IteratorEnvironment.getPluginEnv() (#1768) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Message-ID: <160451041452.23438.3272110034424212160@gitbox.apache.org> From: ctubbsii@apache.org X-Git-Host: gitbox.apache.org X-Git-Repo: accumulo X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Oldrev: d7ca701f62e15d17a29be8f629a3c8cce826da37 X-Git-Newrev: a1054168278e81045b7d3850cf5a7208deb0a7fa X-Git-Rev: a1054168278e81045b7d3850cf5a7208deb0a7fa X-Git-NotificationType: ref_changed_plus_diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated 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 a105416 Implement IteratorEnvironment.getPluginEnv() (#1768) a105416 is described below commit a1054168278e81045b7d3850cf5a7208deb0a7fa Author: Christopher Tubbs AuthorDate: Wed Nov 4 12:09:05 2020 -0500 Implement IteratorEnvironment.getPluginEnv() (#1768) * This fixes #1766 * Return an actual implementation for `IteratorEnvironment.getPluginEnv()` * Clean up `IteratorEnvIT.testEnv()` method to: * Verify implementation of `getPluginEnv()` (same object as `getServiceEnv()`, but with the newer API that doesn't leak internal types * Remove duplicate check of the same table configuration via `getServiceEnv()` and `getPluginEnv()` * Remove duplicate (identical) check from the deprecated `getConfig()` method to get the table's configuration as `AccumuloConfiguration` * Ensure system configuration is covered in the test via `getPluginEnv().getConfiguration()` * Ensure getting the property by the full property name via `get()` works as well as by the `getTableCustom()` convenience method --- .../core/iterators/IteratorEnvironment.java | 2 +- .../org/apache/accumulo/test/IteratorEnvIT.java | 39 +++++++++++++++------- 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/core/src/main/java/org/apache/accumulo/core/iterators/IteratorEnvironment.java b/core/src/main/java/org/apache/accumulo/core/iterators/IteratorEnvironment.java index 6881040..cc9e41d 100644 --- a/core/src/main/java/org/apache/accumulo/core/iterators/IteratorEnvironment.java +++ b/core/src/main/java/org/apache/accumulo/core/iterators/IteratorEnvironment.java @@ -177,7 +177,7 @@ public interface IteratorEnvironment { * @since 2.1.0 */ default PluginEnvironment getPluginEnv() { - throw new UnsupportedOperationException(); + return getServiceEnv(); } /** diff --git a/test/src/main/java/org/apache/accumulo/test/IteratorEnvIT.java b/test/src/main/java/org/apache/accumulo/test/IteratorEnvIT.java index 6965b69..b5e7e54 100644 --- a/test/src/main/java/org/apache/accumulo/test/IteratorEnvIT.java +++ b/test/src/main/java/org/apache/accumulo/test/IteratorEnvIT.java @@ -30,6 +30,7 @@ import org.apache.accumulo.core.client.Accumulo; import org.apache.accumulo.core.client.AccumuloClient; import org.apache.accumulo.core.client.BatchWriter; import org.apache.accumulo.core.client.IteratorSetting; +import org.apache.accumulo.core.client.PluginEnvironment; import org.apache.accumulo.core.client.Scanner; import org.apache.accumulo.core.client.admin.CompactionConfig; import org.apache.accumulo.core.client.admin.NewTableConfiguration; @@ -41,6 +42,7 @@ import org.apache.accumulo.core.iterators.IteratorEnvironment; import org.apache.accumulo.core.iterators.IteratorUtil.IteratorScope; import org.apache.accumulo.core.iterators.SortedKeyValueIterator; import org.apache.accumulo.core.iterators.WrappingIterator; +import org.apache.accumulo.core.spi.common.ServiceEnvironment; import org.apache.accumulo.harness.AccumuloClusterHarness; import org.apache.accumulo.miniclusterImpl.MiniAccumuloConfigImpl; import org.apache.hadoop.conf.Configuration; @@ -142,27 +144,40 @@ public class IteratorEnvIT extends AccumuloClusterHarness { /** * Test the environment methods return what is expected. */ - @SuppressWarnings("deprecation") private static void testEnv(IteratorScope scope, Map opts, IteratorEnvironment env) { TableId expectedTableId = TableId.of(opts.get("expected.table.id")); - if (!"value1".equals(env.getConfig().get("table.custom.iterator.env.test"))) - throw new RuntimeException("Test failed - Expected table property not found."); - if (!"value1".equals( - env.getServiceEnv().getConfiguration(env.getTableId()).getTableCustom("iterator.env.test"))) - throw new RuntimeException("Test failed - Expected table property not found."); - if (!"value1".equals(env.getConfig().get("table.custom.iterator.env.test"))) - throw new RuntimeException("Test failed - Expected table property not found."); - if (!"value1".equals( - env.getPluginEnv().getConfiguration(env.getTableId()).getTableCustom("iterator.env.test"))) - throw new RuntimeException("Test failed - Expected table property not found."); + + // verify getServiceEnv() and getPluginEnv() are the same objects, + // so further checks only need to use getPluginEnv() + @SuppressWarnings("deprecation") + ServiceEnvironment serviceEnv = env.getServiceEnv(); + PluginEnvironment pluginEnv = env.getPluginEnv(); + if (serviceEnv != pluginEnv) + throw new RuntimeException("Test failed - assertSame(getServiceEnv(),getPluginEnv())"); + + // verify property exists on the table config (deprecated and new), + // with and without custom prefix, but not in the system config + @SuppressWarnings("deprecation") + String accTableConf = env.getConfig().get("table.custom.iterator.env.test"); + if (!"value1".equals(accTableConf)) + throw new RuntimeException("Test failed - Expected table property not found in getConfig()."); + var tableConf = pluginEnv.getConfiguration(env.getTableId()); + if (!"value1".equals(tableConf.get("table.custom.iterator.env.test"))) + throw new RuntimeException("Test failed - Expected table property not found in table conf."); + if (!"value1".equals(tableConf.getTableCustom("iterator.env.test"))) + throw new RuntimeException("Test failed - Expected table property not found in table conf."); + var systemConf = pluginEnv.getConfiguration(); + if (systemConf.get("table.custom.iterator.env.test") != null) + throw new RuntimeException("Test failed - Unexpected table property found in system conf."); + + // check other environment settings if (!scope.equals(env.getIteratorScope())) throw new RuntimeException("Test failed - Error getting iterator scope"); if (env.isSamplingEnabled()) throw new RuntimeException("Test failed - isSamplingEnabled returned true, expected false"); if (!expectedTableId.equals(env.getTableId())) throw new RuntimeException("Test failed - Error getting Table ID"); - } @Before