Esempio n. 1
0
class Data(models.Model):
    id = models.CharField(_(u"节点 ID"), unique=True, primary_key=True, max_length=32)
    inputs = IOField(verbose_name=_(u"输入数据"))
    outputs = IOField(verbose_name=_(u"输出数据"))
    ex_data = IOField(verbose_name=_(u"异常数据"))

    objects = DataManager()
Esempio n. 2
0
class HistoryData(models.Model):
    id = models.BigAutoField(_(u"ID"), primary_key=True)
    inputs = IOField(verbose_name=_(u"输入数据"))
    outputs = IOField(verbose_name=_(u"输出数据"))
    ex_data = IOField(verbose_name=_(u"异常数据"))

    objects = DataManager()
Esempio n. 3
0
class ScheduleService(models.Model):
    SCHEDULE_ID_SPLIT_DIVISION = 32

    id = models.CharField(_(u"ID 节点ID+version"), max_length=NAME_MAX_LENGTH, unique=True, primary_key=True)
    activity_id = models.CharField(_(u"节点 ID"), max_length=32, db_index=True)
    process_id = models.CharField(_(u"Pipeline 进程 ID"), max_length=32)
    schedule_times = models.IntegerField(_(u"被调度次数"), default=0)
    wait_callback = models.BooleanField(_(u"是否是回调型调度"), default=False)
    callback_data = IOField(verbose_name=_(u"回调数据"), default=None)
    service_act = IOField(verbose_name=_(u"待调度服务"))
    is_finished = models.BooleanField(_(u"是否已完成"), default=False)
    version = models.CharField(_(u"Activity 的版本"), max_length=32, db_index=True)
    is_scheduling = models.BooleanField(_(u"是否正在被调度"), default=False)

    objects = ScheduleServiceManager()

    def set_next_schedule(self):
        if self.wait_callback:
            raise exceptions.InvalidOperationException('can\'t set next schedule on callback schedule.')
        count_down = self.service_act.service.interval.next()
        self.is_scheduling = False
        self.save()
        ScheduleCeleryTask.objects.unbind(self.id)

        valve.send(signals, 'schedule_ready', sender=ScheduleService, process_id=self.process_id,
                   schedule_id=self.id,
                   countdown=count_down)

    def destroy(self):
        schedule_id = self.id
        self.delete()
        data_service.delete_parent_data(schedule_id)
        ScheduleCeleryTask.objects.destroy(schedule_id)

    def finish(self):
        self.is_finished = True
        self.service_act = None
        self.is_scheduling = False
        self.save()
        ScheduleCeleryTask.objects.destroy(self.id)

    def callback(self, callback_data, process_id):
        if not self.wait_callback:
            raise exceptions.InvalidOperationException('can\'t callback a poll schedule.')

        self.callback_data = callback_data
        self.save()
        valve.send(signals, 'schedule_ready', sender=ScheduleService, process_id=process_id, schedule_id=self.id,
                   countdown=0)
Esempio n. 4
0
class LoopActivityScheduleHistory(models.Model):
    schedule_id = models.CharField(_(u"ID 节点ID+version"), max_length=64)
    activity_id = models.CharField(_(u"节点 ID"), max_length=32, db_index=True)
    schedule_times = models.IntegerField(_(u"被调度次数"), default=0)
    wait_callback = models.BooleanField(_(u"是否是回调型调度"), default=False)
    callback_data = IOField(verbose_name=_(u"回调数据"), default=None)
    version = models.CharField(_(u"Activity 的版本"), max_length=32, db_index=True)
    current_loop = models.PositiveIntegerField(_(u"当前调度所处的循环计数"))

    objects = LoopActivityScheduleHistoryManager()
Esempio n. 5
0
class ProcessSnapshot(models.Model):
    data = IOField(verbose_name=_(u"pipeline 运行时数据"))

    objects = ProcessSnapshotManager()

    @property
    def pipeline_stack(self):
        return self.data['_pipeline_stack']

    @property
    def children(self):
        return self.data['_children']

    @property
    def root_pipeline(self):
        return self.data['_root_pipeline']

    @property
    def subprocess_stack(self):
        return self.data['_subprocess_stack']

    def clean_children(self):
        self.data['_children'] = []
Esempio n. 6
0
class DataSnapshot(models.Model):
    key = models.CharField(_(u"对象唯一键"), max_length=255, primary_key=True)
    obj = IOField(verbose_name=_(u"对象存储字段"))

    objects = DataSnapshotManager()
Esempio n. 7
0
class HistoryData(models.Model):
    inputs = IOField(verbose_name=_(u"输入数据"))
    outputs = IOField(verbose_name=_(u"输出数据"))
    ex_data = IOField(verbose_name=_(u"异常数据"))

    objects = DataManager()