hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r816957 - /hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/TestHMsg.java
Date Sat, 19 Sep 2009 21:42:17 GMT
Author: stack
Date: Sat Sep 19 21:42:17 2009
New Revision: 816957

URL: http://svn.apache.org/viewvc?rev=816957&view=rev
Log:
HBASE-1853 Each time around the regionserver core loop, we clear the messages to pass master,
even if we failed to deliver them

Added:
    hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/TestHMsg.java

Added: hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/TestHMsg.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/TestHMsg.java?rev=816957&view=auto
==============================================================================
--- hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/TestHMsg.java (added)
+++ hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/TestHMsg.java Sat Sep 19 21:42:17
2009
@@ -0,0 +1,55 @@
+/**
+ * Copyright 2009 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;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.hadoop.hbase.util.Bytes;
+
+import junit.framework.TestCase;
+
+public class TestHMsg extends TestCase {
+  public void testList() {
+    List<HMsg> msgs = new ArrayList<HMsg>();
+    HMsg hmsg = null;
+    final int size = 10;
+    for (int i = 0; i < size; i++) {
+      byte [] b = Bytes.toBytes(i);
+      hmsg = new HMsg(HMsg.Type.MSG_REGION_OPEN,
+        new HRegionInfo(new HTableDescriptor(Bytes.toBytes("test")), b, b));
+      msgs.add(hmsg);
+    }
+    assertEquals(size, msgs.size());
+    int index = msgs.indexOf(hmsg);
+    assertNotSame(-1, index);
+    msgs.remove(index);
+    assertEquals(size - 1, msgs.size());
+    byte [] other = Bytes.toBytes("other");
+    hmsg = new HMsg(HMsg.Type.MSG_REGION_OPEN,
+      new HRegionInfo(new HTableDescriptor(Bytes.toBytes("test")), other, other));
+    assertEquals(-1, msgs.indexOf(hmsg));
+    // Assert that two HMsgs are same if same content.
+    byte [] b = Bytes.toBytes(1);
+    hmsg = new HMsg(HMsg.Type.MSG_REGION_OPEN,
+     new HRegionInfo(new HTableDescriptor(Bytes.toBytes("test")), b, b));
+    assertNotSame(-1, msgs.indexOf(hmsg));
+  }
+}



Mime
View raw message