keith-turner commented on code in PR #3331:
URL: https://github.com/apache/accumulo/pull/3331#discussion_r1175575754


##########
server/base/src/main/java/org/apache/accumulo/server/util/ManagerMetadataUtil.java:
##########
@@ -257,14 +257,23 @@ public static Optional<StoredTabletFile> 
updateTabletDataFile(ServerContext cont
    * @param tabletMutator The mutator being built
    * @param extent The tablet extent
    * @param location The new location
+   * @param prevLastLocation The previous last location, if known
    */
   public static void updateLastForAssignmentMode(ClientContext context, Ample 
ample,
-      Ample.TabletMutator tabletMutator, KeyExtent extent, TServerInstance 
location) {
+      Ample.TabletMutator tabletMutator, KeyExtent extent, TServerInstance 
location,
+      Location prevLastLocation) {
     // if the location mode is assignment, then preserve the current location 
in the last
     // location value
     if 
("assignment".equals(context.getConfiguration().get(Property.TSERV_LAST_LOCATION_MODE)))
 {
-      TabletMetadata lastMetadata = ample.readTablet(extent, 
TabletMetadata.ColumnType.LAST);
-      Location lastLocation = (lastMetadata == null ? null : 
lastMetadata.getLast());
+      // If prevLastLocation is not provided then look it up from metadata
+      final Location lastLocation = 
Optional.ofNullable(prevLastLocation).orElseGet(() -> {
+        log.trace(
+            "Previous last location for {} not provided to 
updateLastForAssignmentMode, loading from metadata.",
+            extent);
+        final TabletMetadata lastMetadata =

Review Comment:
   If the last was not present when we read earlier, then we probably do not 
need to read it again.  Its tricky though because null can have two meanings, 
it can mean it was never read previously or it was read previously and was not 
present.  One simplification is that if we assume that all code calling this 
method has already tried to read the last location, then we never need to read 
it here when null.



-- 
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]

Reply via email to