You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by st...@apache.org on 2009/03/19 10:03:20 UTC
svn commit: r755878 [4/4] - in /hadoop/hbase/trunk: ./
src/java/org/apache/hadoop/hbase/ src/java/org/apache/hadoop/hbase/client/
src/java/org/apache/hadoop/hbase/client/tableindexed/
src/java/org/apache/hadoop/hbase/client/transactional/ src/java/org/...
Modified: hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/regionserver/TestHRegion.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/regionserver/TestHRegion.java?rev=755878&r1=755877&r2=755878&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/regionserver/TestHRegion.java (original)
+++ hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/regionserver/TestHRegion.java Thu Mar 19 09:03:08 2009
@@ -23,6 +23,7 @@
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import java.util.TreeMap;
import org.apache.hadoop.hdfs.MiniDFSCluster;
@@ -70,7 +71,8 @@
private static final int FIRST_ROW = 1;
private static final int NUM_VALS = 1000;
- private static final byte [] CONTENTS_BASIC = Bytes.toBytes("contents:basic");
+ private static final String CONTENTS_BASIC_STR = "contents:basic";
+ private static final byte [] CONTENTS_BASIC = Bytes.toBytes(CONTENTS_BASIC_STR);
private static final String CONTENTSTR = "contentstr";
private static final String ANCHORNUM = "anchor:anchornum-";
private static final String ANCHORSTR = "anchorstr";
@@ -83,9 +85,12 @@
HRegionIncommon region = null;
private static int numInserted = 0;
-
+
+ /**
+ * @see org.apache.hadoop.hbase.HBaseTestCase#setUp()
+ */
@Override
- public void setUp() throws Exception {
+ protected void setUp() throws Exception {
this.conf.set("hbase.hstore.compactionThreshold", "2");
conf.setLong("hbase.hregion.max.filesize", 65536);
@@ -145,20 +150,22 @@
byte [] collabel = null;
for (int k = FIRST_ROW; k <= NUM_VALS; k++) {
- byte [] rowlabel = Bytes.toBytes("row_" + k);
+ String rowlabelStr = "row_" + k;
+ byte [] rowlabel = Bytes.toBytes(rowlabelStr);
if (k % 100 == 0) LOG.info(Bytes.toString(rowlabel));
byte [] bodydata = region.get(rowlabel, CONTENTS_BASIC).getValue();
assertNotNull(bodydata);
String bodystr = new String(bodydata, HConstants.UTF8_ENCODING).trim();
String teststr = CONTENTSTR + k;
- assertEquals("Incorrect value for key: (" + rowlabel + "," + CONTENTS_BASIC
+ assertEquals("Incorrect value for key: (" + rowlabelStr + "," + CONTENTS_BASIC_STR
+ "), expected: '" + teststr + "' got: '" + bodystr + "'",
bodystr, teststr);
- collabel = Bytes.toBytes(ANCHORNUM + k);
+ String collabelStr = ANCHORNUM + k;
+ collabel = Bytes.toBytes(collabelStr);
bodydata = region.get(rowlabel, collabel).getValue();
bodystr = new String(bodydata, HConstants.UTF8_ENCODING).trim();
teststr = ANCHORSTR + k;
- assertEquals("Incorrect value for key: (" + rowlabel + "," + collabel
+ assertEquals("Incorrect value for key: (" + rowlabelStr + "," + collabelStr
+ "), expected: '" + teststr + "' got: '" + bodystr + "'",
bodystr, teststr);
}
@@ -205,8 +212,8 @@
try {
byte [] rowid = Bytes.toBytes(Integer.toString(i));
lockids[i] = r.obtainRowLock(rowid);
- rowid.equals(r.getRowFromLock(lockids[i]));
- LOG.debug(getName() + " locked " + rowid.toString());
+ assertEquals(rowid, r.getRowFromLock(lockids[i]));
+ LOG.debug(getName() + " locked " + Bytes.toString(rowid));
} catch (IOException e) {
e.printStackTrace();
}
@@ -289,16 +296,16 @@
new TreeMap<byte [], Cell>(Bytes.BYTES_COMPARATOR);
int k = 0;
while(s.next(curKey, curVals)) {
- for(Iterator<byte []> it = curVals.keySet().iterator(); it.hasNext(); ) {
- byte [] col = it.next();
- byte [] val = curVals.get(col).getValue();
+ for (Map.Entry<byte[], Cell> entry : curVals.entrySet()) {
+ byte [] col = entry.getKey();
+ byte [] val = entry.getValue().getValue();
int curval =
Integer.parseInt(new String(val, HConstants.UTF8_ENCODING).trim());
for(int j = 0; j < cols.length; j++) {
if (Bytes.compareTo(col, cols[j]) == 0) {
- assertEquals("Error at:" + curKey.getRow() + "/"
+ assertEquals("Error at:" + Bytes.toString(curKey.getRow()) + "/"
+ curKey.getTimestamp()
- + ", Value for " + col + " should be: " + k
+ + ", Value for " + Bytes.toString(col) + " should be: " + k
+ ", but was fetched as: " + curval, k, curval);
numFetched++;
}
@@ -338,16 +345,16 @@
new TreeMap<byte [], Cell>(Bytes.BYTES_COMPARATOR);
int k = 0;
while(s.next(curKey, curVals)) {
- for(Iterator<byte []> it = curVals.keySet().iterator(); it.hasNext(); ) {
- byte [] col = it.next();
- byte [] val = curVals.get(col).getValue();
+ for (Map.Entry<byte[], Cell> entry : curVals.entrySet()) {
+ byte [] col = entry.getKey();
+ byte [] val = entry.getValue().getValue();
int curval =
Integer.parseInt(new String(val, HConstants.UTF8_ENCODING).trim());
for(int j = 0; j < cols.length; j++) {
if (Bytes.compareTo(col, cols[j]) == 0) {
- assertEquals("Error at:" + curKey.getRow() + "/"
+ assertEquals("Error at:" + Bytes.toString(curKey.getRow()) + "/"
+ curKey.getTimestamp()
- + ", Value for " + col + " should be: " + k
+ + ", Value for " + Bytes.toString(col) + " should be: " + k
+ ", but was fetched as: " + curval, k, curval);
numFetched++;
}
@@ -397,16 +404,16 @@
new TreeMap<byte [], Cell>(Bytes.BYTES_COMPARATOR);
int k = 0;
while(s.next(curKey, curVals)) {
- for(Iterator<byte []> it = curVals.keySet().iterator(); it.hasNext(); ) {
- byte [] col = it.next();
- byte [] val = curVals.get(col).getValue();
+ for (Map.Entry<byte[], Cell> entry : curVals.entrySet()) {
+ byte [] col = entry.getKey();
+ byte [] val = entry.getValue().getValue();
int curval =
Integer.parseInt(new String(val, HConstants.UTF8_ENCODING).trim());
for(int j = 0; j < cols.length; j++) {
if(Bytes.compareTo(col, cols[j]) == 0) {
- assertEquals("Error at:" + curKey.getRow() + "/"
+ assertEquals("Error at:" + Bytes.toString(curKey.getRow()) + "/"
+ curKey.getTimestamp()
- + ", Value for " + col + " should be: " + k
+ + ", Value for " + Bytes.toString(col) + " should be: " + k
+ ", but was fetched as: " + curval, k, curval);
numFetched++;
}
@@ -445,14 +452,14 @@
new TreeMap<byte [], Cell>(Bytes.BYTES_COMPARATOR);
int k = 0;
while(s.next(curKey, curVals)) {
- for(Iterator<byte []> it = curVals.keySet().iterator(); it.hasNext(); ) {
- byte [] col = it.next();
- byte [] val = curVals.get(col).getValue();
+ for (Map.Entry<byte[], Cell> entry : curVals.entrySet()) {
+ byte [] col = entry.getKey();
+ byte [] val = entry.getValue().getValue();
int curval =
Integer.parseInt(new String(val, HConstants.UTF8_ENCODING).trim());
for (int j = 0; j < cols.length; j++) {
if (Bytes.compareTo(col, cols[j]) == 0) {
- assertEquals("Value for " + col + " should be: " + k
+ assertEquals("Value for " + Bytes.toString(col) + " should be: " + k
+ ", but was fetched as: " + curval, curval, k);
numFetched++;
}
@@ -481,14 +488,14 @@
new TreeMap<byte [], Cell>(Bytes.BYTES_COMPARATOR);
int k = 500;
while(s.next(curKey, curVals)) {
- for(Iterator<byte []> it = curVals.keySet().iterator(); it.hasNext(); ) {
- byte [] col = it.next();
- byte [] val = curVals.get(col).getValue();
+ for (Map.Entry<byte[], Cell> entry : curVals.entrySet()) {
+ byte [] col = entry.getKey();
+ byte [] val = entry.getValue().getValue();
int curval =
Integer.parseInt(new String(val, HConstants.UTF8_ENCODING).trim());
for (int j = 0; j < cols.length; j++) {
if (Bytes.compareTo(col, cols[j]) == 0) {
- assertEquals("Value for " + col + " should be: " + k
+ assertEquals("Value for " + Bytes.toString(col) + " should be: " + k
+ ", but was fetched as: " + curval, curval, k);
numFetched++;
}
@@ -567,19 +574,19 @@
new TreeMap<byte [], Cell>(Bytes.BYTES_COMPARATOR);
int k = 0;
while(s.next(curKey, curVals)) {
- for(Iterator<byte []> it = curVals.keySet().iterator(); it.hasNext(); ) {
- byte [] col = it.next();
- byte [] val = curVals.get(col).getValue();
+ for (Map.Entry<byte[], Cell> entry : curVals.entrySet()) {
+ byte [] col = entry.getKey();
+ byte [] val = entry.getValue().getValue();
String curval = Bytes.toString(val);
if(Bytes.compareTo(col, CONTENTS_BASIC) == 0) {
- assertTrue("Error at:" + curKey.getRow() + "/" + curKey.getTimestamp()
- + ", Value for " + col + " should start with: " + CONTENTSTR
+ assertTrue("Error at:" + Bytes.toString(curKey.getRow()) + "/" + curKey.getTimestamp()
+ + ", Value for " + Bytes.toString(col) + " should start with: " + CONTENTSTR
+ ", but was fetched as: " + curval,
curval.startsWith(CONTENTSTR));
contentsFetched++;
} else if (Bytes.toString(col).startsWith(ANCHORNUM)) {
- assertTrue("Error at:" + curKey.getRow() + "/" + curKey.getTimestamp()
+ assertTrue("Error at:" + Bytes.toString(curKey.getRow()) + "/" + curKey.getTimestamp()
+ ", Value for " + Bytes.toString(col) +
" should start with: " + ANCHORSTR
+ ", but was fetched as: " + curval,
@@ -587,7 +594,7 @@
anchorFetched++;
} else {
- LOG.info("UNEXPECTED COLUMN " + col);
+ LOG.info("UNEXPECTED COLUMN " + Bytes.toString(col));
}
}
curVals.clear();
@@ -621,15 +628,15 @@
new TreeMap<byte [], Cell>(Bytes.BYTES_COMPARATOR);
int k = 0;
while(s.next(curKey, curVals)) {
- for(Iterator<byte []> it = curVals.keySet().iterator(); it.hasNext(); ) {
- byte [] col = it.next();
- byte [] val = curVals.get(col).getValue();
+ for (Map.Entry<byte[], Cell> entry : curVals.entrySet()) {
+ byte [] col = entry.getKey();
+ byte [] val = entry.getValue().getValue();
int curval =
Integer.parseInt(new String(val, HConstants.UTF8_ENCODING).trim());
for (int j = 0; j < cols.length; j++) {
if (Bytes.compareTo(col, cols[j]) == 0) {
- assertEquals("Value for " + col + " should be: " + k
+ assertEquals("Value for " + Bytes.toString(col) + " should be: " + k
+ ", but was fetched as: " + curval, curval, k);
numFetched++;
}
Modified: hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/regionserver/TestScanner.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/regionserver/TestScanner.java?rev=755878&r1=755877&r2=755878&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/regionserver/TestScanner.java (original)
+++ hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/regionserver/TestScanner.java Thu Mar 19 09:03:08 2009
@@ -283,6 +283,7 @@
/**
* Test basic stop row filter works.
+ * @throws Exception
*/
public void testStopRow() throws Exception {
byte [] startrow = Bytes.toBytes("bbb");
Modified: hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/regionserver/TestSplit.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/regionserver/TestSplit.java?rev=755878&r1=755877&r2=755878&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/regionserver/TestSplit.java (original)
+++ hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/regionserver/TestSplit.java Thu Mar 19 09:03:08 2009
@@ -20,6 +20,7 @@
package org.apache.hadoop.hbase.regionserver;
import java.io.IOException;
+import java.util.Map;
import java.util.TreeMap;
import org.apache.commons.logging.Log;
@@ -101,6 +102,7 @@
final HRegion regionForThread = region;
Thread splitThread = new Thread() {
+ @Override
public void run() {
try {
split(regionForThread, midkey);
@@ -235,8 +237,8 @@
new TreeMap<byte [], Cell>(Bytes.BYTES_COMPARATOR);
boolean first = true;
OUTER_LOOP: while(s.next(curKey, curVals)) {
- for(byte [] col: curVals.keySet()) {
- byte [] val = curVals.get(col).getValue();
+ for (Map.Entry<byte[], Cell> entry : curVals.entrySet()) {
+ byte [] val = entry.getValue().getValue();
byte [] curval = val;
if (first) {
first = false;
@@ -252,7 +254,7 @@
}
}
- private HRegion [] split(final HRegion r, final byte [] splitRow)
+ protected HRegion [] split(final HRegion r, final byte [] splitRow)
throws IOException {
// Assert can get mid key from passed region.
assertGet(r, COLFAMILY_NAME3, splitRow);
Modified: hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/regionserver/transactional/DisabledTestHLogRecovery.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/regionserver/transactional/DisabledTestHLogRecovery.java?rev=755878&r1=755877&r2=755878&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/regionserver/transactional/DisabledTestHLogRecovery.java (original)
+++ hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/regionserver/transactional/DisabledTestHLogRecovery.java Thu Mar 19 09:03:08 2009
@@ -46,12 +46,12 @@
import org.apache.hadoop.hbase.util.Bytes;
public class DisabledTestHLogRecovery extends HBaseClusterTestCase {
- private static final Log LOG = LogFactory.getLog(DisabledTestHLogRecovery.class);
+ protected static final Log LOG = LogFactory.getLog(DisabledTestHLogRecovery.class);
private static final String TABLE_NAME = "table1";
private static final byte[] FAMILY = Bytes.toBytes("family:");
- private static final byte[] COL_A = Bytes.toBytes("family:a");
+ static final byte[] COL_A = Bytes.toBytes("family:a");
private static final byte[] ROW1 = Bytes.toBytes("row1");
private static final byte[] ROW2 = Bytes.toBytes("row2");
@@ -198,7 +198,7 @@
+ (abort ? "aborted" : "shut down"));
}
- private void verify(final int numRuns) throws IOException {
+ protected void verify(final int numRuns) throws IOException {
// Reads
int row1 = Bytes.toInt(table.get(ROW1, COL_A).getValue());
int row2 = Bytes.toInt(table.get(ROW2, COL_A).getValue());
@@ -265,18 +265,12 @@
LOG.fatal("could not re-open meta table because", e);
fail();
}
- Scanner scanner = null;
try {
verify(numRuns);
LOG.info("Success!");
} catch (Exception e) {
e.printStackTrace();
fail();
- } finally {
- if (scanner != null) {
- LOG.info("Closing scanner " + scanner);
- scanner.close();
- }
}
}
};
Modified: hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/util/TestMergeTool.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/util/TestMergeTool.java?rev=755878&r1=755877&r2=755878&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/util/TestMergeTool.java (original)
+++ hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/util/TestMergeTool.java Thu Mar 19 09:03:08 2009
@@ -40,7 +40,7 @@
/** Test stand alone merge tool that can merge arbitrary regions */
public class TestMergeTool extends HBaseTestCase {
static final Log LOG = LogFactory.getLog(TestMergeTool.class);
- protected static final byte [] COLUMN_NAME = Bytes.toBytes("contents:");
+ static final byte [] COLUMN_NAME = Bytes.toBytes("contents:");
private final HRegionInfo[] sourceRegions = new HRegionInfo[5];
private final HRegion[] regions = new HRegion[5];
private HTableDescriptor desc;
@@ -175,7 +175,7 @@
for (int i = 0; i < upperbound; i++) {
for (int j = 0; j < rows[i].length; j++) {
byte[] bytes = merged.get(rows[i][j], COLUMN_NAME, -1, -1)[0].getValue();
- assertNotNull(rows[i][j].toString(), bytes);
+ assertNotNull(Bytes.toString(rows[i][j]), bytes);
assertTrue(Bytes.equals(bytes, rows[i][j]));
}
}