accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ctubb...@apache.org
Subject [1/2] git commit: ACCUMULO-2291 CheckForMetadataProblems now checks the root table as well as the metadata table for problems. Also removed the fix option for the metadata table.
Date Wed, 26 Feb 2014 21:16:31 GMT
Repository: accumulo
Updated Branches:
  refs/heads/1.6.0-SNAPSHOT 59716f06b -> 818426c3a


ACCUMULO-2291 CheckForMetadataProblems now checks the root table as well as the metadata table
for problems. Also removed the fix option for the metadata table.

Signed-off-by: Christopher Tubbs <ctubbsii@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/0c4a9566
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/0c4a9566
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/0c4a9566

Branch: refs/heads/1.6.0-SNAPSHOT
Commit: 0c4a956633f96a3426df94dcfefee4e86e5aa3f6
Parents: 59716f0
Author: jpmcnamee <jpm34@terpmail.umd.edu>
Authored: Fri Feb 21 09:49:04 2014 -0500
Committer: Christopher Tubbs <ctubbsii@apache.org>
Committed: Wed Feb 26 16:01:00 2014 -0500

----------------------------------------------------------------------
 .../server/util/CheckForMetadataProblems.java   | 100 ++++++++-----------
 1 file changed, 43 insertions(+), 57 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/0c4a9566/server/base/src/main/java/org/apache/accumulo/server/util/CheckForMetadataProblems.java
----------------------------------------------------------------------
diff --git a/server/base/src/main/java/org/apache/accumulo/server/util/CheckForMetadataProblems.java
b/server/base/src/main/java/org/apache/accumulo/server/util/CheckForMetadataProblems.java
index df9900f..d437bca 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/util/CheckForMetadataProblems.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/util/CheckForMetadataProblems.java
@@ -25,17 +25,14 @@ import java.util.TreeSet;
 
 import org.apache.accumulo.core.client.AccumuloSecurityException;
 import org.apache.accumulo.core.client.Scanner;
-import org.apache.accumulo.core.client.impl.Writer;
 import org.apache.accumulo.core.data.Key;
 import org.apache.accumulo.core.data.KeyExtent;
-import org.apache.accumulo.core.data.Mutation;
 import org.apache.accumulo.core.data.Value;
 import org.apache.accumulo.core.metadata.MetadataTable;
+import org.apache.accumulo.core.metadata.RootTable;
 import org.apache.accumulo.core.metadata.schema.MetadataSchema;
 import org.apache.accumulo.core.metadata.schema.MetadataSchema.TabletsSection;
 import org.apache.accumulo.core.security.Authorizations;
-import org.apache.accumulo.core.security.Credentials;
-import org.apache.accumulo.core.tabletserver.thrift.ConstraintViolationException;
 import org.apache.accumulo.server.cli.ClientOpts;
 import org.apache.accumulo.server.conf.ServerConfiguration;
 import org.apache.accumulo.server.fs.VolumeManager;
@@ -46,29 +43,29 @@ import com.beust.jcommander.Parameter;
 
 public class CheckForMetadataProblems {
   private static boolean sawProblems = false;
-  
+
   public static void checkTable(String tablename, TreeSet<KeyExtent> tablets, Opts
opts) throws AccumuloSecurityException {
     // sanity check of metadata table entries
     // make sure tablets has no holes, and that it starts and ends w/ null
-    
+
     if (tablets.size() == 0) {
       System.out.println("No entries found in metadata table for table " + tablename);
       sawProblems = true;
       return;
     }
-    
+
     if (tablets.first().getPrevEndRow() != null) {
       System.out.println("First entry for table " + tablename + "- " + tablets.first() +
" - has non null prev end row");
       sawProblems = true;
       return;
     }
-    
+
     if (tablets.last().getEndRow() != null) {
       System.out.println("Last entry for table " + tablename + "- " + tablets.last() + "
- has non null end row");
       sawProblems = true;
       return;
     }
-    
+
     Iterator<KeyExtent> tabIter = tablets.iterator();
     Text lastEndRow = tabIter.next().getEndRow();
     boolean everythingLooksGood = true;
@@ -85,13 +82,7 @@ public class CheckForMetadataProblems {
       if (broke) {
         everythingLooksGood = false;
       }
-      if (broke && opts.fix) {
-        KeyExtent ke = new KeyExtent(tabke);
-        ke.setPrevEndRow(lastEndRow);
-        MetadataTableUtil.updateTabletPrevEndRow(ke, new Credentials(opts.principal, opts.getToken()));
-        System.out.println("KE " + tabke + " has been repaired to " + ke);
-      }
-      
+
       lastEndRow = tabke.getEndRow();
     }
     if (everythingLooksGood)
@@ -99,50 +90,51 @@ public class CheckForMetadataProblems {
     else
       sawProblems = true;
   }
-  
-  public static void checkMetadataTableEntries(Opts opts, VolumeManager fs) throws Exception
{
+
+  public static void checkMetadataAndRootTableEntries(String tableNameToCheck, Opts opts,
VolumeManager fs) throws Exception {
+    System.out.println("Checking table: " + tableNameToCheck);
     Map<String,TreeSet<KeyExtent>> tables = new HashMap<String,TreeSet<KeyExtent>>();
-    
+
     Scanner scanner;
-    
+
     if (opts.offline) {
       scanner = new OfflineMetadataScanner(ServerConfiguration.getSystemConfiguration(opts.getInstance()),
fs);
     } else {
-      scanner = opts.getConnector().createScanner(MetadataTable.NAME, Authorizations.EMPTY);
+      scanner = opts.getConnector().createScanner(tableNameToCheck, Authorizations.EMPTY);
     }
-    
+
     scanner.setRange(MetadataSchema.TabletsSection.getRange());
     TabletsSection.TabletColumnFamily.PREV_ROW_COLUMN.fetch(scanner);
     scanner.fetchColumnFamily(TabletsSection.CurrentLocationColumnFamily.NAME);
-    
+
     Text colf = new Text();
     Text colq = new Text();
     boolean justLoc = false;
-    
+
     int count = 0;
-    
+
     for (Entry<Key,Value> entry : scanner) {
       colf = entry.getKey().getColumnFamily(colf);
       colq = entry.getKey().getColumnQualifier(colq);
-      
+
       count++;
-      
+
       String tableName = (new KeyExtent(entry.getKey().getRow(), (Text) null)).getTableId().toString();
-      
+
       TreeSet<KeyExtent> tablets = tables.get(tableName);
       if (tablets == null) {
         Set<Entry<String,TreeSet<KeyExtent>>> es = tables.entrySet();
-        
+
         for (Entry<String,TreeSet<KeyExtent>> entry2 : es) {
           checkTable(entry2.getKey(), entry2.getValue(), opts);
         }
-        
+
         tables.clear();
-        
+
         tablets = new TreeSet<KeyExtent>();
         tables.put(tableName, tablets);
       }
-      
+
       if (TabletsSection.TabletColumnFamily.PREV_ROW_COLUMN.equals(colf, colq)) {
         KeyExtent tabletKe = new KeyExtent(entry.getKey().getRow(), entry.getValue());
         tablets.add(tabletKe);
@@ -151,54 +143,48 @@ public class CheckForMetadataProblems {
         if (justLoc) {
           System.out.println("Problem at key " + entry.getKey());
           sawProblems = true;
-          if (opts.fix) {
-            Writer t = MetadataTableUtil.getMetadataTable(new Credentials(opts.principal,
opts.getToken()));
-            Key k = entry.getKey();
-            Mutation m = new Mutation(k.getRow());
-            m.putDelete(k.getColumnFamily(), k.getColumnQualifier());
-            try {
-              t.update(m);
-              System.out.println("Deleted " + k);
-            } catch (ConstraintViolationException e) {
-              e.printStackTrace();
-            }
-          }
         }
         justLoc = true;
       }
     }
-    
+
     if (count == 0) {
-      System.err.println("ERROR : " + MetadataTable.NAME + " table is empty");
+      System.err.println("ERROR : " + tableNameToCheck + " table is empty");
       sawProblems = true;
     }
-    
+
     Set<Entry<String,TreeSet<KeyExtent>>> es = tables.entrySet();
-    
+
     for (Entry<String,TreeSet<KeyExtent>> entry : es) {
       checkTable(entry.getKey(), entry.getValue(), opts);
     }
-    
+
+    if (!sawProblems) {
+      System.out.println("No problems found");
+    }
     // end METADATA table sanity check
   }
-  
+
   static class Opts extends ClientOpts {
-    @Parameter(names = "--fix", description = "best-effort attempt to fix problems found")
-    boolean fix = false;
-    
     @Parameter(names = "--offline", description = "perform the check on the files directly")
     boolean offline = false;
   }
-  
+
   public static void main(String[] args) throws Exception {
     Opts opts = new Opts();
     opts.parseArgs(CheckForMetadataProblems.class.getName(), args);
-    
+    Opts dummyOpts = new Opts();
+    dummyOpts.auths = opts.auths;
+    dummyOpts.password = opts.password;
+
     VolumeManager fs = VolumeManagerImpl.get();
-    checkMetadataTableEntries(opts, fs);
+
+    checkMetadataAndRootTableEntries(RootTable.NAME, dummyOpts, fs);
+    checkMetadataAndRootTableEntries(MetadataTable.NAME, opts, fs);
+    dummyOpts.stopTracing();
     opts.stopTracing();
     if (sawProblems)
       throw new RuntimeException();
   }
-  
+
 }


Mime
View raw message