accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ktur...@apache.org
Subject [accumulo] branch master updated: Fix #1244 Update MetadataTableUtil to use the ample api (#1254)
Date Mon, 08 Jul 2019 17:06:51 GMT
This is an automated email from the ASF dual-hosted git repository.

kturner pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/accumulo.git


The following commit(s) were added to refs/heads/master by this push:
     new 0ca9cfe  Fix #1244 Update MetadataTableUtil to use the ample api (#1254)
0ca9cfe is described below

commit 0ca9cfe270b0e2a2b14f36ce2945eec96e7be704
Author: hkeebler <49656678+hkeebler@users.noreply.github.com>
AuthorDate: Mon Jul 8 13:06:47 2019 -0400

    Fix #1244 Update MetadataTableUtil to use the ample api (#1254)
---
 .../accumulo/core/metadata/schema/Ample.java       |  6 +-
 .../server/metadata/TabletMutatorBase.java         | 18 ++++-
 .../accumulo/server/util/MetadataTableUtil.java    | 83 +++++++++++-----------
 3 files changed, 62 insertions(+), 45 deletions(-)

diff --git a/core/src/main/java/org/apache/accumulo/core/metadata/schema/Ample.java b/core/src/main/java/org/apache/accumulo/core/metadata/schema/Ample.java
index ad1d6cf..1205a9d 100644
--- a/core/src/main/java/org/apache/accumulo/core/metadata/schema/Ample.java
+++ b/core/src/main/java/org/apache/accumulo/core/metadata/schema/Ample.java
@@ -132,9 +132,11 @@ public interface Ample {
 
     public TabletMutator putFile(FileMeta path, DataFileValue dfv);
 
+    public TabletMutator deleteFile(FileMeta path);
+
     public TabletMutator putScan(FileMeta path);
 
-    public TabletMutator deleteFile(FileMeta path);
+    public TabletMutator deleteScan(FileMeta path);
 
     public TabletMutator putCompactionId(long compactionId);
 
@@ -160,6 +162,8 @@ public interface Ample {
 
     public TabletMutator deleteBulkFile(Ample.FileMeta bulkref);
 
+    public TabletMutator putChopped();
+
     /**
      * This method persist (or queues for persisting) previous put and deletes against this
object.
      * Unless this method is called, previous calls will never be persisted. The purpose
of this
diff --git a/server/base/src/main/java/org/apache/accumulo/server/metadata/TabletMutatorBase.java
b/server/base/src/main/java/org/apache/accumulo/server/metadata/TabletMutatorBase.java
index 9b4e755..3aaa3cf 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/metadata/TabletMutatorBase.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/metadata/TabletMutatorBase.java
@@ -71,6 +71,13 @@ public abstract class TabletMutatorBase implements Ample.TabletMutator
{
   }
 
   @Override
+  public Ample.TabletMutator deleteFile(Ample.FileMeta path) {
+    Preconditions.checkState(updatesEnabled, "Cannot make updates after calling mutate.");
+    mutation.putDelete(DataFileColumnFamily.NAME, path.meta());
+    return this;
+  }
+
+  @Override
   public Ample.TabletMutator putScan(Ample.FileMeta path) {
     Preconditions.checkState(updatesEnabled, "Cannot make updates after calling mutate.");
     mutation.put(ScanFileColumnFamily.NAME, path.meta(), new Value(new byte[0]));
@@ -78,9 +85,9 @@ public abstract class TabletMutatorBase implements Ample.TabletMutator {
   }
 
   @Override
-  public Ample.TabletMutator deleteFile(Ample.FileMeta path) {
+  public Ample.TabletMutator deleteScan(Ample.FileMeta path) {
     Preconditions.checkState(updatesEnabled, "Cannot make updates after calling mutate.");
-    mutation.putDelete(DataFileColumnFamily.NAME, path.meta());
+    mutation.putDelete(ScanFileColumnFamily.NAME, path.meta());
     return this;
   }
 
@@ -177,6 +184,13 @@ public abstract class TabletMutatorBase implements Ample.TabletMutator
{
     return this;
   }
 
+  @Override
+  public Ample.TabletMutator putChopped() {
+    Preconditions.checkState(updatesEnabled, "Cannot make updates after calling mutate.");
+    TabletsSection.ChoppedColumnFamily.CHOPPED_COLUMN.put(mutation, new Value("chopped"));
+    return this;
+  }
+
   protected Mutation getMutation() {
     updatesEnabled = false;
     return mutation;
diff --git a/server/base/src/main/java/org/apache/accumulo/server/util/MetadataTableUtil.java
b/server/base/src/main/java/org/apache/accumulo/server/util/MetadataTableUtil.java
index 2c9a689..da72619 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/util/MetadataTableUtil.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/util/MetadataTableUtil.java
@@ -65,14 +65,13 @@ import org.apache.accumulo.core.data.Value;
 import org.apache.accumulo.core.dataImpl.KeyExtent;
 import org.apache.accumulo.core.metadata.MetadataTable;
 import org.apache.accumulo.core.metadata.RootTable;
-import org.apache.accumulo.core.metadata.schema.Ample;
+import org.apache.accumulo.core.metadata.schema.Ample.TabletMutator;
 import org.apache.accumulo.core.metadata.schema.DataFileValue;
 import org.apache.accumulo.core.metadata.schema.MetadataSchema;
 import org.apache.accumulo.core.metadata.schema.MetadataSchema.TabletsSection;
 import org.apache.accumulo.core.metadata.schema.MetadataSchema.TabletsSection.ChoppedColumnFamily;
 import org.apache.accumulo.core.metadata.schema.MetadataSchema.TabletsSection.ClonedColumnFamily;
 import org.apache.accumulo.core.metadata.schema.MetadataSchema.TabletsSection.DataFileColumnFamily;
-import org.apache.accumulo.core.metadata.schema.MetadataSchema.TabletsSection.ScanFileColumnFamily;
 import org.apache.accumulo.core.metadata.schema.TabletDeletedException;
 import org.apache.accumulo.core.metadata.schema.TabletMetadata;
 import org.apache.accumulo.core.metadata.schema.TabletsMetadata;
@@ -167,53 +166,53 @@ public class MetadataTableUtil {
   public static void updateTabletFlushID(KeyExtent extent, long flushID, ServerContext context,
       ZooLock zooLock) {
     if (!extent.isRootTablet()) {
-      Mutation m = new Mutation(extent.getMetadataEntry());
-      TabletsSection.ServerColumnFamily.FLUSH_COLUMN.put(m,
-          new Value((flushID + "").getBytes(UTF_8)));
-      update(context, zooLock, m, extent);
+      TabletMutator tablet = context.getAmple().mutateTablet(extent);
+      tablet.putFlushId(flushID);
+      tablet.putZooLock(zooLock);
+      tablet.mutate();
     }
   }
 
   public static void updateTabletCompactID(KeyExtent extent, long compactID, ServerContext
context,
       ZooLock zooLock) {
     if (!extent.isRootTablet()) {
-      Mutation m = new Mutation(extent.getMetadataEntry());
-      TabletsSection.ServerColumnFamily.COMPACT_COLUMN.put(m,
-          new Value((compactID + "").getBytes(UTF_8)));
-      update(context, zooLock, m, extent);
+      TabletMutator tablet = context.getAmple().mutateTablet(extent);
+      tablet.putCompactionId(compactID);
+      tablet.putZooLock(zooLock);
+      tablet.mutate();
     }
   }
 
   public static void updateTabletDataFile(long tid, KeyExtent extent,
       Map<FileRef,DataFileValue> estSizes, String time, ServerContext context, ZooLock
zooLock) {
-    Mutation m = new Mutation(extent.getMetadataEntry());
-    byte[] tidBytes = Long.toString(tid).getBytes(UTF_8);
+    TabletMutator tablet = context.getAmple().mutateTablet(extent);
+    tablet.putTime(time);
+    estSizes.forEach(tablet::putFile);
 
-    for (Entry<FileRef,DataFileValue> entry : estSizes.entrySet()) {
-      Text file = entry.getKey().meta();
-      m.put(DataFileColumnFamily.NAME, file, new Value(entry.getValue().encode()));
-      m.put(TabletsSection.BulkFileColumnFamily.NAME, file, new Value(tidBytes));
+    for (FileRef file : estSizes.keySet()) {
+      tablet.putBulkFile(file, tid);
     }
-    TabletsSection.ServerColumnFamily.TIME_COLUMN.put(m, new Value(time.getBytes(UTF_8)));
-    update(context, zooLock, m, extent);
+    tablet.putZooLock(zooLock);
+    tablet.mutate();
   }
 
   public static void updateTabletDir(KeyExtent extent, String newDir, ServerContext context,
-      ZooLock lock) {
-    Mutation m = new Mutation(extent.getMetadataEntry());
-    TabletsSection.ServerColumnFamily.DIRECTORY_COLUMN.put(m, new Value(newDir.getBytes(UTF_8)));
-    update(context, lock, m, extent);
+      ZooLock zooLock) {
+    TabletMutator tablet = context.getAmple().mutateTablet(extent);
+    tablet.putDir(newDir);
+    tablet.putZooLock(zooLock);
+    tablet.mutate();
   }
 
   public static void addTablet(KeyExtent extent, String path, ServerContext context, char
timeType,
-      ZooLock lock) {
-    Mutation m = extent.getPrevRowUpdateMutation();
-
-    TabletsSection.ServerColumnFamily.DIRECTORY_COLUMN.put(m, new Value(path.getBytes(UTF_8)));
-    TabletsSection.ServerColumnFamily.TIME_COLUMN.put(m,
-        new Value((timeType + "0").getBytes(UTF_8)));
+      ZooLock zooLock) {
+    TabletMutator tablet = context.getAmple().mutateTablet(extent);
+    tablet.putPrevEndRow(extent.getPrevEndRow());
+    tablet.putDir(path);
+    tablet.putTime(timeType + "0");
+    tablet.putZooLock(zooLock);
+    tablet.mutate();
 
-    update(context, lock, m, extent);
   }
 
   public static void updateTabletVolumes(KeyExtent extent, List<LogEntry> logsToRemove,
@@ -229,7 +228,7 @@ public class MetadataTableUtil {
         throw new IllegalArgumentException("files not expected for " + extent);
     }
 
-    Ample.TabletMutator tabletMutator = context.getAmple().mutateTablet(extent);
+    TabletMutator tabletMutator = context.getAmple().mutateTablet(extent);
     logsToRemove.forEach(tabletMutator::deleteWal);
     logsToAdd.forEach(tabletMutator::putWal);
 
@@ -334,12 +333,10 @@ public class MetadataTableUtil {
 
   public static void removeScanFiles(KeyExtent extent, Set<FileRef> scanFiles,
       ServerContext context, ZooLock zooLock) {
-    Mutation m = new Mutation(extent.getMetadataEntry());
-
-    for (FileRef pathToRemove : scanFiles)
-      m.putDelete(ScanFileColumnFamily.NAME, pathToRemove.meta());
-
-    update(context, zooLock, m, extent);
+    TabletMutator tablet = context.getAmple().mutateTablet(extent);
+    scanFiles.forEach(tablet::deleteScan);
+    tablet.putZooLock(zooLock);
+    tablet.mutate();
   }
 
   public static void splitDatafiles(Text midRow, double splitRatio,
@@ -489,9 +486,10 @@ public class MetadataTableUtil {
 
   public static void removeUnusedWALEntries(ServerContext context, KeyExtent extent,
       final List<LogEntry> entries, ZooLock zooLock) {
-    Ample.TabletMutator tabletMutator = context.getAmple().mutateTablet(extent);
-    entries.forEach(tabletMutator::deleteWal);
-    tabletMutator.putZooLock(zooLock);
+    TabletMutator tablet = context.getAmple().mutateTablet(extent);
+    entries.forEach(tablet::deleteWal);
+    tablet.putZooLock(zooLock);
+    tablet.mutate();
   }
 
   private static void getFiles(Set<String> files, Collection<String> tabletFiles,
@@ -717,9 +715,10 @@ public class MetadataTableUtil {
   }
 
   public static void chopped(ServerContext context, KeyExtent extent, ZooLock zooLock) {
-    Mutation m = new Mutation(extent.getMetadataEntry());
-    ChoppedColumnFamily.CHOPPED_COLUMN.put(m, new Value("chopped".getBytes(UTF_8)));
-    update(context, zooLock, m, extent);
+    TabletMutator tablet = context.getAmple().mutateTablet(extent);
+    tablet.putChopped();
+    tablet.putZooLock(zooLock);
+    tablet.mutate();
   }
 
   public static void removeBulkLoadEntries(AccumuloClient client, TableId tableId, long tid)


Mime
View raw message