You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@accumulo.apache.org by GitBox <gi...@apache.org> on 2018/05/17 18:17:44 UTC

[GitHub] milleruntime commented on a change in pull request #488: fixes #469 made bulk import scan split tolerant

milleruntime commented on a change in pull request #488: fixes #469 made bulk import scan split tolerant
URL: https://github.com/apache/accumulo/pull/488#discussion_r189049542
 
 

 ##########
 File path: core/src/main/java/org/apache/accumulo/core/metadata/schema/MetadataConsistencyCheckIterator.java
 ##########
 @@ -0,0 +1,153 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.accumulo.core.metadata.schema;
+
+import static org.apache.accumulo.fate.util.UtilWaitThread.sleepUninterruptibly;
+
+import java.util.Iterator;
+import java.util.concurrent.TimeUnit;
+import java.util.function.Function;
+
+import org.apache.accumulo.core.data.Key;
+import org.apache.accumulo.core.data.PartialKey;
+import org.apache.accumulo.core.data.Range;
+import org.apache.accumulo.core.data.impl.KeyExtent;
+import org.apache.hadoop.io.Text;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.collect.Iterators;
+
+/**
+ * Tablets for a table in the metadata table should form a linked list. This iterator detects when
+ * tablets do not form a linked list and backs up when this happens.
+ *
+ * <p>
+ * The purpose of this is to hide inconsistencies caused by splits and detect anomalies in the
+ * metadata table.
+ *
+ * <p>
+ * If a tablet that was returned by this iterator is subsequently deleted from the metadata table,
+ * then this iterator will throw a TabletDeletedException. This could occur when a table is merged.
+ */
+public class MetadataConsistencyCheckIterator implements Iterator<TabletMetadata> {
+
+  private static final Logger log = LoggerFactory.getLogger(MetadataConsistencyCheckIterator.class);
+
+  private Range range;
+  private Function<Range,Iterator<TabletMetadata>> iteratorFactory;
+  private Iterator<TabletMetadata> source;
+  private TabletMetadata prevTablet = null;
+
+  MetadataConsistencyCheckIterator(Function<Range,Iterator<TabletMetadata>> iteratorFactory,
+      Range range) {
+    this.range = range;
+    this.iteratorFactory = iteratorFactory;
+    source = iteratorFactory.apply(range);
+  }
+
+  @Override
+  public boolean hasNext() {
+    return source.hasNext();
+  }
+
+  static boolean goodTransition(TabletMetadata prev, TabletMetadata curr) {
+    if (!curr.sawPrevEndRow()) {
+      log.warn("Tablet {} had no prev end row.", curr.getExtent());
+      return false;
+    }
+
+    if (!curr.getTableId().equals(prev.getTableId())) {
+      if (prev.getEndRow() != null) {
+        log.debug("Non-null end row for last tablet in table: " + prev.getExtent() + " "
+            + curr.getExtent());
+        return false;
+      }
+
+      if (curr.getPrevEndRow() != null) {
+        log.debug("First tablet for table had prev end row {} {} ", prev.getExtent(),
+            curr.getExtent());
 
 Review comment:
   How do you know you are testing the first tablet here?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services