blob_store_actions.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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. import time
  10. from materialize.mzcompose.composition import Composition
  11. from materialize.zippy.blob_store_capabilities import BlobStoreIsRunning
  12. from materialize.zippy.framework import Action, Capability, State
  13. class BlobStoreStart(Action):
  14. """Starts a BlobStore instance."""
  15. def run(self, c: Composition, state: State) -> None:
  16. c.up(c.blob_store())
  17. def provides(self) -> list[Capability]:
  18. return [BlobStoreIsRunning()]
  19. class BlobStoreRestart(Action):
  20. """Restart the BlobStore instance."""
  21. @classmethod
  22. def requires(cls) -> set[type[Capability]]:
  23. return {BlobStoreIsRunning}
  24. def run(self, c: Composition, state: State) -> None:
  25. blob_store = c.blob_store()
  26. c.kill(blob_store)
  27. time.sleep(1)
  28. c.up(blob_store)