Github user srowen commented on a diff in the pull request:

    https://github.com/apache/spark/pull/1608#discussion_r15438461
  
    --- Diff: 
external/hbase/src/main/scala/org/apache/spark/hbase/HConnectionStaticCache.scala
 ---
    @@ -0,0 +1,141 @@
    +/*
    + * 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.spark.hbase
    +
    +import java.util.HashMap
    +import org.apache.hadoop.hbase.client.HConnection
    +import java.util.concurrent.atomic.AtomicInteger
    +import java.util.concurrent.atomic.AtomicLong
    +import java.util.Timer
    +import org.apache.hadoop.conf.Configuration
    +import org.apache.hadoop.hbase.HConstants
    +import org.apache.hadoop.hbase.client.HConnectionManager
    +import java.util.TimerTask
    +import scala.collection.mutable.MutableList
    +import org.apache.spark.Logging
    +
    +/**
    + * A static caching class that will manage all HConnection in a worker
    + * 
    + * The main idea is there is a hashMap with 
    + * HConstants.HBASE_CLIENT_INSTANCE_ID which is 
("hbase.client.instance.id")
    + * 
    + * In that HashMap there is three things
    + *   - HConnection
    + *   - Number of checked out users of the HConnection
    + *   - Time since the HConnection was last used
    + *   
    + * There is also a Timer thread that will start up every 2 minutes
    + * When the Timer thread starts up it will look for HConnection with no
    + * checked out users and a last used time that is older then 1 minute.
    + * 
    + * This class is not intended to be used by Users
    + */
    +object HConnectionStaticCache extends Logging{
    +  @transient private val hconnectionMap = 
    +    new HashMap[String, (HConnection, AtomicInteger, AtomicLong)]
    --- End diff --
    
    This is using a lot of the Java collection API instead of Scala API. I 
think the latter would be more standard. In fact, it would help in a number of 
cases, like the one in the next comment.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to