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
commit 5474f5ae021025251e04405de3841ddd1663db15 Author: Brian Buxton <[email protected]> AuthorDate: Mon Jun 4 08:12:11 2018 -0400 fixes #512 let iterator know if its a user compaction (#513) Adjusted interface for IteratorEnvironment and filled in the trivial implementations Implemented TabletIteratorEnvironment's isUserCompaction --- .../accumulo/core/client/ClientSideIteratorScanner.java | 5 +++++ .../accumulo/core/client/impl/BaseIteratorEnvironment.java | 5 +++++ .../apache/accumulo/core/client/impl/OfflineIterator.java | 5 +++++ .../accumulo/core/iterators/IteratorEnvironment.java | 2 ++ .../environments/SimpleIteratorEnvironment.java | 5 +++++ .../apache/accumulo/tserver/TabletIteratorEnvironment.java | 14 +++++++++++++- .../java/org/apache/accumulo/tserver/tablet/Compactor.java | 4 ++-- 7 files changed, 37 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/org/apache/accumulo/core/client/ClientSideIteratorScanner.java b/core/src/main/java/org/apache/accumulo/core/client/ClientSideIteratorScanner.java index 905d7f7..e0f86d1 100644 --- a/core/src/main/java/org/apache/accumulo/core/client/ClientSideIteratorScanner.java +++ b/core/src/main/java/org/apache/accumulo/core/client/ClientSideIteratorScanner.java @@ -107,6 +107,11 @@ public class ClientSideIteratorScanner extends ScannerOptions implements Scanner } @Override + public boolean isUserCompaction() { + return false; + } + + @Override public void registerSideChannel(SortedKeyValueIterator<Key,Value> iter) { throw new UnsupportedOperationException(); } diff --git a/core/src/main/java/org/apache/accumulo/core/client/impl/BaseIteratorEnvironment.java b/core/src/main/java/org/apache/accumulo/core/client/impl/BaseIteratorEnvironment.java index ddcb066..f1f811d 100644 --- a/core/src/main/java/org/apache/accumulo/core/client/impl/BaseIteratorEnvironment.java +++ b/core/src/main/java/org/apache/accumulo/core/client/impl/BaseIteratorEnvironment.java @@ -57,6 +57,11 @@ public class BaseIteratorEnvironment implements IteratorEnvironment { } @Override + public boolean isUserCompaction() { + throw new UnsupportedOperationException(); + } + + @Override public void registerSideChannel(SortedKeyValueIterator<Key,Value> iter) { throw new UnsupportedOperationException(); } diff --git a/core/src/main/java/org/apache/accumulo/core/client/impl/OfflineIterator.java b/core/src/main/java/org/apache/accumulo/core/client/impl/OfflineIterator.java index 15de019..2418554 100644 --- a/core/src/main/java/org/apache/accumulo/core/client/impl/OfflineIterator.java +++ b/core/src/main/java/org/apache/accumulo/core/client/impl/OfflineIterator.java @@ -105,6 +105,11 @@ class OfflineIterator implements Iterator<Entry<Key,Value>> { return false; } + @Override + public boolean isUserCompaction() { + return false; + } + private ArrayList<SortedKeyValueIterator<Key,Value>> topLevelIterators = new ArrayList<>(); @Override diff --git a/core/src/main/java/org/apache/accumulo/core/iterators/IteratorEnvironment.java b/core/src/main/java/org/apache/accumulo/core/iterators/IteratorEnvironment.java index 39a73b6..596c54a 100644 --- a/core/src/main/java/org/apache/accumulo/core/iterators/IteratorEnvironment.java +++ b/core/src/main/java/org/apache/accumulo/core/iterators/IteratorEnvironment.java @@ -36,6 +36,8 @@ public interface IteratorEnvironment { boolean isFullMajorCompaction(); + boolean isUserCompaction(); + void registerSideChannel(SortedKeyValueIterator<Key,Value> iter); Authorizations getAuthorizations(); diff --git a/iterator-test-harness/src/main/java/org/apache/accumulo/iteratortest/environments/SimpleIteratorEnvironment.java b/iterator-test-harness/src/main/java/org/apache/accumulo/iteratortest/environments/SimpleIteratorEnvironment.java index 1f6ecf4..ba70501 100644 --- a/iterator-test-harness/src/main/java/org/apache/accumulo/iteratortest/environments/SimpleIteratorEnvironment.java +++ b/iterator-test-harness/src/main/java/org/apache/accumulo/iteratortest/environments/SimpleIteratorEnvironment.java @@ -54,6 +54,11 @@ public class SimpleIteratorEnvironment implements IteratorEnvironment { } @Override + public boolean isUserCompaction() { + throw new UnsupportedOperationException(); + } + + @Override public void registerSideChannel(SortedKeyValueIterator<Key,Value> iter) { throw new UnsupportedOperationException(); } diff --git a/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletIteratorEnvironment.java b/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletIteratorEnvironment.java index d3c13b7..c25fde8 100644 --- a/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletIteratorEnvironment.java +++ b/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletIteratorEnvironment.java @@ -35,6 +35,7 @@ import org.apache.accumulo.core.sample.impl.SamplerConfigurationImpl; import org.apache.accumulo.core.security.Authorizations; import org.apache.accumulo.server.fs.FileRef; import org.apache.accumulo.tserver.FileManager.ScanFileManager; +import org.apache.accumulo.tserver.compaction.MajorCompactionReason; import org.apache.hadoop.fs.Path; public class TabletIteratorEnvironment implements IteratorEnvironment { @@ -42,6 +43,7 @@ public class TabletIteratorEnvironment implements IteratorEnvironment { private final ScanFileManager trm; private final IteratorScope scope; private final boolean fullMajorCompaction; + private boolean userCompaction; private final AccumuloConfiguration config; private final ArrayList<SortedKeyValueIterator<Key,Value>> topLevelIterators; private Map<FileRef,DataFileValue> files; @@ -58,6 +60,7 @@ public class TabletIteratorEnvironment implements IteratorEnvironment { this.trm = null; this.config = config; this.fullMajorCompaction = false; + this.userCompaction = false; this.authorizations = Authorizations.EMPTY; this.topLevelIterators = new ArrayList<>(); } @@ -92,7 +95,7 @@ public class TabletIteratorEnvironment implements IteratorEnvironment { } public TabletIteratorEnvironment(IteratorScope scope, boolean fullMajC, - AccumuloConfiguration config) { + AccumuloConfiguration config, MajorCompactionReason reason) { if (scope != IteratorScope.majc) throw new IllegalArgumentException( "Tried to set maj compaction type when scope was " + scope); @@ -101,6 +104,7 @@ public class TabletIteratorEnvironment implements IteratorEnvironment { this.trm = null; this.config = config; this.fullMajorCompaction = fullMajC; + this.userCompaction = reason.equals(MajorCompactionReason.USER); this.authorizations = Authorizations.EMPTY; this.topLevelIterators = new ArrayList<>(); } @@ -123,6 +127,14 @@ public class TabletIteratorEnvironment implements IteratorEnvironment { } @Override + public boolean isUserCompaction() { + if (scope != IteratorScope.majc) + throw new IllegalStateException( + "Asked about user initiated compaction type when scope is " + scope); + return userCompaction; + } + + @Override public SortedKeyValueIterator<Key,Value> reserveMapFileReader(String mapFileName) throws IOException { FileRef ref = new FileRef(mapFileName, new Path(mapFileName)); diff --git a/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/Compactor.java b/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/Compactor.java index f31bb65..a525a4a 100644 --- a/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/Compactor.java +++ b/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/Compactor.java @@ -351,8 +351,8 @@ public class Compactor implements Callable<CompactionStats> { TabletIteratorEnvironment iterEnv; if (env.getIteratorScope() == IteratorScope.majc) - iterEnv = new TabletIteratorEnvironment(IteratorScope.majc, !propogateDeletes, - acuTableConf); + iterEnv = new TabletIteratorEnvironment(IteratorScope.majc, !propogateDeletes, acuTableConf, + getMajorCompactionReason()); else if (env.getIteratorScope() == IteratorScope.minc) iterEnv = new TabletIteratorEnvironment(IteratorScope.minc, acuTableConf); else
