-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HBASE-28436 Use connection url to specify the connection registry inf…
…ormation (#5770) Signed-off-by: Istvan Toth <stoty@apache.org> Signed-off-by: Nick Dimiduk <ndimiduk@apache.org> Reviewed-by: Bryan Beaudreault <bbeaudreault@apache.org> (cherry picked from commit e3761ba)
- Loading branch information
Showing
20 changed files
with
828 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
313 changes: 261 additions & 52 deletions
313
hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionFactory.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionRegistryURIFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* 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.hadoop.hbase.client; | ||
|
||
import java.io.IOException; | ||
import java.net.URI; | ||
import org.apache.hadoop.conf.Configuration; | ||
import org.apache.hadoop.hbase.security.User; | ||
import org.apache.yetus.audience.InterfaceAudience; | ||
|
||
/** | ||
* For creating different {@link ConnectionRegistry} implementation. | ||
*/ | ||
@InterfaceAudience.Private | ||
public interface ConnectionRegistryURIFactory { | ||
|
||
/** | ||
* Instantiate the {@link ConnectionRegistry} using the given parameters. | ||
*/ | ||
ConnectionRegistry create(URI uri, Configuration conf, User user) throws IOException; | ||
|
||
/** | ||
* The scheme for this implementation. Used to register this URI factory to the | ||
* {@link ConnectionRegistryFactory}. | ||
*/ | ||
String getScheme(); | ||
} |
49 changes: 49 additions & 0 deletions
49
hbase-client/src/main/java/org/apache/hadoop/hbase/client/RpcConnectionRegistryCreator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* 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.hadoop.hbase.client; | ||
|
||
import java.io.IOException; | ||
import java.net.URI; | ||
import org.apache.hadoop.conf.Configuration; | ||
import org.apache.hadoop.hbase.security.User; | ||
import org.apache.yetus.audience.InterfaceAudience; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
/** | ||
* Connection registry creator implementation for creating {@link RpcConnectionRegistry}. | ||
*/ | ||
@InterfaceAudience.Private | ||
public class RpcConnectionRegistryCreator implements ConnectionRegistryURIFactory { | ||
|
||
private static final Logger LOG = LoggerFactory.getLogger(RpcConnectionRegistryCreator.class); | ||
|
||
@Override | ||
public ConnectionRegistry create(URI uri, Configuration conf, User user) throws IOException { | ||
assert getScheme().equals(uri.getScheme()); | ||
LOG.debug("connect to hbase cluster with rpc bootstrap servers='{}'", uri.getAuthority()); | ||
Configuration c = new Configuration(conf); | ||
c.set(RpcConnectionRegistry.BOOTSTRAP_NODES, uri.getAuthority()); | ||
return new RpcConnectionRegistry(c, user); | ||
} | ||
|
||
@Override | ||
public String getScheme() { | ||
return "hbase+rpc"; | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
hbase-client/src/main/java/org/apache/hadoop/hbase/client/ZKConnectionRegistryCreator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* 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.hadoop.hbase.client; | ||
|
||
import java.io.IOException; | ||
import java.net.URI; | ||
import org.apache.hadoop.conf.Configuration; | ||
import org.apache.hadoop.hbase.HConstants; | ||
import org.apache.hadoop.hbase.security.User; | ||
import org.apache.yetus.audience.InterfaceAudience; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
/** | ||
* Connection registry creator implementation for creating {@link ZKConnectionRegistry}. | ||
*/ | ||
@InterfaceAudience.Private | ||
public class ZKConnectionRegistryCreator implements ConnectionRegistryURIFactory { | ||
|
||
private static final Logger LOG = LoggerFactory.getLogger(ZKConnectionRegistryCreator.class); | ||
|
||
@Override | ||
public ConnectionRegistry create(URI uri, Configuration conf, User user) throws IOException { | ||
assert getScheme().equals(uri.getScheme()); | ||
LOG.debug("connect to hbase cluster with zk quorum='{}' and parent='{}'", uri.getAuthority(), | ||
uri.getPath()); | ||
Configuration c = new Configuration(conf); | ||
c.set(HConstants.CLIENT_ZOOKEEPER_QUORUM, uri.getAuthority()); | ||
c.set(HConstants.ZOOKEEPER_ZNODE_PARENT, uri.getPath()); | ||
return new ZKConnectionRegistry(c, user); | ||
} | ||
|
||
@Override | ||
public String getScheme() { | ||
return "hbase+zk"; | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...n/resources/META-INF/services/org.apache.hadoop.hbase.client.ConnectionRegistryURIFactory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# 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. | ||
org.apache.hadoop.hbase.client.RpcConnectionRegistryCreator | ||
org.apache.hadoop.hbase.client.ZKConnectionRegistryCreator |
Oops, something went wrong.