|
124 | 124 | import threading
|
125 | 125 | import time
|
126 | 126 |
|
| 127 | +from typing import Dict |
127 | 128 | from dlg.common import CategoryType
|
128 | 129 | from . import registry
|
129 | 130 | from .hsm import manager
|
@@ -229,8 +230,8 @@ def __init__(
|
229 | 230 | # instead of _drops.itervalues() to get a full, thread-safe copy of the
|
230 | 231 | # dictionary values. Maybe there's a better approach for thread-safety
|
231 | 232 | # here
|
232 |
| - self._drops: dict[str, AbstractDROP] = {} |
233 |
| - |
| 233 | + self._drops: Dict[str, AbstractDROP] = {} |
| 234 | + self._serviceDrops: Dict[str, AbstractDROP] = {} |
234 | 235 | self._check_period = check_period
|
235 | 236 | self._cleanup_period = cleanup_period
|
236 | 237 | self._drop_checker = None
|
@@ -334,6 +335,12 @@ def _disappeared(self, drop):
|
334 | 335 |
|
335 | 336 | def deleteLostDrops(self):
|
336 | 337 |
|
| 338 | + for sd in self._serviceDrops.values(): |
| 339 | + if sd.status == DROPStates.INITIALIZED: |
| 340 | + logger.info("No need to delete lost drops whilst Service Drops are " |
| 341 | + "starting up...") |
| 342 | + return |
| 343 | + |
337 | 344 | toRemove = []
|
338 | 345 | for drop in self._drops.values():
|
339 | 346 |
|
@@ -465,15 +472,9 @@ def addDrop(self, drop: AbstractDROP):
|
465 | 472 | drop.phase = DROPPhases.GAS
|
466 | 473 | drop.subscribe(self._listener)
|
467 | 474 |
|
468 |
| - # if drop.CategoryType == CategoryType.SERVICE: |
469 |
| - # connection = drop.getIO().exists() |
470 |
| - # continue |
471 |
| - #TODO LOOK HERE FOR SETTING UP SERVICES BASED ON THE DROP |
472 |
| - # if drop.persist: |
473 |
| - # self._updatePersistentStore(drop) |
474 |
| - |
475 |
| - if drop.CategoryType == CategoryType.SERVICE: # and self._hsm: |
476 |
| - print("We are in the DLM!") |
| 475 | + if drop.CategoryType == CategoryType.SERVICE: # and self._hsm: |
| 476 | + print("Tracking ServiceDROPS in the DLM...") |
| 477 | + self._serviceDrops[drop.uid] = drop |
477 | 478 | # self._hsm.addStore(drop.store)
|
478 | 479 |
|
479 | 480 | self._reg.addDrop(drop)
|
@@ -509,16 +510,18 @@ def handleCompletedDrop(self, uid):
|
509 | 510 |
|
510 | 511 | if not self._enable_drop_replication:
|
511 | 512 | return
|
512 |
| - |
513 |
| - drop = self._drops[uid] |
514 |
| - if drop.persist and self.isReplicable(drop): |
515 |
| - logger.debug( |
516 |
| - "Replicating %r because it's marked to be persisted", drop |
517 |
| - ) |
518 |
| - try: |
519 |
| - self.replicateDrop(drop) |
520 |
| - except: |
521 |
| - logger.exception("Problem while replicating %r", drop) |
| 513 | + try: |
| 514 | + drop = self._drops[uid] |
| 515 | + if drop.persist and self.isReplicable(drop): |
| 516 | + logger.debug( |
| 517 | + "Replicating %r because it's marked to be persisted", drop |
| 518 | + ) |
| 519 | + try: |
| 520 | + self.replicateDrop(drop) |
| 521 | + except: |
| 522 | + logger.exception("Problem while replicating %r", drop) |
| 523 | + except KeyError: |
| 524 | + logger.warning("Drop %s was removed from DLM early!", uid) |
522 | 525 |
|
523 | 526 | def isReplicable(self, drop):
|
524 | 527 | return not isinstance(drop, ContainerDROP)
|
|
0 commit comments