ctubbsii commented on code in PR #3142:
URL: https://github.com/apache/accumulo/pull/3142#discussion_r1073281593


##########
server/base/src/main/java/org/apache/accumulo/server/manager/state/MetaDataStateStore.java:
##########
@@ -60,9 +62,24 @@ public ClosableIterator<TabletLocationState> iterator() {
   public void setLocations(Collection<Assignment> assignments) throws 
DistributedStoreException {
     try (var tabletsMutator = ample.mutateTablets()) {
       for (Assignment assignment : assignments) {
-        tabletsMutator.mutateTablet(assignment.tablet)
-            .putLocation(assignment.server, LocationType.CURRENT)
-            .deleteLocation(assignment.server, 
LocationType.FUTURE).deleteSuspension().mutate();
+        TabletMutator mutation = 
tabletsMutator.mutateTablet(assignment.tablet);

Review Comment:
   I would just change this variable name, so it's not confused for a 
`Mutation` type object, and so it's consistent with the other places we do this.
   
   ```suggestion
           TabletMutator tabletMutator = 
tabletsMutator.mutateTablet(assignment.tablet);
   ```



##########
core/src/main/java/org/apache/accumulo/core/conf/Property.java:
##########
@@ -726,6 +726,14 @@ public enum Property {
       "The number of threads on each tablet server available to retrieve"
           + " summary data, that is not currently in cache, from RFiles.",
       "2.0.0"),
+  TSERV_LAST_LOCATION_MODE("tserver.last.location.mode", "compaction",
+      PropertyType.LAST_LOCATION_MODE,
+      "Describes how the system will record the 'last' location for tablets, 
which can be used for assigning them when a cluster restarts."
+          + " If 'compaction' is the mode, then the system will record the 
location where the tablet's most recent compaction occurred."
+          + " If 'assignment' is the mode, then the most recently assigned 
location will be recorded."
+          + " Also note that manger.startup.tserver properties might need to 
be set as well to ensure"

Review Comment:
   ```suggestion
             + " The manager.startup.tserver properties might also need to be 
set to ensure"
   ```



##########
server/base/src/main/java/org/apache/accumulo/server/util/ManagerMetadataUtil.java:
##########
@@ -240,11 +245,15 @@ public static Optional<StoredTabletFile> 
updateTabletDataFile(ServerContext cont
       newFile = Optional.of(newDatafile.insert());
 
       TServerInstance self = getTServerInstance(address, zooLock);
-      tablet.putLocation(self, LocationType.LAST);
-
-      // remove the old location
-      if (lastLocation != null && !lastLocation.equals(self)) {
-        tablet.deleteLocation(lastLocation, LocationType.LAST);
+      // if the location mode is 'locality'', then preserve the current 
compaction location in the

Review Comment:
   ```suggestion
         // if the location mode is 'compaction', then preserve the current 
compaction location in the
   ```



##########
server/base/src/main/java/org/apache/accumulo/server/manager/state/MetaDataStateStore.java:
##########
@@ -102,6 +119,21 @@ private void unassign(Collection<TabletLocationState> 
tablets,
       for (TabletLocationState tls : tablets) {
         TabletMutator tabletMutator = tabletsMutator.mutateTablet(tls.extent);
         if (tls.current != null) {
+          // 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(tls.extent, TabletMetadata.ColumnType.LAST);
+            if (lastMetadata != null && lastMetadata.getLast() != null) {
+              if (!lastMetadata.getLast().equals(tls.current)) {
+                tabletMutator.putLocation(tls.current, LocationType.LAST);
+                tabletMutator.deleteLocation(lastMetadata.getLast(), 
LocationType.LAST);
+              }
+            } else {
+              tabletMutator.putLocation(tls.current, LocationType.LAST);
+            }
+          }

Review Comment:
   If it's always updated when it is assigned, do you need to record it again 
here?



##########
test/src/main/java/org/apache/accumulo/test/functional/CompactLocationModeIT.java:
##########
@@ -0,0 +1,111 @@
+/*
+ * 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.test.functional;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+
+import java.time.Duration;
+
+import org.apache.accumulo.core.client.AccumuloClient;
+import org.apache.accumulo.core.client.BatchWriter;
+import org.apache.accumulo.core.client.security.tokens.PasswordToken;
+import org.apache.accumulo.core.clientImpl.ClientContext;
+import org.apache.accumulo.core.conf.Property;
+import org.apache.accumulo.core.data.Mutation;
+import org.apache.accumulo.core.data.Range;
+import org.apache.accumulo.core.data.TableId;
+import org.apache.accumulo.core.metadata.MetadataTable;
+import org.apache.accumulo.core.metadata.TabletLocationState;
+import org.apache.accumulo.core.metadata.schema.MetadataSchema.TabletsSection;
+import org.apache.accumulo.core.util.UtilWaitThread;
+import org.apache.accumulo.server.manager.state.MetaDataTableScanner;
+import org.junit.jupiter.api.Test;
+
+public class CompactLocationModeIT extends ConfigurableMacBase {

Review Comment:
   Since you're extending ConfigurableMacBase, you should probably implement 
the configure method. It would be good to set the mode to "compaction" 
explicitly in that method, in case the default ever changes.



##########
server/base/src/main/java/org/apache/accumulo/server/manager/state/ZooTabletStateStore.java:
##########
@@ -134,6 +138,18 @@ public void setLocations(Collection<Assignment> 
assignments) throws DistributedS
 
     TabletMutator tabletMutator = ample.mutateTablet(assignment.tablet);
     tabletMutator.putLocation(assignment.server, LocationType.CURRENT);
+    if 
("assignment".equals(context.getConfiguration().get(Property.TSERV_LAST_LOCATION_MODE)))
 {
+      TabletMetadata lastMetadata =
+          ample.readTablet(assignment.tablet, TabletMetadata.ColumnType.LAST);
+      if (lastMetadata != null && lastMetadata.getLast() != null) {
+        if (!lastMetadata.getLast().equals(assignment.server)) {
+          tabletMutator.putLocation(assignment.server, LocationType.LAST);
+          tabletMutator.deleteLocation(lastMetadata.getLast(), 
LocationType.LAST);
+        }
+      } else {
+        tabletMutator.putLocation(assignment.server, LocationType.LAST);
+      }
+    }

Review Comment:
   I wonder if this whole block can be put into a method that's common to both 
state stores. They differ very little.



##########
server/base/src/main/java/org/apache/accumulo/server/util/ManagerMetadataUtil.java:
##########
@@ -205,11 +206,15 @@ public static void replaceDatafiles(ServerContext 
context, KeyExtent extent,
     }
 
     TServerInstance self = getTServerInstance(address, zooLock);
-    tablet.putLocation(self, LocationType.LAST);
+    // if the location mode is 'locality'', then preserve the current 
compaction location in the

Review Comment:
   ```suggestion
       // if the location mode is 'compaction', then preserve the current 
compaction location in the
   ```



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