You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@accumulo.apache.org by "jmark99 (via GitHub)" <gi...@apache.org> on 2023/07/21 16:26:02 UTC
[GitHub] [accumulo] jmark99 opened a new pull request, #3645: Create getTabletInformation API method
jmark99 opened a new pull request, #3645:
URL: https://github.com/apache/accumulo/pull/3645
This PR creates a new public API method, `getTabletInformation`, which returns a stream of `TabletInformation` objects containing information for each tablet within a provided table. The method can be accessed from the code or `JShell` via the `TableOperations` object.
A new `TabletInformation` class is used to hold information for an individual tablet.
The `listtablets` command has been modified to use this new method rather than using non-public API. The `ListTabletsCommandTest` was updated to reflect the new method. A new IT test has been added to `ShellServerIT` which tests `listtablets` and effectively tests the new API since the method is used to obtain the information for `listtablets`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [accumulo] ctubbsii commented on a diff in pull request #3645: Create getTabletInformation API method
Posted by "ctubbsii (via GitHub)" <gi...@apache.org>.
ctubbsii commented on code in PR #3645:
URL: https://github.com/apache/accumulo/pull/3645#discussion_r1291615500
##########
core/src/main/java/org/apache/accumulo/core/client/admin/TableOperations.java:
##########
@@ -1034,4 +1034,14 @@ default Stream<HostingGoalForTablet> getTabletHostingGoal(final String tableName
throw new UnsupportedOperationException();
}
+ /**
+ * @return a stream of tablets information for tablets that fall in the specified range. The
+ * stream may be backed by a scanner, so its best to close the stream.
Review Comment:
This should be `it is` or `it's`, not the possessive `its`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [accumulo] jmark99 commented on a diff in pull request #3645: Create getTabletInformation API method
Posted by "jmark99 (via GitHub)" <gi...@apache.org>.
jmark99 commented on code in PR #3645:
URL: https://github.com/apache/accumulo/pull/3645#discussion_r1276646752
##########
core/src/main/java/org/apache/accumulo/core/clientImpl/TableOperationsImpl.java:
##########
@@ -2162,12 +2172,54 @@ public Stream<HostingGoalForTablet> getTabletHostingGoal(final String tableName,
return tabletsMetadata.stream().peek(tm -> {
if (scanRangeStart != null && tm.getEndRow() != null
&& tm.getEndRow().compareTo(scanRangeStart) < 0) {
- log.debug(">>>> tablet {} is before scan start range: {}", tm.getExtent(), scanRangeStart);
+ log.debug("tablet {} is before scan start range: {}", tm.getExtent(), scanRangeStart);
throw new RuntimeException("Bug in ample or this code.");
}
}).takeWhile(tm -> tm.getPrevEndRow() == null
|| !range.afterEndKey(new Key(tm.getPrevEndRow()).followingKey(PartialKey.ROW)))
.map(tm -> new HostingGoalForTablet(new TabletIdImpl(tm.getExtent()), tm.getHostingGoal()))
.onClose(tabletsMetadata::close);
}
+
+ @Override
+ public Stream<TabletInformation> getTabletInformation(final String tableName, final Range range)
+ throws TableNotFoundException {
+ EXISTING_TABLE_NAME.validate(tableName);
+
+ final Text scanRangeStart = (range.getStartKey() == null) ? null : range.getStartKey().getRow();
+ TableId tableId = context.getTableId(tableName);
+
+ TabletsMetadata tabletsMetadata =
+ context.getAmple().readTablets().forTable(tableId).overlapping(scanRangeStart, true, null)
+ .fetch(HOSTING_GOAL, LOCATION, DIR, PREV_ROW, FILES, LAST, LOGS, SUSPEND)
+ .checkConsistency().build();
+
+ Set<TServerInstance> liveTserverSet = TabletMetadata.getLiveTServers(context);
+ long[] numEntries = new long[1];
+ long[] size = new long[1];
+ return tabletsMetadata.stream().peek(tm -> {
+ if (scanRangeStart != null && tm.getEndRow() != null
+ && tm.getEndRow().compareTo(scanRangeStart) < 0) {
+ log.debug("tablet {} is before scan start range: {}", tm.getExtent(), scanRangeStart);
+ throw new RuntimeException("Bug in ample or this code.");
+ }
+ numEntries[0] = 0;
+ size[0] = 0;
+ for (DataFileValue dfv : tm.getFilesMap().values()) {
+ numEntries[0] = dfv.getNumEntries();
+ size[0] += dfv.getSize();
+ }
Review Comment:
Moved to the constructor of the new TabletInformationImpl class.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [accumulo] jmark99 commented on a diff in pull request #3645: Create getTabletInformation API method
Posted by "jmark99 (via GitHub)" <gi...@apache.org>.
jmark99 commented on code in PR #3645:
URL: https://github.com/apache/accumulo/pull/3645#discussion_r1272328621
##########
core/src/main/java/org/apache/accumulo/core/client/admin/TabletInformation.java:
##########
@@ -0,0 +1,159 @@
+/*
+ * 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
+ *
+ * https://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.core.client.admin;
+
+import java.util.Objects;
+
+import org.apache.accumulo.core.data.TableId;
+import org.apache.accumulo.core.util.NumUtil;
+
+public class TabletInformation {
+
+ private final String tableName;
+ private final String endRow;
+ private final String prevEndRow;
+ private final int numFiles;
+ private final int numWalLogs;
+ private final long numEntries;
+ private final long size;
+ private final String status;
+ private final String location;
+ private final String dir;
+ private final TableId tableId;
+ private final TabletHostingGoal goal;
+
+ public TabletInformation(String tableName, TableId tableId, String endRow, String prevEndRow,
+ int numFiles, int numWalLogs, long numEntries, long size, String status, String location,
+ String dir, TabletHostingGoal goal) {
+ this.tableName = tableName;
+ this.tableId = tableId;
+ this.endRow = endRow;
+ this.prevEndRow = prevEndRow;
+ this.numFiles = numFiles;
+ this.numWalLogs = numWalLogs;
+ this.numEntries = numEntries;
+ this.size = size;
+ this.status = status;
+ this.location = location;
+ this.dir = dir;
+ this.goal = goal;
+ }
Review Comment:
@keith-turner The issue I run into when attempting this is that it will not compile due to TabletMetadata being a non-public API reference in a public class. The apilyzer maven check prevents the build. Do you know of an alternative means where the same objective could be met? I had run into this earlier when attempting to use KeyExtent. I had to re-work to avoid that same issue as well.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [accumulo] jmark99 commented on a diff in pull request #3645: Create getTabletInformation API method
Posted by "jmark99 (via GitHub)" <gi...@apache.org>.
jmark99 commented on code in PR #3645:
URL: https://github.com/apache/accumulo/pull/3645#discussion_r1276642122
##########
core/src/main/java/org/apache/accumulo/core/client/admin/TabletInformation.java:
##########
@@ -0,0 +1,159 @@
+/*
+ * 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
+ *
+ * https://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.core.client.admin;
+
+import java.util.Objects;
+
+import org.apache.accumulo.core.data.TableId;
+import org.apache.accumulo.core.util.NumUtil;
+
+public class TabletInformation {
+
+ private final String tableName;
+ private final String endRow;
+ private final String prevEndRow;
+ private final int numFiles;
+ private final int numWalLogs;
+ private final long numEntries;
+ private final long size;
+ private final String status;
+ private final String location;
+ private final String dir;
+ private final TableId tableId;
+ private final TabletHostingGoal goal;
+
+ public TabletInformation(String tableName, TableId tableId, String endRow, String prevEndRow,
+ int numFiles, int numWalLogs, long numEntries, long size, String status, String location,
+ String dir, TabletHostingGoal goal) {
+ this.tableName = tableName;
+ this.tableId = tableId;
+ this.endRow = endRow;
+ this.prevEndRow = prevEndRow;
+ this.numFiles = numFiles;
+ this.numWalLogs = numWalLogs;
+ this.numEntries = numEntries;
+ this.size = size;
+ this.status = status;
+ this.location = location;
+ this.dir = dir;
+ this.goal = goal;
+ }
+
+ public String getEndRow() {
+ return Objects.requireNonNullElse(this.endRow, "+INF");
+ }
+
+ public String getStartRow() {
+ return Objects.requireNonNullElse(this.prevEndRow, "-INF");
+ }
+
+ public String getTableId() {
+ return tableId.canonical();
+ }
+
+ public String getTablet() {
+ return getStartRow() + " " + getEndRow();
+ }
+
+ public String getTableName() {
+ return this.tableName;
+ }
+
+ public int getNumFiles() {
+ return this.numFiles;
+ }
+
+ public int getNumWalLogs() {
+ return this.numWalLogs;
+ }
+
+ public long getNumEntries() {
+ return this.numEntries;
+ }
+
+ public String getNumEntries(final boolean humanReadable) {
+ if (humanReadable) {
+ return NumUtil.bigNumberForQuantity(numEntries);
+ }
+ return String.format("%,d", numEntries);
+ }
+
+ public long getSize() {
+ return this.size;
+ }
+
+ public String getSize(final boolean humanReadable) {
+ if (humanReadable) {
+ return NumUtil.bigNumberForSize(size);
+ }
+ return String.format("%,d", size);
+ }
+
+ public String getStatus() {
+ return this.status;
+ }
+
+ public String getLocation() {
+ return this.location;
+ }
+
+ public String getTabletDir() {
+ return this.dir;
+ }
+
+ public TabletHostingGoal getHostingGoal() {
+ return this.goal;
+ }
+
+ @Override
+ public String toString() {
+ return "TabletInformation{tableName='" + tableName + '\'' + ", numFiles=" + numFiles
+ + ", numWalLogs=" + numWalLogs + ", numEntries=" + numEntries + ", size=" + size
+ + ", status='" + status + '\'' + ", location='" + location + '\'' + ", dir='" + dir + '\''
+ + ", tableId=" + tableId + ", tablet=" + getTablet() + ", goal=" + goal + '}';
+ }
+
+ public static final String header =
Review Comment:
Yes. It has been moved.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [accumulo] jmark99 commented on a diff in pull request #3645: Create getTabletInformation API method
Posted by "jmark99 (via GitHub)" <gi...@apache.org>.
jmark99 commented on code in PR #3645:
URL: https://github.com/apache/accumulo/pull/3645#discussion_r1276641290
##########
core/src/main/java/org/apache/accumulo/core/client/admin/TabletInformation.java:
##########
@@ -0,0 +1,159 @@
+/*
+ * 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
+ *
+ * https://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.core.client.admin;
+
+import java.util.Objects;
+
+import org.apache.accumulo.core.data.TableId;
+import org.apache.accumulo.core.util.NumUtil;
+
+public class TabletInformation {
+
+ private final String tableName;
+ private final String endRow;
+ private final String prevEndRow;
+ private final int numFiles;
+ private final int numWalLogs;
+ private final long numEntries;
+ private final long size;
+ private final String status;
+ private final String location;
+ private final String dir;
+ private final TableId tableId;
+ private final TabletHostingGoal goal;
+
+ public TabletInformation(String tableName, TableId tableId, String endRow, String prevEndRow,
+ int numFiles, int numWalLogs, long numEntries, long size, String status, String location,
+ String dir, TabletHostingGoal goal) {
+ this.tableName = tableName;
+ this.tableId = tableId;
+ this.endRow = endRow;
+ this.prevEndRow = prevEndRow;
+ this.numFiles = numFiles;
+ this.numWalLogs = numWalLogs;
+ this.numEntries = numEntries;
+ this.size = size;
+ this.status = status;
+ this.location = location;
+ this.dir = dir;
+ this.goal = goal;
+ }
+
+ public String getEndRow() {
+ return Objects.requireNonNullElse(this.endRow, "+INF");
+ }
+
+ public String getStartRow() {
+ return Objects.requireNonNullElse(this.prevEndRow, "-INF");
+ }
+
+ public String getTableId() {
+ return tableId.canonical();
+ }
+
+ public String getTablet() {
+ return getStartRow() + " " + getEndRow();
+ }
+
+ public String getTableName() {
+ return this.tableName;
+ }
+
+ public int getNumFiles() {
+ return this.numFiles;
+ }
+
+ public int getNumWalLogs() {
+ return this.numWalLogs;
+ }
+
+ public long getNumEntries() {
Review Comment:
Renamed as suggested.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [accumulo] keith-turner commented on a diff in pull request #3645: Create getTabletInformation API method
Posted by "keith-turner (via GitHub)" <gi...@apache.org>.
keith-turner commented on code in PR #3645:
URL: https://github.com/apache/accumulo/pull/3645#discussion_r1277776558
##########
core/src/main/java/org/apache/accumulo/core/client/admin/TabletInformation.java:
##########
@@ -18,142 +18,74 @@
*/
package org.apache.accumulo.core.client.admin;
-import java.util.Objects;
+import java.util.Optional;
import org.apache.accumulo.core.data.TableId;
-import org.apache.accumulo.core.util.NumUtil;
-
-public class TabletInformation {
-
- private final String tableName;
- private final String endRow;
- private final String prevEndRow;
- private final int numFiles;
- private final int numWalLogs;
- private final long numEntries;
- private final long size;
- private final String status;
- private final String location;
- private final String dir;
- private final TableId tableId;
- private final TabletHostingGoal goal;
-
- public TabletInformation(String tableName, TableId tableId, String endRow, String prevEndRow,
- int numFiles, int numWalLogs, long numEntries, long size, String status, String location,
- String dir, TabletHostingGoal goal) {
- this.tableName = tableName;
- this.tableId = tableId;
- this.endRow = endRow;
- this.prevEndRow = prevEndRow;
- this.numFiles = numFiles;
- this.numWalLogs = numWalLogs;
- this.numEntries = numEntries;
- this.size = size;
- this.status = status;
- this.location = location;
- this.dir = dir;
- this.goal = goal;
- }
-
- public String getEndRow() {
- return Objects.requireNonNullElse(this.endRow, "+INF");
- }
-
- public String getStartRow() {
- return Objects.requireNonNullElse(this.prevEndRow, "-INF");
- }
-
- public String getTableId() {
- return tableId.canonical();
- }
-
- public String getTablet() {
- return getStartRow() + " " + getEndRow();
- }
-
- public String getTableName() {
- return this.tableName;
- }
-
- public int getNumFiles() {
- return this.numFiles;
- }
-
- public int getNumWalLogs() {
- return this.numWalLogs;
- }
-
- public long getNumEntries() {
- return this.numEntries;
- }
-
- public String getNumEntries(final boolean humanReadable) {
- if (humanReadable) {
- return NumUtil.bigNumberForQuantity(numEntries);
- }
- return String.format("%,d", numEntries);
- }
-
- public long getSize() {
- return this.size;
- }
-
- public String getSize(final boolean humanReadable) {
- if (humanReadable) {
- return NumUtil.bigNumberForSize(size);
- }
- return String.format("%,d", size);
- }
-
- public String getStatus() {
- return this.status;
- }
-
- public String getLocation() {
- return this.location;
- }
-
- public String getTabletDir() {
- return this.dir;
- }
-
- public TabletHostingGoal getHostingGoal() {
- return this.goal;
- }
-
- @Override
- public String toString() {
- return "TabletInformation{tableName='" + tableName + '\'' + ", numFiles=" + numFiles
- + ", numWalLogs=" + numWalLogs + ", numEntries=" + numEntries + ", size=" + size
- + ", status='" + status + '\'' + ", location='" + location + '\'' + ", dir='" + dir + '\''
- + ", tableId=" + tableId + ", tablet=" + getTablet() + ", goal=" + goal + '}';
- }
-
- public static final String header =
- String.format("%-4s %-15s %-5s %-5s %-9s %-9s %-10s %-30s %-5s %-20s %-20s %-10s", "NUM",
- "TABLET_DIR", "FILES", "WALS", "ENTRIES", "SIZE", "STATUS", "LOCATION", "ID",
- "START (Exclusive)", "END", "GOAL");
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
- TabletInformation that = (TabletInformation) o;
- return numFiles == that.numFiles && numWalLogs == that.numWalLogs
- && numEntries == that.numEntries && size == that.size
- && Objects.equals(tableName, that.tableName) && Objects.equals(endRow, that.endRow)
- && Objects.equals(prevEndRow, that.prevEndRow) && Objects.equals(status, that.status)
- && Objects.equals(location, that.location) && Objects.equals(dir, that.dir)
- && Objects.equals(tableId, that.tableId) && goal == that.goal;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(tableName, endRow, prevEndRow, numFiles, numWalLogs, numEntries, size,
- status, location, dir, tableId, goal);
- }
+import org.apache.accumulo.core.data.TabletId;
+import org.apache.accumulo.core.metadata.schema.TabletMetadata.Location;
+import org.apache.hadoop.io.Text;
+
+public interface TabletInformation {
+
+ /**
+ * @return the TableId of the table containing this tablet.
+ */
+ TableId getTableId();
+
+ /**
+ * @return the TabletId for this tablet.
+ */
+ TabletId getTabletId();
+
+ /**
+ * @return the tablet end row.
+ */
+ Text getEndRow();
+
+ /**
+ * @return the previous end row.
+ */
+ Text getStartRow();
+
+ /**
+ * @return the number of files in the tablet directory.
+ */
+ int getNumFiles();
+
+ /**
+ * @return the number of write-ahead logs associated with the tablet.
+ */
+ int getNumWalLogs();
+
+ /**
+ * @return an estimated number of entries in the tablet.
+ */
+ long getEstimatedEntries();
+
+ /**
+ * @return an estimated size of the tablet data on disk, which is likely the compressed size of
+ * the data.
+ */
+ long getEstimatedSize();
+
+ /**
+ * @return the tablet hosting state.
+ */
+ String getTabletState();
+
+ /**
+ * @return the Location of the tablet.
+ */
+ Optional<Location> getLocation();
Review Comment:
Maybe apilyzer did not catch it because its a type parameter
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [accumulo] keith-turner commented on a diff in pull request #3645: Create getTabletInformation API method
Posted by "keith-turner (via GitHub)" <gi...@apache.org>.
keith-turner commented on code in PR #3645:
URL: https://github.com/apache/accumulo/pull/3645#discussion_r1278205805
##########
core/src/main/java/org/apache/accumulo/core/clientImpl/TabletInformationImpl.java:
##########
@@ -0,0 +1,122 @@
+/*
+ * 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
+ *
+ * https://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.core.clientImpl;
+
+import java.util.Objects;
+import java.util.Optional;
+
+import org.apache.accumulo.core.client.admin.TabletHostingGoal;
+import org.apache.accumulo.core.client.admin.TabletInformation;
+import org.apache.accumulo.core.data.TabletId;
+import org.apache.accumulo.core.dataImpl.TabletIdImpl;
+import org.apache.accumulo.core.metadata.schema.DataFileValue;
+import org.apache.accumulo.core.metadata.schema.TabletMetadata;
+import org.apache.accumulo.core.metadata.schema.TabletMetadata.Location;
+
+public class TabletInformationImpl implements TabletInformation {
+
+ private final TabletMetadata tabletMetadata;
+ private long estimatedSize;
+ private long estimatedEntries;
+ private final String tabletState;
+
+ public TabletInformationImpl(TabletMetadata tabletMetadata, String tabletState) {
+ this.tabletMetadata = tabletMetadata;
+ estimatedEntries = 0L;
+ estimatedSize = 0L;
+ for (DataFileValue dfv : tabletMetadata.getFilesMap().values()) {
+ estimatedEntries += dfv.getNumEntries();
+ estimatedSize += dfv.getSize();
+ }
+ this.tabletState = tabletState;
+ }
+
+ @Override
+ public TabletId getTabletId() {
+ return new TabletIdImpl(tabletMetadata.getExtent());
+ }
+
+ @Override
+ public int getNumFiles() {
+ return tabletMetadata.getFilesMap().size();
+ }
+
+ @Override
+ public int getNumWalLogs() {
+ return tabletMetadata.getLogs().size();
+ }
+
+ @Override
+ public long getEstimatedEntries() {
+ return this.estimatedEntries;
+ }
+
+ @Override
+ public long getEstimatedSize() {
+ return estimatedSize;
+ }
+
+ @Override
+ public String getTabletState() {
+ return tabletState;
+ }
+
+ @Override
+ public Optional<String> getLocation() {
+ Location location = tabletMetadata.getLocation();
+ return location == null ? Optional.empty()
+ : Optional.of(location.getType() + ":" + location.getHostPort());
+ }
+
+ @Override
+ public String getTabletDir() {
+ return tabletMetadata.getDirName();
+ }
+
+ @Override
+ public TabletHostingGoal getHostingGoal() {
+ return tabletMetadata.getHostingGoal();
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ TabletInformationImpl that = (TabletInformationImpl) o;
+ return estimatedSize == that.estimatedSize && estimatedEntries == that.estimatedEntries
+ && Objects.equals(tabletMetadata, that.tabletMetadata)
Review Comment:
TabletMetadata does not have an equals method. I would not implement equals and hashcode for this class. Anyone using this will be using the interface and its not really good practice to make any assumptions about the hashcode and equals when one only has an interface.
##########
core/src/main/java/org/apache/accumulo/core/client/admin/TableOperations.java:
##########
@@ -1034,4 +1035,13 @@ default Stream<HostingGoalForTablet> getTabletHostingGoal(final String tableName
throw new UnsupportedOperationException();
}
+ /**
+ * @return a stream of tablets information for tablets that fall in the specified range
+ * @since 4.0.0
+ */
+ default Stream<TabletInformationImpl> getTabletInformation(final String tableName,
Review Comment:
This should return the public API type
```suggestion
default Stream<TabletInformation> getTabletInformation(final String tableName,
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [accumulo] jmark99 commented on a diff in pull request #3645: Create getTabletInformation API method
Posted by "jmark99 (via GitHub)" <gi...@apache.org>.
jmark99 commented on code in PR #3645:
URL: https://github.com/apache/accumulo/pull/3645#discussion_r1276646083
##########
core/src/main/java/org/apache/accumulo/core/client/admin/TabletInformation.java:
##########
@@ -0,0 +1,159 @@
+/*
+ * 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
+ *
+ * https://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.core.client.admin;
+
+import java.util.Objects;
+
+import org.apache.accumulo.core.data.TableId;
+import org.apache.accumulo.core.util.NumUtil;
+
+public class TabletInformation {
+
+ private final String tableName;
+ private final String endRow;
+ private final String prevEndRow;
+ private final int numFiles;
+ private final int numWalLogs;
+ private final long numEntries;
+ private final long size;
+ private final String status;
+ private final String location;
+ private final String dir;
+ private final TableId tableId;
+ private final TabletHostingGoal goal;
+
+ public TabletInformation(String tableName, TableId tableId, String endRow, String prevEndRow,
+ int numFiles, int numWalLogs, long numEntries, long size, String status, String location,
+ String dir, TabletHostingGoal goal) {
+ this.tableName = tableName;
+ this.tableId = tableId;
+ this.endRow = endRow;
+ this.prevEndRow = prevEndRow;
+ this.numFiles = numFiles;
+ this.numWalLogs = numWalLogs;
+ this.numEntries = numEntries;
+ this.size = size;
+ this.status = status;
+ this.location = location;
+ this.dir = dir;
+ this.goal = goal;
+ }
+
+ public String getEndRow() {
+ return Objects.requireNonNullElse(this.endRow, "+INF");
+ }
+
+ public String getStartRow() {
+ return Objects.requireNonNullElse(this.prevEndRow, "-INF");
+ }
+
+ public String getTableId() {
+ return tableId.canonical();
+ }
+
+ public String getTablet() {
+ return getStartRow() + " " + getEndRow();
+ }
+
+ public String getTableName() {
+ return this.tableName;
+ }
+
+ public int getNumFiles() {
+ return this.numFiles;
+ }
+
+ public int getNumWalLogs() {
+ return this.numWalLogs;
+ }
+
+ public long getNumEntries() {
+ return this.numEntries;
+ }
+
+ public String getNumEntries(final boolean humanReadable) {
+ if (humanReadable) {
+ return NumUtil.bigNumberForQuantity(numEntries);
+ }
+ return String.format("%,d", numEntries);
+ }
Review Comment:
Updated the TabletInformationImpl class to return just the values so the user can then use as needed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [accumulo] keith-turner commented on a diff in pull request #3645: Create getTabletInformation API method
Posted by "keith-turner (via GitHub)" <gi...@apache.org>.
keith-turner commented on code in PR #3645:
URL: https://github.com/apache/accumulo/pull/3645#discussion_r1289414827
##########
core/src/main/java/org/apache/accumulo/core/client/admin/TableOperations.java:
##########
@@ -1034,4 +1034,13 @@ default Stream<HostingGoalForTablet> getTabletHostingGoal(final String tableName
throw new UnsupportedOperationException();
}
+ /**
+ * @return a stream of tablets information for tablets that fall in the specified range
Review Comment:
```suggestion
* @return a stream of tablets information for tablets that fall in the specified range. The stream may be backed by a scanner, so its best to close the stream.
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [accumulo] jmark99 commented on a diff in pull request #3645: Create getTabletInformation API method
Posted by "jmark99 (via GitHub)" <gi...@apache.org>.
jmark99 commented on code in PR #3645:
URL: https://github.com/apache/accumulo/pull/3645#discussion_r1277709601
##########
core/src/main/java/org/apache/accumulo/core/client/admin/TabletInformation.java:
##########
@@ -18,142 +18,74 @@
*/
package org.apache.accumulo.core.client.admin;
-import java.util.Objects;
+import java.util.Optional;
import org.apache.accumulo.core.data.TableId;
-import org.apache.accumulo.core.util.NumUtil;
-
-public class TabletInformation {
-
- private final String tableName;
- private final String endRow;
- private final String prevEndRow;
- private final int numFiles;
- private final int numWalLogs;
- private final long numEntries;
- private final long size;
- private final String status;
- private final String location;
- private final String dir;
- private final TableId tableId;
- private final TabletHostingGoal goal;
-
- public TabletInformation(String tableName, TableId tableId, String endRow, String prevEndRow,
- int numFiles, int numWalLogs, long numEntries, long size, String status, String location,
- String dir, TabletHostingGoal goal) {
- this.tableName = tableName;
- this.tableId = tableId;
- this.endRow = endRow;
- this.prevEndRow = prevEndRow;
- this.numFiles = numFiles;
- this.numWalLogs = numWalLogs;
- this.numEntries = numEntries;
- this.size = size;
- this.status = status;
- this.location = location;
- this.dir = dir;
- this.goal = goal;
- }
-
- public String getEndRow() {
- return Objects.requireNonNullElse(this.endRow, "+INF");
- }
-
- public String getStartRow() {
- return Objects.requireNonNullElse(this.prevEndRow, "-INF");
- }
-
- public String getTableId() {
- return tableId.canonical();
- }
-
- public String getTablet() {
- return getStartRow() + " " + getEndRow();
- }
-
- public String getTableName() {
- return this.tableName;
- }
-
- public int getNumFiles() {
- return this.numFiles;
- }
-
- public int getNumWalLogs() {
- return this.numWalLogs;
- }
-
- public long getNumEntries() {
- return this.numEntries;
- }
-
- public String getNumEntries(final boolean humanReadable) {
- if (humanReadable) {
- return NumUtil.bigNumberForQuantity(numEntries);
- }
- return String.format("%,d", numEntries);
- }
-
- public long getSize() {
- return this.size;
- }
-
- public String getSize(final boolean humanReadable) {
- if (humanReadable) {
- return NumUtil.bigNumberForSize(size);
- }
- return String.format("%,d", size);
- }
-
- public String getStatus() {
- return this.status;
- }
-
- public String getLocation() {
- return this.location;
- }
-
- public String getTabletDir() {
- return this.dir;
- }
-
- public TabletHostingGoal getHostingGoal() {
- return this.goal;
- }
-
- @Override
- public String toString() {
- return "TabletInformation{tableName='" + tableName + '\'' + ", numFiles=" + numFiles
- + ", numWalLogs=" + numWalLogs + ", numEntries=" + numEntries + ", size=" + size
- + ", status='" + status + '\'' + ", location='" + location + '\'' + ", dir='" + dir + '\''
- + ", tableId=" + tableId + ", tablet=" + getTablet() + ", goal=" + goal + '}';
- }
-
- public static final String header =
- String.format("%-4s %-15s %-5s %-5s %-9s %-9s %-10s %-30s %-5s %-20s %-20s %-10s", "NUM",
- "TABLET_DIR", "FILES", "WALS", "ENTRIES", "SIZE", "STATUS", "LOCATION", "ID",
- "START (Exclusive)", "END", "GOAL");
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
- TabletInformation that = (TabletInformation) o;
- return numFiles == that.numFiles && numWalLogs == that.numWalLogs
- && numEntries == that.numEntries && size == that.size
- && Objects.equals(tableName, that.tableName) && Objects.equals(endRow, that.endRow)
- && Objects.equals(prevEndRow, that.prevEndRow) && Objects.equals(status, that.status)
- && Objects.equals(location, that.location) && Objects.equals(dir, that.dir)
- && Objects.equals(tableId, that.tableId) && goal == that.goal;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(tableName, endRow, prevEndRow, numFiles, numWalLogs, numEntries, size,
- status, location, dir, tableId, goal);
- }
+import org.apache.accumulo.core.data.TabletId;
+import org.apache.accumulo.core.metadata.schema.TabletMetadata.Location;
+import org.apache.hadoop.io.Text;
+
+public interface TabletInformation {
+
+ /**
+ * @return the TableId of the table containing this tablet.
+ */
+ TableId getTableId();
+
+ /**
+ * @return the TabletId for this tablet.
+ */
+ TabletId getTabletId();
+
+ /**
+ * @return the tablet end row.
+ */
+ Text getEndRow();
+
+ /**
+ * @return the previous end row.
+ */
+ Text getStartRow();
+
+ /**
+ * @return the number of files in the tablet directory.
+ */
+ int getNumFiles();
+
+ /**
+ * @return the number of write-ahead logs associated with the tablet.
+ */
+ int getNumWalLogs();
+
+ /**
+ * @return an estimated number of entries in the tablet.
+ */
+ long getEstimatedEntries();
+
+ /**
+ * @return an estimated size of the tablet data on disk, which is likely the compressed size of
+ * the data.
+ */
+ long getEstimatedSize();
+
+ /**
+ * @return the tablet hosting state.
+ */
+ String getTabletState();
+
+ /**
+ * @return the Location of the tablet.
+ */
+ Optional<Location> getLocation();
Review Comment:
@keith-turner updated with your suggestions.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [accumulo] jmark99 commented on a diff in pull request #3645: Create getTabletInformation API method
Posted by "jmark99 (via GitHub)" <gi...@apache.org>.
jmark99 commented on code in PR #3645:
URL: https://github.com/apache/accumulo/pull/3645#discussion_r1276647774
##########
core/src/main/java/org/apache/accumulo/core/client/admin/TabletInformation.java:
##########
@@ -0,0 +1,159 @@
+/*
+ * 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
+ *
+ * https://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.core.client.admin;
+
+import java.util.Objects;
+
+import org.apache.accumulo.core.data.TableId;
+import org.apache.accumulo.core.util.NumUtil;
+
+public class TabletInformation {
+
+ private final String tableName;
+ private final String endRow;
+ private final String prevEndRow;
+ private final int numFiles;
+ private final int numWalLogs;
+ private final long numEntries;
+ private final long size;
+ private final String status;
+ private final String location;
+ private final String dir;
+ private final TableId tableId;
+ private final TabletHostingGoal goal;
+
+ public TabletInformation(String tableName, TableId tableId, String endRow, String prevEndRow,
+ int numFiles, int numWalLogs, long numEntries, long size, String status, String location,
+ String dir, TabletHostingGoal goal) {
+ this.tableName = tableName;
+ this.tableId = tableId;
+ this.endRow = endRow;
+ this.prevEndRow = prevEndRow;
+ this.numFiles = numFiles;
+ this.numWalLogs = numWalLogs;
+ this.numEntries = numEntries;
+ this.size = size;
+ this.status = status;
+ this.location = location;
+ this.dir = dir;
+ this.goal = goal;
+ }
+
+ public String getEndRow() {
+ return Objects.requireNonNullElse(this.endRow, "+INF");
+ }
+
+ public String getStartRow() {
+ return Objects.requireNonNullElse(this.prevEndRow, "-INF");
+ }
+
+ public String getTableId() {
+ return tableId.canonical();
+ }
+
+ public String getTablet() {
+ return getStartRow() + " " + getEndRow();
+ }
Review Comment:
Was able to do this once the class was broken into TabletInformation and TabletInformationImpl as you suggested.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [accumulo] jmark99 commented on a diff in pull request #3645: Create getTabletInformation API method
Posted by "jmark99 (via GitHub)" <gi...@apache.org>.
jmark99 commented on code in PR #3645:
URL: https://github.com/apache/accumulo/pull/3645#discussion_r1280685371
##########
core/src/main/java/org/apache/accumulo/core/client/admin/TableOperations.java:
##########
@@ -1034,4 +1035,13 @@ default Stream<HostingGoalForTablet> getTabletHostingGoal(final String tableName
throw new UnsupportedOperationException();
}
+ /**
+ * @return a stream of tablets information for tablets that fall in the specified range
+ * @since 4.0.0
+ */
+ default Stream<TabletInformationImpl> getTabletInformation(final String tableName,
Review Comment:
@keith-turner I took your suggestion and then found that it could be simplified further by adding a cast within the lambda. I thought I had tried that before, but I must have been mistaken.
Once this PR is merged I will address the getTabletHostingGoal method that you mentioned above.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [accumulo] jmark99 merged pull request #3645: Create getTabletInformation API method
Posted by "jmark99 (via GitHub)" <gi...@apache.org>.
jmark99 merged PR #3645:
URL: https://github.com/apache/accumulo/pull/3645
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [accumulo] keith-turner commented on a diff in pull request #3645: Create getTabletInformation API method
Posted by "keith-turner (via GitHub)" <gi...@apache.org>.
keith-turner commented on code in PR #3645:
URL: https://github.com/apache/accumulo/pull/3645#discussion_r1272484527
##########
core/src/main/java/org/apache/accumulo/core/client/admin/TabletInformation.java:
##########
@@ -0,0 +1,159 @@
+/*
+ * 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
+ *
+ * https://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.core.client.admin;
+
+import java.util.Objects;
+
+import org.apache.accumulo.core.data.TableId;
+import org.apache.accumulo.core.util.NumUtil;
+
+public class TabletInformation {
+
+ private final String tableName;
+ private final String endRow;
+ private final String prevEndRow;
+ private final int numFiles;
+ private final int numWalLogs;
+ private final long numEntries;
+ private final long size;
+ private final String status;
+ private final String location;
+ private final String dir;
+ private final TableId tableId;
+ private final TabletHostingGoal goal;
+
+ public TabletInformation(String tableName, TableId tableId, String endRow, String prevEndRow,
+ int numFiles, int numWalLogs, long numEntries, long size, String status, String location,
+ String dir, TabletHostingGoal goal) {
+ this.tableName = tableName;
+ this.tableId = tableId;
+ this.endRow = endRow;
+ this.prevEndRow = prevEndRow;
+ this.numFiles = numFiles;
+ this.numWalLogs = numWalLogs;
+ this.numEntries = numEntries;
+ this.size = size;
+ this.status = status;
+ this.location = location;
+ this.dir = dir;
+ this.goal = goal;
+ }
Review Comment:
Oh interesting. One way around this is the following :
- Create a TabletInformation interface w/ all the getter methods in this class.
- Create a non public API class called TabletInformationImpl that wraps TabletMetadata. Internal code creates TabletInformationImpl and returns them when TabletInformation type is needed.
This is a similar strategy to TabletId and TabletIdImpl which wraps KeyExtent.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [accumulo] jmark99 commented on a diff in pull request #3645: Create getTabletInformation API method
Posted by "jmark99 (via GitHub)" <gi...@apache.org>.
jmark99 commented on code in PR #3645:
URL: https://github.com/apache/accumulo/pull/3645#discussion_r1276640820
##########
core/src/main/java/org/apache/accumulo/core/clientImpl/TableOperationsImpl.java:
##########
@@ -2162,12 +2172,54 @@ public Stream<HostingGoalForTablet> getTabletHostingGoal(final String tableName,
return tabletsMetadata.stream().peek(tm -> {
if (scanRangeStart != null && tm.getEndRow() != null
&& tm.getEndRow().compareTo(scanRangeStart) < 0) {
- log.debug(">>>> tablet {} is before scan start range: {}", tm.getExtent(), scanRangeStart);
+ log.debug("tablet {} is before scan start range: {}", tm.getExtent(), scanRangeStart);
throw new RuntimeException("Bug in ample or this code.");
}
}).takeWhile(tm -> tm.getPrevEndRow() == null
|| !range.afterEndKey(new Key(tm.getPrevEndRow()).followingKey(PartialKey.ROW)))
.map(tm -> new HostingGoalForTablet(new TabletIdImpl(tm.getExtent()), tm.getHostingGoal()))
.onClose(tabletsMetadata::close);
}
+
+ @Override
+ public Stream<TabletInformation> getTabletInformation(final String tableName, final Range range)
+ throws TableNotFoundException {
+ EXISTING_TABLE_NAME.validate(tableName);
+
+ final Text scanRangeStart = (range.getStartKey() == null) ? null : range.getStartKey().getRow();
+ TableId tableId = context.getTableId(tableName);
+
+ TabletsMetadata tabletsMetadata =
+ context.getAmple().readTablets().forTable(tableId).overlapping(scanRangeStart, true, null)
+ .fetch(HOSTING_GOAL, LOCATION, DIR, PREV_ROW, FILES, LAST, LOGS, SUSPEND)
+ .checkConsistency().build();
+
+ Set<TServerInstance> liveTserverSet = TabletMetadata.getLiveTServers(context);
+ long[] numEntries = new long[1];
+ long[] size = new long[1];
Review Comment:
With most recent refactoring, this is no longer an issue.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [accumulo] jmark99 commented on a diff in pull request #3645: Create getTabletInformation API method
Posted by "jmark99 (via GitHub)" <gi...@apache.org>.
jmark99 commented on code in PR #3645:
URL: https://github.com/apache/accumulo/pull/3645#discussion_r1276655629
##########
core/src/main/java/org/apache/accumulo/core/client/admin/TabletInformation.java:
##########
@@ -0,0 +1,159 @@
+/*
+ * 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
+ *
+ * https://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.core.client.admin;
+
+import java.util.Objects;
+
+import org.apache.accumulo.core.data.TableId;
+import org.apache.accumulo.core.util.NumUtil;
+
+public class TabletInformation {
+
+ private final String tableName;
+ private final String endRow;
+ private final String prevEndRow;
+ private final int numFiles;
+ private final int numWalLogs;
+ private final long numEntries;
+ private final long size;
+ private final String status;
+ private final String location;
+ private final String dir;
+ private final TableId tableId;
+ private final TabletHostingGoal goal;
+
+ public TabletInformation(String tableName, TableId tableId, String endRow, String prevEndRow,
+ int numFiles, int numWalLogs, long numEntries, long size, String status, String location,
+ String dir, TabletHostingGoal goal) {
+ this.tableName = tableName;
+ this.tableId = tableId;
+ this.endRow = endRow;
+ this.prevEndRow = prevEndRow;
+ this.numFiles = numFiles;
+ this.numWalLogs = numWalLogs;
+ this.numEntries = numEntries;
+ this.size = size;
+ this.status = status;
+ this.location = location;
+ this.dir = dir;
+ this.goal = goal;
+ }
Review Comment:
@keith-turner the onc parameter I couldn't figure out how to determine within the class itself was the TabletState value, so I pass it in with the TabletMetadata information in the constructor. If you have a suggestion as to how to avoid this please let me know.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [accumulo] keith-turner commented on a diff in pull request #3645: Create getTabletInformation API method
Posted by "keith-turner (via GitHub)" <gi...@apache.org>.
keith-turner commented on code in PR #3645:
URL: https://github.com/apache/accumulo/pull/3645#discussion_r1276808034
##########
core/src/main/java/org/apache/accumulo/core/client/admin/TabletInformation.java:
##########
@@ -18,142 +18,74 @@
*/
package org.apache.accumulo.core.client.admin;
-import java.util.Objects;
+import java.util.Optional;
import org.apache.accumulo.core.data.TableId;
-import org.apache.accumulo.core.util.NumUtil;
-
-public class TabletInformation {
-
- private final String tableName;
- private final String endRow;
- private final String prevEndRow;
- private final int numFiles;
- private final int numWalLogs;
- private final long numEntries;
- private final long size;
- private final String status;
- private final String location;
- private final String dir;
- private final TableId tableId;
- private final TabletHostingGoal goal;
-
- public TabletInformation(String tableName, TableId tableId, String endRow, String prevEndRow,
- int numFiles, int numWalLogs, long numEntries, long size, String status, String location,
- String dir, TabletHostingGoal goal) {
- this.tableName = tableName;
- this.tableId = tableId;
- this.endRow = endRow;
- this.prevEndRow = prevEndRow;
- this.numFiles = numFiles;
- this.numWalLogs = numWalLogs;
- this.numEntries = numEntries;
- this.size = size;
- this.status = status;
- this.location = location;
- this.dir = dir;
- this.goal = goal;
- }
-
- public String getEndRow() {
- return Objects.requireNonNullElse(this.endRow, "+INF");
- }
-
- public String getStartRow() {
- return Objects.requireNonNullElse(this.prevEndRow, "-INF");
- }
-
- public String getTableId() {
- return tableId.canonical();
- }
-
- public String getTablet() {
- return getStartRow() + " " + getEndRow();
- }
-
- public String getTableName() {
- return this.tableName;
- }
-
- public int getNumFiles() {
- return this.numFiles;
- }
-
- public int getNumWalLogs() {
- return this.numWalLogs;
- }
-
- public long getNumEntries() {
- return this.numEntries;
- }
-
- public String getNumEntries(final boolean humanReadable) {
- if (humanReadable) {
- return NumUtil.bigNumberForQuantity(numEntries);
- }
- return String.format("%,d", numEntries);
- }
-
- public long getSize() {
- return this.size;
- }
-
- public String getSize(final boolean humanReadable) {
- if (humanReadable) {
- return NumUtil.bigNumberForSize(size);
- }
- return String.format("%,d", size);
- }
-
- public String getStatus() {
- return this.status;
- }
-
- public String getLocation() {
- return this.location;
- }
-
- public String getTabletDir() {
- return this.dir;
- }
-
- public TabletHostingGoal getHostingGoal() {
- return this.goal;
- }
-
- @Override
- public String toString() {
- return "TabletInformation{tableName='" + tableName + '\'' + ", numFiles=" + numFiles
- + ", numWalLogs=" + numWalLogs + ", numEntries=" + numEntries + ", size=" + size
- + ", status='" + status + '\'' + ", location='" + location + '\'' + ", dir='" + dir + '\''
- + ", tableId=" + tableId + ", tablet=" + getTablet() + ", goal=" + goal + '}';
- }
-
- public static final String header =
- String.format("%-4s %-15s %-5s %-5s %-9s %-9s %-10s %-30s %-5s %-20s %-20s %-10s", "NUM",
- "TABLET_DIR", "FILES", "WALS", "ENTRIES", "SIZE", "STATUS", "LOCATION", "ID",
- "START (Exclusive)", "END", "GOAL");
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
- TabletInformation that = (TabletInformation) o;
- return numFiles == that.numFiles && numWalLogs == that.numWalLogs
- && numEntries == that.numEntries && size == that.size
- && Objects.equals(tableName, that.tableName) && Objects.equals(endRow, that.endRow)
- && Objects.equals(prevEndRow, that.prevEndRow) && Objects.equals(status, that.status)
- && Objects.equals(location, that.location) && Objects.equals(dir, that.dir)
- && Objects.equals(tableId, that.tableId) && goal == that.goal;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(tableName, endRow, prevEndRow, numFiles, numWalLogs, numEntries, size,
- status, location, dir, tableId, goal);
- }
+import org.apache.accumulo.core.data.TabletId;
+import org.apache.accumulo.core.metadata.schema.TabletMetadata.Location;
+import org.apache.hadoop.io.Text;
+
+public interface TabletInformation {
+
+ /**
+ * @return the TableId of the table containing this tablet.
+ */
+ TableId getTableId();
+
+ /**
+ * @return the TabletId for this tablet.
+ */
+ TabletId getTabletId();
+
+ /**
+ * @return the tablet end row.
+ */
+ Text getEndRow();
+
+ /**
+ * @return the previous end row.
+ */
+ Text getStartRow();
+
+ /**
+ * @return the number of files in the tablet directory.
+ */
+ int getNumFiles();
+
+ /**
+ * @return the number of write-ahead logs associated with the tablet.
+ */
+ int getNumWalLogs();
+
+ /**
+ * @return an estimated number of entries in the tablet.
+ */
+ long getEstimatedEntries();
+
+ /**
+ * @return an estimated size of the tablet data on disk, which is likely the compressed size of
+ * the data.
+ */
+ long getEstimatedSize();
+
+ /**
+ * @return the tablet hosting state.
+ */
+ String getTabletState();
+
+ /**
+ * @return the Location of the tablet.
+ */
+ Optional<Location> getLocation();
Review Comment:
Location is not a public API type. Curious if apilyzer detected this.
##########
core/src/main/java/org/apache/accumulo/core/client/admin/TabletInformation.java:
##########
@@ -18,142 +18,74 @@
*/
package org.apache.accumulo.core.client.admin;
-import java.util.Objects;
+import java.util.Optional;
import org.apache.accumulo.core.data.TableId;
-import org.apache.accumulo.core.util.NumUtil;
-
-public class TabletInformation {
-
- private final String tableName;
- private final String endRow;
- private final String prevEndRow;
- private final int numFiles;
- private final int numWalLogs;
- private final long numEntries;
- private final long size;
- private final String status;
- private final String location;
- private final String dir;
- private final TableId tableId;
- private final TabletHostingGoal goal;
-
- public TabletInformation(String tableName, TableId tableId, String endRow, String prevEndRow,
- int numFiles, int numWalLogs, long numEntries, long size, String status, String location,
- String dir, TabletHostingGoal goal) {
- this.tableName = tableName;
- this.tableId = tableId;
- this.endRow = endRow;
- this.prevEndRow = prevEndRow;
- this.numFiles = numFiles;
- this.numWalLogs = numWalLogs;
- this.numEntries = numEntries;
- this.size = size;
- this.status = status;
- this.location = location;
- this.dir = dir;
- this.goal = goal;
- }
-
- public String getEndRow() {
- return Objects.requireNonNullElse(this.endRow, "+INF");
- }
-
- public String getStartRow() {
- return Objects.requireNonNullElse(this.prevEndRow, "-INF");
- }
-
- public String getTableId() {
- return tableId.canonical();
- }
-
- public String getTablet() {
- return getStartRow() + " " + getEndRow();
- }
-
- public String getTableName() {
- return this.tableName;
- }
-
- public int getNumFiles() {
- return this.numFiles;
- }
-
- public int getNumWalLogs() {
- return this.numWalLogs;
- }
-
- public long getNumEntries() {
- return this.numEntries;
- }
-
- public String getNumEntries(final boolean humanReadable) {
- if (humanReadable) {
- return NumUtil.bigNumberForQuantity(numEntries);
- }
- return String.format("%,d", numEntries);
- }
-
- public long getSize() {
- return this.size;
- }
-
- public String getSize(final boolean humanReadable) {
- if (humanReadable) {
- return NumUtil.bigNumberForSize(size);
- }
- return String.format("%,d", size);
- }
-
- public String getStatus() {
- return this.status;
- }
-
- public String getLocation() {
- return this.location;
- }
-
- public String getTabletDir() {
- return this.dir;
- }
-
- public TabletHostingGoal getHostingGoal() {
- return this.goal;
- }
-
- @Override
- public String toString() {
- return "TabletInformation{tableName='" + tableName + '\'' + ", numFiles=" + numFiles
- + ", numWalLogs=" + numWalLogs + ", numEntries=" + numEntries + ", size=" + size
- + ", status='" + status + '\'' + ", location='" + location + '\'' + ", dir='" + dir + '\''
- + ", tableId=" + tableId + ", tablet=" + getTablet() + ", goal=" + goal + '}';
- }
-
- public static final String header =
- String.format("%-4s %-15s %-5s %-5s %-9s %-9s %-10s %-30s %-5s %-20s %-20s %-10s", "NUM",
- "TABLET_DIR", "FILES", "WALS", "ENTRIES", "SIZE", "STATUS", "LOCATION", "ID",
- "START (Exclusive)", "END", "GOAL");
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
- TabletInformation that = (TabletInformation) o;
- return numFiles == that.numFiles && numWalLogs == that.numWalLogs
- && numEntries == that.numEntries && size == that.size
- && Objects.equals(tableName, that.tableName) && Objects.equals(endRow, that.endRow)
- && Objects.equals(prevEndRow, that.prevEndRow) && Objects.equals(status, that.status)
- && Objects.equals(location, that.location) && Objects.equals(dir, that.dir)
- && Objects.equals(tableId, that.tableId) && goal == that.goal;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(tableName, endRow, prevEndRow, numFiles, numWalLogs, numEntries, size,
- status, location, dir, tableId, goal);
- }
+import org.apache.accumulo.core.data.TabletId;
+import org.apache.accumulo.core.metadata.schema.TabletMetadata.Location;
+import org.apache.hadoop.io.Text;
+
+public interface TabletInformation {
+
+ /**
+ * @return the TableId of the table containing this tablet.
+ */
+ TableId getTableId();
+
+ /**
+ * @return the TabletId for this tablet.
+ */
+ TabletId getTabletId();
+
+ /**
+ * @return the tablet end row.
+ */
+ Text getEndRow();
+
+ /**
+ * @return the previous end row.
+ */
+ Text getStartRow();
Review Comment:
Since this information could all be obtained from TabletId, could drop the methods in this interface.
```suggestion
/**
* @return the TabletId for this tablet.
*/
TabletId getTabletId();
```
##########
core/src/main/java/org/apache/accumulo/core/client/admin/TabletInformation.java:
##########
@@ -18,142 +18,74 @@
*/
package org.apache.accumulo.core.client.admin;
-import java.util.Objects;
+import java.util.Optional;
import org.apache.accumulo.core.data.TableId;
-import org.apache.accumulo.core.util.NumUtil;
-
-public class TabletInformation {
-
- private final String tableName;
- private final String endRow;
- private final String prevEndRow;
- private final int numFiles;
- private final int numWalLogs;
- private final long numEntries;
- private final long size;
- private final String status;
- private final String location;
- private final String dir;
- private final TableId tableId;
- private final TabletHostingGoal goal;
-
- public TabletInformation(String tableName, TableId tableId, String endRow, String prevEndRow,
- int numFiles, int numWalLogs, long numEntries, long size, String status, String location,
- String dir, TabletHostingGoal goal) {
- this.tableName = tableName;
- this.tableId = tableId;
- this.endRow = endRow;
- this.prevEndRow = prevEndRow;
- this.numFiles = numFiles;
- this.numWalLogs = numWalLogs;
- this.numEntries = numEntries;
- this.size = size;
- this.status = status;
- this.location = location;
- this.dir = dir;
- this.goal = goal;
- }
-
- public String getEndRow() {
- return Objects.requireNonNullElse(this.endRow, "+INF");
- }
-
- public String getStartRow() {
- return Objects.requireNonNullElse(this.prevEndRow, "-INF");
- }
-
- public String getTableId() {
- return tableId.canonical();
- }
-
- public String getTablet() {
- return getStartRow() + " " + getEndRow();
- }
-
- public String getTableName() {
- return this.tableName;
- }
-
- public int getNumFiles() {
- return this.numFiles;
- }
-
- public int getNumWalLogs() {
- return this.numWalLogs;
- }
-
- public long getNumEntries() {
- return this.numEntries;
- }
-
- public String getNumEntries(final boolean humanReadable) {
- if (humanReadable) {
- return NumUtil.bigNumberForQuantity(numEntries);
- }
- return String.format("%,d", numEntries);
- }
-
- public long getSize() {
- return this.size;
- }
-
- public String getSize(final boolean humanReadable) {
- if (humanReadable) {
- return NumUtil.bigNumberForSize(size);
- }
- return String.format("%,d", size);
- }
-
- public String getStatus() {
- return this.status;
- }
-
- public String getLocation() {
- return this.location;
- }
-
- public String getTabletDir() {
- return this.dir;
- }
-
- public TabletHostingGoal getHostingGoal() {
- return this.goal;
- }
-
- @Override
- public String toString() {
- return "TabletInformation{tableName='" + tableName + '\'' + ", numFiles=" + numFiles
- + ", numWalLogs=" + numWalLogs + ", numEntries=" + numEntries + ", size=" + size
- + ", status='" + status + '\'' + ", location='" + location + '\'' + ", dir='" + dir + '\''
- + ", tableId=" + tableId + ", tablet=" + getTablet() + ", goal=" + goal + '}';
- }
-
- public static final String header =
- String.format("%-4s %-15s %-5s %-5s %-9s %-9s %-10s %-30s %-5s %-20s %-20s %-10s", "NUM",
- "TABLET_DIR", "FILES", "WALS", "ENTRIES", "SIZE", "STATUS", "LOCATION", "ID",
- "START (Exclusive)", "END", "GOAL");
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
- TabletInformation that = (TabletInformation) o;
- return numFiles == that.numFiles && numWalLogs == that.numWalLogs
- && numEntries == that.numEntries && size == that.size
- && Objects.equals(tableName, that.tableName) && Objects.equals(endRow, that.endRow)
- && Objects.equals(prevEndRow, that.prevEndRow) && Objects.equals(status, that.status)
- && Objects.equals(location, that.location) && Objects.equals(dir, that.dir)
- && Objects.equals(tableId, that.tableId) && goal == that.goal;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(tableName, endRow, prevEndRow, numFiles, numWalLogs, numEntries, size,
- status, location, dir, tableId, goal);
- }
+import org.apache.accumulo.core.data.TabletId;
+import org.apache.accumulo.core.metadata.schema.TabletMetadata.Location;
+import org.apache.hadoop.io.Text;
+
+public interface TabletInformation {
Review Comment:
```suggestion
/**
* @since 4.0.0
*/
public interface TabletInformation {
```
##########
core/src/main/java/org/apache/accumulo/core/client/admin/TabletInformation.java:
##########
@@ -0,0 +1,159 @@
+/*
+ * 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
+ *
+ * https://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.core.client.admin;
+
+import java.util.Objects;
+
+import org.apache.accumulo.core.data.TableId;
+import org.apache.accumulo.core.util.NumUtil;
+
+public class TabletInformation {
+
+ private final String tableName;
+ private final String endRow;
+ private final String prevEndRow;
+ private final int numFiles;
+ private final int numWalLogs;
+ private final long numEntries;
+ private final long size;
+ private final String status;
+ private final String location;
+ private final String dir;
+ private final TableId tableId;
+ private final TabletHostingGoal goal;
+
+ public TabletInformation(String tableName, TableId tableId, String endRow, String prevEndRow,
+ int numFiles, int numWalLogs, long numEntries, long size, String status, String location,
+ String dir, TabletHostingGoal goal) {
+ this.tableName = tableName;
+ this.tableId = tableId;
+ this.endRow = endRow;
+ this.prevEndRow = prevEndRow;
+ this.numFiles = numFiles;
+ this.numWalLogs = numWalLogs;
+ this.numEntries = numEntries;
+ this.size = size;
+ this.status = status;
+ this.location = location;
+ this.dir = dir;
+ this.goal = goal;
+ }
Review Comment:
Passing any additional information to the constructor if it can not be obtained from tabletmetadata seems fine.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [accumulo] jmark99 commented on a diff in pull request #3645: Create getTabletInformation API method
Posted by "jmark99 (via GitHub)" <gi...@apache.org>.
jmark99 commented on code in PR #3645:
URL: https://github.com/apache/accumulo/pull/3645#discussion_r1277463358
##########
core/src/main/java/org/apache/accumulo/core/client/admin/TabletInformation.java:
##########
@@ -18,142 +18,74 @@
*/
package org.apache.accumulo.core.client.admin;
-import java.util.Objects;
+import java.util.Optional;
import org.apache.accumulo.core.data.TableId;
-import org.apache.accumulo.core.util.NumUtil;
-
-public class TabletInformation {
-
- private final String tableName;
- private final String endRow;
- private final String prevEndRow;
- private final int numFiles;
- private final int numWalLogs;
- private final long numEntries;
- private final long size;
- private final String status;
- private final String location;
- private final String dir;
- private final TableId tableId;
- private final TabletHostingGoal goal;
-
- public TabletInformation(String tableName, TableId tableId, String endRow, String prevEndRow,
- int numFiles, int numWalLogs, long numEntries, long size, String status, String location,
- String dir, TabletHostingGoal goal) {
- this.tableName = tableName;
- this.tableId = tableId;
- this.endRow = endRow;
- this.prevEndRow = prevEndRow;
- this.numFiles = numFiles;
- this.numWalLogs = numWalLogs;
- this.numEntries = numEntries;
- this.size = size;
- this.status = status;
- this.location = location;
- this.dir = dir;
- this.goal = goal;
- }
-
- public String getEndRow() {
- return Objects.requireNonNullElse(this.endRow, "+INF");
- }
-
- public String getStartRow() {
- return Objects.requireNonNullElse(this.prevEndRow, "-INF");
- }
-
- public String getTableId() {
- return tableId.canonical();
- }
-
- public String getTablet() {
- return getStartRow() + " " + getEndRow();
- }
-
- public String getTableName() {
- return this.tableName;
- }
-
- public int getNumFiles() {
- return this.numFiles;
- }
-
- public int getNumWalLogs() {
- return this.numWalLogs;
- }
-
- public long getNumEntries() {
- return this.numEntries;
- }
-
- public String getNumEntries(final boolean humanReadable) {
- if (humanReadable) {
- return NumUtil.bigNumberForQuantity(numEntries);
- }
- return String.format("%,d", numEntries);
- }
-
- public long getSize() {
- return this.size;
- }
-
- public String getSize(final boolean humanReadable) {
- if (humanReadable) {
- return NumUtil.bigNumberForSize(size);
- }
- return String.format("%,d", size);
- }
-
- public String getStatus() {
- return this.status;
- }
-
- public String getLocation() {
- return this.location;
- }
-
- public String getTabletDir() {
- return this.dir;
- }
-
- public TabletHostingGoal getHostingGoal() {
- return this.goal;
- }
-
- @Override
- public String toString() {
- return "TabletInformation{tableName='" + tableName + '\'' + ", numFiles=" + numFiles
- + ", numWalLogs=" + numWalLogs + ", numEntries=" + numEntries + ", size=" + size
- + ", status='" + status + '\'' + ", location='" + location + '\'' + ", dir='" + dir + '\''
- + ", tableId=" + tableId + ", tablet=" + getTablet() + ", goal=" + goal + '}';
- }
-
- public static final String header =
- String.format("%-4s %-15s %-5s %-5s %-9s %-9s %-10s %-30s %-5s %-20s %-20s %-10s", "NUM",
- "TABLET_DIR", "FILES", "WALS", "ENTRIES", "SIZE", "STATUS", "LOCATION", "ID",
- "START (Exclusive)", "END", "GOAL");
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
- TabletInformation that = (TabletInformation) o;
- return numFiles == that.numFiles && numWalLogs == that.numWalLogs
- && numEntries == that.numEntries && size == that.size
- && Objects.equals(tableName, that.tableName) && Objects.equals(endRow, that.endRow)
- && Objects.equals(prevEndRow, that.prevEndRow) && Objects.equals(status, that.status)
- && Objects.equals(location, that.location) && Objects.equals(dir, that.dir)
- && Objects.equals(tableId, that.tableId) && goal == that.goal;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(tableName, endRow, prevEndRow, numFiles, numWalLogs, numEntries, size,
- status, location, dir, tableId, goal);
- }
+import org.apache.accumulo.core.data.TabletId;
+import org.apache.accumulo.core.metadata.schema.TabletMetadata.Location;
+import org.apache.hadoop.io.Text;
+
+public interface TabletInformation {
+
+ /**
+ * @return the TableId of the table containing this tablet.
+ */
+ TableId getTableId();
+
+ /**
+ * @return the TabletId for this tablet.
+ */
+ TabletId getTabletId();
+
+ /**
+ * @return the tablet end row.
+ */
+ Text getEndRow();
+
+ /**
+ * @return the previous end row.
+ */
+ Text getStartRow();
+
+ /**
+ * @return the number of files in the tablet directory.
+ */
+ int getNumFiles();
+
+ /**
+ * @return the number of write-ahead logs associated with the tablet.
+ */
+ int getNumWalLogs();
+
+ /**
+ * @return an estimated number of entries in the tablet.
+ */
+ long getEstimatedEntries();
+
+ /**
+ * @return an estimated size of the tablet data on disk, which is likely the compressed size of
+ * the data.
+ */
+ long getEstimatedSize();
+
+ /**
+ * @return the tablet hosting state.
+ */
+ String getTabletState();
+
+ /**
+ * @return the Location of the tablet.
+ */
+ Optional<Location> getLocation();
Review Comment:
@keith-turner interestingly, it did not! I'll refactor to use the String value of the location as it had been before. I thought it was strange that Location was not flagged.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [accumulo] DomGarguilo commented on a diff in pull request #3645: Create getTabletInformation API method
Posted by "DomGarguilo (via GitHub)" <gi...@apache.org>.
DomGarguilo commented on code in PR #3645:
URL: https://github.com/apache/accumulo/pull/3645#discussion_r1271072579
##########
core/src/main/java/org/apache/accumulo/core/clientImpl/TableOperationsImpl.java:
##########
@@ -2162,12 +2172,54 @@ public Stream<HostingGoalForTablet> getTabletHostingGoal(final String tableName,
return tabletsMetadata.stream().peek(tm -> {
if (scanRangeStart != null && tm.getEndRow() != null
&& tm.getEndRow().compareTo(scanRangeStart) < 0) {
- log.debug(">>>> tablet {} is before scan start range: {}", tm.getExtent(), scanRangeStart);
+ log.debug("tablet {} is before scan start range: {}", tm.getExtent(), scanRangeStart);
throw new RuntimeException("Bug in ample or this code.");
}
}).takeWhile(tm -> tm.getPrevEndRow() == null
|| !range.afterEndKey(new Key(tm.getPrevEndRow()).followingKey(PartialKey.ROW)))
.map(tm -> new HostingGoalForTablet(new TabletIdImpl(tm.getExtent()), tm.getHostingGoal()))
.onClose(tabletsMetadata::close);
}
+
+ @Override
+ public Stream<TabletInformation> getTabletInformation(final String tableName, final Range range)
+ throws TableNotFoundException {
+ EXISTING_TABLE_NAME.validate(tableName);
+
+ final Text scanRangeStart = (range.getStartKey() == null) ? null : range.getStartKey().getRow();
+ TableId tableId = context.getTableId(tableName);
+
+ TabletsMetadata tabletsMetadata =
+ context.getAmple().readTablets().forTable(tableId).overlapping(scanRangeStart, true, null)
+ .fetch(HOSTING_GOAL, LOCATION, DIR, PREV_ROW, FILES, LAST, LOGS, SUSPEND)
+ .checkConsistency().build();
+
+ Set<TServerInstance> liveTserverSet = TabletMetadata.getLiveTServers(context);
+ long[] numEntries = new long[1];
+ long[] size = new long[1];
Review Comment:
could AtomicLong be used here instead?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [accumulo] keith-turner commented on a diff in pull request #3645: Create getTabletInformation API method
Posted by "keith-turner (via GitHub)" <gi...@apache.org>.
keith-turner commented on code in PR #3645:
URL: https://github.com/apache/accumulo/pull/3645#discussion_r1271117823
##########
core/src/main/java/org/apache/accumulo/core/client/admin/TableOperations.java:
##########
@@ -1034,4 +1034,9 @@ default Stream<HostingGoalForTablet> getTabletHostingGoal(final String tableName
throw new UnsupportedOperationException();
}
+ default Stream<TabletInformation> getTabletInformation(final String tableName, final Range range)
Review Comment:
```suggestion
/**
* @return a stream of tablets information for tablets that fall in the specified range
* @since 4.0.0
*/
default Stream<TabletInformation> getTabletInformation(final String tableName, final Range range)
```
##########
core/src/main/java/org/apache/accumulo/core/client/admin/TabletInformation.java:
##########
@@ -0,0 +1,159 @@
+/*
+ * 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
+ *
+ * https://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.core.client.admin;
+
+import java.util.Objects;
+
+import org.apache.accumulo.core.data.TableId;
+import org.apache.accumulo.core.util.NumUtil;
+
+public class TabletInformation {
+
+ private final String tableName;
+ private final String endRow;
+ private final String prevEndRow;
+ private final int numFiles;
+ private final int numWalLogs;
+ private final long numEntries;
+ private final long size;
+ private final String status;
+ private final String location;
+ private final String dir;
+ private final TableId tableId;
+ private final TabletHostingGoal goal;
+
+ public TabletInformation(String tableName, TableId tableId, String endRow, String prevEndRow,
+ int numFiles, int numWalLogs, long numEntries, long size, String status, String location,
+ String dir, TabletHostingGoal goal) {
+ this.tableName = tableName;
+ this.tableId = tableId;
+ this.endRow = endRow;
+ this.prevEndRow = prevEndRow;
+ this.numFiles = numFiles;
+ this.numWalLogs = numWalLogs;
+ this.numEntries = numEntries;
+ this.size = size;
+ this.status = status;
+ this.location = location;
+ this.dir = dir;
+ this.goal = goal;
+ }
+
+ public String getEndRow() {
+ return Objects.requireNonNullElse(this.endRow, "+INF");
+ }
+
+ public String getStartRow() {
+ return Objects.requireNonNullElse(this.prevEndRow, "-INF");
+ }
+
+ public String getTableId() {
+ return tableId.canonical();
+ }
+
+ public String getTablet() {
+ return getStartRow() + " " + getEndRow();
+ }
+
+ public String getTableName() {
+ return this.tableName;
+ }
+
+ public int getNumFiles() {
+ return this.numFiles;
+ }
+
+ public int getNumWalLogs() {
+ return this.numWalLogs;
+ }
+
+ public long getNumEntries() {
+ return this.numEntries;
+ }
+
+ public String getNumEntries(final boolean humanReadable) {
+ if (humanReadable) {
+ return NumUtil.bigNumberForQuantity(numEntries);
+ }
+ return String.format("%,d", numEntries);
+ }
+
+ public long getSize() {
+ return this.size;
+ }
+
+ public String getSize(final boolean humanReadable) {
+ if (humanReadable) {
+ return NumUtil.bigNumberForSize(size);
+ }
+ return String.format("%,d", size);
+ }
+
+ public String getStatus() {
+ return this.status;
+ }
+
+ public String getLocation() {
+ return this.location;
+ }
+
+ public String getTabletDir() {
+ return this.dir;
+ }
+
+ public TabletHostingGoal getHostingGoal() {
+ return this.goal;
+ }
+
+ @Override
+ public String toString() {
+ return "TabletInformation{tableName='" + tableName + '\'' + ", numFiles=" + numFiles
+ + ", numWalLogs=" + numWalLogs + ", numEntries=" + numEntries + ", size=" + size
+ + ", status='" + status + '\'' + ", location='" + location + '\'' + ", dir='" + dir + '\''
+ + ", tableId=" + tableId + ", tablet=" + getTablet() + ", goal=" + goal + '}';
+ }
+
+ public static final String header =
Review Comment:
Could this be moved to the shell code?
##########
core/src/main/java/org/apache/accumulo/core/client/admin/TabletInformation.java:
##########
@@ -0,0 +1,159 @@
+/*
+ * 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
+ *
+ * https://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.core.client.admin;
+
+import java.util.Objects;
+
+import org.apache.accumulo.core.data.TableId;
+import org.apache.accumulo.core.util.NumUtil;
+
+public class TabletInformation {
+
+ private final String tableName;
+ private final String endRow;
+ private final String prevEndRow;
+ private final int numFiles;
+ private final int numWalLogs;
+ private final long numEntries;
+ private final long size;
+ private final String status;
+ private final String location;
+ private final String dir;
+ private final TableId tableId;
+ private final TabletHostingGoal goal;
+
+ public TabletInformation(String tableName, TableId tableId, String endRow, String prevEndRow,
+ int numFiles, int numWalLogs, long numEntries, long size, String status, String location,
+ String dir, TabletHostingGoal goal) {
+ this.tableName = tableName;
+ this.tableId = tableId;
+ this.endRow = endRow;
+ this.prevEndRow = prevEndRow;
+ this.numFiles = numFiles;
+ this.numWalLogs = numWalLogs;
+ this.numEntries = numEntries;
+ this.size = size;
+ this.status = status;
+ this.location = location;
+ this.dir = dir;
+ this.goal = goal;
+ }
+
+ public String getEndRow() {
+ return Objects.requireNonNullElse(this.endRow, "+INF");
+ }
+
+ public String getStartRow() {
+ return Objects.requireNonNullElse(this.prevEndRow, "-INF");
+ }
+
+ public String getTableId() {
+ return tableId.canonical();
+ }
+
+ public String getTablet() {
+ return getStartRow() + " " + getEndRow();
+ }
Review Comment:
Its good to provide the exact rows as they exist in the metadata table, this can not be done with String as it may mangle certain binary data. Could used the TabletId type which already exist in the public api for this purpose.
```suggestion
public TabletId getTabletId(){
return new TabletIdImp(tabletMetadata.getExtent());
}
```
##########
core/src/main/java/org/apache/accumulo/core/client/admin/TabletInformation.java:
##########
@@ -0,0 +1,159 @@
+/*
+ * 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
+ *
+ * https://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.core.client.admin;
+
+import java.util.Objects;
+
+import org.apache.accumulo.core.data.TableId;
+import org.apache.accumulo.core.util.NumUtil;
+
+public class TabletInformation {
+
+ private final String tableName;
+ private final String endRow;
+ private final String prevEndRow;
+ private final int numFiles;
+ private final int numWalLogs;
+ private final long numEntries;
+ private final long size;
+ private final String status;
+ private final String location;
+ private final String dir;
+ private final TableId tableId;
+ private final TabletHostingGoal goal;
+
+ public TabletInformation(String tableName, TableId tableId, String endRow, String prevEndRow,
+ int numFiles, int numWalLogs, long numEntries, long size, String status, String location,
+ String dir, TabletHostingGoal goal) {
+ this.tableName = tableName;
+ this.tableId = tableId;
+ this.endRow = endRow;
+ this.prevEndRow = prevEndRow;
+ this.numFiles = numFiles;
+ this.numWalLogs = numWalLogs;
+ this.numEntries = numEntries;
+ this.size = size;
+ this.status = status;
+ this.location = location;
+ this.dir = dir;
+ this.goal = goal;
+ }
+
+ public String getEndRow() {
+ return Objects.requireNonNullElse(this.endRow, "+INF");
+ }
+
+ public String getStartRow() {
+ return Objects.requireNonNullElse(this.prevEndRow, "-INF");
+ }
+
+ public String getTableId() {
+ return tableId.canonical();
+ }
+
+ public String getTablet() {
+ return getStartRow() + " " + getEndRow();
+ }
+
+ public String getTableName() {
+ return this.tableName;
+ }
+
+ public int getNumFiles() {
+ return this.numFiles;
+ }
+
+ public int getNumWalLogs() {
+ return this.numWalLogs;
+ }
+
+ public long getNumEntries() {
+ return this.numEntries;
+ }
+
+ public String getNumEntries(final boolean humanReadable) {
+ if (humanReadable) {
+ return NumUtil.bigNumberForQuantity(numEntries);
+ }
+ return String.format("%,d", numEntries);
+ }
Review Comment:
I would move this to the shell code. Someone can call getNumEntries and format it however they like when using the API, and there is good chance they may not like the way this method formats the data.
##########
core/src/main/java/org/apache/accumulo/core/client/admin/TabletInformation.java:
##########
@@ -0,0 +1,159 @@
+/*
+ * 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
+ *
+ * https://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.core.client.admin;
+
+import java.util.Objects;
+
+import org.apache.accumulo.core.data.TableId;
+import org.apache.accumulo.core.util.NumUtil;
+
+public class TabletInformation {
+
+ private final String tableName;
+ private final String endRow;
+ private final String prevEndRow;
+ private final int numFiles;
+ private final int numWalLogs;
+ private final long numEntries;
+ private final long size;
+ private final String status;
+ private final String location;
+ private final String dir;
+ private final TableId tableId;
+ private final TabletHostingGoal goal;
+
+ public TabletInformation(String tableName, TableId tableId, String endRow, String prevEndRow,
+ int numFiles, int numWalLogs, long numEntries, long size, String status, String location,
+ String dir, TabletHostingGoal goal) {
+ this.tableName = tableName;
+ this.tableId = tableId;
+ this.endRow = endRow;
+ this.prevEndRow = prevEndRow;
+ this.numFiles = numFiles;
+ this.numWalLogs = numWalLogs;
+ this.numEntries = numEntries;
+ this.size = size;
+ this.status = status;
+ this.location = location;
+ this.dir = dir;
+ this.goal = goal;
+ }
+
+ public String getEndRow() {
+ return Objects.requireNonNullElse(this.endRow, "+INF");
+ }
+
+ public String getStartRow() {
+ return Objects.requireNonNullElse(this.prevEndRow, "-INF");
+ }
+
+ public String getTableId() {
+ return tableId.canonical();
+ }
+
+ public String getTablet() {
+ return getStartRow() + " " + getEndRow();
+ }
+
+ public String getTableName() {
+ return this.tableName;
+ }
+
+ public int getNumFiles() {
+ return this.numFiles;
+ }
+
+ public int getNumWalLogs() {
+ return this.numWalLogs;
+ }
+
+ public long getNumEntries() {
+ return this.numEntries;
+ }
+
+ public String getNumEntries(final boolean humanReadable) {
+ if (humanReadable) {
+ return NumUtil.bigNumberForQuantity(numEntries);
+ }
+ return String.format("%,d", numEntries);
+ }
+
+ public long getSize() {
+ return this.size;
+ }
+
+ public String getSize(final boolean humanReadable) {
+ if (humanReadable) {
+ return NumUtil.bigNumberForSize(size);
+ }
+ return String.format("%,d", size);
+ }
+
+ public String getStatus() {
+ return this.status;
+ }
+
+ public String getLocation() {
Review Comment:
Since a tablet may not have a location, could have an optional return type to make this clear.
```suggestion
public Optional<String> getLocation() {
```
Also as follow on issue, this could possible use the new type introduced in #3626
##########
core/src/main/java/org/apache/accumulo/core/clientImpl/TableOperationsImpl.java:
##########
@@ -2162,12 +2172,54 @@ public Stream<HostingGoalForTablet> getTabletHostingGoal(final String tableName,
return tabletsMetadata.stream().peek(tm -> {
if (scanRangeStart != null && tm.getEndRow() != null
&& tm.getEndRow().compareTo(scanRangeStart) < 0) {
- log.debug(">>>> tablet {} is before scan start range: {}", tm.getExtent(), scanRangeStart);
+ log.debug("tablet {} is before scan start range: {}", tm.getExtent(), scanRangeStart);
throw new RuntimeException("Bug in ample or this code.");
}
}).takeWhile(tm -> tm.getPrevEndRow() == null
|| !range.afterEndKey(new Key(tm.getPrevEndRow()).followingKey(PartialKey.ROW)))
.map(tm -> new HostingGoalForTablet(new TabletIdImpl(tm.getExtent()), tm.getHostingGoal()))
.onClose(tabletsMetadata::close);
}
+
+ @Override
+ public Stream<TabletInformation> getTabletInformation(final String tableName, final Range range)
+ throws TableNotFoundException {
+ EXISTING_TABLE_NAME.validate(tableName);
+
+ final Text scanRangeStart = (range.getStartKey() == null) ? null : range.getStartKey().getRow();
+ TableId tableId = context.getTableId(tableName);
+
+ TabletsMetadata tabletsMetadata =
+ context.getAmple().readTablets().forTable(tableId).overlapping(scanRangeStart, true, null)
+ .fetch(HOSTING_GOAL, LOCATION, DIR, PREV_ROW, FILES, LAST, LOGS, SUSPEND)
+ .checkConsistency().build();
+
+ Set<TServerInstance> liveTserverSet = TabletMetadata.getLiveTServers(context);
+ long[] numEntries = new long[1];
+ long[] size = new long[1];
+ return tabletsMetadata.stream().peek(tm -> {
+ if (scanRangeStart != null && tm.getEndRow() != null
+ && tm.getEndRow().compareTo(scanRangeStart) < 0) {
+ log.debug("tablet {} is before scan start range: {}", tm.getExtent(), scanRangeStart);
+ throw new RuntimeException("Bug in ample or this code.");
+ }
+ numEntries[0] = 0;
+ size[0] = 0;
+ for (DataFileValue dfv : tm.getFilesMap().values()) {
+ numEntries[0] = dfv.getNumEntries();
+ size[0] += dfv.getSize();
+ }
Review Comment:
If the TabletInformation class took a tablet metadata in it constructor, then this computation could be done in the constructor.
##########
core/src/main/java/org/apache/accumulo/core/client/admin/TabletInformation.java:
##########
@@ -0,0 +1,159 @@
+/*
+ * 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
+ *
+ * https://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.core.client.admin;
+
+import java.util.Objects;
+
+import org.apache.accumulo.core.data.TableId;
+import org.apache.accumulo.core.util.NumUtil;
+
+public class TabletInformation {
+
+ private final String tableName;
+ private final String endRow;
+ private final String prevEndRow;
+ private final int numFiles;
+ private final int numWalLogs;
+ private final long numEntries;
+ private final long size;
+ private final String status;
+ private final String location;
+ private final String dir;
+ private final TableId tableId;
+ private final TabletHostingGoal goal;
+
+ public TabletInformation(String tableName, TableId tableId, String endRow, String prevEndRow,
+ int numFiles, int numWalLogs, long numEntries, long size, String status, String location,
+ String dir, TabletHostingGoal goal) {
+ this.tableName = tableName;
+ this.tableId = tableId;
+ this.endRow = endRow;
+ this.prevEndRow = prevEndRow;
+ this.numFiles = numFiles;
+ this.numWalLogs = numWalLogs;
+ this.numEntries = numEntries;
+ this.size = size;
+ this.status = status;
+ this.location = location;
+ this.dir = dir;
+ this.goal = goal;
+ }
+
+ public String getEndRow() {
+ return Objects.requireNonNullElse(this.endRow, "+INF");
+ }
+
+ public String getStartRow() {
+ return Objects.requireNonNullElse(this.prevEndRow, "-INF");
+ }
+
+ public String getTableId() {
+ return tableId.canonical();
+ }
+
+ public String getTablet() {
+ return getStartRow() + " " + getEndRow();
+ }
+
+ public String getTableName() {
+ return this.tableName;
+ }
+
+ public int getNumFiles() {
+ return this.numFiles;
+ }
+
+ public int getNumWalLogs() {
+ return this.numWalLogs;
+ }
+
+ public long getNumEntries() {
+ return this.numEntries;
+ }
+
+ public String getNumEntries(final boolean humanReadable) {
+ if (humanReadable) {
+ return NumUtil.bigNumberForQuantity(numEntries);
+ }
+ return String.format("%,d", numEntries);
+ }
+
+ public long getSize() {
Review Comment:
```suggestion
/**
* @return an estimated size of the tablet data on disk, which is likely the compressed size of the data.
*/
public long getEstimatedSize() {
```
##########
core/src/main/java/org/apache/accumulo/core/client/admin/TabletInformation.java:
##########
@@ -0,0 +1,159 @@
+/*
+ * 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
+ *
+ * https://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.core.client.admin;
+
+import java.util.Objects;
+
+import org.apache.accumulo.core.data.TableId;
+import org.apache.accumulo.core.util.NumUtil;
+
+public class TabletInformation {
+
+ private final String tableName;
+ private final String endRow;
+ private final String prevEndRow;
+ private final int numFiles;
+ private final int numWalLogs;
+ private final long numEntries;
+ private final long size;
+ private final String status;
+ private final String location;
+ private final String dir;
+ private final TableId tableId;
+ private final TabletHostingGoal goal;
+
+ public TabletInformation(String tableName, TableId tableId, String endRow, String prevEndRow,
+ int numFiles, int numWalLogs, long numEntries, long size, String status, String location,
+ String dir, TabletHostingGoal goal) {
+ this.tableName = tableName;
+ this.tableId = tableId;
+ this.endRow = endRow;
+ this.prevEndRow = prevEndRow;
+ this.numFiles = numFiles;
+ this.numWalLogs = numWalLogs;
+ this.numEntries = numEntries;
+ this.size = size;
+ this.status = status;
+ this.location = location;
+ this.dir = dir;
+ this.goal = goal;
+ }
+
+ public String getEndRow() {
+ return Objects.requireNonNullElse(this.endRow, "+INF");
+ }
+
+ public String getStartRow() {
+ return Objects.requireNonNullElse(this.prevEndRow, "-INF");
+ }
+
+ public String getTableId() {
+ return tableId.canonical();
+ }
+
+ public String getTablet() {
+ return getStartRow() + " " + getEndRow();
+ }
+
+ public String getTableName() {
+ return this.tableName;
+ }
+
+ public int getNumFiles() {
+ return this.numFiles;
+ }
+
+ public int getNumWalLogs() {
+ return this.numWalLogs;
+ }
+
+ public long getNumEntries() {
Review Comment:
```suggestion
public long getEstimatedEntries() {
```
##########
core/src/main/java/org/apache/accumulo/core/client/admin/TabletInformation.java:
##########
@@ -0,0 +1,159 @@
+/*
+ * 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
+ *
+ * https://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.core.client.admin;
+
+import java.util.Objects;
+
+import org.apache.accumulo.core.data.TableId;
+import org.apache.accumulo.core.util.NumUtil;
+
+public class TabletInformation {
+
+ private final String tableName;
+ private final String endRow;
+ private final String prevEndRow;
+ private final int numFiles;
+ private final int numWalLogs;
+ private final long numEntries;
+ private final long size;
+ private final String status;
+ private final String location;
+ private final String dir;
+ private final TableId tableId;
+ private final TabletHostingGoal goal;
+
+ public TabletInformation(String tableName, TableId tableId, String endRow, String prevEndRow,
+ int numFiles, int numWalLogs, long numEntries, long size, String status, String location,
+ String dir, TabletHostingGoal goal) {
+ this.tableName = tableName;
+ this.tableId = tableId;
+ this.endRow = endRow;
+ this.prevEndRow = prevEndRow;
+ this.numFiles = numFiles;
+ this.numWalLogs = numWalLogs;
+ this.numEntries = numEntries;
+ this.size = size;
+ this.status = status;
+ this.location = location;
+ this.dir = dir;
+ this.goal = goal;
+ }
Review Comment:
If its workable it would be nice to make this object a wrapper around TabletMetadata, then it does not need to duplicate alot of the fields.
```suggestion
private final TabletMetadata tabletMetadata;
public TabletInformation(TabletMetadata tabletMetadata) {
this.tabletMetadata = tabletMetadata;
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [accumulo] jmark99 commented on a diff in pull request #3645: Create getTabletInformation API method
Posted by "jmark99 (via GitHub)" <gi...@apache.org>.
jmark99 commented on code in PR #3645:
URL: https://github.com/apache/accumulo/pull/3645#discussion_r1272490981
##########
core/src/main/java/org/apache/accumulo/core/client/admin/TabletInformation.java:
##########
@@ -0,0 +1,159 @@
+/*
+ * 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
+ *
+ * https://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.core.client.admin;
+
+import java.util.Objects;
+
+import org.apache.accumulo.core.data.TableId;
+import org.apache.accumulo.core.util.NumUtil;
+
+public class TabletInformation {
+
+ private final String tableName;
+ private final String endRow;
+ private final String prevEndRow;
+ private final int numFiles;
+ private final int numWalLogs;
+ private final long numEntries;
+ private final long size;
+ private final String status;
+ private final String location;
+ private final String dir;
+ private final TableId tableId;
+ private final TabletHostingGoal goal;
+
+ public TabletInformation(String tableName, TableId tableId, String endRow, String prevEndRow,
+ int numFiles, int numWalLogs, long numEntries, long size, String status, String location,
+ String dir, TabletHostingGoal goal) {
+ this.tableName = tableName;
+ this.tableId = tableId;
+ this.endRow = endRow;
+ this.prevEndRow = prevEndRow;
+ this.numFiles = numFiles;
+ this.numWalLogs = numWalLogs;
+ this.numEntries = numEntries;
+ this.size = size;
+ this.status = status;
+ this.location = location;
+ this.dir = dir;
+ this.goal = goal;
+ }
Review Comment:
Thanks. I'll give that a shot. I definitely prefer not having to use all of the constructor fields.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org