Ejemplo n.º 1
0
class DistributedQueryResult(SurrogatePK, Model):

    columns = Column(JSONB)
    timestamp = Column(db.DateTime, default=dt.datetime.utcnow)

    distributed_query_task_id = reference_col('distributed_query_task',
                                              nullable=False)
    distributed_query_task = relationship(
        'DistributedQueryTask',
        backref=db.backref('results',
                           cascade='all, delete-orphan',
                           lazy='joined'),
    )

    distributed_query_id = reference_col('distributed_query', nullable=False)
    distributed_query = relationship(
        'DistributedQuery',
        backref=db.backref('results',
                           cascade='all, delete-orphan',
                           lazy='joined'),
    )

    def __init__(self,
                 columns,
                 distributed_query=None,
                 distributed_query_task=None):
        self.columns = columns
        self.distributed_query = distributed_query
        self.distributed_query_task = distributed_query_task
Ejemplo n.º 2
0
class StatusLog(SurrogatePK, Model):

    line = Column(db.Integer)
    message = Column(db.String)
    severity = Column(db.Integer)
    filename = Column(db.String)
    created = Column(db.DateTime, default=dt.datetime.utcnow)
    version = Column(db.String)

    node_id = reference_col('node', nullable=False)
    node = relationship('Node',
                        backref=db.backref('status_logs', lazy='dynamic'))

    def __init__(self,
                 line=None,
                 message=None,
                 severity=None,
                 filename=None,
                 created=None,
                 node=None,
                 version=None,
                 **kwargs):
        self.line = int(line)
        self.message = message
        self.severity = int(severity)
        self.filename = filename
        self.created = created
        self.node = node
        self.version = version
Ejemplo n.º 3
0
class ResultLog(SurrogatePK, Model):

    name = Column(db.String, nullable=False)
    timestamp = Column(db.DateTime, default=dt.datetime.utcnow)
    action = Column(db.String)
    columns = Column(JSONB)

    node_id = reference_col('node', nullable=False)
    node = relationship('Node',
                        backref=db.backref('result_logs', lazy='dynamic'))

    def __init__(self,
                 name=None,
                 action=None,
                 columns=None,
                 timestamp=None,
                 node=None,
                 node_id=None,
                 **kwargs):
        self.name = name
        self.action = action
        self.columns = columns or {}
        self.timestamp = timestamp
        if node:
            self.node = node
        elif node_id:
            self.node_id = node_id

    @declared_attr
    def __table_args__(cls):
        return (Index('idx_%s_node_id_timestamp_desc' % cls.__tablename__,
                      'node_id', cls.timestamp.desc()), )
Ejemplo n.º 4
0
class ResultLog(SurrogatePK, Model):

    name = Column(db.String, nullable=False)
    timestamp = Column(db.DateTime, default=dt.datetime.utcnow)
    action = Column(db.String)
    columns = Column(JSONB)

    node_id = reference_col('node', nullable=False)
    node = relationship('Node',
                        backref=db.backref('result_logs', lazy='dynamic'))

    def __init__(self,
                 name=None,
                 action=None,
                 columns=None,
                 timestamp=None,
                 node=None,
                 node_id=None,
                 **kwargs):
        self.name = name
        self.action = action
        self.columns = columns or {}
        self.timestamp = timestamp
        if node:
            self.node = node
        elif node_id:
            self.node_id = node_id
Ejemplo n.º 5
0
class StatusLog(SurrogatePK, Model):

    line = Column(db.Integer)
    message = Column(db.String)
    severity = Column(db.Integer)
    filename = Column(db.String)
    created = Column(db.DateTime, default=dt.datetime.utcnow)
    version = Column(db.String)

    node_id = reference_col('node', nullable=False)
    node = relationship(
        'Node',
        backref=db.backref('status_logs', lazy='dynamic')
    )

    def __init__(self, line=None, message=None, severity=None,
                 filename=None, created=None, node=None, node_id=None,
                 version=None, **kwargs):
        self.line = int(line)
        self.message = message
        self.severity = int(severity)
        self.filename = filename
        self.created = created
        self.version = version
        if node:
            self.node = node
        elif node_id:
            self.node_id = node_id

    @declared_attr
    def __table_args__(cls):
        return (
            Index('idx_%s_node_id_created_desc' % cls.__tablename__,
                'node_id', cls.created.desc()),
        )
Ejemplo n.º 6
0
class DistributedQueryTask(SurrogatePK, Model):

    NEW = 0
    PENDING = 1
    COMPLETE = 2
    FAILED = 3

    guid = Column(db.String, nullable=False, unique=True)
    status = Column(db.Integer, default=0, nullable=False)
    timestamp = Column(db.DateTime)

    distributed_query_id = reference_col('distributed_query', nullable=False)
    distributed_query = relationship(
        'DistributedQuery',
        backref=db.backref('tasks',
                           cascade='all, delete-orphan',
                           lazy='dynamic'),
    )

    node_id = reference_col('node', nullable=False)
    node = relationship(
        'Node',
        backref=db.backref('distributed_queries', lazy='dynamic'),
    )

    def __init__(self,
                 node=None,
                 node_id=None,
                 distributed_query=None,
                 distributed_query_id=None):
        self.guid = str(uuid.uuid4())
        if node:
            self.node = node
        elif node_id:
            self.node_id = node_id
        if distributed_query:
            self.distributed_query = distributed_query
        elif distributed_query_id:
            self.distributed_query_id = distributed_query_id

    @declared_attr
    def __table_args__(cls):
        return (Index('idx_%s_node_id_status' % cls.__tablename__, 'node_id',
                      'status'), )
Ejemplo n.º 7
0
class DistributedQueryResult(SurrogatePK, Model):

    data = Column(JSONBType)
    timestamp = Column(db.DateTime, default=dt.datetime.utcnow)

    distributed_query_id = reference_col('distributed_query', nullable=False)
    distributed_query = relationship(
        'DistributedQuery',
        backref=db.backref('result',
                           uselist=False,
                           cascade='all, delete-orphan',
                           lazy='joined'),
    )

    def __init__(self, data, distributed_query=None):
        self.data = data
        self.distributed_query = distributed_query
Ejemplo n.º 8
0
class DistributedQuery(SurrogatePK, Model):

    NEW = 0
    PENDING = 1
    COMPLETE = 2

    guid = Column(db.String, nullable=False, unique=True)
    status = Column(db.Integer, default=0, nullable=False)
    sql = Column(db.String, nullable=False)
    timestamp = Column(db.DateTime, default=dt.datetime.utcnow)

    node_id = reference_col('node', nullable=False)
    node = relationship(
        'Node',
        backref=db.backref('distributed_queries', lazy='dynamic'),
    )

    def __init__(self, sql, node=None):
        self.guid = str(uuid.uuid4())
        self.sql = sql
        self.node = node
Ejemplo n.º 9
0
class ResultLog(SurrogatePK, Model):

    name = Column(db.String, nullable=False)
    timestamp = Column(db.DateTime, default=dt.datetime.utcnow)
    added = Column(JSONBType)
    removed = Column(JSONBType)

    node_id = reference_col('node', nullable=False)
    node = relationship('Node',
                        backref=db.backref('result_logs', lazy='dynamic'))

    def __init__(self,
                 name=None,
                 timestamp=None,
                 added=None,
                 removed=None,
                 node=None):
        self.name = name
        self.timestamp = timestamp
        self.added = added
        self.removed = removed
        self.node = node