def updateConfig(self, config, outqueue): self.config = config self.outputQueue = outqueue # TODO: Figure out if this maxQueueLength needs to even be set here. I think this should exist on the output # process and the generator shouldn't have anything to do with this. self.outputPlugin = self.config.getPlugin('output.' + self._sample.outputMode, self._sample) if self._sample.maxQueueLength == 0: self._sample.maxQueueLength = self.outputPlugin.MAXQUEUELENGTH # Output = output process, not the plugin. The plugin is loaded by the output process. self._out = Output(self._sample) self._out.updateConfig(self.config) if self.outputPlugin.useOutputQueue or self.config.useOutputQueue: self._out._update_outputqueue(self.outputQueue)
def __init__(self, sample): # Logger already setup by config, just get an instance logger = logging.getLogger('eventgen') from eventgenconfig import EventgenAdapter adapter = EventgenAdapter(logger, {'module': 'GeneratorPlugin', 'sample': sample.name}) self.logger = adapter from eventgenconfig import Config globals()['c'] = Config() # # 2/10/14 CS Make a threadsafe copy of all of the samples for us to work on # with c.copyLock: # # 10/9/15 CS Moving this to inside the lock, in theory, there should only be one thread # # trying to start at once, going to try to ensure this is the case and hoping for no deadlocks # while c.pluginsStarting.value() > 0: # self.logger.debug("Waiting for exclusive lock to start for GeneratorPlugin '%s'" % sample.name) # time.sleep(0.1) # c.pluginsStarting.increment() self.logger.debug("GeneratorPlugin being initialized for sample '%s'" % sample.name) self._out = Output(sample) # # 9/6/15 Don't do any work until all the timers have started # while c.timersStarted.value() < len(c.sampleTimers): # self.logger.debug("Not all timers started, sleeping for GeneratorPlugin '%s'" % sample.name) # time.sleep(1.0) self._samples = { } for s in c.samples: news = copy.copy(s) news.tokens = [ copy.copy(t) for t in s.tokens ] for setting in c._jsonSettings: if setting in s.__dict__: setattr(news, setting, getattr(s, setting)) self._samples[news.name] = news # self._samples = dict((s.name, copy.deepcopy(s)) for s in c.samples) self._sample = sample