You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by kt...@apache.org on 2019/06/19 19:54:35 UTC
[accumulo] branch master updated: Fix #1181 Update addNewTablet to
use new Ample (#1206)
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 5359d94 Fix #1181 Update addNewTablet to use new Ample (#1206)
5359d94 is described below
commit 5359d944a8b79920e9a6689f0ca7586c41ad36cd
Author: hkeebler <49...@users.noreply.github.com>
AuthorDate: Wed Jun 19 15:54:31 2019 -0400
Fix #1181 Update addNewTablet to use new Ample (#1206)
---
.../accumulo/core/metadata/schema/Ample.java | 8 +++++
.../server/metadata/TabletMutatorBase.java | 38 ++++++++++++++++++----
.../accumulo/server/util/MasterMetadataUtil.java | 29 ++++++++---------
3 files changed, 54 insertions(+), 21 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 ce470e4..ad1d6cf 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
@@ -138,6 +138,8 @@ public interface Ample {
public TabletMutator putCompactionId(long compactionId);
+ public TabletMutator putFlushId(long flushId);
+
public TabletMutator putLocation(TServer tserver, LocationType type);
public TabletMutator deleteLocation(TServer tserver, LocationType type);
@@ -152,6 +154,12 @@ public interface Ample {
public TabletMutator deleteWal(LogEntry logEntry);
+ public TabletMutator putTime(String time);
+
+ public TabletMutator putBulkFile(Ample.FileMeta bulkref, long tid);
+
+ public TabletMutator deleteBulkFile(Ample.FileMeta bulkref);
+
/**
* 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 c82efcd..9b4e755 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
@@ -17,8 +17,6 @@
package org.apache.accumulo.server.metadata;
-import static java.nio.charset.StandardCharsets.UTF_8;
-
import org.apache.accumulo.core.data.Mutation;
import org.apache.accumulo.core.data.Value;
import org.apache.accumulo.core.dataImpl.KeyExtent;
@@ -61,8 +59,7 @@ public abstract class TabletMutatorBase implements Ample.TabletMutator {
@Override
public Ample.TabletMutator putDir(String dir) {
Preconditions.checkState(updatesEnabled, "Cannot make updates after calling mutate.");
- TabletsSection.ServerColumnFamily.DIRECTORY_COLUMN.put(mutation,
- new Value(dir.getBytes(UTF_8)));
+ TabletsSection.ServerColumnFamily.DIRECTORY_COLUMN.put(mutation, new Value(dir));
return this;
}
@@ -91,7 +88,21 @@ public abstract class TabletMutatorBase implements Ample.TabletMutator {
public Ample.TabletMutator putCompactionId(long compactionId) {
Preconditions.checkState(updatesEnabled, "Cannot make updates after calling mutate.");
TabletsSection.ServerColumnFamily.COMPACT_COLUMN.put(mutation,
- new Value(("" + compactionId).getBytes()));
+ new Value(Long.toString(compactionId)));
+ return this;
+ }
+
+ @Override
+ public Ample.TabletMutator putFlushId(long flushId) {
+ Preconditions.checkState(updatesEnabled, "Cannot make updates after calling mutate.");
+ TabletsSection.ServerColumnFamily.FLUSH_COLUMN.put(mutation, new Value(Long.toString(flushId)));
+ return this;
+ }
+
+ @Override
+ public Ample.TabletMutator putTime(String time) {
+ Preconditions.checkState(updatesEnabled, "Cannot make updates after calling mutate.");
+ TabletsSection.ServerColumnFamily.TIME_COLUMN.put(mutation, new Value(time));
return this;
}
@@ -126,7 +137,7 @@ public abstract class TabletMutatorBase implements Ample.TabletMutator {
public Ample.TabletMutator putZooLock(ZooLock zooLock) {
Preconditions.checkState(updatesEnabled, "Cannot make updates after calling mutate.");
TabletsSection.ServerColumnFamily.LOCK_COLUMN.put(mutation,
- new Value(zooLock.getLockID().serialize(context.getZooKeeperRoot() + "/").getBytes(UTF_8)));
+ new Value(zooLock.getLockID().serialize(context.getZooKeeperRoot() + "/")));
return this;
}
@@ -151,6 +162,21 @@ public abstract class TabletMutatorBase implements Ample.TabletMutator {
return this;
}
+ @Override
+ public Ample.TabletMutator putBulkFile(Ample.FileMeta bulkref, long tid) {
+ Preconditions.checkState(updatesEnabled, "Cannot make updates after calling mutate.");
+ mutation.put(TabletsSection.BulkFileColumnFamily.NAME, bulkref.meta(),
+ new Value(Long.toString(tid)));
+ return this;
+ }
+
+ @Override
+ public Ample.TabletMutator deleteBulkFile(Ample.FileMeta bulkref) {
+ Preconditions.checkState(updatesEnabled, "Cannot make updates after calling mutate.");
+ mutation.putDelete(TabletsSection.BulkFileColumnFamily.NAME, bulkref.meta());
+ return this;
+ }
+
protected Mutation getMutation() {
updatesEnabled = false;
return mutation;
diff --git a/server/base/src/main/java/org/apache/accumulo/server/util/MasterMetadataUtil.java b/server/base/src/main/java/org/apache/accumulo/server/util/MasterMetadataUtil.java
index be31e56..fde811b 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/util/MasterMetadataUtil.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/util/MasterMetadataUtil.java
@@ -69,34 +69,33 @@ public class MasterMetadataUtil {
TServerInstance location, Map<FileRef,DataFileValue> datafileSizes,
Map<Long,? extends Collection<FileRef>> bulkLoadedFiles, String time, long lastFlushID,
long lastCompactID, ZooLock zooLock) {
- Mutation m = extent.getPrevRowUpdateMutation();
- TabletsSection.ServerColumnFamily.DIRECTORY_COLUMN.put(m, new Value(path.getBytes(UTF_8)));
- TabletsSection.ServerColumnFamily.TIME_COLUMN.put(m, new Value(time.getBytes(UTF_8)));
+ TabletMutator mutator = context.getAmple().mutateTablet(extent);
+ mutator.putPrevEndRow(extent.getPrevEndRow());
+ mutator.putZooLock(zooLock);
+ mutator.putDir(path);
+ mutator.putTime(time);
+
if (lastFlushID > 0)
- TabletsSection.ServerColumnFamily.FLUSH_COLUMN.put(m,
- new Value(("" + lastFlushID).getBytes()));
+ mutator.putFlushId(lastFlushID);
+
if (lastCompactID > 0)
- TabletsSection.ServerColumnFamily.COMPACT_COLUMN.put(m,
- new Value(("" + lastCompactID).getBytes()));
+ mutator.putCompactionId(lastCompactID);
if (location != null) {
- location.putLocation(m);
- location.clearFutureLocation(m);
+ mutator.putLocation(location, LocationType.CURRENT);
+ mutator.deleteLocation(location, LocationType.FUTURE);
}
- for (Entry<FileRef,DataFileValue> entry : datafileSizes.entrySet()) {
- m.put(DataFileColumnFamily.NAME, entry.getKey().meta(), new Value(entry.getValue().encode()));
- }
+ datafileSizes.forEach(mutator::putFile);
for (Entry<Long,? extends Collection<FileRef>> entry : bulkLoadedFiles.entrySet()) {
- Value tidBytes = new Value(Long.toString(entry.getKey()).getBytes());
for (FileRef ref : entry.getValue()) {
- m.put(TabletsSection.BulkFileColumnFamily.NAME, ref.meta(), new Value(tidBytes));
+ mutator.putBulkFile(ref, entry.getKey().longValue());
}
}
- MetadataTableUtil.update(context, zooLock, m, extent);
+ mutator.mutate();
}
public static KeyExtent fixSplit(ServerContext context, Text metadataEntry,