dlmarion commented on code in PR #3331:
URL: https://github.com/apache/accumulo/pull/3331#discussion_r1175302184
##########
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(() -> {
Review Comment:
Could use a conditional statement here and avoid the object creation.
```
Location lastLocation = prevLastLocation;
if (lastLocation == null) {
log.trace(
"Previous last location for {} not provided to
updateLastForAssignmentMode, loading from metadata.", extent);
final TabletMetadata lastMetadata =
ample.readTablet(extent, TabletMetadata.ColumnType.LAST);
lastLocation = lastMetadata == null ? null : lastMetadata.getLast();
}
```
--
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]