storaged_actions.py 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. # Copyright Materialize, Inc. and contributors. All rights reserved.
  2. #
  3. # Use of this software is governed by the Business Source License
  4. # included in the LICENSE file at the root of this repository.
  5. #
  6. # As of the Change Date specified in that file, in accordance with
  7. # the Business Source License, use of this software will be governed
  8. # by the Apache License, Version 2.0.
  9. from materialize.mzcompose.composition import Composition
  10. from materialize.zippy.blob_store_capabilities import BlobStoreIsRunning
  11. from materialize.zippy.crdb_capabilities import CockroachIsRunning
  12. from materialize.zippy.framework import Action, Capability, State
  13. from materialize.zippy.mz_capabilities import MzIsRunning
  14. from materialize.zippy.storaged_capabilities import StoragedRunning
  15. class StoragedStart(Action):
  16. """Starts a storaged clusterd instance."""
  17. @classmethod
  18. def requires(cls) -> set[type[Capability]]:
  19. return {CockroachIsRunning, BlobStoreIsRunning}
  20. @classmethod
  21. def incompatible_with(cls) -> set[type[Capability]]:
  22. return {StoragedRunning}
  23. def run(self, c: Composition, state: State) -> None:
  24. c.up("storaged")
  25. def provides(self) -> list[Capability]:
  26. return [StoragedRunning()]
  27. class StoragedRestart(Action):
  28. """Restarts the entire storaged clusterd instance."""
  29. @classmethod
  30. def requires(cls) -> set[type[Capability]]:
  31. return {MzIsRunning, StoragedRunning}
  32. def run(self, c: Composition, state: State) -> None:
  33. c.kill("storaged")
  34. c.up("storaged")
  35. class StoragedKill(Action):
  36. @classmethod
  37. def requires(cls) -> set[type[Capability]]:
  38. return {MzIsRunning, StoragedRunning}
  39. def run(self, c: Composition, state: State) -> None:
  40. c.kill("storaged")
  41. def withholds(self) -> set[type[Capability]]:
  42. return {StoragedRunning}