nucliadb 6.2.1.post2954__py3-none-any.whl → 6.2.1.post2972__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- nucliadb/common/cluster/manager.py +33 -331
- nucliadb/common/cluster/rebalance.py +2 -2
- nucliadb/common/cluster/rollover.py +12 -71
- nucliadb/common/cluster/standalone/utils.py +0 -43
- nucliadb/common/cluster/utils.py +0 -16
- nucliadb/common/nidx.py +21 -23
- nucliadb/health.py +0 -7
- nucliadb/ingest/app.py +0 -8
- nucliadb/ingest/consumer/auditing.py +1 -1
- nucliadb/ingest/consumer/shard_creator.py +1 -1
- nucliadb/ingest/orm/entities.py +3 -6
- nucliadb/purge/orphan_shards.py +6 -4
- nucliadb/search/api/v1/knowledgebox.py +1 -5
- nucliadb/search/predict.py +4 -4
- nucliadb/search/requesters/utils.py +1 -2
- nucliadb/search/search/chat/ask.py +18 -11
- nucliadb/search/search/chat/query.py +1 -1
- nucliadb/search/search/shards.py +19 -0
- nucliadb/standalone/introspect.py +0 -25
- nucliadb/train/lifecycle.py +0 -6
- nucliadb/train/nodes.py +1 -5
- nucliadb/writer/back_pressure.py +17 -46
- nucliadb/writer/settings.py +2 -2
- {nucliadb-6.2.1.post2954.dist-info → nucliadb-6.2.1.post2972.dist-info}/METADATA +5 -7
- {nucliadb-6.2.1.post2954.dist-info → nucliadb-6.2.1.post2972.dist-info}/RECORD +29 -39
- nucliadb/common/cluster/discovery/__init__.py +0 -19
- nucliadb/common/cluster/discovery/base.py +0 -178
- nucliadb/common/cluster/discovery/k8s.py +0 -301
- nucliadb/common/cluster/discovery/manual.py +0 -57
- nucliadb/common/cluster/discovery/single.py +0 -51
- nucliadb/common/cluster/discovery/types.py +0 -32
- nucliadb/common/cluster/discovery/utils.py +0 -67
- nucliadb/common/cluster/standalone/grpc_node_binding.py +0 -349
- nucliadb/common/cluster/standalone/index_node.py +0 -123
- nucliadb/common/cluster/standalone/service.py +0 -84
- {nucliadb-6.2.1.post2954.dist-info → nucliadb-6.2.1.post2972.dist-info}/WHEEL +0 -0
- {nucliadb-6.2.1.post2954.dist-info → nucliadb-6.2.1.post2972.dist-info}/entry_points.txt +0 -0
- {nucliadb-6.2.1.post2954.dist-info → nucliadb-6.2.1.post2972.dist-info}/top_level.txt +0 -0
- {nucliadb-6.2.1.post2954.dist-info → nucliadb-6.2.1.post2972.dist-info}/zip-safe +0 -0
nucliadb/writer/back_pressure.py
CHANGED
@@ -30,7 +30,6 @@ from cachetools import TTLCache
|
|
30
30
|
from fastapi import HTTPException, Request
|
31
31
|
|
32
32
|
from nucliadb.common import datamanagers
|
33
|
-
from nucliadb.common.cluster.manager import get_index_nodes
|
34
33
|
from nucliadb.common.context import ApplicationContext
|
35
34
|
from nucliadb.common.context.fastapi import get_app_context
|
36
35
|
from nucliadb.common.http_clients.processing import ProcessingHTTPClient
|
@@ -168,7 +167,7 @@ class Materializer:
|
|
168
167
|
self.ingest_check_interval = ingest_check_interval
|
169
168
|
|
170
169
|
self.ingest_pending: int = 0
|
171
|
-
self.indexing_pending:
|
170
|
+
self.indexing_pending: int = 0
|
172
171
|
|
173
172
|
self._tasks: list[asyncio.Task] = []
|
174
173
|
self._running = False
|
@@ -232,7 +231,7 @@ class Materializer:
|
|
232
231
|
response = await self.processing_http_client.stats(kbid=kbid, timeout=0.5)
|
233
232
|
return response.incomplete
|
234
233
|
|
235
|
-
def get_indexing_pending(self) ->
|
234
|
+
def get_indexing_pending(self) -> int:
|
236
235
|
return self.indexing_pending
|
237
236
|
|
238
237
|
def get_ingest_pending(self) -> int:
|
@@ -241,20 +240,18 @@ class Materializer:
|
|
241
240
|
async def _get_indexing_pending_task(self):
|
242
241
|
try:
|
243
242
|
while True:
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
self.
|
248
|
-
|
249
|
-
|
250
|
-
consumer=const.Streams.INDEX.group.format(node=node.id),
|
251
|
-
)
|
252
|
-
except Exception:
|
253
|
-
logger.exception(
|
254
|
-
"Error getting pending messages to index",
|
255
|
-
exc_info=True,
|
256
|
-
extra={"node_id": node.id},
|
243
|
+
try:
|
244
|
+
with back_pressure_observer({"type": "get_indexing_pending"}):
|
245
|
+
self.indexing_pending = await get_nats_consumer_pending_messages(
|
246
|
+
self.nats_manager,
|
247
|
+
stream="nidx",
|
248
|
+
consumer="nidx",
|
257
249
|
)
|
250
|
+
except Exception:
|
251
|
+
logger.exception(
|
252
|
+
"Error getting pending messages to index",
|
253
|
+
exc_info=True,
|
254
|
+
)
|
258
255
|
await asyncio.sleep(self.indexing_check_interval)
|
259
256
|
except asyncio.CancelledError:
|
260
257
|
pass
|
@@ -386,7 +383,7 @@ async def check_indexing_behind(
|
|
386
383
|
context: ApplicationContext,
|
387
384
|
kbid: str,
|
388
385
|
resource_uuid: Optional[str],
|
389
|
-
|
386
|
+
pending: int,
|
390
387
|
):
|
391
388
|
"""
|
392
389
|
If a resource uuid is provided, it will check the nodes that have the replicas
|
@@ -398,36 +395,10 @@ async def check_indexing_behind(
|
|
398
395
|
# Indexing back pressure is disabled
|
399
396
|
return
|
400
397
|
|
401
|
-
if
|
402
|
-
logger.warning("No nodes found to check for pending messages")
|
403
|
-
return
|
404
|
-
|
405
|
-
# Get nodes that are involved in the indexing of the request
|
406
|
-
if resource_uuid is not None:
|
407
|
-
nodes_to_check = await get_nodes_for_resource_shard(context, kbid, resource_uuid)
|
408
|
-
else:
|
409
|
-
nodes_to_check = await get_nodes_for_kb_active_shards(context, kbid)
|
410
|
-
|
411
|
-
if len(nodes_to_check) == 0:
|
412
|
-
logger.warning(
|
413
|
-
"No nodes found to check for pending messages",
|
414
|
-
extra={"kbid": kbid, "resource_uuid": resource_uuid},
|
415
|
-
)
|
416
|
-
return
|
417
|
-
|
418
|
-
# Get the highest pending value
|
419
|
-
highest_pending = 0
|
420
|
-
for node in nodes_to_check:
|
421
|
-
if node not in pending_by_node:
|
422
|
-
logger.warning("Node not found in pending messages", extra={"node": node})
|
423
|
-
continue
|
424
|
-
if pending_by_node[node] > highest_pending:
|
425
|
-
highest_pending = pending_by_node[node]
|
426
|
-
|
427
|
-
if highest_pending > max_pending:
|
398
|
+
if pending > max_pending:
|
428
399
|
try_after = estimate_try_after(
|
429
400
|
rate=settings.indexing_rate,
|
430
|
-
pending=
|
401
|
+
pending=pending,
|
431
402
|
max_wait=settings.max_wait_time,
|
432
403
|
)
|
433
404
|
data = BackPressureData(type="indexing", try_after=try_after)
|
@@ -437,7 +408,7 @@ async def check_indexing_behind(
|
|
437
408
|
"kbid": kbid,
|
438
409
|
"resource_uuid": resource_uuid,
|
439
410
|
"try_after": try_after,
|
440
|
-
"pending":
|
411
|
+
"pending": pending,
|
441
412
|
},
|
442
413
|
)
|
443
414
|
raise BackPressureException(data)
|
nucliadb/writer/settings.py
CHANGED
@@ -36,7 +36,7 @@ class BackPressureSettings(BaseSettings):
|
|
36
36
|
alias="back_pressure_enabled",
|
37
37
|
)
|
38
38
|
indexing_rate: float = Field(
|
39
|
-
default=
|
39
|
+
default=10,
|
40
40
|
description="Estimation of the indexing rate in messages per second. This is used to calculate the try again in time", # noqa
|
41
41
|
)
|
42
42
|
ingest_rate: float = Field(
|
@@ -48,7 +48,7 @@ class BackPressureSettings(BaseSettings):
|
|
48
48
|
description="Estimation of the processing rate in messages per second. This is used to calculate the try again in time", # noqa
|
49
49
|
)
|
50
50
|
max_indexing_pending: int = Field(
|
51
|
-
default=
|
51
|
+
default=1000,
|
52
52
|
description="Max number of messages pending to index in a node queue before rate limiting writes. Set to 0 to disable indexing back pressure checks", # noqa
|
53
53
|
alias="back_pressure_max_indexing_pending",
|
54
54
|
)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: nucliadb
|
3
|
-
Version: 6.2.1.
|
3
|
+
Version: 6.2.1.post2972
|
4
4
|
Home-page: https://docs.nuclia.dev/docs/management/nucliadb/intro
|
5
5
|
Author: NucliaDB Community
|
6
6
|
Author-email: nucliadb@nuclia.com
|
@@ -22,12 +22,11 @@ Classifier: Programming Language :: Python :: 3.12
|
|
22
22
|
Classifier: Programming Language :: Python :: 3 :: Only
|
23
23
|
Requires-Python: >=3.9, <4
|
24
24
|
Description-Content-Type: text/markdown
|
25
|
-
Requires-Dist: nucliadb-telemetry[all]>=6.2.1.
|
26
|
-
Requires-Dist: nucliadb-utils[cache,fastapi,storages]>=6.2.1.
|
27
|
-
Requires-Dist: nucliadb-protos>=6.2.1.
|
28
|
-
Requires-Dist: nucliadb-models>=6.2.1.
|
25
|
+
Requires-Dist: nucliadb-telemetry[all]>=6.2.1.post2972
|
26
|
+
Requires-Dist: nucliadb-utils[cache,fastapi,storages]>=6.2.1.post2972
|
27
|
+
Requires-Dist: nucliadb-protos>=6.2.1.post2972
|
28
|
+
Requires-Dist: nucliadb-models>=6.2.1.post2972
|
29
29
|
Requires-Dist: nucliadb-admin-assets>=1.0.0.post1224
|
30
|
-
Requires-Dist: nucliadb-node-binding>=2.26.0
|
31
30
|
Requires-Dist: nuclia-models>=0.24.2
|
32
31
|
Requires-Dist: uvicorn
|
33
32
|
Requires-Dist: argdantic
|
@@ -78,7 +77,6 @@ Requires-Dist: async_lru>=2.0.4
|
|
78
77
|
Requires-Dist: async-timeout>=4.0.3
|
79
78
|
Requires-Dist: cachetools>=5.3.2
|
80
79
|
Requires-Dist: types-cachetools>=5.3.0.5
|
81
|
-
Requires-Dist: kubernetes_asyncio<30.0.0
|
82
80
|
Provides-Extra: redis
|
83
81
|
Requires-Dist: redis>=4.3.4; extra == "redis"
|
84
82
|
Dynamic: author
|
@@ -31,7 +31,7 @@ migrations/pg/0002_catalog.py,sha256=Rsleecu351Ty19kYZgOpqX5G3MEAY8nMxCJrAeuS2Mw
|
|
31
31
|
migrations/pg/0003_catalog_kbid_index.py,sha256=uKq_vtnuf73GVf0mtl2rhzdk_czAoEU1UdiVKVZpA0M,1044
|
32
32
|
migrations/pg/__init__.py,sha256=cp15ZcFnHvpcu_5-aK2A4uUyvuZVV_MJn4bIXMa20ks,835
|
33
33
|
nucliadb/__init__.py,sha256=_abCmDJ_0ku483Os4UAjPX7Nywm39cQgAV_DiyjsKeQ,891
|
34
|
-
nucliadb/health.py,sha256=
|
34
|
+
nucliadb/health.py,sha256=UIxxA4oms4HIsCRZM_SZsdkIZIlgzmOxw-qSHLlWuak,3465
|
35
35
|
nucliadb/learning_proxy.py,sha256=LxsGbYD-kwCY6wlZWOhGv2kiDJKGz623J7WDfL38yHw,19359
|
36
36
|
nucliadb/metrics_exporter.py,sha256=Rz6G7V_C_GTZCFzd0xEtIfixtZgUuffnr4rDKCbXXWM,5595
|
37
37
|
nucliadb/openapi.py,sha256=wDiw0dVEvTpJvbatkJ0JZLkKm9RItZT5PWRHjqRfqTA,2272
|
@@ -41,29 +41,19 @@ nucliadb/common/constants.py,sha256=QpigxJh_CtD85Evy0PtV5cVq6x0U_f9xfIcXz1ymkUg,
|
|
41
41
|
nucliadb/common/counters.py,sha256=yhJEmmrglTSrDmB8OjaFLkZ__TwhTxayyQrtacnB55I,957
|
42
42
|
nucliadb/common/ids.py,sha256=HMb213Kz9HaY4IsBwaQJFhUErntKWV-29s0UHaGcf1E,8004
|
43
43
|
nucliadb/common/locking.py,sha256=RL0CabZVPzxHZyUjYeUyLvsJTm7W3J9o4fEgsY_ufNc,5896
|
44
|
-
nucliadb/common/nidx.py,sha256=
|
44
|
+
nucliadb/common/nidx.py,sha256=56fimZcR-__SOfbgU72GEZqPPjYhEsz5DHurAef72XE,8823
|
45
45
|
nucliadb/common/cluster/__init__.py,sha256=cp15ZcFnHvpcu_5-aK2A4uUyvuZVV_MJn4bIXMa20ks,835
|
46
46
|
nucliadb/common/cluster/base.py,sha256=kklDqyvsubNX0W494ttl9f3E58lGaX6AXqAd8XX8ZHE,5522
|
47
47
|
nucliadb/common/cluster/exceptions.py,sha256=V3c_fgH00GyJ-a5CaGLhwTuhwhUNR9YAGvS5jaRuc_Y,1495
|
48
48
|
nucliadb/common/cluster/grpc_node_dummy.py,sha256=L85wBnfab7Rev0CfsfUjPxQC6DiHPsETKrZAOLx9XHg,3510
|
49
49
|
nucliadb/common/cluster/index_node.py,sha256=g38H1kiAliF3Y6et_CWYInpn_xPxf7THAFJ7RtgLNZo,3246
|
50
|
-
nucliadb/common/cluster/manager.py,sha256=
|
51
|
-
nucliadb/common/cluster/rebalance.py,sha256=
|
52
|
-
nucliadb/common/cluster/rollover.py,sha256=
|
50
|
+
nucliadb/common/cluster/manager.py,sha256=3UnYwVb-ZykYfLndxM7TLw7-2T_vxqoFXMu0Pzxh5-A,15327
|
51
|
+
nucliadb/common/cluster/rebalance.py,sha256=jSEYsPgs_Dobv3FOaKl5arBko4s8JlWkahm8LOzgNnE,9135
|
52
|
+
nucliadb/common/cluster/rollover.py,sha256=dx6AF9ywKP10iBNlcoJgRV40921fOPpVWaCUU54hztE,25823
|
53
53
|
nucliadb/common/cluster/settings.py,sha256=RqIMJNyNcn5aV5PifUflkn4zDVX-Ruo36PXGP1CV1mc,3263
|
54
|
-
nucliadb/common/cluster/utils.py,sha256=
|
55
|
-
nucliadb/common/cluster/discovery/__init__.py,sha256=cp15ZcFnHvpcu_5-aK2A4uUyvuZVV_MJn4bIXMa20ks,835
|
56
|
-
nucliadb/common/cluster/discovery/base.py,sha256=-iKxLF8CSDO9dyT0DGiR_Hi8MiwxTN_0hqfNAcHNc1c,6473
|
57
|
-
nucliadb/common/cluster/discovery/k8s.py,sha256=etU8uSlgr6UwniWC0BeOfJvYL4iJkLbzl4PPyQM45OM,12282
|
58
|
-
nucliadb/common/cluster/discovery/manual.py,sha256=ZryMjHD45WdIJlEPIoyouAljkLw3ZO_SGGmv3oJnBf4,1919
|
59
|
-
nucliadb/common/cluster/discovery/single.py,sha256=2BhcencPKQQIfVitmTPJZm3TkBHyY9ZMcr-Clh8k2tM,1737
|
60
|
-
nucliadb/common/cluster/discovery/types.py,sha256=vs-K790rofjZ4FWYaMkgjkZZqMvIvd_0eSw3shuiLwA,1139
|
61
|
-
nucliadb/common/cluster/discovery/utils.py,sha256=OWQ3NewGX7PlIGOWuS7M5wxDMb96kQj-Ll53qiv0QcE,2526
|
54
|
+
nucliadb/common/cluster/utils.py,sha256=Vu0f6026EBELe-ff3d5B0ihD0HtjSWKDCr4dy7LmKqg,5848
|
62
55
|
nucliadb/common/cluster/standalone/__init__.py,sha256=itSI7dtTwFP55YMX4iK7JzdMHS5CQVUiB1XzQu4UBh8,833
|
63
|
-
nucliadb/common/cluster/standalone/
|
64
|
-
nucliadb/common/cluster/standalone/index_node.py,sha256=QuxAjx3NguLeK8X91f8xtl54Q7-ynrqJEoB-KgssTIQ,4578
|
65
|
-
nucliadb/common/cluster/standalone/service.py,sha256=A9VSTkBW0scGuNIQi1JiGTzFXhHuEK7KJ1SqPcgO0gM,3416
|
66
|
-
nucliadb/common/cluster/standalone/utils.py,sha256=T6pJ7pWt14i0cVzJ1upw2texM6pophOYJYTdekJppLI,3501
|
56
|
+
nucliadb/common/cluster/standalone/utils.py,sha256=af3r-x_GF7A6dwIAhZLR-r-SZQEVxsFrDKeMfUTA6G0,1908
|
67
57
|
nucliadb/common/context/__init__.py,sha256=gPwX1cZHPV9r-fLl3ZCZMYBTAwo6Q_xvSlQtd4qPd4c,3592
|
68
58
|
nucliadb/common/context/fastapi.py,sha256=j3HZ3lne6mIfw1eEar2het8RWzv6UruUZpXaKieSLOs,1527
|
69
59
|
nucliadb/common/datamanagers/__init__.py,sha256=U1cg-KvqbfzN5AnL_tFFrERmPb81w_0MNiTmxObmla4,2062
|
@@ -110,7 +100,7 @@ nucliadb/export_import/models.py,sha256=dbjScNkiMRv4X3Ktudy1JRliD25bfoDTy3JmEZgQ
|
|
110
100
|
nucliadb/export_import/tasks.py,sha256=fpCBeFYPReyLIdk38LDM9Tpnw_VczeMrobT4n1RAIp4,2507
|
111
101
|
nucliadb/export_import/utils.py,sha256=zrNrkkc9i3uT-R6Ju4J_0WNrzayln3KuQFCz-_qIaIA,19613
|
112
102
|
nucliadb/ingest/__init__.py,sha256=fsw3C38VP50km3R-nHL775LNGPpJ4JxqXJ2Ib1f5SqE,1011
|
113
|
-
nucliadb/ingest/app.py,sha256=
|
103
|
+
nucliadb/ingest/app.py,sha256=kZ8RgZNumzVEssVGnSZIh8jyCYKYotGhxBYz3EWx6Cc,7361
|
114
104
|
nucliadb/ingest/cache.py,sha256=w7jMMzamOmQ7gwXna6Dqm6isRNBVv6l5BTBlTxaYWjE,1005
|
115
105
|
nucliadb/ingest/partitions.py,sha256=2NIhMYbNT0TNBL6bX1UMSi7vxFGICstCKEqsB0TXHOE,2410
|
116
106
|
nucliadb/ingest/processing.py,sha256=gg1DqbMFwqdOsmCSGsZc2abRdYz86xOZJun9vrHOCzs,20618
|
@@ -119,13 +109,13 @@ nucliadb/ingest/serialize.py,sha256=13NcAP0Tw0zxMsjdudnSnedsg1YpiqFrA-TTIxQA6Ww,
|
|
119
109
|
nucliadb/ingest/settings.py,sha256=0B-wQNa8FLqtNcQgRzh-fuIuGptM816XHcbH1NQKfmE,3050
|
120
110
|
nucliadb/ingest/utils.py,sha256=l1myURu3r8oA11dx3GpHw-gNTUc1AFX8xdPm9Lgl2rA,2275
|
121
111
|
nucliadb/ingest/consumer/__init__.py,sha256=cp15ZcFnHvpcu_5-aK2A4uUyvuZVV_MJn4bIXMa20ks,835
|
122
|
-
nucliadb/ingest/consumer/auditing.py,sha256=
|
112
|
+
nucliadb/ingest/consumer/auditing.py,sha256=QLffHz49oz9h9P080oBB7eTBL4cqWI-JTTDeg3SmFQ8,7264
|
123
113
|
nucliadb/ingest/consumer/consumer.py,sha256=Lej1d6jqmaeR3vjzD0mnfKcVzZTT4TQ3lb1DOfyNWM4,14117
|
124
114
|
nucliadb/ingest/consumer/materializer.py,sha256=7ofLbwjldJA8TWXDRZRM4U5EviZt3qNSQ8oadmkzS0Y,3840
|
125
115
|
nucliadb/ingest/consumer/metrics.py,sha256=ji1l_4cKiHJthQd8YNem1ft4iMbw9KThmVvJmLcv3Xg,1075
|
126
116
|
nucliadb/ingest/consumer/pull.py,sha256=EYT0ImngMQgatStG68p2GSrPQBbJxeuq8nFm8DdAbwk,9280
|
127
117
|
nucliadb/ingest/consumer/service.py,sha256=EZM1sABW_7bj6j2UgKUHUuK-EGIEYnLdtPAn8agfWz0,7110
|
128
|
-
nucliadb/ingest/consumer/shard_creator.py,sha256=
|
118
|
+
nucliadb/ingest/consumer/shard_creator.py,sha256=8SotMc-o_G8XZU52gR4Aay7tcigTdIXgz8YtxqHmJ1Q,4309
|
129
119
|
nucliadb/ingest/consumer/utils.py,sha256=jpX8D4lKzuPCpArQLZeX_Zczq3pfen_zAf8sPJfOEZU,2642
|
130
120
|
nucliadb/ingest/fields/__init__.py,sha256=cp15ZcFnHvpcu_5-aK2A4uUyvuZVV_MJn4bIXMa20ks,835
|
131
121
|
nucliadb/ingest/fields/base.py,sha256=b6QpVPsCiDirDiYG3-yOCMaSNznJSHmQB0z6J_eDIyw,20657
|
@@ -138,7 +128,7 @@ nucliadb/ingest/fields/text.py,sha256=tFvSQJAe0W7ePpp2_WDfLiE2yglR1OTU0Zht9acvOF
|
|
138
128
|
nucliadb/ingest/orm/__init__.py,sha256=cp15ZcFnHvpcu_5-aK2A4uUyvuZVV_MJn4bIXMa20ks,835
|
139
129
|
nucliadb/ingest/orm/brain.py,sha256=UND5EsNUdd7XdjScYqRqg4r_xCx3l-My8alGw5M9CWg,28398
|
140
130
|
nucliadb/ingest/orm/broker_message.py,sha256=ZEMueoGuuRKO4tHgzc0P0AM1Ls1TTYey_4UvRQf0BpY,6915
|
141
|
-
nucliadb/ingest/orm/entities.py,sha256=
|
131
|
+
nucliadb/ingest/orm/entities.py,sha256=5d6Gfo-Yz-rns_mNJeRqiGaPeWpUMgSKZnmWIGMLCKo,15537
|
142
132
|
nucliadb/ingest/orm/exceptions.py,sha256=k4Esv4NtL4TrGTcsQpwrSfDhPQpiYcRbB1SpYmBX5MY,1432
|
143
133
|
nucliadb/ingest/orm/knowledgebox.py,sha256=XefDz6YsA0DLMS6T5W8P3VMFTkwr13bIae2ot7wAFpE,25259
|
144
134
|
nucliadb/ingest/orm/metrics.py,sha256=OkwMSPKLZcKba0ZTwtTiIxwBgaLMX5ydhGieKvi2y7E,1096
|
@@ -166,7 +156,7 @@ nucliadb/migrator/utils.py,sha256=NgUreUvON8_nWEzTxELBMWlfV7E6-6qi-g0DMEbVEz4,28
|
|
166
156
|
nucliadb/models/__init__.py,sha256=cp15ZcFnHvpcu_5-aK2A4uUyvuZVV_MJn4bIXMa20ks,835
|
167
157
|
nucliadb/models/responses.py,sha256=qnuOoc7TrVSUnpikfTwHLKez47_DE4mSFzpxrwtqijA,1599
|
168
158
|
nucliadb/purge/__init__.py,sha256=ijcigiWz38ohXmVVwDU87aCki1BkmAIQRjDoNQ3LPRM,11647
|
169
|
-
nucliadb/purge/orphan_shards.py,sha256=
|
159
|
+
nucliadb/purge/orphan_shards.py,sha256=7Qm5PFscGr5ihcn5YZ9BaDh6shagkYouv8Z_tTzLuM8,9222
|
170
160
|
nucliadb/reader/__init__.py,sha256=C5Efic7WlGm2U2C5WOyquMFbIj2Pojwe_8mwzVYnOzE,1304
|
171
161
|
nucliadb/reader/app.py,sha256=Se-BFTE6d1v1msLzQn4q5XIhjnSxa2ckDSHdvm7NRf8,3096
|
172
162
|
nucliadb/reader/lifecycle.py,sha256=5jYyzMD1tpIh-OYbQoNMjKZ0-3D9KFnULa3B_Vf2xyY,1740
|
@@ -189,7 +179,7 @@ nucliadb/search/__init__.py,sha256=tnypbqcH4nBHbGpkINudhKgdLKpwXQCvDtPchUlsyY4,1
|
|
189
179
|
nucliadb/search/app.py,sha256=6UV7rO0f3w5bNFXLdQM8bwUwXayMGnM4hF6GGv7WPv4,4260
|
190
180
|
nucliadb/search/lifecycle.py,sha256=DW8v4WUi4rZqc7xTOi3rE67W7877WG7fH9oTZbolHdE,2099
|
191
181
|
nucliadb/search/openapi.py,sha256=t3Wo_4baTrfPftg2BHsyLWNZ1MYn7ZRdW7ht-wFOgRs,1016
|
192
|
-
nucliadb/search/predict.py,sha256=
|
182
|
+
nucliadb/search/predict.py,sha256=EWOiWVUX9U_TE19Cl6bpCr6Mjs7hjuvCcG26C7e6KnQ,20919
|
193
183
|
nucliadb/search/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
194
184
|
nucliadb/search/run.py,sha256=aFb-CXRi_C8YMpP_ivNj8KW1BYhADj88y8K9Lr_nUPI,1402
|
195
185
|
nucliadb/search/settings.py,sha256=vem3EcyYlTPSim0kEK-xe-erF4BZg0CT_LAb8ZRQAE8,1684
|
@@ -200,7 +190,7 @@ nucliadb/search/api/v1/ask.py,sha256=Od2U_gaOZK6dJZ1eDGQQJ3xUVnbBih58VPYVAsQErOw
|
|
200
190
|
nucliadb/search/api/v1/catalog.py,sha256=ubYPS1wmPHzOgH9LR0qJmmV-9ELZPtHRSs5TYJ1pA9A,7117
|
201
191
|
nucliadb/search/api/v1/feedback.py,sha256=kNLc4dHz2SXHzV0PwC1WiRAwY88fDptPcP-kO0q-FrQ,2620
|
202
192
|
nucliadb/search/api/v1/find.py,sha256=DsnWkySu_cFajDWJIxN8DYvLL_Rm2yiCjHD8TsqPfRk,9304
|
203
|
-
nucliadb/search/api/v1/knowledgebox.py,sha256=
|
193
|
+
nucliadb/search/api/v1/knowledgebox.py,sha256=Hrt2h-28DDlwN3AdjMZPTYI6om0RMy9bmJvqVHvw8sE,8620
|
204
194
|
nucliadb/search/api/v1/predict_proxy.py,sha256=QrGzo0hKjtmyGZ6pjlJHYAh4hxwVUIOTcVcerRCw7eE,3047
|
205
195
|
nucliadb/search/api/v1/router.py,sha256=mtT07rBZcVfpa49doaw9b1tj3sdi3qLH0gn9Io6NYM0,988
|
206
196
|
nucliadb/search/api/v1/search.py,sha256=vCj5V9kozoti0JrgU_XJhTcBucWzI4SY1B0yCSj9EQw,13638
|
@@ -211,7 +201,7 @@ nucliadb/search/api/v1/resource/__init__.py,sha256=cp15ZcFnHvpcu_5-aK2A4uUyvuZVV
|
|
211
201
|
nucliadb/search/api/v1/resource/ask.py,sha256=XMEP9_Uwy37yaXLcIYKMXGiZYNASD8RTByzQGjd9LPQ,3847
|
212
202
|
nucliadb/search/api/v1/resource/search.py,sha256=X0rQU14r_s4_CPpoE2sc84AJPX68gvCftcP4bosWHhA,4812
|
213
203
|
nucliadb/search/requesters/__init__.py,sha256=itSI7dtTwFP55YMX4iK7JzdMHS5CQVUiB1XzQu4UBh8,833
|
214
|
-
nucliadb/search/requesters/utils.py,sha256=
|
204
|
+
nucliadb/search/requesters/utils.py,sha256=ZTiWDkDihJ7rcvs7itCe8hr6OclVcvu_2EAPFeyGhF4,8389
|
215
205
|
nucliadb/search/search/__init__.py,sha256=cp15ZcFnHvpcu_5-aK2A4uUyvuZVV_MJn4bIXMa20ks,835
|
216
206
|
nucliadb/search/search/cache.py,sha256=n9vkN6Y6Xnr2RBJyoH0WzjzGTJOMfKekU9tfPTWWCPc,6810
|
217
207
|
nucliadb/search/search/cut.py,sha256=ytY0_GY7ocNjfxTb4aosxEp4ZfhQNDP--JkhEMGD298,1153
|
@@ -230,15 +220,15 @@ nucliadb/search/search/predict_proxy.py,sha256=xBlh6kjuQpWRq7KsBx4pEl2PtnwljjQIi
|
|
230
220
|
nucliadb/search/search/query.py,sha256=CbCLdkBgD1XRVXN5qgT1rforf28cLNXvKbjbZzQYmUA,38051
|
231
221
|
nucliadb/search/search/rank_fusion.py,sha256=tRGo_KlsFsVx1CQEy1iqQ6f0T1Dq1kf0axDXHuuzvvM,6946
|
232
222
|
nucliadb/search/search/rerankers.py,sha256=0kAHES9X_FKkP7KSN9NRETFmRPKzwrFAo_54MbyvM7Q,9051
|
233
|
-
nucliadb/search/search/shards.py,sha256=
|
223
|
+
nucliadb/search/search/shards.py,sha256=JSRSrHgHcF4sXyuZZoJdMfK0v_LHpoSRf1lCr5-K5ko,2742
|
234
224
|
nucliadb/search/search/summarize.py,sha256=ksmYPubEQvAQgfPdZHfzB_rR19B2ci4IYZ6jLdHxZo8,4996
|
235
225
|
nucliadb/search/search/utils.py,sha256=iF2tbBA56gRMJH1TlE2hMrqeXqjoeOPt4KgRdp2m9Ek,3313
|
236
226
|
nucliadb/search/search/chat/__init__.py,sha256=cp15ZcFnHvpcu_5-aK2A4uUyvuZVV_MJn4bIXMa20ks,835
|
237
|
-
nucliadb/search/search/chat/ask.py,sha256=
|
227
|
+
nucliadb/search/search/chat/ask.py,sha256=tE1Q5V58oLMCo-T9s0N6Kko-1RWn1e4kHfbbPBsD2uU,36266
|
238
228
|
nucliadb/search/search/chat/exceptions.py,sha256=Siy4GXW2L7oPhIR86H3WHBhE9lkV4A4YaAszuGGUf54,1356
|
239
229
|
nucliadb/search/search/chat/images.py,sha256=PA8VWxT5_HUGfW1ULhKTK46UBsVyINtWWqEM1ulzX1E,3095
|
240
230
|
nucliadb/search/search/chat/prompt.py,sha256=r2JTiRWH3YHPdeRAG5w6gD0g0fWVxdTjYIR86qAVa7k,47106
|
241
|
-
nucliadb/search/search/chat/query.py,sha256=
|
231
|
+
nucliadb/search/search/chat/query.py,sha256=y7W5VuKl1XiZuNsxZIcxxHcFXSG6It2W5CoftZ-ekAc,15428
|
242
232
|
nucliadb/search/search/query_parser/__init__.py,sha256=cp15ZcFnHvpcu_5-aK2A4uUyvuZVV_MJn4bIXMa20ks,835
|
243
233
|
nucliadb/search/search/query_parser/exceptions.py,sha256=tuzl7ZyvVsRz6u0_3zMe60vx39nd3pi641prs-5nC0E,872
|
244
234
|
nucliadb/search/search/query_parser/models.py,sha256=-VlCDXUCgOroAZw1Leqhj2VMgRv_CD2w40PXXOBLaUM,2332
|
@@ -248,7 +238,7 @@ nucliadb/standalone/api_router.py,sha256=zR03TQ-Pd2kXx1jeV83Puw19112Z8Jhln7p1cAn
|
|
248
238
|
nucliadb/standalone/app.py,sha256=mAApNK_iVsQgJyd-mtwCeZq5csSimwnXmlQGH9a70pE,5586
|
249
239
|
nucliadb/standalone/auth.py,sha256=UwMv-TywhMZabvVg3anQLeCRdoHDnWf2o3luvnoNBjs,7670
|
250
240
|
nucliadb/standalone/config.py,sha256=g9JBJQfyw87TYZ3yuy0O9WFVLd_MmCJxSRSI0E8FwZE,5396
|
251
|
-
nucliadb/standalone/introspect.py,sha256=
|
241
|
+
nucliadb/standalone/introspect.py,sha256=xHdHV-CB0Vy5cp1MQAodu0Pc8izpzl_lX2ARJJwL3RI,6083
|
252
242
|
nucliadb/standalone/lifecycle.py,sha256=rdKLG-oOLN4rfd2VGG_2vlDUWYneWSCiuEhoeiFKfnM,2343
|
253
243
|
nucliadb/standalone/migrations.py,sha256=s9-3RSZ-O3bjEw2TnBe_YWLUEKbub0bARUxi1gA3yuY,1950
|
254
244
|
nucliadb/standalone/purge.py,sha256=ZY-cebb214FFiPG7OFmXZGg0G3CK5Amw0FLLm9WJhKE,1343
|
@@ -272,9 +262,9 @@ nucliadb/tests/vectors.py,sha256=CcNKx-E8LPpyvRyljbmb-Tn_wST9Juw2CBoogWrKiTk,628
|
|
272
262
|
nucliadb/train/__init__.py,sha256=NVwe5yULoHXb80itIJT8YJYEz2xbiOPQ7_OMys6XJw8,1301
|
273
263
|
nucliadb/train/app.py,sha256=TiRttTvekLuZdIvi46E4HyuumDTkR4G4Luqq3fEdjes,2824
|
274
264
|
nucliadb/train/generator.py,sha256=0_zqWsLUHmJZl0lXhGorO5CWSkl42-k78dqb1slZ5h0,3904
|
275
|
-
nucliadb/train/lifecycle.py,sha256=
|
265
|
+
nucliadb/train/lifecycle.py,sha256=dWnFuo-nYaWd6uayregmakQaZbQFdtVJReJONhYAQYI,1581
|
276
266
|
nucliadb/train/models.py,sha256=BmgmMjDsu_1Ih5JDAqo6whhume90q0ASJcDP9dkMQm8,1198
|
277
|
-
nucliadb/train/nodes.py,sha256=
|
267
|
+
nucliadb/train/nodes.py,sha256=HROQMRw2g5sJTnuBagh3B0id3iWonRJ68tg3skOme9k,5748
|
278
268
|
nucliadb/train/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
279
269
|
nucliadb/train/resource.py,sha256=3qQ_9Zdt5JAbtD-wpmt7OeDGRNKS-fQdKAuIQfznZm0,16219
|
280
270
|
nucliadb/train/run.py,sha256=evz6CKVfJOzkbHMoaYz2mTMlKjJnNOb1O8zBBWMpeBw,1400
|
@@ -302,13 +292,13 @@ nucliadb/train/generators/token_classifier.py,sha256=Vl14aaWoqrgYPijmvM62OjxDdAN
|
|
302
292
|
nucliadb/train/generators/utils.py,sha256=1uSELmM4CpKy9jWp6j_u7_n_KR-udRNkes4UmPMOCcI,3907
|
303
293
|
nucliadb/writer/__init__.py,sha256=S298mrZL3vr62OrBqi97mdLxgR5cReMlRJgnaQHZV7s,1304
|
304
294
|
nucliadb/writer/app.py,sha256=ABBO8-u4pDAa61b3mCdD0TFhuHAYcxMkgpZSGgWARuE,2736
|
305
|
-
nucliadb/writer/back_pressure.py,sha256=
|
295
|
+
nucliadb/writer/back_pressure.py,sha256=JaiC2JAugVA92gDHzABZFiuQexiOKZC9C-3Jn9VF-M0,17898
|
306
296
|
nucliadb/writer/exceptions.py,sha256=-Z7LW--eid7PNeKFuzo9kAlbLEBMUosxE-UVIgGD3SA,929
|
307
297
|
nucliadb/writer/lifecycle.py,sha256=OYyhUZ1ejlybPzO-O_EsInjdifKiPiEzooy2d_2DW3k,2550
|
308
298
|
nucliadb/writer/openapi.py,sha256=thqCO1ht_RJgOkXs-aIsv8aXJrU5z8wo2n05l2_LqMs,1032
|
309
299
|
nucliadb/writer/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
310
300
|
nucliadb/writer/run.py,sha256=euVZ_rtHDXs-O1kB-Pt1Id8eft9CYVpWH3zJzEoEqls,1448
|
311
|
-
nucliadb/writer/settings.py,sha256=
|
301
|
+
nucliadb/writer/settings.py,sha256=pA9aMAvY8H6zvsxAOdGY8SZLrThDvJ8KLhluGI0GxnQ,3288
|
312
302
|
nucliadb/writer/utilities.py,sha256=AZ5qEny1Xm0IDsFtH13oJa2usvJZK8f0FdgF1LrnLCw,1036
|
313
303
|
nucliadb/writer/vectorsets.py,sha256=18XJvsyi0-tePQWig8dl5qaNPaufEZb0-uD22IAOTa0,5648
|
314
304
|
nucliadb/writer/api/__init__.py,sha256=cp15ZcFnHvpcu_5-aK2A4uUyvuZVV_MJn4bIXMa20ks,835
|
@@ -340,9 +330,9 @@ nucliadb/writer/tus/local.py,sha256=7jYa_w9b-N90jWgN2sQKkNcomqn6JMVBOVeDOVYJHto,
|
|
340
330
|
nucliadb/writer/tus/s3.py,sha256=vF0NkFTXiXhXq3bCVXXVV-ED38ECVoUeeYViP8uMqcU,8357
|
341
331
|
nucliadb/writer/tus/storage.py,sha256=ToqwjoYnjI4oIcwzkhha_MPxi-k4Jk3Lt55zRwaC1SM,2903
|
342
332
|
nucliadb/writer/tus/utils.py,sha256=MSdVbRsRSZVdkaum69_0wku7X3p5wlZf4nr6E0GMKbw,2556
|
343
|
-
nucliadb-6.2.1.
|
344
|
-
nucliadb-6.2.1.
|
345
|
-
nucliadb-6.2.1.
|
346
|
-
nucliadb-6.2.1.
|
347
|
-
nucliadb-6.2.1.
|
348
|
-
nucliadb-6.2.1.
|
333
|
+
nucliadb-6.2.1.post2972.dist-info/METADATA,sha256=YnrbW19LMC5vJsf6nRuyDwUNVBFivf8KQJnvl2xeMro,4603
|
334
|
+
nucliadb-6.2.1.post2972.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
335
|
+
nucliadb-6.2.1.post2972.dist-info/entry_points.txt,sha256=XqGfgFDuY3zXQc8ewXM2TRVjTModIq851zOsgrmaXx4,1268
|
336
|
+
nucliadb-6.2.1.post2972.dist-info/top_level.txt,sha256=hwYhTVnX7jkQ9gJCkVrbqEG1M4lT2F_iPQND1fCzF80,20
|
337
|
+
nucliadb-6.2.1.post2972.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
338
|
+
nucliadb-6.2.1.post2972.dist-info/RECORD,,
|
@@ -1,19 +0,0 @@
|
|
1
|
-
# Copyright (C) 2021 Bosutech XXI S.L.
|
2
|
-
#
|
3
|
-
# nucliadb is offered under the AGPL v3.0 and as commercial software.
|
4
|
-
# For commercial licensing, contact us at info@nuclia.com.
|
5
|
-
#
|
6
|
-
# AGPL:
|
7
|
-
# This program is free software: you can redistribute it and/or modify
|
8
|
-
# it under the terms of the GNU Affero General Public License as
|
9
|
-
# published by the Free Software Foundation, either version 3 of the
|
10
|
-
# License, or (at your option) any later version.
|
11
|
-
#
|
12
|
-
# This program is distributed in the hope that it will be useful,
|
13
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
-
# GNU Affero General Public License for more details.
|
16
|
-
#
|
17
|
-
# You should have received a copy of the GNU Affero General Public License
|
18
|
-
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
19
|
-
#
|
@@ -1,178 +0,0 @@
|
|
1
|
-
# Copyright (C) 2021 Bosutech XXI S.L.
|
2
|
-
#
|
3
|
-
# nucliadb is offered under the AGPL v3.0 and as commercial software.
|
4
|
-
# For commercial licensing, contact us at info@nuclia.com.
|
5
|
-
#
|
6
|
-
# AGPL:
|
7
|
-
# This program is free software: you can redistribute it and/or modify
|
8
|
-
# it under the terms of the GNU Affero General Public License as
|
9
|
-
# published by the Free Software Foundation, either version 3 of the
|
10
|
-
# License, or (at your option) any later version.
|
11
|
-
#
|
12
|
-
# This program is distributed in the hope that it will be useful,
|
13
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
-
# GNU Affero General Public License for more details.
|
16
|
-
#
|
17
|
-
# You should have received a copy of the GNU Affero General Public License
|
18
|
-
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
19
|
-
#
|
20
|
-
import abc
|
21
|
-
import asyncio
|
22
|
-
import logging
|
23
|
-
|
24
|
-
import backoff
|
25
|
-
from grpc.aio import AioRpcError
|
26
|
-
|
27
|
-
from nucliadb.common.cluster import manager
|
28
|
-
from nucliadb.common.cluster.discovery.types import IndexNodeMetadata
|
29
|
-
from nucliadb.common.cluster.exceptions import NodeConnectionError
|
30
|
-
from nucliadb.common.cluster.settings import Settings
|
31
|
-
from nucliadb_protos import (
|
32
|
-
noderesources_pb2,
|
33
|
-
nodewriter_pb2,
|
34
|
-
nodewriter_pb2_grpc,
|
35
|
-
replication_pb2_grpc,
|
36
|
-
standalone_pb2,
|
37
|
-
standalone_pb2_grpc,
|
38
|
-
)
|
39
|
-
from nucliadb_telemetry import metrics
|
40
|
-
from nucliadb_utils.grpc import get_traced_grpc_channel
|
41
|
-
|
42
|
-
logger = logging.getLogger(__name__)
|
43
|
-
|
44
|
-
AVAILABLE_NODES = metrics.Gauge("nucliadb_nodes_available")
|
45
|
-
|
46
|
-
|
47
|
-
def update_members(members: list[IndexNodeMetadata]) -> None:
|
48
|
-
# First add new nodes or update existing ones
|
49
|
-
valid_ids = []
|
50
|
-
for member in members:
|
51
|
-
valid_ids.append(member.node_id)
|
52
|
-
|
53
|
-
shard_count = member.shard_count
|
54
|
-
if shard_count is None:
|
55
|
-
shard_count = 0
|
56
|
-
logger.warning(f"Node {member.node_id} has no shard_count")
|
57
|
-
|
58
|
-
node = manager.get_index_node(member.node_id)
|
59
|
-
if node is None:
|
60
|
-
logger.debug(f"{member.node_id} add {member.address}")
|
61
|
-
manager.add_index_node(
|
62
|
-
id=member.node_id,
|
63
|
-
address=member.address,
|
64
|
-
shard_count=shard_count,
|
65
|
-
available_disk=member.available_disk,
|
66
|
-
primary_id=member.primary_id,
|
67
|
-
)
|
68
|
-
logger.debug("Node added")
|
69
|
-
else:
|
70
|
-
logger.debug(f"{member.node_id} update")
|
71
|
-
node.address = member.address
|
72
|
-
node.shard_count = shard_count
|
73
|
-
node.available_disk = member.available_disk
|
74
|
-
logger.debug("Node updated")
|
75
|
-
|
76
|
-
# Then cleanup nodes that are no longer reported
|
77
|
-
node_ids = [x.id for x in manager.get_index_nodes()]
|
78
|
-
removed_node_ids = []
|
79
|
-
for key in node_ids:
|
80
|
-
if key not in valid_ids:
|
81
|
-
node = manager.get_index_node(key)
|
82
|
-
if node is not None:
|
83
|
-
removed_node_ids.append(key)
|
84
|
-
logger.warning(f"{key} remove {node.address}")
|
85
|
-
manager.remove_index_node(key, node.primary_id)
|
86
|
-
|
87
|
-
if len(removed_node_ids) > 1:
|
88
|
-
logger.warning(
|
89
|
-
f"{len(removed_node_ids)} nodes are down simultaneously. This should never happen!"
|
90
|
-
)
|
91
|
-
|
92
|
-
AVAILABLE_NODES.set(len(manager.get_index_nodes()))
|
93
|
-
|
94
|
-
|
95
|
-
@backoff.on_exception(backoff.constant, (Exception,), interval=0.5, max_tries=2)
|
96
|
-
async def _get_index_node_metadata(
|
97
|
-
settings: Settings, address: str, read_replica: bool = False
|
98
|
-
) -> IndexNodeMetadata:
|
99
|
-
"""
|
100
|
-
Get node metadata directly from the writer.
|
101
|
-
|
102
|
-
Establishes a new connection on every try on purpose to avoid long lived connections
|
103
|
-
and dns caching issues.
|
104
|
-
|
105
|
-
This method should be used carefully and results should be cached.
|
106
|
-
"""
|
107
|
-
if address in settings.writer_port_map:
|
108
|
-
# test wiring
|
109
|
-
port = settings.writer_port_map[address]
|
110
|
-
grpc_address = f"localhost:{port}"
|
111
|
-
else:
|
112
|
-
grpc_address = f"{address}:{settings.node_writer_port}"
|
113
|
-
channel = get_traced_grpc_channel(grpc_address, "discovery", variant="_writer")
|
114
|
-
if read_replica:
|
115
|
-
# on a read replica, we need to use the replication service
|
116
|
-
stub = replication_pb2_grpc.ReplicationServiceStub(channel)
|
117
|
-
else:
|
118
|
-
stub = nodewriter_pb2_grpc.NodeWriterStub(channel) # type: ignore
|
119
|
-
try:
|
120
|
-
metadata: nodewriter_pb2.NodeMetadata = await stub.GetMetadata(noderesources_pb2.EmptyQuery()) # type: ignore
|
121
|
-
except AioRpcError as exc:
|
122
|
-
raise NodeConnectionError() from exc
|
123
|
-
|
124
|
-
primary_id = (
|
125
|
-
getattr(metadata, "primary_node_id", None)
|
126
|
-
# the or None here is important because the proto returns an empty string
|
127
|
-
or None
|
128
|
-
)
|
129
|
-
if read_replica and primary_id is None:
|
130
|
-
raise Exception("Primary node id not found when it is expected to be a read replica")
|
131
|
-
|
132
|
-
return IndexNodeMetadata(
|
133
|
-
node_id=metadata.node_id,
|
134
|
-
name=metadata.node_id,
|
135
|
-
address=address,
|
136
|
-
shard_count=metadata.shard_count,
|
137
|
-
primary_id=primary_id,
|
138
|
-
available_disk=metadata.available_disk,
|
139
|
-
)
|
140
|
-
|
141
|
-
|
142
|
-
@backoff.on_exception(backoff.expo, (Exception,), jitter=backoff.random_jitter, max_tries=4)
|
143
|
-
async def _get_standalone_index_node_metadata(settings: Settings, address: str) -> IndexNodeMetadata:
|
144
|
-
if ":" not in address:
|
145
|
-
grpc_address = f"{address}:{settings.standalone_node_port}"
|
146
|
-
else:
|
147
|
-
grpc_address = address
|
148
|
-
channel = get_traced_grpc_channel(grpc_address, "standalone_proxy")
|
149
|
-
stub = standalone_pb2_grpc.StandaloneClusterServiceStub(channel)
|
150
|
-
resp: standalone_pb2.NodeInfoResponse = await stub.NodeInfo(standalone_pb2.NodeInfoRequest()) # type: ignore
|
151
|
-
return IndexNodeMetadata(
|
152
|
-
node_id=resp.id,
|
153
|
-
name=resp.id,
|
154
|
-
address=address,
|
155
|
-
shard_count=resp.shard_count,
|
156
|
-
available_disk=resp.available_disk,
|
157
|
-
)
|
158
|
-
|
159
|
-
|
160
|
-
class AbstractClusterDiscovery(abc.ABC):
|
161
|
-
task: asyncio.Task
|
162
|
-
|
163
|
-
def __init__(self, settings: Settings):
|
164
|
-
self.settings = settings
|
165
|
-
|
166
|
-
@abc.abstractmethod
|
167
|
-
async def initialize(self) -> None:
|
168
|
-
""" """
|
169
|
-
|
170
|
-
@abc.abstractmethod
|
171
|
-
async def finalize(self) -> None:
|
172
|
-
""" """
|
173
|
-
|
174
|
-
async def _query_node_metadata(self, address: str, read_replica: bool = False) -> IndexNodeMetadata:
|
175
|
-
if self.settings.standalone_mode:
|
176
|
-
return await _get_standalone_index_node_metadata(self.settings, address)
|
177
|
-
else:
|
178
|
-
return await _get_index_node_metadata(self.settings, address, read_replica)
|