phoenix5-hive/src/main/java/org/apache/phoenix/hive/util/PhoenixConnectionUtil.java [40:117]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
public class PhoenixConnectionUtil {

    private static final Logger LOG = LoggerFactory.getLogger(PhoenixConnectionUtil.class);

    public static Connection getInputConnection(final Configuration conf, final Properties props)
            throws SQLException {
        String quorum = conf.get(PhoenixStorageHandlerConstants.ZOOKEEPER_QUORUM);
        quorum = quorum == null ? props.getProperty(PhoenixStorageHandlerConstants
                .ZOOKEEPER_QUORUM, PhoenixStorageHandlerConstants.DEFAULT_ZOOKEEPER_QUORUM) :
                quorum;

        int zooKeeperClientPort = conf.getInt(PhoenixStorageHandlerConstants.ZOOKEEPER_PORT, 0);
        zooKeeperClientPort = zooKeeperClientPort == 0 ?
                Integer.parseInt(props.getProperty(PhoenixStorageHandlerConstants.ZOOKEEPER_PORT,
                        String.valueOf(PhoenixStorageHandlerConstants.DEFAULT_ZOOKEEPER_PORT))) :
                zooKeeperClientPort;

        String zNodeParent = conf.get(PhoenixStorageHandlerConstants.ZOOKEEPER_PARENT);
        zNodeParent = zNodeParent == null ? props.getProperty(PhoenixStorageHandlerConstants
                .ZOOKEEPER_PARENT, PhoenixStorageHandlerConstants.DEFAULT_ZOOKEEPER_PARENT) :
                zNodeParent;

        return getConnection(quorum, zooKeeperClientPort, zNodeParent, PropertiesUtil
                .combineProperties(props, conf));
    }

    public static Connection getConnection(final Table table) throws SQLException {
        Map<String, String> tableParameterMap = table.getParameters();

        String zookeeperQuorum = tableParameterMap.get(PhoenixStorageHandlerConstants
                .ZOOKEEPER_QUORUM);
        zookeeperQuorum = zookeeperQuorum == null ? PhoenixStorageHandlerConstants
                .DEFAULT_ZOOKEEPER_QUORUM : zookeeperQuorum;

        String clientPortString = tableParameterMap.get(PhoenixStorageHandlerConstants
                .ZOOKEEPER_PORT);
        int clientPort = clientPortString == null ? PhoenixStorageHandlerConstants
                .DEFAULT_ZOOKEEPER_PORT : Integer.parseInt(clientPortString);

        String zNodeParent = tableParameterMap.get(PhoenixStorageHandlerConstants.ZOOKEEPER_PARENT);
        zNodeParent = zNodeParent == null ? PhoenixStorageHandlerConstants
                .DEFAULT_ZOOKEEPER_PARENT : zNodeParent;
        try {
            Class.forName("org.apache.phoenix.jdbc.PhoenixDriver");
        } catch (ClassNotFoundException e) {
            LOG.warn("Coould not load driver",e);
        }
        return DriverManager.getConnection(QueryUtil.getUrl(zookeeperQuorum, clientPort,
                zNodeParent));
    }

    private static Connection getConnection(final String quorum, final Integer clientPort, String
            zNodeParent, Properties props) throws SQLException {
        if (LOG.isDebugEnabled()) {
            LOG.debug("Connection attrs [quorum, port, znode] : " + quorum + ", " + clientPort +
                    ", " +
                    zNodeParent);
        }

        return DriverManager.getConnection(clientPort != null ? QueryUtil.getUrl(quorum,
                clientPort, zNodeParent) : QueryUtil.getUrl(quorum), props);
    }

    public static Configuration getConfiguration(JobConf jobConf) {
        Configuration conf = new Configuration(jobConf);
        String quorum = conf.get(PhoenixStorageHandlerConstants.ZOOKEEPER_QUORUM);
        if(quorum!=null) {
            conf.set(HConstants.ZOOKEEPER_QUORUM, quorum);
        }
        int zooKeeperClientPort = conf.getInt(PhoenixStorageHandlerConstants.ZOOKEEPER_PORT, 0);
        if(zooKeeperClientPort != 0) {
            conf.setInt(HConstants.ZOOKEEPER_CLIENT_PORT, zooKeeperClientPort);
        }
        String zNodeParent = conf.get(PhoenixStorageHandlerConstants.ZOOKEEPER_PARENT);
        if(zNodeParent != null) {
            conf.set(HConstants.ZOOKEEPER_ZNODE_PARENT, zNodeParent);
        }
        return conf;
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



phoenix5-hive4/src/main/java/org/apache/phoenix/hive/util/PhoenixConnectionUtil.java [40:117]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
public class PhoenixConnectionUtil {

    private static final Logger LOG = LoggerFactory.getLogger(PhoenixConnectionUtil.class);

    public static Connection getInputConnection(final Configuration conf, final Properties props)
            throws SQLException {
        String quorum = conf.get(PhoenixStorageHandlerConstants.ZOOKEEPER_QUORUM);
        quorum = quorum == null ? props.getProperty(PhoenixStorageHandlerConstants
                .ZOOKEEPER_QUORUM, PhoenixStorageHandlerConstants.DEFAULT_ZOOKEEPER_QUORUM) :
                quorum;

        int zooKeeperClientPort = conf.getInt(PhoenixStorageHandlerConstants.ZOOKEEPER_PORT, 0);
        zooKeeperClientPort = zooKeeperClientPort == 0 ?
                Integer.parseInt(props.getProperty(PhoenixStorageHandlerConstants.ZOOKEEPER_PORT,
                        String.valueOf(PhoenixStorageHandlerConstants.DEFAULT_ZOOKEEPER_PORT))) :
                zooKeeperClientPort;

        String zNodeParent = conf.get(PhoenixStorageHandlerConstants.ZOOKEEPER_PARENT);
        zNodeParent = zNodeParent == null ? props.getProperty(PhoenixStorageHandlerConstants
                .ZOOKEEPER_PARENT, PhoenixStorageHandlerConstants.DEFAULT_ZOOKEEPER_PARENT) :
                zNodeParent;

        return getConnection(quorum, zooKeeperClientPort, zNodeParent, PropertiesUtil
                .combineProperties(props, conf));
    }

    public static Connection getConnection(final Table table) throws SQLException {
        Map<String, String> tableParameterMap = table.getParameters();

        String zookeeperQuorum = tableParameterMap.get(PhoenixStorageHandlerConstants
                .ZOOKEEPER_QUORUM);
        zookeeperQuorum = zookeeperQuorum == null ? PhoenixStorageHandlerConstants
                .DEFAULT_ZOOKEEPER_QUORUM : zookeeperQuorum;

        String clientPortString = tableParameterMap.get(PhoenixStorageHandlerConstants
                .ZOOKEEPER_PORT);
        int clientPort = clientPortString == null ? PhoenixStorageHandlerConstants
                .DEFAULT_ZOOKEEPER_PORT : Integer.parseInt(clientPortString);

        String zNodeParent = tableParameterMap.get(PhoenixStorageHandlerConstants.ZOOKEEPER_PARENT);
        zNodeParent = zNodeParent == null ? PhoenixStorageHandlerConstants
                .DEFAULT_ZOOKEEPER_PARENT : zNodeParent;
        try {
            Class.forName("org.apache.phoenix.jdbc.PhoenixDriver");
        } catch (ClassNotFoundException e) {
            LOG.warn("Coould not load driver",e);
        }
        return DriverManager.getConnection(QueryUtil.getUrl(zookeeperQuorum, clientPort,
                zNodeParent));
    }

    private static Connection getConnection(final String quorum, final Integer clientPort, String
            zNodeParent, Properties props) throws SQLException {
        if (LOG.isDebugEnabled()) {
            LOG.debug("Connection attrs [quorum, port, znode] : " + quorum + ", " + clientPort +
                    ", " +
                    zNodeParent);
        }

        return DriverManager.getConnection(clientPort != null ? QueryUtil.getUrl(quorum,
                clientPort, zNodeParent) : QueryUtil.getUrl(quorum), props);
    }

    public static Configuration getConfiguration(JobConf jobConf) {
        Configuration conf = new Configuration(jobConf);
        String quorum = conf.get(PhoenixStorageHandlerConstants.ZOOKEEPER_QUORUM);
        if(quorum!=null) {
            conf.set(HConstants.ZOOKEEPER_QUORUM, quorum);
        }
        int zooKeeperClientPort = conf.getInt(PhoenixStorageHandlerConstants.ZOOKEEPER_PORT, 0);
        if(zooKeeperClientPort != 0) {
            conf.setInt(HConstants.ZOOKEEPER_CLIENT_PORT, zooKeeperClientPort);
        }
        String zNodeParent = conf.get(PhoenixStorageHandlerConstants.ZOOKEEPER_PARENT);
        if(zNodeParent != null) {
            conf.set(HConstants.ZOOKEEPER_ZNODE_PARENT, zNodeParent);
        }
        return conf;
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



