def METHOD_NAME(self, mapper=None):
    if mapper is None:
        mapper = self.get_mapper()
    already_use_ports = [int(i) for i in mapper.keys()]
    avail_ports = sorted(list(set(self.all_avail_ports) - set(already_use_ports)))
    if len(avail_ports) <= 0:
        msg = _('No ports can be used, check and modify the limit on the number '
                'of ports that Magnus listens on in the configuration file.')
        tips = _('All available port count: {}, Already use port count: {}').format(
            len(self.all_avail_ports), len(already_use_ports)
        )
        error = msg + tips
        raise JMSException(error)
    port = avail_ports[0]
    logger.debug('Get next available port: {}'.format(port))
    return port