From f64db932fd2ebf5329294083aa4d5745f59a5f44 Mon Sep 17 00:00:00 2001 From: Jonathan Gray Date: Thu, 6 Jan 2011 22:53:05 +0000 Subject: [PATCH] HBASE-3418 Increment operations can break when qualifiers are split between memstore/snapshot and storefiles git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1056108 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES.txt | 2 + .../hadoop/hbase/regionserver/HRegion.java | 2 + .../regionserver/TestResettingCounters.java | 100 ++++++++++++++++++ 3 files changed, 104 insertions(+) create mode 100644 src/test/java/org/apache/hadoop/hbase/regionserver/TestResettingCounters.java diff --git a/CHANGES.txt b/CHANGES.txt index 12d4e26b28c..dd37cef8898 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -22,6 +22,8 @@ Release 0.91.0 - Unreleased HBASE-3337 Restore HBCK fix of unassignment and dupe assignment for new master HBASE-3332 Regions stuck in transition after RS failure + HBASE-3418 Increment operations can break when qualifiers are split + between memstore/snapshot and storefiles IMPROVEMENTS diff --git a/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java b/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java index 29a0faf8e18..ea3046bbd46 100644 --- a/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java +++ b/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java @@ -31,6 +31,7 @@ import java.util.AbstractList; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; +import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -3086,6 +3087,7 @@ public class HRegion implements HeapSize { // , Writable{ // combine and return results.addAll(fileResults); + Collections.sort(results, KeyValue.COMPARATOR); return results; } diff --git a/src/test/java/org/apache/hadoop/hbase/regionserver/TestResettingCounters.java b/src/test/java/org/apache/hadoop/hbase/regionserver/TestResettingCounters.java new file mode 100644 index 00000000000..f092371396d --- /dev/null +++ b/src/test/java/org/apache/hadoop/hbase/regionserver/TestResettingCounters.java @@ -0,0 +1,100 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * 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.hadoop.hbase.regionserver; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.io.IOException; + +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.fs.FileSystem; +import org.apache.hadoop.fs.Path; +import org.apache.hadoop.hbase.HBaseTestingUtility; +import org.apache.hadoop.hbase.HColumnDescriptor; +import org.apache.hadoop.hbase.HRegionInfo; +import org.apache.hadoop.hbase.HTableDescriptor; +import org.apache.hadoop.hbase.KeyValue; +import org.apache.hadoop.hbase.client.Increment; +import org.apache.hadoop.hbase.client.Result; +import org.apache.hadoop.hbase.util.Bytes; +import org.junit.Test; + +public class TestResettingCounters { + + @Test + public void testResettingCounters() throws Exception { + + HBaseTestingUtility htu = new HBaseTestingUtility(); + Configuration conf = htu.getConfiguration(); + FileSystem fs = FileSystem.get(conf); + byte [] table = Bytes.toBytes("table"); + byte [][] families = new byte [][] { + Bytes.toBytes("family1"), + Bytes.toBytes("family2"), + Bytes.toBytes("family3") + }; + int numQualifiers = 10; + byte [][] qualifiers = new byte [numQualifiers][]; + for (int i=0; i