Skip to content

Commit 7743b23

Browse files
ivandaschisapego
authored andcommitted
IGNITE-14167 Simplify reconnecting, fix affinity topology change detection
This closes #16
1 parent ba268cc commit 7743b23

File tree

15 files changed

+441
-471
lines changed

15 files changed

+441
-471
lines changed

.travis.yml

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515

16+
language: python
1617
sudo: required
1718

1819
addons:
@@ -21,18 +22,27 @@ addons:
2122
- openjdk-8-jdk
2223

2324
env:
24-
- IGNITE_VERSION=2.9.1 IGNITE_HOME=/opt/ignite
25+
global:
26+
- IGNITE_VERSION=2.9.1
27+
- IGNITE_HOME=/opt/ignite
2528

2629
before_install:
2730
- curl -L https://apache-mirror.rbc.ru/pub/apache/ignite/${IGNITE_VERSION}/apache-ignite-slim-${IGNITE_VERSION}-bin.zip > ignite.zip
2831
- unzip ignite.zip -d /opt
2932
- mv /opt/apache-ignite-slim-${IGNITE_VERSION}-bin /opt/ignite
3033
- mv /opt/ignite/libs/optional/ignite-log4j2 /opt/ignite/libs/
3134

32-
language: python
33-
python:
34-
- "3.6"
35-
- "3.7"
36-
- "3.8"
37-
install: pip install tox-travis
35+
jobs:
36+
include:
37+
- python: '3.6'
38+
arch: amd64
39+
env: TOXENV=py36-no-ssl,py36-ssl,py36-ssl-password
40+
- python: '3.7'
41+
arch: amd64
42+
env: TOXENV=py37-no-ssl,py37-ssl,py37-ssl-password
43+
- python: '3.8'
44+
arch: amd64
45+
env: TOXENV=py38-no-ssl,py38-ssl,py38-ssl-password
46+
47+
install: pip install tox
3848
script: tox

pyignite/api/affinity.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,13 @@
5555
partition_mapping = StructArray([
5656
('is_applicable', Bool),
5757

58-
('cache_mapping', Conditional(lambda ctx: ctx['is_applicable'] and ctx['is_applicable'].value == 1,
58+
('cache_mapping', Conditional(['is_applicable'],
59+
lambda ctx: ctx['is_applicable'] and ctx['is_applicable'].value == 1,
5960
lambda ctx: ctx['is_applicable'],
6061
cache_mapping, empty_cache_mapping)),
6162

62-
('node_mapping', Conditional(lambda ctx: ctx['is_applicable'] and ctx['is_applicable'].value == 1,
63+
('node_mapping', Conditional(['is_applicable'],
64+
lambda ctx: ctx['is_applicable'] and ctx['is_applicable'].value == 1,
6365
lambda ctx: ctx['is_applicable'],
6466
node_mapping, empty_node_mapping)),
6567
])

pyignite/cache.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,10 @@ def get_best_node(
283283
parts += len(p)
284284

285285
self.affinity['number_of_partitions'] = parts
286+
287+
for conn in self.client._nodes:
288+
if not conn.alive:
289+
conn.reconnect()
286290
else:
287291
# get number of partitions
288292
parts = self.affinity.get('number_of_partitions')

pyignite/client.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -182,15 +182,9 @@ def connect(self, *args):
182182
if not self.partition_aware:
183183
# do not try to open more nodes
184184
self._current_node = i
185-
else:
186-
# take a chance to schedule the reconnection
187-
# for all the failed connections, that was probed
188-
# before this
189-
for failed_node in self._nodes[:i]:
190-
failed_node.reconnect()
191185

192186
except connection_errors:
193-
conn._fail()
187+
conn.failed = True
194188
if self.partition_aware:
195189
# schedule the reconnection
196190
conn.reconnect()

0 commit comments

Comments
 (0)