Exemplo n.º 1
0
 def translate_delegation_to_avro(*, delegation: ABCDelegation) -> DelegationAvro:
     avro_delegation = DelegationAvro()
     avro_delegation.delegation_id = delegation.get_delegation_id()
     avro_delegation.state = delegation.get_state().value
     avro_delegation.slice = Translate.translate_slice_to_avro(slice_obj=delegation.get_slice_object())
     if delegation.get_graph() is not None and not (delegation.is_reclaimed() or delegation.is_closed()):
         avro_delegation.graph = delegation.get_graph().serialize_graph()
     return avro_delegation
Exemplo n.º 2
0
 def update_delegation(self, *, delegation: ABCDelegation):
     # Update the delegation only when there are changes to be reflected in database
     if not delegation.is_dirty():
         return
     delegation.clear_dirty()
     try:
         self.lock.acquire()
         self.logger.debug("Updating delegation {} in slice {}".format(
             delegation.get_delegation_id(), delegation.get_slice_id()))
         properties = pickle.dumps(delegation)
         self.db.update_delegation(dlg_graph_id=str(
             delegation.get_delegation_id()),
                                   dlg_state=delegation.get_state().value,
                                   properties=properties)
     finally:
         self.lock.release()
Exemplo n.º 3
0
    def add_delegation(self, *, delegation: ABCDelegation):
        self.logger.debug("Adding delegation {} to slice {}".format(
            delegation.get_delegation_id(), delegation.get_slice_id()))

        slc_id = self.get_slice_id_from_guid(
            slice_id=delegation.get_slice_id())
        if slc_id is None:
            raise DatabaseException("Slice with id: {} not found".format(
                delegation.get_slice_id()))

        try:
            self.lock.acquire()
            properties = pickle.dumps(delegation)
            self.db.add_delegation(dlg_slc_id=slc_id,
                                   dlg_graph_id=str(
                                       delegation.get_delegation_id()),
                                   dlg_state=delegation.get_state().value,
                                   properties=properties)
            self.logger.debug("Delegation {} added to slice {}".format(
                delegation.get_delegation_id(), delegation.get_slice_id()))
        finally:
            self.lock.release()
Exemplo n.º 4
0
 def revisit_delegation(self, *, delegation: ABCDelegation):
     if delegation.get_state() == DelegationState.Delegated:
         self.bind_delegation(delegation=delegation)