[accumulo] branch main updated: Remove unneeded resource warning suppressions (#1852)
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 ede736f Remove unneeded resource warning suppressions (#1852) ede736f is described below commit ede736f214dbab5ca272240b41019bb12ea3725c Author: Christopher Tubbs AuthorDate: Tue Jan 5 02:14:19 2021 -0500 Remove unneeded resource warning suppressions (#1852) Work around the need to suppress unclosed resource warnings and remove the unneeded suppressions. For tests: * Use assertThrows and try-with-resources in tests to handle resource creation and cleanup, to avoid warnings about unclosed resources For ListTabletsCommand.java: * Use try-with-resources to ensure TabletsMetadata resource object is closed when done using it For SimpleGarbageCollector: * Rename GarbageCollectionEnvironment.getBlipIterator to .getBlipPaths and make it return a Stream (which is Closeable) instead of an Iterator (which isn't Closeable) * Set the onClose for the Stream returned from .getBlipPaths to close the scanner whose iterator it is wrapping * Ensure the Stream returned from .getBlipPaths is closed in a try-with-resources block * Remove use of Guava's Iterables (not needed, since we can use Stream.map directly now) --- .../accumulo/core/clientImpl/ScannerImplTest.java | 34 +- .../clientImpl/TabletServerBatchReaderTest.java| 7 ++-- .../accumulo/gc/GarbageCollectionAlgorithm.java| 40 -- .../accumulo/gc/GarbageCollectionEnvironment.java | 2 +- .../apache/accumulo/gc/SimpleGarbageCollector.java | 16 - .../src/main/spotbugs/exclude-filter.xml | 5 --- .../apache/accumulo/gc/GarbageCollectionTest.java | 4 +-- .../manager/src/main/spotbugs/exclude-filter.xml | 5 --- .../shell/commands/ListTabletsCommand.java | 34 +- .../src/main/spotbugs/exclude-filter.xml | 5 --- 10 files changed, 71 insertions(+), 81 deletions(-) diff --git a/core/src/test/java/org/apache/accumulo/core/clientImpl/ScannerImplTest.java b/core/src/test/java/org/apache/accumulo/core/clientImpl/ScannerImplTest.java index e5b9c2c..1e21474 100644 --- a/core/src/test/java/org/apache/accumulo/core/clientImpl/ScannerImplTest.java +++ b/core/src/test/java/org/apache/accumulo/core/clientImpl/ScannerImplTest.java @@ -19,8 +19,8 @@ package org.apache.accumulo.core.clientImpl; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; -import org.apache.accumulo.core.client.Scanner; import org.apache.accumulo.core.data.TableId; import org.apache.accumulo.core.security.Authorizations; import org.easymock.EasyMock; @@ -38,34 +38,34 @@ public class ScannerImplTest { @Test public void testValidReadaheadValues() { -Scanner s = new ScannerImpl(context, TableId.of("foo"), Authorizations.EMPTY); -s.setReadaheadThreshold(0); -s.setReadaheadThreshold(10); -s.setReadaheadThreshold(Long.MAX_VALUE); +try (var s = new ScannerImpl(context, TableId.of("foo"), Authorizations.EMPTY)) { + s.setReadaheadThreshold(0); + s.setReadaheadThreshold(10); + s.setReadaheadThreshold(Long.MAX_VALUE); -assertEquals(Long.MAX_VALUE, s.getReadaheadThreshold()); -s.close(); + assertEquals(Long.MAX_VALUE, s.getReadaheadThreshold()); +} } - @Test(expected = IllegalArgumentException.class) + @Test public void testInValidReadaheadValues() { -Scanner s = new ScannerImpl(context, TableId.of("foo"), Authorizations.EMPTY); -s.setReadaheadThreshold(-1); -s.close(); +try (var s = new ScannerImpl(context, TableId.of("foo"), Authorizations.EMPTY)) { + assertThrows(IllegalArgumentException.class, () -> s.setReadaheadThreshold(-1)); +} } @Test public void testGetAuthorizations() { Authorizations expected = new Authorizations("a,b"); -Scanner s = new ScannerImpl(context, TableId.of("foo"), expected); -assertEquals(expected, s.getAuthorizations()); -s.close(); +try (var s = new ScannerImpl(context, TableId.of("foo"), expected)) { + assertEquals(expected, s.getAuthorizations()); +} } - @SuppressWarnings("resource") - @Test(expected = IllegalArgumentException.class) + @Test public void testNullAuthorizationsFails() { -new ScannerImpl(context, TableId.of("foo"), null); +assertThrows(IllegalArgumentException.class, +() -> new ScannerImpl(context, TableId.of("foo"), null)); } } diff --git a/core/src/test/java/org/apache/accumulo/core/clientImpl/TabletServerBatchReaderTest.java b/core/src/test/java/org/apache/accumulo/core/clientImpl/TabletServerBatchReaderTest.java index 7a78b29..33e3405 100644 ---
[accumulo] branch main updated: Create listtablets shell command. Closes #1317 (#1821)
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 376910e Create listtablets shell command. Closes #1317 (#1821) 376910e is described below commit 376910eb26e51d7361f3852705a954ad998e4c6b Author: Mike Miller AuthorDate: Mon Jan 4 15:16:08 2021 -0500 Create listtablets shell command. Closes #1317 (#1821) * New command for debugging tablets called listtablets * Added getLiveTServers() to TabletMetadata for generating a list of tservers that currently have a lock in ZK, similar to master. * The list of live tservers is passed to TabletMetadata in order to get the current state of a tablet * Command will print one line for every tablet in a table * Created TabletMetadataIT for testing getLiveTServers() Co-authored-by: EdColeman --- .../core/metadata/schema/TabletMetadata.java | 48 +++ .../main/java/org/apache/accumulo/shell/Shell.java | 8 +- .../shell/commands/ListTabletsCommand.java | 447 + .../shell/commands/ListTabletsCommandTest.java | 193 + .../accumulo/test/functional/TabletMetadataIT.java | 78 5 files changed, 771 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/org/apache/accumulo/core/metadata/schema/TabletMetadata.java b/core/src/main/java/org/apache/accumulo/core/metadata/schema/TabletMetadata.java index 8be6cbd..1286fce 100644 --- a/core/src/main/java/org/apache/accumulo/core/metadata/schema/TabletMetadata.java +++ b/core/src/main/java/org/apache/accumulo/core/metadata/schema/TabletMetadata.java @@ -18,6 +18,7 @@ */ package org.apache.accumulo.core.metadata.schema; +import static java.nio.charset.StandardCharsets.UTF_8; import static org.apache.accumulo.core.metadata.schema.MetadataSchema.TabletsSection.SuspendLocationColumn; import static org.apache.accumulo.core.metadata.schema.MetadataSchema.TabletsSection.ServerColumnFamily.COMPACT_QUAL; import static org.apache.accumulo.core.metadata.schema.MetadataSchema.TabletsSection.ServerColumnFamily.DIRECTORY_QUAL; @@ -29,18 +30,22 @@ import static org.apache.accumulo.core.metadata.schema.MetadataSchema.TabletsSec import java.util.Collection; import java.util.EnumSet; +import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Objects; +import java.util.Optional; import java.util.OptionalLong; import java.util.Set; import java.util.SortedMap; import java.util.function.Function; +import org.apache.accumulo.core.Constants; import org.apache.accumulo.core.client.RowIterator; import org.apache.accumulo.core.client.Scanner; +import org.apache.accumulo.core.clientImpl.ClientContext; import org.apache.accumulo.core.data.ByteSequence; import org.apache.accumulo.core.data.Key; import org.apache.accumulo.core.data.Range; @@ -65,7 +70,12 @@ import org.apache.accumulo.core.metadata.schema.MetadataSchema.TabletsSection.Se import org.apache.accumulo.core.metadata.schema.MetadataSchema.TabletsSection.TabletColumnFamily; import org.apache.accumulo.core.tabletserver.log.LogEntry; import org.apache.accumulo.core.util.HostAndPort; +import org.apache.accumulo.core.util.ServerServices; +import org.apache.accumulo.fate.zookeeper.ZooCache; +import org.apache.accumulo.fate.zookeeper.ZooLock; import org.apache.hadoop.io.Text; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Preconditions; @@ -75,6 +85,7 @@ import com.google.common.collect.ImmutableSortedMap; import com.google.common.collect.Iterators; public class TabletMetadata { + private static final Logger log = LoggerFactory.getLogger(TabletMetadata.class); private TableId tableId; private Text prevEndRow; @@ -435,4 +446,41 @@ public class TabletMetadata { te.fetchedCols = EnumSet.of(ColumnType.PREV_ROW); return te; } + + /** + * Get the tservers that are live from ZK. Live servers will have a valid ZooLock. This method was + * pulled from org.apache.accumulo.server.master.LiveTServerSet + */ + public static synchronized Set getLiveTServers(ClientContext context) { +final Set liveServers = new HashSet<>(); + +final String path = context.getZooKeeperRoot() + Constants.ZTSERVERS; + +for (String child : context.getZooCache().getChildren(path)) { + checkServer(context, path, child).ifPresent(liveServers::add); +} +log.trace("Found {} live tservers at ZK path: {}", liveServers.size(), path); + +return liveServers; + } + + /** + * Check for tserver ZooLock at the ZK location. Return Optional containing TServerInstance if a + * valid Zoolock exists. + */ + private static Optional checkServer(ClientContext
[accumulo] branch main updated: Re #1841 Add timeout to ConcurrentDeleteTableIT
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 dd637c3 Re #1841 Add timeout to ConcurrentDeleteTableIT dd637c3 is described below commit dd637c350b388e31aadad85f3616f6f0a1d07272 Author: Dom G <47725857+domgargu...@users.noreply.github.com> AuthorDate: Mon Jan 4 11:12:20 2021 -0500 Re #1841 Add timeout to ConcurrentDeleteTableIT * added a default 7min timeout --- .../org/apache/accumulo/test/functional/ConcurrentDeleteTableIT.java | 5 + 1 file changed, 5 insertions(+) diff --git a/test/src/main/java/org/apache/accumulo/test/functional/ConcurrentDeleteTableIT.java b/test/src/main/java/org/apache/accumulo/test/functional/ConcurrentDeleteTableIT.java index ab16085..0d489fe 100644 --- a/test/src/main/java/org/apache/accumulo/test/functional/ConcurrentDeleteTableIT.java +++ b/test/src/main/java/org/apache/accumulo/test/functional/ConcurrentDeleteTableIT.java @@ -52,6 +52,11 @@ import org.junit.Test; public class ConcurrentDeleteTableIT extends AccumuloClusterHarness { + @Override + protected int defaultTimeoutSeconds() { +return 7 * 60; + } + @Test public void testConcurrentDeleteTablesOps() throws Exception { try (AccumuloClient c = Accumulo.newClient().from(getClientProps()).build()) {