diff options
Diffstat (limited to 'bitbake/lib/hashserv/server.py')
-rw-r--r-- | bitbake/lib/hashserv/server.py | 61 |
1 files changed, 38 insertions, 23 deletions
diff --git a/bitbake/lib/hashserv/server.py b/bitbake/lib/hashserv/server.py index 5ed852d1f3..68f64f983b 100644 --- a/bitbake/lib/hashserv/server.py +++ b/bitbake/lib/hashserv/server.py | |||
@@ -234,6 +234,7 @@ class ServerClient(bb.asyncrpc.AsyncServerConnection): | |||
234 | "get": self.handle_get, | 234 | "get": self.handle_get, |
235 | "get-outhash": self.handle_get_outhash, | 235 | "get-outhash": self.handle_get_outhash, |
236 | "get-stream": self.handle_get_stream, | 236 | "get-stream": self.handle_get_stream, |
237 | "exists-stream": self.handle_exists_stream, | ||
237 | "get-stats": self.handle_get_stats, | 238 | "get-stats": self.handle_get_stats, |
238 | "get-db-usage": self.handle_get_db_usage, | 239 | "get-db-usage": self.handle_get_db_usage, |
239 | "get-db-query-columns": self.handle_get_db_query_columns, | 240 | "get-db-query-columns": self.handle_get_db_query_columns, |
@@ -377,8 +378,7 @@ class ServerClient(bb.asyncrpc.AsyncServerConnection): | |||
377 | await self.db.insert_unihash(data["method"], data["taskhash"], data["unihash"]) | 378 | await self.db.insert_unihash(data["method"], data["taskhash"], data["unihash"]) |
378 | await self.db.insert_outhash(data) | 379 | await self.db.insert_outhash(data) |
379 | 380 | ||
380 | @permissions(READ_PERM) | 381 | async def _stream_handler(self, handler): |
381 | async def handle_get_stream(self, request): | ||
382 | await self.socket.send_message("ok") | 382 | await self.socket.send_message("ok") |
383 | 383 | ||
384 | while True: | 384 | while True: |
@@ -400,35 +400,50 @@ class ServerClient(bb.asyncrpc.AsyncServerConnection): | |||
400 | if l == "END": | 400 | if l == "END": |
401 | break | 401 | break |
402 | 402 | ||
403 | (method, taskhash) = l.split() | 403 | msg = await handler(l) |
404 | # self.logger.debug('Looking up %s %s' % (method, taskhash)) | ||
405 | row = await self.db.get_equivalent(method, taskhash) | ||
406 | |||
407 | if row is not None: | ||
408 | msg = row["unihash"] | ||
409 | # self.logger.debug('Found equivalent task %s -> %s', (row['taskhash'], row['unihash'])) | ||
410 | elif self.upstream_client is not None: | ||
411 | upstream = await self.upstream_client.get_unihash(method, taskhash) | ||
412 | if upstream: | ||
413 | msg = upstream | ||
414 | else: | ||
415 | msg = "" | ||
416 | else: | ||
417 | msg = "" | ||
418 | |||
419 | await self.socket.send(msg) | 404 | await self.socket.send(msg) |
420 | finally: | 405 | finally: |
421 | request_measure.end() | 406 | request_measure.end() |
422 | self.request_sample.end() | 407 | self.request_sample.end() |
423 | 408 | ||
424 | # Post to the backfill queue after writing the result to minimize | ||
425 | # the turn around time on a request | ||
426 | if upstream is not None: | ||
427 | await self.server.backfill_queue.put((method, taskhash)) | ||
428 | |||
429 | await self.socket.send("ok") | 409 | await self.socket.send("ok") |
430 | return self.NO_RESPONSE | 410 | return self.NO_RESPONSE |
431 | 411 | ||
412 | @permissions(READ_PERM) | ||
413 | async def handle_get_stream(self, request): | ||
414 | async def handler(l): | ||
415 | (method, taskhash) = l.split() | ||
416 | # self.logger.debug('Looking up %s %s' % (method, taskhash)) | ||
417 | row = await self.db.get_equivalent(method, taskhash) | ||
418 | |||
419 | if row is not None: | ||
420 | # self.logger.debug('Found equivalent task %s -> %s', (row['taskhash'], row['unihash'])) | ||
421 | return row["unihash"] | ||
422 | |||
423 | if self.upstream_client is not None: | ||
424 | upstream = await self.upstream_client.get_unihash(method, taskhash) | ||
425 | if upstream: | ||
426 | await self.server.backfill_queue.put((method, taskhash)) | ||
427 | return upstream | ||
428 | |||
429 | return "" | ||
430 | |||
431 | return await self._stream_handler(handler) | ||
432 | |||
433 | @permissions(READ_PERM) | ||
434 | async def handle_exists_stream(self, request): | ||
435 | async def handler(l): | ||
436 | if await self.db.unihash_exists(l): | ||
437 | return "true" | ||
438 | |||
439 | if self.upstream_client is not None: | ||
440 | if await self.upstream_client.unihash_exists(l): | ||
441 | return "true" | ||
442 | |||
443 | return "false" | ||
444 | |||
445 | return await self._stream_handler(handler) | ||
446 | |||
432 | async def report_readonly(self, data): | 447 | async def report_readonly(self, data): |
433 | method = data["method"] | 448 | method = data["method"] |
434 | outhash = data["outhash"] | 449 | outhash = data["outhash"] |