This is an automated email from the ASF dual-hosted git repository.

domgarguilo 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 9db57c6  Move checkTableMetaData to AssignmentHandler file (#2334)
9db57c6 is described below

commit 9db57c6adcb717284721608157dd690258e79583
Author: Tulika <fictionfre...@gmail.com>
AuthorDate: Mon Nov 22 19:08:16 2021 +0530

    Move checkTableMetaData to AssignmentHandler file (#2334)
    
    * Move checkTableMetaData() to AssignmentHandler.java
    * Improve error messages
    
    Co-authored-by: Christopher Tubbs <ctubb...@apache.org>
    Co-authored-by: Keith Turner <ktur...@apache.org>
---
 .../apache/accumulo/tserver/AssignmentHandler.java | 45 +++++++++++++++++++++-
 .../org/apache/accumulo/tserver/TabletServer.java  | 41 --------------------
 .../accumulo/tserver/CheckTabletMetadataTest.java  |  7 ++--
 3 files changed, 48 insertions(+), 45 deletions(-)

diff --git 
a/server/tserver/src/main/java/org/apache/accumulo/tserver/AssignmentHandler.java
 
b/server/tserver/src/main/java/org/apache/accumulo/tserver/AssignmentHandler.java
index 03d8dfc..fa69abe 100644
--- 
a/server/tserver/src/main/java/org/apache/accumulo/tserver/AssignmentHandler.java
+++ 
b/server/tserver/src/main/java/org/apache/accumulo/tserver/AssignmentHandler.java
@@ -25,9 +25,12 @@ import java.util.Set;
 import java.util.TreeSet;
 import java.util.concurrent.TimeUnit;
 
+import org.apache.accumulo.core.client.AccumuloException;
 import org.apache.accumulo.core.data.TableId;
 import org.apache.accumulo.core.dataImpl.KeyExtent;
 import org.apache.accumulo.core.manager.thrift.TabletLoadState;
+import org.apache.accumulo.core.metadata.RootTable;
+import org.apache.accumulo.core.metadata.TServerInstance;
 import org.apache.accumulo.core.metadata.schema.TabletMetadata;
 import org.apache.accumulo.core.util.threads.Threads;
 import org.apache.accumulo.server.manager.state.Assignment;
@@ -45,6 +48,7 @@ import org.slf4j.LoggerFactory;
 
 class AssignmentHandler implements Runnable {
   private static final Logger log = 
LoggerFactory.getLogger(AssignmentHandler.class);
+  private static final String METADATA_ISSUE = "Saw metadata issue when 
loading tablet : ";
   private final KeyExtent extent;
   private final int retryAttempt;
   private final TabletServer server;
@@ -102,7 +106,7 @@ class AssignmentHandler implements Runnable {
     try {
       tabletMetadata = server.getContext().getAmple().readTablet(extent);
 
-      canLoad = TabletServer.checkTabletMetadata(extent, 
server.getTabletSession(), tabletMetadata);
+      canLoad = checkTabletMetadata(extent, server.getTabletSession(), 
tabletMetadata);
 
       if (canLoad && tabletMetadata.sawOldPrevEndRow()) {
         KeyExtent fixedExtent =
@@ -233,4 +237,43 @@ class AssignmentHandler implements Runnable {
       }, reschedule, TimeUnit.MILLISECONDS);
     }
   }
+
+  public static boolean checkTabletMetadata(KeyExtent extent, TServerInstance 
instance,
+      TabletMetadata meta) throws AccumuloException {
+
+    if (meta == null) {
+      log.info(METADATA_ISSUE + "{}, its metadata was not found.", extent);
+      return false;
+    }
+
+    if (!meta.sawPrevEndRow()) {
+      throw new AccumuloException(METADATA_ISSUE + "metadata entry does not 
have prev row ("
+          + meta.getTableId() + " " + meta.getEndRow() + ")");
+    }
+
+    if (!extent.equals(meta.getExtent())) {
+      log.info(METADATA_ISSUE + "tablet extent mismatch {} {}", extent, 
meta.getExtent());
+      return false;
+    }
+
+    if (meta.getDirName() == null) {
+      throw new AccumuloException(
+          METADATA_ISSUE + "metadata entry does not have directory (" + 
meta.getExtent() + ")");
+    }
+
+    if (meta.getTime() == null && !extent.equals(RootTable.EXTENT)) {
+      throw new AccumuloException(
+          METADATA_ISSUE + "metadata entry does not have time (" + 
meta.getExtent() + ")");
+    }
+
+    TabletMetadata.Location loc = meta.getLocation();
+
+    if (loc == null || loc.getType() != TabletMetadata.LocationType.FUTURE
+        || !instance.equals(loc)) {
+      log.info(METADATA_ISSUE + "Unexpected location {} {}", extent, loc);
+      return false;
+    }
+
+    return true;
+  }
 }
diff --git 
a/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java 
b/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java
index e35b7e8..63c40b0 100644
--- a/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java
+++ b/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java
@@ -53,7 +53,6 @@ import java.util.concurrent.atomic.AtomicLong;
 import java.util.concurrent.locks.ReentrantLock;
 
 import org.apache.accumulo.core.Constants;
-import org.apache.accumulo.core.client.AccumuloException;
 import org.apache.accumulo.core.client.Durability;
 import org.apache.accumulo.core.clientImpl.DurabilityImpl;
 import org.apache.accumulo.core.clientImpl.TabletLocator;
@@ -69,9 +68,6 @@ import 
org.apache.accumulo.core.master.thrift.TabletServerStatus;
 import org.apache.accumulo.core.metadata.MetadataTable;
 import org.apache.accumulo.core.metadata.RootTable;
 import org.apache.accumulo.core.metadata.TServerInstance;
-import org.apache.accumulo.core.metadata.schema.TabletMetadata;
-import org.apache.accumulo.core.metadata.schema.TabletMetadata.Location;
-import org.apache.accumulo.core.metadata.schema.TabletMetadata.LocationType;
 import org.apache.accumulo.core.metrics.MetricsUtil;
 import org.apache.accumulo.core.replication.thrift.ReplicationServicer;
 import org.apache.accumulo.core.rpc.ThriftUtil;
@@ -925,43 +921,6 @@ public class TabletServer extends AbstractServer {
         30000, TimeUnit.MILLISECONDS);
   }
 
-  static boolean checkTabletMetadata(KeyExtent extent, TServerInstance 
instance,
-      TabletMetadata meta) throws AccumuloException {
-
-    if (meta == null) {
-      log.info("Not loading tablet {}, its metadata was not found.", extent);
-      return false;
-    }
-
-    if (!meta.sawPrevEndRow()) {
-      throw new AccumuloException("Metadata entry does not have prev row (" + 
meta.getTableId()
-          + " " + meta.getEndRow() + ")");
-    }
-
-    if (!extent.equals(meta.getExtent())) {
-      log.info("Tablet extent mismatch {} {}", extent, meta.getExtent());
-      return false;
-    }
-
-    if (meta.getDirName() == null) {
-      throw new AccumuloException(
-          "Metadata entry does not have directory (" + meta.getExtent() + ")");
-    }
-
-    if (meta.getTime() == null && !extent.equals(RootTable.EXTENT)) {
-      throw new AccumuloException("Metadata entry does not have time (" + 
meta.getExtent() + ")");
-    }
-
-    Location loc = meta.getLocation();
-
-    if (loc == null || loc.getType() != LocationType.FUTURE || 
!instance.equals(loc)) {
-      log.info("Unexpected location {} {}", extent, loc);
-      return false;
-    }
-
-    return true;
-  }
-
   public String getClientAddressString() {
     if (clientAddress == null) {
       return null;
diff --git 
a/server/tserver/src/test/java/org/apache/accumulo/tserver/CheckTabletMetadataTest.java
 
b/server/tserver/src/test/java/org/apache/accumulo/tserver/CheckTabletMetadataTest.java
index 96bcd78..4bc8f89 100644
--- 
a/server/tserver/src/test/java/org/apache/accumulo/tserver/CheckTabletMetadataTest.java
+++ 
b/server/tserver/src/test/java/org/apache/accumulo/tserver/CheckTabletMetadataTest.java
@@ -18,6 +18,7 @@
  */
 package org.apache.accumulo.tserver;
 
+import static 
org.apache.accumulo.tserver.AssignmentHandler.checkTabletMetadata;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
@@ -65,7 +66,7 @@ public class CheckTabletMetadataTest {
     try {
       TabletMetadata tm = 
TabletMetadata.convertRow(tabletMeta.entrySet().iterator(),
           EnumSet.allOf(ColumnType.class), true);
-      assertFalse(TabletServer.checkTabletMetadata(ke, tsi, tm));
+      assertFalse(checkTabletMetadata(ke, tsi, tm));
     } catch (Exception e) {
       e.printStackTrace();
     }
@@ -78,7 +79,7 @@ public class CheckTabletMetadataTest {
     try {
       TabletMetadata tm = TabletMetadata.convertRow(copy.entrySet().iterator(),
           EnumSet.allOf(ColumnType.class), true);
-      assertFalse(TabletServer.checkTabletMetadata(ke, tsi, tm));
+      assertFalse(checkTabletMetadata(ke, tsi, tm));
     } catch (Exception e) {
       e.printStackTrace();
     }
@@ -101,7 +102,7 @@ public class CheckTabletMetadataTest {
 
     TabletMetadata tm = 
TabletMetadata.convertRow(tabletMeta.entrySet().iterator(),
         EnumSet.allOf(ColumnType.class), true);
-    assertTrue(TabletServer.checkTabletMetadata(ke, tsi, tm));
+    assertTrue(checkTabletMetadata(ke, tsi, tm));
 
     assertFail(tabletMeta, ke, new TServerInstance("127.0.0.1:9998", 4));
     assertFail(tabletMeta, ke, new TServerInstance("127.0.0.1:9998", 5));

Reply via email to