You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@phoenix.apache.org by "meszinorbi (via GitHub)" <gi...@apache.org> on 2025/04/10 07:41:03 UTC
[PR] PHOENIX-7186 Support Square Brackets Notation for IPv6 in JDBC URL [phoenix]
meszinorbi opened a new pull request, #2107:
URL: https://github.com/apache/phoenix/pull/2107
ZK supports using square brackets around the IP address to resolve the colon ambiguity.
Added support for the square bracket notation.
(We still need to escape the colon separating the port from the address.)
i.e. accept:
"phoenix+zk:[fe:80::01]\:2181::/hbase"
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@phoenix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] PHOENIX-7186 Support Square Brackets Notation for IPv6 in JDBC URL [phoenix]
Posted by "stoty (via GitHub)" <gi...@apache.org>.
stoty commented on code in PR #2107:
URL: https://github.com/apache/phoenix/pull/2107#discussion_r2037070885
##########
phoenix-core-client/src/main/java/org/apache/phoenix/jdbc/ConnectionInfo.java:
##########
@@ -119,6 +125,20 @@ protected static String unescape(String escaped) {
return escaped.replaceAll("\\\\:", "=");
}
+ protected static String escapeIPv6Literal(String unescaped){
+ String regex = "(\\[.*?\\])";
+ Pattern pattern = Pattern.compile(regex);
+ Matcher matcher = pattern.matcher(unescaped);
+ StringBuffer result = new StringBuffer();
+ while (matcher.find()) {
+ String matchedText = matcher.group(1);
+ String modifiedText = matchedText.replace(":", "\\\\:");
Review Comment:
won't this double escape already escaped colons in the address ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@phoenix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] PHOENIX-7186 Support Square Brackets Notation for IPv6 in JDBC URL [phoenix]
Posted by "meszinorbi (via GitHub)" <gi...@apache.org>.
meszinorbi commented on PR #2107:
URL: https://github.com/apache/phoenix/pull/2107#issuecomment-2796198118
Found a problem with the new solution. The tilde did not get converted back to a colon. Working on it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@phoenix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] PHOENIX-7186 Support Square Brackets Notation for IPv6 in JDBC URL [phoenix]
Posted by "stoty (via GitHub)" <gi...@apache.org>.
stoty commented on code in PR #2107:
URL: https://github.com/apache/phoenix/pull/2107#discussion_r2037069404
##########
phoenix-core-client/src/main/java/org/apache/phoenix/jdbc/ConnectionInfo.java:
##########
@@ -525,6 +546,11 @@ protected String normalizeHostsList(String quorum, Integer defaultPort)
normalizedParts[i] = hostAndPort[0].trim().toLowerCase() + ":" + defaultPort;
} else if (hostAndPort.length == 2) {
normalizedParts[i] = quorumParts[i].trim().toLowerCase();
+ } else if (hostAndPort.length > 2 && hostAndPort[hostAndPort.length - 1].contains("]")) {
Review Comment:
This is a bit iffy.
Maybe we should just something else instead of '=' to replace the colons in the ipv6 address ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@phoenix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] PHOENIX-7186 Support Square Brackets Notation for IPv6 in JDBC URL [phoenix]
Posted by "stoty (via GitHub)" <gi...@apache.org>.
stoty commented on code in PR #2107:
URL: https://github.com/apache/phoenix/pull/2107#discussion_r2037070885
##########
phoenix-core-client/src/main/java/org/apache/phoenix/jdbc/ConnectionInfo.java:
##########
@@ -119,6 +125,20 @@ protected static String unescape(String escaped) {
return escaped.replaceAll("\\\\:", "=");
}
+ protected static String escapeIPv6Literal(String unescaped){
+ String regex = "(\\[.*?\\])";
+ Pattern pattern = Pattern.compile(regex);
+ Matcher matcher = pattern.matcher(unescaped);
+ StringBuffer result = new StringBuffer();
+ while (matcher.find()) {
+ String matchedText = matcher.group(1);
+ String modifiedText = matchedText.replace(":", "\\\\:");
Review Comment:
won't this double escape already escaped colons in the address ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@phoenix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] PHOENIX-7186 Support Square Brackets Notation for IPv6 in JDBC URL [phoenix]
Posted by "stoty (via GitHub)" <gi...@apache.org>.
stoty commented on code in PR #2107:
URL: https://github.com/apache/phoenix/pull/2107#discussion_r2037064180
##########
phoenix-core-client/src/main/java/org/apache/phoenix/jdbc/ConnectionInfo.java:
##########
@@ -119,6 +125,20 @@ protected static String unescape(String escaped) {
return escaped.replaceAll("\\\\:", "=");
}
+ protected static String escapeIPv6Literal(String unescaped){
+ String regex = "(\\[.*?\\])";
+ Pattern pattern = Pattern.compile(regex);
+ Matcher matcher = pattern.matcher(unescaped);
+ StringBuffer result = new StringBuffer();
+ while (matcher.find()) {
+ String matchedText = matcher.group(1);
+ String modifiedText = matchedText.replace(":", "\\\\:");
+ matcher.appendReplacement(result, modifiedText);
Review Comment:
I didn't know this construct.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@phoenix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] PHOENIX-7186 Support Square Brackets Notation for IPv6 in JDBC URL [phoenix]
Posted by "stoty (via GitHub)" <gi...@apache.org>.
stoty commented on code in PR #2107:
URL: https://github.com/apache/phoenix/pull/2107#discussion_r2037065319
##########
phoenix-core-client/src/main/java/org/apache/phoenix/jdbc/ConnectionInfo.java:
##########
@@ -119,6 +125,20 @@ protected static String unescape(String escaped) {
return escaped.replaceAll("\\\\:", "=");
}
+ protected static String escapeIPv6Literal(String unescaped){
Review Comment:
nit : I'd prefer escapeIPv6Literals as we can have more than one.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@phoenix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] PHOENIX-7186 Support Square Brackets Notation for IPv6 in JDBC URL [phoenix]
Posted by "stoty (via GitHub)" <gi...@apache.org>.
stoty commented on code in PR #2107:
URL: https://github.com/apache/phoenix/pull/2107#discussion_r2041522140
##########
phoenix-core/src/test/java/org/apache/phoenix/jdbc/PhoenixEmbeddedDriverTest.java:
##########
@@ -569,6 +569,106 @@ public void testPrincipalsMatching() throws Exception {
assertFalse(ConnectionInfo.isSameName("user/foobar@APACHE.NET", "user/_HOST", "foobar", "APACHE.ORG"));
}
+ @Test
+ public void testMasterIPv6() throws SQLException {
+ assumeTrue(VersionInfo.compareVersion(VersionInfo.getVersion(), "2.3.0") >= 0);
+ try {
+ Configuration config =
+ HBaseFactoryProvider.getConfigurationFactory().getConfiguration();
+ config.set("hbase.client.registry.impl",
+ "org.apache.hadoop.hbase.client.MasterRegistry");
+ ConnectionInfo.create("jdbc:phoenix+master", config, null, null);
+ fail("Should have thrown exception");
+ } catch (SQLException e) {
+ }
+
+ Configuration config = HBaseFactoryProvider.getConfigurationFactory().getConfiguration();
+ config.set("hbase.client.registry.impl", "org.apache.hadoop.hbase.client.MasterRegistry");
+ config.set("hbase.master.port", "17000");
+ MasterConnectionInfo info =
+ (MasterConnectionInfo) ConnectionInfo.create(
+ "jdbc:phoenix+master:[::1],[\\:\\:2]", config, null, null);
+ assertEquals(info.getBoostrapServers(), "[::1]:17000,[::2]:17000");
+
+ config = HBaseFactoryProvider.getConfigurationFactory().getConfiguration();
+ config.set("hbase.client.registry.impl", "org.apache.hadoop.hbase.client.MasterRegistry");
+ info =
+ (MasterConnectionInfo) ConnectionInfo.create(
+ "jdbc:phoenix+master:[::1]\\:123,[\\:\\:2]\\:234", config, null, null);
+ assertEquals(info.getBoostrapServers(), "[::1]:123,[::2]:234");
+ }
+
+ @Test
+ public void testRPCIPv6() throws SQLException{
+ Configuration config = HBaseFactoryProvider.getConfigurationFactory().getConfiguration();
+ config.set("hbase.client.registry.impl",
+ "org.apache.hadoop.hbase.client.RpcConnectionRegistry");
+ RPCConnectionInfo info =
+ (RPCConnectionInfo) ConnectionInfo.create(
+ "jdbc:phoenix+rpc:[::1]\\:123,[\\:\\:2]\\::234", config,
+ null, null);
+ assertEquals("[::1]:123,[::2]:234", info.getBoostrapServers());
+ }
+
+ @Test
+ public void testZkIPv6() throws Exception {
+ ConnectionInfo connectionInfo = ConnectionInfo.create("jdbc:phoenix+zk:"
+ + "[::1],127.23.45.678\\:7634,v3\\:1,host123.48576\\:723:/hbase;"
+ + "test=true", null, null);
+ ReadOnlyProps props = connectionInfo.asProps();
+ assertEquals("127.23.45.678:7634,[::1]:2181,host123.48576:723,v3:1",
+ props.get(HConstants.ZOOKEEPER_QUORUM));
+
+ connectionInfo = ConnectionInfo.create("jdbc:phoenix+zk:"
+ + "[::1]\\:2181,127.23.45.678\\:7634,v3\\:1,host123.48576\\:723:/hbase;"
+ + "test=true", null, null);
+ props = connectionInfo.asProps();
+ assertEquals("127.23.45.678:7634,[::1]:2181,host123.48576:723,v3:1",
+
+ props.get(HConstants.ZOOKEEPER_QUORUM));
+ connectionInfo = ConnectionInfo.create("jdbc:phoenix+zk:"
+ + "[fe:80::],127.23.45.678\\:7634,v3\\:1,host123.48576\\:723:/hbase;"
+ + "test=true", null, null);
+ props = connectionInfo.asProps();
+ assertEquals("127.23.45.678:7634,[fe:80::]:2181,host123.48576:723,v3:1",
+ props.get(HConstants.ZOOKEEPER_QUORUM));
+
+ connectionInfo = ConnectionInfo.create("jdbc:phoenix+zk:"
+ + "[fe:80::]\\:2181,127.23.45.678\\:7634,v3\\:1,host123.48576\\:723:/hbase;"
+ + "test=true", null, null);
+ props = connectionInfo.asProps();
+ assertEquals("127.23.45.678:7634,[fe:80::]:2181,host123.48576:723,v3:1",
+ props.get(HConstants.ZOOKEEPER_QUORUM));
+
+ connectionInfo = ConnectionInfo.create("jdbc:phoenix+zk:"
+ + "[fe\\:80\\:\\:],127.23.45.678\\:7634,v3\\:1,host123.48576\\:723:/hbase;"
+ + "test=true", null, null);
+ props = connectionInfo.asProps();
+ assertEquals("127.23.45.678:7634,[fe:80::]:2181,host123.48576:723,v3:1",
+ props.get(HConstants.ZOOKEEPER_QUORUM));
+
+ connectionInfo = ConnectionInfo.create("jdbc:phoenix+zk:"
+ + "[fe\\:80\\:\\:]\\:2181,127.23.45.678\\:7634,v3\\:1,host123.48576\\:723:/hbase;"
+ + "test=true", null, null);
+ props = connectionInfo.asProps();
+ assertEquals("127.23.45.678:7634,[fe:80::]:2181,host123.48576:723,v3:1",
+ props.get(HConstants.ZOOKEEPER_QUORUM));
+
+ connectionInfo = ConnectionInfo.create("jdbc:phoenix+zk:"
+ + "[fe:80::2]\\:2181,[2001:db8:3c4d:15::1a2f:1a2b]\\:7634,v3\\:1,host123.48576\\:723:/hbase;"
+ + "test=true", null, null);
+ props = connectionInfo.asProps();
+ assertEquals("[2001:db8:3c4d:15::1a2f:1a2b]:7634,[fe:80::2]:2181,host123.48576:723,v3:1",
+ props.get(HConstants.ZOOKEEPER_QUORUM));
+
+ connectionInfo = ConnectionInfo.create("jdbc:phoenix+zk:"
+ + "[fe:80::2]\\:2181,[2001\\:db8\\:3c4d\\:15\\:\\:1a2f\\:1a2b]\\:7634,v3\\:1,host123.48576\\:723:/hbase;"
+ + "test=true", null, null);
+ props = connectionInfo.asProps();
+ assertEquals("[2001:db8:3c4d:15::1a2f:1a2b]:7634,[fe:80::2]:2181,host123.48576:723,v3:1",
+ props.get(HConstants.ZOOKEEPER_QUORUM));
+ }
Review Comment:
Please add a test with multiple IPv6 addressess for ZK as well.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@phoenix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] PHOENIX-7186 Support Square Brackets Notation for IPv6 in JDBC URL [phoenix]
Posted by "stoty (via GitHub)" <gi...@apache.org>.
stoty merged PR #2107:
URL: https://github.com/apache/phoenix/pull/2107
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@phoenix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] PHOENIX-7186 Support Square Brackets Notation for IPv6 in JDBC URL [phoenix]
Posted by "stoty (via GitHub)" <gi...@apache.org>.
stoty commented on PR #2107:
URL: https://github.com/apache/phoenix/pull/2107#issuecomment-2804294446
I have merged this to master and 5.2, but it does not apply cleanly to 5.1. , and some of the tests fail after fixing compilation problems.
Please do a backport PR for 5.1, @meszinorbi .
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@phoenix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] PHOENIX-7186 Support Square Brackets Notation for IPv6 in JDBC URL [phoenix]
Posted by "meszinorbi (via GitHub)" <gi...@apache.org>.
meszinorbi commented on PR #2107:
URL: https://github.com/apache/phoenix/pull/2107#issuecomment-2796257965
Now it works
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@phoenix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] PHOENIX-7186 Support Square Brackets Notation for IPv6 in JDBC URL [phoenix]
Posted by "stoty (via GitHub)" <gi...@apache.org>.
stoty commented on code in PR #2107:
URL: https://github.com/apache/phoenix/pull/2107#discussion_r2041522140
##########
phoenix-core/src/test/java/org/apache/phoenix/jdbc/PhoenixEmbeddedDriverTest.java:
##########
@@ -569,6 +569,106 @@ public void testPrincipalsMatching() throws Exception {
assertFalse(ConnectionInfo.isSameName("user/foobar@APACHE.NET", "user/_HOST", "foobar", "APACHE.ORG"));
}
+ @Test
+ public void testMasterIPv6() throws SQLException {
+ assumeTrue(VersionInfo.compareVersion(VersionInfo.getVersion(), "2.3.0") >= 0);
+ try {
+ Configuration config =
+ HBaseFactoryProvider.getConfigurationFactory().getConfiguration();
+ config.set("hbase.client.registry.impl",
+ "org.apache.hadoop.hbase.client.MasterRegistry");
+ ConnectionInfo.create("jdbc:phoenix+master", config, null, null);
+ fail("Should have thrown exception");
+ } catch (SQLException e) {
+ }
+
+ Configuration config = HBaseFactoryProvider.getConfigurationFactory().getConfiguration();
+ config.set("hbase.client.registry.impl", "org.apache.hadoop.hbase.client.MasterRegistry");
+ config.set("hbase.master.port", "17000");
+ MasterConnectionInfo info =
+ (MasterConnectionInfo) ConnectionInfo.create(
+ "jdbc:phoenix+master:[::1],[\\:\\:2]", config, null, null);
+ assertEquals(info.getBoostrapServers(), "[::1]:17000,[::2]:17000");
+
+ config = HBaseFactoryProvider.getConfigurationFactory().getConfiguration();
+ config.set("hbase.client.registry.impl", "org.apache.hadoop.hbase.client.MasterRegistry");
+ info =
+ (MasterConnectionInfo) ConnectionInfo.create(
+ "jdbc:phoenix+master:[::1]\\:123,[\\:\\:2]\\:234", config, null, null);
+ assertEquals(info.getBoostrapServers(), "[::1]:123,[::2]:234");
+ }
+
+ @Test
+ public void testRPCIPv6() throws SQLException{
+ Configuration config = HBaseFactoryProvider.getConfigurationFactory().getConfiguration();
+ config.set("hbase.client.registry.impl",
+ "org.apache.hadoop.hbase.client.RpcConnectionRegistry");
+ RPCConnectionInfo info =
+ (RPCConnectionInfo) ConnectionInfo.create(
+ "jdbc:phoenix+rpc:[::1]\\:123,[\\:\\:2]\\::234", config,
+ null, null);
+ assertEquals("[::1]:123,[::2]:234", info.getBoostrapServers());
+ }
+
+ @Test
+ public void testZkIPv6() throws Exception {
+ ConnectionInfo connectionInfo = ConnectionInfo.create("jdbc:phoenix+zk:"
+ + "[::1],127.23.45.678\\:7634,v3\\:1,host123.48576\\:723:/hbase;"
+ + "test=true", null, null);
+ ReadOnlyProps props = connectionInfo.asProps();
+ assertEquals("127.23.45.678:7634,[::1]:2181,host123.48576:723,v3:1",
+ props.get(HConstants.ZOOKEEPER_QUORUM));
+
+ connectionInfo = ConnectionInfo.create("jdbc:phoenix+zk:"
+ + "[::1]\\:2181,127.23.45.678\\:7634,v3\\:1,host123.48576\\:723:/hbase;"
+ + "test=true", null, null);
+ props = connectionInfo.asProps();
+ assertEquals("127.23.45.678:7634,[::1]:2181,host123.48576:723,v3:1",
+
+ props.get(HConstants.ZOOKEEPER_QUORUM));
+ connectionInfo = ConnectionInfo.create("jdbc:phoenix+zk:"
+ + "[fe:80::],127.23.45.678\\:7634,v3\\:1,host123.48576\\:723:/hbase;"
+ + "test=true", null, null);
+ props = connectionInfo.asProps();
+ assertEquals("127.23.45.678:7634,[fe:80::]:2181,host123.48576:723,v3:1",
+ props.get(HConstants.ZOOKEEPER_QUORUM));
+
+ connectionInfo = ConnectionInfo.create("jdbc:phoenix+zk:"
+ + "[fe:80::]\\:2181,127.23.45.678\\:7634,v3\\:1,host123.48576\\:723:/hbase;"
+ + "test=true", null, null);
+ props = connectionInfo.asProps();
+ assertEquals("127.23.45.678:7634,[fe:80::]:2181,host123.48576:723,v3:1",
+ props.get(HConstants.ZOOKEEPER_QUORUM));
+
+ connectionInfo = ConnectionInfo.create("jdbc:phoenix+zk:"
+ + "[fe\\:80\\:\\:],127.23.45.678\\:7634,v3\\:1,host123.48576\\:723:/hbase;"
+ + "test=true", null, null);
+ props = connectionInfo.asProps();
+ assertEquals("127.23.45.678:7634,[fe:80::]:2181,host123.48576:723,v3:1",
+ props.get(HConstants.ZOOKEEPER_QUORUM));
+
+ connectionInfo = ConnectionInfo.create("jdbc:phoenix+zk:"
+ + "[fe\\:80\\:\\:]\\:2181,127.23.45.678\\:7634,v3\\:1,host123.48576\\:723:/hbase;"
+ + "test=true", null, null);
+ props = connectionInfo.asProps();
+ assertEquals("127.23.45.678:7634,[fe:80::]:2181,host123.48576:723,v3:1",
+ props.get(HConstants.ZOOKEEPER_QUORUM));
+
+ connectionInfo = ConnectionInfo.create("jdbc:phoenix+zk:"
+ + "[fe:80::2]\\:2181,[2001:db8:3c4d:15::1a2f:1a2b]\\:7634,v3\\:1,host123.48576\\:723:/hbase;"
+ + "test=true", null, null);
+ props = connectionInfo.asProps();
+ assertEquals("[2001:db8:3c4d:15::1a2f:1a2b]:7634,[fe:80::2]:2181,host123.48576:723,v3:1",
+ props.get(HConstants.ZOOKEEPER_QUORUM));
+
+ connectionInfo = ConnectionInfo.create("jdbc:phoenix+zk:"
+ + "[fe:80::2]\\:2181,[2001\\:db8\\:3c4d\\:15\\:\\:1a2f\\:1a2b]\\:7634,v3\\:1,host123.48576\\:723:/hbase;"
+ + "test=true", null, null);
+ props = connectionInfo.asProps();
+ assertEquals("[2001:db8:3c4d:15::1a2f:1a2b]:7634,[fe:80::2]:2181,host123.48576:723,v3:1",
+ props.get(HConstants.ZOOKEEPER_QUORUM));
+ }
Review Comment:
Please add a test with multiple IPv6 addressess for ZK as well.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@phoenix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org