Deadlock resolver support
This commit is contained in:
parent
51fa9b6409
commit
f6ba365dbe
|
@ -134,6 +134,24 @@ class AdgClient:
|
|||
storage_res.stdout,
|
||||
storage_res.args)
|
||||
|
||||
def create_deadlock_resolver(self, name: str,
|
||||
location: int,
|
||||
envelope: int,
|
||||
system: str = ""):
|
||||
if not system:
|
||||
system = self.system_name
|
||||
|
||||
res = self._run(["csr",
|
||||
"-s", f"{system}",
|
||||
"-n", f"{name}",
|
||||
"-l", f"{location}",
|
||||
"-e", f"{envelope}",
|
||||
"-p", "deadlockresolver"])
|
||||
|
||||
if res.returncode > 0:
|
||||
raise Exception("Failed to create deadock resolver",
|
||||
res.stdout, res.args)
|
||||
|
||||
def _create_unique_database_name(self, prefix: str) -> str:
|
||||
MAX_ATTEMPTS = 100
|
||||
databases = self.get_databases()
|
||||
|
|
29
parser.py
29
parser.py
|
@ -9,7 +9,8 @@ class CommandType(StrEnum):
|
|||
NEWDB = auto(),
|
||||
NORMAL = auto(),
|
||||
NEWSYSTEM = auto(),
|
||||
HOTEL = auto()
|
||||
HOTEL = auto(),
|
||||
DEADLOCK = auto()
|
||||
|
||||
|
||||
class Command():
|
||||
|
@ -25,6 +26,8 @@ class Command():
|
|||
self._init_system(**kwargs)
|
||||
elif self.type == CommandType.HOTEL:
|
||||
self._init_hotel(**kwargs)
|
||||
elif self.type == CommandType.DEADLOCK:
|
||||
self._init_deadlock(**kwargs)
|
||||
except KeyError as e:
|
||||
raise Exception("Required argument not found!", e)
|
||||
|
||||
|
@ -38,6 +41,8 @@ class Command():
|
|||
self._execute_newsystem(client, cache)
|
||||
case CommandType.HOTEL:
|
||||
self._execute_hotel(client, cache)
|
||||
case CommandType.DEADLOCK:
|
||||
self._execute_deadlock(client, cache)
|
||||
|
||||
def _init_newdb(self, **kwargs):
|
||||
self.name = kwargs["name"]
|
||||
|
@ -75,6 +80,17 @@ class Command():
|
|||
+ f"{storage_type_str} not in "
|
||||
+ "{RANDOM,SERIAL}")
|
||||
|
||||
if "system" in kwargs:
|
||||
self.system = kwargs["system"]
|
||||
|
||||
def _init_deadlock(self, **kwargs):
|
||||
self.name = kwargs["name"]
|
||||
self.location = kwargs["location"]
|
||||
self.envelope = kwargs["location"]
|
||||
|
||||
if "system" in kwargs:
|
||||
self.system = kwargs["system"]
|
||||
|
||||
def _init_system(self, **kwargs):
|
||||
if "name" in kwargs:
|
||||
self.name = kwargs["name"]
|
||||
|
@ -121,7 +137,16 @@ class Command():
|
|||
self.location,
|
||||
self.envelope,
|
||||
rows=self.rows if hasattr(self, "rows") else -1,
|
||||
type=self.storage_type if hasattr(self, "storage_type") else None
|
||||
type=self.storage_type if hasattr(self, "storage_type") else None,
|
||||
system=self.system if hasattr(self, "system") else ""
|
||||
)
|
||||
|
||||
def _execute_deadlock(self, client: AdgClient, cache: Cache):
|
||||
client.create_deadlock_resolver(
|
||||
self.name,
|
||||
self.location,
|
||||
self.envelope,
|
||||
system=self.system if hasattr(self, "system") else ""
|
||||
)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue