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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
