hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r1459013 [8/8] - in /hbase/trunk: hbase-client/src/main/java/org/apache/hadoop/hbase/client/ hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/ hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/ hbase-client/src/test/java/org...
Date Wed, 20 Mar 2013 19:36:47 GMT
Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestIPC.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestIPC.java?rev=1459013&r1=1459012&r2=1459013&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestIPC.java (original)
+++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestIPC.java Wed Mar
20 19:36:46 2013
@@ -25,21 +25,35 @@ import static org.mockito.Mockito.doThro
 import static org.mockito.Mockito.spy;
 
 import java.io.IOException;
+import java.lang.reflect.Method;
 import java.net.InetSocketAddress;
 import java.net.Socket;
+import java.util.ArrayList;
+import java.util.List;
 
 import javax.net.SocketFactory;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hbase.Cell;
+import org.apache.hadoop.hbase.CellScannable;
+import org.apache.hadoop.hbase.CellScanner;
+import org.apache.hadoop.hbase.CellUtil;
 import org.apache.hadoop.hbase.HBaseConfiguration;
 import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.IpcProtocol;
+import org.apache.hadoop.hbase.KeyValue;
+import org.apache.hadoop.hbase.KeyValueUtil;
 import org.apache.hadoop.hbase.SmallTests;
+import org.apache.hadoop.hbase.client.Put;
+import org.apache.hadoop.hbase.client.RowMutations;
 import org.apache.hadoop.hbase.monitoring.MonitoredRPCHandler;
-import org.apache.hadoop.hbase.protobuf.generated.RPCProtos.RpcRequestBody;
+import org.apache.hadoop.hbase.protobuf.RequestConverter;
 import org.apache.hadoop.hbase.security.User;
+import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.hbase.util.Pair;
+import org.apache.hadoop.io.compress.GzipCodec;
 import org.apache.hadoop.net.NetUtils;
 import org.apache.hadoop.util.StringUtils;
 import org.junit.Test;
@@ -53,6 +67,8 @@ import com.google.protobuf.Message;
 @Category(SmallTests.class)
 public class TestIPC {
   public static final Log LOG = LogFactory.getLog(TestIPC.class);
+  static byte [] CELL_BYTES =  Bytes.toBytes("xyz");
+  static Cell CELL = new KeyValue(CELL_BYTES, CELL_BYTES, CELL_BYTES, CELL_BYTES);
 
   private static class TestRpcServer extends HBaseServer {
     TestRpcServer() throws IOException {
@@ -60,10 +76,53 @@ public class TestIPC {
     }
 
     @Override
-    public Message call(Class<? extends IpcProtocol> protocol,
-        RpcRequestBody param, long receiveTime, MonitoredRPCHandler status)
+    public Pair<Message, CellScanner> call(Class<? extends IpcProtocol> protocol,
Method method,
+        Message param, final CellScanner cells, long receiveTime, MonitoredRPCHandler status)
     throws IOException {
-      return param;
+      /*
+      List<Cell> cellsOut = new ArrayList<Cell>();
+      while (cells.advance()) {
+        Cell cell = cells.current();
+        Bytes.equals(cell.getRowArray(), cell.getRowOffset(), cell.getRowLength(),
+          CELL_BYTES, 0, CELL_BYTES.length);
+        cellsOut.add(cell);
+      }
+      return new Pair<Message, CellScanner>(param, CellUtil.createCellScanner(cellsOut));
+      */
+      return new Pair<Message, CellScanner>(param, null);
+    }
+  }
+
+  /**
+   * A nothing protocol used in test below.
+   */
+  interface NothingProtocol extends IpcProtocol {
+    void doNothing();
+  }
+
+  public static class DoNothing implements NothingProtocol {
+    public void doNothing() {}
+  }
+
+  @Test
+  public void testCompressCellBlock()
+  throws IOException, InterruptedException, SecurityException, NoSuchMethodException {
+    Configuration conf = HBaseConfiguration.create();
+    conf.set("hbase.client.rpc.compressor", GzipCodec.class.getCanonicalName());
+    TestRpcServer rpcServer = new TestRpcServer();
+    HBaseClient client = new HBaseClient(conf, HConstants.CLUSTER_ID_DEFAULT);
+    List<Cell> cells = new ArrayList<Cell>();
+    cells.add(CELL);
+    try {
+      rpcServer.start();
+      InetSocketAddress address = rpcServer.getListenerAddress();
+      // Get any method name... just so it is not null
+      Method m = NothingProtocol.class.getMethod("doNothing");
+      client.call(m, null, CellUtil.createCellScanner(cells), address, NothingProtocol.class,
+        User.getCurrent(), 0);
+    } finally {
+      client.stop();
+      rpcServer.stop();
     }
   }
 
@@ -81,18 +140,73 @@ public class TestIPC {
     }).when(spyFactory).createSocket();
 
     TestRpcServer rpcServer = new TestRpcServer();
-    rpcServer.start();
-
-    HBaseClient client = new HBaseClient(
-        conf, HConstants.CLUSTER_ID_DEFAULT, spyFactory);
-    InetSocketAddress address = rpcServer.getListenerAddress();
-
+    HBaseClient client = new HBaseClient(conf, HConstants.CLUSTER_ID_DEFAULT, spyFactory);
     try {
-      client.call(RpcRequestBody.getDefaultInstance(), address, User.getCurrent(), 0);
+      rpcServer.start();
+      InetSocketAddress address = rpcServer.getListenerAddress();
+      client.call(null, null, null, address, null, User.getCurrent(), 0);
       fail("Expected an exception to have been thrown!");
     } catch (Exception e) {
       LOG.info("Caught expected exception: " + e.toString());
       assertTrue(StringUtils.stringifyException(e).contains("Injected fault"));
+    } finally {
+      client.stop();
+      rpcServer.stop();
+    }
+  }
+
+  public static void main(String[] args)
+  throws IOException, SecurityException, NoSuchMethodException, InterruptedException {
+    if (args.length != 2) {
+      System.out.println("Usage: TestIPC <CYCLES> <CELLS_PER_CYCLE>");
+      return;
+    }
+    // ((Log4JLogger)HBaseServer.LOG).getLogger().setLevel(Level.INFO);
+    // ((Log4JLogger)HBaseClient.LOG).getLogger().setLevel(Level.INFO);
+    int cycles = Integer.parseInt(args[0]);
+    int cellcount = Integer.parseInt(args[1]);
+    Configuration conf = HBaseConfiguration.create();
+    TestRpcServer rpcServer = new TestRpcServer();
+    HBaseClient client = new HBaseClient(conf, HConstants.CLUSTER_ID_DEFAULT);
+    KeyValue kv = KeyValueUtil.ensureKeyValue(CELL);
+    Put p = new Put(kv.getRow());
+    for (int i = 0; i < cellcount; i++) {
+      p.add(kv);
+    }
+    RowMutations rm = new RowMutations(kv.getRow());
+    rm.add(p);
+    try {
+      rpcServer.start();
+      InetSocketAddress address = rpcServer.getListenerAddress();
+      // Get any method name... just so it is not null
+      Method m = NothingProtocol.class.getMethod("doNothing");
+      long startTime = System.currentTimeMillis();
+      User user = User.getCurrent();
+      for (int i = 0; i < cycles; i++) {
+        List<CellScannable> cells = new ArrayList<CellScannable>();
+        // Message param = RequestConverter.buildMultiRequest(HConstants.EMPTY_BYTE_ARRAY,
rm);
+        Message param = RequestConverter.buildNoDataMultiRequest(HConstants.EMPTY_BYTE_ARRAY,
rm, cells);
+        CellScanner cellScanner = CellUtil.createCellScanner(cells);
+        if (i % 1000 == 0) {
+          LOG.info("" + i);
+          // Uncomment this for a thread dump every so often.
+          // ReflectionUtils.printThreadInfo(new PrintWriter(System.out),
+          //  "Thread dump " + Thread.currentThread().getName());
+        }
+        Pair<Message, CellScanner> response =
+          client.call(m, param, cellScanner, address, NothingProtocol.class, user, 0);
+        /*
+        int count = 0;
+        while (p.getSecond().advance()) {
+          count++;
+        }
+        assertEquals(cells.size(), count);*/
+      }
+      LOG.info("Cycled " + cycles + " time(s) with " + cellcount + " cell(s) in " +
+         (System.currentTimeMillis() - startTime) + "ms");
+    } finally {
+      client.stop();
+      rpcServer.stop();
     }
   }
-}
\ No newline at end of file
+}

Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestProtoBufRpc.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestProtoBufRpc.java?rev=1459013&r1=1459012&r2=1459013&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestProtoBufRpc.java
(original)
+++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestProtoBufRpc.java
Wed Mar 20 19:36:46 2013
@@ -22,13 +22,15 @@ import java.net.InetSocketAddress;
 
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hbase.HConstants;
-import org.apache.hadoop.hbase.MediumTests;
 import org.apache.hadoop.hbase.IpcProtocol;
+import org.apache.hadoop.hbase.MediumTests;
 import org.apache.hadoop.hbase.ipc.protobuf.generated.TestProtos.EchoRequestProto;
 import org.apache.hadoop.hbase.ipc.protobuf.generated.TestProtos.EchoResponseProto;
 import org.apache.hadoop.hbase.ipc.protobuf.generated.TestProtos.EmptyRequestProto;
 import org.apache.hadoop.hbase.ipc.protobuf.generated.TestProtos.EmptyResponseProto;
 import org.apache.hadoop.hbase.ipc.protobuf.generated.TestRpcServiceProtos.TestProtobufRpcProto;
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
 import org.junit.Assert;
 import org.junit.Test;
 import org.junit.Before;
@@ -40,9 +42,9 @@ import com.google.protobuf.ServiceExcept
 
 /**
  * Test for testing protocol buffer based RPC mechanism.
- * This test depends on test.proto definition of types in 
+ * This test depends on test.proto definition of types in
  * hbase-server/src/test/protobuf/test.proto
- * and protobuf service definition from 
+ * and protobuf service definition from
  * hbase-server/src/test/protobuf/test_rpc_service.proto
  */
 @Category(MediumTests.class)
@@ -53,8 +55,7 @@ public class TestProtoBufRpc {
   private static Configuration conf;
   private static RpcServer server;
 
-  public interface TestRpcService
-      extends TestProtobufRpcProto.BlockingInterface, IpcProtocol {
+  public interface TestRpcService extends TestProtobufRpcProto.BlockingInterface, IpcProtocol
{
     public long VERSION = 1;
   }
 
@@ -83,18 +84,20 @@ public class TestProtoBufRpc {
   @Before
   public  void setUp() throws IOException { // Setup server for both protocols
     conf = new Configuration();
-
+    Logger log = Logger.getLogger("org.apache.hadoop.ipc.HBaseServer");
+    log.setLevel(Level.DEBUG);
+    log = Logger.getLogger("org.apache.hadoop.ipc.HBaseServer.trace");
+    log.setLevel(Level.TRACE);
     // Create server side implementation
     PBServerImpl serverImpl = new PBServerImpl();
     // Get RPC server for server side implementation
     server = HBaseServerRPC.getServer(TestRpcService.class,serverImpl,
-        new Class[]{TestRpcService.class}, 
+        new Class[]{TestRpcService.class},
         ADDRESS, PORT, 10, 10, true, conf, 0);
     addr = server.getListenerAddress();
     server.start();
   }
-  
-  
+
   @After
   public void tearDown() throws Exception {
     server.stop();
@@ -105,14 +108,13 @@ public class TestProtoBufRpc {
     ProtobufRpcClientEngine clientEngine =
         new ProtobufRpcClientEngine(conf, HConstants.CLUSTER_ID_DEFAULT);
     try {
-      TestRpcService client = clientEngine.getProxy(TestRpcService.class, addr, conf, 10000);
+      TestRpcService client = clientEngine.getProxy(TestRpcService.class, addr, conf, 100000);
       // Test ping method
       EmptyRequestProto emptyRequest = EmptyRequestProto.newBuilder().build();
       client.ping(null, emptyRequest);
 
       // Test echo method
-      EchoRequestProto echoRequest = EchoRequestProto.newBuilder()
-          .setMessage("hello").build();
+      EchoRequestProto echoRequest = EchoRequestProto.newBuilder().setMessage("hello").build();
       EchoResponseProto echoResponse = client.echo(null, echoRequest);
       Assert.assertEquals(echoResponse.getMessage(), "hello");
 
@@ -126,4 +128,4 @@ public class TestProtoBufRpc {
       clientEngine.close();
     }
   }
-}
\ No newline at end of file
+}

Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/protobuf/TestProtobufUtil.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/protobuf/TestProtobufUtil.java?rev=1459013&r1=1459012&r2=1459013&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/protobuf/TestProtobufUtil.java
(original)
+++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/protobuf/TestProtobufUtil.java
Wed Mar 20 19:36:46 2013
@@ -31,11 +31,11 @@ import org.apache.hadoop.hbase.client.Pu
 import org.apache.hadoop.hbase.client.Scan;
 import org.apache.hadoop.hbase.protobuf.generated.ClientProtos;
 import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.Column;
-import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.Mutate;
-import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.Mutate.ColumnValue;
-import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.Mutate.ColumnValue.QualifierValue;
-import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.Mutate.DeleteType;
-import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.Mutate.MutateType;
+import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MutationProto;
+import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MutationProto.ColumnValue;
+import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MutationProto.ColumnValue.QualifierValue;
+import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MutationProto.DeleteType;
+import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MutationProto.MutationType;
 import org.apache.hadoop.hbase.util.Bytes;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
@@ -88,9 +88,9 @@ public class TestProtobufUtil {
    */
   @Test
   public void testAppend() throws IOException {
-    Mutate.Builder mutateBuilder = Mutate.newBuilder();
+    MutationProto.Builder mutateBuilder = MutationProto.newBuilder();
     mutateBuilder.setRow(ByteString.copyFromUtf8("row"));
-    mutateBuilder.setMutateType(MutateType.APPEND);
+    mutateBuilder.setMutateType(MutationType.APPEND);
     mutateBuilder.setTimestamp(111111);
     ColumnValue.Builder valueBuilder = ColumnValue.newBuilder();
     valueBuilder.setFamily(ByteString.copyFromUtf8("f1"));
@@ -103,29 +103,27 @@ public class TestProtobufUtil {
     valueBuilder.addQualifierValue(qualifierBuilder.build());
     mutateBuilder.addColumnValue(valueBuilder.build());
 
-    Mutate proto = mutateBuilder.build();
+    MutationProto proto = mutateBuilder.build();
     // default fields
     assertEquals(true, proto.getWriteToWAL());
 
     // set the default value for equal comparison
-    mutateBuilder = Mutate.newBuilder(proto);
+    mutateBuilder = MutationProto.newBuilder(proto);
     mutateBuilder.setWriteToWAL(true);
 
-    Append append = ProtobufUtil.toAppend(proto);
+    Append append = ProtobufUtil.toAppend(proto, null);
 
     // append always use the latest timestamp,
     // add the timestamp to the original mutate
     long timestamp = append.getTimeStamp();
     mutateBuilder.setTimestamp(timestamp);
-    for (ColumnValue.Builder column:
-        mutateBuilder.getColumnValueBuilderList()) {
+    for (ColumnValue.Builder column: mutateBuilder.getColumnValueBuilderList()) {
       for (QualifierValue.Builder qualifier:
           column.getQualifierValueBuilderList()) {
         qualifier.setTimestamp(timestamp);
       }
     }
-    assertEquals(mutateBuilder.build(),
-      ProtobufUtil.toMutate(MutateType.APPEND, append));
+    assertEquals(mutateBuilder.build(), ProtobufUtil.toMutation(MutationType.APPEND, append));
   }
 
   /**
@@ -135,9 +133,9 @@ public class TestProtobufUtil {
    */
   @Test
   public void testDelete() throws IOException {
-    Mutate.Builder mutateBuilder = Mutate.newBuilder();
+    MutationProto.Builder mutateBuilder = MutationProto.newBuilder();
     mutateBuilder.setRow(ByteString.copyFromUtf8("row"));
-    mutateBuilder.setMutateType(MutateType.DELETE);
+    mutateBuilder.setMutateType(MutationType.DELETE);
     mutateBuilder.setTimestamp(111111);
     ColumnValue.Builder valueBuilder = ColumnValue.newBuilder();
     valueBuilder.setFamily(ByteString.copyFromUtf8("f1"));
@@ -152,12 +150,12 @@ public class TestProtobufUtil {
     valueBuilder.addQualifierValue(qualifierBuilder.build());
     mutateBuilder.addColumnValue(valueBuilder.build());
 
-    Mutate proto = mutateBuilder.build();
+    MutationProto proto = mutateBuilder.build();
     // default fields
     assertEquals(true, proto.getWriteToWAL());
 
     // set the default value for equal comparison
-    mutateBuilder = Mutate.newBuilder(proto);
+    mutateBuilder = MutationProto.newBuilder(proto);
     mutateBuilder.setWriteToWAL(true);
 
     Delete delete = ProtobufUtil.toDelete(proto);
@@ -172,7 +170,7 @@ public class TestProtobufUtil {
       }
     }
     assertEquals(mutateBuilder.build(),
-      ProtobufUtil.toMutate(MutateType.DELETE, delete));
+      ProtobufUtil.toMutation(MutationType.DELETE, delete));
   }
 
   /**
@@ -182,9 +180,9 @@ public class TestProtobufUtil {
    */
   @Test
   public void testIncrement() throws IOException {
-    Mutate.Builder mutateBuilder = Mutate.newBuilder();
+    MutationProto.Builder mutateBuilder = MutationProto.newBuilder();
     mutateBuilder.setRow(ByteString.copyFromUtf8("row"));
-    mutateBuilder.setMutateType(MutateType.INCREMENT);
+    mutateBuilder.setMutateType(MutationType.INCREMENT);
     ColumnValue.Builder valueBuilder = ColumnValue.newBuilder();
     valueBuilder.setFamily(ByteString.copyFromUtf8("f1"));
     QualifierValue.Builder qualifierBuilder = QualifierValue.newBuilder();
@@ -196,16 +194,16 @@ public class TestProtobufUtil {
     valueBuilder.addQualifierValue(qualifierBuilder.build());
     mutateBuilder.addColumnValue(valueBuilder.build());
 
-    Mutate proto = mutateBuilder.build();
+    MutationProto proto = mutateBuilder.build();
     // default fields
     assertEquals(true, proto.getWriteToWAL());
 
     // set the default value for equal comparison
-    mutateBuilder = Mutate.newBuilder(proto);
+    mutateBuilder = MutationProto.newBuilder(proto);
     mutateBuilder.setWriteToWAL(true);
 
-    Increment increment = ProtobufUtil.toIncrement(proto);
-    assertEquals(mutateBuilder.build(), ProtobufUtil.toMutate(increment));
+    Increment increment = ProtobufUtil.toIncrement(proto, null);
+    assertEquals(mutateBuilder.build(), ProtobufUtil.toMutation(increment));
   }
 
   /**
@@ -215,9 +213,9 @@ public class TestProtobufUtil {
    */
   @Test
   public void testPut() throws IOException {
-    Mutate.Builder mutateBuilder = Mutate.newBuilder();
+    MutationProto.Builder mutateBuilder = MutationProto.newBuilder();
     mutateBuilder.setRow(ByteString.copyFromUtf8("row"));
-    mutateBuilder.setMutateType(MutateType.PUT);
+    mutateBuilder.setMutateType(MutationType.PUT);
     mutateBuilder.setTimestamp(111111);
     ColumnValue.Builder valueBuilder = ColumnValue.newBuilder();
     valueBuilder.setFamily(ByteString.copyFromUtf8("f1"));
@@ -231,12 +229,12 @@ public class TestProtobufUtil {
     valueBuilder.addQualifierValue(qualifierBuilder.build());
     mutateBuilder.addColumnValue(valueBuilder.build());
 
-    Mutate proto = mutateBuilder.build();
+    MutationProto proto = mutateBuilder.build();
     // default fields
     assertEquals(true, proto.getWriteToWAL());
 
     // set the default value for equal comparison
-    mutateBuilder = Mutate.newBuilder(proto);
+    mutateBuilder = MutationProto.newBuilder(proto);
     mutateBuilder.setWriteToWAL(true);
 
     Put put = ProtobufUtil.toPut(proto);
@@ -255,7 +253,7 @@ public class TestProtobufUtil {
       }
     }
     assertEquals(mutateBuilder.build(),
-      ProtobufUtil.toMutate(MutateType.PUT, put));
+      ProtobufUtil.toMutation(MutationType.PUT, put));
   }
 
   /**

Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestClusterId.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestClusterId.java?rev=1459013&r1=1459012&r2=1459013&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestClusterId.java
(original)
+++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestClusterId.java
Wed Mar 20 19:36:46 2013
@@ -18,23 +18,21 @@
  */
 package org.apache.hadoop.hbase.regionserver;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hbase.HBaseTestingUtility;
-import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.MediumTests;
 import org.apache.hadoop.hbase.util.JVMClusterUtil;
 import org.apache.hadoop.hbase.zookeeper.ZKClusterId;
-
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
 
 /**
  * Test metrics incremented on region server operations.

Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestJoinedScanners.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestJoinedScanners.java?rev=1459013&r1=1459012&r2=1459013&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestJoinedScanners.java
(original)
+++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestJoinedScanners.java
Wed Mar 20 19:36:46 2013
@@ -22,37 +22,25 @@ import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.junit.Assert;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.util.Bytes;
-import org.apache.hadoop.hbase.KeyValue;
-import org.apache.hadoop.hbase.LargeTests;
-import org.apache.hadoop.hbase.MediumTests;
-import org.apache.hadoop.hbase.HBaseConfiguration;
+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.HColumnDescriptor;
+import org.apache.hadoop.hbase.LargeTests;
 import org.apache.hadoop.hbase.MiniHBaseCluster;
-
 import org.apache.hadoop.hbase.client.HTable;
 import org.apache.hadoop.hbase.client.Put;
-import org.apache.hadoop.hbase.client.Scan;
 import org.apache.hadoop.hbase.client.Result;
 import org.apache.hadoop.hbase.client.ResultScanner;
-
-import org.apache.hadoop.hbase.filter.SingleColumnValueExcludeFilter;
-import org.apache.hadoop.hbase.filter.SingleColumnValueFilter;
-import org.apache.hadoop.hbase.filter.FilterList;
+import org.apache.hadoop.hbase.client.Scan;
 import org.apache.hadoop.hbase.filter.CompareFilter;
-import org.apache.hadoop.hbase.filter.RowFilter;
-import org.apache.hadoop.hbase.filter.RegexStringComparator;
-
-import org.apache.hadoop.fs.FileSystem;
-import org.apache.hadoop.fs.Path;
-
+import org.apache.hadoop.hbase.filter.SingleColumnValueFilter;
+import org.apache.hadoop.hbase.util.Bytes;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
@@ -69,7 +57,6 @@ public class TestJoinedScanners {
   private static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
   private static final String DIR = TEST_UTIL.getDataTestDir("TestJoinedScanners").toString();
 
-  private static final byte[] tableName = Bytes.toBytes("testTable");
   private static final byte[] cf_essential = Bytes.toBytes("essential");
   private static final byte[] cf_joined = Bytes.toBytes("joined");
   private static final byte[] col_name = Bytes.toBytes("a");

Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestPriorityRpc.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestPriorityRpc.java?rev=1459013&r1=1459012&r2=1459013&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestPriorityRpc.java
(original)
+++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestPriorityRpc.java
Wed Mar 20 19:36:46 2013
@@ -28,58 +28,56 @@ import org.apache.hadoop.hbase.HBaseConf
 import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.HRegionInfo;
 import org.apache.hadoop.hbase.MediumTests;
-import org.apache.hadoop.hbase.protobuf.generated.AdminProtos.GetOnlineRegionRequest;
 import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.Get;
 import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetRequest;
 import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.ScanRequest;
 import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.RegionSpecifier;
 import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.RegionSpecifier.RegionSpecifierType;
-import org.apache.hadoop.hbase.protobuf.generated.RPCProtos.RpcRequestBody;
-import org.apache.hadoop.hbase.regionserver.HRegionServer.QosFunction;
-import org.junit.BeforeClass;
+import org.apache.hadoop.hbase.protobuf.generated.RPCProtos.RequestHeader;
+import org.apache.hadoop.hbase.util.Pair;
+import org.junit.Before;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 import org.mockito.Mockito;
 
 import com.google.protobuf.ByteString;
+import com.google.protobuf.Message;
 /**
  * Tests that verify certain RPCs get a higher QoS.
  */
 @Category(MediumTests.class)
 public class TestPriorityRpc {
-  static HRegionServer regionServer = null;
-  static QosFunction qosFunction = null;
-  @BeforeClass
-  public static void onetimeSetup() {
+  private HRegionServer regionServer = null;
+  private QosFunction qosFunction = null;
+
+  @Before
+  public void setup() {
     Configuration conf = HBaseConfiguration.create();
-    regionServer =
-        HRegionServer.constructRegionServer(HRegionServer.class, conf);
+    regionServer = HRegionServer.constructRegionServer(HRegionServer.class, conf);
     qosFunction = regionServer.getQosFunction();
   }
+
   @Test
   public void testQosFunctionForMeta() throws IOException {
     qosFunction = regionServer.getQosFunction();
-    RpcRequestBody.Builder rpcRequestBuilder = RpcRequestBody.newBuilder();
+    RequestHeader.Builder headerBuilder = RequestHeader.newBuilder();
     //create a rpc request that has references to META region and also
     //uses one of the known argument classes (known argument classes are
     //listed in HRegionServer.QosFunction.knownArgumentClasses)
-    rpcRequestBuilder = RpcRequestBody.newBuilder();
-    rpcRequestBuilder.setMethodName("foo");
+    headerBuilder.setMethodName("foo");
 
     GetRequest.Builder getRequestBuilder = GetRequest.newBuilder();
     RegionSpecifier.Builder regionSpecifierBuilder = RegionSpecifier.newBuilder();
     regionSpecifierBuilder.setType(RegionSpecifierType.REGION_NAME);
-    ByteString name =
-        ByteString.copyFrom(HRegionInfo.FIRST_META_REGIONINFO.getRegionName());
+    ByteString name = ByteString.copyFrom(HRegionInfo.FIRST_META_REGIONINFO.getRegionName());
     regionSpecifierBuilder.setValue(name);
     RegionSpecifier regionSpecifier = regionSpecifierBuilder.build();
     getRequestBuilder.setRegion(regionSpecifier);
     Get.Builder getBuilder = Get.newBuilder();
     getBuilder.setRow(ByteString.copyFrom("somerow".getBytes()));
     getRequestBuilder.setGet(getBuilder.build());
-    rpcRequestBuilder.setRequest(getRequestBuilder.build().toByteString());
-    rpcRequestBuilder.setRequestClassName(GetRequest.class.getCanonicalName());
-    RpcRequestBody rpcRequest = rpcRequestBuilder.build();
+    GetRequest getRequest = getRequestBuilder.build();
+    RequestHeader header = headerBuilder.build();
     HRegion mockRegion = Mockito.mock(HRegion.class);
     HRegionServer mockRS = Mockito.mock(HRegionServer.class);
     HRegionInfo mockRegionInfo = Mockito.mock(HRegionInfo.class);
@@ -87,7 +85,8 @@ public class TestPriorityRpc {
     Mockito.when(mockRegion.getRegionInfo()).thenReturn(mockRegionInfo);
     Mockito.when(mockRegionInfo.isMetaTable()).thenReturn(true);
     qosFunction.setRegionServer(mockRS);
-    assertTrue (qosFunction.apply(rpcRequest) == HConstants.HIGH_QOS);
+    assertTrue (qosFunction.apply(new Pair<RequestHeader, Message>(header, getRequest))
==
+      HConstants.HIGH_QOS);
   }
 
   @Test
@@ -96,51 +95,53 @@ public class TestPriorityRpc {
     //known argument classes (it uses one random request class)
     //(known argument classes are listed in
     //HRegionServer.QosFunction.knownArgumentClasses)
-    RpcRequestBody.Builder rpcRequestBuilder = RpcRequestBody.newBuilder();
-    rpcRequestBuilder.setMethodName("foo");
-    rpcRequestBuilder.setRequestClassName(GetOnlineRegionRequest.class.getCanonicalName());
-    RpcRequestBody rpcRequest = rpcRequestBuilder.build();
+    RequestHeader.Builder headerBuilder = RequestHeader.newBuilder();
+    headerBuilder.setMethodName("foo");
+    RequestHeader header = headerBuilder.build();
     QosFunction qosFunc = regionServer.getQosFunction();
-    assertTrue (qosFunc.apply(rpcRequest) == HConstants.NORMAL_QOS);
+    assertTrue (qosFunc.apply(new Pair<RequestHeader, Message>(header, null)) ==
+      HConstants.NORMAL_QOS);
   }
 
   @Test
   public void testQosFunctionForScanMethod() throws IOException {
-    RpcRequestBody.Builder rpcRequestBuilder = RpcRequestBody.newBuilder();
-    rpcRequestBuilder.setMethodName("scan");
+    RequestHeader.Builder headerBuilder = RequestHeader.newBuilder();
+    headerBuilder.setMethodName("scan");
+    RequestHeader header = headerBuilder.build();
 
     //build an empty scan request
     ScanRequest.Builder scanBuilder = ScanRequest.newBuilder();
-    ByteString requestBody = scanBuilder.build().toByteString();
-    rpcRequestBuilder.setRequest(requestBody);
-    RpcRequestBody rpcRequest = rpcRequestBuilder.build();
-    assertTrue (qosFunction.apply(rpcRequest) == HConstants.NORMAL_QOS);
+    ScanRequest scanRequest = scanBuilder.build();
+    HRegion mockRegion = Mockito.mock(HRegion.class);
+    HRegionServer mockRS = Mockito.mock(HRegionServer.class);
+    HRegionInfo mockRegionInfo = Mockito.mock(HRegionInfo.class);
+    Mockito.when(mockRS.getRegion((RegionSpecifier)Mockito.any())).thenReturn(mockRegion);
+    Mockito.when(mockRegion.getRegionInfo()).thenReturn(mockRegionInfo);
+    Mockito.when(mockRegionInfo.isMetaRegion()).thenReturn(false);
+    qosFunction.setRegionServer(mockRS);
+    int qos = qosFunction.apply(new Pair<RequestHeader, Message>(header, scanRequest));
+    assertTrue ("" + qos, qos == HConstants.NORMAL_QOS);
 
     //build a scan request with scannerID
     scanBuilder = ScanRequest.newBuilder();
     scanBuilder.setScannerId(12345);
-    requestBody = scanBuilder.build().toByteString();
-    rpcRequestBuilder.setRequest(requestBody);
-    rpcRequestBuilder.setRequestClassName(ScanRequest.class.getCanonicalName());
-    rpcRequest = rpcRequestBuilder.build();
+    scanRequest = scanBuilder.build();
     //mock out a high priority type handling and see the QoS returned
-    HRegionServer mockRS = Mockito.mock(HRegionServer.class);
     RegionScanner mockRegionScanner = Mockito.mock(RegionScanner.class);
-    HRegionInfo mockRegionInfo = Mockito.mock(HRegionInfo.class);
-    HRegion mockRegion = Mockito.mock(HRegion.class);
     Mockito.when(mockRS.getScanner(12345)).thenReturn(mockRegionScanner);
     Mockito.when(mockRegionScanner.getRegionInfo()).thenReturn(mockRegionInfo);
     Mockito.when(mockRS.getRegion((RegionSpecifier)Mockito.any())).thenReturn(mockRegion);
     Mockito.when(mockRegion.getRegionInfo()).thenReturn(mockRegionInfo);
-    Mockito.when(mockRegionInfo.isMetaTable()).thenReturn(true);
+    Mockito.when(mockRegionInfo.isMetaRegion()).thenReturn(true);
 
     qosFunction.setRegionServer(mockRS);
 
-    assertTrue (qosFunction.apply(rpcRequest) == HConstants.HIGH_QOS);
+    assertTrue (qosFunction.apply(new Pair<RequestHeader, Message>(header, scanRequest))
==
+      HConstants.HIGH_QOS);
 
     //the same as above but with non-meta region
-    Mockito.when(mockRegionInfo.isMetaTable()).thenReturn(false);
-    assertTrue (qosFunction.apply(rpcRequest) == HConstants.NORMAL_QOS);
+    Mockito.when(mockRegionInfo.isMetaRegion()).thenReturn(false);
+    assertTrue (qosFunction.apply(new Pair<RequestHeader, Message>(header, scanRequest))
==
+      HConstants.NORMAL_QOS);
   }
-
 }

Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/snapshot/TestFlushSnapshotFromClient.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/snapshot/TestFlushSnapshotFromClient.java?rev=1459013&r1=1459012&r2=1459013&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/snapshot/TestFlushSnapshotFromClient.java
(original)
+++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/snapshot/TestFlushSnapshotFromClient.java
Wed Mar 20 19:36:46 2013
@@ -29,6 +29,7 @@ import java.util.concurrent.CountDownLat
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.commons.logging.impl.Log4JLogger;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
@@ -39,8 +40,11 @@ import org.apache.hadoop.hbase.HTableDes
 import org.apache.hadoop.hbase.LargeTests;
 import org.apache.hadoop.hbase.exceptions.SnapshotCreationException;
 import org.apache.hadoop.hbase.exceptions.TableNotFoundException;
+import org.apache.hadoop.hbase.ipc.HBaseClient;
+import org.apache.hadoop.hbase.ipc.HBaseServer;
 import org.apache.hadoop.hbase.client.HBaseAdmin;
 import org.apache.hadoop.hbase.client.HTable;
+import org.apache.hadoop.hbase.client.ScannerCallable;
 import org.apache.hadoop.hbase.master.HMaster;
 import org.apache.hadoop.hbase.master.snapshot.SnapshotManager;
 import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription;
@@ -53,6 +57,7 @@ import org.apache.hadoop.hbase.util.FSTa
 import org.apache.hadoop.hbase.util.FSUtils;
 import org.apache.hadoop.hbase.util.HBaseFsck;
 import org.apache.hadoop.hbase.util.JVMClusterUtil.RegionServerThread;
+import org.apache.log4j.Level;
 import org.junit.After;
 import org.junit.AfterClass;
 import org.junit.Before;
@@ -83,6 +88,9 @@ public class TestFlushSnapshotFromClient
    */
   @BeforeClass
   public static void setupCluster() throws Exception {
+    ((Log4JLogger)HBaseServer.LOG).getLogger().setLevel(Level.ALL);
+    ((Log4JLogger)HBaseClient.LOG).getLogger().setLevel(Level.ALL);
+    ((Log4JLogger)ScannerCallable.LOG).getLogger().setLevel(Level.ALL);
     setupConf(UTIL.getConfiguration());
     UTIL.startMiniCluster(NUM_RS);
   }

Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftServer.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftServer.java?rev=1459013&r1=1459012&r2=1459013&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftServer.java
(original)
+++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftServer.java
Wed Mar 20 19:36:46 2013
@@ -248,6 +248,8 @@ public class TestThriftServer {
 
     Thread.sleep(1000);
     long lv = handler.get(tableAname, rowAname, columnAname, null).get(0).value.getLong();
+    // Wait on all increments being flushed
+    while (handler.coalescer.getQueueSize() != 0) Threads.sleep(10);
     assertEquals((100 + (2 * numIncrements)), lv );
 
 

Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftServerCmdLine.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftServerCmdLine.java?rev=1459013&r1=1459012&r2=1459013&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftServerCmdLine.java
(original)
+++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftServerCmdLine.java
Wed Mar 20 19:36:46 2013
@@ -35,7 +35,6 @@ import org.apache.hadoop.hbase.thrift.ge
 import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
 import org.apache.hadoop.hbase.util.EnvironmentEdgeManagerTestHelper;
 import org.apache.hadoop.hbase.util.IncrementingEnvironmentEdge;
-import org.apache.hadoop.hbase.util.Threads;
 import org.apache.thrift.protocol.TBinaryProtocol;
 import org.apache.thrift.protocol.TCompactProtocol;
 import org.apache.thrift.protocol.TProtocol;



Mime
View raw message