public ConnectionInfo normalize(ReadOnlyProps props, Properties info) throws SQLException { String zookeeperQuorum = this.getZookeeperQuorum(); Integer port = this.getPort(); String rootNode = this.getRootNode(); String keytab = this.getKeytab(); String principal = this.getPrincipal(); if (zookeeperQuorum == null) { throw new SQLExceptionInfo.Builder(SQLExceptionCode.MALFORMED_CONNECTION_URL) .setMessage(this.toString()).build().buildException(); } catch (NumberFormatException e) { throw new SQLExceptionInfo.Builder(SQLExceptionCode.MALFORMED_CONNECTION_URL) .setMessage(this.toString()).build().buildException(); .setMessage("Port may not be specified when using the connectionless url \"" + this.toString() + "\"").build().buildException(); .setMessage("Root node may not be specified when using the connectionless url \"" + this.toString() + "\"").build().buildException(); if (!isConnectionless()) { boolean credsProvidedInUrl = null != principal && null != keytab; boolean credsProvidedInProps = info.containsKey(QueryServices.HBASE_CLIENT_PRINCIPAL) && info.containsKey(QueryServices.HBASE_CLIENT_KEYTAB); if (!currentUser.hasKerberosCredentials() || !isSameName(currentUser.getUserName(), principal)) { synchronized (KERBEROS_LOGIN_LOCK) { if (!currentUser.hasKerberosCredentials() || !isSameName(currentUser.getUserName(), principal)) { final Configuration config = getConfiguration(props, info, principal, keytab); logger.info("Trying to connect to a secure cluster as {} with keytab {}", config.get(QueryServices.HBASE_CLIENT_PRINCIPAL), config.get(QueryServices.HBASE_CLIENT_KEYTAB));
for (Entry<String,String> entry : connectionInfo.asProps()) { config.set(entry.getKey(), entry.getValue()); this.userName = connectionInfo.getPrincipal(); this.user = connectionInfo.getUser(); this.latestMetaData = newEmptyMetaData();
if (url.isEmpty() || url.equalsIgnoreCase("jdbc:phoenix:") || url.equalsIgnoreCase("jdbc:phoenix")) { return defaultConnectionInfo(url); } else { if (!zkPort.equals(quorumInfo[1])) { throw getMalFormedUrlException(url); throw getMalFormedUrlException(url); tokens[nTokens - 1] = prevToken + ":" + extraToken; if (tokenizer.hasMoreTokens() && !(token=tokenizer.nextToken()).equals(TERMINATOR)) { throw getMalFormedUrlException(url); throw getMalFormedUrlException(url); port = Integer.parseInt(tokens[tokenIndex]); if (port < 0) { throw getMalFormedUrlException(url); if (isMultiPortUrl(tokens[tokenIndex])) { throw getMalFormedUrlException(url); return new ConnectionInfo(quorum,port,rootNode, principal, keytabFile);
public ConnectionInfo normalize(ReadOnlyProps props, Properties info) throws SQLException { String zookeeperQuorum = this.getZookeeperQuorum(); Integer port = this.getPort(); String rootNode = this.getRootNode(); String keytab = this.getKeytab(); String principal = this.getPrincipal(); if (zookeeperQuorum == null) { throw new SQLExceptionInfo.Builder(SQLExceptionCode.MALFORMED_CONNECTION_URL) .setMessage(this.toString()).build().buildException(); } catch (NumberFormatException e) { throw new SQLExceptionInfo.Builder(SQLExceptionCode.MALFORMED_CONNECTION_URL) .setMessage(this.toString()).build().buildException(); .setMessage("Port may not be specified when using the connectionless url \"" + this.toString() + "\"").build().buildException(); .setMessage("Root node may not be specified when using the connectionless url \"" + this.toString() + "\"").build().buildException(); if (!isConnectionless()) { boolean credsProvidedInUrl = null != principal && null != keytab; boolean credsProvidedInProps = info.containsKey(QueryServices.HBASE_CLIENT_PRINCIPAL) && info.containsKey(QueryServices.HBASE_CLIENT_KEYTAB); if (!currentUser.hasKerberosCredentials() || !isSameName(currentUser.getUserName(), principal)) { synchronized (KERBEROS_LOGIN_LOCK) { if (!currentUser.hasKerberosCredentials() || !isSameName(currentUser.getUserName(), principal)) { final Configuration config = getConfiguration(props, info, principal, keytab); logger.info("Trying to connect to a secure cluster as {} with keytab {}", config.get(QueryServices.HBASE_CLIENT_PRINCIPAL), config.get(QueryServices.HBASE_CLIENT_KEYTAB));
public ConnectionInfo normalize(ReadOnlyProps props, Properties info) throws SQLException { String zookeeperQuorum = this.getZookeeperQuorum(); Integer port = this.getPort(); String rootNode = this.getRootNode(); String keytab = this.getKeytab(); String principal = this.getPrincipal(); if (zookeeperQuorum == null) { throw new SQLExceptionInfo.Builder(SQLExceptionCode.MALFORMED_CONNECTION_URL) .setMessage(this.toString()).build().buildException(); } catch (NumberFormatException e) { throw new SQLExceptionInfo.Builder(SQLExceptionCode.MALFORMED_CONNECTION_URL) .setMessage(this.toString()).build().buildException(); .setMessage("Port may not be specified when using the connectionless url \"" + this.toString() + "\"").build().buildException(); .setMessage("Root node may not be specified when using the connectionless url \"" + this.toString() + "\"").build().buildException(); if (!isConnectionless()) { boolean credsProvidedInUrl = null != principal && null != keytab; boolean credsProvidedInProps = info.containsKey(QueryServices.HBASE_CLIENT_PRINCIPAL) && info.containsKey(QueryServices.HBASE_CLIENT_KEYTAB); if (!currentUser.hasKerberosCredentials() || !isSameName(currentUser.getUserName(), principal)) { synchronized (KERBEROS_LOGIN_LOCK) { if (!currentUser.hasKerberosCredentials() || !isSameName(currentUser.getUserName(), principal)) { final Configuration config = getConfiguration(props, info, principal, keytab); logger.info("Trying to connect to a secure cluster as {} with keytab {}", config.get(QueryServices.HBASE_CLIENT_PRINCIPAL), config.get(QueryServices.HBASE_CLIENT_KEYTAB));
if (url.isEmpty() || url.equalsIgnoreCase("jdbc:phoenix:") || url.equalsIgnoreCase("jdbc:phoenix")) { return defaultConnectionInfo(url); throw getMalFormedUrlException(url); tokens[nTokens - 1] = prevToken + ":" + extraToken; if (tokenizer.hasMoreTokens() && !(token=tokenizer.nextToken()).equals(TERMINATOR)) { throw getMalFormedUrlException(url); throw getMalFormedUrlException(url); port = Integer.parseInt(tokens[tokenIndex]); if (port < 0) { throw getMalFormedUrlException(url); if (isMultiPortUrl(tokens[tokenIndex])) { throw getMalFormedUrlException(url); return new ConnectionInfo(quorum,port,rootNode, principal, keytabFile);
for (Entry<String,String> entry : connectionInfo.asProps()) { config.set(entry.getKey(), entry.getValue()); this.userName = connectionInfo.getPrincipal(); this.user = connectionInfo.getUser(); this.latestMetaData = newEmptyMetaData();
lockInterruptibly(LockMode.READ); checkClosed(); ConnectionInfo connInfo = ConnectionInfo.create(url); SQLException sqlE = null; boolean success = false; ConnectionQueryServices connectionQueryServices = null; final ConnectionInfo normalizedConnInfo = connInfo.normalize(services.getProps(), info); try { connectionQueryServices =
for (Entry<String,String> entry : connectionInfo.asProps()) { config.set(entry.getKey(), entry.getValue()); this.userName = connectionInfo.getPrincipal(); this.user = connectionInfo.getUser(); this.latestMetaData = newEmptyMetaData();
lockInterruptibly(LockMode.READ); checkClosed(); ConnectionInfo connInfo = ConnectionInfo.create(url); SQLException sqlE = null; boolean success = false; ConnectionQueryServices connectionQueryServices = null; final ConnectionInfo normalizedConnInfo = connInfo.normalize(services.getProps(), info); try { connectionQueryServices =
@Override public PhoenixTransactionClient getTransactionClient(Configuration config, ConnectionInfo connectionInfo) { if (connectionInfo.isConnectionless()) { TransactionManager txnManager = new TransactionManager(config); TransactionSystemClient txClient = new InMemoryTxSystemClient(txnManager); zkQuorumServersString = connectionInfo.getZookeeperConnectionString();
@Override public PhoenixTransactionClient getTransactionClient(Configuration config, ConnectionInfo connectionInfo) { if (connectionInfo.isConnectionless()) { TransactionManager txnManager = new TransactionManager(config); TransactionSystemClient txClient = new InMemoryTxSystemClient(txnManager); zkQuorumServersString = connectionInfo.getZookeeperConnectionString();
public ConnectionlessQueryServicesImpl(QueryServices services, ConnectionInfo connInfo, Properties info) { super(services); userName = connInfo.getPrincipal(); user = connInfo.getUser(); metaData = newEmptyMetaData(); // Use KeyValueBuilder that builds real KeyValues, as our test utils require this this.kvBuilder = GenericKeyValueBuilder.INSTANCE; Configuration config = HBaseFactoryProvider.getConfigurationFactory().getConfiguration(); for (Entry<String,String> entry : services.getProps()) { config.set(entry.getKey(), entry.getValue()); } if (info != null) { for (Object key : info.keySet()) { config.set((String) key, info.getProperty((String) key)); } } for (Entry<String,String> entry : connInfo.asProps()) { config.set(entry.getKey(), entry.getValue()); } // Without making a copy of the configuration we cons up, we lose some of our properties // on the server side during testing. this.config = HBaseFactoryProvider.getConfigurationFactory().getConfiguration(config); this.guidePostsCache = new GuidePostsCache(this, config); // set replication required parameter ConfigUtil.setReplicationConfigIfAbsent(this.config); this.props = new ReadOnlyProps(this.config.iterator()); }
public ConnectionlessQueryServicesImpl(QueryServices services, ConnectionInfo connInfo, Properties info) { super(services); userName = connInfo.getPrincipal(); user = connInfo.getUser(); metaData = newEmptyMetaData(); // Use KeyValueBuilder that builds real KeyValues, as our test utils require this this.kvBuilder = GenericKeyValueBuilder.INSTANCE; Configuration config = HBaseFactoryProvider.getConfigurationFactory().getConfiguration(); for (Entry<String,String> entry : services.getProps()) { config.set(entry.getKey(), entry.getValue()); } if (info != null) { for (Object key : info.keySet()) { config.set((String) key, info.getProperty((String) key)); } } for (Entry<String,String> entry : connInfo.asProps()) { config.set(entry.getKey(), entry.getValue()); } // Without making a copy of the configuration we cons up, we lose some of our properties // on the server side during testing. this.config = HBaseFactoryProvider.getConfigurationFactory().getConfiguration(config); this.guidePostsCache = new GuidePostsCache(this, config); // set replication required parameter ConfigUtil.setReplicationConfigIfAbsent(this.config); this.props = new ReadOnlyProps(this.config.iterator()); }
private static ConnectionInfo defaultConnectionInfo(String url) throws SQLException { Configuration config = HBaseFactoryProvider.getConfigurationFactory().getConfiguration(); String quorum = config.get(HConstants.ZOOKEEPER_QUORUM); if (quorum == null || quorum.isEmpty()) { throw getMalFormedUrlException(url); } String clientPort = config.get(HConstants.ZOOKEEPER_CLIENT_PORT); Integer port = clientPort==null ? null : Integer.parseInt(clientPort); if (port == null || port < 0) { throw getMalFormedUrlException(url); } String znodeParent = config.get(HConstants.ZOOKEEPER_ZNODE_PARENT); LOG.debug("Getting default jdbc connection url " + quorum + ":" + port + ":" + znodeParent); return new ConnectionInfo(quorum, port, znodeParent); } }
private static ConnectionInfo defaultConnectionInfo(String url) throws SQLException { Configuration config = HBaseFactoryProvider.getConfigurationFactory().getConfiguration(); String quorum = config.get(HConstants.ZOOKEEPER_QUORUM); if (quorum == null || quorum.isEmpty()) { throw getMalFormedUrlException(url); } String clientPort = config.get(HConstants.ZOOKEEPER_CLIENT_PORT); Integer port = clientPort==null ? null : Integer.parseInt(clientPort); if (port == null || port < 0) { throw getMalFormedUrlException(url); } String znodeParent = config.get(HConstants.ZOOKEEPER_ZNODE_PARENT); LOG.debug("Getting default jdbc connection url " + quorum + ":" + port + ":" + znodeParent); return new ConnectionInfo(quorum, port, znodeParent); } }
static boolean isSameName(String currentName, String newName, String hostname) throws IOException { return isSameName(currentName, newName, hostname, getDefaultKerberosRealm()); }