|
|
@ -51,22 +51,23 @@ class DBPortManager(object): |
|
|
|
|
|
|
|
|
|
|
|
def pop(self, db: Application): |
|
|
|
def pop(self, db: Application): |
|
|
|
mapper = self.get_mapper() |
|
|
|
mapper = self.get_mapper() |
|
|
|
to_delete_port = self.get_port_by_db(db) |
|
|
|
to_delete_port = self.get_port_by_db(db, raise_exception=False) |
|
|
|
mapper.pop(to_delete_port, None) |
|
|
|
mapper.pop(to_delete_port, None) |
|
|
|
self.set_mapper(mapper) |
|
|
|
self.set_mapper(mapper) |
|
|
|
|
|
|
|
|
|
|
|
def get_port_by_db(self, db): |
|
|
|
def get_port_by_db(self, db, raise_exception=True): |
|
|
|
mapper = self.get_mapper() |
|
|
|
mapper = self.get_mapper() |
|
|
|
for port, db_id in mapper.items(): |
|
|
|
for port, db_id in mapper.items(): |
|
|
|
if db_id == str(db.id): |
|
|
|
if db_id == str(db.id): |
|
|
|
return port |
|
|
|
return port |
|
|
|
error = _( |
|
|
|
if raise_exception: |
|
|
|
'No available port is matched. ' |
|
|
|
error = _( |
|
|
|
'The number of databases may have exceeded the number of ports ' |
|
|
|
'No available port is matched. ' |
|
|
|
'open to the database agent service, ' |
|
|
|
'The number of databases may have exceeded the number of ports ' |
|
|
|
'Contact the administrator to open more ports.' |
|
|
|
'open to the database agent service, ' |
|
|
|
) |
|
|
|
'Contact the administrator to open more ports.' |
|
|
|
raise JMSException(error) |
|
|
|
) |
|
|
|
|
|
|
|
raise JMSException(error) |
|
|
|
|
|
|
|
|
|
|
|
def get_db_by_port(self, port): |
|
|
|
def get_db_by_port(self, port): |
|
|
|
try: |
|
|
|
try: |
|
|
|