Deadlock resolver support

This commit is contained in:
Emilia Allison 2024-01-11 11:40:26 -05:00
parent 51fa9b6409
commit f6ba365dbe
Signed by: emilia
GPG Key ID: 05D5D1107E5100A1
3 changed files with 46 additions and 2 deletions

View File

@ -134,6 +134,24 @@ class AdgClient:
storage_res.stdout, storage_res.stdout,
storage_res.args) 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: def _create_unique_database_name(self, prefix: str) -> str:
MAX_ATTEMPTS = 100 MAX_ATTEMPTS = 100
databases = self.get_databases() databases = self.get_databases()

View File

@ -9,7 +9,8 @@ class CommandType(StrEnum):
NEWDB = auto(), NEWDB = auto(),
NORMAL = auto(), NORMAL = auto(),
NEWSYSTEM = auto(), NEWSYSTEM = auto(),
HOTEL = auto() HOTEL = auto(),
DEADLOCK = auto()
class Command(): class Command():
@ -25,6 +26,8 @@ class Command():
self._init_system(**kwargs) self._init_system(**kwargs)
elif self.type == CommandType.HOTEL: elif self.type == CommandType.HOTEL:
self._init_hotel(**kwargs) self._init_hotel(**kwargs)
elif self.type == CommandType.DEADLOCK:
self._init_deadlock(**kwargs)
except KeyError as e: except KeyError as e:
raise Exception("Required argument not found!", e) raise Exception("Required argument not found!", e)
@ -38,6 +41,8 @@ class Command():
self._execute_newsystem(client, cache) self._execute_newsystem(client, cache)
case CommandType.HOTEL: case CommandType.HOTEL:
self._execute_hotel(client, cache) self._execute_hotel(client, cache)
case CommandType.DEADLOCK:
self._execute_deadlock(client, cache)
def _init_newdb(self, **kwargs): def _init_newdb(self, **kwargs):
self.name = kwargs["name"] self.name = kwargs["name"]
@ -75,6 +80,17 @@ class Command():
+ f"{storage_type_str} not in " + f"{storage_type_str} not in "
+ "{RANDOM,SERIAL}") + "{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): def _init_system(self, **kwargs):
if "name" in kwargs: if "name" in kwargs:
self.name = kwargs["name"] self.name = kwargs["name"]
@ -121,7 +137,16 @@ class Command():
self.location, self.location,
self.envelope, self.envelope,
rows=self.rows if hasattr(self, "rows") else -1, 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 ""
) )

1
test
View File

@ -2,3 +2,4 @@ newdb;name=horsedb
newsystem; newsystem;
normal;name=PlateOrient 1.1;location=0;envelope=1;device=HRB.PlateOrient normal;name=PlateOrient 1.1;location=0;envelope=1;device=HRB.PlateOrient
hotel;name=PlateHotel 1.1;location=100;envelope=1;rows=8;storage_type=random hotel;name=PlateHotel 1.1;location=100;envelope=1;rows=8;storage_type=random
deadlock;name = Deadlock Resolver 1.1;location=70;envelope=1