Ejemplo n.º 1
0
class JournalerConnection(log.Logger, log.LogProxy):
    implements(IJournalerConnection)

    def __init__(self, journaler, externalizer):
        log.LogProxy.__init__(self, journaler)
        log.Logger.__init__(self, self)

        self.serializer = banana.Serializer(externalizer=externalizer)
        self.snapshot_serializer = banana.Serializer()
        self.journaler = IJournaler(journaler)

    ### IJournalerConnection ###

    def new_entry(self, agent_id, instance_id, journal_id, function_id,
                  *args, **kwargs):
        record = self.journaler.prepare_record()
        entry = AgencyJournalEntry(
            self.serializer, record, agent_id, instance_id,
            journal_id, function_id, *args, **kwargs)
        return entry

    def get_filename(self):
        return self.journaler.get_filename()

    def snapshot(self, agent_id, instance_id, snapshot):
        record = self.journaler.prepare_record()
        entry = AgencyJournalEntry(
            self.snapshot_serializer, record, agent_id, instance_id,
            'agency', 'snapshot', snapshot)
        entry.set_result(None)
        entry.commit()
        f = entry.get_result()
        if f:
            self.error('Error snapshoting the agent: %r. It will produce '
                       'manlformed snapshot.', f.trigger_param)
Ejemplo n.º 2
0
    def __init__(self, journaler, externalizer):
        log.LogProxy.__init__(self, journaler)
        log.Logger.__init__(self, self)

        self.serializer = banana.Serializer(externalizer=externalizer)
        self.snapshot_serializer = banana.Serializer()
        self.journaler = IJournaler(journaler)