This is an automated email from the ASF dual-hosted git repository. kturner pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/accumulo.git
The following commit(s) were added to refs/heads/main by this push: new 1409bc0fdd Performs some minor cleanup of TabletLocator (#3271) 1409bc0fdd is described below commit 1409bc0fdd8fa9b262d8de5a388af99ef5deb61e Author: Keith Turner <ktur...@apache.org> AuthorDate: Mon Apr 3 09:44:55 2023 -0400 Performs some minor cleanup of TabletLocator (#3271) This commit has no changes in functionality, it only contains some minor code cleanup of the TabletLocator code. The following changes were made. * Encapsulated fields in TabletLocation class * Replaced a Callable interface with a Supplier interface to avoid the uneeded exception thrown by Callable * Removed an uneeded compareTo method from TabletLocation class --- .../core/clientImpl/RootTabletLocator.java | 6 +- .../core/clientImpl/SyncingTabletLocator.java | 20 ++----- .../core/clientImpl/TableOperationsImpl.java | 14 ++--- .../accumulo/core/clientImpl/TabletLocator.java | 44 +++++++-------- .../core/clientImpl/TabletLocatorImpl.java | 65 +++++++++++----------- .../accumulo/core/clientImpl/ThriftScanner.java | 59 ++++++++++---------- .../apache/accumulo/core/clientImpl/Writer.java | 10 ++-- .../core/metadata/MetadataLocationObtainer.java | 20 +++---- .../core/clientImpl/TabletLocatorImplTest.java | 18 +++--- .../accumulo/server/client/BulkImporter.java | 14 ++--- .../accumulo/server/client/BulkImporterTest.java | 19 ++++--- .../accumulo/test/functional/BulkFailureIT.java | 2 +- .../accumulo/test/manager/SuspendedTabletsIT.java | 4 +- 13 files changed, 144 insertions(+), 151 deletions(-) diff --git a/core/src/main/java/org/apache/accumulo/core/clientImpl/RootTabletLocator.java b/core/src/main/java/org/apache/accumulo/core/clientImpl/RootTabletLocator.java index a7609c9ba3..a24a236998 100644 --- a/core/src/main/java/org/apache/accumulo/core/clientImpl/RootTabletLocator.java +++ b/core/src/main/java/org/apache/accumulo/core/clientImpl/RootTabletLocator.java @@ -56,11 +56,11 @@ public class RootTabletLocator extends TabletLocator { Map<String,TabletServerMutations<T>> binnedMutations, List<T> failures) { TabletLocation rootTabletLocation = getRootTabletLocation(context); if (rootTabletLocation != null) { - TabletServerMutations<T> tsm = new TabletServerMutations<>(rootTabletLocation.tablet_session); + var tsm = new TabletServerMutations<T>(rootTabletLocation.getTserverSession()); for (T mutation : mutations) { tsm.addMutation(RootTable.EXTENT, mutation); } - binnedMutations.put(rootTabletLocation.tablet_location, tsm); + binnedMutations.put(rootTabletLocation.getTserverLocation(), tsm); } else { failures.addAll(mutations); } @@ -73,7 +73,7 @@ public class RootTabletLocator extends TabletLocator { TabletLocation rootTabletLocation = getRootTabletLocation(context); if (rootTabletLocation != null) { for (Range range : ranges) { - TabletLocatorImpl.addRange(binnedRanges, rootTabletLocation.tablet_location, + TabletLocatorImpl.addRange(binnedRanges, rootTabletLocation.getTserverLocation(), RootTable.EXTENT, range); } return Collections.emptyList(); diff --git a/core/src/main/java/org/apache/accumulo/core/clientImpl/SyncingTabletLocator.java b/core/src/main/java/org/apache/accumulo/core/clientImpl/SyncingTabletLocator.java index 8f6daed955..ff9a75cf3f 100644 --- a/core/src/main/java/org/apache/accumulo/core/clientImpl/SyncingTabletLocator.java +++ b/core/src/main/java/org/apache/accumulo/core/clientImpl/SyncingTabletLocator.java @@ -21,7 +21,7 @@ package org.apache.accumulo.core.clientImpl; import java.util.Collection; import java.util.List; import java.util.Map; -import java.util.concurrent.Callable; +import java.util.function.Supplier; import org.apache.accumulo.core.client.AccumuloException; import org.apache.accumulo.core.client.AccumuloSecurityException; @@ -43,16 +43,11 @@ public class SyncingTabletLocator extends TabletLocator { private static final Logger log = LoggerFactory.getLogger(SyncingTabletLocator.class); private volatile TabletLocator locator; - private final Callable<TabletLocator> getLocatorFunction; + private final Supplier<TabletLocator> getLocatorFunction; - public SyncingTabletLocator(Callable<TabletLocator> getLocatorFunction) { + public SyncingTabletLocator(Supplier<TabletLocator> getLocatorFunction) { this.getLocatorFunction = getLocatorFunction; - try { - this.locator = getLocatorFunction.call(); - } catch (Exception e) { - log.error("Problem obtaining TabletLocator", e); - throw new RuntimeException(e); - } + this.locator = getLocatorFunction.get(); } public SyncingTabletLocator(final ClientContext context, final TableId tableId) { @@ -64,12 +59,7 @@ public class SyncingTabletLocator extends TabletLocator { if (!loc.isValid()) { synchronized (this) { if (locator == loc) { - try { - loc = locator = getLocatorFunction.call(); - } catch (Exception e) { - log.error("Problem obtaining TabletLocator", e); - throw new RuntimeException(e); - } + loc = locator = getLocatorFunction.get(); } } } diff --git a/core/src/main/java/org/apache/accumulo/core/clientImpl/TableOperationsImpl.java b/core/src/main/java/org/apache/accumulo/core/clientImpl/TableOperationsImpl.java index d42bf04493..4cc4d573e2 100644 --- a/core/src/main/java/org/apache/accumulo/core/clientImpl/TableOperationsImpl.java +++ b/core/src/main/java/org/apache/accumulo/core/clientImpl/TableOperationsImpl.java @@ -561,7 +561,7 @@ public class TableOperationsImpl extends TableOperationsHelper { continue; } - HostAndPort address = HostAndPort.fromString(tl.tablet_location); + HostAndPort address = HostAndPort.fromString(tl.getTserverLocation()); try { TabletManagementClientService.Client client = @@ -572,15 +572,15 @@ public class TableOperationsImpl extends TableOperationsHelper { if (log.isTraceEnabled()) { log.trace("tid={} Splitting tablet {} on {} at {}", Thread.currentThread().getId(), - tl.tablet_extent, address, split); + tl.getExtent(), address, split); timer = new OpTimer().start(); } - client.splitTablet(TraceUtil.traceInfo(), context.rpcCreds(), - tl.tablet_extent.toThrift(), TextUtil.getByteBuffer(split)); + client.splitTablet(TraceUtil.traceInfo(), context.rpcCreds(), tl.getExtent().toThrift(), + TextUtil.getByteBuffer(split)); // just split it, might as well invalidate it in the cache - tabLocator.invalidateCache(tl.tablet_extent); + tabLocator.invalidateCache(tl.getExtent()); if (timer != null) { timer.stop(); @@ -605,10 +605,10 @@ public class TableOperationsImpl extends TableOperationsHelper { + " Seen {} failures.", split, env.tableName, locationFailures); } - tabLocator.invalidateCache(tl.tablet_extent); + tabLocator.invalidateCache(tl.getExtent()); continue; } catch (TException e) { - tabLocator.invalidateCache(context, tl.tablet_location); + tabLocator.invalidateCache(context, tl.getTserverLocation()); continue; } diff --git a/core/src/main/java/org/apache/accumulo/core/clientImpl/TabletLocator.java b/core/src/main/java/org/apache/accumulo/core/clientImpl/TabletLocator.java index b8e4c533a3..cf5c452e1f 100644 --- a/core/src/main/java/org/apache/accumulo/core/clientImpl/TabletLocator.java +++ b/core/src/main/java/org/apache/accumulo/core/clientImpl/TabletLocator.java @@ -25,6 +25,7 @@ import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Objects; import org.apache.accumulo.core.client.AccumuloException; import org.apache.accumulo.core.client.AccumuloSecurityException; @@ -194,54 +195,53 @@ public abstract class TabletLocator { } } - public static class TabletLocation implements Comparable<TabletLocation> { + public static class TabletLocation { private static final Interner<String> interner = new Interner<>(); - public final KeyExtent tablet_extent; - public final String tablet_location; - public final String tablet_session; + private final KeyExtent tablet_extent; + private final String tserverLocation; + private final String tserverSession; public TabletLocation(KeyExtent tablet_extent, String tablet_location, String session) { checkArgument(tablet_extent != null, "tablet_extent is null"); checkArgument(tablet_location != null, "tablet_location is null"); checkArgument(session != null, "session is null"); this.tablet_extent = tablet_extent; - this.tablet_location = interner.intern(tablet_location); - this.tablet_session = interner.intern(session); + this.tserverLocation = interner.intern(tablet_location); + this.tserverSession = interner.intern(session); } @Override public boolean equals(Object o) { if (o instanceof TabletLocation) { TabletLocation otl = (TabletLocation) o; - return tablet_extent.equals(otl.tablet_extent) - && tablet_location.equals(otl.tablet_location) - && tablet_session.equals(otl.tablet_session); + return getExtent().equals(otl.getExtent()) + && getTserverLocation().equals(otl.getTserverLocation()) + && getTserverSession().equals(otl.getTserverSession()); } return false; } @Override public int hashCode() { - throw new UnsupportedOperationException( - "hashcode is not implemented for class " + this.getClass()); + return Objects.hash(getExtent(), tserverLocation, tserverSession); } @Override public String toString() { - return "(" + tablet_extent + "," + tablet_location + "," + tablet_session + ")"; + return "(" + getExtent() + "," + getTserverLocation() + "," + getTserverSession() + ")"; } - @Override - public int compareTo(TabletLocation o) { - int result = tablet_extent.compareTo(o.tablet_extent); - if (result == 0) { - result = tablet_location.compareTo(o.tablet_location); - if (result == 0) { - result = tablet_session.compareTo(o.tablet_session); - } - } - return result; + public KeyExtent getExtent() { + return tablet_extent; + } + + public String getTserverLocation() { + return tserverLocation; + } + + public String getTserverSession() { + return tserverSession; } } diff --git a/core/src/main/java/org/apache/accumulo/core/clientImpl/TabletLocatorImpl.java b/core/src/main/java/org/apache/accumulo/core/clientImpl/TabletLocatorImpl.java index cefd459e7c..dafada9132 100644 --- a/core/src/main/java/org/apache/accumulo/core/clientImpl/TabletLocatorImpl.java +++ b/core/src/main/java/org/apache/accumulo/core/clientImpl/TabletLocatorImpl.java @@ -125,7 +125,7 @@ public class TabletLocatorImpl extends TabletLocator { return null; } - Pair<String,String> lock = new Pair<>(tl.tablet_location, tl.tablet_session); + Pair<String,String> lock = new Pair<>(tl.getTserverLocation(), tl.getTserverSession()); if (okLocks.contains(lock)) { return tl; @@ -135,14 +135,14 @@ public class TabletLocatorImpl extends TabletLocator { return null; } - if (lockChecker.isLockHeld(tl.tablet_location, tl.tablet_session)) { + if (lockChecker.isLockHeld(tl.getTserverLocation(), tl.getTserverSession())) { okLocks.add(lock); return tl; } if (log.isTraceEnabled()) { - log.trace("Tablet server {} {} no longer holds its lock", tl.tablet_location, - tl.tablet_session); + log.trace("Tablet server {} {} no longer holds its lock", tl.getTserverLocation(), + tl.getTserverSession()); } invalidLocks.add(lock); @@ -244,22 +244,22 @@ public class TabletLocatorImpl extends TabletLocator { private <T extends Mutation> boolean addMutation( Map<String,TabletServerMutations<T>> binnedMutations, T mutation, TabletLocation tl, LockCheckerSession lcSession) { - TabletServerMutations<T> tsm = binnedMutations.get(tl.tablet_location); + TabletServerMutations<T> tsm = binnedMutations.get(tl.getTserverLocation()); if (tsm == null) { // do lock check once per tserver here to make binning faster boolean lockHeld = lcSession.checkLock(tl) != null; if (lockHeld) { - tsm = new TabletServerMutations<>(tl.tablet_session); - binnedMutations.put(tl.tablet_location, tsm); + tsm = new TabletServerMutations<>(tl.getTserverSession()); + binnedMutations.put(tl.getTserverLocation(), tsm); } else { return false; } } // its possible the same tserver could be listed with different sessions - if (tsm.getSession().equals(tl.tablet_session)) { - tsm.addMutation(tl.tablet_extent, mutation); + if (tsm.getSession().equals(tl.getTserverSession())) { + tsm.addMutation(tl.getExtent(), mutation); return true; } @@ -269,10 +269,10 @@ public class TabletLocatorImpl extends TabletLocator { static boolean isContiguous(List<TabletLocation> tabletLocations) { Iterator<TabletLocation> iter = tabletLocations.iterator(); - KeyExtent prevExtent = iter.next().tablet_extent; + KeyExtent prevExtent = iter.next().getExtent(); while (iter.hasNext()) { - KeyExtent currExtent = iter.next().tablet_extent; + KeyExtent currExtent = iter.next().getExtent(); if (!currExtent.isPreviousExtent(prevExtent)) { return false; @@ -323,14 +323,14 @@ public class TabletLocatorImpl extends TabletLocator { tabletLocations.add(tl); - while (tl.tablet_extent.endRow() != null - && !range.afterEndKey(new Key(tl.tablet_extent.endRow()).followingKey(PartialKey.ROW))) { + while (tl.getExtent().endRow() != null + && !range.afterEndKey(new Key(tl.getExtent().endRow()).followingKey(PartialKey.ROW))) { if (useCache) { - Text row = new Text(tl.tablet_extent.endRow()); + Text row = new Text(tl.getExtent().endRow()); row.append(new byte[] {0}, 0, 1); tl = lcSession.checkLock(locateTabletInCache(row)); } else { - tl = _locateTablet(context, tl.tablet_extent.endRow(), true, false, false, lcSession); + tl = _locateTablet(context, tl.getExtent().endRow(), true, false, false, lcSession); } if (tl == null) { @@ -349,7 +349,8 @@ public class TabletLocatorImpl extends TabletLocator { // then after that merges and splits happen. if (isContiguous(tabletLocations)) { for (TabletLocation tl2 : tabletLocations) { - TabletLocatorImpl.addRange(binnedRanges, tl2.tablet_location, tl2.tablet_extent, range); + TabletLocatorImpl.addRange(binnedRanges, tl2.getTserverLocation(), tl2.getExtent(), + range); } } else { failures.add(range); @@ -454,8 +455,8 @@ public class TabletLocatorImpl extends TabletLocator { wLock.lock(); try { for (TabletLocation cacheEntry : metaCache.values()) { - if (cacheEntry.tablet_location.equals(server)) { - badExtents.add(cacheEntry.tablet_extent); + if (cacheEntry.getTserverLocation().equals(server)) { + badExtents.add(cacheEntry.getExtent()); invalidatedCount++; } } @@ -516,7 +517,7 @@ public class TabletLocatorImpl extends TabletLocator { if (timer != null) { timer.stop(); log.trace("tid={} Located tablet {} at {} in {}", Thread.currentThread().getId(), - (tl == null ? "null" : tl.tablet_extent), (tl == null ? "null" : tl.tablet_location), + (tl == null ? "null" : tl.getExtent()), (tl == null ? "null" : tl.getTserverLocation()), String.format("%.3f secs", timer.scale(SECONDS))); } @@ -538,7 +539,7 @@ public class TabletLocatorImpl extends TabletLocator { while (locations != null && locations.getLocations().isEmpty() && locations.getLocationless().isEmpty()) { // try the next tablet, the current tablet does not have any tablets that overlap the row - Text er = ptl.tablet_extent.endRow(); + Text er = ptl.getExtent().endRow(); if (er != null && er.compareTo(lastTabletRow) < 0) { // System.out.println("er "+er+" ltr "+lastTabletRow); ptl = parent.locateTablet(context, er, true, retry); @@ -563,20 +564,20 @@ public class TabletLocatorImpl extends TabletLocator { Text lastEndRow = null; for (TabletLocation tabletLocation : locations.getLocations()) { - KeyExtent ke = tabletLocation.tablet_extent; + KeyExtent ke = tabletLocation.getExtent(); TabletLocation locToCache; // create new location if current prevEndRow == endRow if ((lastEndRow != null) && (ke.prevEndRow() != null) && ke.prevEndRow().equals(lastEndRow)) { locToCache = new TabletLocation(new KeyExtent(ke.tableId(), ke.endRow(), lastEndRow), - tabletLocation.tablet_location, tabletLocation.tablet_session); + tabletLocation.getTserverLocation(), tabletLocation.getTserverSession()); } else { locToCache = tabletLocation; } // save endRow for next iteration - lastEndRow = locToCache.tablet_extent.endRow(); + lastEndRow = locToCache.getExtent().endRow(); updateCache(locToCache, lcSession); } @@ -585,20 +586,20 @@ public class TabletLocatorImpl extends TabletLocator { } private void updateCache(TabletLocation tabletLocation, LockCheckerSession lcSession) { - if (!tabletLocation.tablet_extent.tableId().equals(tableId)) { + if (!tabletLocation.getExtent().tableId().equals(tableId)) { // sanity check throw new IllegalStateException( - "Unexpected extent returned " + tableId + " " + tabletLocation.tablet_extent); + "Unexpected extent returned " + tableId + " " + tabletLocation.getExtent()); } - if (tabletLocation.tablet_location == null) { + if (tabletLocation.getTserverLocation() == null) { // sanity check throw new IllegalStateException( - "Cannot add null locations to cache " + tableId + " " + tabletLocation.tablet_extent); + "Cannot add null locations to cache " + tableId + " " + tabletLocation.getExtent()); } // clear out any overlapping extents in cache - removeOverlapping(metaCache, tabletLocation.tablet_extent); + removeOverlapping(metaCache, tabletLocation.getExtent()); // do not add to cache unless lock is held if (lcSession.checkLock(tabletLocation) == null) { @@ -606,14 +607,14 @@ public class TabletLocatorImpl extends TabletLocator { } // add it to cache - Text er = tabletLocation.tablet_extent.endRow(); + Text er = tabletLocation.getExtent().endRow(); if (er == null) { er = MAX_TEXT; } metaCache.put(er, tabletLocation); if (!badExtents.isEmpty()) { - removeOverlapping(badExtents, tabletLocation.tablet_extent); + removeOverlapping(badExtents, tabletLocation.getExtent()); } } @@ -631,7 +632,7 @@ public class TabletLocatorImpl extends TabletLocator { while (iter.hasNext()) { Entry<Text,TabletLocation> entry = iter.next(); - KeyExtent ke = entry.getValue().tablet_extent; + KeyExtent ke = entry.getValue().getExtent(); if (stopRemoving(nke, ke)) { break; @@ -663,7 +664,7 @@ public class TabletLocatorImpl extends TabletLocator { Entry<Text,TabletLocation> entry = metaCache.ceilingEntry(row); if (entry != null) { - KeyExtent ke = entry.getValue().tablet_extent; + KeyExtent ke = entry.getValue().getExtent(); if (ke.prevEndRow() == null || ke.prevEndRow().compareTo(row) < 0) { return entry.getValue(); } diff --git a/core/src/main/java/org/apache/accumulo/core/clientImpl/ThriftScanner.java b/core/src/main/java/org/apache/accumulo/core/clientImpl/ThriftScanner.java index 1198924519..663b3748c1 100644 --- a/core/src/main/java/org/apache/accumulo/core/clientImpl/ThriftScanner.java +++ b/core/src/main/java/org/apache/accumulo/core/clientImpl/ThriftScanner.java @@ -332,18 +332,18 @@ public class ThriftScanner { } else { // when a tablet splits we do want to continue scanning the low child // of the split if we are already passed it - Range dataRange = loc.tablet_extent.toDataRange(); + Range dataRange = loc.getExtent().toDataRange(); if (scanState.range.getStartKey() != null && dataRange.afterEndKey(scanState.range.getStartKey())) { // go to the next tablet - scanState.startRow = loc.tablet_extent.endRow(); + scanState.startRow = loc.getExtent().endRow(); scanState.skipStartRow = true; loc = null; } else if (scanState.range.getEndKey() != null && dataRange.beforeStartKey(scanState.range.getEndKey())) { // should not happen - throw new RuntimeException("Unexpected tablet, extent : " + loc.tablet_extent + throw new RuntimeException("Unexpected tablet, extent : " + loc.getExtent() + " range : " + scanState.range + " startRow : " + scanState.startRow); } } @@ -369,7 +369,7 @@ public class ThriftScanner { } Span child2 = TraceUtil.startSpan(ThriftScanner.class, "scan::location", - Map.of("tserver", loc.tablet_location)); + Map.of("tserver", loc.getTserverLocation())); try (Scope scanLocation = child2.makeCurrent()) { results = scan(loc, scanState, context); } catch (AccumuloSecurityException e) { @@ -380,7 +380,7 @@ public class ThriftScanner { throw e; } catch (TApplicationException tae) { TraceUtil.setException(child2, tae, true); - throw new AccumuloServerException(scanState.getErrorLocation().tablet_location, tae); + throw new AccumuloServerException(scanState.getErrorLocation().getTserverLocation(), tae); } catch (TSampleNotPresentException tsnpe) { String message = "Table " + context.getPrintableTableInfoFromId(scanState.tableId) + " does not have sampling configured or built"; @@ -395,7 +395,7 @@ public class ThriftScanner { } lastError = error; - TabletLocator.getLocator(context, scanState.tableId).invalidateCache(loc.tablet_extent); + TabletLocator.getLocator(context, scanState.tableId).invalidateCache(loc.getExtent()); loc = null; // no need to try the current scan id somewhere else @@ -470,7 +470,7 @@ public class ThriftScanner { sleepMillis = pause(sleepMillis, maxSleepTime, scanState.runOnScanServer); } catch (TException e) { TabletLocator.getLocator(context, scanState.tableId).invalidateCache(context, - loc.tablet_location); + loc.getTserverLocation()); error = "Scan failed, thrift error " + e.getClass().getName() + " " + e.getMessage() + " " + scanState.getErrorLocation(); if (!error.equals(lastError)) { @@ -522,17 +522,17 @@ public class ThriftScanner { TabletLocation newLoc; - var tabletId = new TabletIdImpl(loc.tablet_extent); + var tabletId = new TabletIdImpl(loc.getExtent()); if (scanState.scanID != null && scanState.prevLoc != null - && scanState.prevLoc.tablet_session.equals("scan_server") - && scanState.prevLoc.tablet_extent.equals(loc.tablet_extent)) { + && scanState.prevLoc.getTserverSession().equals("scan_server") + && scanState.prevLoc.getExtent().equals(loc.getExtent())) { // this is the case of continuing a scan on a scan server for the same tablet, so lets not // call the scan server selector and just go back to the previous scan server newLoc = scanState.prevLoc; log.trace( "For tablet {} continuing scan on scan server {} without consulting scan server selector, using busyTimeout {}", - loc.tablet_extent, newLoc.tablet_location, scanState.busyTimeout); + loc.getExtent(), newLoc.getTserverLocation(), scanState.busyTimeout); } else { // obtain a snapshot once and only expose this snapshot to the plugin for consistency var attempts = scanState.scanAttempts.snapshot(); @@ -564,17 +564,17 @@ public class ThriftScanner { String scanServer = actions.getScanServer(tabletId); if (scanServer != null) { - newLoc = new TabletLocation(loc.tablet_extent, scanServer, "scan_server"); + newLoc = new TabletLocation(loc.getExtent(), scanServer, "scan_server"); delay = actions.getDelay(); scanState.busyTimeout = actions.getBusyTimeout(); log.trace( "For tablet {} scan server selector chose scan_server:{} delay:{} busyTimeout:{}", - loc.tablet_extent, scanServer, delay, scanState.busyTimeout); + loc.getExtent(), scanServer, delay, scanState.busyTimeout); } else { newLoc = loc; delay = actions.getDelay(); scanState.busyTimeout = Duration.ZERO; - log.trace("For tablet {} scan server selector chose tablet_server", loc.tablet_extent); + log.trace("For tablet {} scan server selector chose tablet_server", loc.getExtent()); } if (!delay.isZero()) { @@ -587,7 +587,7 @@ public class ThriftScanner { } } - var reporter = scanState.scanAttempts.createReporter(newLoc.tablet_location, tabletId); + var reporter = scanState.scanAttempts.createReporter(newLoc.getTserverLocation(), tabletId); try { return scanRpc(newLoc, scanState, context, scanState.busyTimeout.toMillis()); @@ -612,7 +612,7 @@ public class ThriftScanner { final TInfo tinfo = TraceUtil.traceInfo(); - final HostAndPort parsedLocation = HostAndPort.fromString(loc.tablet_location); + final HostAndPort parsedLocation = HostAndPort.fromString(loc.getTserverLocation()); TabletScanClientService.Client client = ThriftUtil.getClient(ThriftClientTypes.TABLET_SCAN, parsedLocation, context); @@ -627,23 +627,24 @@ public class ThriftScanner { scanState.prevLoc = loc; if (scanState.scanID == null) { - Thread.currentThread().setName("Starting scan tserver=" + loc.tablet_location + " tableId=" - + loc.tablet_extent.tableId()); + Thread.currentThread().setName("Starting scan tserver=" + loc.getTserverLocation() + + " tableId=" + loc.getExtent().tableId()); if (log.isTraceEnabled()) { - String msg = "Starting scan tserver=" + loc.tablet_location + " tablet=" - + loc.tablet_extent + " range=" + scanState.range + " ssil=" + String msg = "Starting scan tserver=" + loc.getTserverLocation() + " tablet=" + + loc.getExtent() + " range=" + scanState.range + " ssil=" + scanState.serverSideIteratorList + " ssio=" + scanState.serverSideIteratorOptions + " context=" + scanState.classLoaderContext; log.trace("tid={} {}", Thread.currentThread().getId(), msg); timer = new OpTimer().start(); } - TabletType ttype = TabletType.type(loc.tablet_extent); - boolean waitForWrites = !serversWaitedForWrites.get(ttype).contains(loc.tablet_location); + TabletType ttype = TabletType.type(loc.getExtent()); + boolean waitForWrites = + !serversWaitedForWrites.get(ttype).contains(loc.getTserverLocation()); InitialScan is = client.startScan(tinfo, scanState.context.rpcCreds(), - loc.tablet_extent.toThrift(), scanState.range.toThrift(), + loc.getExtent().toThrift(), scanState.range.toThrift(), scanState.columns.stream().map(Column::toThrift).collect(Collectors.toList()), scanState.size, scanState.serverSideIteratorList, scanState.serverSideIteratorOptions, scanState.authorizations.getAuthorizationsBB(), waitForWrites, scanState.isolated, @@ -651,7 +652,7 @@ public class ThriftScanner { SamplerConfigurationImpl.toThrift(scanState.samplerConfig), scanState.batchTimeOut, scanState.classLoaderContext, scanState.executionHints, busyTimeout); if (waitForWrites) { - serversWaitedForWrites.get(ttype).add(loc.tablet_location); + serversWaitedForWrites.get(ttype).add(loc.getTserverLocation()); } sr = is.result; @@ -665,7 +666,7 @@ public class ThriftScanner { } else { // log.debug("Calling continue scan : "+scanState.range+" loc = "+loc); String msg = - "Continuing scan tserver=" + loc.tablet_location + " scanid=" + scanState.scanID; + "Continuing scan tserver=" + loc.getTserverLocation() + " scanid=" + scanState.scanID; Thread.currentThread().setName(msg); if (log.isTraceEnabled()) { @@ -690,7 +691,7 @@ public class ThriftScanner { } else { // log.debug("No more : tab end row = "+loc.tablet_extent.getEndRow()+" range = // "+scanState.range); - if (loc.tablet_extent.endRow() == null) { + if (loc.getExtent().endRow() == null) { scanState.finished = true; if (timer != null) { @@ -701,8 +702,8 @@ public class ThriftScanner { } } else if (scanState.range.getEndKey() == null || !scanState.range - .afterEndKey(new Key(loc.tablet_extent.endRow()).followingKey(PartialKey.ROW))) { - scanState.startRow = loc.tablet_extent.endRow(); + .afterEndKey(new Key(loc.getExtent().endRow()).followingKey(PartialKey.ROW))) { + scanState.startRow = loc.getExtent().endRow(); scanState.skipStartRow = true; if (timer != null) { @@ -749,7 +750,7 @@ public class ThriftScanner { TInfo tinfo = TraceUtil.traceInfo(); log.debug("Closing active scan {} {}", scanState.prevLoc, scanState.scanID); - HostAndPort parsedLocation = HostAndPort.fromString(scanState.prevLoc.tablet_location); + HostAndPort parsedLocation = HostAndPort.fromString(scanState.prevLoc.getTserverLocation()); TabletScanClientService.Client client = null; try { client = diff --git a/core/src/main/java/org/apache/accumulo/core/clientImpl/Writer.java b/core/src/main/java/org/apache/accumulo/core/clientImpl/Writer.java index 6f991e9e18..4a358aee6f 100644 --- a/core/src/main/java/org/apache/accumulo/core/clientImpl/Writer.java +++ b/core/src/main/java/org/apache/accumulo/core/clientImpl/Writer.java @@ -98,21 +98,21 @@ public class Writer { continue; } - final HostAndPort parsedLocation = HostAndPort.fromString(tabLoc.tablet_location); + final HostAndPort parsedLocation = HostAndPort.fromString(tabLoc.getTserverLocation()); try { - updateServer(context, m, tabLoc.tablet_extent, parsedLocation); + updateServer(context, m, tabLoc.getExtent(), parsedLocation); return; } catch (NotServingTabletException e) { log.trace("Not serving tablet, server = {}", parsedLocation); - TabletLocator.getLocator(context, tableId).invalidateCache(tabLoc.tablet_extent); + TabletLocator.getLocator(context, tableId).invalidateCache(tabLoc.getExtent()); } catch (ConstraintViolationException cve) { log.error("error sending update to {}", parsedLocation, cve); // probably do not need to invalidate cache, but it does not hurt - TabletLocator.getLocator(context, tableId).invalidateCache(tabLoc.tablet_extent); + TabletLocator.getLocator(context, tableId).invalidateCache(tabLoc.getExtent()); throw cve; } catch (TException e) { log.error("error sending update to {}", parsedLocation, e); - TabletLocator.getLocator(context, tableId).invalidateCache(tabLoc.tablet_extent); + TabletLocator.getLocator(context, tableId).invalidateCache(tabLoc.getExtent()); } sleepUninterruptibly(500, MILLISECONDS); diff --git a/core/src/main/java/org/apache/accumulo/core/metadata/MetadataLocationObtainer.java b/core/src/main/java/org/apache/accumulo/core/metadata/MetadataLocationObtainer.java index 9ac2658f63..6d0f2aa735 100644 --- a/core/src/main/java/org/apache/accumulo/core/metadata/MetadataLocationObtainer.java +++ b/core/src/main/java/org/apache/accumulo/core/metadata/MetadataLocationObtainer.java @@ -88,8 +88,8 @@ public class MetadataLocationObtainer implements TabletLocationObtainer { if (log.isTraceEnabled()) { log.trace("tid={} Looking up in {} row={} extent={} tserver={}", - Thread.currentThread().getId(), src.tablet_extent.tableId(), TextUtil.truncate(row), - src.tablet_extent, src.tablet_location); + Thread.currentThread().getId(), src.getExtent().tableId(), TextUtil.truncate(row), + src.getExtent(), src.getTserverLocation()); timer = new OpTimer().start(); } @@ -105,8 +105,8 @@ public class MetadataLocationObtainer implements TabletLocationObtainer { List<IterInfo> serverSideIteratorList = new ArrayList<>(); serverSideIteratorList.add(new IterInfo(10000, WholeRowIterator.class.getName(), "WRI")); Map<String,Map<String,String>> serverSideIteratorOptions = Collections.emptyMap(); - boolean more = ThriftScanner.getBatchFromServer(context, range, src.tablet_extent, - src.tablet_location, encodedResults, locCols, serverSideIteratorList, + boolean more = ThriftScanner.getBatchFromServer(context, range, src.getExtent(), + src.getTserverLocation(), encodedResults, locCols, serverSideIteratorList, serverSideIteratorOptions, Constants.SCAN_BATCH_SIZE, Authorizations.EMPTY, 0L, null); decodeRows(encodedResults, results); @@ -115,7 +115,7 @@ public class MetadataLocationObtainer implements TabletLocationObtainer { range = new Range(results.lastKey().followingKey(PartialKey.ROW_COLFAM_COLQUAL_COLVIS_TIME), true, new Key(stopRow).followingKey(PartialKey.ROW), false); encodedResults.clear(); - ThriftScanner.getBatchFromServer(context, range, src.tablet_extent, src.tablet_location, + ThriftScanner.getBatchFromServer(context, range, src.getExtent(), src.getTserverLocation(), encodedResults, locCols, serverSideIteratorList, serverSideIteratorOptions, Constants.SCAN_BATCH_SIZE, Authorizations.EMPTY, 0L, null); @@ -125,7 +125,7 @@ public class MetadataLocationObtainer implements TabletLocationObtainer { if (timer != null) { timer.stop(); log.trace("tid={} Got {} results from {} in {}", Thread.currentThread().getId(), - results.size(), src.tablet_extent, String.format("%.3f secs", timer.scale(SECONDS))); + results.size(), src.getExtent(), String.format("%.3f secs", timer.scale(SECONDS))); } // if (log.isTraceEnabled()) log.trace("results "+results); @@ -134,15 +134,15 @@ public class MetadataLocationObtainer implements TabletLocationObtainer { } catch (AccumuloServerException ase) { if (log.isTraceEnabled()) { - log.trace("{} lookup failed, {} server side exception", src.tablet_extent.tableId(), - src.tablet_location); + log.trace("{} lookup failed, {} server side exception", src.getExtent().tableId(), + src.getTserverLocation()); } throw ase; } catch (AccumuloException e) { if (log.isTraceEnabled()) { - log.trace("{} lookup failed", src.tablet_extent.tableId(), e); + log.trace("{} lookup failed", src.getExtent().tableId(), e); } - parent.invalidateCache(context, src.tablet_location); + parent.invalidateCache(context, src.getTserverLocation()); } return null; diff --git a/core/src/test/java/org/apache/accumulo/core/clientImpl/TabletLocatorImplTest.java b/core/src/test/java/org/apache/accumulo/core/clientImpl/TabletLocatorImplTest.java index ea20ee6643..97e01c4d3d 100644 --- a/core/src/test/java/org/apache/accumulo/core/clientImpl/TabletLocatorImplTest.java +++ b/core/src/test/java/org/apache/accumulo/core/clientImpl/TabletLocatorImplTest.java @@ -170,7 +170,7 @@ public class TabletLocatorImplTest { for (Entry<KeyExtent,TabletLocation> entry : mcke.entrySet()) { setLocation(tservers, metaTabLoc, METADATA_TABLE_EXTENT, entry.getKey(), - entry.getValue().tablet_location); + entry.getValue().getTserverLocation()); } return tab1TabletCache; @@ -236,7 +236,7 @@ public class TabletLocatorImplTest { HashSet<KeyExtent> eic = new HashSet<>(); for (TabletLocation tl : metaCache.values()) { - eic.add(tl.tablet_extent); + eic.add(tl.getExtent()); } assertEquals(expected, eic); @@ -485,22 +485,22 @@ public class TabletLocatorImplTest { public TabletLocations lookupTablet(ClientContext context, TabletLocation src, Text row, Text stopRow, TabletLocator parent) { - Map<KeyExtent,SortedMap<Key,Value>> tablets = tservers.get(src.tablet_location); + Map<KeyExtent,SortedMap<Key,Value>> tablets = tservers.get(src.getTserverLocation()); if (tablets == null) { - parent.invalidateCache(context, src.tablet_location); + parent.invalidateCache(context, src.getTserverLocation()); return null; } - SortedMap<Key,Value> tabletData = tablets.get(src.tablet_extent); + SortedMap<Key,Value> tabletData = tablets.get(src.getExtent()); if (tabletData == null) { - parent.invalidateCache(src.tablet_extent); + parent.invalidateCache(src.getExtent()); return null; } // the following clip is done on a tablet, do it here to see if it throws exceptions - src.tablet_extent.toDataRange().clip(new Range(row, true, stopRow, true)); + src.getExtent().toDataRange().clip(new Range(row, true, stopRow, true)); Key startKey = new Key(row); Key stopKey = new Key(stopRow).followingKey(PartialKey.ROW); @@ -661,8 +661,8 @@ public class TabletLocatorImplTest { assertNull(tl); } else { assertNotNull(tl); - assertEquals(server, tl.tablet_location); - assertEquals(expected, tl.tablet_extent); + assertEquals(server, tl.getTserverLocation()); + assertEquals(expected, tl.getExtent()); } } diff --git a/server/base/src/main/java/org/apache/accumulo/server/client/BulkImporter.java b/server/base/src/main/java/org/apache/accumulo/server/client/BulkImporter.java index 7acd327db1..09401ac705 100644 --- a/server/base/src/main/java/org/apache/accumulo/server/client/BulkImporter.java +++ b/server/base/src/main/java/org/apache/accumulo/server/client/BulkImporter.java @@ -340,7 +340,7 @@ public class BulkImporter { private static List<KeyExtent> extentsOf(List<TabletLocation> locations) { List<KeyExtent> result = new ArrayList<>(locations.size()); for (TabletLocation tl : locations) { - result.add(tl.tablet_extent); + result.add(tl.getExtent()); } return result; } @@ -374,7 +374,7 @@ public class BulkImporter { // need to estimate its // size ais.put(entry.getKey(), Collections.singletonList( - new AssignmentInfo(tabletLocation.tablet_extent, mapFileSizes.get(entry.getKey())))); + new AssignmentInfo(tabletLocation.getExtent(), mapFileSizes.get(entry.getKey())))); continue; } @@ -398,7 +398,7 @@ public class BulkImporter { long estSize = (long) (mapFileSizes.get(entry.getKey()) / (double) entry.getValue().size()); for (TabletLocation tl : entry.getValue()) { - estimatedSizes.put(tl.tablet_extent, estSize); + estimatedSizes.put(tl.getExtent(), estSize); } } @@ -437,7 +437,7 @@ public class BulkImporter { Map<KeyExtent,String> result = new HashMap<>(); for (List<TabletLocation> entry : assignments.values()) { for (TabletLocation tl : entry) { - result.put(tl.tablet_extent, tl.tablet_location); + result.put(tl.getExtent(), tl.getTserverLocation()); } } return result; @@ -669,7 +669,7 @@ public class BulkImporter { TabletLocation tabletLocation = locator.locateTablet(context, row, false, true); // log.debug(filename + " found row " + row + " at location " + tabletLocation); result.add(tabletLocation); - row = tabletLocation.tablet_extent.endRow(); + row = tabletLocation.getExtent().endRow(); if (row != null && (endRow == null || row.compareTo(endRow) < 0)) { row = new Text(row); row.append(byte0, 0, byte0.length); @@ -697,9 +697,9 @@ public class BulkImporter { for (Entry<Path,List<TabletLocation>> entry : assignments.entrySet()) { for (TabletLocation tl : entry.getValue()) { - Integer count = getCount(tl.tablet_extent); + Integer count = getCount(tl.getExtent()); - counts.put(tl.tablet_extent, count + 1); + counts.put(tl.getExtent(), count + 1); } } } diff --git a/server/base/src/test/java/org/apache/accumulo/server/client/BulkImporterTest.java b/server/base/src/test/java/org/apache/accumulo/server/client/BulkImporterTest.java index 9b69efa196..e37783e826 100644 --- a/server/base/src/test/java/org/apache/accumulo/server/client/BulkImporterTest.java +++ b/server/base/src/test/java/org/apache/accumulo/server/client/BulkImporterTest.java @@ -23,6 +23,7 @@ import static org.junit.jupiter.api.Assertions.assertNull; import java.util.Collection; import java.util.Collections; +import java.util.Comparator; import java.util.List; import java.util.Map; import java.util.SortedSet; @@ -147,25 +148,25 @@ public class BulkImporterTest { List<TabletLocation> overlaps = BulkImporter.findOverlappingTablets(context, vm, locator, new Path(file), null, null, cs); assertEquals(5, overlaps.size()); - Collections.sort(overlaps); - assertEquals(new KeyExtent(tableId, new Text("a"), null), overlaps.get(0).tablet_extent); + Collections.sort(overlaps, Comparator.comparing(tl -> tl.getExtent())); + assertEquals(new KeyExtent(tableId, new Text("a"), null), overlaps.get(0).getExtent()); assertEquals(new KeyExtent(tableId, new Text("d"), new Text("cm")), - overlaps.get(1).tablet_extent); + overlaps.get(1).getExtent()); assertEquals(new KeyExtent(tableId, new Text("dm"), new Text("d")), - overlaps.get(2).tablet_extent); + overlaps.get(2).getExtent()); assertEquals(new KeyExtent(tableId, new Text("j"), new Text("i")), - overlaps.get(3).tablet_extent); - assertEquals(new KeyExtent(tableId, null, new Text("l")), overlaps.get(4).tablet_extent); + overlaps.get(3).getExtent()); + assertEquals(new KeyExtent(tableId, null, new Text("l")), overlaps.get(4).getExtent()); List<TabletLocation> overlaps2 = BulkImporter.findOverlappingTablets(context, vm, locator, new Path(file), new KeyExtent(tableId, new Text("h"), new Text("b")), cs); assertEquals(3, overlaps2.size()); assertEquals(new KeyExtent(tableId, new Text("d"), new Text("cm")), - overlaps2.get(0).tablet_extent); + overlaps2.get(0).getExtent()); assertEquals(new KeyExtent(tableId, new Text("dm"), new Text("d")), - overlaps2.get(1).tablet_extent); + overlaps2.get(1).getExtent()); assertEquals(new KeyExtent(tableId, new Text("j"), new Text("i")), - overlaps2.get(2).tablet_extent); + overlaps2.get(2).getExtent()); assertEquals(locator.invalidated, 1); } } diff --git a/test/src/main/java/org/apache/accumulo/test/functional/BulkFailureIT.java b/test/src/main/java/org/apache/accumulo/test/functional/BulkFailureIT.java index 9322042527..5bd88cc91c 100644 --- a/test/src/main/java/org/apache/accumulo/test/functional/BulkFailureIT.java +++ b/test/src/main/java/org/apache/accumulo/test/functional/BulkFailureIT.java @@ -307,7 +307,7 @@ public class BulkFailureIT extends AccumuloClusterHarness { locator.invalidateCache(extent); HostAndPort location = HostAndPort - .fromString(locator.locateTablet(context, new Text(""), false, true).tablet_location); + .fromString(locator.locateTablet(context, new Text(""), false, true).getTserverLocation()); long timeInMillis = context.getConfiguration().getTimeInMillis(Property.TSERV_BULK_TIMEOUT); TabletIngestClientService.Iface client = diff --git a/test/src/main/java/org/apache/accumulo/test/manager/SuspendedTabletsIT.java b/test/src/main/java/org/apache/accumulo/test/manager/SuspendedTabletsIT.java index 9a5843cfd1..e93b2ccaf2 100644 --- a/test/src/main/java/org/apache/accumulo/test/manager/SuspendedTabletsIT.java +++ b/test/src/main/java/org/apache/accumulo/test/manager/SuspendedTabletsIT.java @@ -189,8 +189,8 @@ public class SuspendedTabletsIT extends ConfigurableMacBase { TabletLocator.TabletLocation tab = tl.locateTablet(ctx, tls.extent.toMetaRow(), false, false); // add it to the set of servers with metadata - metadataServerSet - .add(new TServerInstance(tab.tablet_location, Long.valueOf(tab.tablet_session, 16))); + metadataServerSet.add(new TServerInstance(tab.getTserverLocation(), + Long.valueOf(tab.getTserverSession(), 16))); } }