title: Spark HBase Connection Timeout / Hang
body: <p>I'm trying to test reads and writes to hbase on my local machine. </p>
  
  <p>I'm using the cloudera quick start docker image to host hbase / hadoop / zookeeper etc. </p>
  
  <p>I have the following code: </p>
  
  <pre><code>        val conf = new SparkConf().setAppName("Database Benchmark")
  
          val sparkContext = new SparkContext(conf)
          val tableName = "testTable"
          val HBaseConf = HBaseConfiguration.create()
          // Add local HBase conf
          HBaseConf.set("hbase.master", "localhost")
          HBaseConf.set("hbase.zookeeper.quorum","localhost")
          HBaseConf.set("hbase.zookeeper.property.clientPort", "2181")
          HBaseConf.set(TableInputFormat.INPUT_TABLE, tableName)
  
          val connection = ConnectionFactory.createConnection(HBaseConf)
          val table = connection.getTable(TableName.valueOf(tableName))
  
          val rdd = sparkContext.parallelize(1 to 100)
            .map(i =&gt; (i.toString, i+1))
  
          try {
              read(table)
  
              write(rdd)
          } catch {
              case e : Exception =&gt;  println("uh oh") // uh oh.
          } finally {
              table.close
              connection.close
          }
  
  
      }
  
      def write(toWrite :  RDD[(String, Int)]): Put = {
          val putter = new Put(Bytes.toBytes("Row2"))
          putter.addColumn(Bytes.toBytes("test"),
              Bytes.toBytes("column1"), Bytes.toBytes(toWrite.toString()))
      }
  
      def read(table : Table) = {
          val row = table.get(new Get(Bytes.toBytes("newRow")))
          println(row.toString)
      }
  </code></pre>
  
  <p>Currently my code doesn't really do much, I'm just trying to get a read and write to work, but when I attempt to connect to the container I get the following hang-up message indefinitely: </p>
  
  <pre><code>Using Spark's default log4j profile: org/apache/spark/log4j-defaults.properties
  16/10/25 14:56:00 INFO SparkContext: Running Spark version 2.0.1
  16/10/25 14:56:01 WARN NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
  16/10/25 14:56:01 INFO SecurityManager: Changing view acls to: {user}
  16/10/25 14:56:01 INFO SecurityManager: Changing modify acls to: {user}
  16/10/25 14:56:01 INFO SecurityManager: Changing view acls groups to: 
  16/10/25 14:56:01 INFO SecurityManager: Changing modify acls groups to: 
  16/10/25 14:56:01 INFO SecurityManager: SecurityManager: authentication disabled; ui acls disabled; users  with view permissions: Set({user}); groups with view permissions: Set(); users  with modify permissions: Set({user}); groups with modify permissions: Set()
  16/10/25 14:56:02 INFO Utils: Successfully started service 'sparkDriver' on port 57682.
  16/10/25 14:56:02 INFO SparkEnv: Registering MapOutputTracker
  16/10/25 14:56:02 INFO SparkEnv: Registering BlockManagerMaster
  16/10/25 14:56:02 INFO DiskBlockManager: Created local directory at /private/var/folders/b5/6bhlwry949n3mpwppt4m5_1jcmsf2g/T/blockmgr-d4aaf6d1-ca0d-4c9b-9e08-9b7716e89791
  16/10/25 14:56:02 INFO MemoryStore: MemoryStore started with capacity 2004.6 MB
  16/10/25 14:56:02 INFO SparkEnv: Registering OutputCommitCoordinator
  16/10/25 14:56:02 INFO Utils: Successfully started service 'SparkUI' on port 4040.
  16/10/25 14:56:02 INFO SparkUI: Bound SparkUI to 127.0.0.1, and started at http://127.0.0.1:4040
  16/10/25 14:56:02 INFO Executor: Starting executor ID driver on host localhost
  16/10/25 14:56:02 INFO Utils: Successfully started service 'org.apache.spark.network.netty.NettyBlockTransferService' on port 57683.
  16/10/25 14:56:02 INFO NettyBlockTransferService: Server created on 127.0.0.1:57683
  16/10/25 14:56:02 INFO BlockManagerMaster: Registering BlockManager BlockManagerId(driver, 127.0.0.1, 57683)
  16/10/25 14:56:02 INFO BlockManagerMasterEndpoint: Registering block manager 127.0.0.1:57683 with 2004.6 MB RAM, BlockManagerId(driver, 127.0.0.1, 57683)
  16/10/25 14:56:02 INFO BlockManagerMaster: Registered BlockManager BlockManagerId(driver, 127.0.0.1, 57683)
  16/10/25 14:56:02 INFO RecoverableZooKeeper: Process identifier=hconnection-0x5bd73d1a connecting to ZooKeeper ensemble=localhost:2181
  16/10/25 14:56:02 INFO ZooKeeper: Client environment:zookeeper.version=3.4.6-1569965, built on 02/20/2014 09:09 GMT
  16/10/25 14:56:02 INFO ZooKeeper: Client environment:host.name=10.171.46.220
  16/10/25 14:56:02 INFO ZooKeeper: Client environment:java.version=1.8.0_101
  16/10/25 14:56:02 INFO ZooKeeper: Client environment:java.vendor=Oracle Corporation
  16/10/25 14:56:02 INFO ZooKeeper: Client environment:java.library.path=/Users/{user}/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.
  16/10/25 14:56:02 INFO ZooKeeper: Client environment:java.io.tmpdir=/var/folders/b5/6bhlwry949n3mpwppt4m5_1jcmsf2g/T/
  16/10/25 14:56:02 INFO ZooKeeper: Client environment:java.compiler=&lt;NA&gt;
  16/10/25 14:56:02 INFO ZooKeeper: Client environment:os.name=Mac OS X
  16/10/25 14:56:02 INFO ZooKeeper: Client environment:os.arch=x86_64
  16/10/25 14:56:02 INFO ZooKeeper: Client environment:os.version=10.11.6
  16/10/25 14:56:02 INFO ZooKeeper: Client environment:user.name={user}
  16/10/25 14:56:02 INFO ZooKeeper: Client environment:user.home=/Users/{user}
  16/10/25 14:56:02 INFO ZooKeeper: Client environment:user.dir=/Users/{user}/code/scala/HBaseTest
  16/10/25 14:56:02 INFO ZooKeeper: Initiating client connection, connectString=localhost:2181 sessionTimeout=90000 watcher=hconnection-0x5bd73d1a0x0, quorum=localhost:2181, baseZNode=/hbase
  16/10/25 14:56:02 INFO ClientCnxn: Opening socket connection to server localhost/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)
  16/10/25 14:56:02 INFO ClientCnxn: Socket connection established to localhost/127.0.0.1:2181, initiating session
  16/10/25 14:56:02 INFO ClientCnxn: Session establishment complete on server localhost/127.0.0.1:2181, sessionid = 0x157fc012352000e, negotiated timeout = 40000
  16/10/25 14:56:41 INFO RpcRetryingCaller: Call exception, tries=10, retries=35, started=38307 ms ago, cancelled=false, msg=row 'testTable,newRow,99999999999999' on table 'hbase:meta' at region=hbase:meta,,1.1588230740, hostname=quickstart.cloudera,60020,1477401812367, seqNum=0
  16/10/25 14:56:51 INFO RpcRetryingCaller: Call exception, tries=11, retries=35, started=48337 ms ago, cancelled=false, msg=row 'testTable,newRow,99999999999999' on table 'hbase:meta' at region=hbase:meta,,1.1588230740, hostname=quickstart.cloudera,60020,1477401812367, seqNum=0
  ...
  16/10/25 15:00:56 INFO RpcRetryingCaller: Call exception, tries=11, retries=35, started=48468 ms ago, cancelled=false, msg=row 'testTable,newRow,99999999999999' on table 'hbase:meta' at region=hbase:meta,,1.1588230740, hostname=quickstart.cloudera,60020,1477401812367, seqNum=0
  16/10/25 15:01:08 INFO SparkContext: Invoking stop() from shutdown hook
  16/10/25 15:01:08 INFO SparkUI: Stopped Spark web UI at http://127.0.0.1:4040
  16/10/25 15:01:08 INFO MapOutputTrackerMasterEndpoint: MapOutputTrackerMasterEndpoint stopped!
  16/10/25 15:01:08 INFO MemoryStore: MemoryStore cleared
  16/10/25 15:01:08 INFO BlockManager: BlockManager stopped
  16/10/25 15:01:08 INFO BlockManagerMaster: BlockManagerMaster stopped
  16/10/25 15:01:08 INFO OutputCommitCoordinator$OutputCommitCoordinatorEndpoint: OutputCommitCoordinator stopped!
  16/10/25 15:01:08 INFO SparkContext: Successfully stopped SparkContext
  16/10/25 15:01:08 INFO ShutdownHookManager: Shutdown hook called
  16/10/25 15:01:08 INFO ShutdownHookManager: Deleting directory /private/var/folders/b5/6bhlwry949n3mpwppt4m5_1jcmsf2g/T/spark-cc1a87f4-ae09-489e-8957-c2c8a3788e9b
  
  
  Process finished with exit code 130 (interrupted by signal 2: SIGINT)
  </code></pre>
  
  <p>I don't believe it's the docker container's ports because I forward the required ports with the following: </p>
  
  <pre><code>docker run --hostname=quickstart.cloudera --privileged=true -t -i -p 8888:8888 -p 7180:7180 -p 8000:80 -p 50070:50070 -p 8020:8020 -p 7077 -p 60000:60000 -p 60020:60020 -p 2181:2181  cloudera/quickstart /usr/bin/docker-quickstart
  </code></pre>
  
  <p>The hbase-site.xml is as follows: </p>
  
  <pre><code>&lt;configuration&gt;
    &lt;property&gt;
      &lt;name&gt;hbase.rest.port&lt;/name&gt;
      &lt;value&gt;8070&lt;/value&gt;
      &lt;description&gt;The port for the HBase REST server.&lt;/description&gt;
    &lt;/property&gt;
  
    &lt;property&gt;
      &lt;name&gt;hbase.cluster.distributed&lt;/name&gt;
      &lt;value&gt;true&lt;/value&gt;
    &lt;/property&gt;
  
    &lt;property&gt;
      &lt;name&gt;hbase.rootdir&lt;/name&gt;
      &lt;value&gt;hdfs://quickstart.cloudera:8020/hbase&lt;/value&gt;
    &lt;/property&gt;
  
    &lt;property&gt;
      &lt;name&gt;hbase.regionserver.ipc.address&lt;/name&gt;
      &lt;value&gt;0.0.0.0&lt;/value&gt;
    &lt;/property&gt;
  
    &lt;property&gt;
      &lt;name&gt;hbase.master.ipc.address&lt;/name&gt;
      &lt;value&gt;0.0.0.0&lt;/value&gt;
    &lt;/property&gt;
  
    &lt;property&gt;
      &lt;name&gt;hbase.thrift.info.bindAddress&lt;/name&gt;
      &lt;value&gt;0.0.0.0&lt;/value&gt;
    &lt;/property&gt;
  
  &lt;/configuration&gt;
  </code></pre>
  
  <p>Any idea what the issue could possibly be? </p>