You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2020/06/13 23:42:35 UTC
[GitHub] [airflow] vanka56 opened a new pull request #9280: Functionality to shuffle HMS connections to be used by HiveMetastoreHook facilitating load balancing
vanka56 opened a new pull request #9280:
URL: https://github.com/apache/airflow/pull/9280
HiveMetastoreHook connects to the first available server from a collection and connects to it every time it is instantiated. Shuffling the collection(containing collection) would facilitate
load balancing among the HMS servers(with same conn_id)
Make sure to mark the boxes below before creating PR: [x]
- [ x] Description above provides context of the change
- [ x] Unit tests coverage for changes (not needed for documentation changes)
- [ x] Target Github ISSUE in description if exists
- [ x] Commits follow "[How to write a good git commit message](http://chris.beams.io/posts/git-commit/)"
- [ x] Relevant documentation is updated including usage instructions.
- [ x] I will engage committers as explained in [Contribution Workflow Example](https://github.com/apache/airflow/blob/master/CONTRIBUTING.rst#contribution-workflow-example).
---
In case of fundamental code change, Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvements+Proposals)) is needed.
In case of a new dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
In case of backwards incompatible changes please leave a note in [UPDATING.md](https://github.com/apache/airflow/blob/master/UPDATING.md).
Read the [Pull Request Guidelines](https://github.com/apache/airflow/blob/master/CONTRIBUTING.rst#pull-request-guidelines) for more information.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] vanka56 commented on a change in pull request #9280: Functionality to shuffle HMS connections to be used by HiveMetastoreHook facilitating load balancing
Posted by GitBox <gi...@apache.org>.
vanka56 commented on a change in pull request #9280:
URL: https://github.com/apache/airflow/pull/9280#discussion_r445715925
##########
File path: tests/hooks/test_hive_hook.py
##########
@@ -390,6 +390,25 @@ def test_table_exists(self):
self.hook.table_exists(str(random.randint(1, 10000)))
)
+ def test_check_hms_clients_load_balance(self):
+ # checks if every time HMS Hook is instantiated, it gets to
+ # different HMS server most of the time and not to the same HMS server.
+ connection_count = {}
+ hms_hook = HiveMetastoreHook()
+ hms_server_count = len(hms_hook.get_connections('metastore_default'))
+
+ if hms_server_count > 2:
+ for index in range(2 * hms_server_count):
+ conn = HiveMetastoreHook()._find_valid_server().host
+ if conn in connection_count:
+ if connection_count[conn] >= (2 * hms_server_count) - 1:
+ self.assertTrue(1 == 2)
+ else:
+ connection_count[conn] = connection_count[conn] + 1
+ else:
+ connection_count[conn] = 1
+ self.assertTrue(1 == 1)
Review comment:
@ashb sure let me work 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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] vanka56 commented on a change in pull request #9280: Functionality to shuffle HMS connections to be used by HiveMetastoreHook facilitating load balancing
Posted by GitBox <gi...@apache.org>.
vanka56 commented on a change in pull request #9280:
URL: https://github.com/apache/airflow/pull/9280#discussion_r446318276
##########
File path: tests/hooks/test_hive_hook.py
##########
@@ -390,6 +390,11 @@ def test_table_exists(self):
self.hook.table_exists(str(random.randint(1, 10000)))
)
+ @mock.patch('random.shuffle')
+ def test_check_hms_clients_load_balance(self, mock_shuffle):
+ HiveMetastoreHook()._find_valid_server()
+ mock_shuffle.has_calls()
+
Review comment:
LGTM. just one small change, mocking get_metastore_client as well to avoid error.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] vanka56 commented on a change in pull request #9280: Functionality to shuffle HMS connections to be used by HiveMetastoreHook facilitating load balancing
Posted by GitBox <gi...@apache.org>.
vanka56 commented on a change in pull request #9280:
URL: https://github.com/apache/airflow/pull/9280#discussion_r446319600
##########
File path: tests/hooks/test_hive_hook.py
##########
@@ -390,6 +390,11 @@ def test_table_exists(self):
self.hook.table_exists(str(random.randint(1, 10000)))
)
+ @mock.patch('random.shuffle')
+ def test_check_hms_clients_load_balance(self, mock_shuffle):
+ HiveMetastoreHook()._find_valid_server()
+ mock_shuffle.has_calls()
+
Review comment:
@turbaszek Please take a look. Thank you!
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] vanka56 commented on a change in pull request #9280: Functionality to shuffle HMS connections to be used by HiveMetastoreHook facilitating load balancing
Posted by GitBox <gi...@apache.org>.
vanka56 commented on a change in pull request #9280:
URL: https://github.com/apache/airflow/pull/9280#discussion_r445924780
##########
File path: tests/hooks/test_hive_hook.py
##########
@@ -390,6 +390,25 @@ def test_table_exists(self):
self.hook.table_exists(str(random.randint(1, 10000)))
)
+ def test_check_hms_clients_load_balance(self):
+ # checks if every time HMS Hook is instantiated, it gets to
+ # different HMS server most of the time and not to the same HMS server.
+ connection_count = {}
+ hms_hook = HiveMetastoreHook()
+ hms_server_count = len(hms_hook.get_connections('metastore_default'))
+
+ if hms_server_count > 2:
+ for index in range(2 * hms_server_count):
+ conn = HiveMetastoreHook()._find_valid_server().host
+ if conn in connection_count:
+ if connection_count[conn] >= (2 * hms_server_count) - 1:
+ self.assertTrue(1 == 2)
+ else:
+ connection_count[conn] = connection_count[conn] + 1
+ else:
+ connection_count[conn] = 1
+ self.assertTrue(1 == 1)
Review comment:
@turbaszek
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] ashb commented on a change in pull request #9280: Functionality to shuffle HMS connections to be used by HiveMetastoreHook facilitating load balancing
Posted by GitBox <gi...@apache.org>.
ashb commented on a change in pull request #9280:
URL: https://github.com/apache/airflow/pull/9280#discussion_r445427034
##########
File path: tests/hooks/test_hive_hook.py
##########
@@ -390,6 +390,25 @@ def test_table_exists(self):
self.hook.table_exists(str(random.randint(1, 10000)))
)
+ def test_check_hms_clients_load_balance(self):
+ # checks if every time HMS Hook is instantiated, it gets to
+ # different HMS server most of the time and not to the same HMS server.
+ connection_count = {}
+ hms_hook = HiveMetastoreHook()
+ hms_server_count = len(hms_hook.get_connections('metastore_default'))
+
+ if hms_server_count > 2:
+ for index in range(2 * hms_server_count):
+ conn = HiveMetastoreHook()._find_valid_server().host
+ if conn in connection_count:
+ if connection_count[conn] >= (2 * hms_server_count) - 1:
+ self.assertTrue(1 == 2)
+ else:
+ connection_count[conn] = connection_count[conn] + 1
+ else:
+ connection_count[conn] = 1
+ self.assertTrue(1 == 1)
Review comment:
@vanka56 could you make this change Tomek suggested today by any chance? (Then we can get this in to 1.10.11)
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] vanka56 commented on a change in pull request #9280: Functionality to shuffle HMS connections to be used by HiveMetastoreHook facilitating load balancing
Posted by GitBox <gi...@apache.org>.
vanka56 commented on a change in pull request #9280:
URL: https://github.com/apache/airflow/pull/9280#discussion_r445912949
##########
File path: tests/hooks/test_hive_hook.py
##########
@@ -390,6 +390,25 @@ def test_table_exists(self):
self.hook.table_exists(str(random.randint(1, 10000)))
)
+ def test_check_hms_clients_load_balance(self):
+ # checks if every time HMS Hook is instantiated, it gets to
+ # different HMS server most of the time and not to the same HMS server.
+ connection_count = {}
+ hms_hook = HiveMetastoreHook()
+ hms_server_count = len(hms_hook.get_connections('metastore_default'))
+
+ if hms_server_count > 2:
+ for index in range(2 * hms_server_count):
+ conn = HiveMetastoreHook()._find_valid_server().host
+ if conn in connection_count:
+ if connection_count[conn] >= (2 * hms_server_count) - 1:
+ self.assertTrue(1 == 2)
+ else:
+ connection_count[conn] = connection_count[conn] + 1
+ else:
+ connection_count[conn] = 1
+ self.assertTrue(1 == 1)
Review comment:
@ashb i have done the changes. take a look. thanks!
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] turbaszek commented on pull request #9280: Functionality to shuffle HMS connections to be used by HiveMetastoreHook facilitating load balancing
Posted by GitBox <gi...@apache.org>.
turbaszek commented on pull request #9280:
URL: https://github.com/apache/airflow/pull/9280#issuecomment-651224358
@vanka56 can you please take a look at the CI?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] vanka56 commented on pull request #9280: Functionality to shuffle HMS connections to be used by HiveMetastoreHook facilitating load balancing
Posted by GitBox <gi...@apache.org>.
vanka56 commented on pull request #9280:
URL: https://github.com/apache/airflow/pull/9280#issuecomment-651342257
@turbaszek
As far as i could see there is no error related to my changes. its talking about these things(package dependency).
Is there a document about how to go about these build issues and ways to correct them. i am new to this.
"The following packages have unmet dependencies:
libc6-dev : Breaks: libgcc-8-dev (< 8.4.0-2~) but 8.3.0-6 is to be installed
E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages.
"
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] turbaszek commented on a change in pull request #9280: Functionality to shuffle HMS connections to be used by HiveMetastoreHook facilitating load balancing
Posted by GitBox <gi...@apache.org>.
turbaszek commented on a change in pull request #9280:
URL: https://github.com/apache/airflow/pull/9280#discussion_r444053678
##########
File path: tests/hooks/test_hive_hook.py
##########
@@ -390,6 +390,25 @@ def test_table_exists(self):
self.hook.table_exists(str(random.randint(1, 10000)))
)
+ def test_check_hms_clients_load_balance(self):
+ # checks if every time HMS Hook is instantiated, it gets to
+ # different HMS server most of the time and not to the same HMS server.
+ connection_count = {}
+ hms_hook = HiveMetastoreHook()
+ hms_server_count = len(hms_hook.get_connections('metastore_default'))
+
+ if hms_server_count > 2:
+ for index in range(2 * hms_server_count):
+ conn = HiveMetastoreHook()._find_valid_server().host
+ if conn in connection_count:
+ if connection_count[conn] >= (2 * hms_server_count) - 1:
+ self.assertTrue(1 == 2)
+ else:
+ connection_count[conn] = connection_count[conn] + 1
+ else:
+ connection_count[conn] = 1
+ self.assertTrue(1 == 1)
Review comment:
I appreciate the test, however I'm wondering if it would be sufficient to mock the `random.shuffle` and assert that it was called? Additionaly we can mock it with callable that gives deterministic result i.e `lambda xs: xs[::-1]`, WDYT?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] kaxil merged pull request #9280: Functionality to shuffle HMS connections to be used by HiveMetastoreHook facilitating load balancing
Posted by GitBox <gi...@apache.org>.
kaxil merged pull request #9280:
URL: https://github.com/apache/airflow/pull/9280
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] vanka56 commented on pull request #9280: Functionality to shuffle HMS connections to be used by HiveMetastoreHook facilitating load balancing
Posted by GitBox <gi...@apache.org>.
vanka56 commented on pull request #9280:
URL: https://github.com/apache/airflow/pull/9280#issuecomment-647857736
Hi @ashb @turbaszek,
Do you mind reviewing this change when you get a chance. Thank you! cc @Acehaidrey Acehaidrey
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] ashb commented on a change in pull request #9280: Functionality to shuffle HMS connections to be used by HiveMetastoreHook facilitating load balancing
Posted by GitBox <gi...@apache.org>.
ashb commented on a change in pull request #9280:
URL: https://github.com/apache/airflow/pull/9280#discussion_r444951860
##########
File path: tests/hooks/test_hive_hook.py
##########
@@ -390,6 +390,25 @@ def test_table_exists(self):
self.hook.table_exists(str(random.randint(1, 10000)))
)
+ def test_check_hms_clients_load_balance(self):
+ # checks if every time HMS Hook is instantiated, it gets to
+ # different HMS server most of the time and not to the same HMS server.
+ connection_count = {}
+ hms_hook = HiveMetastoreHook()
+ hms_server_count = len(hms_hook.get_connections('metastore_default'))
+
+ if hms_server_count > 2:
+ for index in range(2 * hms_server_count):
+ conn = HiveMetastoreHook()._find_valid_server().host
+ if conn in connection_count:
+ if connection_count[conn] >= (2 * hms_server_count) - 1:
+ self.assertTrue(1 == 2)
+ else:
+ connection_count[conn] = connection_count[conn] + 1
+ else:
+ connection_count[conn] = 1
+ self.assertTrue(1 == 1)
Review comment:
Yeah, that sounds more stable to me.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] turbaszek commented on a change in pull request #9280: Functionality to shuffle HMS connections to be used by HiveMetastoreHook facilitating load balancing
Posted by GitBox <gi...@apache.org>.
turbaszek commented on a change in pull request #9280:
URL: https://github.com/apache/airflow/pull/9280#discussion_r446074371
##########
File path: tests/hooks/test_hive_hook.py
##########
@@ -390,6 +390,11 @@ def test_table_exists(self):
self.hook.table_exists(str(random.randint(1, 10000)))
)
+ @mock.patch('random.shuffle')
+ def test_check_hms_clients_load_balance(self, mock_shuffle):
+ HiveMetastoreHook()._find_valid_server()
+ mock_shuffle.has_calls()
+
Review comment:
```suggestion
@mock.patch('airflow.hooks.hive_hooks.random.shuffle')
@mock.patch('airflow.hooks.hive_hooks. HiveMetastoreHook.get_connections')
def test_check_hms_clients_load_balance(self, mock_get_conn, mock_shuffle):
HiveMetastoreHook()._find_valid_server()
mock_shuffle.assert_called_once_with(mock_get_conn.return_value)
```
WDYT?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] Acehaidrey commented on pull request #9280: Functionality to shuffle HMS connections to be used by HiveMetastoreHook facilitating load balancing
Posted by GitBox <gi...@apache.org>.
Acehaidrey commented on pull request #9280:
URL: https://github.com/apache/airflow/pull/9280#issuecomment-646237046
Hi @ashb @turbaszek if either of you have a chance to look at this; sorry to keep pinging.
CC @venka56
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] Acehaidrey commented on pull request #9280: Functionality to shuffle HMS connections to be used by HiveMetastoreHook facilitating load balancing
Posted by GitBox <gi...@apache.org>.
Acehaidrey commented on pull request #9280:
URL: https://github.com/apache/airflow/pull/9280#issuecomment-652626222
@vanka56 can you try to rebase and see if that will help
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] boring-cyborg[bot] commented on pull request #9280: Functionality to shuffle HMS connections to be used by HiveMetastoreHook facilitating load balancing
Posted by GitBox <gi...@apache.org>.
boring-cyborg[bot] commented on pull request #9280:
URL: https://github.com/apache/airflow/pull/9280#issuecomment-654749672
Awesome work, congrats on your first merged pull request!
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org