Ejemplo n.º 1
0
    def __init__(self, config, host, port, output_dir):

        with open(config, 'r') as f:
            LOGGER.info('Loading config')
            self.config = ExperimentConfig(
                toml.load(f, _dict=RecursiveNestedDict))

        LOGGER.warning('Loaded config from %s', config)
        LOGGER.warning('Output directory: %s', output_dir)

        self.clients = list()
        self.host = host
        self.port = port
        self.tcpdump_proc = None
        self.output_dir = output_dir

        self.backend_mgr = BackendManager(self.config)

        if self.config.gen_load:
            self.load_mgr = CPULoadManager(self.config)
        else:
            self.load_mgr = NullCPULoadManager()

        self.ntp_client = ntplib.NTPClient()
        self.offset = 0

        LOGGER.info('Experiment ID: %s', self.config.name)
        LOGGER.info('Clients: %d', self.config.clients)
        LOGGER.info('Runs: %d', self.config.runs)
Ejemplo n.º 2
0
    def shutdown(self, e=None):
        LOGGER.warning('Shut down!')

        if e:
            LOGGER.critical(e)

        try:
            for client in self.clients:
                client.shutdown()
        except Exception as e:
            LOGGER.error('Something went wrong while shutting down clients')
            LOGGER.error(e)

        try:
            if self.tcpdump_proc:
                self.tcpdump_proc.send_signal(signal.SIGINT)
        except Exception as e:
            LOGGER.error('Something went wrong while shutting down TCPDUMP')
            LOGGER.error(e)

        try:
            if self.backend_mgr:
                self.backend_mgr.shutdown()
        except Exception as e:
            LOGGER.error(
                'Something went wrong while shutting down Docker containers')
            LOGGER.error(e)
Ejemplo n.º 3
0
    def shutdown(self):
        # not asynchronous by design
        LOGGER.warning(f'Shutting down client %d...', self.config['client_id'])

        # wait for worker thread to finish the current task
        self.shutdown_flag.set()
        self.worker.join()

        buf = struct.pack('>I', constants.CMD_SHUTDOWN)
        self.conn.sendall(buf)
        self.conn.shutdown(socket.SHUT_RDWR)
        self.conn.close()

        LOGGER.warning(f'Client %d shut down.', self.config['client_id'])
Ejemplo n.º 4
0
 def shutdown(self):
     LOGGER.warning('Shutting down containers...')
     for cont in self.containers:
         cont.kill()
     LOGGER.warning('Containers shut down!')